No Description

print_assessment.blade.php 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <?php
  2. echo '<html>';
  3. echo '<body>';
  4. //Inline styles (only for printing)
  5. echo
  6. '<style type="text/css">
  7. body
  8. {
  9. font-family: "Arial", sans-serif;
  10. width:90%;
  11. margin: 0 auto;
  12. }
  13. .header-text
  14. {
  15. text-align:center;
  16. font-weight: bold;
  17. margin:0;
  18. }
  19. h1.header-text
  20. {
  21. margin: 15px 0;
  22. }
  23. table
  24. {
  25. border-collapse: collapse;
  26. border: 1px solid black;
  27. width: 100%;
  28. margin: 30px auto;
  29. font-size:1vw;
  30. }
  31. td, th
  32. {
  33. border: 1px solid black;
  34. padding: 5px;
  35. }
  36. .activity-name-row
  37. {
  38. background:black;
  39. color:white;
  40. }
  41. .activity-headers-row
  42. {
  43. background:lightgrey;
  44. font-weight:bold;
  45. }
  46. .report-info
  47. {
  48. margin:5px 0;
  49. font-size: 16px;
  50. }
  51. .criterion-field
  52. {
  53. text-align:left;
  54. }
  55. .score-field, .total, .percentage
  56. {
  57. text-align:center;
  58. }
  59. .header
  60. {
  61. margin: 30px 0;
  62. }
  63. .content
  64. {
  65. font-size: 12px;
  66. }
  67. .logo
  68. {
  69. position:absolute;
  70. right:0;
  71. top: 30px;
  72. width: 100px;
  73. }
  74. @media print{@page {size: landscape}}
  75. </style>';
  76. ?>
  77. <img class="logo" src="{{ asset('images/logo_uprrp_bw.png') }}" alt="UPRRP Logo">
  78. <div class="header">
  79. <p class="header-text">University of Puerto Rico, Río Piedras Campus</p>
  80. <p class="header-text">Online Learning Assessment System</p>
  81. <p class="header-text">{{$course->program->name}} Program</p>
  82. <h1 class="header-text">Activity Report</h1>
  83. </div>
  84. <div class="content">
  85. <p class="report-info">Activity: {{{ $activity->name}}}</p>
  86. <p class="report-info">Passing Criteria: <span id="expected_percentage">{{{ $rubric->expected_percentage }}}% of students must obtain at least </span><span id="expected_points">{{{$rubric->expected_points}}}</span> points. </p>
  87. <p class="report-info">Course: {{{ $course->code }}} {{{ $course->number }}}-{{{ $course->section }}} - {{$course->name}}</p>
  88. <p class="report-info">Professor: {{{ $course->user->surnames }}}, {{{ $course->user->first_name }}} </p>
  89. <p class="report-info">Report Date: {{ date('M/d/Y')}}</p>
  90. </div>
  91. <div class="row">
  92. <div class="col-md-12">
  93. <table id="assessment-table" class="table table-striped table-condensed table-bordered">
  94. <thead>
  95. <tr>
  96. <th>Student</th>
  97. @foreach ($rubric_contents as $criterion)
  98. <th class="criterion-field" data-criterion-id="{{{ $criterion->id }}}">{{ $criterion->name}}</th>
  99. @endforeach
  100. <th>Student Percentage</th>
  101. </tr>
  102. </thead>
  103. <tbody>
  104. <!-- If the activity was assessed, load the assessment.-->
  105. @if(sizeof($assessments)!=0)
  106. <!-- For each assessment -->
  107. @foreach ($assessments as $assessment)
  108. <tr class="student-row">
  109. <!-- Fetch student name -->
  110. <td class="student-field" data-student-id="{{ $assessment->student_id }}">
  111. {{{ Student::find($assessment->student_id)->name }}}
  112. </td>
  113. <!-- For each criterion in the rubric, there's a score field -->
  114. @for ($i = 0; $i<sizeof($rubric_contents); $i++)
  115. <td class="score-field">
  116. {{ $scores_array[$assessment->id][$rubric_contents[$i]->id] }}
  117. </td>
  118. @endfor
  119. <td class="percentage">{{{ $assessment->percentage }}}</td>
  120. </tr>
  121. @endforeach
  122. @endif
  123. </tbody>
  124. <tfoot>
  125. <tr>
  126. <td>
  127. <strong>Passed Criteria Percentage </strong>
  128. </td>
  129. @for ($i = 0; $i<sizeof($rubric_contents); $i++)
  130. <td class="total"><strong><span class="total-value"></span>%</strong>
  131. </td>
  132. @endfor
  133. <td></td>
  134. </tr>
  135. </tfoot>
  136. </table>
  137. </div>
  138. </div>
  139. <?
  140. echo '</body>';
  141. echo '</html>';
  142. ?>
  143. <script src="{{ asset('vendor/jquery.min.js') }}"></script>
  144. <script>
  145. $(document).ready(function(){
  146. // --------------------------------------------------------------------------
  147. // Page load
  148. // --------------------------------------------------------------------------
  149. $('.total').each(function(index)
  150. {
  151. percentagePerCriterionPlain(index+1);
  152. });
  153. $('.student-row').each(function(index)
  154. {
  155. percentagePerStudentPlain($(this));
  156. });
  157. window.print();
  158. // --------------------------------------------------------------------------
  159. // Functions
  160. // --------------------------------------------------------------------------
  161. // Calculate average of students that passed a specific criterion
  162. function percentagePerCriterionPlain(columnIndex)
  163. {
  164. // Object to hold the score sum of each criterion
  165. var sum = 0 ;
  166. var total = 0;
  167. columnIndex+=1;
  168. // Iterate through rows of column
  169. $('table tbody tr td:nth-child('+columnIndex+')').each(function( index )
  170. {
  171. var val = parseInt($(this).text());
  172. /* If N/A or 0 are chosen, they are ignored in the calculation. */
  173. if(val % 1 === 0 && val!=0) //Check if number is integer and not 0
  174. {
  175. if(val >= parseInt($('#expected_points').text()))
  176. {
  177. sum+=1;
  178. }
  179. total+=1;
  180. }
  181. });
  182. var percentage= (sum/total*100).toFixed(2);
  183. // If no criteria were assessed, set the percentage to 0.
  184. // This is to avoid show NaN%
  185. if(total==0)
  186. percentage="0.00";
  187. $('.total:nth-child('+columnIndex+') span').html(percentage);
  188. }
  189. // Calculate total for a specific student
  190. function percentagePerStudentPlain(row)
  191. {
  192. // Object to hold the score student's total score
  193. var sum = 0 ;
  194. var total = 0;
  195. var percentage = 0;
  196. row.find('td.score-field').each(function(index)
  197. {
  198. var val = parseInt($(this).text());
  199. if(val % 1 === 0) //Check if number is integer
  200. {
  201. sum += val;
  202. total+=1;
  203. }
  204. });
  205. percentage =((sum/(total*8))*100).toFixed(2);
  206. //If percentage is not a number, set it to 0.
  207. if(isNaN(percentage))
  208. percentage="0.00";
  209. row.find('.percentage').html('<strong>'+percentage+'%</strong>');
  210. }
  211. });
  212. </script>