No Description

annual-plans.blade.php 18KB

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