Bez popisu

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

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