Nessuna descrizione

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

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