@extends('layouts.master')

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

@section('main')

<div class="row">
    <div class="col-md-12">
      <div class="btn-group pull-right" role="group" aria-label="navigation-buttons">
        {{ HTML::linkAction('StudentsController@printStudentReport', 'Print', array($course->semester_id, $course->code.$course->number.'-'.$course->section, $student->number), array('class'=>'btn btn-default')) }}
        {{ HTML::linkAction('CoursesController@show', 'Back to Section', array($course->id), array('class'=>'btn btn-default')) }}
      </div>

      <p class="lead">Student Number: {{{ substr($student->number, 0, 3)}}}-{{{substr($student->number, 3, 2)}}}-{{{substr($student->number, 5, 4)}}}</p>
      <p class="lead">Course: {{{ $course->name }}} ({{{ $course->code }}} {{{ $course->number }}}-{{{ $course->section }}})</p>

    </div>
</div>

<!-- <div class="row">
  <div class="col-md-12" id="graph"></div>
</div> -->

@if($assessments!=NULL)
  <div class="row">
    <div class="col-md-12">
      <h3>Assessment Results </h3>
      @foreach($assessments as $assessment)
        <?php
          $activity = Activity::find($assessment->activity_id);

          // Used to get custom rubric criterion indicators
          $rubric_contents = json_decode(Rubric::find($activity->rubric_id)->contents, true);
        ?>

        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">{{ $activity->name }}</h3>
            </div>
            <div class="panel-body">
                <table class="table table-striped table-condensed">
                    <thead>
                        <tr>
                            <th class="col-md-4">Criterion</th>
                            <th class="col-md-2">Score</th>
                            <th class="col-md-6">Reason</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php

                        $scores = json_decode($assessment->scores, true);

                        ?>

                        @foreach($rubric_contents as $row)

                        <?php $real_score = $scores[$row['id']]; ?>

                        <tr>
                            <td>{{{ $row['name'] }}}</td>
                            <td>{{{ $real_score }}}</td>
                            <td>
                                @if($real_score == 1 || $real_score == 2)
                                    {{ nl2br($row['description12']) }}
                                @elseif ($real_score == 3 || $real_score == 4)
                                    {{ nl2br($row['description34']) }}
                                @elseif ($real_score == 5 || $real_score == 6)
                                    {{ nl2br($row['description56']) }}
                                @elseif ($real_score == 7 || $real_score == 8)
                                    {{ nl2br($row['description78']) }}
                                @else
                                    There is not enough information to assess this criterion, or the student did not complete the required work.
                                @endif
                            </td>
                        </tr>
                        @endforeach
                    </tbody>
                </table>

                <p class="lead"><strong>Percentage:</strong> {{ $assessment->percentage }}%</p>
                <p class="lead"><strong>Comments:</strong> {{ $assessment->comments }}</p>
            </div>
        </div>
      @endforeach
    </div>
  </div>
@else
  <div class="row">
    <div class="col-md-12">
      <p class="lead">No activities have been assessed.</p>
    </div>
  </div>
@endif

@stop

@section('javascript')

// --------------------------------------------------------------------------
// Page load
// --------------------------------------------------------------------------

  // Hide accordion panel contents by default
  $('.panel-body').hide();

// --------------------------------------------------------------------------
// Functions
// --------------------------------------------------------------------------


// --------------------------------------------------------------------------
// Events
// --------------------------------------------------------------------------

  // When panel heading is clicked, toggle it
  $('.panel-heading').on('click', function()
  {
    $(this).next().stop().slideToggle();
  })



@stop