설명 없음

rubrics.blade.php 52KB

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