@extends('layouts.master')

@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">
    <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 $activity_id => $activity)
        <?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">{{ $assessments[$activity_id]['activity'] }}</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($assessments[$activity_id]["criteria"] as $activity_criterion_id => $criteria)

                        

                        <tr>
                            <td>{{{ $criteria->name }}}</td>
                            <td>{{{$assessments[$activity_id]["score"][$activity_criterion_id]}}}</td>
                            <td>
                                @if($assessments[$activity_id]['score'][$activity_criterion_id] != 0 || $assessments[$activity_id]['score'][$activity_criterion_id] !="N/A")
                                    {{ $assessments[$activity_id]['explication'][$activity_criterion_id] }}
  
                                @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> {{ $assessments[$activity_id]['percentage'] }}%</p>
                <p class="lead"><strong>Comments:</strong> {{ $assessments[$activity_id]['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
