Nessuna descrizione

assessment.blade.php 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  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>{{$rubric->titles[$i]}} ({{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 {{$rubric->max_score}} 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 {{$rubric->max_score}} 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 ($rubric_criterion as $index => $criterion)
  91. <th data-criterion-id="{{{ $criterion->criterion_id }}}" ><div class="th-box">
  92. Weight<input class="form-control" id="weight-{{$index}}" name='weight[]' type="text" value="{{$criterion->weight}}" data-activity-criterion-id="{{$criterion->activity_criterion_id}}">
  93. </div></th>
  94. @endforeach
  95. </tr>
  96. <tr>
  97. <th>
  98. <div class="th-box">
  99. Student
  100. </div>
  101. </th>
  102. @foreach ($rubric_criterion as $criterion)
  103. <th class="criterion-field" data-activity-criterion-id = "{{$criterion->activity_criterion_id}}"data-rubric-criterion-id = "{{$criterion->rubric_criterion_id}}" data-criterion-id="{{{ $criterion->criterion_id }}}" ><div class="th-box">{{ $criterion->name}}</div></th>
  104. @endforeach
  105. <th>Student Percentage</th>
  106. <th>Student % per Weight</th>
  107. <th>Comments</th>
  108. </tr>
  109. </thead>
  110. <tbody>
  111. <!-- If the activity was assessed, load the assessment. Otherwise load empty sheet -->
  112. @if(sizeof($assessments)!=0)
  113. <!-- For each assessment -->
  114. @foreach ($students as $student)
  115. <tr class="student-row">
  116. <!-- Fetch student name -->
  117. <td class="student-field" data-student-id="{{ $student->id }}">
  118. {{{ $student->name }}}
  119. </td>
  120. <!-- For each criterion in the rubric, there's a score field -->
  121. @for ($i = 0; $i<sizeof($rubric_criterion); $i++)
  122. <td class="score-field">
  123. <select name="" id="" class="form-control" data-toggle="tooltip" data-placement="right" title="{{{ $student->name }}}">
  124. <!-- Option from 0-8 -->
  125. @for ($j=0; $j<=$rubric->max_score; $j++)
  126. <!-- If the decoded scores with index as the assessment id and second index as criterion id equals the loop index, mark it as selected -->
  127. @if(array_key_exists($student->id, $scores_array) && isset($scores_array[$student->id][$rubric_criterion[$i]->activity_criterion_id]) && $j == $scores_array[$student->id][$rubric_criterion[$i]->activity_criterion_id])
  128. <option value="{{$j}}" selected="selected">{{ $j }}</option>
  129. @else
  130. <option value="{{$j}}">{{ $j }}</option>
  131. @endif
  132. @endfor
  133. <!-- N/A option -->
  134. @if( !array_key_exists($student->id, $scores_array)|| !isset($scores_array[$student->id][$rubric_criterion[$i]->activity_criterion_id]))
  135. <option value="N/A" selected="selected">N/A</option>
  136. @else
  137. <option value="N/A">N/A</option>
  138. @endif
  139. </select>
  140. </td>
  141. @endfor
  142. <td class="percentage"></td>
  143. <td class="percentage-per-weight"></td>
  144. <td class="">
  145. <textarea class="comments full-textarea" placeholder="Max. 255 characters" maxLength="255" >
  146. @if(array_key_exists($student->id, $scores_array))
  147. {{ $scores_array[$student->id]["comments"] }}
  148. @endif
  149. </textarea>
  150. </td>
  151. </tr>
  152. @endforeach
  153. @else
  154. @foreach ($students as $student)
  155. <tr class="student-row">
  156. <td class="student-field" data-student-id={{ $student->id }}>{{{ $student->name }}}</td>
  157. @for ($i = 0; $i<sizeof($rubric_criterion); $i++)
  158. <td class="score-field" data-weight = '1'>
  159. <select name="" id="" class="form-control" data-toggle="tooltip" data-placement="right" title="{{{ $student->name }}}">
  160. @for($j=0; $j<=$rubric->max_score; $j++)
  161. <option value ='{{$j}}'>{{$j}}</option>
  162. @endfor
  163. <option selected="selected" value="N/A">N/A</option>
  164. </select>
  165. </td>
  166. @endfor
  167. <td class="percentage"></td>
  168. <td class="percentage-per-weight"></td>
  169. <td class="comments"><textarea class="comments full-textarea" placeholder="Max. 255 characters" maxLength="255" ></textarea></td>
  170. </tr>
  171. @endforeach
  172. @endif
  173. </tbody>
  174. <tfoot>
  175. <tr>
  176. <td>
  177. <strong>Passed Criteria Percentage </strong>
  178. </td>
  179. @for ($i = 0; $i<sizeof($rubric_criterion); $i++)
  180. <td class="total"><strong><span class="total-value"></span><span class="percent-sign">%</span></strong>
  181. </td>
  182. @endfor
  183. <td></td>
  184. </tr>
  185. </tfoot>
  186. </table>
  187. <div class="text-center">
  188. <button id="button-submit-assessment" class="btn btn-primary btn-lg publish">Publish Assessment</button>
  189. <button id="button-diagnostic-assessment" class="btn btn-primary btn-lg diagnostic">Save as Diagnostic Test</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. <script>
  195. $('#button-submit-assessment, #button-draft-assessment, #button-diagnostic-assessment').on('click', function(e)
  196. {
  197. var draft = 0;
  198. var diagnostic=0
  199. if($(this).hasClass('draft'))
  200. draft = 1;
  201. if($(this).hasClass('diagnostic'))
  202. diagnostic = 1;
  203. var expected_points = parseInt($('#expected_points').text());
  204. var expected_percentage = parseInt($('#expected_percentage').text());
  205. //Prevent page refresh
  206. e.preventDefault();
  207. // Row in the database
  208. var activity_id = $('#activity').data('activity-id');
  209. var student_info = new Object();
  210. // Object to hold the score sum of each criterion
  211. var criteriaSumObject = new Object();
  212. // Object to hold % of students that passed each criterion
  213. var CriteriaAchievedPercentage = new Object();
  214. // Object to hold all student evaluations
  215. var studentAssessments = new Array();
  216. var weights = new Object();
  217. $('input[name="weight[]"]').each(function (index){
  218. activity_criterion_id = $(this).data('activity-criterion-id');
  219. weight = $(this).val();
  220. weights[activity_criterion_id] = weight;
  221. });
  222. // Iterate through all students
  223. $('#assessment-table tbody tr').each(function( index )
  224. {
  225. student_info[index] = new Object()
  226. student_info[index].studentId = $(this).find('.student-field').data('student-id');
  227. student_info[index].activity_crit_id = new Object();
  228. /* var ScoresObject = new Object(); // Scores column in database
  229. var CriterionObject = new Object(); // Objects inside ScoresObject
  230. var SingleStudentAssessment = new Object();
  231. SingleStudentAssessment.student_id = $(this).find('.student-field').data('student-id');
  232. */
  233. // For each criterion, store the score in array
  234. $(this).children('td.score-field').each(function(index2)
  235. {
  236. // Table cell with a score
  237. var scoreField = $(this);
  238. // Criterion being evaluated in current iteration
  239. activity_criterion_id = $('.criterion-field').eq(index2).data('activity-criterion-id');
  240. score = scoreField.children('select').find(':selected').val();
  241. if(score != "N/A")
  242. student_info[index].activity_crit_id[activity_criterion_id] = score;
  243. // Score in the cell
  244. //var score = scoreField.children('select').find(':selected').val();
  245. // Store the score in the scores Object
  246. //ScoresObject[criterion_id]=score;
  247. // Initialize the index for the sum object, if it's undefined
  248. //if(typeof(criteriaSumObject[criterion_id]) == 'undefined')
  249. //{
  250. // criteriaSumObject[criterion_id]=0;
  251. //}
  252. // Add to this criterion's total
  253. //criteriaSumObject[criterion_id]+=parseInt(score);
  254. });
  255. student_info[index].comments = $.trim($(this).find('.comments').val());
  256. //SingleStudentAssessment.scores = ScoresObject;
  257. //SingleStudentAssessment.percentage = $(this).find('.percentage').text();
  258. //SingleStudentAssessment.comments = $.trim($(this).find('.comments').val());
  259. // console.log('comment '+index+': '+SingleStudentAssessment.comments);
  260. // console.log('student object: '+JSON.stringify(SingleStudentAssessment));
  261. //var clone = jQuery.extend({}, SingleStudentAssessment);
  262. //studentAssessments.push(clone);
  263. });
  264. // console.log('students: '+JSON.stringify(studentAssessments));
  265. // console.log('total points per criteria: '+JSON.stringify(criteriaSumObject));
  266. // Iterate through all evaluated criteria, determining which were achieved
  267. // by comparing the completion percentage to the expected percentage
  268. /*var CriteriaAchievedResults = new Object();
  269. $('.total').each(function(index)
  270. {
  271. var id = $('.criterion-field').eq(index).data('criterion-id');
  272. CriteriaAchievedPercentage[id] = parseFloat($(this).find('span').text());
  273. //Set whether criterion was achieved (1) or not (0)
  274. if(CriteriaAchievedPercentage[id] >= expected_percentage)
  275. {
  276. CriteriaAchievedResults[id]=1;
  277. }
  278. else if (CriteriaAchievedPercentage[id] < expected_percentage)
  279. {
  280. CriteriaAchievedResults[id]=0;
  281. }
  282. else
  283. {
  284. CriteriaAchievedResults[id]=null;
  285. }
  286. });
  287. */
  288. // console.log('criteria percentages: '+JSON.stringify(CriteriaAchievedPercentage));
  289. // console.log('criteria achieved results: '+JSON.stringify(CriteriaAchievedResults));
  290. // Save activity to the database
  291. $.post
  292. (
  293. "{{ URL::action('ActivitiesController@saveAssessment') }}",
  294. {
  295. activity_id: activity_id,
  296. draft: draft,
  297. weights: JSON.stringify(weights),
  298. student_info: JSON.stringify(student_info),
  299. diagnostic:diagnostic
  300. },
  301. function(data)
  302. {
  303. location.replace(data);
  304. }
  305. );
  306. });
  307. </script>
  308. @stop
  309. @section('included-js')
  310. <!-- StickyTableHeaders js -->
  311. <script src="{{ asset('vendor/stickyTableHeaders/js/jquery.stickytableheaders.min.js') }}"></script>
  312. @stop
  313. @section ('javascript')
  314. // --------------------------------------------------------------------------
  315. // Page load
  316. // --------------------------------------------------------------------------
  317. // Enable fixed headers
  318. //$('#assessment-table').stickyTableHeaders();
  319. // Hide spanish instructions by default
  320. $('#spanish-instructions').toggle();
  321. $('.total').each(function(index)
  322. {
  323. percentagePerCriterion(index+1);
  324. });
  325. $('.student-row').each(function(index)
  326. {
  327. percentagePerStudent($(this));
  328. });
  329. // Highlight student names on hover
  330. $('.student-row td').on('mouseover', function()
  331. {
  332. $('.student-field').css(
  333. {
  334. 'color': 'black',
  335. });
  336. $(this).siblings('.student-field').css(
  337. {
  338. 'color': '#DD0026',
  339. });
  340. });
  341. toggleSaveButton();
  342. // --------------------------------------------------------------------------
  343. // Functions
  344. // --------------------------------------------------------------------------
  345. // Calculate average of students that passed a specific criterion
  346. function percentagePerCriterion(columnIndex)
  347. {
  348. // Object to hold the score sum of each criterion
  349. var sum = 0 ;
  350. var total = 0;
  351. columnIndex+=1;
  352. // Iterate through rows of column
  353. $('table tbody tr td:nth-child('+columnIndex+')').each(function( index )
  354. {
  355. var val = parseInt($(this).children('select').find(':selected').val());
  356. /* If N/A or 0 are chosen, they are ignored in the calculation. */
  357. if(val % 1 === 0)
  358. {
  359. if(val >= parseInt($('#expected_points').text()))
  360. {
  361. sum+=1;
  362. }
  363. total+=1;
  364. }
  365. });
  366. var percentage= (sum/total*100).toFixed(2);
  367. // If no criteria were assessed, set the percentage to 0.
  368. // This is to avoid show NaN%
  369. if(total==0)
  370. {
  371. percentage="N/A";
  372. $('.total:nth-child('+columnIndex+') span.total-value').html(percentage);
  373. $('.total:nth-child('+columnIndex+') span.percent-sign').hide();
  374. }
  375. else
  376. {
  377. $('.total:nth-child('+columnIndex+') span.total-value').html(percentage);
  378. $('.total:nth-child('+columnIndex+') span.percent-sign').show();
  379. }
  380. }
  381. // Calculate total for a specific student
  382. function percentagePerStudent(row)
  383. {
  384. // Object to hold the score student's total score
  385. var sum = 0 ;
  386. var total = 0;
  387. var percentage = 0;
  388. var max_score = parseInt($('#max').val());
  389. sum_of_weight = 0;
  390. per_of_weight =0;
  391. row.find('td.score-field').each(function(index)
  392. {
  393. var val = parseInt($(this).children('select').find(':selected').val());
  394. if(val % 1 === 0) //If number is integer
  395. {
  396. sum += val;
  397. total+=1;
  398. per_of_weight += val * parseInt($('#weight-'+index).val());
  399. sum_of_weight += parseInt($('#weight-'+index).val());
  400. }
  401. });
  402. percentage_per_weight = (100 *(per_of_weight/(max_score*sum_of_weight))).toFixed(2);
  403. percentage =((sum/(total*max_score))*100).toFixed(2);
  404. //If percentage is not a number, set it to 0.
  405. if(isNaN(percentage))
  406. {
  407. percentage="N/A";
  408. row.find('.percentage').html('<strong>'+percentage+'</strong>');
  409. }
  410. else
  411. {
  412. row.find('.percentage').html('<strong>'+percentage+'%</strong>');
  413. }
  414. if(isNaN(percentage_per_weight)){
  415. percentage_per_weight="N/A";
  416. row.find('.percentage-per-weight').html('<strong>'+percentage_per_weight+'</strong>');
  417. }
  418. else{
  419. row.find('.percentage-per-weight').html('<strong>'+percentage_per_weight+'%</strong>');
  420. }
  421. }
  422. function toggleSaveButton()
  423. {
  424. // Check at least one total criterion percentage is not zero
  425. var all_zeros_criteria = true;
  426. $('.total-value').each(function(index)
  427. {
  428. if(Number($(this).text())>0.00)
  429. all_zeros_criteria = false;
  430. });
  431. // Check at least one total student percentage is not zero
  432. var all_zeros_students = true;
  433. $('.percentage').each(function(index)
  434. {
  435. var value = $(this).text().replace('%', '');
  436. if(Number(value)>0.00)
  437. all_zeros_students = false;
  438. });
  439. if(all_zeros_criteria && all_zeros_students)
  440. {
  441. $('#button-submit-assessment').prop('disabled', true);
  442. $('#button-draft-assessment').prop('disabled', true);
  443. }
  444. else
  445. {
  446. $('#button-submit-assessment').prop('disabled', false);
  447. $('#button-draft-assessment').prop('disabled', false);
  448. }
  449. return;
  450. }
  451. // --------------------------------------------------------------------------
  452. // Events
  453. // --------------------------------------------------------------------------
  454. $('input[name="weight[]"]').on('change', function(e){
  455. $('.student-row').each(function(index)
  456. {
  457. percentagePerStudent($(this));
  458. });
  459. });
  460. // When any score changes, calculate percentages
  461. $('select').on('change', function(e)
  462. {
  463. percentagePerCriterion($(this).parent().index());
  464. percentagePerStudent($(this).closest('tr'));
  465. toggleSaveButton();
  466. });
  467. //LA LINEA DONDE VA, 410
  468. // Submit button is clicked
  469. // Language button is clicked
  470. $('#button-language').on('click', function(e)
  471. {
  472. $('#english-instructions').stop().toggle();
  473. $('#spanish-instructions').stop().toggle();
  474. });
  475. // Criterion name is clicked
  476. $('.criterion-field').on('click', function()
  477. {
  478. $.ajax({
  479. type: 'POST',
  480. url: "{{ URL::action('RubricsController@fetchRubricCriterion') }}",
  481. data: {
  482. criterion_id: $(this).data('criterion-id')
  483. },
  484. success: function(data)
  485. {
  486. data = JSON.parse(data);
  487. $('.modal-title').html(data.criteria.name);
  488. descriptions = '';
  489. $('.modal-body tbody tr').empty();
  490. for(i =0; i<{{$rubric->num_scales}}; i++){
  491. descriptions += '<td>'+data[i].description+'</td>'
  492. }
  493. $('.modal-body tbody tr').append
  494. (
  495. descriptions
  496. );
  497. if(data.criteria.notes!=null)
  498. $('.modal-body tbody tr').append('<td>'+data.criteria.notes+'</td>');
  499. else
  500. $('.modal-body tbody tr').append('<td></td>');
  501. },
  502. async:true
  503. });
  504. $('#modal-view-criterion').modal();
  505. });
  506. $(window).load(function(){
  507. $(".tableFloatingHeader").each(function(){
  508. $(this).remove();
  509. })
  510. });
  511. @stop