Sin descripción

view_assessment.blade.php 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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. {{$scores_array[$student->id][$i]}}
  87. </td>
  88. @endfor
  89. <td class="percentage text-center"></td>
  90. <td class="percentage-per-weight text-center"></td>
  91. <td class="">
  92. <textarea class="comments full-textarea" placeholder="Max. 255 characters" maxLength="255" disabled >{{ $scores_array[$student->id]["comments"] }}</textarea>
  93. </td>
  94. </tr>
  95. @endforeach
  96. @endif
  97. </tbody>
  98. <tfoot>
  99. <tr>
  100. <td>
  101. <strong>Passed Criteria Percentage </strong>
  102. </td>
  103. @for ($i = 0; $i<sizeof($rubric_criterion); $i++)
  104. <td class="total text-center"><strong><span class="total-value"></span>%</strong>
  105. </td>
  106. @endfor
  107. <td></td>
  108. </tr>
  109. </tfoot>
  110. </table>
  111. </div>
  112. </div>
  113. <input type='hidden' value = {{$rubric->max_score}} id = "max">
  114. <script>
  115. </script>
  116. @stop
  117. @section('included-js')
  118. <!-- StickyTableHeaders js -->
  119. <script src="{{ asset('vendor/stickyTableHeaders/js/jquery.stickytableheaders.min.js') }}"></script>
  120. @stop
  121. @section ('javascript')
  122. // --------------------------------------------------------------------------
  123. // Page load
  124. // --------------------------------------------------------------------------
  125. // Enable fixed headers
  126. $('table').stickyTableHeaders();
  127. $('.total').each(function(index)
  128. {
  129. percentagePerCriterionPlain(index+1);
  130. });
  131. $('.student-row').each(function(index)
  132. {
  133. percentagePerStudentPlain($(this));
  134. });
  135. // --------------------------------------------------------------------------
  136. // Functions
  137. // --------------------------------------------------------------------------
  138. // Calculate average of students that passed a specific criterion
  139. function percentagePerCriterionPlain(columnIndex)
  140. {
  141. // Object to hold the score sum of each criterion
  142. var sum = 0 ;
  143. var total = 0;
  144. columnIndex+=1;
  145. // Iterate through rows of column
  146. $('table tbody tr td:nth-child('+columnIndex+')').each(function( index )
  147. {
  148. var val = parseInt($(this).text());
  149. /* Check if number is integer. If N/A or 0 are chosen, they are ignored in the calculation. */
  150. if(val % 1 === 0 && val!=0)
  151. {
  152. if(val >= parseInt($('#expected_points').text()))
  153. {
  154. sum+=1;
  155. }
  156. total+=1;
  157. }
  158. });
  159. var percentage= (sum/total*100).toFixed(2);
  160. // If no criteria were assessed, set the percentage to 0.
  161. // This is to avoid show NaN%
  162. if(total==0)
  163. percentage="0.00";
  164. $('.total:nth-child('+columnIndex+') span').html(percentage);
  165. }
  166. // Calculate total for a specific student
  167. function percentagePerStudentPlain(row)
  168. {
  169. /* // Object to hold the score student's total score
  170. var sum = 0 ;
  171. var total = 0;
  172. var percentage = 0;
  173. row.find('td.score-field').each(function(index)
  174. {
  175. var val = parseInt($(this).text());
  176. if(val % 1 === 0) // Check if number is an integer
  177. {
  178. sum += val;
  179. total+=1;
  180. }
  181. });
  182. percentage =((sum/(total*8))*100).toFixed(2);
  183. //If percentage is not a number, set it to 0.
  184. if(isNaN(percentage))
  185. percentage="0.00";
  186. row.find('.percentage').html('<strong>'+percentage+'%</strong>');
  187. */
  188. var sum = 0 ;
  189. var total = 0;
  190. var percentage = 0;
  191. var max_score = parseInt($('#max').val());
  192. sum_of_weight = 0;
  193. per_of_weight =0;
  194. row.find('td.score-field').each(function(index)
  195. {
  196. var val = parseInt($(this).text());
  197. if(val % 1 === 0) //If number is integer
  198. {
  199. sum += val;
  200. total+=1;
  201. per_of_weight += val * parseInt($('#weight-'+index).data("weight"));
  202. sum_of_weight += parseInt($('#weight-'+index).data("weight"));
  203. }
  204. });
  205. percentage_per_weight = (100 *(per_of_weight/(max_score*sum_of_weight))).toFixed(2);
  206. percentage =((sum/(total*max_score))*100).toFixed(2);
  207. //If percentage is not a number, set it to 0.
  208. if(isNaN(percentage))
  209. {
  210. percentage="N/A";
  211. row.find('.percentage').html('<strong>'+percentage+'</strong>');
  212. }
  213. else
  214. {
  215. row.find('.percentage').html('<strong>'+percentage+'%</strong>');
  216. }
  217. if(isNaN(percentage_per_weight)){
  218. percentage_per_weight="N/A";
  219. row.find('.percentage-per-weight').html('<strong>'+percentage_per_weight+'</strong>');
  220. }
  221. else{
  222. row.find('.percentage-per-weight').html('<strong>'+percentage_per_weight+'%</strong>');
  223. }
  224. }
  225. // --------------------------------------------------------------------------
  226. // Events
  227. // --------------------------------------------------------------------------
  228. // Criterion name is clicked
  229. $('.criterion-field').on('click', function()
  230. {
  231. $.ajax({
  232. type: 'POST',
  233. url: "{{ URL::action('CriteriaController@fetchCriterionWithTrashed') }}",
  234. data: { id: $(this).data('criterion-id') },
  235. success: function(data)
  236. {
  237. $('.modal-title').html(data.name);
  238. $('.modal-body tbody tr').empty();
  239. $('.modal-body tbody tr').append
  240. (
  241. '<td>'+data.description12+'</td>'
  242. +'<td>'+data.description34+'</td>'
  243. +'<td>'+data.description56+'</td>'
  244. +'<td>'+data.description78+'</td>'
  245. );
  246. if(data.notes!=null)
  247. $('.modal-body tbody tr').append('<td>'+data.notes+'</td>');
  248. else
  249. $('.modal-body tbody tr').append('<td></td>');
  250. },
  251. async:true
  252. });
  253. $('#modal-view-criterion').modal();
  254. });
  255. @stop