暂无描述

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

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