No Description

rubrics.blade.php 52KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490
  1. @extends('layouts.master')
  2. @section('navigation')
  3. @if(Auth::user()->role==1)
  4. @include('local.managers.admins._navigation')
  5. @elseif(Auth::user()->role==2)
  6. @include('local.managers.sCoords._new_navigation')
  7. @elseif(Auth::user()->role==3)
  8. @include('local.managers.pCoords._new_navigation')
  9. @endif
  10. @stop
  11. @section('main')
  12. <!-- Update Rubric Modal -->
  13. <div class="modal fade" id="modal-confirm-update">
  14. <div class="modal-dialog modal-sm">
  15. <div class="modal-content">
  16. <div class="modal-header">
  17. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  18. <h4 class="modal-title">Update Rubric</h4>
  19. </div>
  20. <div class="modal-body">
  21. <p>Speak to any coordinators and/or professors in your School or
  22. Program that may be affected when you update this rubric. <strong>Professors
  23. that have already used this rubric will keep a copy of it as
  24. they used it, not an updated one.</strong></p>
  25. <p>Do you want to update this rubric?</p>
  26. </div>
  27. <div class="modal-footer">
  28. <button type="button" class="btn btn-default" data-dismiss="modal">No</button>
  29. <button id="button-update-rubric" class="btn btn-primary save">Update</button>
  30. </div>
  31. </div><!-- /.modal-content -->
  32. </div><!-- /.modal-dialog -->
  33. </div><!-- /.modal -->
  34. <!-- Delete Rubric Modal -->
  35. <div class="modal fade" id="modal-confirm-delete">
  36. <div class="modal-dialog modal-sm">
  37. <div class="modal-content">
  38. <div class="modal-header">
  39. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  40. <h4 class="modal-title">Delete Rubric</h4>
  41. </div>
  42. <div class="modal-body">
  43. <p>Please note: By deleting this rubric, it will no longer be available
  44. to your school's or program's professors. However, professors that
  45. have already used it will keep a copy in their activities. Speak to
  46. any coordinators and/or professors in your School or Program that may be affected.</p>
  47. <p>Are you sure you want to delete this rubric?</p>
  48. </div>
  49. <div class="modal-footer">
  50. <button type="button" class="btn btn-default" data-dismiss="modal">No</button>
  51. <button id="button-delete-rubric" class="btn btn-primary">Delete</button>
  52. </div>
  53. </div><!-- /.modal-content -->
  54. </div><!-- /.modal-dialog -->
  55. </div><!-- /.modal -->
  56. <div class="row">
  57. <div class="col-md-12">
  58. <div class="panel panel-default">
  59. <div class="panel-heading">
  60. <span class="glyphicon glyphicon-triangle-bottom"></span>
  61. General Information
  62. </div>
  63. <div class="panel-body">
  64. <form>
  65. <div class="form-group">
  66. <label>Select a template, or create your own rubric</label>
  67. <select id="select-template" class="form-control selectpicker">
  68. <option data-template-id="0">Custom</option>
  69. @foreach ($templates as $template)
  70. @if($template->school_id==NULL && $template->program_id==NULL)
  71. <option
  72. data-template-id="{{ $template->id }}"
  73. data-template-program-id="{{ $template->program_id }}"
  74. data-admin="1"
  75. >
  76. {{{ $template->name }}}
  77. </option>
  78. @else
  79. <option
  80. data-template-id="{{ $template->id }}"
  81. data-template-program-id="{{ $template->program_id }}"
  82. >
  83. {{{ $template->name }}}
  84. </option>
  85. @endif
  86. @endforeach
  87. </select>
  88. </div>
  89. <!-- If user is admin s/he can pick which schools can view the rubric -->
  90. @if(Auth::user()->role==1)
  91. <div class="form-group">
  92. <label>Select the School this rubric will be visible from</label>
  93. <select id="select-school" class="form-control selectpicker">
  94. <option data-school-id="0">All</option>
  95. @foreach ($schools as $school)
  96. <option data-school-id="{{ $school->id }}">
  97. {{ $school->name }}
  98. </option>
  99. @endforeach
  100. </select>
  101. </div>
  102. @endif
  103. <!-- If user is admin or school coordinator, s/he can pick which programs -->
  104. @if(Auth::user()->role==1 || Auth::user()->role==2 || Auth::user()->role ==3)
  105. <div class="form-group">
  106. <label>Select the Program this rubric belongs to</label>
  107. <select id="select-program" class="form-control selectpicker">
  108. <option data-program-id="0">All</option>
  109. @foreach ($programs as $program)
  110. <option
  111. data-program-id="{{ $program->id }}"
  112. data-program-program-id="{{ $program->program_id }}"
  113. >
  114. {{ $program->name }}
  115. </option>
  116. @endforeach
  117. </select>
  118. </div>
  119. @endif
  120. </form>
  121. <label for="">Select the lower bound for passing criteria</label>
  122. <form class="form-inline">
  123. <div class="form-group">
  124. <!-- Select percentage. If there is a rubric, select the saved value -->
  125. <select id="expected_percentage" class="form-control selectpicker">
  126. @for($i = 50; $i <= 100; $i++)
  127. @if($i==70)
  128. <option selected="selected" value="{{ $i }}">{{ $i }}</option>
  129. @else
  130. <option value="{{ $i }}">{{ $i }}</option>
  131. @endif
  132. @endfor
  133. </select>
  134. % of all students must score at least
  135. <!-- Select points. If there is a rubric, select the saved value -->
  136. <select id="expected_points" class="form-control selectpicker">
  137. @for($i = 0; $i <= 8; $i++)
  138. @if($i==5)
  139. <option selected="selected" value="{{ $i }}">{{ $i }}</option>
  140. @else
  141. <option value="{{ $i }}">{{ $i }}</option>
  142. @endif
  143. @endfor
  144. </select>
  145. point(s) in a criterion for it to pass.
  146. </div>
  147. </form>
  148. <br>
  149. <form>
  150. <div class="form-group">
  151. <label>Select Status (you can change this later)</label>
  152. <div class="radio">
  153. <label>
  154. <input type="radio" name="is_visible" id="is_visible0" value="0" checked>
  155. This rubric is <strong>not complete</strong> yet and will not be available to professors.
  156. </label>
  157. </div>
  158. <div class="radio">
  159. <label>
  160. <input type="radio" name="is_visible" id="is_visible1" value="1">
  161. This rubric is <strong>complete</strong> and will be available to professors.
  162. </label>
  163. </div>
  164. </div>
  165. </form>
  166. <div>
  167. <p class="small">Note: You can hide or show this section by clicking on its heading. You may want to hide it to have more space. </p>
  168. </div>
  169. </div>
  170. </div>
  171. <div class="well">
  172. <form>
  173. <div class="form-group">
  174. <label>Select a Learning Outcome</label>
  175. <select id="select-outcome" class="form-control selectpicker" >
  176. @foreach ($outcomes as $outcome)
  177. <option data-outcome-id="{{ $outcome->id }}">{{ $outcome->name }}</option>
  178. @endforeach
  179. </select>
  180. </div>
  181. <div class="form-group">
  182. <label>Select an Objective</label>
  183. <select id="select-objective" class="form-control selectpicker" >
  184. </select>
  185. </div>
  186. <div class="form-group">
  187. <label>Select the Maximum Score</label>
  188. <select id="max_score" class="form-control selectpicker">
  189. @for($i = 1; $i <= 100; $i++)
  190. @if($i==8)
  191. <option selected="selected" value="{{ $i }}">{{ $i }}</option>
  192. @else
  193. <option value="{{ $i }}">{{ $i }}</option>
  194. @endif
  195. @endfor
  196. </select>
  197. </div>
  198. <div class="form-group">
  199. <label>Select the Type of Rubric</label>
  200. <select id="number_of_scales" class="form-control selectpicker" >
  201. @for($i = 1; $i <= 20; $i++)
  202. @if(8%$i == 0)
  203. @if($i==1)
  204. <option value="{{ $i }}">Cuantitative Rubric</option>
  205. @elseif($i==4)
  206. <option selected="selected" value="{{ $i }}">{{ $i }}-Scale Rubric</option>
  207. @else
  208. <option value="{{ $i }}">{{ $i }}-Scale Rubric</option>
  209. @endif
  210. @endif
  211. @endfor
  212. </select>
  213. <div>
  214. @if(Auth::user()->role != '1')
  215. <label>Filter Criteria</label>
  216. <div class="form-group">
  217. <label class="radio-inline">
  218. <input type="radio" checked name="criteria-filter" id="criteria-all" value="all"> All Criteria
  219. </label>
  220. <label class="radio-inline">
  221. <input type="radio" name="criteria-filter" id="criteria-school" value="school"> Criteria from my School
  222. </label>
  223. @if(Auth::user()->role == '3')
  224. <label class="radio-inline">
  225. <input type="radio" name="criteria-filter" id="criteria-program" value="program"> Criteria from my Program(s)
  226. </label>
  227. @endif
  228. </div>
  229. @endif
  230. <div class="form-group">
  231. <label>Select a Criterion</label><span id="updated-text" class="text-success small"> updated</span>
  232. <select id="select-criterion" class="form-control selectpicker">
  233. </select>
  234. </div>
  235. <button id="button-add-criterion" class="btn btn-md btn-primary center-block"> <span class="glyphicon glyphicon-plus"></span> Add Criterion to Rubric</button>
  236. </form>
  237. </div>
  238. </div>
  239. </div>
  240. <div id="rubric-container" class="row">
  241. <div class="col-md-12">
  242. <table class="table table-striped table-condensed" style="table-layout: fixed">
  243. <thead id="theHead"><tr><th colspan="7 "><input id="rubric-name" type="text" class="form-control input-lg" placeholder="Rubric Name"></th></tr></thead>
  244. <thead id = "theScaleTitles">
  245. </thead>
  246. <thead>
  247. <tr id ="criterion-header">
  248. <th></th>
  249. <th></th>
  250. </tr>
  251. </thead>
  252. <tbody id = "allCriteria">
  253. </tbody>
  254. </table>
  255. <div id="copyright-info">
  256. <hr>
  257. <p class="small"><strong>Copyright</strong></p>
  258. <ul id="copyright-list" class="list-unstyled small">
  259. </ul>
  260. <hr>
  261. </div>
  262. <div class="text-center">
  263. <div class="btn-group" role="group" aria-label="...">
  264. <button id="button-create-rubric" class="btn btn-lg btn-primary save">
  265. <span class="glyphicon glyphicon-floppy-disk"></span>
  266. Create
  267. </button>
  268. <button id="button-confirm-update-rubric" data-toggle="modal" data-target="#modal-confirm-update" class="btn btn-lg btn-primary">
  269. <span class="glyphicon glyphicon-pencil"></span>
  270. Update
  271. </button>
  272. <button id="button-confirm-delete-rubric" data-toggle="modal" data-target="#modal-confirm-delete" class="btn btn-lg btn-primary">
  273. <span class="glyphicon glyphicon-remove"></span>
  274. Delete
  275. </button>
  276. <button id="button-print-rubric" class="btn btn-lg btn-primary"><span class="glyphicon glyphicon-print"></span> Print <span class="small">(saved version)</span></button>
  277. </div>
  278. </div>
  279. </div>
  280. </div>
  281. <div class="modal fade" id="rubric-modal">
  282. <div class="modal-dialog modal-md">
  283. <div class="modal-content">
  284. <div class="modal-header">
  285. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  286. <h4 class="modal-title text-center" id ="modal-title-rubric">You are adding criteria to your program</h4>
  287. </div>
  288. <div class="modal-body" id ="modal-body-rubric">
  289. </div>
  290. <div class="modal-footer">
  291. <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  292. <button type="button" class="btn btn-primary" id ="saveButton" data-button-id = '' value="Save" type="button" onclick = "saveTemplate()" >Save</button>
  293. </div>
  294. </div><!-- /.modal-content -->
  295. </div><!-- /.modal-dialog -->
  296. </div>
  297. <script>
  298. </script>
  299. @stop
  300. @section('included-js')
  301. <!-- jQuery Sortable Tables -->
  302. <script src="{{ asset('vendor/jQuerySortable/jquery-sortable-min.js') }}"></script>
  303. <script>
  304. function saveTemplate()
  305. {
  306. //Prevent page refresh
  307. var criterionObject = new Object();
  308. var criteriaArray = new Array();
  309. var criteria = [];
  310. var titles = [];
  311. var amount_of_scales =parseInt($('#number_of_scales').find(':selected').val())+2;
  312. var max = parseInt($('#max_score').find(':selected').val());
  313. // For each criterion in the rubric, get its value and put it into an array
  314. $('tbody tr').each(function( index )
  315. {
  316. criteria.push($(this).data('criterion-id'));
  317. });
  318. $('.editable').each(function(index){
  319. titles.push($(this).text());
  320. })
  321. button_id = $("#saveButton").data('button-id');
  322. //console.log('school', $('#select-school').find(':selected').data('school-id') );
  323. //console.log('program', $('#select-program').find(':selected').data('program-id') );
  324. if(button_id=='button-create-rubric')
  325. {
  326. // Create
  327. $.post
  328. (
  329. "{{ URL::to('saveTemplate') }}",
  330. {
  331. name: $('#rubric-name').val(),
  332. school_id: $('#select-school').find(':selected').data('school-id'),
  333. program_id: $('#select-program').find(':selected').data('program-id'),
  334. expected_percentage: $('#expected_percentage').find(':selected').val(),
  335. expected_points: $('#expected_points').find(':selected').val(),
  336. is_visible: $('input[name=is_visible]:checked').val(),
  337. criteria : criteria,
  338. //scales: scales,
  339. max_score : max,
  340. /*copyright : copyright,
  341. notes :notes*/
  342. titles: titles
  343. },
  344. function(data)
  345. {
  346. location.reload(true);
  347. }
  348. );
  349. }
  350. else
  351. {
  352. console.log('school', $('#select-school').find(':selected').data('school-id') );
  353. console.log('program', $('#select-program').find(':selected').data('program-id') );
  354. // Update database
  355. $.post
  356. (
  357. "{{ URL::to('updateTemplate') }}",
  358. {
  359. id: $('#select-template').find(':selected').data('template-id'),
  360. name: $('#rubric-name').val(),
  361. school_id: $('#select-school').find(':selected').data('school-id'),
  362. program_id: $('#select-program').find(':selected').data('program-id'),
  363. expected_percentage: $('#expected_percentage').find(':selected').val(),
  364. expected_points: $('#expected_points').find(':selected').val(),
  365. is_visible: $('input[name=is_visible]:checked').val(),
  366. criteria : criteria,
  367. //scales: scales,
  368. max_score : max,
  369. /*copyright : copyright,
  370. notes :notes*/
  371. titles: titles
  372. },
  373. function(data)
  374. {
  375. location.reload(true);
  376. }
  377. );
  378. }
  379. }
  380. </script>
  381. <!-- X-Editable js -->
  382. <script src="{{ asset('vendor/xeditable/bootstrap-editable.min.js') }}"></script>
  383. @stop
  384. @section('javascript')
  385. $('#select-outcome').on('change',function(){
  386. fetchObjective(this);
  387. })
  388. // --------------------------------------------------------------------------
  389. // Functions
  390. // --------------------------------------------------------------------------
  391. function fetchObjective(outcome){
  392. $.post(
  393. "{{URL::route('fetchObjectivesForSelect')}}",
  394. {
  395. outcomeID:$(outcome).find(':selected').data('outcome-id'),
  396. },
  397. function(data){
  398. options = '';
  399. for(objective_index in data){
  400. options += '<option value = "'+data[objective_index].objective_id+'">'+data[objective_index].text+'</option>';
  401. }
  402. $('#select-objective').html(options);
  403. $('#select-objective').selectpicker('refresh');
  404. fetchCriteria($('#select-outcome'), $('#select-objective'));
  405. }, 'json',
  406. );
  407. }
  408. // Fetch criteria associated to a specific learning outcome
  409. //here
  410. function fetchCriteria(outcome, objective)
  411. {
  412. amount_of_scales = parseInt($('#number_of_scales').find(':selected').val());
  413. maximum = parseInt($('#max_score').find(":selected").val());
  414. $.post
  415. (
  416. "{{ URL::route('fetchCriteria') }}",
  417. {
  418. outcome_id: outcome.find(':selected').data('outcome-id'),
  419. objective_id: objective.find(':selected').val(),
  420. num_scales: amount_of_scales,
  421. maximum: maximum,
  422. filter: $('input[name=criteria-filter]:checked').val()
  423. },
  424. function(data)
  425. {
  426. $('#select-criterion').empty();
  427. // Append criteria
  428. data.forEach( function (arrayItem)
  429. {
  430. objectives = JSON.stringify(arrayItem.objectives);
  431. $('#select-criterion')
  432. .append('<option data-criterion-id="'+arrayItem.id+'" data-program-ids = '+"'"+arrayItem.program_ids+"'"+' data-assoc-objectives= '+"'"+objectives+"'"+'>'+arrayItem.name+'</option>');
  433. });
  434. // If there are no criteria assigned to the selected outcome, disable the
  435. // input and the button used to add criteria.
  436. if(!$('#select-criterion').children().length)
  437. {
  438. $('#select-criterion').prop('disabled', true);
  439. $('#button-add-criterion').prop('disabled', true);
  440. }
  441. // Otherwise, enable both the input and the button
  442. else
  443. {
  444. $('#select-criterion').prop('disabled', false);
  445. $('#button-add-criterion').prop('disabled', false);
  446. }
  447. $('#updated-text').fadeIn('slow').fadeOut('slow');
  448. refreshSelects();
  449. }
  450. );
  451. }
  452. // Add a new criterion to the rubric
  453. function addCriterion()
  454. {
  455. // Show the rubric container
  456. if(!$('tbody').children().length)
  457. {
  458. $('#rubric-container').show();
  459. }
  460. // Get the selected criterion's id
  461. var id= parseInt($('#select-criterion').find(':selected').data('criterion-id'));
  462. var program_ids = $('#select-criterion').find(':selected').data('program-ids');
  463. var objectives = $('#select-criterion').find(':selected').data('assoc-objectives');
  464. // Check for duplicates
  465. var duplicates=false;
  466. numberOfScale = $('#number_of_scales').find(':selected').val();
  467. $('tbody tr').each(function()
  468. {
  469. if ($(this).data('criterion-id') == id)
  470. {
  471. duplicates=true;
  472. }
  473. });
  474. // If there are any, display an error
  475. if(duplicates)
  476. {
  477. $('#js-error-row').show();
  478. $('#js-error-row').find('#error-message').text('Error: The selected criterion was already added.');
  479. return;
  480. }
  481. // Otherwise, hide the error container
  482. else
  483. {
  484. $('#js-error-row').hide();
  485. }
  486. // Fetch information of the criterion selected
  487. $.post
  488. (
  489. "{{ URL::route('fetchCriterionWithTemplate') }}",
  490. { id: id,
  491. },
  492. function(data)
  493. {
  494. // Append the fetched data
  495. copyright = null;
  496. notes = null;
  497. if(data.criterion.copyright){
  498. copyright = data.criterion.copyright;
  499. }
  500. if(data.criterion.notes){
  501. notes = data.criterion.notes;
  502. }
  503. objectives = JSON.stringify(objectives);
  504. var str ='<tr data-criterion-name ="'+data.criterion.name+'" data-program-ids = "['+program_ids+']" data-assoc-objectives = '+"'"+objectives+"'"+' data-criterion-id="'+data.criterion.id+'" data-criterion-copyright="'+copyright+'" data-criterion-notes="'+notes+'" data-outcomes = "'+data.outcomes+'"><th><span class="glyphicon glyphicon-move"></span></th><td>';
  505. var subcriteria = '';
  506. if(data.criterion.subcriteria){
  507. var subcriteria_array = JSON.parse(data.criterion.subcriteria);
  508. subcriteria = '<ul class="subcriteria list-unstyled">';
  509. subcriteria_array.forEach(function (value) {
  510. subcriteria += '<li>'+value+'</li>';
  511. });
  512. subcriteria += '</ul>';
  513. }
  514. if(notes)
  515. {
  516. str+='<span><em data-toggle="tooltip" data-placement="top" title="'+notes+'">'+data.criterion.name+'</em></span><sup></sup>'+subcriteria+'</td>';
  517. }
  518. else
  519. {
  520. str+='<span>'+data.criterion.name+'</span><sup></sup>'+subcriteria+'</td>';
  521. }
  522. numberOfScale = $('#number_of_scales').find(':selected').val();
  523. for(i=0; i<numberOfScale; i++){
  524. str+='<td>'+data.scales[i].description+'</td>';
  525. }
  526. str+= '<td>'+data.outcomes+'</td>'
  527. str +='<th><span class="glyphicon glyphicon-remove icon-btn" aria-hidden="true"></span></th></tr>';
  528. $('table tbody').append(str);
  529. // Build copyright list
  530. buildCopyrightList();
  531. // Enable X-Edtable on this new row
  532. $('.editable').editable({
  533. unsavedclass: null,
  534. rows: 4
  535. });
  536. // Turn on tooltips again (because content is dynamic)
  537. $('[data-toggle="tooltip"]').tooltip();
  538. // Sortable rows
  539. $('.table').sortable({
  540. handle: 'span.glyphicon.glyphicon-move',
  541. containerSelector: 'table',
  542. itemPath: '> tbody',
  543. itemSelector: 'tr',
  544. placeholder: '<tr class="placeholder"><th><span class="glyphicon glyphicon-arrow-right"></span></th></tr>'
  545. });
  546. },
  547. 'json',
  548. );
  549. }
  550. // Fetch single criterion
  551. function fetchCriterion(criterion)
  552. {
  553. $.post
  554. (
  555. "{{ URL::route('fetchCriterion') }}",
  556. { id: outcome.find(':selected').data('outcome-id')},
  557. function(data)
  558. {
  559. $('#select-criterion').empty();
  560. data.forEach( function (arrayItem)
  561. {
  562. $('#select-criterion')
  563. .append('<option data-criterion-id="'+arrayItem.id+'" >'+arrayItem.name+'</option>');
  564. });
  565. $('#select-criterion').append('<option data-criterion-id="0">Custom</option>');
  566. refreshSelects();
  567. }
  568. );
  569. }
  570. // Build list from copyright info in rubric
  571. function buildCopyrightList()
  572. {
  573. // Empty the copyright list
  574. $('#copyright-list').empty();
  575. $('tbody tr').each(function( index )
  576. {
  577. var criterion = $(this);
  578. // If there's copyright info
  579. if(criterion.data('criterion-copyright')!=null){
  580. var copyright = criterion.data('criterion-copyright');
  581. if($('#copyright-list li').length>0)
  582. {
  583. var found = false;
  584. $('#copyright-list li').each(function()
  585. {
  586. // If found, give the string its number
  587. if(copyright==$(this).find('span').text())
  588. {
  589. copyrightNumber = Number.parseInt($(this).find('sup').text());
  590. console.log('a: '+copyrightNumber);
  591. criterion.children('td:nth-child(2)').find('sup').text(copyrightNumber);
  592. found =true;
  593. //to break
  594. return false;
  595. }
  596. });
  597. // Otherwise, give it the next number and append a new item to the
  598. // list
  599. if(!found)
  600. {
  601. var copyrightNumber = $('#copyright-list li').length+1;
  602. console.log('b: '+copyrightNumber);
  603. console.log(criterion.children('td:nth-child(2)').find('sup').length);
  604. criterion.children('td:nth-child(2)').find('sup').text(copyrightNumber);
  605. $('#copyright-list').append('<li><sup>'+copyrightNumber+' </sup><span>'+copyright+'<span></li>');
  606. }
  607. }
  608. else
  609. {
  610. criterion.children('td:nth-child(2)').find('sup').text('1');
  611. $('#copyright-list').append('<li><sup>1 </sup><span>'+copyright+'<span></li>');
  612. }
  613. }
  614. });
  615. if($('#copyright-info li').length>0)
  616. {
  617. $('#copyright-info').show();
  618. }
  619. else
  620. {
  621. $('#copyright-info').hide();
  622. }}
  623. /* if(criterion.data('criterion-copyright')!=null)
  624. {
  625. var copyright = criterion.data('criterion-copyright');
  626. // If there is anything in the copyright list
  627. if($('#copyright-list li').length>0)
  628. {
  629. // Check copyright list for the same copyright text
  630. var found = false;
  631. $('#copyright-list li').each(function()
  632. {
  633. // If found, give the string its number
  634. if(copyright==$(this).find('span').text())
  635. {
  636. copyrightNumber = Number.parseInt($(this).find('sup').text());
  637. console.log('a: '+copyrightNumber);
  638. criterion.children('td:nth-child(2)').find('sup').text(copyrightNumber);
  639. found =true;
  640. //to break
  641. return false;
  642. }
  643. });
  644. // Otherwise, give it the next number and append a new item to the
  645. // list
  646. if(!found)
  647. {
  648. var copyrightNumber = $('#copyright-list li').length+1;
  649. console.log('b: '+copyrightNumber);
  650. console.log(criterion.children('td:nth-child(2)').find('sup').length);
  651. criterion.children('td:nth-child(2)').find('sup').text(copyrightNumber);
  652. $('#copyright-list').append('<li><sup>'+copyrightNumber+' </sup><span>'+copyright+'<span></li>');
  653. }
  654. }
  655. // Otherwise, give it number 1 and append it
  656. else
  657. {
  658. criterion.children('td:nth-child(2)').find('sup').text('1');
  659. $('#copyright-list').append('<li><sup>1 </sup><span>'+copyright+'<span></li>');
  660. }
  661. }
  662. });
  663. if($('#copyright-info li').length>0)
  664. {
  665. $('#copyright-info').show();
  666. }
  667. else
  668. {
  669. $('#copyright-info').hide();
  670. }
  671. }
  672. */
  673. function refreshSelects()
  674. {
  675. $('#select-template').selectpicker('refresh');
  676. $('#select-school').selectpicker('refresh');
  677. $('#select-program').selectpicker('refresh');
  678. $('#select-outcome').selectpicker('refresh');
  679. $('#select-criterion').selectpicker('refresh');
  680. $('#expected_percentage').selectpicker('refresh');
  681. $('#expected_points').selectpicker('refresh');
  682. $('#number_of_scales').selectpicker('refresh');
  683. $('#select-objective').selectpicker('refresh');
  684. }
  685. // Fetch programs associated to a specific school
  686. function fetchPrograms(school)
  687. {
  688. $.ajax({
  689. type: 'POST',
  690. url: "{{ URL::action('ProgramsController@fetch') }}",
  691. data: { id: school.find(':selected').data('school-id')},
  692. success: function(data)
  693. {
  694. $('#select-program').empty();
  695. $('#select-program').append('<option data-program-id="0">All</option>');
  696. data.forEach( function (program)
  697. {
  698. $('#select-program')
  699. .append('<option data-program-id="'+program.id+'" >'+program.name+'</option>');
  700. });
  701. },
  702. async:false
  703. });
  704. if($('#select-school').find(':selected').data('school-id')!=0)
  705. $('#select-program').prop('disabled', false);
  706. else
  707. $('#select-program').prop('disabled', true);
  708. refreshSelects();
  709. }
  710. // Load a template. This function is different from the one for professors
  711. function loadTemplate()
  712. {
  713. $.post
  714. (
  715. "{{ URL::to('loadTemplate') }}",
  716. { id: $('#select-template').find(':selected').data('template-id')},
  717. function(data)
  718. {
  719. // Show the container and empty all rows
  720. $('#rubric-container').show();
  721. $('tbody').empty();
  722. //Set the name of the rubric
  723. $('#rubric-name').val(data.template.name);
  724. // Set school id to 0, then to the saved value if it exists
  725. $('#select-school option[data-school-id="0"]').prop('selected', true);
  726. $('#select-school option[data-school-id="'+data.template.school_id+'"]').prop('selected', true);
  727. // Fetch programs associated to that school
  728. fetchPrograms($('#select-school'));
  729. // Set program id to 0, then to the saved value if it exists
  730. $('#select-program option[data-program-id="0"]').prop('selected', true);
  731. $('#select-program option[data-program-id="'+data.template.program_id+'"]').prop('selected', true);
  732. // Set expected values
  733. console.log(data.template.expected_percentage);
  734. console.log(data.template.expected_points);
  735. console.log(data.template.max_score);
  736. $('#max_score').val(data.template.max_score);
  737. $('#max_score').trigger("change");
  738. $('#expected_percentage').val(data.template.expected_percentage);
  739. $('#expected_points').val(data.template.expected_points);
  740. $('#number_of_scales').val(data.template.num_scales);
  741. refreshSelects();
  742. changeTable();
  743. // Set visibility
  744. var is_visible = data.template.is_visible;
  745. if(is_visible)
  746. {
  747. $('#is_visible0').prop('checked', false);
  748. $('#is_visible1').prop('checked', true);
  749. }
  750. else
  751. {
  752. $('#is_visible1').prop('checked', false);
  753. $('#is_visible0').prop('checked', true);
  754. }
  755. // Set the contents of the rubric
  756. var temp_criterion = data.criterion;
  757. for(temp_c in temp_criterion){
  758. current_criterion = temp_criterion[temp_c]
  759. objectives = JSON.stringify(current_criterion.objectives);
  760. var str = '<tr data-assoc-objectives= '+"'"+objectives+"'"+' data-program_ids = "'+current_criterion.program_ids+'" data-criterion-name = "'+current_criterion.name+'" 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+'"><th><span class="glyphicon glyphicon-move"></span></th><td>';
  761. var subcriteria ='';
  762. if(current_criterion.subcriteria){
  763. var subcriteria_array = JSON.parse(current_criterion.subcriteria);
  764. subcriteria = '<ul class="subcriteria list-unstyled">';
  765. subcriteria_array.forEach(function (value) {
  766. subcriteria += '<li>'+value+'</li>';
  767. });
  768. subcriteria += '</ul>';
  769. }
  770. if(current_criterion.notes)
  771. {
  772. str+='<span><em data-toggle="tooltip" data-placement="top" title="'+current_criterion.notes+'">'+current_criterion.name+'</em></span><sup></sup>'+subcriteria;
  773. }
  774. else
  775. {
  776. str+='<span>'+current_criterion.name+'</span><sup></sup>'+subcriteria;
  777. }
  778. str+= '</td>';
  779. for(scaleIndex in current_criterion.scales){
  780. scale = current_criterion.scales[scaleIndex];
  781. str+='<td>'+scale.description+'</td>';
  782. }
  783. str+= '<td>'+current_criterion.outcomes+'</td>'
  784. str+='<th><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></th></tr>';
  785. $('table tbody').append(str);
  786. // Enable X-Edtable on this new row
  787. $('.editable').editable({
  788. unsavedclass: null,
  789. rows: 4
  790. });
  791. // Turn on tooltips again (because content is dynamic)
  792. $('[data-toggle="tooltip"]').tooltip();
  793. refreshSelects();
  794. }
  795. /*
  796. var contents = JSON.parse(data.contents);
  797. contents.forEach(function (data)
  798. {
  799. // Append the fetched data
  800. 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>';
  801. var subcriteria = '';
  802. if(data.subcriteria){
  803. var subcriteria_array = data.subcriteria;
  804. subcriteria = '<ul class="subcriteria list-unstyled">';
  805. subcriteria_array.forEach(function (value) {
  806. subcriteria += '<li>'+value+'</li>';
  807. });
  808. subcriteria += '</ul>';
  809. }
  810. if(data.notes)
  811. {
  812. str+='<span><em data-toggle="tooltip" data-placement="top" title="'+data.notes+'">'+data.name+'</em></span><sup></sup>'+subcriteria;
  813. }
  814. else
  815. {
  816. str+='<span>'+data.name+'</span><sup></sup>'+subcriteria;
  817. }
  818. str+='</td><td class="editable" data-type="textarea">'+data.description12+'</td>'
  819. +'<td class="editable" data-type="textarea">'+data.description34+'</td>'
  820. +'<td class="editable" data-type="textarea">'+data.description56+'</td>'
  821. +'<td class="editable" data-type="textarea">'+data.description78+'</td>'
  822. +'<th><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></th></tr>';
  823. $('table tbody').append(str);
  824. // Build copyright list
  825. buildCopyrightList();
  826. // Enable X-Edtable on this new row
  827. $('.editable').editable({
  828. unsavedclass: null,
  829. rows: 4
  830. });
  831. // Turn on tooltips again (because content is dynamic)
  832. $('[data-toggle="tooltip"]').tooltip();
  833. refreshSelects();
  834. }); */
  835. // Sortable rows
  836. $('.table').sortable({
  837. handle: 'span.glyphicon.glyphicon-move',
  838. containerSelector: 'table',
  839. itemPath: '> tbody',
  840. itemSelector: 'tr',
  841. placeholder: '<tr class="placeholder"><th><span class="glyphicon glyphicon-arrow-right"></span></th></tr>'
  842. });
  843. // Build Copyright List
  844. buildCopyrightList();
  845. $('.editable').each(function (index){
  846. $(this).text(data.titles[index].text);
  847. })
  848. var selected = $('#select-template').find(':selected');
  849. var programs = {{ json_encode(Auth::user()->programs->lists('id')) }};
  850. var template_program = selected.data('template-program-id');
  851. if(
  852. {{ Auth::user()->role }}==1
  853. || ({{ Auth::user()->role }}==2 && selected.data('admin')!=1)
  854. || ({{ Auth::user()->role }}==3
  855. && programs.includes(selected.data('template-program-id'))
  856. && selected.data('admin')!=1
  857. )
  858. )
  859. {
  860. $('#button-confirm-delete-rubric').prop('disabled', false);
  861. $('#button-confirm-update-rubric').prop('disabled', false);
  862. }
  863. else
  864. {
  865. // Disable update and edit
  866. $('#button-confirm-delete-rubric').prop('disabled', true);
  867. $('#button-confirm-update-rubric').prop('disabled', true);
  868. }
  869. // Enable print button
  870. $('#button-print-rubric').prop('disabled', false);
  871. fetchCriteria($('#select-outcome'), $('#select-objective'));
  872. },
  873. 'json',
  874. );
  875. }
  876. // Checks whether the user wants to save a rubric with a name that already exists
  877. function nameExists()
  878. {
  879. var duplicates = false;
  880. $('#select-template option').each(function()
  881. {
  882. var optionName = $(this).text().trim();
  883. if($('#rubric-name').val().trim()===optionName)
  884. {
  885. duplicates = true;
  886. }
  887. });
  888. refreshSelects();
  889. return duplicates;
  890. }
  891. //Enable disable program select
  892. function toggleProgramSelect(school)
  893. {
  894. if(school.find(':selected').data('school-id') <1)
  895. {
  896. $('#select-program option[data-program-id="0"]').prop('selected', true);
  897. $('#select-program').prop('disabled', true);
  898. }
  899. else
  900. {
  901. fetchPrograms(school);
  902. $('#select-program').prop('disabled', false);
  903. }
  904. refreshSelects();
  905. }
  906. fetchObjective($('#select-outcome'));
  907. // --------------------------------------------------------------------------
  908. // Events
  909. // --------------------------------------------------------------------------
  910. // Toggle visibility for accordion panels
  911. $('.panel-heading').on('click', function()
  912. {
  913. if($(this).find('.glyphicon').hasClass('glyphicon-triangle-right'))
  914. {
  915. $(this).find('.glyphicon').removeClass('glyphicon-triangle-right');
  916. $(this).find('.glyphicon').addClass('glyphicon-triangle-bottom');
  917. }
  918. else if($(this).find('.glyphicon').hasClass('glyphicon-triangle-bottom'))
  919. {
  920. $(this).find('.glyphicon').removeClass('glyphicon-triangle-bottom');
  921. $(this).find('.glyphicon').addClass('glyphicon-triangle-right');
  922. }
  923. $(this).siblings('.panel-body').stop().slideToggle();
  924. });
  925. // Fetch criteria everytime something changes
  926. $('#select-objective').on('change', function(){
  927. fetchCriteria($('#select-outcome'), $('#select-objective'));
  928. })
  929. $("#number_of_scales").on('change', function(){
  930. fetchCriteria($('#select-outcome'), $('#select-objective'));
  931. })
  932. // When trying to change the template, ask the user to confirm and reset the
  933. // rubric if s/he does
  934. $('#select-template').on('change', function()
  935. {
  936. // If changing to custom template, reset
  937. if($('#select-template').find(':selected').data('template-id')=='0')
  938. {
  939. $('#rubric-container').hide();
  940. $('#rubric-name').val('');
  941. $('tbody').empty();
  942. // Disable delete, update and print buttons
  943. $('#button-confirm-delete-rubric').prop('disabled', true);
  944. $('#button-confirm-update-rubric').prop('disabled', true);
  945. $('#button-print-rubric').prop('disabled', true);
  946. }
  947. // Otherwise, load the selected template
  948. else
  949. {
  950. loadTemplate();
  951. //If user is admin, or the templates id matches user's, or the template
  952. // id's school matches user, allow editing
  953. /*var selected = $('#select-template').find(':selected');
  954. var programs = {{ json_encode(Auth::user()->programs->lists('id')) }};
  955. var template_program = selected.data('template-program-id');
  956. var dataset = selected.dataSet.templateProgramId;
  957. if(
  958. {{ Auth::user()->role }}==1
  959. || ({{ Auth::user()->role }}==2 && selected.data('admin')!=1)
  960. || ({{ Auth::user()->role }}==3
  961. && programs.includes(selected.data('template-program-id'))
  962. && selected.data('admin')!=1
  963. )
  964. )
  965. {
  966. $('#button-confirm-delete-rubric').prop('disabled', false);
  967. $('#button-confirm-update-rubric').prop('disabled', false);
  968. }
  969. else
  970. {
  971. // Disable update and edit
  972. $('#button-confirm-delete-rubric').prop('disabled', true);
  973. $('#button-confirm-update-rubric').prop('disabled', true);
  974. }
  975. // Enable print button
  976. $('#button-print-rubric').prop('disabled', false);
  977. */
  978. }
  979. });
  980. function changeTable(){
  981. amount_of_scales = parseInt($('#number_of_scales').find(':selected').val());
  982. counter2 = 0;
  983. maximum = parseInt($('#max_score').find(":selected").val());
  984. newScaleHeaders = '<th></th><th>Criterion</th>';
  985. editableTitles = '<th></th><th></th>';
  986. counter = 0;
  987. division = maximum/amount_of_scales;
  988. if(amount_of_scales==1){
  989. newScaleHeaders+= "<th>Score (1 - "+maximum+")</th>";
  990. editableTitles += "<th class = 'editable' data-type = 'textarea'>Click to edit Title </th>"
  991. }
  992. else if(maximum!= amount_of_scales){
  993. while(counter <amount_of_scales){
  994. minimumScore = 1+(counter*division);
  995. maximumScore = (1+counter)*division;
  996. newScaleHeaders+= "<th>Scale "+ (counter +1) + " ("+minimumScore+" - "+maximumScore+")</th>";
  997. editableTitles+="<th class = 'editable' data-type = 'textarea'>Click to edit Title "+(counter+1)+"</th>"
  998. counter++;
  999. }
  1000. }else{
  1001. while(counter <amount_of_scales){
  1002. newScaleHeaders+= "<th>Scale "+ (counter +1) + " </th>";
  1003. editableTitles+="<th class = 'editable' data-type = 'textarea'>Click to edit Title "+(counter+1)+"</th>"
  1004. counter++;
  1005. }
  1006. }
  1007. newScaleHeaders += '<th>Outcomes</th><th></th>';
  1008. editableTitles += '<th></th><th></th>';
  1009. $('#theScaleTitles').html(editableTitles);
  1010. $("#criterion-header").html(newScaleHeaders);
  1011. $('#allCriteria').html(' ');
  1012. }
  1013. // When a school changes, update its programs. If all is selected, disable
  1014. $('#select-school').on('change', function()
  1015. {
  1016. toggleProgramSelect($(this));
  1017. });
  1018. $('#max_score').on('change', function(){
  1019. var max = parseInt($('#max_score').find(':selected').val());
  1020. var stringToScales = "<option value= '1'>Cuantitative Rubric </option>";
  1021. selectedValue = 1;
  1022. valueBefore = 0;
  1023. for(i=2; i<=20; i++){
  1024. if(max%i==0){
  1025. stringToScales += "<option value= '"+i+"'>"+i+"-Scale Rubric</option>";
  1026. selectedValue = i - valueBefore;
  1027. valueBefore = i;
  1028. }
  1029. }
  1030. $('#number_of_scales').html(stringToScales);
  1031. $('#number_of_scales').selectpicker('refresh');
  1032. $('#number_of_scales').val(selectedValue);
  1033. $('#number_of_scales').selectpicker('refresh');
  1034. var expected_points = Math.floor(max *0.7);
  1035. var expected_points_html = '';
  1036. for(i=1; i<max; i++){
  1037. expected_points_html += '<option value="'+i+'"> '+i+'</option>';
  1038. }
  1039. $('#expected_points').html(expected_points_html);
  1040. refreshSelects();
  1041. $('#expected_points').val(expected_points);
  1042. refreshSelects();
  1043. changeTable();
  1044. fetchCriteria($('#select-outcome'), $('#select-objective'))
  1045. })
  1046. $('#number_of_scales').on('change', function(){
  1047. changeTable();
  1048. $('#rubric-container').hide();
  1049. $('#rubric-name').val('');
  1050. $('tbody').empty();
  1051. })
  1052. // When a learning outcome changes, update its criteria
  1053. /*$('#select-outcome, input[name=criteria-filter]').on('change', function()
  1054. {
  1055. fetchCriteria($('#select-outcome'));
  1056. });
  1057. */
  1058. // When the add button is clicked
  1059. $('#button-add-criterion').on('click', function(e)
  1060. {
  1061. //Prevent page refresh
  1062. e.preventDefault();
  1063. //Add new criterion
  1064. addCriterion();
  1065. });
  1066. // When the create or update buttons are clicked (.save)
  1067. $('.save').on('click', function(e)
  1068. {
  1069. //Prevent page refresh
  1070. e.preventDefault();
  1071. var emptyFields=false;
  1072. $('#allCriteria').children('td').each(function()
  1073. {
  1074. if (($(this).text() == "" || $(this).text() == "Empty") && !($(this).hasClass('nullable')) )
  1075. {
  1076. emptyFields=true;
  1077. }
  1078. });
  1079. // If any fields are empty, display error
  1080. if(emptyFields || $.trim($('#rubric-name').val())=='')
  1081. {
  1082. $('#js-error-row').show();
  1083. $('#js-error-row').find('#error-message').text('Error: Please fill all the fields. Make sure your rubric has a name and all scale scores are filled.');
  1084. return;
  1085. }
  1086. else
  1087. {
  1088. $('#js-error-row').hide();
  1089. }
  1090. // Check whether a rubric with the written name already exists
  1091. if($(this).attr('id')=='button-create-rubric' && nameExists())
  1092. {
  1093. $('#js-error-row').show();
  1094. $('#js-error-row').find('#error-message').text('Error: A template with that name already exists.');
  1095. return;
  1096. }
  1097. else
  1098. {
  1099. $('#js-error-row').hide();
  1100. }
  1101. program_id = $('#select-program').find(':selected').data('program-id')
  1102. if(program_id == 0){
  1103. $('#modal-title-rubric').html("All criteria will be associated with this school's programs");
  1104. htmlString = "<h5>The following criteria and objectives will be matched with all programs</h5>"
  1105. htmlString += "<ol style='list-style-position: inside'>"
  1106. $('tbody tr').each(function( index )
  1107. {
  1108. objectives = $(this).data('assoc-objectives');
  1109. htmlString += "<li>" +$(this).data('criterion-name');
  1110. htmlString += "<br><h5>This criterion is associated with these objectives</h5>"
  1111. htmlString +="<ul style='padding-left: 5%; list-style-position: inside'>"
  1112. for(index in objectives){
  1113. objective_string = objectives[index];
  1114. htmlString +="<li>"+objective_string+"</li>";
  1115. }
  1116. htmlString += "</ul>"
  1117. htmlString +="</li>"
  1118. htmlString+= "<br>";
  1119. });
  1120. htmlString +='</ol>';
  1121. $("#modal-body-rubric").html(htmlString);
  1122. }
  1123. else{
  1124. $('#modal-title-rubric').html('Some criteria will be associated with this program');
  1125. $('tbody tr').each(function( index )
  1126. {
  1127. htmlString = '';
  1128. program_ids = $(this).data('program-ids')
  1129. if(!program_ids.includes(program_id) ){
  1130. title = "<h6>The following criteria and objectives will be matched with this program</h6>"
  1131. htmlString += "<ol style='list-style-position: inside'>"
  1132. objectives = $(this).data('assoc-objectives');
  1133. //objectives = objectives.split(',');
  1134. htmlString += "<li>" +$(this).data('criterion-name');
  1135. htmlString += "<br><h6>This criterion is associated with these objectives</h6>"
  1136. htmlString +="<ul style='padding-left: 5%; list-style-position: inside'>"
  1137. for(index in objectives){
  1138. objective_string = objectives[index];
  1139. htmlString +="<li>"+objective_string+"</li>";
  1140. }
  1141. htmlString += "</ul>"
  1142. htmlString +="</li>"
  1143. htmlString+= "<br>";
  1144. }
  1145. if(htmlString != ''){
  1146. $("#modal-body-rubric").html(title);
  1147. $("#modal-body-rubric").append(htmlString);
  1148. }
  1149. });
  1150. }
  1151. $('#rubric-modal').modal('toggle');
  1152. $('#saveButton').data('button-id',$(this).attr('id'));
  1153. });
  1154. // When the confirm delete button is clicked
  1155. $('#button-delete-rubric').on('click', function(e)
  1156. {
  1157. $('#modal-confirm-delete').modal('hide');
  1158. // Delete from database
  1159. $.post
  1160. (
  1161. "{{ URL::to('deleteTemplate') }}",
  1162. {
  1163. id: $('#select-template').find(':selected').data('template-id')
  1164. },
  1165. function(data)
  1166. {
  1167. location.reload();
  1168. }
  1169. );
  1170. });
  1171. // Remove a criterion and hide the table if it was the only one
  1172. $('table').on('click', 'span.glyphicon-remove', function(e)
  1173. {
  1174. $(this).closest('tr').remove();
  1175. if(!$('tbody').children().length)
  1176. {
  1177. $('#rubric-container').hide();
  1178. }
  1179. buildCopyrightList();
  1180. });
  1181. // When print button is clicked, redirect to print page
  1182. $('#button-print-rubric').on('click', function(e)
  1183. {
  1184. e.preventDefault();
  1185. window.location = "printRubric/"+$('#select-template').find(':selected').data('template-id');
  1186. });
  1187. // --------------------------------------------------------------------------
  1188. // Page load
  1189. // --------------------------------------------------------------------------
  1190. $('#updated-text').hide();
  1191. // Enable/disable program selection depending on school selection if user is
  1192. // admin
  1193. if({{Auth::user()->role}}==1)
  1194. toggleProgramSelect($('#select-school'));
  1195. // Fetch criteria of first outcome
  1196. fetchCriteria($('#select-outcome'), $('#select-objective'));
  1197. changeTable();
  1198. // Hide table
  1199. $('#rubric-container').hide();
  1200. // Disable Update and Delete Buttons by default
  1201. $('#button-confirm-update-rubric').prop('disabled', true);
  1202. $('#button-confirm-delete-rubric').prop('disabled', true);
  1203. $('#button-print-rubric').prop('disabled', true);
  1204. // Sortable rows
  1205. $('.table').sortable({
  1206. handle: 'span.glyphicon.glyphicon-move',
  1207. containerSelector: 'table',
  1208. itemPath: '> tbody',
  1209. itemSelector: 'tr',
  1210. placeholder: '<tr class="placeholder"><th><span class="glyphicon glyphicon-arrow-right"></span></th></tr>'
  1211. });
  1212. @stop