暫無描述

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

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