@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 class="row">
    <div class="col-md-8" id="graph_undergrad_combined"></div>
</div>

        <div class="row">
            <div class="col-md-8">
                <h3>Performance of {{ $program->name }} Students by Learning Outcome</h3>
                @if($outcomes->count()>0)
                    <table class="table table-striped table-condensed">
                        <thead>
                            <tr>
                                <th>Program Id</th>
                                <th>Program Is Graduate</th>
                                <th>Learning Outcome</th>
                                <th>Number Students</th>
                                <th>Number Students that Achieved the Target</th>
                                <th>Percentage of Students that Achieved the Target</th>
                            </tr>
                        </thead>
                        
                        <tbody>
                            @foreach($outcomes_colap as $outcome)
                                @if(isset($outcomes_attempted_colap[$outcome->id]))
                              <tr>
                                    <td>{{{ $program->id }}}</td>
                                    <td>{{{ $program->is_graduate }}}</td>
                                    <td>{{  $outcome->name }}</td>
                                    <td>{{{ $outcomes_attempted_colap[$outcome->id] }}}</td>
                                    <td>{{{ $outcomes_achieved_colap[$outcome->id] }}}</td>
                                    <td>
                                        @if($outcomes_attempted_colap[$outcome->id]!=0)
                                            {{{ round($outcomes_achieved_colap[$outcome->id] / $outcomes_attempted_colap[$outcome->id]*100, 2) }}}%
                                        @else
                                            N/M
                                        @endif
                                    </td>
                                </tr>
                                @endif
                            @endforeach
                        </tbody>
                    </table>
                @else
                    <p class="lead"> No courses assigned.</p>
                @endif
            </div>
        </div>

        <div class="row">
            <div class="col-md-8">
                <h3>Courses in this program</h3>
                @if(count($grouped_courses)>0)
                    <table class="table table-striped table-condensed">
                        <thead>
                            <tr>
                                <th>Identifier</th>
                                <th>Name</th>
                                <th>Course Program</th>
                                <th>Number of Students</th>
                            </tr>
                        </thead>
                        
                        <tbody>
                            @foreach($grouped_courses as $grouped_course)
                                <tr>
                                    <td class="col-md-2">{{  $grouped_course->code.$grouped_course->number.' ('.$grouped_course->semester->code.')' }}</td>
                                    <td class="col-md-4">{{{ $grouped_course->name}}}</td>
                                    <td class="col-md-2">{{{ $grouped_course->program->code}}}</td>
                                    <td class="col-md-3">{{{ $grouped_course->quantity }}}</td>
                                </tr>
                            @endforeach
                        </tbody>
                    </table>
                @else
                    <p class="lead"> No courses assigned.</p>
                @endif
            </div>
        </div>




<!-- =================== 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_undergrad_combined').highcharts({
    chart: {
        type: 'bar'
    },
    title: {
        text: 'Performance of {{ $program->name }} Students by Learning Outcome'
    },
    legend: {
                reversed: true,
            },
    xAxis: {
        categories: [
            @foreach($outcomes_colap as $outcome)
                "{{{ $outcome->name }}}<br>(N = {{{ $outcomes_attempted_colap[$outcome->id] }}}, {{{ $outcomes_achieved_colap[$outcome->id] }}})",
            @endforeach
        ],
        labels: {
            style: {
                fontSize:'11px'
            },
            step:1,
            useHTML:true,
            formatter: function() {
                return '<div style="width:200px; word-break:break; text-overflow:ellipsis; overflow:hidden;">'+this.value+'</div>';
            },
        }
    },
    yAxis: {
        min: 0,
        max: 100,
        title: {
            text: 'Percentage'
        },        @if($program->expected_outcome_target == null)
        plotLines:[{
    value:70,
    color: '#000',
    width:3,
    zIndex:4,
    label:{
        text: 'Goal (70%)',
        style: {
            color: '#000',
            fontSize: '14px',
        }

    }
}]
@else
plotLines:[{
    value:{{$program->expected_outcome_target->expected_target}},
    color: '#000',
    width:3,
    zIndex:4,
    label:{
        text: 'Goal ({{$program->expected_outcome_target->expected_target}}%)',
        style: {
            color: '#000',
            fontSize: '14px',
        }

    }
}]
@endif

    },
    tooltip: {
        headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
        pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
            '<td style="padding:0"><b>{point.y:.2f}</b></td></tr>',
        footerFormat: '</table>',
        shared: true,
        useHTML: true
    },
    plotOptions: {
        bar: {
            //grouping: false,
            shadow: false,
            borderWidth: 0,
        },
        series: {
        pointPadding: 0,
        groupPadding: 0.075
        },
    },
    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_colap as $index => $outcome)
                @if(
                    is_array($outcomes_attempted_colap)
                    && array_key_exists($outcome->id, $outcomes_attempted_colap)
                    && $outcomes_attempted_colap[$outcome->id]!=0)
                @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_colap as $index => $outcome)
                @if(
                    is_array($outcomes_attempted_colap)
                    && array_key_exists($outcome->id, $outcomes_attempted_colap)
                    && $outcomes_attempted_colap[$outcome->id]!=0)
                    {{{ ($outcomes_achieved_colap[$outcome->id]/$outcomes_attempted_colap[$outcome->id])*100 }}},
                @else
                    0,
                @endif
            @endforeach
        ]
    }]
});



@stop