Brak opisu

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

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