Açıklama Yok

annual-plans.blade.php 28KB

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