Brak opisu

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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  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 id="VerifyModal" class="modal fade" tabindex="-1" data-criterion-id="0">
  285. <div class="modal-dialog">
  286. <div class="modal-content">
  287. <div class="modal-header" style="background-color: rgba(247, 83, 6, 0.817)">
  288. <h5 class="modal-title">There is some information missing</h5>
  289. <button type="button" class="close" data-dismiss="modal">&times;</button>
  290. </div>
  291. <div class="modal-body" id = "VerifyBody">
  292. </div>
  293. <div class="modal-footer">
  294. <button type="button" class="btn btn-secondary" data-dismiss="modal" >Ok</button>
  295. </div>
  296. </div>
  297. </div>
  298. </div>
  299. </div>
  300. <script>
  301. $(document).ready(function() {
  302. // --------------------------------------------------------------------------
  303. // Page load
  304. // --------------------------------------------------------------------------
  305. // Hide accordion panel contents by default
  306. var outcomes = {{ json_encode($outcomes) }};
  307. $('.panel-group .panel-body').hide();
  308. $('#cycle-display').parent().hide();
  309. $("#clonedOutcome0").hide();;
  310. $('.show-course-selection').hide();
  311. // --------------------------------------------------------------------------
  312. // Functions
  313. // --------------------------------------------------------------------------
  314. (function() {
  315. var previous;
  316. $("select").on('focus', function() {
  317. // Store the current value on focus and on change
  318. previous = this.value;
  319. }).change(function() {
  320. //comienzo
  321. var options_values = $(this).parent().find('select').val().split('-');
  322. //ifs
  323. if (options_values.length == 3) {
  324. var typ_id = $('#table-cycles').data('typ-id');
  325. var previous_objective_id = previous.split('-')[2];
  326. var options_values = this.value.split('-');
  327. var outcome_id = options_values[0];
  328. var semester_id = options_values[1];
  329. var new_objective_id = options_values[2];
  330. if (new_objective_id == 'n') {
  331. new_objective_id = 'nothing_selected';
  332. }
  333. if (previous_objective_id == 'n') {
  334. previous_objective_id = 'nothing_selected';
  335. }
  336. $.post(
  337. "{{ URL::action('ThreeYearPlanController@section2_on_change') }}", {
  338. typ_id: (typ_id),
  339. previous_objective_id: (previous_objective_id),
  340. outcome_id: (outcome_id),
  341. semester_id: (semester_id),
  342. new_objective_id: (new_objective_id),
  343. program_id: {{ $program_id }},
  344. },
  345. function(data) {
  346. //
  347. }
  348. );
  349. previous = this.value;
  350. } else if (options_values.length == 4) {
  351. var typ_id = $('#table-cycles').data('typ-id');
  352. var previous_course_id = previous.split('-')[3];
  353. var options_values = this.value.split('-');
  354. var outcome_id = options_values[0];
  355. var semester_id = options_values[1];
  356. var objective_id = options_values[2];
  357. var new_course_id = options_values[3];
  358. if (new_course_id == 'n') {
  359. new_course_id = 'nothing_selected';
  360. }
  361. if (previous_course_id == 'n') {
  362. previous_course_id = 'nothing_selected';
  363. }
  364. $.post(
  365. "{{ URL::action('ThreeYearPlanController@section3_on_change') }}", {
  366. typ_id: (typ_id),
  367. previous_course_id: (previous_course_id),
  368. outcome_id: (outcome_id),
  369. semester_id: (semester_id),
  370. objective_id: (objective_id),
  371. new_course_id: (new_course_id),
  372. program_id: {{ $program_id }}
  373. },
  374. function(data) {
  375. //
  376. }
  377. );
  378. previous = this.value;
  379. }
  380. });
  381. })();
  382. // --------------------------------------------------------------------------
  383. // Events
  384. // --------------------------------------------------------------------------
  385. $('.go-to-temp').on('click', function() {
  386. typ_id =$('#table-cycles').data('typ-id');
  387. $.post(
  388. "{{ URL::action('ThreeYearPlanController@verifyAndCreate', [$program_id]) }}", {
  389. typ_id: typ_id
  390. },
  391. function(informationMissing) {
  392. if(informationMissing.length == 0){
  393. window.open("{{ URL::action('ThreeYearPlanController@printPlan', [$program_id]) }}"+"/"+typ_id+"/1", '_blank');
  394. $('#SubmitModal').modal('show');
  395. }
  396. else{
  397. $("#VerifyBody").html('<h3>These are the fields that are missing</h3>');
  398. if(informationMissing.objectives_missing !== undefined){
  399. $("#VerifyBody").append("<h4>These Outcomes need Objectives paired.</h4>")
  400. $.each(informationMissing.objectives_missing, function(ob_id, semester_object){
  401. name = "<h5>"+semester_object.semester_name+"</h5>";
  402. ul = $('<ul>');
  403. $.each(semester_object.outcome_text, function(ind, outcome){
  404. li = $('<li>').html(outcome)
  405. ul.append(li);
  406. })
  407. $('#VerifyBody').append(name);
  408. $("#VerifyBody").append(ul);
  409. });
  410. }
  411. if(informationMissing.courses_missing !== undefined){
  412. $("#VerifyBody").append("<h4>These Objectives need Courses. </h4>")
  413. $.each(informationMissing.courses_missing, function(ob_id, semester_object){
  414. name = "<h5>" + semester_object.semester_name +"</h5>";
  415. ul = $('<ul>');
  416. $.each(semester_object.outcomes, function(ind, outcome){
  417. li = $('<li>').html(outcome.outcome_name);
  418. nested_ul = $('<ul>');
  419. $.each(outcome.objectives, function(ind, ob){
  420. nested_li = $("<li>").html(ob);
  421. nested_ul.append(nested_li);
  422. });
  423. li.append(nested_ul);
  424. ul.append(li);
  425. })
  426. $('#VerifyBody').append(name);
  427. $("#VerifyBody").append(ul);
  428. });
  429. }
  430. $("#VerifyModal").modal('show');
  431. }
  432. // window.location.href = "{{ URL::action('AnnualPlansController@showPlan', [$program_id]) }}";
  433. });
  434. });
  435. // When list item is clicked, load corresponding info
  436. //section 1
  437. $('.list-group-item').on('click', function() {
  438. $('#three_year_button').hide();
  439. var id = $(this).data('cycle-id');
  440. $('#table-cycles').data('typ-id', id);
  441. $('#view_button').show();
  442. $('#view_button').attr("href",
  443. "{{ URL::action('ThreeYearPlanController@viewPlan', [$program_id]) }}" +
  444. '/' + $(this).data('cycle-id'));
  445. $('#print_button').show();
  446. $('#print_button').attr("href",
  447. "{{ URL::action('ThreeYearPlanController@printPlan', [$program_id]) }}" +
  448. '/' + $(this).data('cycle-id'));
  449. $('#section1').show();
  450. $('#section2').hide();
  451. $('#section3').hide();
  452. var outcome_id_semester_code_program_id_box_id_typ_id = new Object();
  453. var outcome_id_semester_code_program_id_box_id_typ_id = Array();
  454. $.post(
  455. "{{ URL::action('ThreeYearPlanController@fetchThreeYears') }}", {
  456. id: id
  457. },
  458. function(json) {
  459. // Retrieve datatable instance
  460. var table = $('#table-cycles');
  461. var typ = json.typ;
  462. var year_start = json.typ.year_start;
  463. var year_end = json.typ.year_end;
  464. var semesters = json.typ.semesters;
  465. var program_id = {{ $program_id }};
  466. // var outcomes = already defined
  467. $('#cycle-display').parent().show();
  468. $('.no-cycle').parent().hide();
  469. //Display title and definition
  470. $('#cycle-display .panel-title').html('Planning for the years of ' +
  471. year_start + '-' + year_end);
  472. $('#cycle-display .cycle-definition').html(
  473. "Select the semesters which you would like to review an outcome in the three year plan of " +
  474. year_start + '-' + year_end + ".");
  475. //Empty table
  476. //table.clear();
  477. // Add new semesters
  478. //if(typ.length>0)
  479. //{
  480. $('table').show();
  481. $('#cycle1').html((parseInt(year_start)) + "-" + (parseInt(year_start) + 1));
  482. $('#cycle2').html((parseInt(year_start) + 1) + "-" + (parseInt(year_end) - 1));
  483. $('#cycle3').html((parseInt(year_end) - 1) + "-" + (parseInt(year_end)));
  484. $('#cycle_id').val(typ.id);
  485. //resets the checkboxes' name, clears marked, and disables them by default.
  486. $.each(outcomes, function(index, outcome) {
  487. $.each([1, 2, 3, 4, 5, 6], function(index, semester) {
  488. var id = outcome.id + "-sem" + semester;
  489. var new_name = id;
  490. document.getElementById(id).setAttribute("name",
  491. new_name);
  492. $("#" + id).attr("disabled", true);
  493. $("#" + id).prop("checked", false);
  494. });
  495. });
  496. var i = 1;
  497. $.each(outcomes, function(index, outcome) {
  498. $.each(semesters, function(index, semester) {
  499. var id = outcome.id + "-sem" + i;
  500. var new_name = outcome.id + "-sem" + semester.code;
  501. var checkbox = document.getElementById(id);
  502. checkbox.setAttribute("name", new_name);
  503. //enable the check box
  504. $("#" + id).removeAttr("disabled");
  505. //store checkboxes info in an array to later lookup which are marked
  506. var temp = Array(outcome.id, semester.code, program_id,
  507. id, typ.id);
  508. outcome_id_semester_code_program_id_box_id_typ_id.push(
  509. temp);
  510. i++;
  511. });
  512. i = 1;
  513. });
  514. //search which boxes are marked in the data-base
  515. $.post(
  516. "{{ URL::action('ThreeYearPlanController@lookup_typ_semester_outcome') }}", {
  517. info: (outcome_id_semester_code_program_id_box_id_typ_id)
  518. },
  519. function(data) {
  520. $.each(data.box_value, function(index, box_id_value) {
  521. var box_id = box_id_value[0];
  522. var value = box_id_value[1];
  523. if (1 == value) {
  524. $("#" + box_id).prop("checked", true);
  525. }
  526. });
  527. }
  528. );
  529. },
  530. 'json'
  531. );
  532. });
  533. });
  534. function submitTYP(){
  535. typ_id =$('#table-cycles').data('typ-id');
  536. $.post(
  537. "{{URL::action('ThreeYearPlanController@submit', [$program_id])}}",{
  538. typ_id:typ_id
  539. },
  540. function(code){
  541. if(code!=500)
  542. window.location.href = "{{ URL::action('AnnualPlansController@showPlan', [$program_id]) }}";
  543. }
  544. )
  545. }
  546. // go back to section 1
  547. $('.back-to-1').on('click', function(e) {
  548. window.scrollTo(0, 0);
  549. $(".panel-body").hide();
  550. $("#section1").show();
  551. });
  552. // go back to section 2
  553. $('.back-to-2').on('click', function(e) {
  554. window.scrollTo(0, 0);
  555. $(".panel-body").hide();
  556. $("#section2").show();
  557. });
  558. // go to section 2
  559. $('.go-to-2').on('click', function(e) {
  560. var not_enough = false;
  561. var i = 0;
  562. $('#table-cycles tbody tr').each(function() {
  563. $(this).find('th').each(function() {
  564. if ($(this).find('input').is(':checked')) {
  565. i = i + 1;
  566. }
  567. });
  568. if (i < 2) {
  569. not_enough = true;
  570. }
  571. i = 0;
  572. });
  573. if (not_enough == true) {
  574. alert("Each Learning Outcome must be evaluated in at least 2 semesters.");
  575. return true;
  576. }
  577. $(".panel-body").hide();;
  578. $("#section2").show();;
  579. var typ_id = $('#table-cycles').data('typ-id');
  580. $.post(
  581. "{{ URL::action('ThreeYearPlanController@section2_arrive') }}", {
  582. typ_id: (typ_id),
  583. program_id: {{ $program_id }}
  584. },
  585. function(data) {
  586. $('.objectives-section').empty();
  587. $.each(data, function(index, outcome) {
  588. var outcome_name = outcome.name;
  589. var outcome_id = outcome.id;
  590. $('.objectives-section').append('<hr>');
  591. var area = $('.courses-section-0').clone(true);
  592. area.attr('class', '');
  593. var title = outcome_name;
  594. //var title = 'Learning Outcome: ' + outcome_name;
  595. var title_area = $('.title-course-selection-0').clone(true);
  596. title_area.attr('class', 'title-course-selection h3');
  597. title_area.find('p').html(title);
  598. area.append(title_area);
  599. $.each(outcome.selected_semesters, function(index, semester) {
  600. var semester_name = semester.name;
  601. var semester_id = semester.semester_id;
  602. var select_area = $('.semester-course-selection-0').clone(true);
  603. select_area.attr('class', 'semester-course-selection');
  604. select_area.attr('style', ' ');
  605. select_area.find('.semester-label-course-selection-0').html(
  606. semester_name + "'s Objectives");
  607. var no_option = outcome_id + '-' + semester_id + '-n';
  608. select_area.find('option').val(no_option).html(
  609. 'Select an Objective');
  610. select_area.find('.add-objective-course').html(
  611. '<span class="glyphicon glyphicon-plus"></span> Choose more Objectives'
  612. );
  613. if (semester.available_objectives.length != 0) {
  614. select_area.find('.objective-selector-0 label').hide();
  615. $.each(semester.available_objectives, function(index,
  616. objective) {
  617. var objective_id = objective.id;
  618. var option_value = outcome_id + '-' + semester_id +
  619. '-' + objective_id;
  620. var option_name = objective.text;
  621. var new_option = select_area.find('.default-option')
  622. .clone(true);
  623. new_option.html(option_name);
  624. new_option.val(option_value);
  625. new_option.attr('class', 'select_objective');
  626. select_area.find('select').append(new_option);
  627. });
  628. }
  629. if (semester.available_objectives.length == 0) {
  630. select_area.find('select').prop('disabled', 'disabled');
  631. select_area.find('.objective-selector-0 label').html(
  632. 'There are no Objectives available for this Learning Outcome and Semester combination'
  633. );
  634. select_area.find('.objective-selector-0 select').hide();
  635. select_area.find('button').prop('disabled', 'disabled');
  636. }
  637. $.each(semester.selected_objectives, function(index, objective) {
  638. select_area.find('.objective-selector-0').hide();
  639. //si hay objetivos previamente seleccionados, escribirlos
  640. var objective_id = objective.id;
  641. var option_value = outcome_id + '-' + semester_id +
  642. '-' + objective_id;
  643. var new_select = select_area.find(
  644. '.objective-selector-0').clone(true);
  645. new_select.attr('class', 'objective-selector');
  646. new_select.find('select').val(option_value);
  647. select_area.find('.clone-objective-course-select-0')
  648. .before(new_select);
  649. select_area.find('.objective-selector').show();
  650. objective_selector = select_area.find(
  651. '.objective-selector');
  652. objective_selector.find(".delete-selection-0").show();
  653. });
  654. area.append(select_area);
  655. });
  656. var footer = $('.footer-course-selection-0').clone(true);
  657. footer.attr('class', 'footer-course-selection');
  658. footer.find('p').html(
  659. '<b>Objective selection for this Learning Outcome is currently hidden.</b>'
  660. );
  661. area.append(footer);
  662. area.append('<br>');
  663. area.show(true);
  664. $('.objectives-section').append(area);
  665. });
  666. }
  667. );
  668. });
  669. // hide the options of an outcome in section 2 and 3
  670. $('.hide-course-selection').on('click', function(e) {
  671. $(this).parent().find('.show-course-selection').show();;
  672. $(this).hide();;
  673. $(this).parent().parent().find('.semester-course-selection').hide(333);
  674. $(this).parent().parent().find('.footer-course-selection').show(333);
  675. });
  676. // show the options of an outcome in section 2 and 3
  677. $('.show-course-selection').on('click', function(e) {
  678. $(this).parent().find('.hide-course-selection').show();
  679. $(this).hide();
  680. $(this).parent().parent().find('.semester-course-selection').show(333);
  681. $(this).parent().parent().find('.footer-course-selection').hide(333);
  682. });
  683. // in section 2 and 3, add selects for choosing more objectives and courses, respectively
  684. $('.add-objective-course').on('click', function(e) {
  685. var new_select = $(this).parent().parent().find('.objective-selector-0').clone(true);
  686. new_select.attr('class', 'objective-selector');
  687. new_select.show();
  688. $(this).parent().before(new_select);
  689. });
  690. // go to section 3
  691. $('.go-to-3').on('click', function(e) {
  692. window.scrollTo(0, 0);
  693. $(".panel-body").hide();;
  694. $("#section3").show();;
  695. var typ_id = $('#table-cycles').data('typ-id');
  696. $.post(
  697. "{{ URL::action('ThreeYearPlanController@section3_arrive') }}", {
  698. typ_id: (typ_id),
  699. program_id: {{ $program_id }}
  700. },
  701. function(data) {
  702. $('.courses-section').empty();
  703. $.each(data, function(index, outcome) {
  704. var outcome_name = outcome.name;
  705. var outcome_id = outcome.id;
  706. $('.courses-section').append('<hr>');
  707. var area = $('.courses-section-0').clone(true);
  708. area.attr('class', '');
  709. //var title = 'Outcome: ' + outcome_name;
  710. var title = outcome_name;
  711. var title_area = $('.title-course-selection-0').clone(true);
  712. title_area.attr('class', 'title-course-selection h3');
  713. title_area.find('p').html(title);
  714. area.append(title_area);
  715. $.each(outcome.selected_semesters, function(index, semester) {
  716. var semester_name = semester.name;
  717. var semester_id = semester.semester_id;
  718. var select_area = $('.semester-course-selection-0').clone(true);
  719. select_area.attr('class', 'semester-course-selection');
  720. select_area.attr('style', ' ');
  721. select_area.find('.semester-label-course-selection-0').html(
  722. semester_name);
  723. $.each(semester.selected_objectives, function(index, objective) {
  724. var objective_id = objective.objective_id;
  725. var objective_text = objective.text;
  726. var new_select = select_area.find(
  727. '.select-course-selection-0').clone(true);
  728. new_select.attr('class', 'select-course-selection');
  729. new_select.find('label').html('');
  730. new_select.find('.objective-selector-0').before(
  731. '<p>Objective: <b>' + objective_text +
  732. '</b></p>');
  733. {{-- new_select.find('.objective-selector-0 select').attr('style','width:100%;max-width:25%;'); --}}
  734. $.each(objective.available_courses, function(index,
  735. course) {
  736. var course_id = course.course_id;
  737. var option_value = outcome_id + '-' +
  738. semester_id + '-' + objective_id + '-' +
  739. course_id;
  740. var option_name = '[' + course.code + course
  741. .number + '] ' + course.name;
  742. var new_option = new_select.find(
  743. '.default-option').clone(true);
  744. new_option.html(option_name);
  745. new_option.val(option_value);
  746. new_option.attr('class', 'select_course');
  747. new_select.find('select').append(
  748. new_option);
  749. });
  750. if (objective.available_courses.length == 0) {
  751. new_select.find('.select-course-selection-0')
  752. .hide();
  753. new_select.find('select').prop('disabled',
  754. 'disabled');
  755. new_select.find('select label').html(
  756. ' Objective "' + objective_text +
  757. '" has no courses available for selection');
  758. new_select.find('button').prop('disabled',
  759. 'disabled');
  760. }
  761. $.each(objective.selected_courses, function(index,
  762. course) {
  763. new_select.find('.objective-selector-0')
  764. .hide();
  765. //si hay objetivos previamente seleccionados, escribirlos
  766. var course_id = course.course_id;
  767. var option_value = outcome_id + '-' +
  768. semester_id + '-' + objective_id + '-' +
  769. course_id;
  770. var new_selected_course = new_select.find(
  771. '.objective-selector-0').clone(true);
  772. new_selected_course.attr('class',
  773. 'objective-selector');
  774. new_selected_course.find('select').val(
  775. option_value);
  776. {{-- new_selected_course.find('label').html(''); --}}
  777. new_selected_course.show();
  778. new_select.find(
  779. '.clone-objective-course-select-0')
  780. .before(new_selected_course);
  781. });
  782. select_area.find('.select-course-selection-0').after(
  783. new_select);
  784. });
  785. if (semester.selected_objectives.length != 0) {
  786. select_area.find('.select-course-selection-0').hide();
  787. } else {
  788. select_area.find('select').prop('disabled', 'disabled');
  789. select_area.find('.objective-selector-0').html(
  790. 'There are no objectives selected for this semester');
  791. select_area.find('button').prop('disabled', 'disabled');
  792. }
  793. area.append(select_area);
  794. });
  795. var footer = $('.footer-course-selection-0').clone(true);
  796. footer.attr('class', 'footer-course-selection');
  797. area.append(footer);
  798. area.append('<br>');
  799. area.show(true);
  800. $('.courses-section').append(area);
  801. });
  802. //$('.objective-selector').children('.delete-selection-0').css("margin:5px; display:block;");
  803. }
  804. );
  805. });
  806. // remove an
  807. // remove an
  808. $('.delete-selection-0').on('click', function(e) {
  809. var options_values = $(this).parent().find('select').val().split('-');
  810. var ob_selector = $(this).parent();
  811. //if == 3 then we are in the objective selector
  812. if (options_values.length == 3) {
  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. /*
  823. if (count_objective_selectors_total == 1 || (count_objective_selectors_total == 2 &&
  824. objective_selector_0_hidden)) {
  825. //if there is only one objective-selector,throw an alert and do nothing
  826. //html alert with dismiss button in the alert_placeholder div
  827. $('#alert_placeholder').html(
  828. '<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>'
  829. );
  830. return true;
  831. }*/
  832. //subtract 1 from count_objective_selectors_total
  833. var typ_id = $('#table-cycles').data('typ-id');
  834. var outcome_id = options_values[0];
  835. var semester_id = options_values[1];
  836. var new_objective_id = "nothing_selected";
  837. var previous_objective_id = options_values[2];
  838. if (previous_objective_id == 'n') {
  839. previous_objective_id = "nothing_selected";
  840. // with the next return, the post shouldnt excecute.
  841. // im leaving the assignment in the line before this one just in case.
  842. //check to see if parent is objective-selector-0
  843. var x = $(this).parent().parent().attr('class');
  844. if ($(this).parent().attr('class') == 'objective-selector-0') {
  845. // if it is then hide it
  846. $(this).parent().hide();
  847. return true;
  848. }
  849. $(this).parent().remove();;
  850. return true;
  851. }
  852. $.post(
  853. "{{ URL::action('ThreeYearPlanController@section2_on_change') }}", {
  854. typ_id: (typ_id),
  855. previous_objective_id: (previous_objective_id),
  856. outcome_id: (outcome_id),
  857. semester_id: (semester_id),
  858. new_objective_id: (new_objective_id),
  859. program_id: {{ $program_id }},
  860. },
  861. function(data) {
  862. //
  863. }
  864. );
  865. }
  866. //if == 4 then we are in the course selector
  867. else if (options_values.length == 4 || options_values == "nothing_selected") {
  868. //get count of all objective-selectors in the same semester, plus objective-selector-0
  869. var count_objective_selectors = $(this).parent().parent().find('.objective-selector').length;
  870. var count_objective_selectors_0 = $(this).parent().parent().find('.objective-selector-0').length;
  871. var count_objective_selectors_total = count_objective_selectors + count_objective_selectors_0;
  872. //view count of all objective-selectors in the same semester, plus objective-selector-0
  873. console.log(count_objective_selectors_total);
  874. //variable that holds value of wether the objective-selector-0 is hidden or not
  875. var objective_selector_0_hidden = $(this).parent().parent().find('.objective-selector-0').is(
  876. ':hidden');
  877. /*if (count_objective_selectors_total == 1 || (count_objective_selectors_total == 2 &&
  878. objective_selector_0_hidden)) {
  879. //if there is only one objective-selector,throw an alert and do nothing
  880. //html alert with dismiss button in the alert-placeholder div
  881. $('#alert_placeholder').html(
  882. '<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>'
  883. );
  884. return true;
  885. }*/
  886. //subtract 1 from count_objective_selectors_total
  887. var typ_id = $('#table-cycles').data('typ-id');
  888. var outcome_id = options_values[0];
  889. var semester_id = options_values[1];
  890. var objective_id = options_values[2];
  891. var previous_course_id = options_values[3];
  892. var new_course_id = 'nothing_selected';
  893. $.post(
  894. "{{ URL::action('ThreeYearPlanController@section3_on_change') }}", {
  895. typ_id: (typ_id),
  896. previous_course_id: (previous_course_id),
  897. outcome_id: (outcome_id),
  898. semester_id: (semester_id),
  899. objective_id: (objective_id),
  900. new_course_id: (new_course_id),
  901. program_id:{{$program_id}}
  902. },
  903. function(data) {
  904. //
  905. }
  906. );
  907. }
  908. var x = $(this).parent().attr('class');
  909. if ($(this).parent().attr('class') == 'objective-selector-0') {
  910. // if it is then hide it
  911. $(this).parent().parent().hide();
  912. return;
  913. }
  914. //remove the select
  915. $(this).parent().remove();;
  916. });
  917. </script>
  918. @stop
  919. @section('included-js')
  920. @include('global._datatables_js')
  921. @stop
  922. @stop