<?php

echo '<html>';
echo '<body>';

//Inline styles (only for printing)
echo
'<style>
    body
    {
        font-family: "Arial", sans-serif;
        width:90%;
        margin: 0 auto;
    }
    .header-text
    {
        text-align:center;
        font-weight: bold;
        margin:0;
    }

    h1.header-text
    {
      margin: 15px 0;
    }

    table
    {
        border-collapse: collapse;
        border: 1px solid black;
        width: 100%;
        margin: 30px auto;
    }
    td, th
    {
        border: 1px solid black;
        padding: 5px;
    }

    .activity-name-row
    {
      background:black;
      color:white;
    }

    .activity-headers-row
    {
      background:lightgrey;
      font-weight:bold;
    }

    .active
    {
      background:lightgrey;
    }

    .report-info
    {
      margin:5px 0;
      font-size: 16px;
    }

    .criterion
    {
      width:45%;
    }
    .score
    {
      width:10%;
      text-align:center;
    }
    .reason
    {
      width:45%;
    }

    .header
    {
      margin: 30px 0;
    }

    .content
    {
      font-size: 12px;
    }

    .logo
    {
      position:absolute;
      right:0;
      top: 30px;
      width: 100px;
    }
</style>';

?>


<img class="logo" src="{{ asset('images/logo_uprrp_bw.png') }}" alt="UPRRP Logo">


<div class="header">
  <p class="header-text">University of Puerto Rico, Río Piedras Campus</p>
  <p class="header-text">Online Learning Assessment System</p>
  <p class="header-text">{{$course->program->name}} Program</p>
  <h1 class="header-text">Student Report </h1>
</div>


<div class="content">
  <p class="student-name report-info">Student Name: {{{ $student->name}}}</p>
  <p class="report-info">Number: {{{ substr($student->number, 0, 3)}}}-{{{substr($student->number, 3, 2)}}}-{{{substr($student->number, 5, 4)}}}</p>
  <p class="report-info">Course: {{{ $course->code }}} {{{ $course->number }}}-{{{ $course->section }}} - {{$course->name}}</p>
  <p class="report-info">Professor: {{{ $course->user->surnames }}}, {{{ $course->user->first_name }}} </p>
  <p class="report-info">Report Date: {{ date('M/d/Y')}}</p>
</div>




@if($assessments!=NULL)
  @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
@else
  <p class="lead">No activities have been assessed.</p>
@endif


<?php

echo '</body>';
echo '</html>';
?>

<script type="text/javascript">

window.print();

</script>
