Nenhuma descrição

annual-plans.blade.php 21KB

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