No Description

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

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