Brak opisu

annual_report.blade.php 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  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. <select class="form-control selectpicker" id="annual_plan" onchange="fetchInfo('annual_plan')">
  21. <option value='0'> Nothing Selected</option>
  22. @foreach ($annual_plans as $an_plan)
  23. <option value={{ $an_plan->annual_id }}>Plan {{ $an_plan->academic_year }}</option>
  24. @endforeach
  25. </select>
  26. <br>
  27. <div id='allOutcomes'>
  28. </div>
  29. </div>
  30. <div class="col-md-9">
  31. <div id="outcome-display" class="panel panel-default">
  32. <div class="panel-heading">
  33. <h4 class=" panel-title" style="cursor:auto!important;">
  34. Primer Semestre 2019-2020
  35. </h4>
  36. </div>
  37. <div class="panel-body">
  38. <div id='outcomeInfo'>
  39. </div>
  40. <div id="tableOutcome">
  41. </div>
  42. <ul id="levelTabs" class="nav nav-tabs" role="tablist">
  43. </ul>
  44. <div id="allLists" class="tab-content">
  45. </div>
  46. <!-- <div class="table-responsive">
  47. <table class="table table-striped table-condensed datatable" style="table-layout: fixed ; width : 100%">
  48. <thead><tr><th>Objectives for courses</th><th>Criteria per Course</th><th>Transformative Actions</th></tr></thead>
  49. <tbody>
  50. </tbody>
  51. </table>
  52. </div>-->
  53. </div>
  54. </div>
  55. </div>
  56. <div class="col-md-9">
  57. <div class="no-outcome alert alert-info">
  58. <p>Select a Learning Outcome to view its information</p>
  59. </div>
  60. </div>
  61. </div>
  62. <script>
  63. function nextChar(c) {
  64. return String.fromCharCode(c.charCodeAt(0) + 1);
  65. }
  66. changed = false;
  67. $(document).ready(function() {
  68. // --------------------------------------------------------------------------
  69. // Page load
  70. // --------------------------------------------------------------------------
  71. // Hide accordion panel contents by default
  72. $('.panel-group .panel-body').hide();
  73. $('#outcome-display').parent().hide();
  74. // --------------------------------------------------------------------------
  75. // Functions
  76. // --------------------------------------------------------------------------
  77. // --------------------------------------------------------------------------
  78. // Events
  79. // --------------------------------------------------------------------------
  80. // When list item is clicked, load corresponding info
  81. });
  82. // Create everything
  83. function fetchEverything(li) {
  84. var outcome_id = $(li).data('outcome-id');
  85. var name = $(li).data('outcome-name');
  86. var semester_id = $(li).data('semester-id');
  87. var annual_plan_id = $(li).data('annual-plan');
  88. var typ_semester_outcome_id = $(li).data('typ-semester-outcome-id');
  89. $('#theChange').data('annual-plan', annual_plan);
  90. $.post(
  91. "{{ URL::action('AnnualPlansController@fetchReportWithOutcome') }}", {
  92. semester_id: semester_id,
  93. outcome_id: outcome_id,
  94. program_id: {{ $program->id }},
  95. annual_plan_id: annual_plan_id,
  96. typ_semester_outcome_id: typ_semester_outcome_id
  97. },
  98. function(outcome) {
  99. if (outcome.objectives) {
  100. $('table').show();
  101. $('#outcome-display').parent().show();
  102. $('#outcome-display .panel-title').html(name);
  103. $('#allLists').empty();
  104. $('#levelTabs').empty();
  105. $('.no-outcome').hide();
  106. if (outcome.outcome_program_goal) {
  107. outcome.outcome_program_goal = outcome.outcome_program_goal.expected_target;
  108. } else {
  109. outcome.outcome_program_goal = 'It has not been defined';
  110. }
  111. var outcomeHTML = "<h4>Performance of Students by Learning Outcome</h4>" +
  112. '<h5 style = "display: inline; margin:30px;">Target learning by learning outcome: </h5>' +
  113. '<p style = "display: inline;"> <i>>= ' + outcome.expected_outcome +
  114. ' of the attempts</i>' + '</p>' +
  115. '<br><h5 style = "display: inline; margin:30px;">Expected percent of students achieving the target by learning outcome: </h5>' +
  116. '<p style = "display: inline;"> <i>' + outcome.outcome_program_goal + '</i></p>';
  117. $('#outcomeInfo').html('<p class="outcome-definition">' + outcome.definition + '</p>' +
  118. outcomeHTML);
  119. //theStudentOutcomeTable = $("<table/>");
  120. //theStudentOutcomeTable.hide();
  121. ///$('#outcomeInfo').append(theStudentOutcomeTable);
  122. wholeDict = {};
  123. tableStudent = $('<table/>', {
  124. 'class': 'table table-striped table-condensed datatable'
  125. });
  126. tableStudent.html('<thead><tr>' +
  127. '<th>Student</th>' +
  128. '<th>Criteria Attempted</th>' +
  129. '<th>Criteria Achieved</th>' +
  130. '<th>Percentage</th>' +
  131. '<th>Outcome Achieved</th>' +
  132. '</tr></thead><tbody></tbody>');
  133. $.each(outcome.objectives, function(index, objective) {
  134. li = $('<li/>', {
  135. 'role': 'presentation'
  136. });
  137. a = $('<a/>', {
  138. 'data-toggle': 'tab',
  139. 'href': '#' + objective.id,
  140. 'role': 'tab'
  141. }).html('Objective ' + (index + 1));
  142. li.append(a);
  143. $('#levelTabs').append(li);
  144. objective_title = "<h3>" + objective.text + '</h3>';
  145. div = $('<div/>', {
  146. 'role': 'tabpanel',
  147. 'class': 'tab-pane',
  148. 'id': objective.id
  149. }).html(objective_title);
  150. div.appendTo($('#allLists'))
  151. if (objective.courses) {
  152. $.each(objective.courses, function(index, course_code) {
  153. if (course_code.criteria.length) {
  154. $.each(course_code.students, function(index, student) {
  155. if (wholeDict[student.student_id] === undefined) {
  156. wholeDict[student.student_id] = {
  157. 'student': student.student_id,
  158. 'criteria_attempted': 0,
  159. 'criteria_achieved': 0
  160. }
  161. }
  162. wholeDict[student.student_id][
  163. "criteria_attempted"
  164. ] += student
  165. .criteria_attempted;
  166. wholeDict[student.student_id][
  167. "criteria_achieved"
  168. ] += student
  169. .criteria_achieved;
  170. });
  171. div.append(
  172. '<p>The following results are from the courses in the selected semester with the focused criteria in the selected annual plan</p>'
  173. );
  174. table = $('<table/>', {
  175. 'class': 'table table-striped table-condensed datatable'
  176. }).html('<thead><th>Criterion</th><th>' +
  177. 'Number of Students Assessed </th>' +
  178. '<th>Number of students that achieved the target</th></thead>'
  179. );
  180. tbody = $('<tbody/>')
  181. $.each(course_code.criteria, function(index, criterion) {
  182. tr = $('<tr/>').append(
  183. "<td>" + criterion.name + "</td>" +
  184. "<td>" + criterion.criteria_attempted +
  185. "</td>" +
  186. "<td>" + criterion.criteria_achieved +
  187. "</td>"
  188. );
  189. tbody.append(tr);
  190. });
  191. table.append(tbody);
  192. Course_and_transformative = '<h3>' + course_code.code + ' ' +
  193. course_code.number + '</h3><hr>';
  194. if (course_code.transforming_actions.length) {
  195. Course_and_transformative +=
  196. '<h5> This course was tied to the following transformative actions</h5>';
  197. Course_and_transformative += '<ol>';
  198. $.each(course_code.transforming_actions, function(index,
  199. transformative_action) {
  200. Course_and_transformative += '<li><p><strong>' +
  201. transformative_action.at_text +
  202. '</strong>: ' + transformative_action
  203. .description + '</p></li>'
  204. })
  205. }
  206. div.append(Course_and_transformative)
  207. div.append(table);
  208. table.DataTable();
  209. }
  210. })
  211. } else {
  212. div.append('<div class="no-outcome alert alert-info"' +
  213. '<p>No Course in plan has assessed yet</p>' +
  214. '</div>')
  215. }
  216. })
  217. theArray = [];
  218. $('#tableOutcome').html(tableStudent);
  219. //tableStudent.appendTo($('#outcomeInfo'));
  220. tableStudent = tableStudent.DataTable({
  221. dom: 'Bfrtip',
  222. buttons: [
  223. 'csv', 'excel', 'pdf', 'print'
  224. ]
  225. });
  226. students_attempted = 0;
  227. students_achieved = 0;
  228. $.each(wholeDict, function(key, dict) {
  229. if (dict.criteria_attempted) {
  230. students_attempted += 1;
  231. percentage = ((dict.criteria_achieved / dict.criteria_attempted) * 100).toFixed(
  232. 2);
  233. if (parseFloat(percentage) >= parseFloat(outcome.expected_outcome)) {
  234. achieved = "Yes"
  235. students_achieved += 1;
  236. } else achieved = "No"
  237. } else {
  238. percentage = "N/A"
  239. achieved = "N/A"
  240. }
  241. tableStudent.row.add([
  242. dict.student,
  243. dict.criteria_attempted,
  244. dict.criteria_achieved,
  245. percentage,
  246. achieved
  247. ]);
  248. })
  249. tableStudent.draw();
  250. if (students_attempted) {
  251. studentPercentage = ((students_achieved / students_attempted) * 100).toFixed(2);
  252. if (parseFloat(studentPercentage) >= parseFloat(outcome.outcome_program_goal)) {
  253. FinalReport = "<br><p><strong>The students achieved the Learning Outcome with " +
  254. studentPercentage + "% of students achieving.</strong></p>";
  255. } else {
  256. FinalReport = "<br><p><strong>The students did not achieve the Learning Outcome with " +
  257. studentPercentage + "% of students achieving.</strong></p>";
  258. }
  259. }
  260. $("#outcomeInfo").append(FinalReport)
  261. /* table.row.add([
  262. objectivesHTML,
  263. courseshtml,
  264. courseTAhtml
  265. ]);
  266. table.draw();
  267. */
  268. } else {
  269. $('table').hide();
  270. }
  271. }
  272. );
  273. }
  274. function posttoTransAnnual(annual_id, selectTransId, typ_course_id) {
  275. ta = $("#" + selectTransId).val();
  276. old_ta = $("#" + selectTransId).data('old-TA');
  277. if (ta == "0") return;
  278. $.post("../annual-plan-postTA", {
  279. annual_id: annual_id,
  280. TA_id: ta,
  281. typ_course_id: typ_course_id,
  282. old_ta: old_ta
  283. },
  284. function(message) {
  285. $("#" + selectTransId).data('old-TA', ta);
  286. }
  287. )
  288. }
  289. function addTAselect(options, master_div, annual_plan_id, objective_id, typ_course_id, selected_ta) {
  290. var $div = $('<div/>', {
  291. 'class': 'form-group '
  292. });
  293. counter = parseInt($('#' + master_div).data('amount-ta'));
  294. var selectTA = $('<select/>', {
  295. 'class': "selectpicker form-control",
  296. 'data-live-search': 'true',
  297. 'data-old-TA': '0',
  298. 'data-width': '180px',
  299. 'id': 'transformativeForObjective' + master_div + '_' + counter,
  300. 'onchange': 'posttoTransAnnual(' + annual_plan_id + ', "transformativeForObjective' + master_div +
  301. '_' + counter + '", ' + typ_course_id + ')'
  302. });
  303. selectTA.append(options);
  304. selectTA.appendTo($div);
  305. selectTA.val(selected_ta);
  306. selectTA.data('old-TA', selected_ta);
  307. selectTA.selectpicker('refresh');
  308. $span = $('<span/>', {
  309. 'id': 'close',
  310. 'onclick': ' postDeleteTA(' + annual_plan_id + ', "transformativeForObjective' + master_div + '_' +
  311. counter + '", ' + typ_course_id +
  312. '); this.parentNode.parentNode.removeChild(this.parentNode);return false;'
  313. }).html('x');
  314. $span.appendTo($div);
  315. $div.append("<br><br>");
  316. $('#' + master_div).append("<br>");
  317. $div.appendTo($('#' + master_div));
  318. $('#' + master_div).data('amount-ta', counter + 1);
  319. }
  320. function postDeleteTA(annual_id, selectTransId, typ_course_id) {
  321. ta = $("#" + selectTransId).val();
  322. if (ta == "0") return;
  323. $.post("../annual-plan-deleteTA", {
  324. annual_id: annual_id,
  325. TA_id: ta,
  326. typ_id: typ_course_id,
  327. });
  328. parent = $("#" + selectTransId).parent().parent().parent();
  329. counter = parseInt(parent.data('amount-ta'));
  330. parent.data('amount-ta', counter - 1);
  331. }
  332. function postToAnnualPlans(typ_course_id, criteria_select) {
  333. var criteria = $('#' + criteria_select).val();
  334. var oldCriteria = $('#' + criteria_select).data('old-criteria');
  335. var criteriaNode = document.getElementById(criteria_select).parentNode.parentNode.parentNode;
  336. var annual = criteriaNode.dataset.annualPlan;
  337. $.post("../annual-plan-postOnChange", {
  338. criteria: criteria,
  339. typ_course_id: typ_course_id,
  340. annual_plan: annual,
  341. old_criteria: oldCriteria
  342. },
  343. function(message) {
  344. if (message == "Duplicate entry, please choose another criteria.") {
  345. alert(message)
  346. } else {
  347. $('#' + criteria_select).data('old-criteria', criteria);
  348. changed = true;
  349. }
  350. })
  351. }
  352. function addCriteriaTest(div, new_id_for_select, typ_course_id, i = null, options) {
  353. if (!i) amount_select = $('#' + div).data("amount-select");
  354. else amount_select = i;
  355. $select = $('<select/>', {
  356. 'class': "selectpicker form-control",
  357. 'data-live-search': 'true',
  358. 'data-old-criteria': '0',
  359. 'data-width': '180px',
  360. 'id': 'criteriaFor' + new_id_for_select + '_' + amount_select,
  361. 'onchange': 'postToAnnualPlans(' + typ_course_id + ', "criteriaFor' + new_id_for_select + '_' +
  362. amount_select + '")'
  363. })
  364. var $div = $('<div/>', {
  365. 'id': 'courseSelect_' + new_id_for_select + '_' + amount_select,
  366. 'class': 'form-group '
  367. });
  368. $select.append(options);
  369. $select.appendTo($div);
  370. $span = $('<span/>', {
  371. 'id': 'close',
  372. 'onclick': ' postDelete(' + typ_course_id + ', "criteriaFor' + new_id_for_select + '_' +
  373. amount_select + '"); this.parentNode.parentNode.removeChild(this.parentNode);return false;'
  374. }).html('x');
  375. $div.append($span);
  376. $div.append("<br><br>")
  377. $('#' + div).append("<br>");
  378. $div.appendTo($("#" + div));
  379. $select.selectpicker('refresh');
  380. $("#" + div).data("amount-select", amount_select + 1);
  381. }
  382. $('#allOutcomes').hide();
  383. function postDelete(typ_course_id, criteria_select) {
  384. var criteria = $('#' + criteria_select).val();
  385. var oldCriteria = $('#' + criteria_select).data('old-criteria');
  386. var criteriaNode = document.getElementById(criteria_select).parentNode.parentNode.parentNode;
  387. var annual = criteriaNode.dataset.annualPlan;
  388. $.post("../annual-plan-deleteCriteria", {
  389. criteria: criteria,
  390. typ_course_id: typ_course_id,
  391. annual_plan: annual,
  392. old_criteria: oldCriteria
  393. });
  394. }
  395. function fetchInfo(id) {
  396. annual_id = $("#" + id).val();
  397. program_id = {{ $program->id }};
  398. $.post("{{ URL::action('AnnualPlansController@fetchInfo') }}", {
  399. id: annual_id,
  400. program_id: program_id
  401. },
  402. function(json) {
  403. div = $('<div/>', {
  404. 'class': 'list-group',
  405. 'id': 'list'
  406. });
  407. if (json.outcomes.first) {
  408. header5 = $('<h5/>', {
  409. 'style': "padding-left: 10px"
  410. }).html("First Semester");
  411. div.append(header5);
  412. list = '';
  413. for (outcome in json.outcomes.first) {
  414. list +=
  415. "<li style='padding-left: 25px' onclick = 'fetchEverything(this)' data-annual-plan = '" +
  416. json.annual_plans.id + "' data-typ-semester-outcome-id ='" + json.outcomes.first[
  417. outcome].typ_semester_outcome_id + "' data-semester-id = '" + json.allSemesterOrder
  418. .first.id +
  419. "' data-outcome-id='" + json.outcomes.first[outcome].id + "' data-outcome-name ='" +
  420. json
  421. .outcomes.first[outcome].name + "' class='list-group-item' >" + json.outcomes.first[
  422. outcome]
  423. .name + " </li>";
  424. }
  425. div.append(list);
  426. }
  427. if (json.outcomes.second) {
  428. header4 = $('<h5/>', {
  429. 'style': "padding-left: 10px"
  430. }).html("Second Semester");
  431. div.append(header4);
  432. list = '';
  433. for (outcome in json.outcomes.second) {
  434. list +=
  435. "<li style='padding-left: 25px' onclick = 'fetchEverything(this)' data-annual-plan = '" +
  436. json.annual_plans.id + "' data-typ-semester-outcome-id ='" + json.outcomes.second[
  437. outcome].typ_semester_outcome_id + "'data-semester-id = '" + json.allSemesterOrder
  438. .second.id +
  439. "' data-outcome-id='" + json.outcomes.second[outcome].id + "' data-outcome-name ='" +
  440. json
  441. .outcomes.second[outcome].name + "' class='list-group-item' >" + json.outcomes.second[
  442. outcome].name + " </li>";
  443. }
  444. div.append(list);
  445. }
  446. html = div[0].innerHTML;
  447. $("#allOutcomes").html(div[0].innerHTML);
  448. $("#allOutcomes").show();
  449. },
  450. "json",
  451. );
  452. }
  453. function deleteObjective(objectiveSelectDiv, closeObj) {
  454. $('#' + objectiveSelectDiv).remove();
  455. $('#' + closeObj).remove();
  456. $('#' + div).data("amount-select", $('#' + div).data("amount-select") - 1);
  457. }
  458. </script>
  459. @stop
  460. @section('included-js')
  461. @include('global._datatables_js')
  462. @stop