Sin descripción

objectives.blade.php 31KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  1. @extends('layouts.master')
  2. @section('navigation')
  3. @if (Auth::user()->role == 1)
  4. @include('local.managers.admins._new_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
  175. associated to
  176. this Objective?</h5>
  177. </div>
  178. <div class="modal-body" id="ObjectiveModalBody">
  179. </div>
  180. <div class="modal-footer">
  181. <button type="button" class="btn btn-secondary"
  182. onclick="pair_every_criteria_with_objective =0; $('#update_button').click()"
  183. data-dismiss="modal">No</button>
  184. <button type="button" onclick="pair_every_criteria_with_objective =1; $('#update_button').click()"
  185. class="btn btn-primary" data-dismiss="modal">Yes</button>
  186. <button type="hidden" style="display:none" id="update_button" class="btn btn-primary"></button>
  187. </div>
  188. </div>
  189. </div>
  190. </div>
  191. <script>
  192. $('.filterSection').show();
  193. $('.filterButton').on('click', function() {
  194. var span = $(this).find('span');
  195. if (span.attr('class') == 'glyphicon glyphicon-plus') {
  196. span.attr('class', 'glyphicon glyphicon-minus');
  197. } else {
  198. span.attr('class', 'glyphicon glyphicon-plus');
  199. }
  200. $('.filterSection').toggle(533);
  201. });
  202. var outcomeHTML = document.getElementById('outcomeGroup').innerHTML;
  203. var selectOptions = document.getElementById('outcome[0]').innerHTML;
  204. var ran = false;
  205. function fetchAllObjectives(program, outcome) {
  206. var program_id_fetch = $('#' + program).find(':selected').val();
  207. var outcome_fetch = $('#' + outcome).find(':selected').val();
  208. $.post(
  209. "{{ URL::action('Objective2Controller@fetchAllObjectives') }}", {
  210. program_fetch: program_id_fetch,
  211. outcome_fetch: outcome_fetch
  212. },
  213. function(json) {
  214. json_length = (json.objective.length);
  215. fullHTML = '';
  216. for (var i = 0; i < json_length; i++) {
  217. fullHTML += '<option value="' + json.objective[i].id + '">' + json.objective[i].text +
  218. '</option>';
  219. }
  220. $('#select-objective').html(fullHTML);
  221. $('#select-objective').selectpicker('refresh');
  222. fetchObjectiveForEditing();
  223. },
  224. 'json'
  225. );
  226. }
  227. var counter = 1;
  228. var counterAssoc = 0;
  229. //Add Another Outcome
  230. function changeOutcomeHtml() {
  231. var outcomeHTML = document.getElementById('outcomeGroup').innerHTML;
  232. outcomeHTML = outcomeHTML.replace('outcome[' + counter.toString() + ']', 'outcome[' + (counter + 1).toString() +
  233. ']');
  234. counter += 1;
  235. document.getElementById("outcomeGroup").innerHTML += outcomeHTML;
  236. document.getElementById('button-add-outcome').onclick = addOutcome;
  237. }
  238. function addOutcome() {
  239. outcomeHTML = outcomeHTML.replace('outcome[' + counter.toString() + ']', 'outcome[' + (counter + 1).toString() +
  240. ']');
  241. counter += 1;
  242. document.getElementById("outcomeGroup").innerHTML += outcomeHTML;
  243. }
  244. function addOutcomeTest() {
  245. var $select = $('<select/>', {
  246. 'class': "selectpicker form-control createOutcome",
  247. 'name': "outcome[" + counter.toString() + "]",
  248. 'data-live-search': 'true'
  249. });
  250. //holds both the select div and the button div
  251. var $containerdiv = $('<div/>', {
  252. 'id': 'outcomeContainer' + counter.toString(),
  253. });
  254. var $div = $('<div/>', {
  255. 'id': 'outcomeForm' + counter.toString(),
  256. 'class': 'form-group col-md-11'
  257. });
  258. var $divForButton = $('<div/>', {
  259. 'class': 'col-md-1',
  260. 'id': 'close' + counter.toString()
  261. });
  262. var $button = $('<button/>', {
  263. 'type': 'button',
  264. 'class': 'btn btn-primary',
  265. //send the counter to the function so it can tell which container to remove
  266. 'onclick': 'deleteLast(' + counter + ')',
  267. });
  268. $button.append('X');
  269. $divForButton.append($button);
  270. $containerdiv.appendTo('#outcomeGroup')
  271. $div.appendTo('#outcomeContainer' + counter.toString())
  272. $select.append(selectOptions);
  273. $select.appendTo('#outcomeForm' + counter.toString()).selectpicker('refresh');
  274. $divForButton.appendTo('#outcomeContainer' + counter.toString());
  275. counter += 1;
  276. $('#counter').val(counter);
  277. }
  278. //Recieves the counter variable so it can find the specific div and delete it
  279. function deleteLast(counter) {
  280. div = document.getElementById('outcomeContainer' + (counter).toString());
  281. div.remove();
  282. }
  283. function fetchObjectiveForEditing() {
  284. var id = $('#select-objective').find(':selected').val();
  285. $.post(
  286. "{{ URL::action('Objective2Controller@fetchObjectiveWithTrashed') }}", {
  287. id: id
  288. },
  289. function(json) {
  290. var text = json.objective[0].text;
  291. // Display info
  292. $('#objective-text').val(text);
  293. // Select associated outcome
  294. $(".removable-outcome").remove();
  295. $('.warning-objective').remove();
  296. $("#assoc_outcome0").attr('data-old-outcome-id',json.outcome[0].outcome_id);
  297. $('#assoc_outcome0').val(json.outcome[0].outcome_id);
  298. disabled = 0;
  299. //se va a disable cuando pertenece a un plan.
  300. if (json.outcome[0].typ_semester_outcome_id != null){ //|| json.outcome[0].count_criterion_id != 0) {
  301. $('#assoc_outcome0').attr('disabled', true);
  302. disabled = 1;
  303. } else $('#assoc_outcome0').attr('disabled', false);
  304. counterAssoc = 0;
  305. $('#assoc_outcome0').selectpicker('refresh');
  306. for (var i = 1; i < json.outcome.length; i++) {
  307. counterAssoc = i;
  308. var $select = $('<select />', {
  309. 'class': "selectpicker form-control ",
  310. 'name': "assoc_outcome[]",
  311. 'data-live-search': 'true',
  312. 'id': 'assoc_outcome' + i.toString(),
  313. 'data-old-outcome-id': json.outcome[i].outcome_id
  314. });
  315. var $div = $('<div />', {
  316. 'id': 'assocOutcomeForm' + i.toString(),
  317. 'class': 'form-group col-md-11 removable-outcome'
  318. });
  319. var $divForButton = $('<div />', {
  320. 'class': 'col-md-1 removable-outcome',
  321. 'id': 'closeAssoc' + i.toString()
  322. });
  323. var $button = $('<button />', {
  324. 'type': 'button',
  325. 'class': 'btn btn-primary removable-outcome',
  326. 'onclick': 'deleteLastAssoc(' + i + ')'
  327. });
  328. $button.append('X');
  329. $divForButton.append($button);
  330. $div.appendTo('#assocOutcomeGroup')
  331. $select.append(selectOptions);
  332. if (json.outcome[i].typ_semester_outcome_id != null //|| json.outcome[i].count_criterion_id != 0
  333. ) {
  334. $select.attr('disabled', true);
  335. $button.attr('disabled', true);
  336. disabled = 1;
  337. }
  338. $select.appendTo('#assocOutcomeForm' + i.toString()).selectpicker('refresh');
  339. $divForButton.appendTo('#assocOutcomeGroup');
  340. $('#assoc_outcome' + i.toString()).val(json.outcome[i].outcome_id);
  341. $('#assoc_outcome' + i.toString()).selectpicker('refresh');
  342. }
  343. if (disabled == 1) {
  344. alert = $('<div/>', {
  345. 'class': 'alert alert-danger alert-dismissible warning-objective',
  346. 'role': 'alert'
  347. })
  348. button = $('<button/>', {
  349. 'type': 'button',
  350. 'class': 'close',
  351. 'data-dismiss': 'alert',
  352. 'alert-label': 'close'
  353. }).html('<span aria-hidden="true">×</span>');
  354. alert.append(button);
  355. alert.append(
  356. '<strong>If you wish to edit the disabled Learning Outcomes, you need to detach this Objective from the desired Learning Outcome in every Three Year Plan.</strong>'
  357. )
  358. alert.appendTo($('#message_to_disconnect'))
  359. }
  360. var program_length = json.program.length;
  361. $('input[type=checkbox]').prop('checked', false);
  362. for (var i = 0; i < program_length; i++) {
  363. prog = json.program[i].program_id.toString();
  364. $('#assoc_program_id_' + prog).prop("checked", true);
  365. }
  366. // Select status
  367. if (json.objective[0].deleted_at)
  368. $('#status').val(0);
  369. else
  370. $('#status').val(1);
  371. typ_status = "";
  372. warning = "";
  373. if (json.typ_semester_objectives.length > 0 && json.assessment.length > 0) {
  374. warning =
  375. "<p>This objective is currently participating in an Assessment and it is paired to a Three Year Plan, therefore it cannot be deleted </p>";
  376. $("#deleteObj").html(warning);
  377. } else if (json.assessment.length > 0) {
  378. $('#deleteObj').html(
  379. "<p>This objective is currently participating in an Assessment, therefore it cannot be deleted</p>"
  380. );
  381. } else if (json.typ_semester_objectives.length > 0) {
  382. warning =
  383. "<p>This objective is currently paired to a Three Year Plan, therefore it cannot be deleted </p>";
  384. $("#deleteObj").html(
  385. warning
  386. );
  387. } else if (json.assoc_criteria.length > 0) {
  388. modal =
  389. '<button type="button" class="btn btn-primary btn-block" data-toggle="modal" data-target="#delete">' +
  390. 'Delete' +
  391. '</button>' +
  392. '<input type="hidden" value =' + json.objective[0].id + ' name="deleteObj">' +
  393. '<div class="modal fade" id="delete" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">' +
  394. '<div class="modal-dialog" role="document">' +
  395. '<div class="modal-content">' +
  396. ' <div class="modal-header">' +
  397. '<h5 class="modal-title" id="exampleModalLabel">Are you sure?</h5>' +
  398. '<button type="button" class="close" data-dismiss="modal" aria-label="Close">' +
  399. '<span aria-hidden="true">&times;</span>' +
  400. '</button>' +
  401. ' </div>' +
  402. '<div class="modal-body">' +
  403. "<p>This objective is associated to: <p>" +
  404. '<ul>';
  405. for (var i = 0; i < json.assoc_criteria.length; i++) {
  406. modal += "<li>" + json.assoc_criteria[i].name + '</li>';
  407. }
  408. modal += ' </ul>' +
  409. '<p>Do you still want to delete it?</p>' +
  410. '</div>' +
  411. '<div class="modal-footer">' +
  412. '<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>' +
  413. '<button type="submit" class="btn btn-primary">Delete</button>' +
  414. '</div>' +
  415. '</div>' +
  416. '</div>' +
  417. '</div>';
  418. $('#deleteObj').html(modal);
  419. } else {
  420. modal =
  421. '<button type="button" class="btn btn-primary btn-block" data-toggle="modal" data-target="#delete">' +
  422. 'Delete' +
  423. '</button>' +
  424. '<input type="hidden" value =' + json.objective[0].id + ' name="deleteObj">' +
  425. '<div class="modal fade" id="delete" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">' +
  426. '<div class="modal-dialog" role="document">' +
  427. '<div class="modal-content">' +
  428. ' <div class="modal-header">' +
  429. '<h5 class="modal-title" id="exampleModalLabel">Are you sure?</h5>' +
  430. '<button type="button" class="close" data-dismiss="modal" aria-label="Close">' +
  431. '<span aria-hidden="true">&times;</span>' +
  432. '</button>' +
  433. ' </div>' +
  434. '<div class="modal-body">' +
  435. "<p> Once deleted, there is no chance of getting it back.</p>";
  436. modal +=
  437. '<p>Do you still want to delete it?</p>' +
  438. '</div>' +
  439. '<div class="modal-footer">' +
  440. '<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>' +
  441. '<button type="submit" class="btn btn-primary">Delete</button>' +
  442. '</div>' +
  443. '</div>' +
  444. '</div>' +
  445. '</div>';
  446. $('#deleteObj').html(modal);
  447. }
  448. },
  449. 'json'
  450. );
  451. }
  452. function deleteLastAssoc(i) {
  453. div = document.getElementById('assocOutcomeForm' + (i).toString());
  454. div.remove();
  455. button = document.getElementById('closeAssoc' + (i).toString());
  456. button.remove();
  457. //counterAssoc -= 1;
  458. //$('#counterAssoc').val(counterAssoc);
  459. }
  460. function addAssoc() {
  461. counterAssoc += 1;
  462. var $select = $('<select />', {
  463. 'class': "selectpicker form-control ",
  464. 'name': "assoc_outcome[]",
  465. 'data-live-search': 'true',
  466. 'id': 'assoc_outcome' + counterAssoc.toString(),
  467. 'data-new-outcome': 'true'
  468. });
  469. var $div = $('<div />', {
  470. 'id': 'assocOutcomeForm' + counterAssoc.toString(),
  471. 'class': 'form-group col-md-11 removable-outcome'
  472. });
  473. var $divForButton = $('<div />', {
  474. 'class': 'col-md-1 removable-outcome',
  475. 'id': 'closeAssoc' + counterAssoc.toString()
  476. });
  477. var $button = $('<button />', {
  478. 'type': 'button',
  479. 'class': 'btn btn-primary',
  480. 'onclick': 'deleteLastAssoc(' + counterAssoc + ')'
  481. });
  482. $button.append('X');
  483. $divForButton.append($button);
  484. $div.appendTo('#assocOutcomeGroup')
  485. $select.append(selectOptions);
  486. $select.appendTo('#assocOutcomeForm' + counterAssoc.toString()).selectpicker('refresh');
  487. $divForButton.appendTo('#assocOutcomeGroup');
  488. ran = true;
  489. //counterAssoc += 1;
  490. $('#counterAssoc').val(counterAssoc);
  491. }
  492. $("#update_button_to_modal").on('click', function(e) {
  493. e.preventDefault();
  494. newOutcomes = [];
  495. $('#assocOutcomeGroup').find('select').each(function() {
  496. if ($(this).data('new-outcome') == true || $(this).data('old-outcome-id') != $(this).val()) {
  497. option = $(this).find(':selected');
  498. newOutcomes.push(option[0].text);
  499. }
  500. })
  501. if (newOutcomes.length > 0) {
  502. ul = $("<ul>");
  503. $.each(newOutcomes, function(id, text) {
  504. li = $("<li>").html(text)
  505. ul.append(li);
  506. });
  507. $("#ObjectiveModalBody").html(ul);
  508. $('#ObjectiveAssocModal').modal("toggle");
  509. } else {
  510. pair_every_criteria_with_objective = 0;
  511. $("#update_button").click();
  512. }
  513. })
  514. //Terrible notation but
  515. pair_every_criteria_with_objective = 0;
  516. $('#update_button').on('click', function(e) {
  517. e.preventDefault();
  518. outcome_id = []
  519. program_id = [];
  520. status = $('#status').val();
  521. text = $('#objective-text').val();
  522. id = $('#select-objective').val();
  523. $('#assocOutcomeGroup').find('select').each(function() {
  524. outcome_id.push($(this).val())
  525. })
  526. $('input[name="assoc_program_id[]"]').each(function() {
  527. if (this.checked)
  528. program_id.push($(this).val())
  529. });
  530. $.post(
  531. "{{ URL::action('Objective2Controller@update') }}", {
  532. assoc_outcome: outcome_id,
  533. program_id: program_id,
  534. status: status,
  535. text: text,
  536. id: id,
  537. pair_every_criteria_with_objective: pair_every_criteria_with_objective
  538. },
  539. function($array) {
  540. div = $('<div/>', {
  541. 'class': 'alert alert-dismissible alert-' + $array.status,
  542. 'role': 'alert'
  543. })
  544. button = $('<button/>', {
  545. 'class': 'close',
  546. 'type': 'button',
  547. 'data-dismiss': 'alert',
  548. 'aria-label': 'Close'
  549. }).html('<span aria-hidden="true">&times;</span>');
  550. div.append(button);
  551. if ($array.status == 'danger') {
  552. span = $('<span/>', {
  553. 'class': 'glyphicon glyphicon-remove-sign'
  554. });
  555. } else {
  556. span = $('<span/>', {
  557. 'class': 'glyphicon glyphicon-ok-sign'
  558. });
  559. }
  560. div.append(span);
  561. div.append($array.message);
  562. div.appendTo('#message');
  563. }
  564. )
  565. })
  566. </script>
  567. @stop
  568. @section('javascript')
  569. // --------------------------------------------------------------------------
  570. // Page load
  571. // --------------------------------------------------------------------------
  572. // Hide accordion panel contents by default
  573. $('.panel-group .panel-body').hide();
  574. $('#outcome-display').parent().hide();
  575. // fetchObjectiveForEditing();
  576. // setCriterionStatus();
  577. fetchAllObjectives("select-program", "assoc_outcomes_fetch")
  578. // --------------------------------------------------------------------------
  579. // Functions
  580. // --------------------------------------------------------------------------
  581. // Fetch criterion info for editing
  582. $('#button-add-outcome').on('click', function(e) {
  583. // Prevent the default action of the clicked item. In this case that is submit
  584. e.preventDefault();
  585. return false;
  586. });
  587. $('#button-add-assoc-outcome').on('click', function(e) {
  588. // Prevent the default action of the clicked item. In this case that is submit
  589. e.preventDefault();
  590. return false;
  591. });
  592. // --------------------------------------------------------------------------
  593. // Events
  594. // --------------------------------------------------------------------------
  595. // When panel heading is clicked, toggle it
  596. $('.panel-group .panel-heading').on('click', function()
  597. {
  598. $(this).next().stop().slideToggle();
  599. })
  600. // When list item is clicked, load corresponding info
  601. $('#select-objective').on('change', function()
  602. {
  603. fetchObjectiveForEditing();
  604. $('.selectpicker').selectpicker('refresh');
  605. });
  606. // When list item is clicked, load corresponding info
  607. $('.selectpicker').on('change', function()
  608. {
  609. //alert($(this).find(':selected').val());
  610. $('.selectpicker').selectpicker('refresh');
  611. });
  612. @stop