No Description

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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997
  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. typ_id =$('#table-cycles').data('typ-id');
  354. $.post(
  355. "{{ URL::action('ThreeYearPlanController@createAnnualPlan', [$program_id]) }}", {
  356. typ_id: typ_id
  357. },
  358. function() {
  359. window.open("{{ URL::action('ThreeYearPlanController@printPlan', [$program_id]) }}"+"/"+typ_id+"/1", '_blank');
  360. window.location.href = "{{ URL::action('AnnualPlansController@showPlan', [$program_id]) }}";
  361. });
  362. });
  363. // When list item is clicked, load corresponding info
  364. //section 1
  365. $('.list-group-item').on('click', function() {
  366. $('#three_year_button').hide();
  367. var id = $(this).data('cycle-id');
  368. $('#table-cycles').data('typ-id', id);
  369. $('#view_button').show();
  370. $('#view_button').attr("href",
  371. "{{ URL::action('ThreeYearPlanController@viewPlan', [$program_id]) }}" +
  372. '/' + $(this).data('cycle-id'));
  373. $('#print_button').show();
  374. $('#print_button').attr("href",
  375. "{{ URL::action('ThreeYearPlanController@printPlan', [$program_id]) }}" +
  376. '/' + $(this).data('cycle-id'));
  377. $('#section1').show();
  378. $('#section2').hide();
  379. $('#section3').hide();
  380. var outcome_id_semester_code_program_id_box_id_typ_id = new Object();
  381. var outcome_id_semester_code_program_id_box_id_typ_id = Array();
  382. $.post(
  383. "{{ URL::action('ThreeYearPlanController@fetchThreeYears') }}", {
  384. id: id
  385. },
  386. function(json) {
  387. // Retrieve datatable instance
  388. var table = $('#table-cycles');
  389. var typ = json.typ;
  390. var year_start = json.typ.year_start;
  391. var year_end = json.typ.year_end;
  392. var semesters = json.typ.semesters;
  393. var program_id = {{ $program_id }};
  394. // var outcomes = already defined
  395. $('#cycle-display').parent().show();
  396. $('.no-cycle').parent().hide();
  397. //Display title and definition
  398. $('#cycle-display .panel-title').html('Planning for the years of ' +
  399. year_start + '-' + year_end);
  400. $('#cycle-display .cycle-definition').html(
  401. "Select the semesters which you would like to review an outcome in the three year plan of " +
  402. year_start + '-' + year_end + ".");
  403. //Empty table
  404. //table.clear();
  405. // Add new semesters
  406. //if(typ.length>0)
  407. //{
  408. $('table').show();
  409. $('#cycle1').html((parseInt(year_start)) + "-" + (parseInt(year_start) + 1));
  410. $('#cycle2').html((parseInt(year_start) + 1) + "-" + (parseInt(year_end) - 1));
  411. $('#cycle3').html((parseInt(year_end) - 1) + "-" + (parseInt(year_end)));
  412. $('#cycle_id').val(typ.id);
  413. //resets the checkboxes' name, clears marked, and disables them by default.
  414. $.each(outcomes, function(index, outcome) {
  415. $.each([1, 2, 3, 4, 5, 6], function(index, semester) {
  416. var id = outcome.id + "-sem" + semester;
  417. var new_name = id;
  418. document.getElementById(id).setAttribute("name",
  419. new_name);
  420. $("#" + id).attr("disabled", true);
  421. $("#" + id).prop("checked", false);
  422. });
  423. });
  424. var i = 1;
  425. $.each(outcomes, function(index, outcome) {
  426. $.each(semesters, function(index, semester) {
  427. var id = outcome.id + "-sem" + i;
  428. var new_name = outcome.id + "-sem" + semester.code;
  429. var checkbox = document.getElementById(id);
  430. checkbox.setAttribute("name", new_name);
  431. //enable the check box
  432. $("#" + id).removeAttr("disabled");
  433. //store checkboxes info in an array to later lookup which are marked
  434. var temp = Array(outcome.id, semester.code, program_id,
  435. id, typ.id);
  436. outcome_id_semester_code_program_id_box_id_typ_id.push(
  437. temp);
  438. i++;
  439. });
  440. i = 1;
  441. });
  442. //search which boxes are marked in the data-base
  443. $.post(
  444. "{{ URL::action('ThreeYearPlanController@lookup_typ_semester_outcome') }}", {
  445. info: (outcome_id_semester_code_program_id_box_id_typ_id)
  446. },
  447. function(data) {
  448. $.each(data.box_value, function(index, box_id_value) {
  449. var box_id = box_id_value[0];
  450. var value = box_id_value[1];
  451. if (1 == value) {
  452. $("#" + box_id).prop("checked", true);
  453. }
  454. });
  455. }
  456. );
  457. },
  458. 'json'
  459. );
  460. });
  461. });
  462. // go back to section 1
  463. $('.back-to-1').on('click', function(e) {
  464. window.scrollTo(0, 0);
  465. $(".panel-body").hide();
  466. $("#section1").show();
  467. });
  468. // go back to section 2
  469. $('.back-to-2').on('click', function(e) {
  470. window.scrollTo(0, 0);
  471. $(".panel-body").hide();
  472. $("#section2").show();
  473. });
  474. // go to section 2
  475. $('.go-to-2').on('click', function(e) {
  476. var not_enough = false;
  477. var i = 0;
  478. $('#table-cycles tbody tr').each(function() {
  479. $(this).find('th').each(function() {
  480. if ($(this).find('input').is(':checked')) {
  481. i = i + 1;
  482. }
  483. });
  484. if (i < 2) {
  485. not_enough = true;
  486. }
  487. i = 0;
  488. });
  489. if (not_enough == true) {
  490. alert("Each Learning Outcome must be evaluated in at least 2 semesters.");
  491. return true;
  492. }
  493. $(".panel-body").hide();;
  494. $("#section2").show();;
  495. var typ_id = $('#table-cycles').data('typ-id');
  496. $.post(
  497. "{{ URL::action('ThreeYearPlanController@section2_arrive') }}", {
  498. typ_id: (typ_id),
  499. program_id: {{ $program_id }}
  500. },
  501. function(data) {
  502. $('.objectives-section').empty();
  503. $.each(data, function(index, outcome) {
  504. var outcome_name = outcome.name;
  505. var outcome_id = outcome.id;
  506. $('.objectives-section').append('<hr>');
  507. var area = $('.courses-section-0').clone(true);
  508. area.attr('class', '');
  509. var title = outcome_name;
  510. //var title = 'Learning Outcome: ' + outcome_name;
  511. var title_area = $('.title-course-selection-0').clone(true);
  512. title_area.attr('class', 'title-course-selection h3');
  513. title_area.find('p').html(title);
  514. area.append(title_area);
  515. $.each(outcome.selected_semesters, function(index, semester) {
  516. var semester_name = semester.name;
  517. var semester_id = semester.semester_id;
  518. var select_area = $('.semester-course-selection-0').clone(true);
  519. select_area.attr('class', 'semester-course-selection');
  520. select_area.attr('style', ' ');
  521. select_area.find('.semester-label-course-selection-0').html(
  522. semester_name + "'s Objectives");
  523. var no_option = outcome_id + '-' + semester_id + '-n';
  524. select_area.find('option').val(no_option).html(
  525. 'Select an Objective');
  526. select_area.find('.add-objective-course').html(
  527. '<span class="glyphicon glyphicon-plus"></span> Choose more Objectives'
  528. );
  529. if (semester.available_objectives.length != 0) {
  530. select_area.find('.objective-selector-0 label').hide();
  531. $.each(semester.available_objectives, function(index,
  532. objective) {
  533. var objective_id = objective.id;
  534. var option_value = outcome_id + '-' + semester_id +
  535. '-' + objective_id;
  536. var option_name = objective.text;
  537. var new_option = select_area.find('.default-option')
  538. .clone(true);
  539. new_option.html(option_name);
  540. new_option.val(option_value);
  541. new_option.attr('class', 'select_objective');
  542. select_area.find('select').append(new_option);
  543. });
  544. }
  545. if (semester.available_objectives.length == 0) {
  546. select_area.find('select').prop('disabled', 'disabled');
  547. select_area.find('.objective-selector-0 label').html(
  548. 'There are no Objectives available for this Learning Outcome and Semester combination'
  549. );
  550. select_area.find('.objective-selector-0 select').hide();
  551. select_area.find('button').prop('disabled', 'disabled');
  552. }
  553. $.each(semester.selected_objectives, function(index, objective) {
  554. select_area.find('.objective-selector-0').hide();
  555. //si hay objetivos previamente seleccionados, escribirlos
  556. var objective_id = objective.id;
  557. var option_value = outcome_id + '-' + semester_id +
  558. '-' + objective_id;
  559. var new_select = select_area.find(
  560. '.objective-selector-0').clone(true);
  561. new_select.attr('class', 'objective-selector');
  562. new_select.find('select').val(option_value);
  563. select_area.find('.clone-objective-course-select-0')
  564. .before(new_select);
  565. select_area.find('.objective-selector').show();
  566. objective_selector = select_area.find(
  567. '.objective-selector');
  568. objective_selector.find(".delete-selection-0").show();
  569. });
  570. area.append(select_area);
  571. });
  572. var footer = $('.footer-course-selection-0').clone(true);
  573. footer.attr('class', 'footer-course-selection');
  574. footer.find('p').html(
  575. '<b>Objective selection for this Learning Outcome is currently hidden.</b>'
  576. );
  577. area.append(footer);
  578. area.append('<br>');
  579. area.show(true);
  580. $('.objectives-section').append(area);
  581. });
  582. }
  583. );
  584. });
  585. // hide the options of an outcome in section 2 and 3
  586. $('.hide-course-selection').on('click', function(e) {
  587. $(this).parent().find('.show-course-selection').show();;
  588. $(this).hide();;
  589. $(this).parent().parent().find('.semester-course-selection').hide(333);
  590. $(this).parent().parent().find('.footer-course-selection').show(333);
  591. });
  592. // show the options of an outcome in section 2 and 3
  593. $('.show-course-selection').on('click', function(e) {
  594. $(this).parent().find('.hide-course-selection').show();
  595. $(this).hide();
  596. $(this).parent().parent().find('.semester-course-selection').show(333);
  597. $(this).parent().parent().find('.footer-course-selection').hide(333);
  598. });
  599. // in section 2 and 3, add selects for choosing more objectives and courses, respectively
  600. $('.add-objective-course').on('click', function(e) {
  601. var new_select = $(this).parent().parent().find('.objective-selector-0').clone(true);
  602. new_select.attr('class', 'objective-selector');
  603. new_select.show();
  604. $(this).parent().before(new_select);
  605. });
  606. // go to section 3
  607. $('.go-to-3').on('click', function(e) {
  608. window.scrollTo(0, 0);
  609. $(".panel-body").hide();;
  610. $("#section3").show();;
  611. var typ_id = $('#table-cycles').data('typ-id');
  612. $.post(
  613. "{{ URL::action('ThreeYearPlanController@section3_arrive') }}", {
  614. typ_id: (typ_id),
  615. program_id: {{ $program_id }}
  616. },
  617. function(data) {
  618. $('.courses-section').empty();
  619. $.each(data, function(index, outcome) {
  620. var outcome_name = outcome.name;
  621. var outcome_id = outcome.id;
  622. $('.courses-section').append('<hr>');
  623. var area = $('.courses-section-0').clone(true);
  624. area.attr('class', '');
  625. //var title = 'Outcome: ' + outcome_name;
  626. var title = outcome_name;
  627. var title_area = $('.title-course-selection-0').clone(true);
  628. title_area.attr('class', 'title-course-selection h3');
  629. title_area.find('p').html(title);
  630. area.append(title_area);
  631. $.each(outcome.selected_semesters, function(index, semester) {
  632. var semester_name = semester.name;
  633. var semester_id = semester.semester_id;
  634. var select_area = $('.semester-course-selection-0').clone(true);
  635. select_area.attr('class', 'semester-course-selection');
  636. select_area.attr('style', ' ');
  637. select_area.find('.semester-label-course-selection-0').html(
  638. semester_name);
  639. $.each(semester.selected_objectives, function(index, objective) {
  640. var objective_id = objective.objective_id;
  641. var objective_text = objective.text;
  642. var new_select = select_area.find(
  643. '.select-course-selection-0').clone(true);
  644. new_select.attr('class', 'select-course-selection');
  645. new_select.find('label').html('');
  646. new_select.find('.objective-selector-0').before(
  647. '<p>Objective: <b>' + objective_text +
  648. '</b></p>');
  649. {{-- new_select.find('.objective-selector-0 select').attr('style','width:100%;max-width:25%;'); --}}
  650. $.each(objective.available_courses, function(index,
  651. course) {
  652. var course_id = course.course_id;
  653. var option_value = outcome_id + '-' +
  654. semester_id + '-' + objective_id + '-' +
  655. course_id;
  656. var option_name = '[' + course.code + course
  657. .number + '] ' + course.name;
  658. var new_option = new_select.find(
  659. '.default-option').clone(true);
  660. new_option.html(option_name);
  661. new_option.val(option_value);
  662. new_option.attr('class', 'select_course');
  663. new_select.find('select').append(
  664. new_option);
  665. });
  666. if (objective.available_courses.length == 0) {
  667. new_select.find('.select-course-selection-0')
  668. .hide();
  669. new_select.find('select').prop('disabled',
  670. 'disabled');
  671. new_select.find('select label').html(
  672. ' Objective "' + objective_text +
  673. '" has no courses available for selection');
  674. new_select.find('button').prop('disabled',
  675. 'disabled');
  676. }
  677. $.each(objective.selected_courses, function(index,
  678. course) {
  679. new_select.find('.objective-selector-0')
  680. .hide();
  681. //si hay objetivos previamente seleccionados, escribirlos
  682. var course_id = course.course_id;
  683. var option_value = outcome_id + '-' +
  684. semester_id + '-' + objective_id + '-' +
  685. course_id;
  686. var new_selected_course = new_select.find(
  687. '.objective-selector-0').clone(true);
  688. new_selected_course.attr('class',
  689. 'objective-selector');
  690. new_selected_course.find('select').val(
  691. option_value);
  692. {{-- new_selected_course.find('label').html(''); --}}
  693. new_selected_course.show();
  694. new_select.find(
  695. '.clone-objective-course-select-0')
  696. .before(new_selected_course);
  697. });
  698. select_area.find('.select-course-selection-0').after(
  699. new_select);
  700. });
  701. if (semester.selected_objectives.length != 0) {
  702. select_area.find('.select-course-selection-0').hide();
  703. } else {
  704. select_area.find('select').prop('disabled', 'disabled');
  705. select_area.find('.objective-selector-0').html(
  706. 'There are no objectives selected for this semester');
  707. select_area.find('button').prop('disabled', 'disabled');
  708. }
  709. area.append(select_area);
  710. });
  711. var footer = $('.footer-course-selection-0').clone(true);
  712. footer.attr('class', 'footer-course-selection');
  713. area.append(footer);
  714. area.append('<br>');
  715. area.show(true);
  716. $('.courses-section').append(area);
  717. });
  718. //$('.objective-selector').children('.delete-selection-0').css("margin:5px; display:block;");
  719. }
  720. );
  721. });
  722. // remove an
  723. // remove an
  724. $('.delete-selection-0').on('click', function(e) {
  725. var options_values = $(this).parent().find('select').val().split('-');
  726. //if == 3 then we are in the objective selector
  727. if (options_values.length == 3) {
  728. //get count of all objective-selectors in the same semester, plus objective-selector-0
  729. var count_objective_selectors = $(this).parent().parent().find('.objective-selector').length;
  730. var count_objective_selectors_0 = $(this).parent().parent().find('.objective-selector-0').length;
  731. var count_objective_selectors_total = count_objective_selectors + count_objective_selectors_0;
  732. //view count of all objective-selectors in the same semester, plus objective-selector-0
  733. console.log(count_objective_selectors_total);
  734. //variable that holds value of wether the objective-selector-0 is hidden or not
  735. var objective_selector_0_hidden = $(this).parent().parent().find('.objective-selector-0').is(
  736. ':hidden');
  737. if (count_objective_selectors_total == 1 || (count_objective_selectors_total == 2 &&
  738. objective_selector_0_hidden)) {
  739. //if there is only one objective-selector,throw an alert and do nothing
  740. //html alert with dismiss button in the alert_placeholder div
  741. $('#alert_placeholder').html(
  742. '<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>'
  743. );
  744. return true;
  745. }
  746. //subtract 1 from count_objective_selectors_total
  747. var typ_id = $('#table-cycles').data('typ-id');
  748. var outcome_id = options_values[0];
  749. var semester_id = options_values[1];
  750. var new_objective_id = "nothing_selected";
  751. var previous_objective_id = options_values[2];
  752. if (previous_objective_id == 'n') {
  753. previous_objective_id = "nothing_selected";
  754. // with the next return, the post shouldnt excecute.
  755. // im leaving the assignment in the line before this one just in case.
  756. //check to see if parent is objective-selector-0
  757. var x = $(this).parent().parent().attr('class');
  758. if ($(this).parent().attr('class') == 'objective-selector-0') {
  759. // if it is then hide it
  760. $(this).parent().hide();
  761. return true;
  762. }
  763. $(this).parent().remove();;
  764. return true;
  765. }
  766. $.post(
  767. "{{ URL::action('ThreeYearPlanController@section2_on_change') }}", {
  768. typ_id: (typ_id),
  769. previous_objective_id: (previous_objective_id),
  770. outcome_id: (outcome_id),
  771. semester_id: (semester_id),
  772. new_objective_id: (new_objective_id),
  773. program_id: {{ $program_id }},
  774. },
  775. function(data) {
  776. //
  777. }
  778. );
  779. }
  780. //if == 4 then we are in the course selector
  781. else if (options_values.length == 4 || options_values == "nothing_selected") {
  782. //get count of all objective-selectors in the same semester, plus objective-selector-0
  783. var count_objective_selectors = $(this).parent().parent().find('.objective-selector').length;
  784. var count_objective_selectors_0 = $(this).parent().parent().find('.objective-selector-0').length;
  785. var count_objective_selectors_total = count_objective_selectors + count_objective_selectors_0;
  786. //view count of all objective-selectors in the same semester, plus objective-selector-0
  787. console.log(count_objective_selectors_total);
  788. //variable that holds value of wether the objective-selector-0 is hidden or not
  789. var objective_selector_0_hidden = $(this).parent().parent().find('.objective-selector-0').is(
  790. ':hidden');
  791. if (count_objective_selectors_total == 1 || (count_objective_selectors_total == 2 &&
  792. objective_selector_0_hidden)) {
  793. //if there is only one objective-selector,throw an alert and do nothing
  794. //html alert with dismiss button in the alert-placeholder div
  795. $('#alert_placeholder').html(
  796. '<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>'
  797. );
  798. return true;
  799. }
  800. //subtract 1 from count_objective_selectors_total
  801. var typ_id = $('#table-cycles').data('typ-id');
  802. var outcome_id = options_values[0];
  803. var semester_id = options_values[1];
  804. var objective_id = options_values[2];
  805. var previous_course_id = options_values[3];
  806. var new_course_id = 'nothing_selected';
  807. $.post(
  808. "{{ URL::action('ThreeYearPlanController@section3_on_change') }}", {
  809. typ_id: (typ_id),
  810. previous_course_id: (previous_course_id),
  811. outcome_id: (outcome_id),
  812. semester_id: (semester_id),
  813. objective_id: (objective_id),
  814. new_course_id: (new_course_id)
  815. },
  816. function(data) {
  817. //
  818. }
  819. );
  820. }
  821. var x = $(this).parent().attr('class');
  822. if ($(this).parent().attr('class') == 'objective-selector-0') {
  823. // if it is then hide it
  824. $(this).parent().parent().hide();
  825. return;
  826. }
  827. //remove the select
  828. $(this).parent().remove();;
  829. });
  830. </script>
  831. @stop
  832. @section('included-js')
  833. @include('global._datatables_js')
  834. @stop
  835. @stop