No Description

assessment.blade.php 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  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 id = "criteria-header">;
  25. @for($i=0; $i<$rubric->num_scales; $i++)
  26. <th>Scale {{$i+1}} ({{1+($i*($rubric->max_score/$rubric->num_scales))}} - {{(1+$i)*($rubric->max_score/$rubric->num_scales)}})</th>
  27. @endfor
  28. <th>Notes</th>
  29. </thead>
  30. <tbody>
  31. <tr>
  32. </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="well">
  42. <button id="button-language" class="btn btn-default btn-sm pull-right">Change language / Cambiar idioma</button>
  43. <div id="english-instructions">
  44. <h4>Instructions:</h4>
  45. <ol>
  46. <li>Fill in the scores per criterion for each student. You can see the student's final score in the last column.</li>
  47. <li>Click 'Publish Assessment' if you are done. Click 'Save as Draft' if you have not finished assessing the activity. You can come back later if you need to make any updates.
  48. <li>Unpublished results will be isolated. That is, they <strong>will not</strong> be aggregated to other results.</li>
  49. </ol>
  50. <h4>Notes:</h4>
  51. <ul>
  52. <li>If a particular criterion cannot be assessed for a student, select "N/A" (Not Applicable). This <strong>will not</strong> affect the student's score.</li>
  53. <li>If a particular criterion was assessed but the student did not complete the necessary work, you must select "0". This <strong>will</strong> affect the student's score.</li>
  54. <li>If a student did not complete any work for this activity, select "0" for all columns in that student's row.</li>
  55. <li>If a student dropped the class, select "N/A" (Not Applicable) for all columns in that student's row.</li>
  56. <li>Cells with "N/A" <strong>will not</strong> be used to determine whether a criterion is achieved. Only scores from 0 to 8 will be considered for this purpose.</li>
  57. <li>For this activity, <strong>at least one score must be from 1-{{$rubric->max_score}}.</strong> Otherwise, the 'Publish Assessment' and 'Save as Draft' buttons will be <strong>disabled</strong>. If you want to delete previously saved scores, go back to the activity and click the "Delete Assessment" button.</li>
  58. </ul>
  59. </div>
  60. <div id="spanish-instructions">
  61. <h4>Instrucciones:</h4>
  62. <ol>
  63. <li>Seleccione la puntuación por criterio para cada estudiante. Puede ver la puntuación final en la última columna.</li>
  64. <li>Oprima 'Publish Assessment' una vez termine. Si no ha terminado, oprima 'Save as Draft' (guardar como borrador). Puede volver a esta página luego si desea hacer cambios.</li>
  65. <li>Los resultados guardados como borrador estarán asilados. Es decir, <strong>no</strong> se agregarán a los demás resultados.</li>
  66. </ol>
  67. <h4>Notas:</h4>
  68. <ul>
  69. <li>Si un criterio particular no puede ser evaluado, seleccione "N/A" (No Aplica). Esto <strong>no</strong> afectará la puntuación final del estudiante.</li>
  70. <li>Si un criterio particular fue evaluado, pero el estudiante no completó el trabajo necesario, debe seleccionar "0". Esto <strong>sí</strong> afectará la puntuación final del estudiante.</li>
  71. <li>Si un estudiante no completó el trabajo para esta actividad, seleccione "0" en todas las columnas de la fila de ese estudiante.</li>
  72. <li>Si un estudiante se dio de baja, seleccione "N/A" (No Aplica) en todas las columnas de la fila de ese estudiante.</li>
  73. <li>Las celdas con "N/A" <strong>no</strong> serán utilizadas para determinar si un criterio se alcanzó o no. Solamente las puntuaciones del 0 al 8 serán consideradas.</li>
  74. <li>Para esta actividad, <strong>al menos una puntuación deber ser del 1 al {{$rubric->max_score}}.</strong> De otra manera, el botón para guardar <strong>se desactivará</strong>. Si quiere borrar los resultados del avalúo, vuelva a la actividad y oprima el botón que dice "Delete Assessment".</li>
  75. </ul>
  76. </div>
  77. </div>
  78. <input type='hidden' id='max' name= 'max' value='{{$rubric->max_score}}'>
  79. <input type ='hidden' id='num_of_scales' name ='num_of_scales' value ='{{$rubric->num_scales}}'>
  80. <p id="course">Course: {{{ $course->code }}} {{{ $course->number }}}</p>
  81. <p id="section">Section: {{{ $course->section }}}</p>
  82. {{ HTML::linkAction('ActivitiesController@show', 'Back to Activity', array($activity->id), array('class'=>'btn btn-default btn-sm pull-right')) }}
  83. <p id="activity" data-activity-id="{{{ $activity->id }}}">Activity: {{{ $activity->name}}} </p>
  84. <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>
  85. <table data-rubric-id="{{{ $rubric->id }}}" id="assessment-table" class="table table-striped table-condensed table-bordered">
  86. <thead>
  87. <tr>
  88. <th>
  89. </th>
  90. @foreach ($criterion_rubric as $index => $criterion)
  91. <th data-criterion-id="{{{ $criterion->criterion_id }}}" ><div class="th-box">
  92. <!--<div class="form-group row">
  93. <div class="col-xs-1">
  94. <label for="weight-{{$index}}">Weight</label>
  95. <input class="form-control" id="weight-{{$index}}" name='weight[]' type="text">
  96. </div>
  97. </div>-->
  98. Weight<input class="form-control" id="weight-{{$index}}" name='weight[]' type="text" style = "width: 50%">
  99. </div></th>
  100. @endforeach
  101. </tr>
  102. <tr>
  103. <th>
  104. <div class="th-box">
  105. Student
  106. </div>
  107. </th>
  108. @foreach ($criterion_rubric as $criterion)
  109. <th class="criterion-field" data-criterion-id="{{{ $criterion->criterion_id }}}" ><div class="th-box">{{ $criterion->name}}</div></th>
  110. @endforeach
  111. <th>Student Percentage</th>
  112. <th>Student % per Weight</th>
  113. <th>Comments</th>
  114. </tr>
  115. </thead>
  116. <tbody>
  117. <!-- If the activity was assessed, load the assessment. Otherwise load empty sheet -->
  118. @if(sizeof($assessments)!=0)
  119. <!-- For each assessment -->
  120. @foreach ($assessments as $assessment)
  121. <tr class="student-row">
  122. <!-- Fetch student name -->
  123. <td class="student-field" data-student-id="{{ $assessment->student_id }}">
  124. {{{ $assessment->name }}}
  125. </td>
  126. <!-- For each criterion in the rubric, there's a score field -->
  127. @for ($i = 0; $i<sizeof($criterion_rubric); $i++)
  128. <td class="score-field">
  129. <select name="" id="" class="form-control" data-toggle="tooltip" data-placement="right" title="{{{ $assessment->name }}}">
  130. <!-- Option from 0-8 -->
  131. @for ($j=0; $j<=8; $j++)
  132. <!-- If the decoded scores with index as the assessment id and second index as criterion id equals the loop index, mark it as selected -->
  133. @if( $j == $scores_array[$assessment->id][$criterion_rubric[$i]->criterion_id])
  134. <option value="{{$j}}" selected="selected">{{ $j }}</option>
  135. @else
  136. <option value="{{$j}}">{{ $j }}</option>
  137. @endif
  138. @endfor
  139. <!-- N/A option -->
  140. @if( $scores_array[$assessment->id][$criterion_rubric[$i]->criterion_id]=="N/A")
  141. <option value="N/A" selected="selected">N/A</option>
  142. @else
  143. <option value="N/A">N/A</option>
  144. @endif
  145. </select>
  146. </td>
  147. @endfor
  148. <td class="percentage">{{{ $assessment->percentage }}}</td>
  149. <td class="">
  150. <textarea class="comments full-textarea" placeholder="Max. 255 characters" maxLength="255" >{{ $assessment->comments }}</textarea>
  151. </td>
  152. </tr>
  153. @endforeach
  154. @else
  155. @foreach ($students as $student)
  156. <tr class="student-row">
  157. <td class="student-field" data-student-id={{ $student->id }}>{{{ $student->name }}}</td>
  158. @for ($i = 0; $i<sizeof($criterion_rubric); $i++)
  159. <td class="score-field">
  160. <select name="" id="" class="form-control" data-toggle="tooltip" data-placement="right" title="{{{ $student->name }}}">
  161. @for($j=0; $j<=$rubric->max_score; $j++)
  162. <option value ='{{$j}}'>{{$j}}</option>
  163. @endfor
  164. <option selected="selected" value="N/A">N/A</option>
  165. </select>
  166. </td>
  167. @endfor
  168. <td class="percentage"></td>
  169. <td class="percentage-per-w"></td>
  170. <td class="comments"><textarea class="comments full-textarea" placeholder="Max. 255 characters" maxLength="255" ></textarea></td>
  171. </tr>
  172. @endforeach
  173. @endif
  174. </tbody>
  175. <tfoot>
  176. <tr>
  177. <td>
  178. <strong>Passed Criteria Percentage </strong>
  179. </td>
  180. @for ($i = 0; $i<sizeof($criterion_rubric); $i++)
  181. <td class="total"><strong><span class="total-value"></span><span class="percent-sign">%</span></strong>
  182. </td>
  183. @endfor
  184. <td></td>
  185. </tr>
  186. </tfoot>
  187. </table>
  188. <div class="text-center">
  189. <button id="button-submit-assessment" class="btn btn-primary btn-lg publish">Publish Assessment</button>
  190. <button id="button-draft-assessment" class="btn btn-primary btn-lg draft">Save as Draft</button>
  191. </div>
  192. </div>
  193. </div>
  194. @stop
  195. @section('included-js')
  196. <!-- StickyTableHeaders js -->
  197. <script src="{{ asset('vendor/stickyTableHeaders/js/jquery.stickytableheaders.min.js') }}"></script>
  198. @stop
  199. @section ('javascript')
  200. // --------------------------------------------------------------------------
  201. // Page load
  202. // --------------------------------------------------------------------------
  203. changeTable();
  204. // Enable fixed headers
  205. $('#assessment-table').stickyTableHeaders();
  206. // Hide spanish instructions by default
  207. $('#spanish-instructions').toggle();
  208. $('.total').each(function(index)
  209. {
  210. percentagePerCriterion(index+1);
  211. });
  212. $('.student-row').each(function(index)
  213. {
  214. percentagePerStudent($(this));
  215. });
  216. // Highlight student names on hover
  217. $('.student-row td').on('mouseover', function()
  218. {
  219. $('.student-field').css(
  220. {
  221. 'color': 'black',
  222. });
  223. $(this).siblings('.student-field').css(
  224. {
  225. 'color': '#DD0026',
  226. });
  227. });
  228. toggleSaveButton();
  229. // --------------------------------------------------------------------------
  230. // Functions
  231. // --------------------------------------------------------------------------
  232. // Calculate average of students that passed a specific criterion
  233. function percentagePerCriterion(columnIndex)
  234. {
  235. // Object to hold the score sum of each criterion
  236. var sum = 0 ;
  237. var total = 0;
  238. columnIndex+=1;
  239. // Iterate through rows of column
  240. $('table tbody tr td:nth-child('+columnIndex+')').each(function( index )
  241. {
  242. var val = parseInt($(this).children('select').find(':selected').val());
  243. /* If N/A or 0 are chosen, they are ignored in the calculation. */
  244. if(val % 1 === 0)
  245. {
  246. if(val >= parseInt($('#expected_points').text()))
  247. {
  248. sum+=1;
  249. }
  250. total+=1;
  251. }
  252. });
  253. var percentage= (sum/total*100).toFixed(2);
  254. // If no criteria were assessed, set the percentage to 0.
  255. // This is to avoid show NaN%
  256. if(total==0)
  257. {
  258. percentage="N/A";
  259. $('.total:nth-child('+columnIndex+') span.total-value').html(percentage);
  260. $('.total:nth-child('+columnIndex+') span.percent-sign').hide();
  261. }
  262. else
  263. {
  264. $('.total:nth-child('+columnIndex+') span.total-value').html(percentage);
  265. $('.total:nth-child('+columnIndex+') span.percent-sign').show();
  266. }
  267. }
  268. // Calculate total for a specific student
  269. function percentagePerStudent(row)
  270. {
  271. // Object to hold the score student's total score
  272. var sum = 0 ;
  273. var total = 0;
  274. var percentage = 0;
  275. var max_score = parseInt($('#max').val());
  276. row.find('td.score-field').each(function(index)
  277. {
  278. var val = parseInt($(this).children('select').find(':selected').val());
  279. if(val % 1 === 0) //If number is integer
  280. {
  281. sum += val;
  282. total+=1;
  283. }
  284. });
  285. percentage =((sum/(total*max_score))*100).toFixed(2);
  286. //If percentage is not a number, set it to 0.
  287. if(isNaN(percentage))
  288. {
  289. percentage="N/A";
  290. row.find('.percentage').html('<strong>'+percentage+'</strong>');
  291. }
  292. else
  293. {
  294. row.find('.percentage').html('<strong>'+percentage+'%</strong>');
  295. }
  296. }
  297. function toggleSaveButton()
  298. {
  299. // Check at least one total criterion percentage is not zero
  300. var all_zeros_criteria = true;
  301. $('.total-value').each(function(index)
  302. {
  303. if(Number($(this).text())>0.00)
  304. all_zeros_criteria = false;
  305. });
  306. // Check at least one total student percentage is not zero
  307. var all_zeros_students = true;
  308. $('.percentage').each(function(index)
  309. {
  310. var value = $(this).text().replace('%', '');
  311. if(Number(value)>0.00)
  312. all_zeros_students = false;
  313. });
  314. if(all_zeros_criteria && all_zeros_students)
  315. {
  316. $('#button-submit-assessment').prop('disabled', true);
  317. $('#button-draft-assessment').prop('disabled', true);
  318. }
  319. else
  320. {
  321. $('#button-submit-assessment').prop('disabled', false);
  322. $('#button-draft-assessment').prop('disabled', false);
  323. }
  324. return;
  325. }
  326. // --------------------------------------------------------------------------
  327. // Events
  328. // --------------------------------------------------------------------------
  329. // When any score changes, calculate percentages
  330. $('select').on('change', function(e)
  331. {
  332. percentagePerCriterion($(this).parent().index());
  333. percentagePerStudent($(this).closest('tr'));
  334. toggleSaveButton();
  335. });
  336. // Submit button is clicked
  337. $('#button-submit-assessment, #button-draft-assessment').on('click', function(e)
  338. {
  339. var draft = 0;
  340. if($(this).hasClass('draft'))
  341. draft = 1;
  342. var expected_points = parseInt($('#expected_points').text());
  343. var expected_percentage = parseInt($('#expected_percentage').text());
  344. //Prevent page refresh
  345. e.preventDefault();
  346. // Row in the database
  347. var activity_id = $('#activity').data('activity-id');
  348. // Object to hold the score sum of each criterion
  349. var criteriaSumObject = new Object();
  350. // Object to hold % of students that passed each criterion
  351. var CriteriaAchievedPercentage = new Object();
  352. // Object to hold all student evaluations
  353. var studentAssessments = new Array();
  354. // Iterate through all students
  355. $('#assessment-table tbody tr').each(function( index )
  356. {
  357. var ScoresObject = new Object(); // Scores column in database
  358. var CriterionObject = new Object(); // Objects inside ScoresObject
  359. var SingleStudentAssessment = new Object();
  360. SingleStudentAssessment.student_id = $(this).find('.student-field').data('student-id');
  361. // For each criterion, store the score in array
  362. $(this).children('td.score-field').each(function(index)
  363. {
  364. // Table cell with a score
  365. var scoreField = $(this);
  366. // Criterion being evaluated in current iteration
  367. var criterion_id = $('.criterion-field').eq(index).data('criterion-id');
  368. // Score in the cell
  369. var score = scoreField.children('select').find(':selected').val();
  370. // Store the score in the scores Object
  371. ScoresObject[criterion_id]=score;
  372. // Initialize the index for the sum object, if it's undefined
  373. if(typeof(criteriaSumObject[criterion_id]) == 'undefined')
  374. {
  375. criteriaSumObject[criterion_id]=0;
  376. }
  377. // Add to this criterion's total
  378. criteriaSumObject[criterion_id]+=parseInt(score);
  379. });
  380. SingleStudentAssessment.scores = ScoresObject;
  381. SingleStudentAssessment.percentage = $(this).find('.percentage').text();
  382. SingleStudentAssessment.comments = $.trim($(this).find('.comments').val());
  383. // console.log('comment '+index+': '+SingleStudentAssessment.comments);
  384. // console.log('student object: '+JSON.stringify(SingleStudentAssessment));
  385. var clone = jQuery.extend({}, SingleStudentAssessment);
  386. studentAssessments.push(clone);
  387. });
  388. // console.log('students: '+JSON.stringify(studentAssessments));
  389. // console.log('total points per criteria: '+JSON.stringify(criteriaSumObject));
  390. // Iterate through all evaluated criteria, determining which were achieved
  391. // by comparing the completion percentage to the expected percentage
  392. var CriteriaAchievedResults = new Object();
  393. $('.total').each(function(index)
  394. {
  395. var id = $('.criterion-field').eq(index).data('criterion-id');
  396. CriteriaAchievedPercentage[id] = parseFloat($(this).find('span').text());
  397. //Set whether criterion was achieved (1) or not (0)
  398. if(CriteriaAchievedPercentage[id] >= expected_percentage)
  399. {
  400. CriteriaAchievedResults[id]=1;
  401. }
  402. else if (CriteriaAchievedPercentage[id] < expected_percentage)
  403. {
  404. CriteriaAchievedResults[id]=0;
  405. }
  406. else
  407. {
  408. CriteriaAchievedResults[id]=null;
  409. }
  410. });
  411. // console.log('criteria percentages: '+JSON.stringify(CriteriaAchievedPercentage));
  412. // console.log('criteria achieved results: '+JSON.stringify(CriteriaAchievedResults));
  413. // Save activity to the database
  414. $.post
  415. (
  416. "{{ URL::action('ActivitiesController@saveAssessment') }}",
  417. {
  418. activity_id: activity_id,
  419. draft: draft,
  420. criteria_achieved_percentage: JSON.stringify(CriteriaAchievedPercentage),
  421. criteria_achievement: JSON.stringify(CriteriaAchievedResults),
  422. student_scores: JSON.stringify(studentAssessments),
  423. },
  424. function(data)
  425. {
  426. location.replace(data);
  427. }
  428. );
  429. });
  430. // Language button is clicked
  431. $('#button-language').on('click', function(e)
  432. {
  433. $('#english-instructions').stop().toggle();
  434. $('#spanish-instructions').stop().toggle();
  435. });
  436. // Criterion name is clicked
  437. $('.criterion-field').on('click', function()
  438. {
  439. $.ajax({
  440. type: 'POST',
  441. url: "{{ URL::action('RubricsController@fetchRubricCriterion') }}",
  442. data: {
  443. rubric_id: $(this).closest('table').data('rubric-id'),
  444. criterion_id: $(this).data('criterion-id'),
  445. },
  446. success: function(data)
  447. {
  448. data = JSON.parse(data);
  449. $('.modal-title').html(data.name);
  450. $('.modal-body tbody tr').empty();
  451. $('.modal-body tbody tr').append
  452. (
  453. '<td>'+data.description12+'</td>'
  454. +'<td>'+data.description34+'</td>'
  455. +'<td>'+data.description56+'</td>'
  456. +'<td>'+data.description78+'</td>'
  457. );
  458. if(data.notes!=null)
  459. $('.modal-body tbody tr').append('<td>'+data.notes+'</td>');
  460. else
  461. $('.modal-body tbody tr').append('<td></td>');
  462. },
  463. async:true
  464. });
  465. $('#modal-view-criterion').modal();
  466. });
  467. @stop