暂无描述

annual-plans.blade.php 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  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 objectives = json.objectives;
  95. var courses = json.courses;
  96. var criteria = json.criteria;
  97. var selected_criteria = json.selected_criteria;
  98. var nextLetter ="A";
  99. if(courses)
  100. {
  101. $('table').show();
  102. $('#outcome-display').parent().show();
  103. $('.no-outcome').parent().hide();
  104. //Display title and definition
  105. $('#outcome-display .panel-title').html(name);
  106. //Empty table
  107. table.clear();
  108. var annual_plan = json.annual_plan.id;
  109. for(objective in objectives){
  110. var objectivesHTML = '';
  111. var courseshtml = '';
  112. var courseTAhtml = '';
  113. var criteriaHTML = '';
  114. objectivesHTML += '<strong>' + nextLetter +'. '+objectives[objective].text+'</strong>';
  115. // courseshtml += "<strong>Objective "+nextLetter+"</strong>";
  116. // courseshtml += '<ul>';
  117. criteriaHTML +="<strong>Objective "+nextLetter+"</strong>";
  118. //criteriaHTML+= '<ol>';
  119. var typ_objective_id = json.typ_objective_id[objectives[objective].id].id;
  120. nextLetter= nextChar(nextLetter);
  121. for(course in courses[objectives[objective].id]){
  122. courseshtml += ' &#8226; '+courses[objectives[objective].id][course].code+' '+courses[objectives[objective].id][course].number+'<br>'
  123. courseTAhtml += ' &#8226; '+courses[objectives[objective].id][course].code+' '+courses[objectives[objective].id][course].number+'<br>'
  124. $divForEach =$('<div/>',{
  125. 'id':'objective-'+objectives[objective].id
  126. });
  127. $divForSelects = $('<div/>', {
  128. 'id' : 'forObjective-'+objectives[objective].id+'-course-'+courses[objectives[objective].id][course].typ_course_id,
  129. 'data-amount-select':'0',
  130. 'class':'form-group',
  131. 'data-annual-plan': json.annual_plan.id
  132. });
  133. options = "<option value = '0' >Nothing Selected</option>"
  134. for (criterion in criteria[objectives[objective].id]){
  135. options += "<option value='"+criteria[objectives[objective].id][criterion].id+"'>"+criteria[objectives[objective].id][criterion].name+"</option>";
  136. }
  137. var $button = $('<button/>', {
  138. 'type': 'button',
  139. 'class': 'btn btn-secondary',
  140. 'onclick': 'addCriteriaTest("forObjective-'+objectives[objective].id+"-course-"+courses[objectives[objective].id][course].id+'", "'+objectives[objective].id+"-course-"+courses[objectives[objective].id][course].id+'", '+courses[objectives[objective].id][course].typ_course_id+', null, "'+options+'")'
  141. });
  142. $button.append("+ Add criteria");
  143. $divForEach.append($divForSelects);
  144. $divForEach.append("<br>")
  145. $divForEach.append($button);
  146. $divForTA = $('<div/>',{
  147. 'id':'objectiveTA-'+objectives[objective].id
  148. });
  149. $divForTASelects = $('<div/>', {
  150. 'id': 'forTA-objective-'+objectives[objective].id+'-course-'+courses[objectives[objective].id][course].typ_course_id,
  151. 'class':'form-group',
  152. 'data-amount-ta':'0'
  153. });
  154. var optionsForTa = "<option value = '0'>Nothing Selected</option>";
  155. transformativeDefault = json.transformative_actions;
  156. optionsForTa+= "<optgroup label='Default'>";
  157. for(trans in transformativeDefault){
  158. optionsForTa+= "<option value='"+transformativeDefault[trans].id+"'>"+transformativeDefault[trans].at_text+"</option> ";
  159. }
  160. optionsForTa+='</optgroup>';
  161. course_id = courses[objectives[objective].id][course].id
  162. transformativeDefault = json.custom_transformative[objectives[objective].id][course_id];
  163. if(transformativeDefault!= undefined){
  164. optionsForTa+="<optgroup label = 'Custom'>";
  165. for(trans in transformativeDefault){
  166. optionsForTa+= "<option value='"+transformativeDefault[trans].ta_id+"'>"+transformativeDefault[trans].at_text+"</option> ";
  167. }
  168. }
  169. var $buttonTA = $('<button/>', {
  170. 'type': 'button',
  171. 'class': 'btn btn-secondary',
  172. 'onclick': 'addTAselect("'+optionsForTa+'", "forTA-objective-'+objectives[objective].id+'-course-'+courses[objectives[objective].id][course].typ_course_id+'", '+annual_plan+', '+objectives[objective].id+', '+typ_objective_id+', 0)'
  173. });
  174. $buttonTA.append("+ Add TA");
  175. $divForTA.append($divForTASelects);
  176. $divForTA.append('<br>');
  177. $divForTA.append($buttonTA)
  178. courseshtml += $divForEach[0].innerHTML +"<br><br>";
  179. courseTAhtml += $divForTA[0].innerHTML +"<br><br>";
  180. }
  181. /*$divForTA = $('<div/>',{
  182. 'id':'objectiveTA-'+objectives[objective].id
  183. });
  184. $divForTASelects = $('<div/>', {
  185. 'id': 'forTA-objective-'+objectives[objective].id,
  186. 'class':'form-group',
  187. 'data-amount-ta':'0'
  188. });
  189. var optionsForTa = "<option value = '0'>Nothing Selected</option>";
  190. transformativeDefault = json.transformative_actions;
  191. optionsForTa+= "<optgroup label='Default'>";
  192. for(trans in transformativeDefault){
  193. optionsForTa+= "<option value='"+transformativeDefault[trans].id+"'>"+transformativeDefault[trans].at_text+"</option> ";
  194. }
  195. optionsForTa+='</optgroup>';
  196. transformativeDefault = json.custom_transformative[objectives[objective].id];
  197. if(transformativeDefault!= undefined){
  198. optionsForTa+="<optgroup label = 'Custom'>";
  199. for(trans in transformativeDefault){
  200. optionsForTa+= "<option value='"+transformativeDefault[trans].id+"'>"+transformativeDefault[trans].at_text+"</option> ";
  201. }
  202. }
  203. var $buttonTA = $('<button/>', {
  204. 'type': 'button',
  205. 'class': 'btn btn-secondary',
  206. 'onclick': 'addTAselect("'+optionsForTa+'", "forTA-objective-'+objectives[objective].id+'", '+annual_plan+', '+objectives[objective].id+', '+typ_objective_id+', 0)'
  207. });
  208. $buttonTA.append("+ Add TA");
  209. $divForTA.append($divForTASelects);
  210. $divForTA.append('<br>');
  211. $divForTA.append($buttonTA)
  212. */
  213. table.row.add([
  214. objectivesHTML,
  215. courseshtml,
  216. courseTAhtml
  217. ]);
  218. table.draw();
  219. for(course in courses[objectives[objective].id]){
  220. typ_course_id = courses[objectives[objective].id][course].typ_course_id
  221. if(json.annual_plans_transformative[objectives[objective].id][typ_course_id].length){
  222. for(i=0; i<json.annual_plans_transformative[objectives[objective].id][typ_course_id].length; i++){
  223. selected_ta = json.annual_plans_transformative[objectives[objective].id][typ_course_id][i].trans_id;
  224. addTAselect(optionsForTa, "forTA-objective-"+objectives[objective].id+'-course-'+typ_course_id, annual_plan, objectives[objective].id, typ_course_id, selected_ta);
  225. }
  226. }
  227. else{
  228. addTAselect(optionsForTa, "forTA-objective-"+objectives[objective].id+'-course-'+typ_course_id, annual_plan, objectives[objective].id, typ_course_id, 0);
  229. }
  230. if(json.selected_criteria[objectives[objective].id][typ_course_id].length){
  231. for(i =0; i<json.selected_criteria[objectives[objective].id][typ_course_id].length; i++){
  232. 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);
  233. $('#criteriaFor'+objectives[objective].id+"-course-"+typ_course_id+'_'+i).val(json.selected_criteria[objectives[objective].id][typ_course_id][i].criteria_id);
  234. $('#criteriaFor'+objectives[objective].id+"-course-"+typ_course_id+'_'+i).data('old-criteria', json.selected_criteria[objectives[objective].id][typ_course_id][i].criteria_id);
  235. $('#criteriaFor'+objectives[objective].id+"-course-"+typ_course_id+'_'+i).selectpicker('refresh');
  236. } // Update display
  237. }
  238. else{
  239. addCriteriaTest("forObjective-"+objectives[objective].id+"-course-"+typ_course_id, ""+objectives[objective].id+"-course-"+typ_course_id+"", ""+typ_course_id+"", 0, options);
  240. $('#criteriaFor'+objectives[objective].id+"-course-"+typ_course_id+'_0').val(0);
  241. $('#criteriaFor'+objectives[objective].id+"-course-"+typ_course_id+'_0').data('old-criteria', 0);
  242. $('#criteriaFor'+objectives[objective].id+"-course-"+typ_course_id+'_0').selectpicker('refresh');
  243. }
  244. }
  245. }
  246. table.draw();
  247. }
  248. else
  249. {
  250. $('table').hide();
  251. }
  252. },
  253. 'json'
  254. );
  255. }
  256. function posttoTransAnnual(annual_id, selectTransId, typ_course_id){
  257. ta = $("#"+selectTransId).val();
  258. old_ta = $("#"+selectTransId).data('old-TA');
  259. if(ta == "0")return;
  260. $.post("../annual-plan-postTA",
  261. {annual_id : annual_id,
  262. TA_id:ta,
  263. typ_course_id : typ_course_id,
  264. old_ta:old_ta
  265. },
  266. function(message){
  267. $("#"+selectTransId).data('old-TA', ta);
  268. }
  269. )
  270. }
  271. function addTAselect(options, master_div, annual_plan_id, objective_id, typ_course_id, selected_ta){
  272. var $div = $('<div/>', {
  273. 'class': 'form-group '
  274. });
  275. counter = parseInt($('#'+master_div).data('amount-ta'));
  276. var selectTA = $('<select/>',{
  277. 'class': "selectpicker form-control",
  278. 'data-live-search':'true',
  279. 'data-old-TA' :'0',
  280. 'data-width': '180px',
  281. 'id': 'transformativeForObjective'+master_div+'_'+counter,
  282. 'onchange':'posttoTransAnnual('+annual_plan_id+', "transformativeForObjective'+master_div+'_'+counter+'", '+typ_course_id+')'
  283. });
  284. selectTA.append(options);
  285. selectTA.appendTo($div);
  286. selectTA.val(selected_ta);
  287. selectTA.data('old-TA', selected_ta);
  288. selectTA.selectpicker('refresh');
  289. $span = $('<span/>', {
  290. 'id':'close',
  291. 'onclick':' postDeleteTA('+annual_plan_id+', "transformativeForObjective'+master_div+'_'+counter+'", '+typ_course_id+'); this.parentNode.parentNode.removeChild(this.parentNode);return false;'
  292. }).html('x');
  293. $span.appendTo($div);
  294. $div.append("<br><br>");
  295. $('#'+master_div).append("<br>");
  296. $div.appendTo($('#'+master_div));
  297. $('#'+master_div).data('amount-ta', counter+1);
  298. }
  299. function postDeleteTA(annual_id, selectTransId, typ_course_id){
  300. ta = $("#"+selectTransId).val();
  301. if(ta == "0")return;
  302. $.post("../annual-plan-deleteTA",
  303. {annual_id : annual_id,
  304. TA_id:ta,
  305. typ_id : typ_course_id,
  306. }
  307. );
  308. parent = $("#"+selectTransId).parent().parent().parent();
  309. counter = parseInt(parent.data('amount-ta'));
  310. parent.data('amount-ta', counter-1);
  311. }
  312. function postToAnnualPlans(typ_course_id, criteria_select){
  313. var criteria = $('#'+criteria_select).val();
  314. var oldCriteria = $('#'+criteria_select).data('old-criteria');
  315. var criteriaNode = document.getElementById(criteria_select).parentNode.parentNode.parentNode;
  316. var annual = criteriaNode.dataset.annualPlan;
  317. $.post("../annual-plan-postOnChange",
  318. {criteria : criteria,
  319. typ_course_id : typ_course_id,
  320. annual_plan : annual,
  321. old_criteria :oldCriteria
  322. },
  323. function(message){
  324. if(message =="Duplicate entry, please choose another criteria."){
  325. alert(message)
  326. }
  327. else{
  328. $('#'+criteria_select).data('old-criteria', criteria);
  329. changed = true;
  330. }
  331. })
  332. }
  333. function addCriteriaTest(div, new_id_for_select, typ_course_id, i=null, options) {
  334. if(!i) amount_select = $('#'+div).data("amount-select");
  335. else amount_select = i;
  336. $select = $('<select/>',{
  337. 'class': "selectpicker form-control",
  338. 'data-live-search':'true',
  339. 'data-old-criteria' :'0',
  340. 'data-width': '180px',
  341. 'id': 'criteriaFor'+new_id_for_select+'_'+amount_select,
  342. 'onchange':'postToAnnualPlans('+typ_course_id+', "criteriaFor'+new_id_for_select+'_'+amount_select+'")'
  343. })
  344. var $div = $('<div/>', {
  345. 'id': 'courseSelect_' + new_id_for_select +'_'+amount_select,
  346. 'class': 'form-group '
  347. });
  348. $select.append(options);
  349. $select.appendTo($div);
  350. $span = $('<span/>', {
  351. 'id':'close',
  352. 'onclick':' postDelete('+typ_course_id+', "criteriaFor'+new_id_for_select+'_'+amount_select+'"); this.parentNode.parentNode.removeChild(this.parentNode);return false;'
  353. }).html('x');
  354. $div.append($span);
  355. $div.append("<br><br>")
  356. $("#forObjective-"+new_id_for_select).append("<br>");
  357. $div.appendTo($("#forObjective-"+new_id_for_select));
  358. $select.selectpicker('refresh');
  359. $("#forObjective-"+new_id_for_select).data("amount-select", amount_select+1);
  360. }
  361. $('#allOutcomes').hide();
  362. function postDelete(typ_course_id, criteria_select){
  363. var criteria = $('#'+criteria_select).val();
  364. var oldCriteria = $('#'+criteria_select).data('old-criteria');
  365. var criteriaNode = document.getElementById(criteria_select).parentNode.parentNode.parentNode;
  366. var annual = criteriaNode.dataset.annualPlan;
  367. $.post("../annual-plan-deleteCriteria",
  368. {criteria : criteria,
  369. typ_course_id : typ_course_id,
  370. annual_plan : annual,
  371. old_criteria :oldCriteria
  372. });
  373. }
  374. function fetchInfo(id){
  375. annual_id = $("#"+id).val();
  376. program_id = {{$program->id}};
  377. $.post("{{URL::action('AnnualPlansController@fetchInfo')}}",
  378. {
  379. id:annual_id,
  380. program_id:program_id
  381. },
  382. function(json){
  383. div = $('<div/>', {
  384. 'class':'list-group',
  385. 'id':'list'
  386. });
  387. header5 = $('<h5/>', {
  388. 'style':"padding-left: 10px"
  389. }).html("First Semester");
  390. div.append(header5);
  391. list = '';
  392. for(outcome in json.outcomes.first){
  393. 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>";
  394. }
  395. div.append(list);
  396. header4 = $('<h5/>', {
  397. 'style':"padding-left: 10px"
  398. }).html("Second Semester");
  399. div.append(header4);
  400. list = '';
  401. for(outcome in json.outcomes.second){
  402. 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>";
  403. }
  404. div.append(list);
  405. html = div[0].innerHTML;
  406. $("#allOutcomes").html(div[0].innerHTML);
  407. $("#allOutcomes").show();
  408. },
  409. "json",
  410. );
  411. }
  412. function deleteObjective(objectiveSelectDiv, closeObj){
  413. $('#'+objectiveSelectDiv).remove();
  414. $('#'+closeObj).remove();
  415. $('#'+div).data("amount-select", $('#'+div).data("amount-select")-1);
  416. }
  417. </script>
  418. @stop
  419. @section('included-js')
  420. @include('global._datatables_js')
  421. @stop