Няма описание

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

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