No Description

print_assessment.blade.php 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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 $index=>$criterion)
  98. <th class="criterion-field" data-criterion-id="{{{ $criterion->criterion_id }}}">{{ $criterion->name}}</th>
  99. <input type="hidden" id="weight-{{$index}}" value = "{{$criterion->weight}}">
  100. @endforeach
  101. <th>Student Percentage</th>
  102. <th>Student % per Weight<th>
  103. </tr>
  104. </thead>
  105. <tbody>
  106. <!-- If the activity was assessed, load the assessment.-->
  107. @if(sizeof($assessments)!=0)
  108. <!-- For each assessment -->
  109. @foreach ($students as $student)
  110. <tr class="student-row">
  111. <!-- Fetch student name -->
  112. <td class="student-field" data-student-id="{{ $student->id }}">
  113. {{{ $student->name }}}
  114. </td>
  115. <!-- For each criterion in the rubric, there's a score field -->
  116. @for ($i = 0; $i<sizeof($rubric_contents); $i++)
  117. <td class="score-field">
  118. @if(array_key_exists($student->id, $scores_array)&& isset($scores_array[$student->id][$rubric_contents[$i]->activity_criterion_id]))
  119. {{ $scores_array[$student->id][$rubric_contents[$i]->activity_criterion_id] }}
  120. @else
  121. N/A
  122. @endif
  123. </td>
  124. @endfor
  125. <td class="percentage"></td>
  126. <td class="percentage-per-weight"></td>
  127. </tr>
  128. @endforeach
  129. @endif
  130. </tbody>
  131. <tfoot>
  132. <tr>
  133. <td>
  134. <strong>Passed Criteria Percentage </strong>
  135. </td>
  136. @for ($i = 0; $i<sizeof($rubric_contents); $i++)
  137. <td class="total"><strong><span class="total-value"></span>%</strong>
  138. </td>
  139. @endfor
  140. <td></td>
  141. </tr>
  142. </tfoot>
  143. </table>
  144. </div>
  145. </div>
  146. <?php
  147. echo '</body>';
  148. echo '</html>';
  149. ?>
  150. <script src="{{ asset('vendor/jquery.min.js') }}"></script>
  151. <script>
  152. $(document).ready(function(){
  153. // --------------------------------------------------------------------------
  154. // Page load
  155. // --------------------------------------------------------------------------
  156. $('.total').each(function(index)
  157. {
  158. percentagePerCriterionPlain(index+1);
  159. });
  160. $('.student-row').each(function(index)
  161. {
  162. percentagePerStudentPlain($(this));
  163. });
  164. window.print();
  165. // --------------------------------------------------------------------------
  166. // Functions
  167. // --------------------------------------------------------------------------
  168. // Calculate average of students that passed a specific criterion
  169. function percentagePerCriterionPlain(columnIndex)
  170. {
  171. // Object to hold the score sum of each criterion
  172. var sum = 0 ;
  173. var total = 0;
  174. columnIndex+=1;
  175. // Iterate through rows of column
  176. $('table tbody tr td:nth-child('+columnIndex+')').each(function( index )
  177. {
  178. var val = parseInt($(this).text());
  179. /* If N/A or 0 are chosen, they are ignored in the calculation. */
  180. if(val % 1 === 0 && val!=0) //Check if number is integer and not 0
  181. {
  182. if(val >= parseInt($('#expected_points').text()))
  183. {
  184. sum+=1;
  185. }
  186. total+=1;
  187. }
  188. });
  189. var percentage= (sum/total*100).toFixed(2);
  190. // If no criteria were assessed, set the percentage to 0.
  191. // This is to avoid show NaN%
  192. if(total==0)
  193. percentage="0.00";
  194. $('.total:nth-child('+columnIndex+') span').html(percentage);
  195. }
  196. // Calculate total for a specific student
  197. function percentagePerStudentPlain(row)
  198. {
  199. // Object to hold the score student's total score
  200. var sum = 0 ;
  201. var total = 0;
  202. var percentage = 0;
  203. var max_score = {{$rubric->max_score}};
  204. var per_of_weight =0;
  205. var sum_of_weight =0;
  206. row.find('td.score-field').each(function(index)
  207. {
  208. var val = parseInt($(this).text());
  209. if(val % 1 === 0) //Check if number is integer
  210. {
  211. sum += val;
  212. total+=1;
  213. per_of_weight += val * parseInt($('#weight-'+index).val());
  214. sum_of_weight += parseInt($('#weight-'+index).val());
  215. }
  216. });
  217. percentage_per_weight = (100 *(per_of_weight/(max_score*sum_of_weight))).toFixed(2);
  218. percentage =((sum/(total*max_score))*100).toFixed(2);
  219. //If percentage is not a number, set it to 0.
  220. if(isNaN(percentage))
  221. percentage="0.00";
  222. if(isNaN(percentage_per_weight))
  223. percentage_per_weight ="0.00";
  224. row.find('.percentage').html('<strong>'+percentage+'%</strong>');
  225. row.find('.percentage-per-weight').html('<strong>'+percentage_per_weight+'%</strong>');
  226. }
  227. });
  228. </script>