Без опису

annual-plans.blade.php 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. @extends('layouts.master-2')
  2. @section('navigation')
  3. @if(Auth::user()->role==1)
  4. @include('local.managers.admins._navigation')
  5. @elseif(Auth::user()->role==2)
  6. @include('local.managers.sCoords._navigation')
  7. @elseif(Auth::user()->role==3)
  8. @include('local.managers.pCoords._navigation')
  9. @elseif(Auth::user()->role==4)
  10. @include('local.professors._navigation')
  11. @endif
  12. @stop
  13. @section('main')
  14. {{-- TODO: look where to place this script.
  15. if placed inside .ready() or before it,
  16. an error that the function is not defined occurs. --}}
  17. {{-- TODO: no reconoce acentos --}}
  18. <div class="row">
  19. <div class="col-md-3">
  20. <a role ="button" class="btn btn-secondary" href="{{URL::action("AnnualPlansController@viewAllPlans", array($program->id))}}">View Plans</a>
  21. <select class = "form-control selectpicker" id = "annual_plan" onchange="fetchInfo('annual_plan')">
  22. <option value = '0'> Nothing Selected</option>
  23. @foreach ($annual_plans as $an_plan)
  24. <option value={{$an_plan->id}}>Plan {{$an_plan->academic_year}}</option>
  25. @endforeach
  26. </select>
  27. <br>
  28. <div id='allOutcomes'>
  29. </div>
  30. </div>
  31. <div class="col-md-9">
  32. <div id="outcome-display" class="panel panel-default">
  33. <div class="panel-heading">
  34. <h4 class=" panel-title" style="cursor:auto!important;">
  35. Primer Semestre 2019-2020
  36. </h4>
  37. </div>
  38. <div class="panel-body">
  39. <p class="outcome-definition "></p>
  40. <div class="table-responsive">
  41. <table class="table table-striped table-condensed datatable" style="table-layout: fixed ; width : 100%">
  42. <thead><tr><th>Objectives for courses</th><th>Criteria per Course</th><th>Transformative Actions</th></tr></thead>
  43. <tbody>
  44. </tbody>
  45. </table>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. <div class="col-md-9">
  51. <div class="no-outcome alert alert-info">
  52. <p>Select a Learning Outcome to view its information</p>
  53. </div>
  54. </div>
  55. </div>
  56. <script>
  57. function nextChar(c) {
  58. return String.fromCharCode(c.charCodeAt(0) + 1);
  59. }
  60. changed = false;
  61. $(document).ready(function()
  62. {
  63. // --------------------------------------------------------------------------
  64. // Page load
  65. // --------------------------------------------------------------------------
  66. // Hide accordion panel contents by default
  67. $('.panel-group .panel-body').hide();
  68. $('#outcome-display').parent().hide();
  69. // --------------------------------------------------------------------------
  70. // Functions
  71. // --------------------------------------------------------------------------
  72. // --------------------------------------------------------------------------
  73. // Events
  74. // --------------------------------------------------------------------------
  75. // When list item is clicked, load corresponding info
  76. });
  77. function fetchEverything(li)
  78. {
  79. var id = $(li).data('outcome-id');
  80. var name = $(li).data('outcome-name');
  81. var semester = $(li).data('semester-id');
  82. var annual_plan = $(li).data('annual-plan');
  83. $('#theChange').data('annual-plan', annual_plan);
  84. $.post(
  85. "../annual-plan-fetchTYP/{{$program->id}}",
  86. { id: id,
  87. semester: semester
  88. },
  89. function(json)
  90. {
  91. // Retrieve datatable instance
  92. var table = $('.datatable').DataTable();
  93. table.clear();
  94. var optionsForTADict ={};
  95. var objectives = json.objectives;
  96. var courses = json.courses;
  97. var criteria = json.criteria;
  98. var selected_criteria = json.selected_criteria;
  99. var nextLetter ="A";
  100. if(courses)
  101. {
  102. $('table').show();
  103. $('#outcome-display').parent().show();
  104. $('.no-outcome').parent().hide();
  105. //Display title and definition
  106. $('#outcome-display .panel-title').html(name);
  107. //Empty table
  108. table.clear();
  109. var annual_plan = json.annual_plan.id;
  110. for(objective in objectives){
  111. var objectivesHTML = '';
  112. var courseshtml = '';
  113. var courseTAhtml = '';
  114. var criteriaHTML = '';
  115. objectivesHTML += '<strong>' + nextLetter +'. '+objectives[objective].text+'</strong>';
  116. // courseshtml += "<strong>Objective "+nextLetter+"</strong>";
  117. // courseshtml += '<ul>';
  118. criteriaHTML +="<strong>Objective "+nextLetter+"</strong>";
  119. //criteriaHTML+= '<ol>';
  120. var typ_objective_id = json.typ_objective_id[objectives[objective].id].id;
  121. nextLetter= nextChar(nextLetter);
  122. for(course in courses[objectives[objective].id]){
  123. courseshtml += ' &#8226; '+courses[objectives[objective].id][course].code+' '+courses[objectives[objective].id][course].name+'<br>'
  124. courseTAhtml += ' &#8226; '+courses[objectives[objective].id][course].code+' '+courses[objectives[objective].id][course].name+'<br>'
  125. $divForEach =$('<div/>',{
  126. 'id':'objective-'+objectives[objective].id
  127. });
  128. $divForSelects = $('<div/>', {
  129. 'id' : 'forObjective-'+objectives[objective].id+'-course-'+courses[objectives[objective].id][course].typ_course_id,
  130. 'data-amount-select':'0',
  131. 'class':'form-group',
  132. 'data-annual-plan': json.annual_plan.id
  133. });
  134. options = "<option value = '0' >Nothing Selected</option>"
  135. for (criterion in criteria[objectives[objective].id]){
  136. options += "<option value='"+criteria[objectives[objective].id][criterion].id+"'>"+criteria[objectives[objective].id][criterion].name+"</option>";
  137. }
  138. var $button = $('<button/>', {
  139. 'type': 'button',
  140. 'class': 'btn btn-secondary',
  141. 'onclick': 'addCriteriaTest("forObjective-'+objectives[objective].id+"-course-"+courses[objectives[objective].id][course].typ_course_id+'", "'+objectives[objective].id+"-course-"+courses[objectives[objective].id][course].typ_course_id+'", '+courses[objectives[objective].id][course].typ_course_id+', null, "'+options+'")'
  142. });
  143. $button.append("+ Add criteria");
  144. $divForEach.append($divForSelects);
  145. $divForEach.append("<br>")
  146. $divForEach.append($button);
  147. $divForTA = $('<div/>',{
  148. 'id':'objectiveTA-'+objectives[objective].id
  149. });
  150. $divForTASelects = $('<div/>', {
  151. 'id': 'forTA-objective-'+objectives[objective].id+'-course-'+courses[objectives[objective].id][course].typ_course_id,
  152. 'class':'form-group',
  153. 'data-amount-ta':'0'
  154. });
  155. var optionsForTa = "<option value = '0'>Nothing Selected</option>";
  156. transformativeDefault = json.transformative_actions;
  157. optionsForTa+= "<optgroup label='Default'>";
  158. for(trans in transformativeDefault){
  159. optionsForTa+= "<option value='"+transformativeDefault[trans].id+"'>"+transformativeDefault[trans].at_text+"</option> ";
  160. }
  161. optionsForTa+='</optgroup>';
  162. course_id = courses[objectives[objective].id][course].id
  163. transformativeDefault = json.custom_transformative[objectives[objective].id][course_id];
  164. if(transformativeDefault!= undefined){
  165. optionsForTa+="<optgroup label = 'Custom'>";
  166. for(trans in transformativeDefault){
  167. optionsForTa+= "<option value='"+transformativeDefault[trans].ta_id+"'>"+transformativeDefault[trans].at_text+"</option> ";
  168. }
  169. }
  170. typ_course_id = courses[objectives[objective].id][course].typ_course_id
  171. var $buttonTA = $('<button/>', {
  172. 'type': 'button',
  173. 'class': 'btn btn-secondary',
  174. 'onclick': 'addTAselect("'+optionsForTa+'", "forTA-objective-'+objectives[objective].id+'-course-'+courses[objectives[objective].id][course].typ_course_id+'", '+annual_plan+', '+objectives[objective].id+', '+typ_course_id+', 0)'
  175. });
  176. $buttonTA.append("+ Add TA");
  177. typ_course_id = courses[objectives[objective].id][course].typ_course_id
  178. optionsForTADict[typ_course_id] = optionsForTa;
  179. $divForTA.append($divForTASelects);
  180. $divForTA.append('<br>');
  181. $divForTA.append($buttonTA)
  182. courseshtml += $divForEach[0].innerHTML +"<br><br>";
  183. courseTAhtml += $divForTA[0].innerHTML +"<br><br>";
  184. }
  185. /*$divForTA = $('<div/>',{
  186. 'id':'objectiveTA-'+objectives[objective].id
  187. });
  188. $divForTASelects = $('<div/>', {
  189. 'id': 'forTA-objective-'+objectives[objective].id,
  190. 'class':'form-group',
  191. 'data-amount-ta':'0'
  192. });
  193. var optionsForTa = "<option value = '0'>Nothing Selected</option>";
  194. transformativeDefault = json.transformative_actions;
  195. optionsForTa+= "<optgroup label='Default'>";
  196. for(trans in transformativeDefault){
  197. optionsForTa+= "<option value='"+transformativeDefault[trans].id+"'>"+transformativeDefault[trans].at_text+"</option> ";
  198. }
  199. optionsForTa+='</optgroup>';
  200. transformativeDefault = json.custom_transformative[objectives[objective].id];
  201. if(transformativeDefault!= undefined){
  202. optionsForTa+="<optgroup label = 'Custom'>";
  203. for(trans in transformativeDefault){
  204. optionsForTa+= "<option value='"+transformativeDefault[trans].id+"'>"+transformativeDefault[trans].at_text+"</option> ";
  205. }
  206. }
  207. var $buttonTA = $('<button/>', {
  208. 'type': 'button',
  209. 'class': 'btn btn-secondary',
  210. 'onclick': 'addTAselect("'+optionsForTa+'", "forTA-objective-'+objectives[objective].id+'", '+annual_plan+', '+objectives[objective].id+', '+typ_objective_id+', 0)'
  211. });
  212. $buttonTA.append("+ Add TA");
  213. $divForTA.append($divForTASelects);
  214. $divForTA.append('<br>');
  215. $divForTA.append($buttonTA)
  216. */
  217. table.row.add([
  218. objectivesHTML,
  219. courseshtml,
  220. courseTAhtml
  221. ]);
  222. table.draw();
  223. for(course in courses[objectives[objective].id]){
  224. typ_course_id = courses[objectives[objective].id][course].typ_course_id
  225. if(json.annual_plans_transformative[objectives[objective].id][typ_course_id].length){
  226. for(i=0; i<json.annual_plans_transformative[objectives[objective].id][typ_course_id].length; i++){
  227. selected_ta = json.annual_plans_transformative[objectives[objective].id][typ_course_id][i].trans_id;
  228. addTAselect(optionsForTADict[typ_course_id], "forTA-objective-"+objectives[objective].id+'-course-'+typ_course_id, annual_plan, objectives[objective].id, typ_course_id, selected_ta);
  229. }
  230. }
  231. else{
  232. $('#')
  233. addTAselect(optionsForTADict[typ_course_id], "forTA-objective-"+objectives[objective].id+'-course-'+typ_course_id, annual_plan, objectives[objective].id, typ_course_id, 0);
  234. }
  235. if(json.selected_criteria[objectives[objective].id][typ_course_id].length){
  236. for(i =0; i<json.selected_criteria[objectives[objective].id][typ_course_id].length; i++){
  237. addCriteriaTest("forObjective-"+objectives[objective].id+"-course-"+typ_course_id, ""+objectives[objective].id+"-course-"+typ_course_id, ""+json.selected_criteria[objectives[objective].id][typ_course_id][i].typ_course_id+"", i, options);
  238. $('#criteriaFor'+objectives[objective].id+"-course-"+typ_course_id+'_'+i).val(json.selected_criteria[objectives[objective].id][typ_course_id][i].criteria_id);
  239. $('#criteriaFor'+objectives[objective].id+"-course-"+typ_course_id+'_'+i).data('old-criteria', json.selected_criteria[objectives[objective].id][typ_course_id][i].criteria_id);
  240. $('#criteriaFor'+objectives[objective].id+"-course-"+typ_course_id+'_'+i).selectpicker('refresh');
  241. } // Update display
  242. }
  243. else{
  244. addCriteriaTest("forObjective-"+objectives[objective].id+"-course-"+typ_course_id, ""+objectives[objective].id+"-course-"+typ_course_id+"", ""+typ_course_id+"", 0, options);
  245. $('#criteriaFor'+objectives[objective].id+"-course-"+typ_course_id+'_0').val(0);
  246. $('#criteriaFor'+objectives[objective].id+"-course-"+typ_course_id+'_0').data('old-criteria', 0);
  247. $('#criteriaFor'+objectives[objective].id+"-course-"+typ_course_id+'_0').selectpicker('refresh');
  248. }
  249. }
  250. }
  251. table.draw();
  252. }
  253. else
  254. {
  255. $('table').hide();
  256. }
  257. },
  258. 'json'
  259. );
  260. }
  261. function posttoTransAnnual(annual_id, selectTransId, typ_course_id){
  262. ta = $("#"+selectTransId).val();
  263. old_ta = $("#"+selectTransId).data('old-TA');
  264. if(ta == "0")return;
  265. $.post("../annual-plan-postTA",
  266. {annual_id : annual_id,
  267. TA_id:ta,
  268. typ_course_id : typ_course_id,
  269. old_ta:old_ta
  270. },
  271. function(message){
  272. $("#"+selectTransId).data('old-TA', ta);
  273. }
  274. )
  275. }
  276. function addTAselect(options, master_div, annual_plan_id, objective_id, typ_course_id, selected_ta){
  277. var $div = $('<div/>', {
  278. 'class': 'form-group '
  279. });
  280. counter = parseInt($('#'+master_div).data('amount-ta'));
  281. var selectTA = $('<select/>',{
  282. 'class': "selectpicker form-control",
  283. 'data-live-search':'true',
  284. 'data-old-TA' :'0',
  285. 'data-width': '180px',
  286. 'id': 'transformativeForObjective'+master_div+'_'+counter,
  287. 'onchange':'posttoTransAnnual('+annual_plan_id+', "transformativeForObjective'+master_div+'_'+counter+'", '+typ_course_id+')'
  288. });
  289. selectTA.append(options);
  290. selectTA.appendTo($div);
  291. selectTA.val(selected_ta);
  292. selectTA.data('old-TA', selected_ta);
  293. selectTA.selectpicker('refresh');
  294. $span = $('<span/>', {
  295. 'id':'close',
  296. 'onclick':' postDeleteTA('+annual_plan_id+', "transformativeForObjective'+master_div+'_'+counter+'", '+typ_course_id+'); this.parentNode.parentNode.removeChild(this.parentNode);return false;'
  297. }).html('x');
  298. $span.appendTo($div);
  299. $div.append("<br><br>");
  300. $('#'+master_div).append("<br>");
  301. $div.appendTo($('#'+master_div));
  302. $('#'+master_div).data('amount-ta', counter+1);
  303. }
  304. function postDeleteTA(annual_id, selectTransId, typ_course_id){
  305. ta = $("#"+selectTransId).val();
  306. if(ta == "0")return;
  307. $.post("../annual-plan-deleteTA",
  308. {annual_id : annual_id,
  309. TA_id:ta,
  310. typ_id : typ_course_id,
  311. }
  312. );
  313. parent = $("#"+selectTransId).parent().parent().parent();
  314. counter = parseInt(parent.data('amount-ta'));
  315. parent.data('amount-ta', counter-1);
  316. }
  317. function postToAnnualPlans(typ_course_id, criteria_select){
  318. var criteria = $('#'+criteria_select).val();
  319. var oldCriteria = $('#'+criteria_select).data('old-criteria');
  320. var criteriaNode = document.getElementById(criteria_select).parentNode.parentNode.parentNode;
  321. var annual = criteriaNode.dataset.annualPlan;
  322. $.post("../annual-plan-postOnChange",
  323. {criteria : criteria,
  324. typ_course_id : typ_course_id,
  325. annual_plan : annual,
  326. old_criteria :oldCriteria
  327. },
  328. function(message){
  329. if(message =="Duplicate entry, please choose another criteria."){
  330. alert(message)
  331. }
  332. else{
  333. $('#'+criteria_select).data('old-criteria', criteria);
  334. changed = true;
  335. }
  336. })
  337. }
  338. function addCriteriaTest(div, new_id_for_select, typ_course_id, i=null, options) {
  339. if(!i) amount_select = $('#'+div).data("amount-select");
  340. else amount_select = i;
  341. $select = $('<select/>',{
  342. 'class': "selectpicker form-control",
  343. 'data-live-search':'true',
  344. 'data-old-criteria' :'0',
  345. 'data-width': '180px',
  346. 'id': 'criteriaFor'+new_id_for_select+'_'+amount_select,
  347. 'onchange':'postToAnnualPlans('+typ_course_id+', "criteriaFor'+new_id_for_select+'_'+amount_select+'")'
  348. })
  349. var $div = $('<div/>', {
  350. 'id': 'courseSelect_' + new_id_for_select +'_'+amount_select,
  351. 'class': 'form-group '
  352. });
  353. $select.append(options);
  354. $select.appendTo($div);
  355. $span = $('<span/>', {
  356. 'id':'close',
  357. 'onclick':' postDelete('+typ_course_id+', "criteriaFor'+new_id_for_select+'_'+amount_select+'"); this.parentNode.parentNode.removeChild(this.parentNode);return false;'
  358. }).html('x');
  359. $div.append($span);
  360. $div.append("<br><br>")
  361. $('#'+div).append("<br>");
  362. $div.appendTo($("#"+div));
  363. $select.selectpicker('refresh');
  364. $("#"+div).data("amount-select", amount_select+1);
  365. }
  366. $('#allOutcomes').hide();
  367. function postDelete(typ_course_id, criteria_select){
  368. var criteria = $('#'+criteria_select).val();
  369. var oldCriteria = $('#'+criteria_select).data('old-criteria');
  370. var criteriaNode = document.getElementById(criteria_select).parentNode.parentNode.parentNode;
  371. var annual = criteriaNode.dataset.annualPlan;
  372. $.post("../annual-plan-deleteCriteria",
  373. {criteria : criteria,
  374. typ_course_id : typ_course_id,
  375. annual_plan : annual,
  376. old_criteria :oldCriteria
  377. });
  378. }
  379. function fetchInfo(id){
  380. annual_id = $("#"+id).val();
  381. program_id = {{$program->id}};
  382. $.post("{{URL::action('AnnualPlansController@fetchInfo')}}",
  383. {
  384. id:annual_id,
  385. program_id:program_id
  386. },
  387. function(json){
  388. div = $('<div/>', {
  389. 'class':'list-group',
  390. 'id':'list'
  391. });
  392. header5 = $('<h5/>', {
  393. 'style':"padding-left: 10px"
  394. }).html("First Semester");
  395. div.append(header5);
  396. list = '';
  397. for(outcome in json.outcomes.first){
  398. list+= "<li style='padding-left: 25px' onclick = 'fetchEverything(this)' data-annual-plan = '"+json.annual_plans.id+"' data-semester-id = '"+json.allSemesterOrder.first.id+"' data-outcome-id='"+json.outcomes.first[outcome].id+"' data-outcome-name ='"+json.outcomes.first[outcome].name+"' class='list-group-item' >"+json.outcomes.first[outcome].name+" </li>";
  399. }
  400. div.append(list);
  401. header4 = $('<h5/>', {
  402. 'style':"padding-left: 10px"
  403. }).html("Second Semester");
  404. div.append(header4);
  405. list = '';
  406. for(outcome in json.outcomes.second){
  407. list+= "<li style='padding-left: 25px' onclick = 'fetchEverything(this)' data-annual-plan = '"+json.annual_plans.id+"' data-semester-id = '"+json.allSemesterOrder.second.id+"' data-outcome-id='"+json.outcomes.second[outcome].id+"' data-outcome-name ='"+json.outcomes.second[outcome].name+"' class='list-group-item' >"+json.outcomes.second[outcome].name+" </li>";
  408. }
  409. div.append(list);
  410. html = div[0].innerHTML;
  411. $("#allOutcomes").html(div[0].innerHTML);
  412. $("#allOutcomes").show();
  413. },
  414. "json",
  415. );
  416. }
  417. function deleteObjective(objectiveSelectDiv, closeObj){
  418. $('#'+objectiveSelectDiv).remove();
  419. $('#'+closeObj).remove();
  420. $('#'+div).data("amount-select", $('#'+div).data("amount-select")-1);
  421. }
  422. </script>
  423. @stop
  424. @section('included-js')
  425. @include('global._datatables_js')
  426. @stop