Nessuna descrizione

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

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