暫無描述

assessment.blade.php 22KB

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