<?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 $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
@else
  <p class="lead">No activities have been assessed.</p>
@endif


<?

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

<script type="text/javascript">

window.print();

</script>