No Description

view_assessment.blade.php 10KB

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