설명 없음

rubrics.blade.php 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  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. <!-- No rubric modal -->
  15. <div class="modal fade" id="modal-no-rubric">
  16. <div class="modal-dialog modal-sm">
  17. <div class="modal-content">
  18. <div class="modal-header">
  19. <h4 class="modal-title">No Rubric Available</h4>
  20. </div>
  21. <div class="modal-body">
  22. There are no existing rubrics for your School. Please contact your Program's Coordinator. You will be redirected to the previous page.
  23. </div>
  24. <div class="modal-footer">
  25. <button id="button-redirect" class="btn btn-primary">Ok</button>
  26. </div>
  27. </div><!-- /.modal-content -->
  28. </div><!-- /.modal-dialog -->
  29. </div><!-- /.modal -->
  30. <div class="row">
  31. <div class="col-md-12">
  32. <div>
  33. {{ HTML::linkAction('ActivitiesController@show', 'Back to Activity', array($activity->id), array('class'=>'btn btn-default btn-sm pull-right')) }}
  34. <br>
  35. <br>
  36. </div>
  37. <div class="well">
  38. @if(count($activity->rubric)!=0)
  39. <span id="assigned_rubric" class="hidden" data-assigned-rubric="{{{ $activity->rubric[0]->id }}}"></span>
  40. @endif
  41. <input id="activity_id" type="hidden" value="{{{ $activity->id}}}">
  42. <div class="form-group">
  43. @if($activity->draft)
  44. <label>Select a Rubric:</label>
  45. <select id="select-template" class="form-control selectpicker">
  46. @else
  47. <label>Rubric (Assessment was published):</label>
  48. <select id="select-template" class="form-control selectpicker" disabled>
  49. @endif
  50. @foreach ($templates as $template)
  51. @if(count($activity->rubric)!=0 && $template->name == Rubric::find($activity->rubric[0]->id)->name)
  52. <option data-template-id="{{ $template->id }}" class="template" selected="selected">{{ $template->name }}</option>
  53. @else
  54. <option data-template-id="{{ $template->id }}" class="template">{{ $template->name }}</option>
  55. @endif
  56. @endforeach
  57. </select>
  58. </div>
  59. <input type='hidden' id='max' name= 'max' value="0">
  60. <input type ='hidden' id='num_of_scales' name ='num_of_scales' value ='0'>
  61. <div class="form-group">
  62. <label>Expected Criteria Outcome: </label>
  63. <!-- Select percentage. If there is a rubric, select the saved value -->
  64. <strong>
  65. <span id="expected_percentage">
  66. </span>%
  67. </strong> of all students must score at least
  68. <!-- Select points. If there is a rubric, select the saved value -->
  69. <strong>
  70. <span id="expected_points">
  71. </span>
  72. </strong>
  73. points in a criterion for it to pass.
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. <div id="rubric-container" class="row">
  79. <div class="col-md-12">
  80. <!-- <table class="table" style="table-layout: fixed"> -->
  81. <table class="table table-striped table-condensed">
  82. <thead><tr><th colspan="6 "><h3 id="rubric-name"></h3></th></tr></thead>
  83. <thead><tr id ="criterion-header"><th>Criterion</th><th>Beginning (1-2)</th><th>In Progress (3-4)</th><th>Good (5-6)</th><th>Excellent (7-8)</th></tr></thead>
  84. <tbody>
  85. </tbody>
  86. </table>
  87. <div id="copyright-info">
  88. <hr>
  89. <p class="small"><strong>Copyright Information</strong></p>
  90. <ul id="copyright-list" class="list-unstyled small">
  91. </ul>
  92. <hr>
  93. </div>
  94. @if($activity->outcomes_attempted!=NULL)
  95. <div class="alert alert-info" role="alert">This activity has already been assessed. Changing the rubric will delete all saved scores.</div>
  96. @endif
  97. <div class="text-center">
  98. <button id="button-save-rubric" class="btn btn-lg btn-primary save"><span class="glyphicon glyphicon-floppy-disk"></span> Save</button>
  99. </div>
  100. </div>
  101. </div>
  102. <script>
  103. function changeTable(data){
  104. amount_of_scales = parseInt($('#num_of_scales').val());
  105. counter2 = 0;
  106. maximum = parseInt($('#max').val());
  107. newScaleHeaders = '<th>Criterion</th>';
  108. counter = 0;
  109. division = maximum/amount_of_scales;
  110. if(amount_of_scales==1){
  111. newScaleHeaders+= "<th class ='titles' data-title-id ="+data.titles[counter].title_id+">"+data.titles[counter].text+" (1 - "+maximum+")</th>";
  112. }
  113. else if(maximum!= amount_of_scales){
  114. while(counter <amount_of_scales){
  115. minimumScore = 1+(counter*division);
  116. maximumScore = (1+counter)*division;
  117. newScaleHeaders+= "<th class ='titles' data-title-id = "+data.titles[counter].title_id+">"+data.titles[counter].text+" ("+minimumScore+" - "+maximumScore+")</th>";
  118. counter++;
  119. }
  120. }else{
  121. while(counter <amount_of_scales){
  122. newScaleHeaders+= "<th class ='titles' data-title-id ="+data.titles[counter].title_id+"> "+data.titles[counter].text+ " </th>";
  123. counter++;
  124. }
  125. }
  126. newScaleHeaders += '<th>Outcomes</th>';
  127. $("#criterion-header").html(newScaleHeaders);
  128. }
  129. </script>
  130. @stop
  131. @section('javascript')
  132. // --------------------------------------------------------------------------
  133. // Page load
  134. // --------------------------------------------------------------------------
  135. console.log({{ $activity }});
  136. //If there are no rubrics to show, alert user and redirect.
  137. if($('#select-template').children().length)
  138. loadTemplate();
  139. else
  140. {
  141. $('#modal-no-rubric').modal({
  142. backdrop: 'static'
  143. });
  144. }
  145. // --------------------------------------------------------------------------
  146. // Functions
  147. // --------------------------------------------------------------------------
  148. // Fetch criteria associated to a specific learning outcome
  149. function fetchCriteria(outcome)
  150. {
  151. $.post
  152. (
  153. "{{ URL::route('fetchCriteria') }}",
  154. { id: outcome.find(':selected').data('outcome-id')},
  155. function(data)
  156. {
  157. $('#select-criterion').empty();
  158. data.forEach( function (arrayItem)
  159. {
  160. // If criterion does not belong to a user, display it
  161. if(arrayItem.user_id==null)
  162. {
  163. $('#select-criterion')
  164. .append('<option data-criterion-id="'+arrayItem.id+'" >'+arrayItem.name+'</option>');
  165. }
  166. // If it does, but the user is the one logged on, display.
  167. // Otherwise, ignore
  168. else if(arrayItem.user_id!="" && {{{Auth::id()}}}==arrayItem.user_id )
  169. {
  170. $('#select-criterion')
  171. .append('<option data-criterion-id="'+arrayItem.id+'" >'+arrayItem.name+'</option>');
  172. }
  173. });
  174. // Add custom option
  175. $('#select-criterion')
  176. .append('<option data-criterion-id="0">Custom</option>');
  177. $('#select-criterion').prop('disabled', false);
  178. $('#button-add-criterion').prop('disabled', false);
  179. }
  180. );
  181. }
  182. // Build list from copyright info in rubric
  183. function buildCopyrightList()
  184. {
  185. // Empty the copyright list
  186. $('#copyright-list').empty();
  187. $('tbody tr').each(function( index )
  188. {
  189. var criterion = $(this);
  190. // If there's copyright info
  191. if(criterion.data('criterion-copyright')!=null){
  192. var copyright = criterion.data('criterion-copyright');
  193. if($('#copyright-list li').length>0)
  194. {
  195. var found = false;
  196. $('#copyright-list li').each(function()
  197. {
  198. // If found, give the string its number
  199. if(copyright==$(this).find('span').text())
  200. {
  201. copyrightNumber = Number.parseInt($(this).find('sup').text());
  202. console.log('a: '+copyrightNumber);
  203. criterion.children('td:nth-child(2)').find('sup').text(copyrightNumber);
  204. found =true;
  205. //to break
  206. return false;
  207. }
  208. });
  209. // Otherwise, give it the next number and append a new item to the
  210. // list
  211. if(!found)
  212. {
  213. var copyrightNumber = $('#copyright-list li').length+1;
  214. console.log('b: '+copyrightNumber);
  215. console.log(criterion.children('td:nth-child(2)').find('sup').length);
  216. criterion.children('td:nth-child(2)').find('sup').text(copyrightNumber);
  217. $('#copyright-list').append('<li><sup>'+copyrightNumber+' </sup><span>'+copyright+'<span></li>');
  218. }
  219. }
  220. else
  221. {
  222. criterion.children('td:nth-child(2)').find('sup').text('1');
  223. $('#copyright-list').append('<li><sup>1 </sup><span>'+copyright+'<span></li>');
  224. }
  225. }
  226. });
  227. if($('#copyright-info li').length>0)
  228. {
  229. $('#copyright-info').show();
  230. }
  231. else
  232. {
  233. $('#copyright-info').hide();
  234. }}
  235. // Load a template
  236. function loadTemplate()
  237. {
  238. $.post
  239. (
  240. "{{ URL::to('loadTemplate') }}",
  241. { id: $('#select-template').find(':selected').data('template-id')},
  242. function(data)
  243. {
  244. // Show the container and empty all rows
  245. $('#rubric-container').show();
  246. $('tbody').empty();
  247. //Set the name of the rubric
  248. $('#rubric-name').val(data.template.name);
  249. $('#expected_percentage').text(data.template.expected_percentage);
  250. $('#expected_points').text(data.template.expected_points)
  251. $('#max').val(data.template.max_score);
  252. $('#num_of_scales').val(data.template.num_scales);
  253. changeTable(data);
  254. // Set the contents of the rubric
  255. var temp_criterion = data.criterion;
  256. for(temp_c in temp_criterion){
  257. var str = '<tr data-criterion-id="'+temp_criterion[temp_c].criterion_id+'" data-criterion-copyright="'+temp_criterion[temp_c].copyright+'" data-criterion-notes="'+temp_criterion[temp_c].notes+'" data-outcomes = "'+temp_criterion[temp_c].outcomes+'">';
  258. current_criterion = temp_criterion[temp_c]
  259. var subcriteria ='';
  260. if(current_criterion.subcriteria){
  261. var subcriteria_array = JSON.parse(current_criterion.subcriteria);
  262. subcriteria = '<ul class="subcriteria list-unstyled">';
  263. subcriteria_array.forEach(function (value) {
  264. subcriteria += '<li>'+value+'</li>';
  265. });
  266. subcriteria += '</ul>';
  267. }
  268. if(current_criterion.notes)
  269. {
  270. str+='<td><span><em data-toggle="tooltip" data-placement="top" title="'+current_criterion.notes+'">'+current_criterion.name+'</em></span><sup></sup>'+subcriteria+'</td>';
  271. }
  272. else
  273. {
  274. str+='<td><span>'+current_criterion.name+'</span><sup></sup>'+subcriteria+'</td>';
  275. }
  276. for(scaleIndex in current_criterion.scales){
  277. scale = current_criterion.scales[scaleIndex];
  278. str+='<td>'+scale.description+'</td>';
  279. }
  280. str+= '<td>'+current_criterion.outcomes+'</td>';
  281. str+='</tr>';
  282. $('table tbody').append(str);
  283. buildCopyrightList();
  284. // Turn on tooltips again (because content is dynamic)
  285. $('[data-toggle="tooltip"]').tooltip();
  286. }
  287. /*
  288. var contents = JSON.parse(data.contents);
  289. contents.forEach(function (data)
  290. {
  291. // Append the fetched data
  292. var str ='<tr data-criterion-id="'+data.id+'" data-criterion-copyright="'+data.copyright+'" data-criterion-notes="'+data.notes+'"><th><span class="glyphicon glyphicon-move"></span></th><td>';
  293. var subcriteria = '';
  294. if(data.subcriteria){
  295. var subcriteria_array = data.subcriteria;
  296. subcriteria = '<ul class="subcriteria list-unstyled">';
  297. subcriteria_array.forEach(function (value) {
  298. subcriteria += '<li>'+value+'</li>';
  299. });
  300. subcriteria += '</ul>';
  301. }
  302. if(data.notes)
  303. {
  304. str+='<span><em data-toggle="tooltip" data-placement="top" title="'+data.notes+'">'+data.name+'</em></span><sup></sup>'+subcriteria;
  305. }
  306. else
  307. {
  308. str+='<span>'+data.name+'</span><sup></sup>'+subcriteria;
  309. }
  310. str+='</td><td class="editable" data-type="textarea">'+data.description12+'</td>'
  311. +'<td class="editable" data-type="textarea">'+data.description34+'</td>'
  312. +'<td class="editable" data-type="textarea">'+data.description56+'</td>'
  313. +'<td class="editable" data-type="textarea">'+data.description78+'</td>'
  314. +'<th><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></th></tr>';
  315. $('table tbody').append(str);
  316. // Build copyright list
  317. buildCopyrightList();
  318. // Enable X-Edtable on this new row
  319. $('.editable').editable({
  320. unsavedclass: null,
  321. rows: 4
  322. });
  323. // Turn on tooltips again (because content is dynamic)
  324. $('[data-toggle="tooltip"]').tooltip();
  325. }); */
  326. // Build Copyright List
  327. buildCopyrightList();
  328. },
  329. 'json',
  330. );
  331. }
  332. /*
  333. console.log($('#expected_percentage').text());
  334. console.log($('#expected_points').text());
  335. // Set expected values
  336. $('#expected_percentage').text(data.expected_percentage);
  337. $('#expected_points').text(data.expected_points);
  338. // Set the contents of the rubric
  339. var contents = JSON.parse(data.contents);
  340. contents.forEach(function (criterion)
  341. {
  342. var str ='<tr data-assoc-outcome-id="'+criterion.outcome_id+'"'
  343. +'data-criterion-id="'+criterion.id+'" data-criterion-copyright="'+criterion.copyright+'" data-criterion-notes="'+criterion.notes+'">';
  344. var subcriteria = '';
  345. if(criterion.subcriteria){
  346. var subcriteria_array = criterion.subcriteria;
  347. subcriteria = '<ul class="subcriteria list-unstyled">';
  348. subcriteria_array.forEach(function (value) {
  349. subcriteria += '<li>'+value+'</li>';
  350. });
  351. subcriteria += '</ul>';
  352. }
  353. // If the criterion has notes, set the tooltip with them
  354. if(criterion.notes)
  355. {
  356. str+='<td><span><em data-toggle="tooltip" data-placement="top" title="'+criterion.notes+'">'+criterion.name+'</em></span><sup></sup>'+subcriteria+'</td>';
  357. }
  358. else
  359. {
  360. str+='<td><span>'+criterion.name+'</span><sup></sup>'+subcriteria+'</td>';
  361. }
  362. // Add the descriptions
  363. str+='<td>'+criterion.description12.replace(/\n/gi, '<br>')+'</td>'
  364. +'<td>'+criterion.description34.replace(/\n/gi, '<br>')+'</td>'
  365. +'<td>'+criterion.description56.replace(/\n/gi, '<br>')+'</td>'
  366. +'<td>'+criterion.description78.replace(/\n/gi, '<br>')+'</td></tr>';
  367. // Append the string to the table
  368. $('table tbody').append(str);
  369. // Turn on tooltips again (because content is dynamic)
  370. $('[data-toggle="tooltip"]').tooltip();
  371. });
  372. // Build Copyright List
  373. buildCopyrightList();
  374. }
  375. );
  376. }
  377. */
  378. // --------------------------------------------------------------------------
  379. // Events
  380. // --------------------------------------------------------------------------
  381. // When trying to change the template, ask the user to confirm and reset the
  382. // rubric if s/he does
  383. $('#select-template').on('change', function()
  384. {
  385. loadTemplate();
  386. });
  387. // When a learning outcome changes, update its criteria
  388. $('#select-outcome').on('change', function()
  389. {
  390. fetchCriteria($(this));
  391. });
  392. // When save button is clicked
  393. $('#button-save-rubric').on('click', function(e)
  394. {
  395. //Prevent page refresh
  396. e.preventDefault();
  397. var criteria = [];
  398. var titles = [];
  399. max_score = $('#max').val();
  400. // For each criterion in the rubric, get its value and put it into an array
  401. $('tbody tr').each(function( index )
  402. {
  403. criteria.push($(this).data('criterion-id'));
  404. /*
  405. criterionObject.id = $(this).data('criterion-id');
  406. criterionObject.outcome_id = $(this).data('assoc-outcome-id');
  407. criterionObject.name = $(this).children('td:nth-child(1)').find('span').text();
  408. var subcriteriaArray = new Array();
  409. $(this).children('td:nth-child(1)').find('.subcriteria li').each(function(index){
  410. subcriteriaArray.push($(this).text());
  411. });
  412. criterionObject.subcriteria = subcriteriaArray;
  413. criterionObject.description12 = $(this).children('td:nth-child(2)').html().replace(/<br>/gi, '\n');
  414. criterionObject.description34 = $(this).children('td:nth-child(3)').html().replace(/<br>/gi, '\n');
  415. criterionObject.description56 = $(this).children('td:nth-child(4)').html().replace(/<br>/gi, '\n');
  416. criterionObject.description78 = $(this).children('td:nth-child(5)').html().replace(/<br>/gi, '\n');
  417. criterionObject.copyright = $(this).data('criterion-copyright');
  418. criterionObject.notes = $(this).data('criterion-notes');
  419. // Clone the object and push it into the array
  420. var clone = jQuery.extend({}, criterionObject);
  421. criteriaArray.push(clone);
  422. */
  423. });
  424. $('.titles').each(function(index){
  425. titles.push($(this).data('title-id'));
  426. });
  427. // If activity does not have a rubric, create it
  428. if($('#assigned_rubric').length === 0)
  429. {
  430. $('#js-error-row').hide();
  431. // Create
  432. $.post
  433. (
  434. "{{ URL::to('professor/saveRubric') }}",
  435. {
  436. name: $('#select-template').find(':selected').text(),
  437. activity_id: parseInt($('#activity_id').val()),
  438. expected_percentage: $('#expected_percentage').text(),
  439. expected_points: $('#expected_points').text(),
  440. criteria: criteria,
  441. titles:titles,
  442. max_score:max_score
  443. },
  444. function(data)
  445. {
  446. location.replace(data);
  447. }
  448. );
  449. }
  450. // Else, update it
  451. else
  452. {
  453. // Update database
  454. $.post
  455. (
  456. "{{ URL::to('professor/updateRubric') }}",
  457. {
  458. id: $('#assigned_rubric').data('assigned-rubric'),
  459. name: $('#select-template').find(':selected').text(),
  460. activity_id: parseInt($('#activity_id').val()),
  461. expected_percentage: $('#expected_percentage').text(),
  462. expected_points: $('#expected_points').text(),
  463. criteria: criteria,
  464. titles:titles,
  465. max_score:max_score
  466. },
  467. function(data)
  468. {
  469. location.replace(data);
  470. }
  471. );
  472. }
  473. });
  474. // When Ok button is clicked, redirect to previous page
  475. // When save button is clicked
  476. $('#button-redirect').on('click', function(e)
  477. {
  478. e.preventDefault();
  479. history.go(-1);
  480. });
  481. @stop