@extends('layouts.master')

@section('css')
    {{ HTML::style('vendor/jquery-ui-1.11.4.custom/jquery-ui.min.css') }}
    {{ HTML::style('vendor/jquery-ui-1.11.4.custom/jquery-ui.theme.min.css') }}
@stop

@section('navigation')
    @if ($role == 1)
        @include('local.managers.admins._new_navigation')
    @elseif($role == 2)
        @include('local.managers.sCoords._new_navigation')
    @elseif($role == 3)
        @include('local.managers.pCoords._new_navigation')
    @else
        @include('local.professors._navigation')
    @endif
@stop


@section('main')










    <div class="row">
        <ul id='levelTabs' class="nav nav-tabs" role="tablist">
            <!-- For each grouped course -->


            <li role="presentation" class='first'>
                <a data-toggle="tab" href="#activity_1"
                    role="tab">{{ strlen($activity_1->name) > 50 ? substr($activity_1->name, 0, 50) . '...' : $activity_1->name }}</a>
            </li>
            <li role="presentation">
                <a data-toggle="tab" href="#activity_2"
                    role="tab">{{ strlen($activity_2->name) > 50 ? substr($activity_2->name, 0, 50) . '...' : $activity_2->name }}</a>
            </li>


        </ul>
        <div id="allLists" class="tab-content">
            <div role="tabpanel" class='tab-pane first' id="activity_1">
                <h3 style="text-align: center">Performance by Learning Outcome Criteria in {{ $activity_1->name }}</h3>
                <hr>
                <div class="col-md-9" id="graph_1"></div>

            </div>

            <div role="tabpanel" class='tab-pane' id="activity_2">
                <h3 style="text-align: center">Performance by Learning Outcome Criteria in {{ $activity_2->name }}</h3>
                <hr>
                <div class="col-md-9" id="graph_2"></div>

            </div>

        </div>
    </div>
    <div class="row">

        <ul id='levelTabs' class="nav nav-tabs" role="tablist">
            <!-- For each grouped course -->


            <li role="presentation" class="first">
                <a data-toggle="tab" href="#activity_criteriaGraph_1"
                    role="tab">{{ strlen($activity_1->name) > 50 ? substr($activity_1->name, 0, 50) . '...' : $activity_1->name }}</a>
            </li>
            <li role="presentation">
                <a data-toggle="tab" href="#activity_criteriaGraph_2"
                    role="tab">{{ strlen($activity_2->name) > 50 ? substr($activity_2->name, 0, 50) . '...' : $activity_2->name }}</a>
            </li>


        </ul>
        <div id="allLists" class="tab-content">
            <div role="tabpanel" class='tab-pane first' id="activity_criteriaGraph_1">
                <h3 style="text-align: center">Criteria Achievement {{ $activity_1->name }}</h3>
                <hr>
                <div class="col-md-9" id="criteriaGraph_1">

                </div>
            </div>
            <div role="tabpanel" class='tab-pane' id="activity_criteriaGraph_2">
                <h3 style="text-align: center">Criteria Achievement {{ $activity_2->name }}</h3>
                <hr>
                <div class="col-md-9" id="criteriaGraph_2">

                </div>
            </div>
        </div>
    </div>
    <div class="row">

        <ul id='levelTabs' class="nav nav-tabs" role="tablist">
            <!-- For each grouped course -->


            <li role="presentation" class="first">
                <a data-toggle="tab" href="#activity_tabla_1"
                    role="tab">{{ strlen($activity_1->name) > 50 ? substr($activity_1->name, 0, 50) . '...' : $activity_1->name }}</a>
            </li>
            <li role="presentation">
                <a data-toggle="tab" href="#activity_tabla_2"
                    role="tab">{{ strlen($activity_2->name) > 50 ? substr($activity_2->name, 0, 50) . '...' : $activity_2->name }}</a>
            </li>


        </ul>
        <div id="allLists" class="tab-content">
            <div role="tabpanel" class='tab-pane first' id="activity_tabla_1">


                <h3 style="text-align: center;">{{ $activity_1->name }} </h3>

                <br>
                <br>
                <h5 style="display: inline;">Date: </h5>
                <p style="display: inline;">
                    <strong>({{ $activity_1->date }})</strong>
                </p>
                <br>

                <h5 style="display: inline;">Performance Indicators: </h5>
                <?php
                Log::info($activity_1->rubric[0]);
                ?>
                <p style="display: inline;"><i>{{ $activity_1->rubric[0]->num_scales }} (
                        <?php
                        $titles = $activity_1->rubric[0]->getTitles();
                        ?>
                        @if (sizeof($titles) != 1)
                            @foreach ($titles as $index5 => $rubric_title)
                                @if ($index5 != $activity_1->rubric[0]->num_scales - 1)
                                    {{ $rubric_title->text }},
                                @else
                                    and {{ $rubric_title->text }}
                                @endif
                            @endforeach
                            )
                        @else
                            {{ $titles[0]->text }} )
                        @endif
                    </i></p>
                <br>
                <h5 style="display: inline;">Scale: </h5>
                @if ($activity_1->rubric[0]->max_score == 1)
                    <p style="display: inline;">1 point scale</p>
                @else
                    <p style="display: inline;">1-{{ $activity_1->rubric[0]->max_score }} point scale</p>
                @endif
                <br>
                <br>
                <h4>Performance of Students by Learning Outcome Criteria</h4>
                <h5 style="display: inline; margin:30px;">Target by criterion: </h5>
                <p style="display: inline;"> <i>{{ $activity_1->rubric[0]->expected_points }} or more</i>
                </p>
                <br>
                <h5 style="display: inline; margin:30px;">Expected percent of students achieving the
                    target by criterion: </h5>
                <p style="display: inline;"> <i>{{ $activity_1->rubric[0]->expected_percentage }} %</i>
                </p>
                <br>
                <table class='table table-striped table-condensed datatable'>
                    <thead>
                        <tr>
                            <th>
                                Criterion
                            </th>
                            <th>
                                Number of Students Assessed
                            </th>
                            <th>
                                Number of students that achieved the target
                            </th>
                            <th>
                                %
                            </th>
                            <th>
                                Learning Outcomes
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach ($activity_1->allActivityCriterionInfo() as $index5 => $ac_criterion)
                            <tr>
                                <td> {{ $ac_criterion->name }}</td>
                                <td>{{ Criterion::students_attempted($ac_criterion->criterion_id, $activity_1->id) }}
                                </td>
                                <td>
                                    {{ Criterion::students_achieved($ac_criterion->criterion_id, $activity_1->id) }}

                                </td>
                                <?php
                                
                                $out_att = Criterion::students_attempted($ac_criterion->criterion_id, $activity_1->id);
                                $out_ach = Criterion::students_achieved($ac_criterion->criterion_id, $activity_1->id);
                                
                                $percentage = 'N/A';
                                $activity_1->getOutcomeReport();
                                
                                ?>
                                @if ($out_att == 0)
                                    <td class="col-md-1 danger">{{ $percentage }}</td>
                                @else
                                    <?php
                                    $percentage = round(($out_ach / $out_att) * 100, 2);
                                    ?>
                                    @if ($percentage >= $activity_1->rubric[0]->expected_percentage)
                                        <td class="col-md-1 success">{{ $percentage }}%</td>
                                    @else
                                        <td class="col-md-1 danger">{{ $percentage }}%</td>
                                    @endif
                                @endif
                                <td>

                                    @foreach (Criterion::outcomes($ac_criterion->criterion_id) as $index6 => $outcome)
                                        {{ $index6 + 1 }}. <?php echo $outcome->name . "\n\n\n <br>"; ?>
                                    @endforeach


                                </td>
                            </tr>
                        @endforeach
                    </tbody>

                </table>

                <h5 style="display: inline; margin:30px;">Formative Actions: </h5>
                <?php $formative_actions = $activity_1->formativeActionsWithCriteria(); ?>
                @if ($formative_actions)
                    <p style="display: inline;"> <u>{{ $formative_actions[0]->at_text }}:
                        </u>

                        <i>{{ $formative_actions[0]->description }}
                        </i>
                    </p>
                    <br>
                    <h5 style="display: inline; margin:30px;">Formative Action's Associated
                        Criteria: </h5>
                    <ul style=" margin:30px;">
                        @foreach ($formative_actions as $criteria)
                            <li> <i>{{ $criteria->name }} </i></li>
                        @endforeach
                    </ul>
                @endif


                <h5 style="display: inline; margin:30px;">Assessment Comments: </h5>
                @if ($activity_1->assessment_comments != null)
                    <p style="display: inline;">{{ $activity_1->assessment_comments }}</p>
                @endif
                <hr>
                <br>

                <h4>Performance of Students by Learning Outcome</h4>

                <h5 style="text-align: center;">{{ $activity_1->name }} </h5>
                <h5 style="display: inline; margin:30px;">Target by learning outcome: </h5>
                <p style="display: inline;"> <i>>= 66.67% of the attempts</i>
                </p>
                <br>
                <h5 style="display: inline; margin:30px;">Expected percent of students achieving the
                    target by learning outcome: </h5>
                <p style="display: inline;"> <i>
                        <?php
                        $expected = DB::table('target_outcomes_program')
                            ->where('program_id', $course->program_id)
                            ->where('semester_id', $course->semester_id)
                            ->first();
                        if (!$expected) {
                            $expected = 'It has not been defined in the annual plan';
                        } else {
                            $expected = $expected->expected_target;
                        }
                        
                        ?>
                        {{ $expected }}

                    </i>
                </p>
                <br>
                <table class='table table-striped table-condensed datatable'>
                    <thead>
                        <tr>
                            <th>
                                Learning Outcome
                            </th>
                            <th>
                                Number of Students Assessed
                            </th>
                            <th>
                                Number of students that achieved the target
                            </th>
                            <th>
                                %
                            </th>

                        </tr>
                    </thead>
                    <tbody>
                        @foreach ($activity_1->getOutcomeReport() as $outcome)
                            <tr>
                                <td>
                                    {{ $outcome->name }}
                                </td>
                                <td>
                                    {{ $outcome->attempted }}
                                </td>
                                <td>
                                    {{ $outcome->achieved }}
                                </td>
                                @if ($outcome->percentage >= $expected)
                                    <td class="col-md-1 success">{{ $outcome->percentage }}%</td>
                                @else
                                    <td class="col-md-1 danger">{{ $outcome->percentage }}%</td>
                                @endif





                            </tr>
                        @endforeach
                    </tbody>
                </table>

                <br>
                <hr>







            </div>
            <div role="tabpanel" class='tab-pane' id="activity_tabla_2">


                <h3 style="text-align: center;">{{ $activity_2->name }} </h3>

                <br>
                <br>
                <h5 style="display: inline;">Date: </h5>
                <p style="display: inline;">
                    <strong>({{ $activity_2->date }})</strong>
                </p>
                <br>

                <h5 style="display: inline;">Performance Indicators: </h5>
                <?php
                Log::info($activity_2->rubric[0]);
                ?>
                <p style="display: inline;"><i>{{ $activity_2->rubric[0]->num_scales }} (
                        <?php
                        $titles = $activity_2->rubric[0]->getTitles();
                        ?>
                        @if (sizeof($titles) != 1)
                            @foreach ($titles as $index5 => $rubric_title)
                                @if ($index5 != $activity_2->rubric[0]->num_scales - 1)
                                    {{ $rubric_title->text }},
                                @else
                                    and {{ $rubric_title->text }}
                                @endif
                            @endforeach
                            )
                        @else
                            {{ $titles[0]->text }} )
                        @endif
                    </i></p>
                <br>
                <h5 style="display: inline;">Scale: </h5>
                @if ($activity_2->rubric[0]->max_score == 1)
                    <p style="display: inline;">1 point scale</p>
                @else
                    <p style="display: inline;">1-{{ $activity_2->rubric[0]->max_score }} point scale</p>
                @endif
                <br>
                <br>
                <h4>Performance of Students by Learning Outcome Criteria</h4>
                <h5 style="text-align: center;">{{ $activity_2->name }} </h5>
                <h5 style="display: inline; margin:30px;">Target by criterion: </h5>
                <p style="display: inline;"> <i>{{ $activity_2->rubric[0]->expected_points }} or more</i>
                </p>
                <br>
                <h5 style="display: inline; margin:30px;">Expected percent of students achieving the
                    target by criterion: </h5>
                <p style="display: inline;"> <i>{{ $activity_2->rubric[0]->expected_percentage }} %</i>
                </p>
                <br>
                <table class='table table-striped table-condensed datatable'>
                    <thead>
                        <tr>
                            <th>
                                Criterion
                            </th>
                            <th>
                                Number of Students Assessed
                            </th>
                            <th>
                                Number of students that achieved the target
                            </th>
                            <th>
                                %
                            </th>
                            <th>
                                Learning Outcomes
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach ($activity_2->allActivityCriterionInfo() as $index5 => $ac_criterion)
                            <tr>
                                <td> {{ $ac_criterion->name }}</td>
                                <td>{{ Criterion::students_attempted($ac_criterion->criterion_id, $activity_2->id) }}
                                </td>
                                <td>
                                    {{ Criterion::students_achieved($ac_criterion->criterion_id, $activity_2->id) }}

                                </td>
                                <?php
                                
                                $out_att = Criterion::students_attempted($ac_criterion->criterion_id, $activity_2->id);
                                $out_ach = Criterion::students_achieved($ac_criterion->criterion_id, $activity_2->id);
                                
                                $percentage = 'N/A';
                                $activity_2->getOutcomeReport();
                                
                                ?>
                                @if ($out_att == 0)
                                    <td class="col-md-1 danger">{{ $percentage }}</td>
                                @else
                                    <?php
                                    $percentage = round(($out_ach / $out_att) * 100, 2);
                                    ?>
                                    @if ($percentage >= $activity_2->rubric[0]->expected_percentage)
                                        <td class="col-md-1 success">{{ $percentage }}%</td>
                                    @else
                                        <td class="col-md-1 danger">{{ $percentage }}%</td>
                                    @endif
                                @endif
                                <td>

                                    @foreach (Criterion::outcomes($ac_criterion->criterion_id) as $index6 => $outcome)
                                        <?php echo $outcome->name . "\n\n\n <br>"; ?>
                                    @endforeach


                                </td>
                            </tr>
                        @endforeach
                    </tbody>

                </table>

                <h5 style="display: inline; margin:30px;">Formative Actions: </h5>
                <?php $formative_actions = $activity_2->formativeActionsWithCriteria(); ?>
                @if ($formative_actions)
                    <p style="display: inline;"> <u>{{ $formative_actions[0]->at_text }}:
                        </u>

                        <i>{{ $formative_actions[0]->description }}
                        </i>
                    </p>
                    <br>
                    <h5 style="display: inline; margin:30px;">Formative Action's Associated
                        Criteria: </h5>
                    <ul style=" margin:30px;">
                        @foreach ($formative_actions as $criteria)
                            <li> <i>{{ $criteria->name }} </i></li>
                        @endforeach
                    </ul>
                @endif

                <h5 style="display: inline; margin:30px;">Assessment Comments: </h5>
                @if ($activity_2->assessment_comments != null)
                    <p style="display: inline;">{{ $activity_2->assessment_comments }}</p>
                @endif
                <hr>
                <br>

                <h4>Performance of Students by Learning Outcome</h4>
                <h5 style="display: inline; margin:30px;">Target by learning outcome: </h5>
                <p style="display: inline;"> <i>>= 66.67% of the attempts</i>
                </p>
                <br>
                <h5 style="display: inline; margin:30px;">Expected percent of students achieving the
                    target by learning outcome: </h5>
                <p style="display: inline;"> <i>
                        <?php
                        $expected = DB::table('target_outcomes_program')
                            ->where('program_id', $course->program_id)
                            ->where('semester_id', $course->semester_id)
                            ->first(); //->expected_target;
                        if (!$expected) {
                            $expected = 'It has not been defined in the annual plan';
                        } else {
                            $expected = $expected->expected_target;
                        }
                        ?>
                        {{ $expected }}
                    </i>
                </p>
                <br>
                <table class='table table-striped table-condensed datatable'>
                    <thead>
                        <tr>
                            <th>
                                Learning Outcome
                            </th>
                            <th>
                                Number of Students Assessed
                            </th>
                            <th>
                                Number of students that achieved the target
                            </th>
                            <th>
                                %
                            </th>

                        </tr>
                    </thead>
                    <tbody>
                        @foreach ($activity_2->getOutcomeReport() as $outcome)
                            <tr>
                                <td>
                                    {{ $outcome->name }}
                                </td>
                                <td>
                                    {{ $outcome->attempted }}
                                </td>
                                <td>
                                    {{ $outcome->achieved }}
                                </td>
                                @if ($outcome->percentage >= $expected)
                                    <td class="col-md-1 success">{{ $outcome->percentage }}%</td>
                                @else
                                    <td class="col-md-1 danger">{{ $outcome->percentage }}%</td>
                                @endif





                            </tr>
                        @endforeach
                    </tbody>
                </table>

                <br>
                <hr>







            </div>
        </div>
    </div>



@stop
@section('included-js')
    @include('global._datatables_js')
    <!-- HighCharts -->
    <script src="{{ asset('vendor/highcharts/highcharts.js') }}"></script>
    <!--script src="http://code.highcharts.com/modules/exporting.js"></script -->

    <!-- Datepicker -->
    <script src="{{ asset('vendor/jquery-ui-1.11.4.custom/jquery-ui.min.js') }}"></script>

@stop


@section('javascript')
    $(function() {



    $('#criteriaGraph_1').highcharts({
    chart: {
    type: 'bar',
    height:
    @if ($activity_1->is_assessed())
        {{ count($activity_1->criteria_achieved()) * 22 + 225 }}
    @else
        {{ 22 + 225 }}
    @endif,
    },
    title: {
    text: ' ',
    },
    xAxis: {
    categories: [
    @if ($activity_1->is_assessed())
        @foreach ($activity_1->criteria_achieved() as $id => $value)
            "{{ Criterion::withTrashed()->find($id)->name }}",
        @endforeach
    @endif
    ],
    labels: {
    style: {
    fontSize: '12px'
    },
    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 (isset($activity_1->rubric[0]) and isset($activity_1->rubric[0]->expected_percentage))
        plotLines:[{
        value:{{ $activity_1->rubric[0]->expected_percentage }},
        color: '#000',
        width:3,
        zIndex:4,
        label:{
        text: 'Goal ({{ $activity_1->rubric[0]->expected_percentage }}%)',
        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.1
    },
    },
    series: [{
    type: 'column',
    name: 'Passed',
    color: '#e70033',
    dataLabels: {
    enabled: true,
    fontSize: 8,
    color: '#fff',
    align: 'right',
    format: '{y:.1f}%',
    style: {
    //fontWeight: 'bold'
    },
    y: -1
    },
    data: [
    @if ($activity_1->is_assessed())
        @foreach ($activity_1->cap_array as $id => $crit)
            //This conditional is to ignore criteria that weren't assessed. These would have a value of null.
            @if ($crit->score_percentage)
                {{ $crit->score_percentage }},
            @else
                0,
            @endif
        @endforeach
    @endif
    ],
    pointPadding: 0,
    }]
    });

    $('#criteriaGraph_2').highcharts({
    chart: {
    type: 'bar',
    height:
    @if ($activity_2->is_assessed())
        {{ count($activity_2->criteria_achieved()) * 22 + 225 }}
    @else
        {{ 22 + 225 }}
    @endif,
    },
    title: {
    text: ' ',
    },
    xAxis: {
    categories: [
    @if ($activity_2->is_assessed())
        @foreach ($activity_2->criteria_achieved() as $id => $value)
            "{{ Criterion::withTrashed()->find($id)->name }}",
        @endforeach
    @endif
    ],
    labels: {
    style: {
    fontSize: '12px'
    },
    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 (isset($activity_2->rubric[0]) and isset($activity_2->rubric[0]->expected_percentage))
        plotLines:[{
        value:{{ $activity_2->rubric[0]->expected_percentage }},
        color: '#000',
        width:3,
        zIndex:4,
        label:{
        text: 'Goal ({{ $activity_2->rubric[0]->expected_percentage }}%)',
        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.1
    },
    },
    series: [{
    type: 'column',
    name: 'Passed',
    color: '#e70033',
    dataLabels: {
    enabled: true,
    fontSize: 8,
    color: '#fff',
    align: 'right',
    format: '{y:.1f}%',
    style: {
    //fontWeight: 'bold'
    },
    y: -1
    },
    data: [
    @if ($activity_2->is_assessed())
        @foreach ($activity_2->cap_array as $id => $crit)
            //This conditional is to ignore criteria that weren't assessed. These would have a value of null.
            @if ($crit->score_percentage)
                {{ $crit->score_percentage }},
            @else
                0,
            @endif
        @endforeach
    @endif
    ],
    pointPadding: 0,
    }]
    });


    $('#graph_1').highcharts({
    chart: {
    type: 'bar',
    },
    title: {
    text: ' '
    },
    xAxis: {
    categories: [
    @foreach ($outcomes as $outcome)
        "{{ $outcome->name }}<br>"+
        @if(isset($results_1[$outcome->id]))
        "( N = {{$results_1[$outcome->id]->attempted}}, {{$results_1[$outcome->id]->achieved}})",
        @else
        "( N = 0, 0)",
        @endif
    @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'
        }, 
        
                plotLines:[{
            value:66.67,
            color: '#000',
            width:3,
            zIndex:4,
            label:{
                text: 'Goal (66.67%)',
                style: {
                    color: '#000',
                    fontSize: '14px',
                }
    
            }
        }]
    },
    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: '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($results_1) && array_key_exists($outcome->id, $results_1) && $results_1[$outcome->id]->attempted != 0)
            {{ ($results_1[$outcome->id]->achieved / $results_1[$outcome->id]->attempted) * 100 }},
        @else
            0,
        @endif
    @endforeach
    ],
    pointPadding: 0,
    }/*, {
    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($results_1) && array_key_exists($outcome->id, $results_1) && $results_1[$outcome->id]->attempted != 0)
            {{ $outcome->expected_outcome }},
        @else
            0,
        @endif
    @endforeach
    ],
    pointPadding: 0,
    }*/]
    });

    $('#graph_2').highcharts({
    chart: {
    type: 'bar',
    },
    title: {
    text:' '
    },
    xAxis: {
    categories: [
    @foreach ($outcomes as $outcome)
    "{{ $outcome->name }}<br>"+
    @if(isset($results_2[$outcome->id]))
    "( N = {{$results_2[$outcome->id]->attempted}}, {{$results_2[$outcome->id]->achieved}})",
    @else
    "( N = 0, 0)",
    @endif
    @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'
        }, 
        
                plotLines:[{
            value:66.67,
            color: '#000',
            width:3,
            zIndex:4,
            label:{
                text: 'Goal (66.67%)',
                style: {
                    color: '#000',
                    fontSize: '14px',
                }
    
            }
        }]
    },
    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: '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($results_2) && array_key_exists($outcome->id, $results_2) && $results_2[$outcome->id]->attempted != 0)
            {{ ($results_2[$outcome->id]->achieved / $results_2[$outcome->id]->attempted) * 100 }},
        @else
            0,
        @endif
    @endforeach
    ],
    pointPadding: 0,
    }, /*{
    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($results_2) && array_key_exists($outcome->id, $results_2) && $results_2[$outcome->id]->attempted != 0)
            {{ $outcome->expected_outcome }},
        @else
            0,
        @endif
    @endforeach
    ],
    pointPadding: 0,
    }*/]
    });

    var chart = $('#graph_1').highcharts();
    var titletext = $('#graph_1').highcharts().options.title.text;
    var newtitletext = titletext.replace("&#039;", "\'");
    chart.setTitle({
    text: newtitletext
    });
    var chart = $('#graph_2').highcharts();
    var titletext = $('#graph_2').highcharts().options.title.text;
    var newtitletext = titletext.replace("&#039;", "\'");
    chart.setTitle({
    text: newtitletext
    });
    $('.first').each(function(){
    $(this).addClass('active');
    })
    // Include dummy graph for outcomes
    @include('global.dummy-outcomes')


    });


@stop

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

    <!-- Datepicker -->
    <script src="{{ asset('vendor/jquery-ui-1.11.4.custom/jquery-ui.min.js') }}"></script>

@stop
