@extends('layouts.print')

@section('header')
<p class="header-text">
    @foreach (Session::get('semesters_info') as $index => $semester_info)
        {{ $semester_info }}
        @if($index+1 != count(Session::get('semesters_info')))
        <strong>&#183;</strong>
        @endif
    @endforeach
</p>
<p class="header-text">Program Assessment Results</p>
<h1 class="header-text">{{{ $program->name}}}</h1>
@stop

@section('main')

<div id="graph"></div>

<h3>Courses</h3>
@if($program_courses->count()>0)
    <table>
        <thead>
            <tr>
                <th>Identifier</th>
                <th>Name</th>
                <th>Assessed and Published</th>
            </tr>
        </thead>
        <tbody>
            @foreach($grouped_courses as $grouped_course)
                <tr>
                    <td>{{ $grouped_course->code.$grouped_course->number.' ('.$grouped_course->semester->code.')' }}</td>
                    <td>{{{ $grouped_course->name}}}</td>
                    <td>
                        @if($grouped_course->outcomes_attempted!=NULL)
                            <span class="glyphicon glyphicon-ok"></span>
                        @endif
                    </td>
                </tr>
            @endforeach
        </tbody>
    </table>
@else
    <p class="lead"> No courses assigned.</p>
@endif

<h3>Sections</h3>
@if($program_courses->count()>0)
    <p class="lead"> {{{ $assessed_courses_count }}} out of {{{ $program_courses->count() }}} section(s) doing Assessment ({{{ round($assessed_courses_count/$program_courses->count()*100, 2) }}}%)</p>
    <table>
        <thead>
            <tr>
                <th>Identifier</th>
                <th>Name</th>
                <th>Professor</th>
                <th>Assessed Activities</th>
                <th>Published Results</th>
            </tr>
        </thead>
        <tbody>
            @foreach($program_courses as $course)
            <tr>
                <td>{{ $course->code.$course->number.'-'.$course->section.' ('.$course->semester->code.')' }}</td>
                <td>{{{ $course->name}}}</td>
                <td>{{{ $course->user->surnames }}}, {{{ $course->user->first_name }}}</td>
                <td>
                    @if(count($course->assessedActivities))
                        <span class="glyphicon glyphicon-ok"></span>
                    @endif
                </td>
                <td>
                    @if(count($course->publishedActivities))
                        <span class="glyphicon glyphicon-ok"></span>
                    @endif
                </td>
            </tr>
            @endforeach
        </tbody>
    </table>
@else
    <p class="lead"> No sections assigned.</p>
@endif


<!-- =================== end tabs =================== -->

@stop

@section('included-js')

<!-- HighCharts -->
<script src="{{ asset('vendor/highcharts/highcharts.js') }}"></script>
<!--script src="http://code.highcharts.com/modules/exporting.js"></script -->

@stop

@section('javascript')

$('#graph').highcharts({
    chart: {
        type: 'bar'
    },
    title: {
        text: 'Performance by Learning Outcome Criteria in {{ $program->name }} Program'
    },
    legend: {
        reversed: true,
    },
    xAxis: {
        categories: [
            @foreach($outcomes as $outcome)
                "{{{ $outcome->name }}}",
            @endforeach
        ],
        labels: {
            style: {
                fontSize:'11px'
            },
            step:1,
            useHTML:true,
            formatter: function() {
                return '<div style="width:100px; word-break:break; text-overflow:ellipsis; overflow:hidden;">'+this.value+'</div>';
            },
        }
    },
    yAxis: {
        min: 0,
        max: 100,
        title: {
            text: 'Percentage'
        }
    },
    tooltip: {
        enabled:false
    },
    plotOptions: {
            bar: {
                //grouping: false,
                shadow: false,
                borderWidth: 0,
            },
            series: {
                pointPadding: 0,
                groupPadding: 0.075,
                animation: false
            },
        },
    series: [{
        name: 'Expected Value',
        color: '#555555',
        dataLabels: {
            enabled: true,
            fontSize: 8,
            color: '#fff',
            align: 'right',
            format: '{y:.1f}%',
            style: {
                //fontWeight: 'bold'
            },
            y:-1
        },
        data: [
            @foreach($outcomes as $index => $outcome)
                @if(
                    is_array($outcomes_attempted)
                    && array_key_exists($outcome->id, $outcomes_attempted)
                    && $outcomes_attempted[$outcome->id]!=0)
                    {{{ $outcome->expected_outcome }}},
                @else
                    0,
                @endif
            @endforeach
        ]

    },{
        name: 'Obtained Value',
        color: '#e70033',
        dataLabels: {
            enabled: true,
            fontSize: 8,
            color: '#fff',
            align: 'right',
            format: '{y:.1f}%',
            style: {
                //fontWeight: 'bold'
            },
            y:-1
        },
        data:[
            @foreach($outcomes as $index => $outcome)
                @if(
                    is_array($outcomes_attempted)
                    && array_key_exists($outcome->id, $outcomes_attempted)
                    && $outcomes_attempted[$outcome->id]!=0)
                    {{{ ($outcomes_achieved[$outcome->id]/$outcomes_attempted[$outcome->id])*100 }}},
                @else
                    0,
                @endif
            @endforeach

        ]
    }]
});

@stop
