Aucune description

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

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