No Description

overview2.blade.php 17KB

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