No Description

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

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