No Description

view-three-year-plan.blade.php 48KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994
  1. @extends('layouts.master')
  2. @section('navigation')
  3. @if (Auth::user()->role == 2)
  4. @include('local.managers.sCoords._new_navigation')
  5. @elseif(Auth::user()->role == 3)
  6. @include('local.managers.pCoords._new_navigation')
  7. @endif
  8. @stop
  9. @section('main')
  10. <script type="text/javascript">
  11. function filterCycles() {
  12. // Declare variables
  13. var input, filter, div, li, i, cycleText;
  14. input = document.getElementById('userInput');
  15. filter = input.value.toUpperCase();
  16. div = document.getElementById("list");
  17. li = div.getElementsByTagName('li');
  18. // Loop through all list items, and hide those who don't match the search query
  19. for (i = 0; i < li.length; i++) {
  20. cycleText = li[i].textContent;
  21. if (cycleText.toUpperCase().indexOf(filter) > -1) {
  22. li[i].style.display = "";
  23. } else {
  24. li[i].style.display = "none";
  25. }
  26. }
  27. }
  28. // onChange, update selected outcomes-semesters
  29. function update_outcome_semesters() {
  30. var outcomeSemesterArray = new Array();
  31. // For each learning outcome, get selected boxes and put it into an array
  32. $('#outcome-semesters-body tr').each(function(index) {
  33. var outcomeObject = new Object();
  34. outcomeObject.id = $(this).data('id');
  35. var semesters = new Array();
  36. var temp = new Array();
  37. temp.push($(this).children(".sem1-box").find("input").attr('name'));
  38. temp.push($(this).children(".sem1-box").find("input").prop("checked"));
  39. semesters.push(temp);
  40. temp = new Array();
  41. temp.push($(this).children(".sem2-box").find("input").attr('name'));
  42. temp.push($(this).children(".sem2-box").find("input").prop("checked"));
  43. semesters.push(temp);
  44. temp = new Array();
  45. temp.push($(this).children(".sem3-box").find("input").attr('name'));
  46. temp.push($(this).children(".sem3-box").find("input").prop("checked"));
  47. semesters.push(temp);
  48. temp = new Array();
  49. temp.push($(this).children(".sem4-box").find("input").attr('name'));
  50. temp.push($(this).children(".sem4-box").find("input").prop("checked"));
  51. semesters.push(temp);
  52. temp = new Array();
  53. temp.push($(this).children(".sem5-box").find("input").attr('name'));
  54. temp.push($(this).children(".sem5-box").find("input").prop("checked"));
  55. semesters.push(temp);
  56. temp = new Array();
  57. temp.push($(this).children(".sem6-box").find("input").attr('name'));
  58. temp.push($(this).children(".sem6-box").find("input").prop("checked"));
  59. semesters.push(temp);
  60. outcomeObject.semesters = semesters;
  61. var clone = jQuery.extend({}, outcomeObject);
  62. outcomeSemesterArray.push(clone);
  63. });
  64. var id = $('#table-cycles').data('typ-id');
  65. $.post(
  66. "{{ URL::action('ThreeYearPlanController@update_typ_outcomes_semesters') }}", {
  67. outcomeSemesterArray: JSON.stringify(outcomeSemesterArray),
  68. typ_id: (id),
  69. program_id: {{ $program_id }}
  70. },
  71. function(data) {
  72. //;
  73. }
  74. );
  75. }
  76. </script>
  77. <div class="row">
  78. <div id="alert_placeholder">
  79. </div>
  80. <div class="col-md-3">
  81. <input class="form-control" type="text" id="userInput" onkeyup="filterCycles()"
  82. placeholder="Search for Cycles..">
  83. <div class="list-group" id='list'>
  84. @foreach ($typs as $typ)
  85. <li data-cycle-id="{{ $typ->id }}" class="list-group-item">
  86. {{ $typ->year_start }}-{{ $typ->year_end }}</li>
  87. @endforeach
  88. </div>
  89. <br>
  90. <!--<button type="button" class="btn btn-secondary" id = "three_year_button" data-toggle="modal" data-target="#three_year">Create Three Year Cycle</button>
  91. -->
  92. </div>
  93. <!-- Modal -->
  94. <div id="three_year" class="modal fade" role="dialog">
  95. <div class="modal-dialog">
  96. <!-- Modal content-->
  97. <div class="modal-content">
  98. <div class="modal-header">
  99. <button type="button" class="close" data-dismiss="modal">&times;</button>
  100. <h4 class="modal-title">Create New Cycle</h4>
  101. </div>
  102. <div class="modal-body">
  103. {{ Form::open(['action' => 'ThreeYearPlanController@create']) }}
  104. <p>Select a new cycle. You cannot choose a cycle that has been created before</p>
  105. <input type='hidden' name='program_id' value='{{ $program_id }}'>
  106. <select name='years' class="form-control selectpicker">
  107. <option value='{{ $last_year }}'>{{ $last_year }} - {{ $last_year + 3 }} </option>
  108. <option value='{{ $last_year + 3 }}'>{{ $last_year + 3 }} - {{ $last_year + 6 }}
  109. </option>
  110. </select>
  111. </div>
  112. <div class="modal-footer">
  113. <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  114. {{ Form::submit('Create Cycle', ['class' => 'btn btn-primary']) }}
  115. {{ Form::close() }}
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. <div class="col-md-9">
  121. <div class="btn-group pull-right">
  122. <a href="" id="view_button" class="btn btn-default" target="_blank" rel="noopener noreferrer">View</a>
  123. <a href="" id="print_button" class="btn btn-default" target="_blank" rel="noopener noreferrer">Print</a>
  124. </div>
  125. <div id="cycle-display" class="panel panel-default">
  126. <div class="panel-heading">
  127. <h4 class=" panel-title" style="cursor:auto!important;">
  128. </h4>
  129. </div>
  130. <div class="panel-body" id="section1">
  131. <p class="section1-description">Select two or more Semesters that will be evaluated by a Learning
  132. Outcome.</p>
  133. <div class="table-responsive">
  134. {{-- <table class="table table-striped table-condensed datatable"> --}}
  135. <table data-typ-id="0" class="table table-striped table-condensed" id="table-cycles">
  136. <style media="screen">
  137. input[type=checkbox] {
  138. transform: scale(2);
  139. }
  140. </style>
  141. <thead>
  142. <tr style="background-color:#FDD8B5;">
  143. <th rowspan="0" style="background-color:#F5DEDD;" class="text-center">Learning
  144. Outcomes</th>
  145. <th colspan="2" class="text-center" id="cycle1"></th>
  146. <th colspan="2" class="text-center" id="cycle2"></th>
  147. <th colspan="2" class="text-center" id="cycle3"></th>
  148. </tr>
  149. <tr class="">
  150. <th class="text-center">1er sem</th>
  151. <th class="text-center">2do sem</th>
  152. <th class="text-center">1er sem</th>
  153. <th class="text-center">2do sem</th>
  154. <th class="text-center">1er sem</th>
  155. <th class="text-center">2do sem</th>
  156. </tr>
  157. </thead>
  158. <tfoot>
  159. </tfoot>
  160. <input type="text" id="cycle_id" name="cycle_id" value="getsReplacedWithJS" hidden>
  161. <tbody id="outcome-semesters-body" onchange="update_outcome_semesters()">
  162. @foreach ($outcomes as $outcome)
  163. <tr data-id="{{ $outcome->id }}">
  164. <th>{{ $outcome->name }}</th>
  165. <th class="text-center sem1-box"><input type="checkbox"
  166. id="{{ $outcome->id }}-sem1" name="{{ $outcome->id }}-sem1"
  167. value="checked" /></th>
  168. <th class="text-center sem2-box"><input type="checkbox"
  169. id="{{ $outcome->id }}-sem2" name="{{ $outcome->id }}-sem2"
  170. value="checked" /></th>
  171. <th class="text-center sem3-box"><input type="checkbox"
  172. id="{{ $outcome->id }}-sem3" name="{{ $outcome->id }}-sem3"
  173. value="checked" /></th>
  174. <th class="text-center sem4-box"><input type="checkbox"
  175. id="{{ $outcome->id }}-sem4" name="{{ $outcome->id }}-sem4"
  176. value="checked" /></th>
  177. <th class="text-center sem5-box"><input type="checkbox"
  178. id="{{ $outcome->id }}-sem5" name="{{ $outcome->id }}-sem5"
  179. value="checked" /></th>
  180. <th class="text-center sem6-box"><input type="checkbox"
  181. id="{{ $outcome->id }}-sem6" name="{{ $outcome->id }}-sem6"
  182. value="checked" /></th>
  183. </tr>
  184. @endforeach
  185. </tbody>
  186. </table>
  187. <hr>
  188. <div class="">
  189. <button class="btn-lg btn-primary pull-right go-to-2" style="margin:5px;">Select
  190. Objectives</button>
  191. </div>
  192. </div>
  193. </div>
  194. <div class="panel-body" id="section2">
  195. <p class="section2-description">Select one or more Objectives that will be evaluated in a given
  196. Semester.</p>
  197. <div>
  198. <div class="objectives-section-0">
  199. </div>
  200. <div class="objectives-section">
  201. </div>
  202. <hr>
  203. <div class="">
  204. <button class="btn-lg btn-primary pull-right go-to-3" style="margin:5px;">Go to Course
  205. Selection</button>
  206. <button class="btn-lg btn-primary pull-right back-to-1" style="margin:5px;">Back to Semester
  207. Selection</button>
  208. </div>
  209. </div>
  210. </div>
  211. <div class="panel-body" id="section3">
  212. <p class="section3-description">Select one or more Courses that will be evaluated by an Objective in a
  213. given Semester.</p>
  214. <div>
  215. <div class="courses-main-clone-0" hidden>
  216. <div class="title-course-selection-0">
  217. <button class="btn btn-md btn-secondary pull-right hide-course-selection"><span
  218. class="glyphicon glyphicon-minus"></span> Hide Learning Outcome Options</button>
  219. <button class="btn btn-md btn-secondary pull-right show-course-selection"><span
  220. class="glyphicon glyphicon-plus"></span> Show Learning Outcome Options</button>
  221. <p class="h3" style="width:100%;max-width:80%;"><b> Learning Outcome:
  222. example</b></p>
  223. </div>
  224. <div class="semester-course-selection-0" style="margin-left:30px;">
  225. <label class="semester-label-course-selection-0" for="">First Semester of 2000-2000</label>
  226. <div class="select-course-selection-0" style="margin-left:30px;">
  227. <div class="objective-selector-0">
  228. <label for="">OBJECTIVE TEMP</label>
  229. <select class="select-0" name="" style="width:100%;max-width:55%;">
  230. <option class="default-option" value="nothing_selected">Select a course</option>
  231. </select>
  232. <button class="btn btn-md btn-primary delete-selection-0"
  233. style="margin:5px; "><span></span> X</button>
  234. </div>
  235. <div class="clone-objective-course-select-0">
  236. <button class="btn btn-md btn-secondary add-objective-course"
  237. style="margin:5px;"><span class="glyphicon glyphicon-plus"></span> Choose more
  238. Courses</button>
  239. </div>
  240. </div>
  241. </div>
  242. <div class="footer-course-selection-0" style="margin-left:30px;" hidden>
  243. <p><b>Course selection for this Learning Outcome is currently hidden</b></p>
  244. </div>
  245. </div>
  246. <div class="courses-section-0">
  247. </div>
  248. <div class="courses-section">
  249. </div>
  250. <hr>
  251. <div class="">
  252. <button class="btn-lg btn-primary pull-right go-to-temp" style="margin:5px;">Save & Create
  253. Annual Plans</button>
  254. <button class="btn-lg btn-primary pull-right back-to-2" style="margin:5px;">Back to Objective
  255. Selection</button>
  256. </div>
  257. </div>
  258. </div>
  259. </div>
  260. </div>
  261. <div class="col-md-9">
  262. <div class="no-cycle alert alert-info">
  263. <p>Select a Three year cycle to start</p>
  264. </div>
  265. </div>
  266. </div>
  267. <script>
  268. $(document).ready(function() {
  269. // --------------------------------------------------------------------------
  270. // Page load
  271. // --------------------------------------------------------------------------
  272. // Hide accordion panel contents by default
  273. var outcomes = {{ json_encode($outcomes) }};
  274. $('.panel-group .panel-body').hide();
  275. $('#cycle-display').parent().hide();
  276. $("#clonedOutcome0").hide();;
  277. $('.show-course-selection').hide();
  278. // --------------------------------------------------------------------------
  279. // Functions
  280. // --------------------------------------------------------------------------
  281. (function() {
  282. var previous;
  283. $("select").on('focus', function() {
  284. // Store the current value on focus and on change
  285. previous = this.value;
  286. }).change(function() {
  287. //comienzo
  288. var options_values = $(this).parent().find('select').val().split('-');
  289. //ifs
  290. if (options_values.length == 3) {
  291. var typ_id = $('#table-cycles').data('typ-id');
  292. var previous_objective_id = previous.split('-')[2];
  293. var options_values = this.value.split('-');
  294. var outcome_id = options_values[0];
  295. var semester_id = options_values[1];
  296. var new_objective_id = options_values[2];
  297. if (new_objective_id == 'n') {
  298. new_objective_id = 'nothing_selected';
  299. }
  300. if (previous_objective_id == 'n') {
  301. previous_objective_id = 'nothing_selected';
  302. }
  303. $.post(
  304. "{{ URL::action('ThreeYearPlanController@section2_on_change') }}", {
  305. typ_id: (typ_id),
  306. previous_objective_id: (previous_objective_id),
  307. outcome_id: (outcome_id),
  308. semester_id: (semester_id),
  309. new_objective_id: (new_objective_id),
  310. program_id: {{ $program_id }},
  311. },
  312. function(data) {
  313. //
  314. }
  315. );
  316. previous = this.value;
  317. } else if (options_values.length == 4) {
  318. var typ_id = $('#table-cycles').data('typ-id');
  319. var previous_course_id = previous.split('-')[3];
  320. var options_values = this.value.split('-');
  321. var outcome_id = options_values[0];
  322. var semester_id = options_values[1];
  323. var objective_id = options_values[2];
  324. var new_course_id = options_values[3];
  325. if (new_course_id == 'n') {
  326. new_course_id = 'nothing_selected';
  327. }
  328. if (previous_course_id == 'n') {
  329. previous_course_id = 'nothing_selected';
  330. }
  331. $.post(
  332. "{{ URL::action('ThreeYearPlanController@section3_on_change') }}", {
  333. typ_id: (typ_id),
  334. previous_course_id: (previous_course_id),
  335. outcome_id: (outcome_id),
  336. semester_id: (semester_id),
  337. objective_id: (objective_id),
  338. new_course_id: (new_course_id),
  339. program_id: {{ $program_id }}
  340. },
  341. function(data) {
  342. //
  343. }
  344. );
  345. previous = this.value;
  346. }
  347. });
  348. })();
  349. // --------------------------------------------------------------------------
  350. // Events
  351. // --------------------------------------------------------------------------
  352. $('.go-to-temp').on('click', function() {
  353. $.post(
  354. "{{ URL::action('ThreeYearPlanController@createAnnualPlan', [$program_id]) }}", {
  355. typ_id: $('#table-cycles').data('typ-id')
  356. },
  357. function() {
  358. window.location.href =
  359. "{{ URL::action('AnnualPlansController@showPlan', [$program_id]) }}";
  360. });
  361. });
  362. // When list item is clicked, load corresponding info
  363. //section 1
  364. $('.list-group-item').on('click', function() {
  365. $('#three_year_button').hide();
  366. var id = $(this).data('cycle-id');
  367. $('#table-cycles').data('typ-id', id);
  368. $('#view_button').show();
  369. $('#view_button').attr("href",
  370. "{{ URL::action('ThreeYearPlanController@viewPlan', [$program_id]) }}" +
  371. '/' + $(this).data('cycle-id'));
  372. $('#print_button').show();
  373. $('#print_button').attr("href",
  374. "{{ URL::action('ThreeYearPlanController@printPlan', [$program_id]) }}" +
  375. '/' + $(this).data('cycle-id'));
  376. $('#section1').show();
  377. $('#section2').hide();
  378. $('#section3').hide();
  379. var outcome_id_semester_code_program_id_box_id_typ_id = new Object();
  380. var outcome_id_semester_code_program_id_box_id_typ_id = Array();
  381. $.post(
  382. "{{ URL::action('ThreeYearPlanController@fetchThreeYears') }}", {
  383. id: id
  384. },
  385. function(json) {
  386. // Retrieve datatable instance
  387. var table = $('#table-cycles');
  388. var typ = json.typ;
  389. var year_start = json.typ.year_start;
  390. var year_end = json.typ.year_end;
  391. var semesters = json.typ.semesters;
  392. var program_id = {{ $program_id }};
  393. // var outcomes = already defined
  394. $('#cycle-display').parent().show();
  395. $('.no-cycle').parent().hide();
  396. //Display title and definition
  397. $('#cycle-display .panel-title').html('Planning for the years of ' +
  398. year_start + '-' + year_end);
  399. $('#cycle-display .cycle-definition').html(
  400. "Select the semesters which you would like to review an outcome in the three year plan of " +
  401. year_start + '-' + year_end + ".");
  402. //Empty table
  403. //table.clear();
  404. // Add new semesters
  405. //if(typ.length>0)
  406. //{
  407. $('table').show();
  408. $('#cycle1').html((parseInt(year_start)) + "-" + (parseInt(year_start) + 1));
  409. $('#cycle2').html((parseInt(year_start) + 1) + "-" + (parseInt(year_end) - 1));
  410. $('#cycle3').html((parseInt(year_end) - 1) + "-" + (parseInt(year_end)));
  411. $('#cycle_id').val(typ.id);
  412. //resets the checkboxes' name, clears marked, and disables them by default.
  413. $.each(outcomes, function(index, outcome) {
  414. $.each([1, 2, 3, 4, 5, 6], function(index, semester) {
  415. var id = outcome.id + "-sem" + semester;
  416. var new_name = id;
  417. document.getElementById(id).setAttribute("name",
  418. new_name);
  419. $("#" + id).attr("disabled", true);
  420. $("#" + id).prop("checked", false);
  421. });
  422. });
  423. var i = 1;
  424. $.each(outcomes, function(index, outcome) {
  425. $.each(semesters, function(index, semester) {
  426. var id = outcome.id + "-sem" + i;
  427. var new_name = outcome.id + "-sem" + semester.code;
  428. var checkbox = document.getElementById(id);
  429. checkbox.setAttribute("name", new_name);
  430. //enable the check box
  431. $("#" + id).removeAttr("disabled");
  432. //store checkboxes info in an array to later lookup which are marked
  433. var temp = Array(outcome.id, semester.code, program_id,
  434. id, typ.id);
  435. outcome_id_semester_code_program_id_box_id_typ_id.push(
  436. temp);
  437. i++;
  438. });
  439. i = 1;
  440. });
  441. //search which boxes are marked in the data-base
  442. $.post(
  443. "{{ URL::action('ThreeYearPlanController@lookup_typ_semester_outcome') }}", {
  444. info: (outcome_id_semester_code_program_id_box_id_typ_id)
  445. },
  446. function(data) {
  447. $.each(data.box_value, function(index, box_id_value) {
  448. var box_id = box_id_value[0];
  449. var value = box_id_value[1];
  450. if (1 == value) {
  451. $("#" + box_id).prop("checked", true);
  452. }
  453. });
  454. }
  455. );
  456. },
  457. 'json'
  458. );
  459. });
  460. });
  461. // go back to section 1
  462. $('.back-to-1').on('click', function(e) {
  463. window.scrollTo(0, 0);
  464. $(".panel-body").hide();
  465. $("#section1").show();
  466. });
  467. // go back to section 2
  468. $('.back-to-2').on('click', function(e) {
  469. window.scrollTo(0, 0);
  470. $(".panel-body").hide();
  471. $("#section2").show();
  472. });
  473. // go to section 2
  474. $('.go-to-2').on('click', function(e) {
  475. var not_enough = false;
  476. var i = 0;
  477. $('#table-cycles tbody tr').each(function() {
  478. $(this).find('th').each(function() {
  479. if ($(this).find('input').is(':checked')) {
  480. i = i + 1;
  481. }
  482. });
  483. if (i < 2) {
  484. not_enough = true;
  485. }
  486. i = 0;
  487. });
  488. if (not_enough == true) {
  489. alert("Each Learning Outcome must be evaluated in at least 2 semesters.");
  490. return true;
  491. }
  492. $(".panel-body").hide();;
  493. $("#section2").show();;
  494. var typ_id = $('#table-cycles').data('typ-id');
  495. $.post(
  496. "{{ URL::action('ThreeYearPlanController@section2_arrive') }}", {
  497. typ_id: (typ_id),
  498. program_id: {{ $program_id }}
  499. },
  500. function(data) {
  501. $('.objectives-section').empty();
  502. $.each(data, function(index, outcome) {
  503. var outcome_name = outcome.name;
  504. var outcome_id = outcome.id;
  505. $('.objectives-section').append('<hr>');
  506. var area = $('.courses-section-0').clone(true);
  507. area.attr('class', '');
  508. var title = outcome_name;
  509. //var title = 'Learning Outcome: ' + outcome_name;
  510. var title_area = $('.title-course-selection-0').clone(true);
  511. title_area.attr('class', 'title-course-selection h3');
  512. title_area.find('p').html(title);
  513. area.append(title_area);
  514. $.each(outcome.selected_semesters, function(index, semester) {
  515. var semester_name = semester.name;
  516. var semester_id = semester.semester_id;
  517. var select_area = $('.semester-course-selection-0').clone(true);
  518. select_area.attr('class', 'semester-course-selection');
  519. select_area.attr('style', ' ');
  520. select_area.find('.semester-label-course-selection-0').html(
  521. semester_name + "'s Objectives");
  522. var no_option = outcome_id + '-' + semester_id + '-n';
  523. select_area.find('option').val(no_option).html(
  524. 'Select an Objective');
  525. select_area.find('.add-objective-course').html(
  526. '<span class="glyphicon glyphicon-plus"></span> Choose more Objectives'
  527. );
  528. if (semester.available_objectives.length != 0) {
  529. select_area.find('.objective-selector-0 label').hide();
  530. $.each(semester.available_objectives, function(index,
  531. objective) {
  532. var objective_id = objective.id;
  533. var option_value = outcome_id + '-' + semester_id +
  534. '-' + objective_id;
  535. var option_name = objective.text;
  536. var new_option = select_area.find('.default-option')
  537. .clone(true);
  538. new_option.html(option_name);
  539. new_option.val(option_value);
  540. new_option.attr('class', 'select_objective');
  541. select_area.find('select').append(new_option);
  542. });
  543. }
  544. if (semester.available_objectives.length == 0) {
  545. select_area.find('select').prop('disabled', 'disabled');
  546. select_area.find('.objective-selector-0 label').html(
  547. 'There are no Objectives available for this Learning Outcome and Semester combination'
  548. );
  549. select_area.find('.objective-selector-0 select').hide();
  550. select_area.find('button').prop('disabled', 'disabled');
  551. }
  552. $.each(semester.selected_objectives, function(index, objective) {
  553. select_area.find('.objective-selector-0').hide();
  554. //si hay objetivos previamente seleccionados, escribirlos
  555. var objective_id = objective.id;
  556. var option_value = outcome_id + '-' + semester_id +
  557. '-' + objective_id;
  558. var new_select = select_area.find(
  559. '.objective-selector-0').clone(true);
  560. new_select.attr('class', 'objective-selector');
  561. new_select.find('select').val(option_value);
  562. select_area.find('.clone-objective-course-select-0')
  563. .before(new_select);
  564. select_area.find('.objective-selector').show();
  565. objective_selector = select_area.find(
  566. '.objective-selector');
  567. objective_selector.find(".delete-selection-0").show();
  568. });
  569. area.append(select_area);
  570. });
  571. var footer = $('.footer-course-selection-0').clone(true);
  572. footer.attr('class', 'footer-course-selection');
  573. footer.find('p').html(
  574. '<b>Objective selection for this Learning Outcome is currently hidden.</b>'
  575. );
  576. area.append(footer);
  577. area.append('<br>');
  578. area.show(true);
  579. $('.objectives-section').append(area);
  580. });
  581. }
  582. );
  583. });
  584. // hide the options of an outcome in section 2 and 3
  585. $('.hide-course-selection').on('click', function(e) {
  586. $(this).parent().find('.show-course-selection').show();;
  587. $(this).hide();;
  588. $(this).parent().parent().find('.semester-course-selection').hide(333);
  589. $(this).parent().parent().find('.footer-course-selection').show(333);
  590. });
  591. // show the options of an outcome in section 2 and 3
  592. $('.show-course-selection').on('click', function(e) {
  593. $(this).parent().find('.hide-course-selection').show();
  594. $(this).hide();
  595. $(this).parent().parent().find('.semester-course-selection').show(333);
  596. $(this).parent().parent().find('.footer-course-selection').hide(333);
  597. });
  598. // in section 2 and 3, add selects for choosing more objectives and courses, respectively
  599. $('.add-objective-course').on('click', function(e) {
  600. var new_select = $(this).parent().parent().find('.objective-selector-0').clone(true);
  601. new_select.attr('class', 'objective-selector');
  602. new_select.show();
  603. $(this).parent().before(new_select);
  604. });
  605. // go to section 3
  606. $('.go-to-3').on('click', function(e) {
  607. window.scrollTo(0, 0);
  608. $(".panel-body").hide();;
  609. $("#section3").show();;
  610. var typ_id = $('#table-cycles').data('typ-id');
  611. $.post(
  612. "{{ URL::action('ThreeYearPlanController@section3_arrive') }}", {
  613. typ_id: (typ_id),
  614. program_id: {{ $program_id }}
  615. },
  616. function(data) {
  617. $('.courses-section').empty();
  618. $.each(data, function(index, outcome) {
  619. var outcome_name = outcome.name;
  620. var outcome_id = outcome.id;
  621. $('.courses-section').append('<hr>');
  622. var area = $('.courses-section-0').clone(true);
  623. area.attr('class', '');
  624. //var title = 'Outcome: ' + outcome_name;
  625. var title = outcome_name;
  626. var title_area = $('.title-course-selection-0').clone(true);
  627. title_area.attr('class', 'title-course-selection h3');
  628. title_area.find('p').html(title);
  629. area.append(title_area);
  630. $.each(outcome.selected_semesters, function(index, semester) {
  631. var semester_name = semester.name;
  632. var semester_id = semester.semester_id;
  633. var select_area = $('.semester-course-selection-0').clone(true);
  634. select_area.attr('class', 'semester-course-selection');
  635. select_area.attr('style', ' ');
  636. select_area.find('.semester-label-course-selection-0').html(
  637. semester_name);
  638. $.each(semester.selected_objectives, function(index, objective) {
  639. var objective_id = objective.objective_id;
  640. var objective_text = objective.text;
  641. var new_select = select_area.find(
  642. '.select-course-selection-0').clone(true);
  643. new_select.attr('class', 'select-course-selection');
  644. new_select.find('label').html('');
  645. new_select.find('.objective-selector-0').before(
  646. '<p>Objective: <b>' + objective_text +
  647. '</b></p>');
  648. {{-- new_select.find('.objective-selector-0 select').attr('style','width:100%;max-width:25%;'); --}}
  649. $.each(objective.available_courses, function(index,
  650. course) {
  651. var course_id = course.course_id;
  652. var option_value = outcome_id + '-' +
  653. semester_id + '-' + objective_id + '-' +
  654. course_id;
  655. var option_name = '[' + course.code + course
  656. .number + '] ' + course.name;
  657. var new_option = new_select.find(
  658. '.default-option').clone(true);
  659. new_option.html(option_name);
  660. new_option.val(option_value);
  661. new_option.attr('class', 'select_course');
  662. new_select.find('select').append(
  663. new_option);
  664. });
  665. if (objective.available_courses.length == 0) {
  666. new_select.find('.select-course-selection-0')
  667. .hide();
  668. new_select.find('select').prop('disabled',
  669. 'disabled');
  670. new_select.find('select label').html(
  671. ' Objective "' + objective_text +
  672. '" has no courses available for selection');
  673. new_select.find('button').prop('disabled',
  674. 'disabled');
  675. }
  676. $.each(objective.selected_courses, function(index,
  677. course) {
  678. new_select.find('.objective-selector-0')
  679. .hide();
  680. //si hay objetivos previamente seleccionados, escribirlos
  681. var course_id = course.course_id;
  682. var option_value = outcome_id + '-' +
  683. semester_id + '-' + objective_id + '-' +
  684. course_id;
  685. var new_selected_course = new_select.find(
  686. '.objective-selector-0').clone(true);
  687. new_selected_course.attr('class',
  688. 'objective-selector');
  689. new_selected_course.find('select').val(
  690. option_value);
  691. {{-- new_selected_course.find('label').html(''); --}}
  692. new_selected_course.show();
  693. new_select.find(
  694. '.clone-objective-course-select-0')
  695. .before(new_selected_course);
  696. });
  697. select_area.find('.select-course-selection-0').after(
  698. new_select);
  699. });
  700. if (semester.selected_objectives.length != 0) {
  701. select_area.find('.select-course-selection-0').hide();
  702. } else {
  703. select_area.find('select').prop('disabled', 'disabled');
  704. select_area.find('.objective-selector-0').html(
  705. 'There are no objectives selected for this semester');
  706. select_area.find('button').prop('disabled', 'disabled');
  707. }
  708. area.append(select_area);
  709. });
  710. var footer = $('.footer-course-selection-0').clone(true);
  711. footer.attr('class', 'footer-course-selection');
  712. area.append(footer);
  713. area.append('<br>');
  714. area.show(true);
  715. $('.courses-section').append(area);
  716. });
  717. //$('.objective-selector').children('.delete-selection-0').css("margin:5px; display:block;");
  718. }
  719. );
  720. });
  721. // remove an
  722. // remove an
  723. $('.delete-selection-0').on('click', function(e) {
  724. var options_values = $(this).parent().find('select').val().split('-');
  725. //if == 3 then we are in the objective selector
  726. if (options_values.length == 3) {
  727. //get count of all objective-selectors in the same semester, plus objective-selector-0
  728. var count_objective_selectors = $(this).parent().parent().find('.objective-selector').length;
  729. var count_objective_selectors_0 = $(this).parent().parent().find('.objective-selector-0').length;
  730. var count_objective_selectors_total = count_objective_selectors + count_objective_selectors_0;
  731. //view count of all objective-selectors in the same semester, plus objective-selector-0
  732. console.log(count_objective_selectors_total);
  733. //variable that holds value of wether the objective-selector-0 is hidden or not
  734. var objective_selector_0_hidden = $(this).parent().parent().find('.objective-selector-0').is(
  735. ':hidden');
  736. if (count_objective_selectors_total == 1 || (count_objective_selectors_total == 2 &&
  737. objective_selector_0_hidden)) {
  738. //if there is only one objective-selector,throw an alert and do nothing
  739. //html alert with dismiss button in the alert_placeholder div
  740. $('#alert_placeholder').html(
  741. '<div class="alert alert-danger alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button> <strong>Warning!</strong>You must have at least one Objective per Semester </div>'
  742. );
  743. return true;
  744. }
  745. //subtract 1 from count_objective_selectors_total
  746. var typ_id = $('#table-cycles').data('typ-id');
  747. var outcome_id = options_values[0];
  748. var semester_id = options_values[1];
  749. var new_objective_id = "nothing_selected";
  750. var previous_objective_id = options_values[2];
  751. if (previous_objective_id == 'n') {
  752. previous_objective_id = "nothing_selected";
  753. // with the next return, the post shouldnt excecute.
  754. // im leaving the assignment in the line before this one just in case.
  755. //check to see if parent is objective-selector-0
  756. var x = $(this).parent().parent().attr('class');
  757. if ($(this).parent().attr('class') == 'objective-selector-0') {
  758. // if it is then hide it
  759. $(this).parent().hide();
  760. return true;
  761. }
  762. $(this).parent().remove();;
  763. return true;
  764. }
  765. $.post(
  766. "{{ URL::action('ThreeYearPlanController@section2_on_change') }}", {
  767. typ_id: (typ_id),
  768. previous_objective_id: (previous_objective_id),
  769. outcome_id: (outcome_id),
  770. semester_id: (semester_id),
  771. new_objective_id: (new_objective_id),
  772. program_id: {{ $program_id }},
  773. },
  774. function(data) {
  775. //
  776. }
  777. );
  778. }
  779. //if == 4 then we are in the course selector
  780. else if (options_values.length == 4 || options_values == "nothing_selected") {
  781. //get count of all objective-selectors in the same semester, plus objective-selector-0
  782. var count_objective_selectors = $(this).parent().parent().find('.objective-selector').length;
  783. var count_objective_selectors_0 = $(this).parent().parent().find('.objective-selector-0').length;
  784. var count_objective_selectors_total = count_objective_selectors + count_objective_selectors_0;
  785. //view count of all objective-selectors in the same semester, plus objective-selector-0
  786. console.log(count_objective_selectors_total);
  787. //variable that holds value of wether the objective-selector-0 is hidden or not
  788. var objective_selector_0_hidden = $(this).parent().parent().find('.objective-selector-0').is(
  789. ':hidden');
  790. if (count_objective_selectors_total == 1 || (count_objective_selectors_total == 2 &&
  791. objective_selector_0_hidden)) {
  792. //if there is only one objective-selector,throw an alert and do nothing
  793. //html alert with dismiss button in the alert-placeholder div
  794. $('#alert_placeholder').html(
  795. '<div class="alert alert-danger alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button> <strong>Warning!</strong>You must have at least one Course </div>'
  796. );
  797. return true;
  798. }
  799. //subtract 1 from count_objective_selectors_total
  800. var typ_id = $('#table-cycles').data('typ-id');
  801. var outcome_id = options_values[0];
  802. var semester_id = options_values[1];
  803. var objective_id = options_values[2];
  804. var previous_course_id = options_values[3];
  805. var new_course_id = 'nothing_selected';
  806. $.post(
  807. "{{ URL::action('ThreeYearPlanController@section3_on_change') }}", {
  808. typ_id: (typ_id),
  809. previous_course_id: (previous_course_id),
  810. outcome_id: (outcome_id),
  811. semester_id: (semester_id),
  812. objective_id: (objective_id),
  813. new_course_id: (new_course_id)
  814. },
  815. function(data) {
  816. //
  817. }
  818. );
  819. }
  820. var x = $(this).parent().attr('class');
  821. if ($(this).parent().attr('class') == 'objective-selector-0') {
  822. // if it is then hide it
  823. $(this).parent().parent().hide();
  824. return;
  825. }
  826. //remove the select
  827. $(this).parent().remove();;
  828. });
  829. </script>
  830. @stop
  831. @section('included-js')
  832. @include('global._datatables_js')
  833. @stop
  834. @stop