No Description

view_assessment.blade.php 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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>Student</th>
  53. @foreach ($rubric_contents as $criterion)
  54. <th class="criterion-field" data-criterion-id="{{{ $criterion->id }}}"><div class="th-box">{{ $criterion->name}}</div></th>
  55. @endforeach
  56. <th>Student Percentage</th>
  57. </tr>
  58. </thead>
  59. <tbody>
  60. <!-- If the activity was assessed, load the assessment. Otherwise load empty sheet -->
  61. @if(sizeof($assessments)!=0)
  62. <!-- For each assessment -->
  63. @foreach ($assessments as $assessment)
  64. <tr class="student-row">
  65. <!-- Fetch student name -->
  66. <td class="student-field" data-student-id="{{ $assessment->student_id }}">
  67. {{{ Student::find($assessment->student_id)->name }}}
  68. </td>
  69. <!-- For each criterion in the rubric, there's a score field -->
  70. @for ($i = 0; $i<sizeof($rubric_contents); $i++)
  71. <td class="score-field text-center">
  72. {{ $scores_array[$assessment->id][$rubric_contents[$i]->id] }}
  73. </td>
  74. @endfor
  75. <td class="percentage text-center">{{{ $assessment->percentage }}}</td>
  76. </tr>
  77. @endforeach
  78. @endif
  79. </tbody>
  80. <tfoot>
  81. <tr>
  82. <td>
  83. <strong>Passed Criteria Percentage </strong>
  84. </td>
  85. @for ($i = 0; $i<sizeof($rubric_contents); $i++)
  86. <td class="total text-center"><strong><span class="total-value"></span>%</strong>
  87. </td>
  88. @endfor
  89. <td></td>
  90. </tr>
  91. </tfoot>
  92. </table>
  93. </div>
  94. </div>
  95. @stop
  96. @section('included-js')
  97. <!-- StickyTableHeaders js -->
  98. <script src="{{ asset('vendor/stickyTableHeaders/js/jquery.stickytableheaders.min.js') }}"></script>
  99. @stop
  100. @section ('javascript')
  101. // --------------------------------------------------------------------------
  102. // Page load
  103. // --------------------------------------------------------------------------
  104. // Enable fixed headers
  105. $('table').stickyTableHeaders();
  106. $('.total').each(function(index)
  107. {
  108. percentagePerCriterionPlain(index+1);
  109. });
  110. $('.student-row').each(function(index)
  111. {
  112. percentagePerStudentPlain($(this));
  113. });
  114. // --------------------------------------------------------------------------
  115. // Functions
  116. // --------------------------------------------------------------------------
  117. // Calculate average of students that passed a specific criterion
  118. function percentagePerCriterionPlain(columnIndex)
  119. {
  120. // Object to hold the score sum of each criterion
  121. var sum = 0 ;
  122. var total = 0;
  123. columnIndex+=1;
  124. // Iterate through rows of column
  125. $('table tbody tr td:nth-child('+columnIndex+')').each(function( index )
  126. {
  127. var val = parseInt($(this).text());
  128. /* Check if number is integer. If N/A or 0 are chosen, they are ignored in the calculation. */
  129. if(val % 1 === 0 && val!=0)
  130. {
  131. if(val >= parseInt($('#expected_points').text()))
  132. {
  133. sum+=1;
  134. }
  135. total+=1;
  136. }
  137. });
  138. var percentage= (sum/total*100).toFixed(2);
  139. // If no criteria were assessed, set the percentage to 0.
  140. // This is to avoid show NaN%
  141. if(total==0)
  142. percentage="0.00";
  143. $('.total:nth-child('+columnIndex+') span').html(percentage);
  144. }
  145. // Calculate total for a specific student
  146. function percentagePerStudentPlain(row)
  147. {
  148. // Object to hold the score student's total score
  149. var sum = 0 ;
  150. var total = 0;
  151. var percentage = 0;
  152. row.find('td.score-field').each(function(index)
  153. {
  154. var val = parseInt($(this).text());
  155. if(val % 1 === 0) // Check if number is an integer
  156. {
  157. sum += val;
  158. total+=1;
  159. }
  160. });
  161. percentage =((sum/(total*8))*100).toFixed(2);
  162. //If percentage is not a number, set it to 0.
  163. if(isNaN(percentage))
  164. percentage="0.00";
  165. row.find('.percentage').html('<strong>'+percentage+'%</strong>');
  166. }
  167. // --------------------------------------------------------------------------
  168. // Events
  169. // --------------------------------------------------------------------------
  170. // Criterion name is clicked
  171. $('.criterion-field').on('click', function()
  172. {
  173. $.ajax({
  174. type: 'POST',
  175. url: "{{ URL::action('CriteriaController@fetchCriterionWithTrashed') }}",
  176. data: { id: $(this).data('criterion-id') },
  177. success: function(data)
  178. {
  179. $('.modal-title').html(data.name);
  180. $('.modal-body tbody tr').empty();
  181. $('.modal-body tbody tr').append
  182. (
  183. '<td>'+data.description12+'</td>'
  184. +'<td>'+data.description34+'</td>'
  185. +'<td>'+data.description56+'</td>'
  186. +'<td>'+data.description78+'</td>'
  187. );
  188. if(data.notes!=null)
  189. $('.modal-body tbody tr').append('<td>'+data.notes+'</td>');
  190. else
  191. $('.modal-body tbody tr').append('<td></td>');
  192. },
  193. async:true
  194. });
  195. $('#modal-view-criterion').modal();
  196. });
  197. @stop