Нет описания

objectives.blade.php 31KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. @extends('layouts.master')
  2. @section('navigation')
  3. @if (Auth::user()->role == 1)
  4. @include('local.managers.admins._navigation')
  5. @elseif(Auth::user()->role == 2)
  6. @include('local.managers.sCoords._new_navigation')
  7. @elseif(Auth::user()->role == 3)
  8. @include('local.managers.pCoords._new_navigation')
  9. @endif
  10. @stop
  11. @section('main')
  12. <div class="row">
  13. <div class="col-md-12" id='message'>
  14. </div>
  15. </div>
  16. <div class="row">
  17. <div class="col-md-6">
  18. <!-- Form to add a new objective -->
  19. <div class="panel panel-default panel-button">
  20. <div class="panel-heading">
  21. Create
  22. </div>
  23. <div class="panel-body">
  24. {{ Form::open(['action' => 'Objective2Controller@create']) }}
  25. <div id='outcomeGroup'>
  26. <label> Associated Learning Outcome</label>
  27. <div class="form-group col-md-11" id='outcomeForm'>
  28. <select id="outcome[0]" name="outcome[0]" class="form-control selectpicker createOutcome">
  29. @foreach ($outcomes as $outcome)
  30. <option value="{{ $outcome->id }}">
  31. {{ $outcome->name }}
  32. </option>
  33. @endforeach
  34. </select>
  35. </div>
  36. </div>
  37. <input type='hidden' name='counter' id='counter' value=1>
  38. <button id='button-add-outcome' class='btn btn-md btn-secondary' onclick='addOutcomeTest()'>
  39. <span class='glyphicon glyphicon-plus'>
  40. </span>
  41. Add another Learning Outcome
  42. </button>
  43. <!-- Associated Program -->
  44. <div class="form-group">
  45. {{ Form::label('program_id', 'Associated Program') }}<br>
  46. <br>
  47. @foreach ($programs as $program)
  48. <input type="checkbox" id="{{ $program->name }}" name="program_id[]"
  49. value="{{ $program->id }}">
  50. <label for="{{ $program->name }}"> {{ $program->name }}
  51. [{{ $program->school->name }}]</label><br>
  52. @endforeach
  53. </div>
  54. <div class="form-group">
  55. {{ Form::label('text', 'Text') }}
  56. {{ Form::text('text', '', ['class' => 'form-control']) }}
  57. </div>
  58. {{ Form::submit('Create', ['class' => 'btn btn-primary btn-block', 'id' => 'createObjectiveButton']) }}
  59. {{ Form::close() }}
  60. </div>
  61. </div>
  62. </div>
  63. <div class="col-md-6">
  64. <div class="panel panel-default panel-button">
  65. <div class="panel-heading">
  66. Edit
  67. </div>
  68. <div class="panel-body">
  69. <button class="btn btn-md btn-secondary filterButton">
  70. <span class="glyphicon glyphicon-minus">
  71. </span>
  72. Filters
  73. </button>
  74. <div class='filterSection'>
  75. {{ Form::open(['action' => 'Objective2Controller@update']) }}
  76. <div class="form-group">
  77. {{ Form::label('program_id2', 'Associated Program') }}
  78. <select id='select-program' class="form-control selectpicker"
  79. onchange='fetchAllObjectives("select-program", "assoc_outcomes_fetch")'>
  80. @foreach ($programs as $program)
  81. <option value='{{ $program->id }}' data-subtext="{{ $program->code }}">
  82. {{ $program->name }}</option>
  83. @endforeach
  84. </select>
  85. </div>
  86. <div class="form-group">
  87. <label>Associated Learning Outcome</label>
  88. {{-- Form::select('assoc_outcome_fetch', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcomes_fetch', 'onchange'=>'fetchAllObjectives("select-program", "assoc_outcomes_fetch")']) --}}
  89. <select id="assoc_outcomes_fetch" name="assoc_outcome_fetch" class="form-control selectpicker"
  90. onchange="fetchAllObjectives('select-program', 'assoc_outcomes_fetch')">
  91. @foreach ($outcomes as $outcome)
  92. <option value="{{ $outcome->id }}">
  93. {{ $outcome->name }}
  94. </option>
  95. @endforeach
  96. </select>
  97. </div>
  98. </div>
  99. <hr>
  100. <div class="form-group">
  101. {{ Form::label('objective_id', 'Objectives') }}
  102. <select id="select-objective" name='id' class="form-control selectpicker">
  103. @foreach ($objectives as $objective)
  104. <option value="{{ $objective->id }}"
  105. data-subtext="
  106. @if ($objective->program) &nbsp;&nbsp;&nbsp;[{{ $objective->program->name }}] @endif
  107. ">
  108. {{ $objective->text }}
  109. </option>
  110. @endforeach
  111. </select>
  112. </div>
  113. <!-- Associated Outcome -->
  114. <div class="form-group">
  115. <div id='assocOutcomeGroup'>
  116. <label>Associated Learning Outcome</label>
  117. <div id="message_to_disconnect"></div>
  118. <select id="assoc_outcome0" name="assoc_outcome[]" class="form-control selectpicker">
  119. @foreach ($outcomes as $outcome)
  120. <option value="{{ $outcome->id }}">
  121. {{ $outcome->name }}
  122. </option>
  123. @endforeach
  124. </select>
  125. <br><br>
  126. </div>
  127. </div>
  128. <button id='button-add-assoc-outcome' class='btn btn-md btn-secondary' onclick='addAssoc()'>
  129. <span class='glyphicon glyphicon-plus'>
  130. </span>
  131. Add another Learning Outcome
  132. </button>
  133. <!-- Associated Program -->
  134. <div class="form-group">
  135. {{ Form::label('program_id', 'Associated Program') }}<br>
  136. <br>
  137. @foreach ($programs as $program)
  138. <input type="checkbox" id="assoc_program_id_{{ $program->id }}" name="assoc_program_id[]"
  139. value="{{ $program->id }}">
  140. <label for="assoc_program_id_{{ $program->id }}"> {{ $program->name }}
  141. <sub>[{{ $program->school->name }}]</sub></label><br>
  142. @endforeach
  143. </div>
  144. <!-- Status -->
  145. <div class="form-group">
  146. {{ Form::label('status', 'Status') }}
  147. <span data-toggle="tooltip" data-placement="top"
  148. title="Use this option to deactivate or reactivate objectives. Inactive objective will stay in the system, but will not be available to use in new rubrics."
  149. class="glyphicon glyphicon-question-sign"></span>
  150. <select id="status" name="status" class="form-control">
  151. <option value="1">Active</option>
  152. <option value="0">Inactive</option>
  153. </select>
  154. </div>
  155. <div class="form-group">
  156. {{ Form::label('text', 'Text') }}
  157. {{ Form::text('text', Input::old('text'), ['class' => 'form-control', 'id' => 'objective-text']) }}
  158. </div>
  159. <div id="text">
  160. </div>
  161. {{ Form::submit('Update', ['class' => 'btn btn-primary btn-block', 'id' => 'update_button_to_modal']) }}
  162. {{ Form::close() }}
  163. <form action="/deleteObjective" method="POST" id='deleteObj'>
  164. </form>
  165. </div>
  166. </div>
  167. </div>
  168. </div>
  169. <div id="ObjectiveAssocModal" class="modal fade" tabindex="-1" data-criterion-id="0">
  170. <div class="modal-dialog">
  171. <div class="modal-content">
  172. <div class="modal-header">
  173. <button type="button" class="close" data-dismiss="modal">&times;</button>
  174. <h5 class="modal-title">Would you like to pair these new Learning Outcomes to all the Criteria associated to
  175. this Objective?</h5>
  176. </div>
  177. <div class="modal-body" id="ObjectiveModalBody">
  178. </div>
  179. <div class="modal-footer">
  180. <button type="button" class="btn btn-secondary"
  181. onclick="pair_every_criteria_with_objective =0; $('#update_button').click()"
  182. data-dismiss="modal">No</button>
  183. <button type="button" onclick="pair_every_criteria_with_objective =1; $('#update_button').click()"
  184. class="btn btn-primary" data-dismiss="modal">Yes</button>
  185. <button type="hidden" style="display:none" id="update_button" class="btn btn-primary"></button>
  186. </div>
  187. </div>
  188. </div>
  189. </div>
  190. <script>
  191. $('.filterSection').show();
  192. $('.filterButton').on('click', function() {
  193. var span = $(this).find('span');
  194. if (span.attr('class') == 'glyphicon glyphicon-plus') {
  195. span.attr('class', 'glyphicon glyphicon-minus');
  196. } else {
  197. span.attr('class', 'glyphicon glyphicon-plus');
  198. }
  199. $('.filterSection').toggle(533);
  200. });
  201. var outcomeHTML = document.getElementById('outcomeGroup').innerHTML;
  202. var selectOptions = document.getElementById('outcome[0]').innerHTML;
  203. var ran = false;
  204. function fetchAllObjectives(program, outcome) {
  205. var program_id_fetch = $('#' + program).find(':selected').val();
  206. var outcome_fetch = $('#' + outcome).find(':selected').val();
  207. $.post(
  208. "{{ URL::action('Objective2Controller@fetchAllObjectives') }}", {
  209. program_fetch: program_id_fetch,
  210. outcome_fetch: outcome_fetch
  211. },
  212. function(json) {
  213. json_length = (json.objective.length);
  214. fullHTML = '';
  215. for (var i = 0; i < json_length; i++) {
  216. fullHTML += '<option value="' + json.objective[i].id + '">' + json.objective[i].text +
  217. '</option>';
  218. }
  219. $('#select-objective').html(fullHTML);
  220. $('#select-objective').selectpicker('refresh');
  221. fetchObjectiveForEditing();
  222. },
  223. 'json'
  224. );
  225. }
  226. var counter = 1;
  227. var counterAssoc = 0;
  228. //Add Another Outcome
  229. function changeOutcomeHtml() {
  230. var outcomeHTML = document.getElementById('outcomeGroup').innerHTML;
  231. outcomeHTML = outcomeHTML.replace('outcome[' + counter.toString() + ']', 'outcome[' + (counter + 1).toString() +
  232. ']');
  233. counter += 1;
  234. document.getElementById("outcomeGroup").innerHTML += outcomeHTML;
  235. document.getElementById('button-add-outcome').onclick = addOutcome;
  236. }
  237. function addOutcome() {
  238. outcomeHTML = outcomeHTML.replace('outcome[' + counter.toString() + ']', 'outcome[' + (counter + 1).toString() +
  239. ']');
  240. counter += 1;
  241. document.getElementById("outcomeGroup").innerHTML += outcomeHTML;
  242. }
  243. function addOutcomeTest() {
  244. var $select = $('<select/>', {
  245. 'class': "selectpicker form-control createOutcome",
  246. 'name': "outcome[" + counter.toString() + "]",
  247. 'data-live-search': 'true'
  248. });
  249. //holds both the select div and the button div
  250. var $containerdiv = $('<div/>', {
  251. 'id': 'outcomeContainer' + counter.toString(),
  252. });
  253. var $div = $('<div/>', {
  254. 'id': 'outcomeForm' + counter.toString(),
  255. 'class': 'form-group col-md-11'
  256. });
  257. var $divForButton = $('<div/>', {
  258. 'class': 'col-md-1',
  259. 'id': 'close' + counter.toString()
  260. });
  261. var $button = $('<button/>', {
  262. 'type': 'button',
  263. 'class': 'btn btn-primary',
  264. //send the counter to the function so it can tell which container to remove
  265. 'onclick': 'deleteLast(' + counter + ')',
  266. });
  267. $button.append('X');
  268. $divForButton.append($button);
  269. $containerdiv.appendTo('#outcomeGroup')
  270. $div.appendTo('#outcomeContainer' + counter.toString())
  271. $select.append(selectOptions);
  272. $select.appendTo('#outcomeForm' + counter.toString()).selectpicker('refresh');
  273. $divForButton.appendTo('#outcomeContainer' + counter.toString());
  274. counter += 1;
  275. $('#counter').val(counter);
  276. }
  277. //Recieves the counter variable so it can find the specific div and delete it
  278. function deleteLast(counter) {
  279. div = document.getElementById('outcomeContainer' + (counter).toString());
  280. div.remove();
  281. }
  282. function fetchObjectiveForEditing() {
  283. var id = $('#select-objective').find(':selected').val();
  284. $.post(
  285. "{{ URL::action('Objective2Controller@fetchObjectiveWithTrashed') }}", {
  286. id: id
  287. },
  288. function(json) {
  289. var text = json.objective[0].text;
  290. // Display info
  291. $('#objective-text').val(text);
  292. // Select associated outcome
  293. $(".removable-outcome").remove();
  294. $('.warning-objective').remove();
  295. $('#assoc_outcome0').val(json.outcome[0].outcome_id);
  296. disabled = 0;
  297. if (json.outcome[0].typ_semester_outcome_id != null || json.outcome[0].count_criterion_id != 0) {
  298. $('#assoc_outcome0').attr('disabled', true);
  299. disabled = 1;
  300. } else $('#assoc_outcome0').attr('disabled', false);
  301. counterAssoc = 0;
  302. $('#assoc_outcome0').selectpicker('refresh');
  303. for (var i = 1; i < json.outcome.length; i++) {
  304. counterAssoc = i;
  305. var $select = $('<select />', {
  306. 'class': "selectpicker form-control ",
  307. 'name': "assoc_outcome[]",
  308. 'data-live-search': 'true',
  309. 'id': 'assoc_outcome' + i.toString(),
  310. });
  311. var $div = $('<div />', {
  312. 'id': 'assocOutcomeForm' + i.toString(),
  313. 'class': 'form-group col-md-11 removable-outcome'
  314. });
  315. var $divForButton = $('<div />', {
  316. 'class': 'col-md-1 removable-outcome',
  317. 'id': 'closeAssoc' + i.toString()
  318. });
  319. var $button = $('<button />', {
  320. 'type': 'button',
  321. 'class': 'btn btn-primary removable-outcome',
  322. 'onclick': 'deleteLastAssoc(' + i + ')'
  323. });
  324. $button.append('X');
  325. $divForButton.append($button);
  326. $div.appendTo('#assocOutcomeGroup')
  327. $select.append(selectOptions);
  328. if (json.outcome[i].typ_semester_outcome_id != null || json.outcome[i].count_criterion_id !=
  329. 0) {
  330. $select.attr('disabled', true);
  331. $button.attr('disabled', true);
  332. disabled = 1;
  333. }
  334. $select.appendTo('#assocOutcomeForm' + i.toString()).selectpicker('refresh');
  335. $divForButton.appendTo('#assocOutcomeGroup');
  336. $('#assoc_outcome' + i.toString()).val(json.outcome[i].outcome_id);
  337. $('#assoc_outcome' + i.toString()).selectpicker('refresh');
  338. }
  339. if (disabled == 1) {
  340. alert = $('<div/>', {
  341. 'class': 'alert alert-danger alert-dismissible warning-objective',
  342. 'role': 'alert'
  343. })
  344. button = $('<button/>', {
  345. 'type': 'button',
  346. 'class': 'close',
  347. 'data-dismiss': 'alert',
  348. 'alert-label': 'close'
  349. }).html('<span aria-hidden="true">×</span>');
  350. alert.append(button);
  351. alert.append(
  352. '<strong>If you wish to edit the disabled Learning Outcomes you need to detach the Objective from every Criteria paired to it and this Objectvie cannot be in any annual plan with that Learning Outcome</strong>'
  353. )
  354. alert.appendTo($('#message_to_disconnect'))
  355. }
  356. var program_length = json.program.length;
  357. $('input[type=checkbox]').prop('checked', false);
  358. for (var i = 0; i < program_length; i++) {
  359. prog = json.program[i].program_id.toString();
  360. $('#assoc_program_id_' + prog).prop("checked", true);
  361. }
  362. // Select status
  363. if (json.objective[0].deleted_at)
  364. $('#status').val(0);
  365. else
  366. $('#status').val(1);
  367. typ_status = "";
  368. warning = "";
  369. if (json.typ_semester_objectives.length > 0 && json.assessment.length > 0) {
  370. warning =
  371. "<p>This objective is currently participating in an Assessment and it is paired to a Three Year Plan, therefore it cannot be deleted </p>";
  372. $("#deleteObj").html(warning);
  373. } else if (json.assessment.length > 0) {
  374. $('#deleteObj').html(
  375. "<p>This objective is currently participating in an Assessment, therefore it cannot be deleted</p>"
  376. );
  377. } else if (json.typ_semester_objectives.length > 0) {
  378. warning =
  379. "<p>This objective is currently paired to a Three Year Plan, therefore it cannot be deleted </p>";
  380. $("#deleteObj").html(
  381. warning
  382. );
  383. } else if (json.assoc_criteria.length > 0) {
  384. modal =
  385. '<button type="button" class="btn btn-primary btn-block" data-toggle="modal" data-target="#delete">' +
  386. 'Delete' +
  387. '</button>' +
  388. '<input type="hidden" value =' + json.objective[0].id + ' name="deleteObj">' +
  389. '<div class="modal fade" id="delete" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">' +
  390. '<div class="modal-dialog" role="document">' +
  391. '<div class="modal-content">' +
  392. ' <div class="modal-header">' +
  393. '<h5 class="modal-title" id="exampleModalLabel">Are you sure?</h5>' +
  394. '<button type="button" class="close" data-dismiss="modal" aria-label="Close">' +
  395. '<span aria-hidden="true">&times;</span>' +
  396. '</button>' +
  397. ' </div>' +
  398. '<div class="modal-body">' +
  399. "<p>This objective is associated to: <p>" +
  400. '<ul>';
  401. for (var i = 0; i < json.assoc_criteria.length; i++) {
  402. modal += "<li>" + json.assoc_criteria[i].name + '</li>';
  403. }
  404. modal += ' </ul>' +
  405. '<p>Do you still want to delete it?</p>' +
  406. '</div>' +
  407. '<div class="modal-footer">' +
  408. '<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>' +
  409. '<button type="submit" class="btn btn-primary">Delete</button>' +
  410. '</div>' +
  411. '</div>' +
  412. '</div>' +
  413. '</div>';
  414. $('#deleteObj').html(modal);
  415. } else {
  416. modal =
  417. '<button type="button" class="btn btn-primary btn-block" data-toggle="modal" data-target="#delete">' +
  418. 'Delete' +
  419. '</button>' +
  420. '<input type="hidden" value =' + json.objective[0].id + ' name="deleteObj">' +
  421. '<div class="modal fade" id="delete" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">' +
  422. '<div class="modal-dialog" role="document">' +
  423. '<div class="modal-content">' +
  424. ' <div class="modal-header">' +
  425. '<h5 class="modal-title" id="exampleModalLabel">Are you sure?</h5>' +
  426. '<button type="button" class="close" data-dismiss="modal" aria-label="Close">' +
  427. '<span aria-hidden="true">&times;</span>' +
  428. '</button>' +
  429. ' </div>' +
  430. '<div class="modal-body">' +
  431. "<p> Once deleted, there is no chance of getting it back.</p>";
  432. modal +=
  433. '<p>Do you still want to delete it?</p>' +
  434. '</div>' +
  435. '<div class="modal-footer">' +
  436. '<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>' +
  437. '<button type="submit" class="btn btn-primary">Delete</button>' +
  438. '</div>' +
  439. '</div>' +
  440. '</div>' +
  441. '</div>';
  442. $('#deleteObj').html(modal);
  443. }
  444. },
  445. 'json'
  446. );
  447. }
  448. function deleteLastAssoc(i) {
  449. div = document.getElementById('assocOutcomeForm' + (i).toString());
  450. div.remove();
  451. button = document.getElementById('closeAssoc' + (i).toString());
  452. button.remove();
  453. //counterAssoc -= 1;
  454. //$('#counterAssoc').val(counterAssoc);
  455. }
  456. function addAssoc() {
  457. counterAssoc += 1;
  458. var $select = $('<select />', {
  459. 'class': "selectpicker form-control ",
  460. 'name': "assoc_outcome[]",
  461. 'data-live-search': 'true',
  462. 'id': 'assoc_outcome' + counterAssoc.toString(),
  463. 'data-new-outcome': 'true'
  464. });
  465. var $div = $('<div />', {
  466. 'id': 'assocOutcomeForm' + counterAssoc.toString(),
  467. 'class': 'form-group col-md-11 removable-outcome'
  468. });
  469. var $divForButton = $('<div />', {
  470. 'class': 'col-md-1 removable-outcome',
  471. 'id': 'closeAssoc' + counterAssoc.toString()
  472. });
  473. var $button = $('<button />', {
  474. 'type': 'button',
  475. 'class': 'btn btn-primary',
  476. 'onclick': 'deleteLastAssoc(' + counterAssoc + ')'
  477. });
  478. $button.append('X');
  479. $divForButton.append($button);
  480. $div.appendTo('#assocOutcomeGroup')
  481. $select.append(selectOptions);
  482. $select.appendTo('#assocOutcomeForm' + counterAssoc.toString()).selectpicker('refresh');
  483. $divForButton.appendTo('#assocOutcomeGroup');
  484. ran = true;
  485. //counterAssoc += 1;
  486. $('#counterAssoc').val(counterAssoc);
  487. }
  488. $("#update_button_to_modal").on('click', function(e) {
  489. e.preventDefault();
  490. newOutcomes = [];
  491. $('#assocOutcomeGroup').find('select').each(function() {
  492. if ($(this).data('new-outcome') == true) {
  493. option = $(this).find(':selected');
  494. newOutcomes.push(option[0].text);
  495. }
  496. })
  497. if (newOutcomes.length > 0) {
  498. ul = $("<ul>");
  499. $.each(newOutcomes, function(id, text) {
  500. li = $("<li>").html(text)
  501. ul.append(li);
  502. });
  503. $("#ObjectiveModalBody").html(ul);
  504. $('#ObjectiveAssocModal').modal("toggle");
  505. } else {
  506. pair_every_criteria_with_objective = 0;
  507. $("#update_button").click();
  508. }
  509. })
  510. //Terrible notation but
  511. pair_every_criteria_with_objective = 0;
  512. $('#update_button').on('click', function(e) {
  513. e.preventDefault();
  514. outcome_id = []
  515. program_id = [];
  516. status = $('#status').val();
  517. text = $('#objective-text').val();
  518. id = $('#select-objective').val();
  519. $('#assocOutcomeGroup').find('select').each(function() {
  520. outcome_id.push($(this).val())
  521. })
  522. $('input[name="assoc_program_id[]"]').each(function() {
  523. if (this.checked)
  524. program_id.push($(this).val())
  525. });
  526. $.post(
  527. "{{ URL::action('Objective2Controller@update') }}", {
  528. assoc_outcome: outcome_id,
  529. program_id: program_id,
  530. status: status,
  531. text: text,
  532. id: id,
  533. pair_every_criteria_with_objective: pair_every_criteria_with_objective
  534. },
  535. function($array) {
  536. div = $('<div/>', {
  537. 'class': 'alert alert-dismissible alert-' + $array.status,
  538. 'role': 'alert'
  539. })
  540. button = $('<button/>', {
  541. 'class': 'close',
  542. 'type': 'button',
  543. 'data-dismiss': 'alert',
  544. 'aria-label': 'Close'
  545. }).html('<span aria-hidden="true">&times;</span>');
  546. div.append(button);
  547. if ($array.status == 'danger') {
  548. span = $('<span/>', {
  549. 'class': 'glyphicon glyphicon-remove-sign'
  550. });
  551. } else {
  552. span = $('<span/>', {
  553. 'class': 'glyphicon glyphicon-ok-sign'
  554. });
  555. }
  556. div.append(span);
  557. div.append($array.message);
  558. div.appendTo('#message');
  559. }
  560. )
  561. })
  562. </script>
  563. @stop
  564. @section('javascript')
  565. // --------------------------------------------------------------------------
  566. // Page load
  567. // --------------------------------------------------------------------------
  568. // Hide accordion panel contents by default
  569. $('.panel-group .panel-body').hide();
  570. $('#outcome-display').parent().hide();
  571. // fetchObjectiveForEditing();
  572. // setCriterionStatus();
  573. fetchAllObjectives("select-program", "assoc_outcomes_fetch")
  574. // --------------------------------------------------------------------------
  575. // Functions
  576. // --------------------------------------------------------------------------
  577. // Fetch criterion info for editing
  578. $('#button-add-outcome').on('click', function(e) {
  579. // Prevent the default action of the clicked item. In this case that is submit
  580. e.preventDefault();
  581. return false;
  582. });
  583. $('#button-add-assoc-outcome').on('click', function(e) {
  584. // Prevent the default action of the clicked item. In this case that is submit
  585. e.preventDefault();
  586. return false;
  587. });
  588. // --------------------------------------------------------------------------
  589. // Events
  590. // --------------------------------------------------------------------------
  591. // When panel heading is clicked, toggle it
  592. $('.panel-group .panel-heading').on('click', function()
  593. {
  594. $(this).next().stop().slideToggle();
  595. })
  596. // When list item is clicked, load corresponding info
  597. $('#select-objective').on('change', function()
  598. {
  599. fetchObjectiveForEditing();
  600. $('.selectpicker').selectpicker('refresh');
  601. });
  602. // When list item is clicked, load corresponding info
  603. $('.selectpicker').on('change', function()
  604. {
  605. //alert($(this).find(':selected').val());
  606. $('.selectpicker').selectpicker('refresh');
  607. });
  608. @stop