暂无描述

overview2.blade.php 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. @extends('layouts.master_sin_semesterbar')
  2. @section('navigation')
  3. @include('local.managers.admins._new_navigation')
  4. @stop
  5. @section('main')
  6. <div>
  7. <div class="">
  8. <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
  9. <script type="text/javascript">
  10. function make_chart(outcomes_info, semesters) {
  11. //////// Get values ready for chart
  12. var target_line = {{ $target }};
  13. var x_label = 'Learning Outcomes';
  14. var y_label = 'Percent of students';
  15. var outcomes_labels = Array();
  16. var i = 0;
  17. outcomes_info.forEach(eachOutcome);
  18. function eachOutcome(outcome, index) {
  19. outcomes_labels.push({
  20. v: (index + 1),
  21. f: outcome.name
  22. });
  23. i = i + 1;
  24. }
  25. //
  26. var outcomes_data = Array();
  27. var legend = Array();
  28. legend.push('');
  29. legend.push('Target');
  30. $.each(semesters, function(index, semester) {
  31. var name = semester.name;
  32. name = name.split(' ');
  33. var semester_number = name[0];
  34. var semester_year = name[2];
  35. if (semester_number == 'First') {
  36. semester_number = '1';
  37. } else if (semester_number == 'Second') {
  38. semester_number = '2';
  39. }
  40. name = semester_year + " Sem " + semester_number;
  41. legend.push(name);
  42. });
  43. outcomes_data.push(legend);
  44. //
  45. var hidden_values = Array();
  46. hidden_values.push(0);
  47. hidden_values.push(target_line);
  48. var k = 0;
  49. while (k < semesters.length) {
  50. hidden_values.push(null);
  51. k = k + 1;
  52. }
  53. //
  54. outcomes_data.push(hidden_values);
  55. // console.log(semesters)
  56. $.each(outcomes_info, function(index, outcome) {
  57. var temp_outcome_grouping_info = Array();
  58. temp_outcome_grouping_info.push({
  59. v: (index + 1),
  60. f: "Students acheiving Learning Outcomes"
  61. });
  62. temp_outcome_grouping_info.push(target_line);
  63. // console.log(outcome.semesters)
  64. var i = 0;
  65. $.each(outcome.semesters, function(index, semester) {
  66. // if semester is not the same, insert null.
  67. // else, insert info from expected semester.
  68. if (semester.name != semesters[i].name) {
  69. while (semester.name != semesters[i].name && i < semesters.length) {
  70. temp_outcome_grouping_info.push(null);
  71. i = i + 1;
  72. }
  73. }
  74. i = i + 1;
  75. var total = semester.total_evaluated;
  76. var achievers = semester.total_achieved;
  77. var percentage = achievers / total;
  78. var display_percentage = percentage * 100;
  79. temp_outcome_grouping_info.push({
  80. v: percentage,
  81. f: '\nAchieved by ' + display_percentage.toFixed(2) + '%\n(' + achievers +
  82. ' achievers and ' + total + ' participants)'
  83. });
  84. });
  85. var i = temp_outcome_grouping_info.length;
  86. while (i < semesters.length + 2) {
  87. temp_outcome_grouping_info.push(null);
  88. i = i + 1;
  89. }
  90. outcomes_data.push(temp_outcome_grouping_info);
  91. });
  92. var last_hidden_values = [...hidden_values];
  93. last_hidden_values[0] = i + 1;
  94. outcomes_data.push(last_hidden_values);
  95. ////////
  96. google.charts.load('current', {
  97. packages: ['corechart']
  98. }).then(function() {
  99. var data = google.visualization.arrayToDataTable(outcomes_data);
  100. // var data = google.visualization.arrayToDataTable([
  101. // ['', 'Target', '2020-21 Sem 2', '2021-22 Sem 1', '2021-22 Sem 2'],
  102. // [0, 0.80, null, null, null],
  103. // [{v:1,f:"Students acheiving Learning Outcomes"}, 0.80, {v:0.8275,f:82.75}, {v:0.9075,f:'\nAchieved by '+(90.75).toString()+'%\n(60 achievers and 80 participants)'}, {v:0.8475,f:84.75}],
  104. // [{v:2,f:"Students acheiving Learning Outcomes"}, 0.80, {v:0.7475,f:74.75}, {v:0.8775,f:87.75}, {v:0.9975,f:60.75}],
  105. // [{v:3,f:"Students acheiving Learning Outcomes"}, 0.80, {v:0.6875,f:68.75}, {v:0.9175,f:91.75}, {v:0.8475,f:84.75}],
  106. // [4, 0.80, null, null, null]
  107. // ]);
  108. var chartDiv = document.getElementById('chart_div');
  109. var chart = new google.visualization.ColumnChart(chartDiv);
  110. chart.draw(data, {
  111. // colors: ['lime', 'magenta'],
  112. hAxis: {
  113. title: x_label,
  114. ticks: outcomes_labels,
  115. viewWindow: {
  116. min: 0.5,
  117. max: outcomes_info.length + 0.5 // el total de outcomes + 0.5
  118. },
  119. textStyle: {
  120. fontSize: 10,
  121. bold: true,
  122. }
  123. },
  124. legend: 'right',
  125. series: {
  126. 0: {
  127. type: 'line'
  128. }
  129. },
  130. title: ' ',
  131. chartArea: {
  132. width: '70%',
  133. // top: 10,
  134. // height: '50%'
  135. },
  136. vAxis: {
  137. title: y_label,
  138. format: 'percent',
  139. viewWindow: {
  140. min: 0,
  141. max: 1
  142. }
  143. }
  144. });
  145. });
  146. }
  147. // labels for each outcome grouping
  148. var outcomes_info = <?= json_encode($outcomes, JSON_HEX_TAG) ?>;
  149. var semesters = <?= json_encode($semesters, JSON_HEX_TAG) ?>;
  150. // console.log(outcomes_info);
  151. make_chart(outcomes_info, semesters);
  152. </script>
  153. <script src="https://www.gstatic.com/charts/loader.js"></script>
  154. <div class="">
  155. <div class="filters">
  156. <div class="row" style="display: flex;">
  157. <div class="category">
  158. <label for="is_graduate">Level</label>
  159. <div class="select">
  160. <select class="selectpicker" name="is_graduate" id="is_graduate">
  161. <option value="0" selected="selected">Undergradute</option>
  162. <option value="1">Graduate</option>
  163. </select>
  164. </div>
  165. </div>
  166. </div>
  167. <div class="row" style="display: flex;">
  168. <div class="category">
  169. <label for="school">School</label>
  170. <div class="select">
  171. <select multiple class="selectpicker" name="school" id="school">
  172. <option value="0" selected="selected">All</option>
  173. @foreach ($filters['school'] as $school)
  174. <option value="{{ $school->id }}">{{ $school->name }}</option>
  175. @endforeach
  176. </select>
  177. </div>
  178. </div>
  179. <div class="category">
  180. <label for="program">Academic Program</label>
  181. <div class="select">
  182. <select multiple class="selectpicker" name="program" id="program">
  183. <option value="0" selected="selected">All</option>
  184. @foreach ($filters['program'] as $program)
  185. <option value="{{ $program->id }}">{{ $program->name }}</option>
  186. @endforeach
  187. </select>
  188. </div>
  189. </div>
  190. </div>
  191. <div class="row" style="display: flex;">
  192. <div class="category">
  193. <label for="semester">Semester</label>
  194. <div class="select">
  195. <select multiple class="selectpicker" name="semester" id="semester">
  196. <option value="0" selected="selected">All</option>
  197. @foreach ($filters['semester'] as $semester)
  198. <option value="{{ $semester->id }}">{{ $semester->name }}</option>
  199. @endforeach
  200. </select>
  201. </div>
  202. </div>
  203. <div class="category">
  204. <label for="year">Academic Year</label>
  205. <div class="select">
  206. <select multiple class="selectpicker" name="year" id="year">
  207. <option value="0" selected="selected">All</option>
  208. @foreach ($filters['year'] as $year)
  209. <option value="{{ $year->id }}">{{ $year->start }}</option>
  210. @endforeach
  211. </select>
  212. </div>
  213. </div>
  214. <div class="category">
  215. <label for="outcome">Learning Outcomes</label>
  216. <div class="select">
  217. <select multiple class="selectpicker" name="outcome" id="outcome">
  218. <option value="0" selected="selected">All</option>
  219. @foreach ($filters['outcome'] as $outcome)
  220. <option value="{{ $outcome->id }}">{{ $outcome->name }}</option>
  221. @endforeach
  222. </select>
  223. </div>
  224. </div>
  225. </div>
  226. </div>
  227. <h4 class="container">
  228. <b>Percent of Students Achieving Learning Outcomes By Academic Session</b>
  229. </h4>
  230. <div class="container" style="height:500px; width:1300px;" id="chart_div"></div>
  231. <div class="" style="padding-left: 25px;">
  232. <h5>
  233. <b>Annotation</b>
  234. </h5>
  235. The target line represents the expected percent of students achieving the learning
  236. outcome({{ $target * 100 }}%).
  237. </div>
  238. </div>
  239. </div>
  240. </div>
  241. @stop
  242. @section('included-js')
  243. <!-- HighCharts -->
  244. <script src="{{ asset('vendor/highcharts/highcharts.js') }}"></script>
  245. @stop
  246. @section('javascript')
  247. $(document).ready(function()
  248. {
  249. $("#year").parent().parent().parent().hide();
  250. // when a filter is focused
  251. var previous;
  252. $(".category").find("button").focus(function() {
  253. previous = Array();
  254. $(this).parent().find("select option:selected").each(function() {
  255. previous.push(this.value);
  256. });
  257. });
  258. // when a filter is changed
  259. $(".category").find("select").change(function() {
  260. var new_value = Array();
  261. $(this).parent().find("select option:selected").each(function() {
  262. new_value.push(this.value);
  263. });
  264. //if statements so that "All" only can be selected alone and dont allow selecting no options
  265. if(jQuery.inArray("0",new_value) !== -1 && jQuery.inArray("0",previous) === -1){
  266. $(this).parent().find("select option:selected").each(function() {
  267. $(this).removeAttr('selected');
  268. $(this).parent().val(0);
  269. //$('.selectpicker').selectpicker('refresh');
  270. new_value = ["0"];
  271. });
  272. }else if(jQuery.inArray("0",new_value) !== -1 && jQuery.inArray("0",previous) !== -1 && new_value.length >
  273. previous.length){
  274. $(this).parent().find("select option:selected").each(function() {
  275. if(this.value == "0"){
  276. $(this).removeAttr('selected');
  277. //$('.selectpicker').selectpicker('refresh');
  278. new_value = Array(new_value[1]);
  279. }
  280. });
  281. }else if(new_value.length == 0){
  282. $(this).parent().find("select").val(0);
  283. //$('.selectpicker').selectpicker('refresh');
  284. new_value = ["0"];
  285. }
  286. previous = new_value;
  287. // get values from all selects
  288. var schools = $("#school").val();
  289. var programs = $("#program").val();
  290. var semesters = $("#semester").val();
  291. var years = $("#year").val();
  292. var outcomes = $("#outcome").val();
  293. var outcomes = $("#outcome").val();
  294. var is_graduate = $("#is_graduate").val();
  295. // query the values and get new data for chart
  296. $.post(
  297. "{{ URL::action('AdministratorsController@overview2_filter_results') }}",
  298. {
  299. schools: (schools),
  300. programs: (programs),
  301. semesters: (semesters),
  302. years: (years),
  303. outcomes: (outcomes),
  304. is_graduate: (is_graduate),
  305. },
  306. function(data)
  307. {
  308. var filters = data.filters;
  309. var outcomes_info = data.outcomes_info;
  310. var semesters = data.semesters;
  311. //////// update chart
  312. make_chart(outcomes_info,semesters);
  313. ////////update filters
  314. var new_all = $('
  315. <option />',{
  316. 'value': "0",
  317. 'html': "All",
  318. });;
  319. {{-- //update school filter
  320. var school_filter = $("#school");
  321. var new_school_options = filters.school;
  322. school_filter.find("option").remove();
  323. school_filter.append(new_all.clone(true));
  324. $.each(new_school_options, function(index, school)
  325. {
  326. var value = school.id;
  327. var html = school.name;
  328. var new_option = $('<option/>',{
  329. 'value': value,
  330. 'html': html,
  331. });;
  332. school_filter.append(new_option);
  333. }); --}}
  334. //update school filter
  335. var school_filter = $("#school");
  336. var school_selected_options = Array();
  337. school_filter.find("option:selected").each(function() {
  338. school_selected_options.push(this.value);
  339. });
  340. var new_school_options = filters.school;
  341. school_filter.find("option").remove();
  342. if(Array("0")[0] == school_selected_options[0]){
  343. school_filter.append(new_all.clone(true).attr("selected","selected"));
  344. } else{
  345. school_filter.append(new_all.clone(true));
  346. }
  347. $.each(new_school_options, function(index, school)
  348. {
  349. var value = school.id.toString();
  350. var html = school.name;
  351. var new_option;
  352. if(jQuery.inArray(value,school_selected_options) === -1){
  353. new_option = $('
  354. <option />',{
  355. 'value': value,
  356. 'html': html,
  357. });;
  358. }else{
  359. new_option = $('
  360. <option />',{
  361. 'value': value,
  362. 'html': html,
  363. 'selected': 'selected',
  364. });;
  365. }
  366. school_filter.append(new_option);
  367. });
  368. //update semester filter
  369. var semester_filter = $("#semester");
  370. var semester_selected_options = Array();
  371. semester_filter.find("option:selected").each(function() {
  372. semester_selected_options.push(this.value);
  373. });
  374. var new_semester_options = filters.semester;
  375. semester_filter.find("option").remove();
  376. if(Array("0")[0] == semester_selected_options[0]){
  377. semester_filter.append(new_all.clone(true).attr("selected","selected"));
  378. } else{
  379. semester_filter.append(new_all.clone(true));
  380. }
  381. $.each(new_semester_options, function(index, semester)
  382. {
  383. var value = semester.id.toString();
  384. var html = semester.name;
  385. var new_option;
  386. if(jQuery.inArray(value,semester_selected_options) === -1){
  387. new_option = $('
  388. <option />',{
  389. 'value': value,
  390. 'html': html,
  391. });;
  392. }else{
  393. new_option = $('
  394. <option />',{
  395. 'value': value,
  396. 'html': html,
  397. 'selected': 'selected',
  398. });;
  399. }
  400. semester_filter.append(new_option);
  401. });
  402. //update program filter
  403. var program_filter = $("#program");
  404. var program_selected_options = Array();
  405. program_filter.find("option:selected").each(function() {
  406. program_selected_options.push(this.value);
  407. });
  408. var new_program_options = filters.program;
  409. program_filter.find("option").remove();
  410. if(Array("0")[0] == program_selected_options[0]){
  411. program_filter.append(new_all.clone(true).attr("selected","selected"));
  412. } else{
  413. program_filter.append(new_all.clone(true));
  414. }
  415. $.each(new_program_options, function(index, program)
  416. {
  417. var value = program.id.toString();
  418. var html = program.name;
  419. var new_option;
  420. if(jQuery.inArray(value,program_selected_options) === -1){
  421. new_option = $('
  422. <option />',{
  423. 'value': value,
  424. 'html': html,
  425. });;
  426. }else{
  427. new_option = $('
  428. <option />',{
  429. 'value': value,
  430. 'html': html,
  431. 'selected': 'selected',
  432. });;
  433. }
  434. program_filter.append(new_option);
  435. });
  436. //update outcome filter
  437. var outcome_filter = $("#outcome");
  438. var outcome_selected_options = Array();
  439. outcome_filter.find("option:selected").each(function() {
  440. outcome_selected_options.push(this.value);
  441. });
  442. var new_outcome_options = filters.outcome;
  443. outcome_filter.find("option").remove();
  444. if(Array("0")[0] == outcome_selected_options[0]){
  445. outcome_filter.append(new_all.clone(true).attr("selected","selected"));
  446. } else{
  447. outcome_filter.append(new_all.clone(true));
  448. }
  449. $.each(new_outcome_options, function(index, outcome)
  450. {
  451. var value = outcome.id.toString();
  452. var html = outcome.name;
  453. var new_option;
  454. if(jQuery.inArray(value,outcome_selected_options) === -1){
  455. new_option = $('
  456. <option />',{
  457. 'value': value,
  458. 'html': html,
  459. });;
  460. }else{
  461. new_option = $('
  462. <option />',{
  463. 'value': value,
  464. 'html': html,
  465. 'selected': 'selected',
  466. });;
  467. }
  468. outcome_filter.append(new_option);
  469. });
  470. {{-- //update semester filter
  471. var semester_filter = $("#semester");
  472. var new_semester_options = filters.semester;
  473. semester_filter.find("option").remove();
  474. semester_filter.append(new_all.clone(true));
  475. $.each(new_semester_options, function(index, semester)
  476. {
  477. var value = semester.id;
  478. var html = semester.name;
  479. var new_option = $('<option/>',{
  480. 'value': value,
  481. 'html': html,
  482. });;
  483. semester_filter.append(new_option);
  484. }); --}}
  485. $('.selectpicker').selectpicker('refresh');
  486. }
  487. );
  488. });
  489. });
  490. {{-- @include('global.dummy-outcomes') --}}
  491. @stop