Sin descripción

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

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