Keine Beschreibung

annual-plans.blade.php 17KB

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