설명 없음

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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803
  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. // When list item is clicked, load corresponding info
  302. //section 1
  303. $('.list-group-item').on('click', function()
  304. {
  305. var id = $(this).data('cycle-id');
  306. $('#table-cycles').data('typ-id',id);
  307. $('#section1').show();
  308. $('#section2').hide();
  309. $('#section3').hide();
  310. var outcome_id_semester_code_program_id_box_id_typ_id = new Object();
  311. var outcome_id_semester_code_program_id_box_id_typ_id = Array();
  312. $.post(
  313. "{{ URL::action('ThreeYearPlanController@fetchThreeYears') }}",
  314. { id: id },
  315. function(json)
  316. {
  317. // Retrieve datatable instance
  318. var table = $('#table-cycles');
  319. var typ = json.typ;
  320. var year_start = json.typ.year_start;
  321. var year_end = json.typ.year_end;
  322. var semesters = json.typ.semesters;
  323. var program_id = {{$program_id}};
  324. // var outcomes = already defined
  325. $('#cycle-display').parent().show();
  326. $('.no-cycle').parent().hide();
  327. //Display title and definition
  328. $('#cycle-display .panel-title').html('Planning for the years of ' + year_start + '-' + year_end);
  329. $('#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+".");
  330. //Empty table
  331. //table.clear();
  332. // Add new semesters
  333. //if(typ.length>0)
  334. //{
  335. $('table').show();
  336. $('#cycle1').html((year_start)+"-"+(year_start+1));
  337. $('#cycle2').html((year_start+1)+"-"+(year_end-1));
  338. $('#cycle3').html((year_end-1)+"-"+(year_end));
  339. $('#cycle_id').val(typ.id);
  340. //resets the checkboxes' name, clears marked, and disables them by default.
  341. $.each(outcomes, function(index, outcome)
  342. {
  343. $.each([1,2,3,4,5,6], function(index, semester)
  344. {
  345. var id = outcome.id+"-sem"+semester;
  346. var new_name = id;
  347. document.getElementById(id).setAttribute("name", new_name);
  348. $("#"+id).attr("disabled", true);
  349. $("#"+id).prop("checked", false);
  350. });
  351. });
  352. var i = 1;
  353. $.each(outcomes, function(index, outcome)
  354. {
  355. $.each(semesters, function(index, semester)
  356. {
  357. var id = outcome.id+"-sem"+i;
  358. var new_name = outcome.id+"-sem"+semester.code;
  359. var checkbox = document.getElementById(id);
  360. checkbox.setAttribute("name", new_name);
  361. //enable the check box
  362. $("#"+id).removeAttr("disabled");
  363. //store checkboxes info in an array to later lookup which are marked
  364. var temp = Array(outcome.id,semester.code,program_id, id, typ.id);
  365. outcome_id_semester_code_program_id_box_id_typ_id.push(temp);
  366. i++;
  367. });
  368. i = 1;
  369. });
  370. //search which boxes are marked in the data-base
  371. $.post(
  372. "{{ URL::action('ThreeYearPlanController@lookup_typ_semester_outcome' ) }}",
  373. {
  374. info : (outcome_id_semester_code_program_id_box_id_typ_id)
  375. },
  376. function(data)
  377. {
  378. $.each(data.box_value, function(index, box_id_value)
  379. {
  380. var box_id = box_id_value[0];
  381. var value = box_id_value[1];
  382. if (1 == value) {
  383. $("#"+box_id).prop("checked", true);
  384. }
  385. });
  386. }
  387. );
  388. },
  389. 'json'
  390. );
  391. });
  392. });
  393. // go back to section 1
  394. $('.back-to-1').on('click', function(e)
  395. {
  396. window.scrollTo(0, 0);
  397. $(".panel-body").hide();
  398. $("#section1").show();
  399. });
  400. // go back to section 2
  401. $('.back-to-2').on('click', function(e)
  402. {
  403. window.scrollTo(0, 0);
  404. $(".panel-body").hide();
  405. $("#section2").show();
  406. });
  407. // go to section 2
  408. $('.go-to-2').on('click', function(e)
  409. {
  410. var not_enough = false;
  411. var i = 0;
  412. $('#table-cycles tbody tr').each(function() {
  413. $(this).find('th').each(function() {
  414. if ($(this).find('input').is(':checked')){
  415. i = i + 1;
  416. }
  417. });
  418. if (i < 2){
  419. not_enough = true;
  420. }
  421. i = 0;
  422. });
  423. if (not_enough == true){
  424. alert("Each Outcome must be evaluated in at least 2 semesters.");
  425. return true;
  426. }
  427. $(".panel-body").hide();;
  428. $("#section2").show();;
  429. var typ_id = $('#table-cycles').data('typ-id');
  430. $.post(
  431. "{{ URL::action('ThreeYearPlanController@section2_arrive') }}",
  432. {
  433. typ_id: (typ_id)
  434. },
  435. function(data)
  436. {
  437. $('.objectives-section').empty();
  438. $.each(data, function(index, outcome)
  439. {
  440. var outcome_name = outcome.name;
  441. var outcome_id = outcome.id;
  442. $('.objectives-section').append('<hr>');
  443. var area = $('.courses-section-0').clone(true);
  444. area.attr('class','');
  445. var title = 'Outcome: ' + outcome_name;
  446. var title_area = $('.title-course-selection-0').clone(true);
  447. title_area.attr('class','title-course-selection h3');
  448. title_area.find('p').html(title);
  449. area.append(title_area);
  450. $.each(outcome.selected_semesters, function(index, semester)
  451. {
  452. var semester_name = semester.name;
  453. var semester_id = semester.semester_id;
  454. var select_area = $('.semester-course-selection-0').clone(true);
  455. select_area.attr('class','semester-course-selection');
  456. select_area.attr('style',' ');
  457. select_area.find('.semester-label-course-selection-0').html(semester_name+"'s Objectives");
  458. var no_option = outcome_id+'-'+semester_id+'-n';
  459. select_area.find('option').val(no_option).html('Select an Objective');
  460. select_area.find('.add-objective-course').html('<span class="glyphicon glyphicon-plus"></span> Choose more Objectives');
  461. if (semester.available_objectives.length != 0){
  462. select_area.find('.objective-selector-0 label').hide();
  463. $.each(semester.available_objectives, function(index, objective)
  464. {
  465. var objective_id = objective.id;
  466. var option_value = outcome_id+'-'+semester_id+'-'+objective_id;
  467. var option_name = objective.text;
  468. var new_option = select_area.find('.default-option').clone(true);
  469. new_option.html(option_name);
  470. new_option.val(option_value);
  471. new_option.attr('class','select_objective');
  472. select_area.find('select').append(new_option);
  473. });
  474. }
  475. if (semester.available_objectives.length == 0){
  476. select_area.find('select').prop('disabled', 'disabled');
  477. select_area.find('.objective-selector-0 label').html('There are no Objectives available for this Outcome and Semester combination');
  478. select_area.find('.objective-selector-0 select').hide();
  479. select_area.find('button').prop('disabled', 'disabled');
  480. }
  481. $.each(semester.selected_objectives, function(index, objective)
  482. {
  483. select_area.find('.objective-selector-0').hide();
  484. //si hay objetivos previamente seleccionados, escribirlos
  485. var objective_id = objective.id;
  486. var option_value = outcome_id+'-'+semester_id+'-'+objective_id;
  487. var new_select = select_area.find('.objective-selector-0').clone(true);
  488. new_select.attr('class','objective-selector');
  489. new_select.find('select').val(option_value);
  490. select_area.find('.clone-objective-course-select-0').before(new_select);
  491. select_area.find('.objective-selector').show();
  492. });
  493. area.append(select_area);
  494. });
  495. var footer = $('.footer-course-selection-0').clone(true);
  496. footer.attr('class','footer-course-selection');
  497. footer.find('p').html('<b>Objective selection for this Outcome is currently hidden.</b>');
  498. area.append(footer);
  499. area.append('<br>');
  500. area.show(true);
  501. $('.objectives-section').append(area);
  502. });
  503. }
  504. );
  505. });
  506. // hide the options of an outcome in section 2 and 3
  507. $('.hide-course-selection').on('click', function(e)
  508. {
  509. $(this).parent().find('.show-course-selection').show();;
  510. $(this).hide();;
  511. $(this).parent().parent().find('.semester-course-selection').hide(333);
  512. $(this).parent().parent().find('.footer-course-selection').show(333);
  513. });
  514. // show the options of an outcome in section 2 and 3
  515. $('.show-course-selection').on('click', function(e)
  516. {
  517. $(this).parent().find('.hide-course-selection').show();
  518. $(this).hide();
  519. $(this).parent().parent().find('.semester-course-selection').show(333);
  520. $(this).parent().parent().find('.footer-course-selection').hide(333);
  521. });
  522. // in section 2 and 3, add selects for choosing more objectives and courses, respectively
  523. $('.add-objective-course').on('click', function(e)
  524. {
  525. var new_select = $(this).parent().parent().find('.objective-selector-0').clone(true);
  526. new_select.attr('class','objective-selector');
  527. new_select.show();
  528. $(this).parent().before(new_select);
  529. });
  530. // go to section 3
  531. $('.go-to-3').on('click', function(e)
  532. {
  533. window.scrollTo(0, 0);
  534. $(".panel-body").hide();;
  535. $("#section3").show();;
  536. var typ_id = $('#table-cycles').data('typ-id');
  537. $.post(
  538. "{{ URL::action('ThreeYearPlanController@section3_arrive') }}",
  539. {
  540. typ_id: (typ_id)
  541. },
  542. function(data)
  543. {
  544. $('.courses-section').empty();
  545. $.each(data, function(index, outcome)
  546. {
  547. var outcome_name = outcome.name;
  548. var outcome_id = outcome.id;
  549. $('.courses-section').append('<hr>');
  550. var area = $('.courses-section-0').clone(true);
  551. area.attr('class','');
  552. var title = 'Outcome: ' + outcome_name;
  553. var title_area = $('.title-course-selection-0').clone(true);
  554. title_area.attr('class','title-course-selection h3');
  555. title_area.find('p').html(title);
  556. area.append(title_area);
  557. $.each(outcome.selected_semesters, function(index, semester)
  558. {
  559. var semester_name = semester.name;
  560. var semester_id = semester.semester_id;
  561. var select_area = $('.semester-course-selection-0').clone(true);
  562. select_area.attr('class','semester-course-selection');
  563. select_area.attr('style',' ');
  564. select_area.find('.semester-label-course-selection-0').html(semester_name);
  565. $.each(semester.selected_objectives, function(index, objective)
  566. {
  567. var objective_id = objective.objective_id;
  568. var objective_text = objective.text;
  569. var new_select = select_area.find('.select-course-selection-0').clone(true);
  570. new_select.attr('class','select-course-selection');
  571. new_select.find('label').html('');
  572. new_select.find('.objective-selector-0').before('<p>Objective: <b>'+objective_text+'</b></p>');
  573. {{-- new_select.find('.objective-selector-0 select').attr('style','width:100%;max-width:25%;'); --}}
  574. $.each(objective.available_courses, function(index, course)
  575. {
  576. var course_id = course.course_id;
  577. var option_value = outcome_id+'-'+semester_id+'-'+objective_id+'-'+course_id;
  578. var option_name = '['+course.code+'] '+course.name;
  579. var new_option = new_select.find('.default-option').clone(true);
  580. new_option.html(option_name);
  581. new_option.val(option_value);
  582. new_option.attr('class','select_course');
  583. new_select.find('select').append(new_option);
  584. });
  585. if (objective.available_courses.length == 0){
  586. new_select.find('.select-course-selection-0').hide();
  587. new_select.find('select').prop('disabled', 'disabled');
  588. new_select.find('select label').html(' Objective "'+objective_text+'" has no courses available for selection');
  589. new_select.find('button').prop('disabled', 'disabled');
  590. }
  591. $.each(objective.selected_courses, function(index, course)
  592. {
  593. new_select.find('.objective-selector-0').hide();
  594. //si hay objetivos previamente seleccionados, escribirlos
  595. var course_id = course.course_id;
  596. var option_value = outcome_id+'-'+semester_id+'-'+objective_id+'-'+course_id;
  597. var new_selected_course = new_select.find('.objective-selector-0').clone(true);
  598. new_selected_course.attr('class','objective-selector');
  599. new_selected_course.find('select').val(option_value);
  600. {{-- new_selected_course.find('label').html(''); --}}
  601. new_selected_course.show();
  602. new_select.find('.clone-objective-course-select-0').before(new_selected_course);
  603. });
  604. select_area.find('.select-course-selection-0').after(new_select);
  605. });
  606. if (semester.selected_objectives.length != 0){
  607. select_area.find('.select-course-selection-0').hide();
  608. }
  609. else{
  610. select_area.find('select').prop('disabled', 'disabled');
  611. select_area.find('.objective-selector-0').html('There are no objectives selected for this semester');
  612. select_area.find('button').prop('disabled', 'disabled');
  613. }
  614. area.append(select_area);
  615. });
  616. var footer = $('.footer-course-selection-0').clone(true);
  617. footer.attr('class','footer-course-selection');
  618. area.append(footer);
  619. area.append('<br>');
  620. area.show(true);
  621. $('.courses-section').append(area);
  622. });
  623. }
  624. );
  625. });
  626. // remove an
  627. $('.delete-selection-0').on('click', function(e)
  628. {
  629. var options_values = $(this).parent().find('select').val().split('-');
  630. if (options_values.length == 3){
  631. var typ_id = $('#table-cycles').data('typ-id');
  632. var outcome_id = options_values[0];
  633. var semester_id = options_values[1];
  634. var new_objective_id = "nothing_selected";
  635. var previous_objective_id = options_values[2];
  636. if (previous_objective_id == 'n'){
  637. previous_objective_id = "nothing_selected";
  638. // with the next return, the post shouldnt excecute.
  639. // im leaving the assignment in the line before this one just in case.
  640. $(this).parent().hide();;
  641. return true;
  642. }
  643. $.post(
  644. "{{ URL::action('ThreeYearPlanController@section2_on_change') }}",
  645. {
  646. typ_id: (typ_id),
  647. previous_objective_id: (previous_objective_id),
  648. outcome_id: (outcome_id),
  649. semester_id: (semester_id),
  650. new_objective_id: (new_objective_id)
  651. },
  652. function(data)
  653. {
  654. //
  655. }
  656. );
  657. }
  658. else if (options_values.length == 4){
  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 objective_id = options_values[2];
  663. var previous_course_id = options_values[3];
  664. var new_course_id = 'nothing_selected';
  665. $.post(
  666. "{{ URL::action('ThreeYearPlanController@section3_on_change') }}",
  667. {
  668. typ_id: (typ_id),
  669. previous_course_id: (previous_course_id),
  670. outcome_id: (outcome_id),
  671. semester_id: (semester_id),
  672. objective_id: (objective_id),
  673. new_course_id: (new_course_id)
  674. },
  675. function(data)
  676. {
  677. //
  678. }
  679. );
  680. }
  681. $(this).parent().hide();;
  682. });
  683. @stop