Без опису

AdministratorsController.php 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <?php
  2. class AdministratorsController extends \BaseController
  3. {
  4. private function outcomes_semesters($selected_semesters, $level)
  5. {
  6. $min_start="9000-01-01 00:00:00";
  7. $max_end="1000-01-01 00:00:00";
  8. foreach($selected_semesters as $semester)
  9. {
  10. if($min_start>$semester->start)
  11. {
  12. $min_start=$semester->start;
  13. }
  14. if($max_end<$semester->end)
  15. {
  16. $max_end=$semester->end;
  17. }
  18. }
  19. $outcomes = Outcome::where(function($query) use ($min_start)
  20. {
  21. $query->where('deactivation_date', '>=', $min_start)
  22. ->orWhere('deactivation_date', null);
  23. })
  24. ->where('activation_date', '<=', $max_end)
  25. ->where(function($query2) use ($level)
  26. {
  27. $query2->where("level", $level+1)
  28. ->orWhere("level",3);
  29. })
  30. ->orderBy('name', 'ASC')
  31. ->get();
  32. $outcomeCount = Outcome::where(function($query) use ($min_start)
  33. {
  34. $query->where('deactivation_date', '>=', $min_start)
  35. ->orWhere('deactivation_date', null);
  36. })
  37. ->where('activation_date', '<=', $max_end)
  38. ->where(function($query2) use ($level)
  39. {
  40. $query2->where("level",$level+1)
  41. ->orWhere("level",3);
  42. })
  43. ->count();
  44. foreach($outcomes as $outcome)
  45. {
  46. // var_dump($outcome->id);
  47. // print "<br>";
  48. $outcomes_attempted[$outcome->id]=$outcome->attempted($selected_semesters, $level);
  49. $outcomes_achieved[$outcome->id]=$outcome->achieved($selected_semesters, $level);
  50. }
  51. $uhs_school_id = School::where('name', 'LIKE', '%UHS%')->first()->id;
  52. $uhs_program_id = Program::where('name', 'LIKE', '%UHS%')->first()->id;
  53. foreach ($outcomes as $outcome)
  54. {
  55. $achievedProgramsPerOutcome[$outcome->id]=0; // For each program with courses that do assessment
  56. $attemptedProgramsPerOutcome[$outcome->id]=0; // For each program with courses that do assessment
  57. foreach (Program::with(array('courses' => function($query){
  58. // $query->whereNotNull('outcomes_attempted');
  59. $query->where('code', '!=', 'TEST');
  60. $query->whereIn('semester_id', Session::get('semesters_ids'));
  61. }))->where('is_graduate', $level)->where('school_id', '!=', $uhs_school_id)->orderBy('name', 'asc')->get() as $program)
  62. {
  63. $achieved_outcomes_per_program[$program->id]=0;
  64. $attempted_outcomes_per_program[$program->id]=0;
  65. $participating_programs[$program->id]=(object)array('id'=>$program->id, 'name'=>$program->name, 'is_graduate'=> $program->is_graduate, 'school_id'=>$program->school_id);
  66. // SELECT ac.id activity_criterion_id, ac.activity_id, ac.expected_student_score, ac.expected_percentage_students_achieving, co.program_id FROM activity_criterion ac, new_criteria c, activities a, objectives o, courses co where co.id=a.course_id and co.semester_id=13 and a.id=ac.activity_id and c.id = ac.criterion_id and o.id=c.objective_id and o.outcome_id = 2 order by program_id
  67. $program_attempted_outcome=$program->attempted_outcome($outcome->id, $selected_semesters);
  68. $attempted_outcomes_per_program[$program->id]+=$program_attempted_outcome;
  69. // var_dump($program_attempted_outcome);
  70. // exit();
  71. if($program_attempted_outcome)
  72. {
  73. $program_achieved_outcome=$program->achieved_outcome($outcome->id, $selected_semesters);
  74. $achieved_outcomes_per_program[$program->id]+=$program_achieved_outcome;
  75. $attemptedProgramsPerOutcome[$outcome->id]+=$program_attempted_outcome;
  76. // $attemptedProgramsPerOutcome[$outcome->id]+=1;
  77. $achievedProgramsPerOutcome[$outcome->id]+=$program_achieved_outcome;
  78. // $achieved_outcomes_per_program[$outcome->id]=$program->achieved_outcome($outcome->id, $selected_semesters);
  79. // if($attempted_outcomes_per_program[$outcome->id]!=0 && 100.0*$achieved_outcomes_per_program[$outcome->id]/$attempted_outcomes_per_program[$outcome->id] >= $outcome->expected_outcome)
  80. // {
  81. // $achievedProgramsPerOutcome[$outcome->id]+=1;
  82. // // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
  83. // }
  84. }
  85. }
  86. }
  87. return array('outcomes'=>$outcomes,'outcomes_attempted'=>$outcomes_attempted, 'outcomes_achieved'=>$outcomes_achieved, 'attemptedProgramsPerOutcome'=>$attemptedProgramsPerOutcome, 'achievedProgramsPerOutcome'=>$achievedProgramsPerOutcome,'participating_programs'=>$participating_programs);
  88. }
  89. public function overview()
  90. {
  91. $selected_semesters = Semester::find(Session::get('semesters_ids'));
  92. $subgraduado=$this->outcomes_semesters($selected_semesters,0);
  93. $outcomes_subgrad=$subgraduado['outcomes'];
  94. $undergrad_outcomes_achieved=$subgraduado['outcomes_achieved'];
  95. $undergrad_outcomes_attempted=$subgraduado['outcomes_attempted'];
  96. $attemptedUndergradProgramsPerOutcome=$subgraduado['attemptedProgramsPerOutcome'];
  97. $achievedUndergradProgramsPerOutcome=$subgraduado['achievedProgramsPerOutcome'];
  98. $participating_undergrad_programs=$subgraduado['participating_programs'];
  99. $graduado=$this->outcomes_semesters($selected_semesters,1);
  100. $outcomes_grad=$graduado['outcomes'];
  101. $grad_outcomes_achieved=$graduado['outcomes_achieved'];
  102. $grad_outcomes_attempted=$graduado['outcomes_attempted'];
  103. $attemptedGradProgramsPerOutcome=$graduado['attemptedProgramsPerOutcome'];
  104. $achievedGradProgramsPerOutcome=$graduado['achievedProgramsPerOutcome'];
  105. $participating_grad_programs=$graduado['participating_programs'];
  106. //Total amount of learning outcomes
  107. // $outcomeCount = Outcome::withTrashed()->count();
  108. // $selected_semester = Semester::find(Session::get('semesters_ids')[0]);
  109. // $outcomes_subgrad = Outcome::where(function($query) use ($selected_semester)
  110. // {
  111. // $query->where('deactivation_date', '>=', $selected_semester->start)
  112. // ->orWhere('deactivation_date', null);
  113. // })
  114. // ->where('activation_date', '<=', $selected_semester->end)
  115. // ->where(function($query2)
  116. // {
  117. // $query2->where("level",1)
  118. // ->orWhere("level",3);
  119. // })
  120. // ->orderBy('name', 'ASC')
  121. // ->get();
  122. // $outcomeCount_subgrad = Outcome::where(function($query) use ($selected_semester)
  123. // {
  124. // $query->where('deactivation_date', '>=', $selected_semester->start)
  125. // ->orWhere('deactivation_date', null);
  126. // })
  127. // ->where('activation_date', '<=', $selected_semester->end)
  128. // ->where(function($query2)
  129. // {
  130. // $query2->where("level",1)
  131. // ->orWhere("level",3);
  132. // })
  133. // ->count();
  134. //
  135. // $outcomes_grad = Outcome::where(function($query) use ($selected_semester){$query->where('deactivation_date', '>=', $selected_semester->start)->orWhere('deactivation_date', null);})->where(function($query2){$query2->where("level",2)->orWhere("level",3);})->orderBy('name', 'ASC')->get();
  136. // $outcomeCount_grad = Outcome::where(function($query) use ($selected_semester){$query->where('deactivation_date', '>=', $selected_semester->start)->orWhere('deactivation_date', null);})->where(function($query2){$query2->where("level",2)->orWhere("level",3);})->count();
  137. // print($outcomeCount_subgrad);
  138. // print($outcomeCount_grad);
  139. // Id for excluding UHS from records
  140. $uhs_school_id = School::where('name', 'LIKE', '%UHS%')->first()->id;
  141. // $uhs_program_id = Program::where('name', 'LIKE', '%UHS%')->first()->id;
  142. $schools = School::where('id', '!=', $uhs_school_id)->orderBy('name', 'asc')->get();
  143. $title = 'Campus Overview';
  144. /**
  145. * Calculate campus wide outcome performance by counting the number of students
  146. $undergrad_outcomes_attempted will have the number of criteria that was assessed in undergradute courses during the selected semester
  147. $undergrad_outcomes_achieved will have the number of criteria that was assessed in undergradute courses during the selected semester
  148. where the percentage of students that obtained a better or equal score than the expected_student_score established in the
  149. activity_criterion table is greater or equal than the expected_percentage_students_achieving also established in the
  150. activity_criterion table
  151. */
  152. // foreach($outcomes_subgrad as $outcome)
  153. // {
  154. // $undergrad_outcomes_attempted[$outcome->id]=$outcome->attempted($selected_semester->id,0);
  155. // $undergrad_outcomes_achieved[$outcome->id]=$outcome->achieved($selected_semester->id,0);
  156. // }
  157. // var_dump($undergrad_outcomes_attempted);
  158. // print"<br>";
  159. // var_dump($undergrad_outcomes_achieved);
  160. // print"<br>";
  161. // foreach($outcomes_grad as $outcome)
  162. // {
  163. // $grad_outcomes_attempted[$outcome->id]=$outcome->attempted($selected_semester->id,1);
  164. // $grad_outcomes_achieved[$outcome->id]=$outcome->achieved($selected_semester->id,1);
  165. // }
  166. /**
  167. * Calculate how many programs achieved and attempted each outcome
  168. */
  169. // Number of programs that achieved a particular learning outcome
  170. // $achievedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount_subgrad, 0);
  171. // Number of programs that attempted a particular learning outcome
  172. // $attemptedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount_subgrad, 0);
  173. // Names of programs doing assessment
  174. // Fetch programs with participation
  175. // $participating_undergrad_programs = DB::table('VIEW_participating_programs')
  176. // ->whereIn('semester_id', Session::get('semesters_ids'))
  177. // ->where('is_graduate', 0)
  178. // ->groupBy('id')
  179. // ->orderBy('name', 'asc')
  180. // ->get();
  181. // $output = array();
  182. /**
  183. * Calculate how many undergrad programs achieved and attempted each outcome
  184. */
  185. // foreach ($outcomes_subgrad as $outcome)
  186. // {
  187. // $achieved_outcomes_per_undergrad_program[$outcome->id]=0;
  188. // $attempted_outcomes_per_undergrad_program[$outcome->id]=0;
  189. // $achievedUndergradProgramsPerOutcome[$outcome->id]=0; // For each program with courses that do assessment
  190. // $attemptedUndergradProgramsPerOutcome[$outcome->id]=0; // For each program with courses that do assessment
  191. // foreach (Program::with(array('courses' => function($query){
  192. // // $query->whereNotNull('outcomes_attempted');
  193. // $query->where('code', '!=', 'TEST');
  194. // $query->whereIn('semester_id', Session::get('semesters_ids'));
  195. // }))->where('is_graduate', 0)->where('school_id', '!=', $uhs_school_id)->orderBy('name', 'asc')->get() as $program)
  196. // {
  197. // $participating_undergrad_programs[$program->id]=(object)array('id'=>$program->id, 'name'=>$program->name, 'is_graduate'=> $program->is_graduate, 'school_id'=>$program->school_id,'semestre_id',$selected_semester);
  198. //
  199. // // SELECT ac.id activity_criterion_id, ac.activity_id, ac.expected_student_score, ac.expected_percentage_students_achieving, co.program_id FROM activity_criterion ac, new_criteria c, activities a, objectives o, courses co where co.id=a.course_id and co.semester_id=13 and a.id=ac.activity_id and c.id = ac.criterion_id and o.id=c.objective_id and o.outcome_id = 2 order by program_id
  200. // $program_attempted_outcome=$program->attempted_outcome($outcome->id, $selected_semester->id);
  201. // $attempted_outcomes_per_undergrad_program[$outcome->id]+=$program_attempted_outcome;
  202. // // var_dump($program_attempted_outcome);
  203. // // exit();
  204. // if($program_attempted_outcome)
  205. // {
  206. // $attemptedUndergradProgramsPerOutcome[$outcome->id]+=1;
  207. // $achieved_outcomes_per_undergrad_program[$outcome->id]=$program->achieved_outcome($outcome->id, $selected_semester->id);
  208. // if($attempted_outcomes_per_undergrad_program[$outcome->id]!=0 && 100.0*$achieved_outcomes_per_undergrad_program[$outcome->id]/$attempted_outcomes_per_undergrad_program[$outcome->id] >= $outcome->expected_outcome)
  209. // {
  210. // $achievedUndergradProgramsPerOutcome[$outcome->id]+=1;
  211. // // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedUndergradProgramsPerOutcome);
  212. // }
  213. // }
  214. // }
  215. // }
  216. // var_dump($attempted_outcomes_per_undergrad_program);
  217. // print"<br>";
  218. // var_dump($achieved_outcomes_per_undergrad_program);
  219. // print"<br>";
  220. // var_dump($attemptedUndergradProgramsPerOutcome);
  221. // print"<br>";
  222. // var_dump($achievedUndergradProgramsPerOutcome);
  223. // print"<br>";
  224. // exit();
  225. /**
  226. * Calculate how many grad programs achieved and attempted each outcome
  227. $grad_outcomes_attempted will have the number of criteria that was assessed in gradute courses during the selected semester
  228. $grad_outcomes_achieved will have the number of criteria that was assessed in gradute courses during the selected semester
  229. where the percentage of students that obtained a better or equal score than the expected_student_score established in the
  230. activity_criterion table is greater or equal than the expected_percentage_students_achieving also established in the
  231. activity_criterion table
  232. */
  233. // Names of programs doing assessment
  234. // $participating_grad_programs = DB::table('VIEW_participating_programs')
  235. // ->whereIn('semester_id', Session::get('semesters_ids'))
  236. // ->where('is_graduate', 1)
  237. // ->groupBy('id')
  238. // ->orderBy('name', 'asc')
  239. // ->get();
  240. // foreach ($outcomes_grad as $outcome)
  241. // {
  242. // $achieved_outcomes_per_grad_program[$outcome->id]=0;
  243. // $attempted_outcomes_per_grad_program[$outcome->id]=0;
  244. // $achievedGradProgramsPerOutcome[$outcome->id]=0; // For each program with courses that do assessment
  245. // $attemptedGradProgramsPerOutcome[$outcome->id]=0; // For each program with courses that do assessment
  246. // foreach (Program::with(array('courses' => function($query){
  247. // $query->whereNotNull('outcomes_attempted');
  248. // $query->where('code', '!=', 'TEST');
  249. // $query->whereIn('semester_id', Session::get('semesters_ids'));
  250. // }))->where('is_graduate', 1)->where('school_id', '!=', $uhs_school_id)->orderBy('name', 'asc')->get() as $program)
  251. // {
  252. // $participating_grad_programs[$program->id]=(object)array('id'=>$program->id, 'name'=>$program->name, 'is_graduate'=> $program->is_graduate, 'school_id'=>$program->school_id,'semestre_id',$selected_semester);
  253. // // SELECT ac.id activity_criterion_id, ac.activity_id, ac.expected_student_score, ac.expected_percentage_students_achieving, co.program_id FROM activity_criterion ac, new_criteria c, activities a, objectives o, courses co where co.id=a.course_id and co.semester_id=13 and a.id=ac.activity_id and c.id = ac.criterion_id and o.id=c.objective_id and o.outcome_id = 2 order by program_id
  254. // $program_attempted_outcome=$program->attempted_outcome($outcome->id, $selected_semester->id);
  255. // $attempted_outcomes_per_grad_program[$outcome->id]+=$program_attempted_outcome;
  256. // // var_dump($attempted_outcomes_per_undergrad_program);
  257. // // exit();
  258. // if($program_attempted_outcome)
  259. // {
  260. // $attemptedGradProgramsPerOutcome[$outcome->id]+=1;
  261. // $achieved_outcomes_per_grad_program[$outcome->id]=$program->achieved_outcome($outcome->id, $selected_semester->id);
  262. // if($attempted_outcomes_per_grad_program[$outcome->id]!=0 && (float)$achieved_outcomes_per_grad_program[$outcome->id]/$attempted_outcomes_per_grad_program[$outcome->id]*100 >= $outcome->expected_outcome)
  263. // {
  264. // $achievedGradProgramsPerOutcome[$outcome->id]+=1;
  265. // // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedUndergradProgramsPerOutcome);
  266. // }
  267. // }
  268. // }
  269. // }
  270. // var_dump($grad_outcomes_attempted);
  271. // print("<br>");
  272. // var_dump($grad_outcomes_achieved);
  273. // exit();
  274. return View::make('local.managers.admins.overview', compact('title', 'schools', 'outcomes_subgrad', 'outcomes_grad', 'undergrad_outcomes_achieved', 'undergrad_outcomes_attempted', 'grad_outcomes_achieved', 'grad_outcomes_attempted', 'attemptedUndergradProgramsPerOutcome', 'participating_undergrad_programs', 'achievedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'participating_grad_programs', 'achievedGradProgramsPerOutcome'));
  275. }
  276. }