暫無描述

view_assessment.blade.php 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. @extends('layouts.master')
  2. @section('navigation')
  3. @if($role==1)
  4. @include('local.managers.admins._navigation')
  5. @elseif($role==2)
  6. @include('local.managers.sCoords._navigation')
  7. @elseif($role==3)
  8. @include('local.managers.pCoords._navigation')
  9. @else
  10. @include('local.professors._navigation')
  11. @endif
  12. @stop
  13. @section('main')
  14. <!-- View criterion info -->
  15. <div class="modal fade" id="modal-view-criterion">
  16. <div class="modal-dialog modal-lg">
  17. <div class="modal-content">
  18. <div class="modal-header">
  19. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  20. <h4 class="modal-title"></h4>
  21. </div>
  22. <div class="modal-body">
  23. <table class="table table-bordered">
  24. <thead>
  25. @foreach($rubric->titles as $i=>$title)
  26. <th>{{$title}} ({{1+($i*($rubric->max_score/$rubric->num_scales))}}-{{(1+$i)*($rubric->max_score/$rubric->num_scales)}})</th>
  27. @endforeach
  28. <th>Notes</th>
  29. </thead>
  30. <tbody>
  31. <tr></tr>
  32. </tbody>
  33. </table>
  34. </div>
  35. </div><!-- /.modal-content -->
  36. </div><!-- /.modal-dialog -->
  37. </div><!-- /.modal -->
  38. <div class="row">
  39. <div class="col-md-12">
  40. <div class="btn-group pull-right">
  41. {{ HTML::linkAction('ActivitiesController@show', 'Back to Activity', array($activity->id), array('class'=>'btn btn-default btn-sm')) }}
  42. {{ HTML::linkAction('ActivitiesController@printAssessment', 'Print', array($activity->id), array('class'=>'btn btn-default btn-sm')) }}
  43. </div>
  44. <p id="course">Course: {{{ $course->code }}} {{{ $course->number }}}</p>
  45. <p id="section">Section: {{{ $course->section }}}</p>
  46. <p id="activity" data-activity-id="{{{ $activity->id }}}">Activity: {{{ $activity->name}}} </p>
  47. <p>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>
  48. <table id="assessment-table" class="table table-striped table-condensed table-bordered">
  49. <thead>
  50. <tr>
  51. <th>
  52. </th>
  53. @foreach ($rubric_criterion as $index => $criterion)
  54. <th data-criterion-id="{{{ $criterion->criterion_id }}}" id="weight-{{$index}}" data-weight = " {{$criterion->weight}}" data-activity-criterion-id="{{$criterion->activity_criterion_id}}">
  55. Weight: {{$criterion->weight}}
  56. </th>
  57. @endforeach
  58. <th></th>
  59. <th></th>
  60. <th></th>
  61. </tr>
  62. <tr>
  63. <th>Student</th>
  64. @foreach ($rubric_criterion as $criterion)
  65. <th class="criterion-field" data-criterion-id="{{{ $criterion->criterion_id }}}"><div class="th-box">{{ $criterion->name}}</div></th>
  66. @endforeach
  67. <th>Student Percentage</th>
  68. <th>Student % Per Weight</th>
  69. <th>Comments</th>
  70. </tr>
  71. </thead>
  72. <tbody>
  73. <!-- If the activity was assessed, load the assessment. Otherwise load empty sheet -->
  74. @if(sizeof($assessments)!=0)
  75. <!-- For each assessment -->
  76. @foreach ($students as $student)
  77. <tr class="student-row">
  78. <!-- Fetch student name -->
  79. <td class="student-field" data-student-id="{{ $student->id }}">
  80. {{{ $student->name }}}
  81. </td>
  82. <!-- For each criterion in the rubric, there's a score field -->
  83. @for ($i = 0; $i<sizeof($rubric_criterion); $i++)
  84. <td class="score-field text-center">
  85. @if(array_key_exists($student->id, $scores_array) && isset($scores_array[$student->id][$rubric_criterion[$i]->activity_criterion_id]))
  86. {{$scores_array[$student->id][$rubric_criterion[$i]->activity_criterion_id]}}
  87. @else
  88. N/A
  89. @endif
  90. </td>
  91. @endfor
  92. <td class="percentage text-center"></td>
  93. <td class="percentage-per-weight text-center"></td>
  94. <td class="">
  95. <textarea class="comments full-textarea" placeholder="Max. 255 characters" maxLength="255" disabled >
  96. @if(array_key_exists($student->id, $scores_array))
  97. {{ $scores_array[$student->id]["comments"] }}
  98. @endif
  99. </textarea>
  100. </td>
  101. </tr>
  102. @endforeach
  103. @endif
  104. </tbody>
  105. <tfoot>
  106. <tr>
  107. <td>
  108. <strong>Passed Criteria Percentage </strong>
  109. </td>
  110. @for ($i = 0; $i<sizeof($rubric_criterion); $i++)
  111. <td class="total text-center"><strong><span class="total-value"></span>%</strong>
  112. </td>
  113. @endfor
  114. <td></td>
  115. </tr>
  116. </tfoot>
  117. </table>
  118. </div>
  119. </div>
  120. <input type='hidden' value = {{$rubric->max_score}} id = "max">
  121. <script>
  122. </script>
  123. @stop
  124. @section('included-js')
  125. <!-- StickyTableHeaders js -->
  126. <script src="{{ asset('vendor/stickyTableHeaders/js/jquery.stickytableheaders.min.js') }}"></script>
  127. @stop
  128. @section ('javascript')
  129. // --------------------------------------------------------------------------
  130. // Page load
  131. // --------------------------------------------------------------------------
  132. // Enable fixed headers
  133. $('table').stickyTableHeaders();
  134. $('.total').each(function(index)
  135. {
  136. percentagePerCriterionPlain(index+1);
  137. });
  138. $('.student-row').each(function(index)
  139. {
  140. percentagePerStudentPlain($(this));
  141. });
  142. // --------------------------------------------------------------------------
  143. // Functions
  144. // --------------------------------------------------------------------------
  145. // Calculate average of students that passed a specific criterion
  146. function percentagePerCriterionPlain(columnIndex)
  147. {
  148. // Object to hold the score sum of each criterion
  149. var sum = 0 ;
  150. var total = 0;
  151. columnIndex+=1;
  152. // Iterate through rows of column
  153. $('table tbody tr td:nth-child('+columnIndex+')').each(function( index )
  154. {
  155. var val = parseInt($(this).text());
  156. /* Check if number is integer. If N/A or 0 are chosen, they are ignored in the calculation. */
  157. if(val % 1 === 0 && val!=0)
  158. {
  159. if(val >= parseInt($('#expected_points').text()))
  160. {
  161. sum+=1;
  162. }
  163. total+=1;
  164. }
  165. });
  166. var percentage= (sum/total*100).toFixed(2);
  167. // If no criteria were assessed, set the percentage to 0.
  168. // This is to avoid show NaN%
  169. if(total==0)
  170. percentage="0.00";
  171. $('.total:nth-child('+columnIndex+') span').html(percentage);
  172. }
  173. // Calculate total for a specific student
  174. function percentagePerStudentPlain(row)
  175. {
  176. /* // Object to hold the score student's total score
  177. var sum = 0 ;
  178. var total = 0;
  179. var percentage = 0;
  180. row.find('td.score-field').each(function(index)
  181. {
  182. var val = parseInt($(this).text());
  183. if(val % 1 === 0) // Check if number is an integer
  184. {
  185. sum += val;
  186. total+=1;
  187. }
  188. });
  189. percentage =((sum/(total*8))*100).toFixed(2);
  190. //If percentage is not a number, set it to 0.
  191. if(isNaN(percentage))
  192. percentage="0.00";
  193. row.find('.percentage').html('<strong>'+percentage+'%</strong>');
  194. */
  195. var sum = 0 ;
  196. var total = 0;
  197. var percentage = 0;
  198. var max_score = parseInt($('#max').val());
  199. sum_of_weight = 0;
  200. per_of_weight =0;
  201. row.find('td.score-field').each(function(index)
  202. {
  203. var val = parseInt($(this).text());
  204. if(val % 1 === 0) //If number is integer
  205. {
  206. sum += val;
  207. total+=1;
  208. per_of_weight += val * parseInt($('#weight-'+index).data("weight"));
  209. sum_of_weight += parseInt($('#weight-'+index).data("weight"));
  210. }
  211. });
  212. percentage_per_weight = (100 *(per_of_weight/(max_score*sum_of_weight))).toFixed(2);
  213. percentage =((sum/(total*max_score))*100).toFixed(2);
  214. //If percentage is not a number, set it to 0.
  215. if(isNaN(percentage))
  216. {
  217. percentage="N/A";
  218. row.find('.percentage').html('<strong>'+percentage+'</strong>');
  219. }
  220. else
  221. {
  222. row.find('.percentage').html('<strong>'+percentage+'%</strong>');
  223. }
  224. if(isNaN(percentage_per_weight)){
  225. percentage_per_weight="N/A";
  226. row.find('.percentage-per-weight').html('<strong>'+percentage_per_weight+'</strong>');
  227. }
  228. else{
  229. row.find('.percentage-per-weight').html('<strong>'+percentage_per_weight+'%</strong>');
  230. }
  231. }
  232. // --------------------------------------------------------------------------
  233. // Events
  234. // --------------------------------------------------------------------------
  235. // Criterion name is clicked
  236. $('.criterion-field').on('click', function()
  237. {
  238. $.ajax({
  239. type: 'POST',
  240. url: "{{ URL::action('RubricsController@fetchRubricCriterion') }}",
  241. data: { criterion_id: $(this).data('criterion-id') },
  242. success: function(data)
  243. {
  244. data = JSON.parse(data);
  245. $('.modal-title').html(data.criteria.name);
  246. descriptions = '';
  247. $('.modal-body tbody tr').empty();
  248. for(i =0; i<{{$rubric->num_scales}}; i++){
  249. descriptions += '<td>'+data[i].description+'</td>'
  250. }
  251. $('.modal-body tbody tr').append
  252. (
  253. descriptions
  254. );
  255. if(data.criteria.notes!=null)
  256. $('.modal-body tbody tr').append('<td>'+data.criteria.notes+'</td>');
  257. else
  258. $('.modal-body tbody tr').append('<td></td>');
  259. },
  260. async:true
  261. });
  262. $('#modal-view-criterion').modal();
  263. });
  264. @stop