Ei kuvausta

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._navigation')
  7. @elseif(Auth::user()->role==3)
  8. @include('local.managers.pCoords._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)
  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. function fetchCriteria(outcome, objective)
  410. {
  411. amount_of_scales = parseInt($('#number_of_scales').find(':selected').val());
  412. maximum = parseInt($('#max_score').find(":selected").val());
  413. $.post
  414. (
  415. "{{ URL::route('fetchCriteria') }}",
  416. {
  417. outcome_id: outcome.find(':selected').data('outcome-id'),
  418. objective_id: objective.find(':selected').val(),
  419. num_scales: amount_of_scales,
  420. maximum: maximum,
  421. filter: $('input[name=criteria-filter]:checked').val()
  422. },
  423. function(data)
  424. {
  425. $('#select-criterion').empty();
  426. // Append criteria
  427. data.forEach( function (arrayItem)
  428. {
  429. objectives = JSON.stringify(arrayItem.objectives);
  430. $('#select-criterion')
  431. .append('<option data-criterion-id="'+arrayItem.id+'" data-program-ids = "'+arrayItem.program_ids+'" data-assoc-objectives= '+"'"+objectives+"'"+'>'+arrayItem.name+'</option>');
  432. });
  433. // If there are no criteria assigned to the selected outcome, disable the
  434. // input and the button used to add criteria.
  435. if(!$('#select-criterion').children().length)
  436. {
  437. $('#select-criterion').prop('disabled', true);
  438. $('#button-add-criterion').prop('disabled', true);
  439. }
  440. // Otherwise, enable both the input and the button
  441. else
  442. {
  443. $('#select-criterion').prop('disabled', false);
  444. $('#button-add-criterion').prop('disabled', false);
  445. }
  446. $('#updated-text').fadeIn('slow').fadeOut('slow');
  447. refreshSelects();
  448. }
  449. );
  450. }
  451. // Add a new criterion to the rubric
  452. function addCriterion()
  453. {
  454. // Show the rubric container
  455. if(!$('tbody').children().length)
  456. {
  457. $('#rubric-container').show();
  458. }
  459. // Get the selected criterion's id
  460. var id= parseInt($('#select-criterion').find(':selected').data('criterion-id'));
  461. var program_ids = $('#select-criterion').find(':selected').data('program-ids');
  462. var objectives = $('#select-criterion').find(':selected').data('assoc-objectives');
  463. // Check for duplicates
  464. var duplicates=false;
  465. numberOfScale = $('#number_of_scales').find(':selected').val();
  466. $('tbody tr').each(function()
  467. {
  468. if ($(this).data('criterion-id') == id)
  469. {
  470. duplicates=true;
  471. }
  472. });
  473. // If there are any, display an error
  474. if(duplicates)
  475. {
  476. $('#js-error-row').show();
  477. $('#js-error-row').find('#error-message').text('Error: The selected criterion was already added.');
  478. return;
  479. }
  480. // Otherwise, hide the error container
  481. else
  482. {
  483. $('#js-error-row').hide();
  484. }
  485. // Fetch information of the criterion selected
  486. $.post
  487. (
  488. "{{ URL::route('fetchCriterionWithTemplate') }}",
  489. { id: id,
  490. },
  491. function(data)
  492. {
  493. // Append the fetched data
  494. copyright = null;
  495. notes = null;
  496. if(data.criterion.copyright){
  497. copyright = data.criterion.copyright;
  498. }
  499. if(data.criterion.notes){
  500. notes = data.criterion.notes;
  501. }
  502. objectives = JSON.stringify(objectives);
  503. 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>';
  504. var subcriteria = '';
  505. if(data.criterion.subcriteria){
  506. var subcriteria_array = JSON.parse(data.criterion.subcriteria);
  507. subcriteria = '<ul class="subcriteria list-unstyled">';
  508. subcriteria_array.forEach(function (value) {
  509. subcriteria += '<li>'+value+'</li>';
  510. });
  511. subcriteria += '</ul>';
  512. }
  513. if(notes)
  514. {
  515. str+='<span><em data-toggle="tooltip" data-placement="top" title="'+notes+'">'+data.criterion.name+'</em></span><sup></sup>'+subcriteria+'</td>';
  516. }
  517. else
  518. {
  519. str+='<span>'+data.criterion.name+'</span><sup></sup>'+subcriteria+'</td>';
  520. }
  521. numberOfScale = $('#number_of_scales').find(':selected').val();
  522. for(i=0; i<numberOfScale; i++){
  523. str+='<td>'+data.scales[i].description+'</td>';
  524. }
  525. str+= '<td>'+data.outcomes+'</td>'
  526. str +='<th><span class="glyphicon glyphicon-remove icon-btn" aria-hidden="true"></span></th></tr>';
  527. $('table tbody').append(str);
  528. // Build copyright list
  529. buildCopyrightList();
  530. // Enable X-Edtable on this new row
  531. $('.editable').editable({
  532. unsavedclass: null,
  533. rows: 4
  534. });
  535. // Turn on tooltips again (because content is dynamic)
  536. $('[data-toggle="tooltip"]').tooltip();
  537. // Sortable rows
  538. $('.table').sortable({
  539. handle: 'span.glyphicon.glyphicon-move',
  540. containerSelector: 'table',
  541. itemPath: '> tbody',
  542. itemSelector: 'tr',
  543. placeholder: '<tr class="placeholder"><th><span class="glyphicon glyphicon-arrow-right"></span></th></tr>'
  544. });
  545. },
  546. 'json',
  547. );
  548. }
  549. // Fetch single criterion
  550. function fetchCriterion(criterion)
  551. {
  552. $.post
  553. (
  554. "{{ URL::route('fetchCriterion') }}",
  555. { id: outcome.find(':selected').data('outcome-id')},
  556. function(data)
  557. {
  558. $('#select-criterion').empty();
  559. data.forEach( function (arrayItem)
  560. {
  561. $('#select-criterion')
  562. .append('<option data-criterion-id="'+arrayItem.id+'" >'+arrayItem.name+'</option>');
  563. });
  564. $('#select-criterion').append('<option data-criterion-id="0">Custom</option>');
  565. refreshSelects();
  566. }
  567. );
  568. }
  569. // Build list from copyright info in rubric
  570. function buildCopyrightList()
  571. {
  572. // Empty the copyright list
  573. $('#copyright-list').empty();
  574. $('tbody tr').each(function( index )
  575. {
  576. var criterion = $(this);
  577. // If there's copyright info
  578. if(criterion.data('criterion-copyright')!=null){
  579. var copyright = criterion.data('criterion-copyright');
  580. if($('#copyright-list li').length>0)
  581. {
  582. var found = false;
  583. $('#copyright-list li').each(function()
  584. {
  585. // If found, give the string its number
  586. if(copyright==$(this).find('span').text())
  587. {
  588. copyrightNumber = Number.parseInt($(this).find('sup').text());
  589. console.log('a: '+copyrightNumber);
  590. criterion.children('td:nth-child(2)').find('sup').text(copyrightNumber);
  591. found =true;
  592. //to break
  593. return false;
  594. }
  595. });
  596. // Otherwise, give it the next number and append a new item to the
  597. // list
  598. if(!found)
  599. {
  600. var copyrightNumber = $('#copyright-list li').length+1;
  601. console.log('b: '+copyrightNumber);
  602. console.log(criterion.children('td:nth-child(2)').find('sup').length);
  603. criterion.children('td:nth-child(2)').find('sup').text(copyrightNumber);
  604. $('#copyright-list').append('<li><sup>'+copyrightNumber+' </sup><span>'+copyright+'<span></li>');
  605. }
  606. }
  607. else
  608. {
  609. criterion.children('td:nth-child(2)').find('sup').text('1');
  610. $('#copyright-list').append('<li><sup>1 </sup><span>'+copyright+'<span></li>');
  611. }
  612. }
  613. });
  614. if($('#copyright-info li').length>0)
  615. {
  616. $('#copyright-info').show();
  617. }
  618. else
  619. {
  620. $('#copyright-info').hide();
  621. }}
  622. /* if(criterion.data('criterion-copyright')!=null)
  623. {
  624. var copyright = criterion.data('criterion-copyright');
  625. // If there is anything in the copyright list
  626. if($('#copyright-list li').length>0)
  627. {
  628. // Check copyright list for the same copyright text
  629. var found = false;
  630. $('#copyright-list li').each(function()
  631. {
  632. // If found, give the string its number
  633. if(copyright==$(this).find('span').text())
  634. {
  635. copyrightNumber = Number.parseInt($(this).find('sup').text());
  636. console.log('a: '+copyrightNumber);
  637. criterion.children('td:nth-child(2)').find('sup').text(copyrightNumber);
  638. found =true;
  639. //to break
  640. return false;
  641. }
  642. });
  643. // Otherwise, give it the next number and append a new item to the
  644. // list
  645. if(!found)
  646. {
  647. var copyrightNumber = $('#copyright-list li').length+1;
  648. console.log('b: '+copyrightNumber);
  649. console.log(criterion.children('td:nth-child(2)').find('sup').length);
  650. criterion.children('td:nth-child(2)').find('sup').text(copyrightNumber);
  651. $('#copyright-list').append('<li><sup>'+copyrightNumber+' </sup><span>'+copyright+'<span></li>');
  652. }
  653. }
  654. // Otherwise, give it number 1 and append it
  655. else
  656. {
  657. criterion.children('td:nth-child(2)').find('sup').text('1');
  658. $('#copyright-list').append('<li><sup>1 </sup><span>'+copyright+'<span></li>');
  659. }
  660. }
  661. });
  662. if($('#copyright-info li').length>0)
  663. {
  664. $('#copyright-info').show();
  665. }
  666. else
  667. {
  668. $('#copyright-info').hide();
  669. }
  670. }
  671. */
  672. function refreshSelects()
  673. {
  674. $('#select-template').selectpicker('refresh');
  675. $('#select-school').selectpicker('refresh');
  676. $('#select-program').selectpicker('refresh');
  677. $('#select-outcome').selectpicker('refresh');
  678. $('#select-criterion').selectpicker('refresh');
  679. $('#expected_percentage').selectpicker('refresh');
  680. $('#expected_points').selectpicker('refresh');
  681. $('#number_of_scales').selectpicker('refresh');
  682. $('#select-objective').selectpicker('refresh');
  683. }
  684. // Fetch programs associated to a specific school
  685. function fetchPrograms(school)
  686. {
  687. $.ajax({
  688. type: 'POST',
  689. url: "{{ URL::action('ProgramsController@fetch') }}",
  690. data: { id: school.find(':selected').data('school-id')},
  691. success: function(data)
  692. {
  693. $('#select-program').empty();
  694. $('#select-program').append('<option data-program-id="0">All</option>');
  695. data.forEach( function (program)
  696. {
  697. $('#select-program')
  698. .append('<option data-program-id="'+program.id+'" >'+program.name+'</option>');
  699. });
  700. },
  701. async:false
  702. });
  703. if($('#select-school').find(':selected').data('school-id')!=0)
  704. $('#select-program').prop('disabled', false);
  705. else
  706. $('#select-program').prop('disabled', true);
  707. refreshSelects();
  708. }
  709. // Load a template. This function is different from the one for professors
  710. function loadTemplate()
  711. {
  712. $.post
  713. (
  714. "{{ URL::to('loadTemplate') }}",
  715. { id: $('#select-template').find(':selected').data('template-id')},
  716. function(data)
  717. {
  718. // Show the container and empty all rows
  719. $('#rubric-container').show();
  720. $('tbody').empty();
  721. //Set the name of the rubric
  722. $('#rubric-name').val(data.template.name);
  723. // Set school id to 0, then to the saved value if it exists
  724. $('#select-school option[data-school-id="0"]').prop('selected', true);
  725. $('#select-school option[data-school-id="'+data.template.school_id+'"]').prop('selected', true);
  726. // Fetch programs associated to that school
  727. fetchPrograms($('#select-school'));
  728. // Set program id to 0, then to the saved value if it exists
  729. $('#select-program option[data-program-id="0"]').prop('selected', true);
  730. $('#select-program option[data-program-id="'+data.template.program_id+'"]').prop('selected', true);
  731. // Set expected values
  732. console.log(data.template.expected_percentage);
  733. console.log(data.template.expected_points);
  734. console.log(data.template.max_score);
  735. $('#max_score').val(data.template.max_score);
  736. $('#max_score').trigger("change");
  737. $('#expected_percentage').val(data.template.expected_percentage);
  738. $('#expected_points').val(data.template.expected_points);
  739. $('#number_of_scales').val(data.template.num_scales);
  740. refreshSelects();
  741. changeTable();
  742. // Set visibility
  743. var is_visible = data.template.is_visible;
  744. if(is_visible)
  745. {
  746. $('#is_visible0').prop('checked', false);
  747. $('#is_visible1').prop('checked', true);
  748. }
  749. else
  750. {
  751. $('#is_visible1').prop('checked', false);
  752. $('#is_visible0').prop('checked', true);
  753. }
  754. // Set the contents of the rubric
  755. var temp_criterion = data.criterion;
  756. for(temp_c in temp_criterion){
  757. current_criterion = temp_criterion[temp_c]
  758. objectives = JSON.stringify(current_criterion.objectives);
  759. 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>';
  760. var subcriteria ='';
  761. if(current_criterion.subcriteria){
  762. var subcriteria_array = JSON.parse(current_criterion.subcriteria);
  763. subcriteria = '<ul class="subcriteria list-unstyled">';
  764. subcriteria_array.forEach(function (value) {
  765. subcriteria += '<li>'+value+'</li>';
  766. });
  767. subcriteria += '</ul>';
  768. }
  769. if(current_criterion.notes)
  770. {
  771. str+='<span><em data-toggle="tooltip" data-placement="top" title="'+current_criterion.notes+'">'+current_criterion.name+'</em></span><sup></sup>'+subcriteria;
  772. }
  773. else
  774. {
  775. str+='<span>'+current_criterion.name+'</span><sup></sup>'+subcriteria;
  776. }
  777. str+= '</td>';
  778. for(scaleIndex in current_criterion.scales){
  779. scale = current_criterion.scales[scaleIndex];
  780. str+='<td>'+scale.description+'</td>';
  781. }
  782. str+= '<td>'+current_criterion.outcomes+'</td>'
  783. str+='<th><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></th></tr>';
  784. $('table tbody').append(str);
  785. // Enable X-Edtable on this new row
  786. $('.editable').editable({
  787. unsavedclass: null,
  788. rows: 4
  789. });
  790. // Turn on tooltips again (because content is dynamic)
  791. $('[data-toggle="tooltip"]').tooltip();
  792. refreshSelects();
  793. }
  794. /*
  795. var contents = JSON.parse(data.contents);
  796. contents.forEach(function (data)
  797. {
  798. // Append the fetched data
  799. 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>';
  800. var subcriteria = '';
  801. if(data.subcriteria){
  802. var subcriteria_array = data.subcriteria;
  803. subcriteria = '<ul class="subcriteria list-unstyled">';
  804. subcriteria_array.forEach(function (value) {
  805. subcriteria += '<li>'+value+'</li>';
  806. });
  807. subcriteria += '</ul>';
  808. }
  809. if(data.notes)
  810. {
  811. str+='<span><em data-toggle="tooltip" data-placement="top" title="'+data.notes+'">'+data.name+'</em></span><sup></sup>'+subcriteria;
  812. }
  813. else
  814. {
  815. str+='<span>'+data.name+'</span><sup></sup>'+subcriteria;
  816. }
  817. str+='</td><td class="editable" data-type="textarea">'+data.description12+'</td>'
  818. +'<td class="editable" data-type="textarea">'+data.description34+'</td>'
  819. +'<td class="editable" data-type="textarea">'+data.description56+'</td>'
  820. +'<td class="editable" data-type="textarea">'+data.description78+'</td>'
  821. +'<th><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></th></tr>';
  822. $('table tbody').append(str);
  823. // Build copyright list
  824. buildCopyrightList();
  825. // Enable X-Edtable on this new row
  826. $('.editable').editable({
  827. unsavedclass: null,
  828. rows: 4
  829. });
  830. // Turn on tooltips again (because content is dynamic)
  831. $('[data-toggle="tooltip"]').tooltip();
  832. refreshSelects();
  833. }); */
  834. // Sortable rows
  835. $('.table').sortable({
  836. handle: 'span.glyphicon.glyphicon-move',
  837. containerSelector: 'table',
  838. itemPath: '> tbody',
  839. itemSelector: 'tr',
  840. placeholder: '<tr class="placeholder"><th><span class="glyphicon glyphicon-arrow-right"></span></th></tr>'
  841. });
  842. // Build Copyright List
  843. buildCopyrightList();
  844. $('.editable').each(function (index){
  845. $(this).text(data.titles[index].text);
  846. })
  847. var selected = $('#select-template').find(':selected');
  848. var programs = {{ json_encode(Auth::user()->programs->lists('id')) }};
  849. var template_program = selected.data('template-program-id');
  850. if(
  851. {{ Auth::user()->role }}==1
  852. || ({{ Auth::user()->role }}==2 && selected.data('admin')!=1)
  853. || ({{ Auth::user()->role }}==3
  854. && programs.includes(selected.data('template-program-id'))
  855. && selected.data('admin')!=1
  856. )
  857. )
  858. {
  859. $('#button-confirm-delete-rubric').prop('disabled', false);
  860. $('#button-confirm-update-rubric').prop('disabled', false);
  861. }
  862. else
  863. {
  864. // Disable update and edit
  865. $('#button-confirm-delete-rubric').prop('disabled', true);
  866. $('#button-confirm-update-rubric').prop('disabled', true);
  867. }
  868. // Enable print button
  869. $('#button-print-rubric').prop('disabled', false);
  870. fetchCriteria($('#select-outcome'), $('#select-objective'));
  871. },
  872. 'json',
  873. );
  874. }
  875. // Checks whether the user wants to save a rubric with a name that already exists
  876. function nameExists()
  877. {
  878. var duplicates = false;
  879. $('#select-template option').each(function()
  880. {
  881. var optionName = $(this).text().trim();
  882. if($('#rubric-name').val().trim()===optionName)
  883. {
  884. duplicates = true;
  885. }
  886. });
  887. refreshSelects();
  888. return duplicates;
  889. }
  890. //Enable disable program select
  891. function toggleProgramSelect(school)
  892. {
  893. if(school.find(':selected').data('school-id') <1)
  894. {
  895. $('#select-program option[data-program-id="0"]').prop('selected', true);
  896. $('#select-program').prop('disabled', true);
  897. }
  898. else
  899. {
  900. fetchPrograms(school);
  901. $('#select-program').prop('disabled', false);
  902. }
  903. refreshSelects();
  904. }
  905. fetchObjective($('#select-outcome'));
  906. // --------------------------------------------------------------------------
  907. // Events
  908. // --------------------------------------------------------------------------
  909. // Toggle visibility for accordion panels
  910. $('.panel-heading').on('click', function()
  911. {
  912. if($(this).find('.glyphicon').hasClass('glyphicon-triangle-right'))
  913. {
  914. $(this).find('.glyphicon').removeClass('glyphicon-triangle-right');
  915. $(this).find('.glyphicon').addClass('glyphicon-triangle-bottom');
  916. }
  917. else if($(this).find('.glyphicon').hasClass('glyphicon-triangle-bottom'))
  918. {
  919. $(this).find('.glyphicon').removeClass('glyphicon-triangle-bottom');
  920. $(this).find('.glyphicon').addClass('glyphicon-triangle-right');
  921. }
  922. $(this).siblings('.panel-body').stop().slideToggle();
  923. });
  924. // Fetch criteria everytime something changes
  925. $('#select-objective').on('change', function(){
  926. fetchCriteria($('#select-outcome'), $('#select-objective'));
  927. })
  928. $("#number_of_scales").on('change', function(){
  929. fetchCriteria($('#select-outcome'), $('#select-objective'));
  930. })
  931. // When trying to change the template, ask the user to confirm and reset the
  932. // rubric if s/he does
  933. $('#select-template').on('change', function()
  934. {
  935. // If changing to custom template, reset
  936. if($('#select-template').find(':selected').data('template-id')=='0')
  937. {
  938. $('#rubric-container').hide();
  939. $('#rubric-name').val('');
  940. $('tbody').empty();
  941. // Disable delete, update and print buttons
  942. $('#button-confirm-delete-rubric').prop('disabled', true);
  943. $('#button-confirm-update-rubric').prop('disabled', true);
  944. $('#button-print-rubric').prop('disabled', true);
  945. }
  946. // Otherwise, load the selected template
  947. else
  948. {
  949. loadTemplate();
  950. //If user is admin, or the templates id matches user's, or the template
  951. // id's school matches user, allow editing
  952. /*var selected = $('#select-template').find(':selected');
  953. var programs = {{ json_encode(Auth::user()->programs->lists('id')) }};
  954. var template_program = selected.data('template-program-id');
  955. var dataset = selected.dataSet.templateProgramId;
  956. if(
  957. {{ Auth::user()->role }}==1
  958. || ({{ Auth::user()->role }}==2 && selected.data('admin')!=1)
  959. || ({{ Auth::user()->role }}==3
  960. && programs.includes(selected.data('template-program-id'))
  961. && selected.data('admin')!=1
  962. )
  963. )
  964. {
  965. $('#button-confirm-delete-rubric').prop('disabled', false);
  966. $('#button-confirm-update-rubric').prop('disabled', false);
  967. }
  968. else
  969. {
  970. // Disable update and edit
  971. $('#button-confirm-delete-rubric').prop('disabled', true);
  972. $('#button-confirm-update-rubric').prop('disabled', true);
  973. }
  974. // Enable print button
  975. $('#button-print-rubric').prop('disabled', false);
  976. */
  977. }
  978. });
  979. function changeTable(){
  980. amount_of_scales = parseInt($('#number_of_scales').find(':selected').val());
  981. counter2 = 0;
  982. maximum = parseInt($('#max_score').find(":selected").val());
  983. newScaleHeaders = '<th></th><th>Criterion</th>';
  984. editableTitles = '<th></th><th></th>';
  985. counter = 0;
  986. division = maximum/amount_of_scales;
  987. if(amount_of_scales==1){
  988. newScaleHeaders+= "<th>Score (1 - "+maximum+")</th>";
  989. editableTitles += "<th class = 'editable' data-type = 'textarea'>Click to edit Title </th>"
  990. }
  991. else if(maximum!= amount_of_scales){
  992. while(counter <amount_of_scales){
  993. minimumScore = 1+(counter*division);
  994. maximumScore = (1+counter)*division;
  995. newScaleHeaders+= "<th>Scale "+ (counter +1) + " ("+minimumScore+" - "+maximumScore+")</th>";
  996. editableTitles+="<th class = 'editable' data-type = 'textarea'>Click to edit Title "+(counter+1)+"</th>"
  997. counter++;
  998. }
  999. }else{
  1000. while(counter <amount_of_scales){
  1001. newScaleHeaders+= "<th>Scale "+ (counter +1) + " </th>";
  1002. editableTitles+="<th class = 'editable' data-type = 'textarea'>Click to edit Title "+(counter+1)+"</th>"
  1003. counter++;
  1004. }
  1005. }
  1006. newScaleHeaders += '<th>Outcomes</th><th></th>';
  1007. editableTitles += '<th></th><th></th>';
  1008. $('#theScaleTitles').html(editableTitles);
  1009. $("#criterion-header").html(newScaleHeaders);
  1010. $('#allCriteria').html(' ');
  1011. }
  1012. // When a school changes, update its programs. If all is selected, disable
  1013. $('#select-school').on('change', function()
  1014. {
  1015. toggleProgramSelect($(this));
  1016. });
  1017. $('#max_score').on('change', function(){
  1018. var max = parseInt($('#max_score').find(':selected').val());
  1019. var stringToScales = "<option value= '1'>Cuantitative Rubric </option>";
  1020. selectedValue = 1;
  1021. valueBefore = 0;
  1022. for(i=2; i<=20; i++){
  1023. if(max%i==0){
  1024. stringToScales += "<option value= '"+i+"'>"+i+"-Scale Rubric</option>";
  1025. selectedValue = i - valueBefore;
  1026. valueBefore = i;
  1027. }
  1028. }
  1029. $('#number_of_scales').html(stringToScales);
  1030. $('#number_of_scales').selectpicker('refresh');
  1031. $('#number_of_scales').val(selectedValue);
  1032. $('#number_of_scales').selectpicker('refresh');
  1033. var expected_points = Math.floor(max *0.7);
  1034. var expected_points_html = '';
  1035. for(i=1; i<max; i++){
  1036. expected_points_html += '<option value="'+i+'"> '+i+'</option>';
  1037. }
  1038. $('#expected_points').html(expected_points_html);
  1039. refreshSelects();
  1040. $('#expected_points').val(expected_points);
  1041. refreshSelects();
  1042. changeTable();
  1043. fetchCriteria($('#select-outcome'), $('#select-objective'))
  1044. })
  1045. $('#number_of_scales').on('change', function(){
  1046. changeTable();
  1047. $('#rubric-container').hide();
  1048. $('#rubric-name').val('');
  1049. $('tbody').empty();
  1050. })
  1051. // When a learning outcome changes, update its criteria
  1052. /*$('#select-outcome, input[name=criteria-filter]').on('change', function()
  1053. {
  1054. fetchCriteria($('#select-outcome'));
  1055. });
  1056. */
  1057. // When the add button is clicked
  1058. $('#button-add-criterion').on('click', function(e)
  1059. {
  1060. //Prevent page refresh
  1061. e.preventDefault();
  1062. //Add new criterion
  1063. addCriterion();
  1064. });
  1065. // When the create or update buttons are clicked (.save)
  1066. $('.save').on('click', function(e)
  1067. {
  1068. //Prevent page refresh
  1069. e.preventDefault();
  1070. var emptyFields=false;
  1071. $('#allCriteria').children('td').each(function()
  1072. {
  1073. if (($(this).text() == "" || $(this).text() == "Empty") && !($(this).hasClass('nullable')) )
  1074. {
  1075. emptyFields=true;
  1076. }
  1077. });
  1078. // If any fields are empty, display error
  1079. if(emptyFields || $.trim($('#rubric-name').val())=='')
  1080. {
  1081. $('#js-error-row').show();
  1082. $('#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.');
  1083. return;
  1084. }
  1085. else
  1086. {
  1087. $('#js-error-row').hide();
  1088. }
  1089. // Check whether a rubric with the written name already exists
  1090. if($(this).attr('id')=='button-create-rubric' && nameExists())
  1091. {
  1092. $('#js-error-row').show();
  1093. $('#js-error-row').find('#error-message').text('Error: A template with that name already exists.');
  1094. return;
  1095. }
  1096. else
  1097. {
  1098. $('#js-error-row').hide();
  1099. }
  1100. program_id = $('#select-program').find(':selected').data('program-id')
  1101. if(program_id == 0){
  1102. $('#modal-title-rubric').html("All criteria will be associated with this school's programs");
  1103. htmlString = "<h5>The following criteria and objectives will be matched with all programs</h5>"
  1104. htmlString += "<ol style='list-style-position: inside'>"
  1105. $('tbody tr').each(function( index )
  1106. {
  1107. objectives = $(this).data('assoc-objectives');
  1108. htmlString += "<li>" +$(this).data('criterion-name');
  1109. htmlString += "<br><h5>This criterion is associated with these objectives</h5>"
  1110. htmlString +="<ul style='padding-left: 5%; list-style-position: inside'>"
  1111. for(index in objectives){
  1112. objective_string = objectives[index];
  1113. htmlString +="<li>"+objective_string+"</li>";
  1114. }
  1115. htmlString += "</ul>"
  1116. htmlString +="</li>"
  1117. htmlString+= "<br>";
  1118. });
  1119. htmlString +='</ol>';
  1120. $("#modal-body-rubric").html(htmlString);
  1121. }
  1122. else{
  1123. $('#modal-title-rubric').html('Some criteria will be associated with this program');
  1124. $('tbody tr').each(function( index )
  1125. {
  1126. htmlString = '';
  1127. program_ids = $(this).data('program-ids')
  1128. if(!program_ids.includes(program_id) ){
  1129. title = "<h6>The following criteria and objectives will be matched with this program</h6>"
  1130. htmlString += "<ol style='list-style-position: inside'>"
  1131. objectives = $(this).data('assoc-objectives');
  1132. //objectives = objectives.split(',');
  1133. htmlString += "<li>" +$(this).data('criterion-name');
  1134. htmlString += "<br><h6>This criterion is associated with these objectives</h6>"
  1135. htmlString +="<ul style='padding-left: 5%; list-style-position: inside'>"
  1136. for(index in objectives){
  1137. objective_string = objectives[index];
  1138. htmlString +="<li>"+objective_string+"</li>";
  1139. }
  1140. htmlString += "</ul>"
  1141. htmlString +="</li>"
  1142. htmlString+= "<br>";
  1143. }
  1144. if(htmlString != ''){
  1145. $("#modal-body-rubric").html(title);
  1146. $("#modal-body-rubric").append(htmlString);
  1147. }
  1148. });
  1149. }
  1150. $('#rubric-modal').modal('toggle');
  1151. $('#saveButton').data('button-id',$(this).attr('id'));
  1152. });
  1153. // When the confirm delete button is clicked
  1154. $('#button-delete-rubric').on('click', function(e)
  1155. {
  1156. $('#modal-confirm-delete').modal('hide');
  1157. // Delete from database
  1158. $.post
  1159. (
  1160. "{{ URL::to('deleteTemplate') }}",
  1161. {
  1162. id: $('#select-template').find(':selected').data('template-id')
  1163. },
  1164. function(data)
  1165. {
  1166. location.reload();
  1167. }
  1168. );
  1169. });
  1170. // Remove a criterion and hide the table if it was the only one
  1171. $('table').on('click', 'span.glyphicon-remove', function(e)
  1172. {
  1173. $(this).closest('tr').remove();
  1174. if(!$('tbody').children().length)
  1175. {
  1176. $('#rubric-container').hide();
  1177. }
  1178. buildCopyrightList();
  1179. });
  1180. // When print button is clicked, redirect to print page
  1181. $('#button-print-rubric').on('click', function(e)
  1182. {
  1183. e.preventDefault();
  1184. window.location = "printRubric/"+$('#select-template').find(':selected').data('template-id');
  1185. });
  1186. // --------------------------------------------------------------------------
  1187. // Page load
  1188. // --------------------------------------------------------------------------
  1189. $('#updated-text').hide();
  1190. // Enable/disable program selection depending on school selection if user is
  1191. // admin
  1192. if({{Auth::user()->role}}==1)
  1193. toggleProgramSelect($('#select-school'));
  1194. // Fetch criteria of first outcome
  1195. fetchCriteria($('#select-outcome'), $('#select-objective'));
  1196. changeTable();
  1197. // Hide table
  1198. $('#rubric-container').hide();
  1199. // Disable Update and Delete Buttons by default
  1200. $('#button-confirm-update-rubric').prop('disabled', true);
  1201. $('#button-confirm-delete-rubric').prop('disabled', true);
  1202. $('#button-print-rubric').prop('disabled', true);
  1203. // Sortable rows
  1204. $('.table').sortable({
  1205. handle: 'span.glyphicon.glyphicon-move',
  1206. containerSelector: 'table',
  1207. itemPath: '> tbody',
  1208. itemSelector: 'tr',
  1209. placeholder: '<tr class="placeholder"><th><span class="glyphicon glyphicon-arrow-right"></span></th></tr>'
  1210. });
  1211. @stop