No Description

objectives.blade.php 32KB

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