暂无描述

overview2.blade.php 17KB

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