Geen omschrijving

SchoolsController.php 49KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919
  1. <?php
  2. class SchoolsController extends \BaseController
  3. {
  4. private function participatingPrograms($school)
  5. {
  6. return DB::table('programs')
  7. ->join('courses', 'courses.program_id', '=', 'programs.id')
  8. ->join('activities', 'activities.course_id', '=', 'courses.id')
  9. ->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
  10. ->join('assessments', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
  11. ->select('programs.id', 'programs.name', 'programs.is_graduate', 'programs.school_id')
  12. ->addSelect('courses.semester_id')
  13. ->where('school_id', $school->id)
  14. ->whereIn('semester_id', Session::get('semesters_ids'))
  15. ->lists('id');
  16. // return DB::table('programs')
  17. // ->join('courses', 'courses.program_id', '=', 'programs.id')
  18. // ->select('programs.id', 'programs.name', 'programs.is_graduate', 'programs.school_id')
  19. // ->addSelect('courses.semester_id')
  20. // ->where('school_id', $school->id)
  21. // ->whereIn('semester_id', Session::get('semesters_ids'))
  22. // ->lists('id');
  23. }
  24. public function show($id)
  25. {
  26. ini_set('memory_limit', '256M');
  27. DB::connection()->disableQueryLog();
  28. $school = School::find($id);
  29. $title = $school->name;
  30. $schools = School::all();
  31. $semesters = Semester::whereIn('id', Session::get('semesters_ids'))->get();
  32. $outcomes_grad = Outcome::active_by_semesters($semesters, 1);
  33. $outcomes_undergrad = Outcome::active_by_semesters($semesters, 0);
  34. /**
  35. * List of grouped courses (grouped sections)
  36. */
  37. $program_ids = $school->programs->lists('id');
  38. $undergrad_programs = DB::table('programs')
  39. ->select('id', 'name', 'school_id', 'is_graduate')
  40. ->where('is_graduate', '=', 0)
  41. ->where('school_id', '=', $id)
  42. ->orderBy('name', 'ASC')
  43. ->get();
  44. $grad_programs = DB::table('programs')
  45. ->select('id', 'name', 'school_id', 'is_graduate')
  46. ->where('is_graduate', '=', 1)
  47. ->where('school_id', '=', $id)
  48. ->orderBy('name', 'ASC')
  49. ->get();
  50. $grad_grouped_courses = Course::
  51. // select(DB::raw('courses.name, courses.code, courses.number, max(courses.outcomes_attempted) as outcomes_attempted, courses.semester_id, courses.program_id'))
  52. select(DB::raw('courses.name, courses.code, courses.number, courses.semester_id, courses.program_id'))
  53. ->with('semester')
  54. ->with('program')
  55. ->whereIn('courses.program_id', $program_ids)
  56. ->whereIn('courses.semester_id', Session::get('semesters_ids'))
  57. ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
  58. ->where('programs.is_graduate', '=', 1)
  59. ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
  60. ->orderBy('courses.code')
  61. ->orderBy('courses.number')
  62. ->orderBy('courses.semester_id')
  63. ->get();
  64. $undergrad_grouped_courses = Course::
  65. // select(DB::raw('courses.name, courses.code, courses.number, max(courses.outcomes_attempted) as outcomes_attempted, courses.semester_id, courses.program_id'))
  66. select(DB::raw('courses.name, courses.code, courses.number, courses.semester_id, courses.program_id'))
  67. ->with('semester')
  68. ->with('program')
  69. ->whereIn('courses.program_id', $program_ids)
  70. ->whereIn('courses.semester_id', Session::get('semesters_ids'))
  71. ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
  72. ->where('programs.is_graduate', '=', 0)
  73. ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
  74. ->orderBy('courses.code')
  75. ->orderBy('courses.number')
  76. ->orderBy('courses.semester_id')
  77. ->get();
  78. foreach ($undergrad_grouped_courses as $key => $courses) {
  79. $undergrad_grouped_courses[$key]->outcomes_attempted = NULL;
  80. $coursesT = Course::where('courses.code', $courses->code)->where('courses.number', $courses->number)->where('courses.semester_id', $courses->semester_id)->get();
  81. foreach ($coursesT as $course) {
  82. if ($course->isAssessed()) {
  83. $undergrad_grouped_courses[$key]->outcomes_attempted = true;
  84. }
  85. }
  86. }
  87. foreach ($grad_grouped_courses as $key => $courses) {
  88. $grad_grouped_courses[$key]->outcomes_attempted = NULL;
  89. $coursesT = Course::where('courses.code', $courses->code)->where('courses.number', $courses->number)->where('courses.semester_id', $courses->semester_id)->get();
  90. foreach ($coursesT as $course) {
  91. if ($course->isAssessed()) {
  92. $grad_grouped_courses[$key]->outcomes_attempted = true;
  93. }
  94. }
  95. }
  96. // Fetch programs with participation
  97. $participating_programs = $this->participatingPrograms($school);
  98. /**
  99. * Calculate how many sections are doing assessment
  100. */
  101. $undergrad_assessed_sections_count = 0;
  102. $undergrad_school_sections_count = 0;
  103. $grad_assessed_sections_count = 0;
  104. $grad_school_sections_count = 0;
  105. foreach ($school->programs as $program) {
  106. foreach ($program->courses as $course) {
  107. if (!$course->program->is_graduate) {
  108. $undergrad_school_sections_count += 1;
  109. if ($course->isAssessed()) $undergrad_assessed_sections_count += 1;
  110. } else {
  111. $grad_school_sections_count += 1;
  112. if ($course->isAssessed()) $grad_assessed_sections_count += 1;
  113. }
  114. }
  115. }
  116. /**
  117. * Calculate how many programs achieved and attempted each outcome in this school
  118. */
  119. // For each outcome
  120. foreach ($outcomes_undergrad as $outcome) {
  121. // $attempted_outcomes_per_undergrad_program[$outcome->id]=0;
  122. // $achieved_outcomes_per_undergrad_program[$outcome->id]=0;
  123. $attemptedUndergradProgramsPerOutcome[$outcome->id] = 0;
  124. $achievedUndergradProgramsPerOutcome[$outcome->id] = 0;
  125. $programs_attempted_in_school[$outcome->id] = $outcome->programs_attempted_in_school($semesters, $school->id);
  126. // var_dump($programs_attempted_in_school);exit();
  127. foreach ($programs_attempted_in_school[$outcome->id] as $program_id) {
  128. // var_dump($program_id->id);exit();
  129. $program = DB::table('programs')->where('id', '=', $program_id->id)->first();
  130. if (!$program->is_graduate) {
  131. $attemptedUndergradProgramsPerOutcome[$outcome->id]++;
  132. $programC = Program::where('id', '=', $program_id->id)->first();
  133. // var_dump($programC);exit();
  134. if ($programC->achieved_outcome($outcome->id, $semesters)) {
  135. $achievedUndergradProgramsPerOutcome[$outcome->id]++;
  136. }
  137. }
  138. }
  139. $undergrad_outcomes_attempted[$outcome->id] = $outcome->attempted_by_school($semesters, $school->id, 0);
  140. $undergrad_outcomes_achieved[$outcome->id] = $outcome->achieved_by_school($semesters, $school->id, 0);
  141. // For each program with courses that do assessment
  142. $programs_with_courses = Program::with(array('courses' => function ($query) {
  143. // $query->whereNotNull('outcomes_attempted');
  144. $query->whereIn('semester_id', Session::get('semesters_ids'));
  145. }))->where('is_graduate', 0)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
  146. }
  147. /**
  148. * Calculate how many Graduate programs achieved and attempted each outcome in this school
  149. */
  150. // For each outcome
  151. foreach ($outcomes_grad as $outcome) {
  152. // $attempted_outcomes_per_grad_program[$outcome->id]=0;
  153. $achieved_outcomes_per_grad_program[$outcome->id] = 0;
  154. $attemptedGradProgramsPerOutcome[$outcome->id] = 0;
  155. $achievedGradProgramsPerOutcome[$outcome->id] = 0;
  156. $grad_outcomes_attempted[$outcome->id] = $outcome->attempted_by_school($semesters, $school->id, 1);
  157. $grad_outcomes_achieved[$outcome->id] = $outcome->achieved_by_school($semesters, $school->id, 1);
  158. // For each program with courses that do assessment
  159. foreach ($programs_attempted_in_school[$outcome->id] as $program_id) {
  160. // var_dump($program_id->id);exit();
  161. $program = DB::table('programs')
  162. ->where('id', '=', $program_id->id)
  163. ->first();
  164. // $program=Program::where('id', $program_id->id);
  165. // var_dump($program);exit();
  166. if ($program->is_graduate) {
  167. $attemptedGradProgramsPerOutcome[$outcome->id]++;
  168. $programC = Program::where('id', '=', $program_id->id)->first();
  169. // var_dump($programC);exit();
  170. if ($programC->achieved_outcome($outcome->id, $semesters)) {
  171. $achievedGradProgramsPerOutcome[$outcome->id]++;
  172. }
  173. }
  174. }
  175. $programs_with_courses = Program::with(array('courses' => function ($query) {
  176. // $query->whereNotNull('outcomes_attempted');
  177. $query->whereIn('semester_id', Session::get('semesters_ids'));
  178. }))->where('is_graduate', 1)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
  179. }
  180. if ($school->id == 13) {
  181. // return View::make('local.managers.shared.school-uhs', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
  182. return View::make('local.managers.shared.school-uhs', compact('title', 'outcomes_grad', 'outcomes_undergrad', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs'));
  183. } else {
  184. // return View::make('local.managers.shared.school', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
  185. return View::make('local.managers.shared.school', compact('title', 'outcomes_grad', 'outcomes_undergrad', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs'));
  186. }
  187. }
  188. private function cmp($a, $b)
  189. {
  190. return strcmp($a->name, $b->name);
  191. }
  192. public function studentSchoolAssessmentReport($school_id)
  193. {
  194. $id=$school_id;
  195. ini_set('memory_limit', -1);
  196. ini_set('max_execution_time', 300);
  197. $outcomes = Outcome::orderBy('name', 'asc')->get();
  198. $school = School::find($school_id);
  199. $title= $school->name;
  200. $outcomeCount = Outcome::all()->count();
  201. $programs=Program::where('school_id','=',$school_id)->get();
  202. $programs_ids=array();
  203. // var_dump($programs);exit();
  204. $programs_name=array();
  205. foreach($programs as $program)
  206. {
  207. // var_dump($program);
  208. $programs_ids[]=$program->id;
  209. $programs_name[$program->id]=$program->name;
  210. }
  211. $grouped_courses = Course::
  212. // select(DB::raw('courses.name, courses.code, courses.number, max(courses.outcomes_attempted) as outcomes_attempted, courses.semester_id, courses.program_id'))
  213. select(DB::raw('courses.name, courses.code, courses.number, courses.semester_id, courses.program_id'))
  214. ->with('semester')
  215. ->with('program')
  216. ->whereIn('courses.program_id', $programs_ids)
  217. ->whereIn('courses.semester_id', Session::get('semesters_ids'))
  218. ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
  219. ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
  220. ->orderBy('courses.code')
  221. ->orderBy('courses.number')
  222. ->orderBy('courses.semester_id')
  223. ->get();
  224. $role=Auth::user()->role;
  225. $users =array();
  226. $resultados_todos_obj = DB::table('assessments')
  227. ->join('activity_criterion', 'activity_criterion.id', '=', 'assessments.activity_criterion_id')
  228. ->join('activities', 'activities.id', '=', 'activity_criterion.activity_id')
  229. ->join('courses', 'courses.id', '=', 'activities.course_id')
  230. ->join('students', 'students.id', '=', 'assessments.student_id')
  231. ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'activity_criterion.criterion_id')
  232. ->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
  233. ->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
  234. ->join('semesters', 'semesters.id', '=', 'courses.semester_id')
  235. ->whereIn('students.program_id',$programs_ids)
  236. ->whereIn('semester_id', Session::get('semesters_ids'))
  237. ->where('semesters.is_visible','=',1)
  238. ->select('student_id', 'students.program_id', 'semesters.code', 'outcome_id', 'criterion_objective_outcome.criterion_id','score','expected_points')
  239. ->distinct()
  240. ->get();
  241. foreach($resultados_todos_obj as $resultado)
  242. {
  243. if(!isset($resultados_todos[$resultado->program_id][$resultado->outcome_id]['semesters']))
  244. {
  245. $resultados_todos[$resultado->program_id][$resultado->outcome_id]['semesters']=array();
  246. }
  247. $resultados_todos[$resultado->program_id][$resultado->outcome_id]['semesters'][]=$resultado->code;
  248. $resultados_todos[$resultado->program_id][$resultado->outcome_id]['semesters']=array_unique($resultados_todos[$resultado->program_id][$resultado->outcome_id]['semesters']);
  249. if(!isset($resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['attempted']))
  250. {
  251. $resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['attempted']=0;
  252. }
  253. $resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['attempted']++;
  254. if(!isset($resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['achieved']))
  255. {
  256. $resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['achieved']=0;
  257. }
  258. if($resultado->score>=$resultado->expected_points)
  259. {
  260. $resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['achieved']++;
  261. }
  262. }
  263. $outcomes_colap=array();
  264. $programs=array();
  265. // $outcomes_colap=array();
  266. $i=0;
  267. $outcomes_attempted=array();
  268. $outcomes_attempted_colap=array();
  269. $outcomes_achieved_colap=array();
  270. $outcomes_attempted_semesters=array();
  271. foreach($resultados_todos as $program_id => $resultados_prog)
  272. {
  273. $outcomes_attempted_semesters[$program_id]=array();
  274. foreach($resultados_prog as $out=>$datos_out)
  275. {
  276. $outcomes_achieved[$program_id][$out] = 0;
  277. $outcomes_attempted[$program_id][$out] = 0;
  278. // var_dump($datos_out);outcomes_attempted_semesters
  279. $outcomes_attempted_semesters[$program_id][$out]=$datos_out['semesters'];
  280. unset($datos_out['semesters']);
  281. // var_dump($outcomes_attempted_semesters[$program_id][$out]);
  282. // var_dump($datos_out);
  283. // exit();
  284. foreach($datos_out as $res)
  285. {
  286. $outcomes_attempted[$program_id][$out]++;
  287. if(3*$res['achieved']>=2*$res['attempted'])
  288. $outcomes_achieved[$program_id][$out]++;
  289. }
  290. }
  291. $programs[]=Program::find($program_id);
  292. if(Program::find($program_id)->is_graduate)
  293. {
  294. $colapso=array(1=>array(),3=>array(),2=>array(11),12=>array(7,14),10=>array(),4=>array(6,15));
  295. }
  296. else
  297. {
  298. $colapso=array(10=>array(),1=>array(),12=>array(7),3=>array(9,8,14),2=>array(11),5=>array(),4=>array(6,13),16=>array());
  299. }
  300. $resultados_todos_colap[$program_id]=array();
  301. foreach($colapso as $out=>$pares)
  302. {
  303. $resultados_todos_colap[$program_id][$out]["semesters"]=array();
  304. if(isset($resultados_todos[$program_id][$out]))
  305. $resultados_todos_colap[$program_id][$out]=$resultados_todos[$program_id][$out];
  306. else $resultados_todos_colap[$program_id][$out]=array();
  307. foreach($pares as $par)
  308. {
  309. if(isset($resultados_todos[$program_id][$par]))
  310. {
  311. // unset($resultados_todos[$program_id][$par]['semesters']);
  312. foreach($resultados_todos[$program_id][$par] as $estu => $resus)
  313. {
  314. if($estu!="semesters")
  315. {
  316. if(!isset($resultados_todos_colap[$program_id][$out][$estu]))
  317. {
  318. $resultados_todos_colap[$program_id][$out][$estu]['attempted']=0;
  319. $resultados_todos_colap[$program_id][$out][$estu]['achieved']=0;
  320. }
  321. // print $program_id." ".$par." ".$estu."<br>";
  322. // var_dump($resultados_todos[$program_id][$par][$estu]);
  323. $resultados_todos_colap[$program_id][$out][$estu]['attempted']+=$resultados_todos[$program_id][$par][$estu]['attempted'];
  324. $resultados_todos_colap[$program_id][$out][$estu]['achieved']+=$resultados_todos[$program_id][$par][$estu]['achieved'];
  325. }
  326. else if(isset($resultados_todos[$program_id][$par]["semesters"]))
  327. {
  328. if(isset($resultados_todos_colap[$program_id][$out]["semesters"]))
  329. {
  330. $tmp=array_merge($resultados_todos_colap[$program_id][$out]["semesters"],$resultados_todos[$program_id][$par]["semesters"]);
  331. // var_dump(($tmp));
  332. // var_dump(array_unique($tmp));
  333. // exit();
  334. $resultados_todos_colap[$program_id][$out]["semesters"]=array_unique($tmp);
  335. }
  336. else
  337. $resultados_todos_colap[$program_id][$out]["semesters"]=array_unique($resultados_todos[$program_id][$par]["semesters"]);
  338. }
  339. }
  340. }
  341. }
  342. }
  343. // var_dump($resultados_todos_colap);
  344. $outcomes_attempted_colap[$program_id]=array();
  345. $outcomes_achieved_colap[$program_id]=array();
  346. $outcomes_attempted_colap_semesters[$program_id]=array();
  347. // print $program_id."<br>";
  348. // var_dump($resultados_todos_colap[$program_id]);
  349. // print "<br>";
  350. foreach($resultados_todos_colap[$program_id] as $out=>$datos_out)
  351. {
  352. if(!$i)$outcomes_colap[]=Outcome::find($out);
  353. // $outcomes_attempted_colap_semesters[$program_id][$out]=array();
  354. if(isset($datos_out['semesters']))
  355. {
  356. $outcomes_attempted_colap_semesters[$program_id][$out]=$datos_out['semesters'];
  357. unset($datos_out['semesters']);
  358. }
  359. foreach($datos_out as $res)
  360. {
  361. if(!isset($outcomes_attempted_colap[$program_id][$out]))
  362. {
  363. $outcomes_attempted_colap[$program_id][$out]=0;
  364. $outcomes_achieved_colap[$program_id][$out]=0;
  365. }
  366. $outcomes_attempted_colap[$program_id][$out]++;
  367. if(3*$res['achieved']>=2*$res['attempted'])
  368. $outcomes_achieved_colap[$program_id][$out]++;
  369. }
  370. if(empty($datos_out))
  371. {
  372. $outcomes_attempted_colap[$program_id][$out]=0;
  373. $outcomes_achieved_colap[$program_id][$out]=0;
  374. }
  375. }
  376. $i++;
  377. }
  378. usort($outcomes_colap, array($this, "cmp"));
  379. // var_dump($outcomes_attempted_colap); print "<br>";
  380. // var_dump($outcomes_achieved_colap); print "<br>";
  381. // exit();
  382. $outcomes_attempted_colap_todo=array();
  383. $outcomes_achieved_colap_todo=array();
  384. foreach($outcomes_attempted_colap as $program_id => $out_res)
  385. {
  386. foreach($out_res as $out=>$res)
  387. {
  388. if(!isset($outcomes_attempted_colap_todo[$out]))
  389. {
  390. $outcomes_attempted_colap_todo[$out]=0;
  391. $outcomes_achieved_colap_todo[$out]=0;
  392. }
  393. $outcomes_attempted_colap_todo[$out]+=$outcomes_attempted_colap[$program_id][$out];
  394. $outcomes_achieved_colap_todo[$out]+=$outcomes_achieved_colap[$program_id][$out];
  395. }
  396. }
  397. $outcomes_attempted_todo=array();
  398. $outcomes_achieved_todo=array();
  399. foreach($outcomes_attempted as $program_id => $out_res)
  400. {
  401. foreach($out_res as $out=>$res)
  402. {
  403. if(!isset($outcomes_attempted_todo[$out]))
  404. {
  405. $outcomes_attempted_todo[$out]=0;
  406. $outcomes_achieved_todo[$out]=0;
  407. }
  408. $outcomes_attempted_todo[$out]+=$outcomes_attempted[$program_id][$out];
  409. $outcomes_achieved_todo[$out]+=$outcomes_achieved[$program_id][$out];
  410. }
  411. }
  412. return View::make('local.managers.shared.school_student_result', compact('title','outcomes_attempted_colap_semesters','outcomes_attempted_semesters','outcomes_attempted_colap_todo','outcomes_achieved_colap_todo','outcomes_attempted_todo','outcomes_achieved_todo','school','programs_name','role','outcomes','outcomes_colap', 'outcomes_attempted', 'outcomes_achieved', 'outcomes_attempted_colap', 'outcomes_achieved_colap', 'programs', 'users','program_courses','grouped_courses'));
  413. }
  414. public function showQuasiOri($id)
  415. {
  416. ini_set('memory_limit', '256M');
  417. DB::connection()->disableQueryLog();
  418. $school = School::find($id);
  419. $title = $school->name;
  420. $schools = School::all();
  421. // $outcomes = Outcome::orderBy('name', 'asc')->get();
  422. // $outcomeCount = Outcome::all()->count();
  423. $semesters = Semester::whereIn('id', Session::get('semesters_ids'))->get();
  424. // var_dump($semesters);
  425. // exit();
  426. $outcomes_grad = Outcome::active_by_semesters($semesters, 1);
  427. $outcomes_undergrad = Outcome::active_by_semesters($semesters, 0);
  428. /**
  429. * List of grouped courses (grouped sections)
  430. */
  431. $program_ids = $school->programs->lists('id');
  432. $undergrad_programs = DB::table('programs')
  433. ->select('id', 'name', 'school_id', 'is_graduate')
  434. ->where('is_graduate', '=', 0)
  435. ->where('school_id', '=', $id)
  436. ->orderBy('name', 'ASC')
  437. ->get();
  438. $grad_programs = DB::table('programs')
  439. ->select('id', 'name', 'school_id', 'is_graduate')
  440. ->where('is_graduate', '=', 1)
  441. ->where('school_id', '=', $id)
  442. ->orderBy('name', 'ASC')
  443. ->get();
  444. $grad_grouped_courses = Course::
  445. // select(DB::raw('courses.name, courses.code, courses.number, max(courses.outcomes_attempted) as outcomes_attempted, courses.semester_id, courses.program_id'))
  446. select(DB::raw('courses.name, courses.code, courses.number, courses.semester_id, courses.program_id'))
  447. ->with('semester')
  448. ->with('program')
  449. ->whereIn('courses.program_id', $program_ids)
  450. ->whereIn('courses.semester_id', Session::get('semesters_ids'))
  451. ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
  452. ->where('programs.is_graduate', '=', 1)
  453. ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
  454. ->orderBy('courses.code')
  455. ->orderBy('courses.number')
  456. ->orderBy('courses.semester_id')
  457. ->get();
  458. $undergrad_grouped_courses = Course::
  459. // select(DB::raw('courses.name, courses.code, courses.number, max(courses.outcomes_attempted) as outcomes_attempted, courses.semester_id, courses.program_id'))
  460. select(DB::raw('courses.name, courses.code, courses.number, courses.semester_id, courses.program_id'))
  461. ->with('semester')
  462. ->with('program')
  463. ->whereIn('courses.program_id', $program_ids)
  464. ->whereIn('courses.semester_id', Session::get('semesters_ids'))
  465. ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
  466. ->where('programs.is_graduate', '=', 0)
  467. ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
  468. ->orderBy('courses.code')
  469. ->orderBy('courses.number')
  470. ->orderBy('courses.semester_id')
  471. ->get();
  472. // Fetch programs with participation
  473. $participating_programs = $this->participatingPrograms($school);
  474. /**
  475. * Calculate how many sections are doing assessment
  476. */
  477. // $undergrad_outcomes_achieved = array_fill(1, $outcomeCount, 0);
  478. // $undergrad_outcomes_attempted = array_fill(1, $outcomeCount, 0);
  479. $undergrad_assessed_sections_count = 0;
  480. $undergrad_school_sections_count = 0;
  481. // $grad_outcomes_achieved = array_fill(1, $outcomeCount, 0);
  482. // $grad_outcomes_attempted = array_fill(1, $outcomeCount, 0);
  483. $grad_assessed_sections_count = 0;
  484. $grad_school_sections_count = 0;
  485. foreach ($school->programs as $program) {
  486. foreach ($program->courses as $course) {
  487. // Log::info("aqui".$course);
  488. if (!$course->program->is_graduate) {
  489. $undergrad_school_sections_count += 1;
  490. if ($course->isAssessed()) $undergrad_assessed_sections_count += 1;
  491. // Log::info("aqui".$course);
  492. } else {
  493. $grad_school_sections_count += 1;
  494. if ($course->isAssessed()) $grad_assessed_sections_count += 1;
  495. // Log::info("aqui".$course);
  496. }
  497. // if (!$course->program->is_graduate) {
  498. // if ($course->outcomes_achieved != NULL) {
  499. // $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
  500. // $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
  501. // for ($i = 1; $i <= count($undergrad_outcomes_attempted); $i++) {
  502. // $undergrad_outcomes_achieved[$i] += $course_outcomes_achieved[$i];
  503. // $undergrad_outcomes_attempted[$i] += $course_outcomes_attempted[$i];
  504. // }
  505. // $undergrad_assessed_sections_count += 1;
  506. // }
  507. // $undergrad_school_sections_count += 1;
  508. // } else {
  509. // if ($course->outcomes_achieved != NULL) {
  510. // $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
  511. // $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
  512. // for ($i = 1; $i <= count($grad_outcomes_attempted); $i++) {
  513. // $grad_outcomes_achieved[$i] += $course_outcomes_achieved[$i];
  514. // $grad_outcomes_attempted[$i] += $course_outcomes_attempted[$i];
  515. // }
  516. // $grad_assessed_sections_count += 1;
  517. // }
  518. // $grad_school_sections_count += 1;
  519. // }
  520. }
  521. }
  522. /**
  523. * Calculate how many programs achieved and attempted each outcome in this school
  524. */
  525. // Number of programs that achieved a particular learning outcome
  526. // $achievedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
  527. // Number of programs that attempted a particular learning outcome
  528. // $attemptedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
  529. // Fetch programs with participation for the school
  530. // $participating_undergrad_programs = DB::table('programs')
  531. // ->join('courses', 'courses.program_id', '=', 'programs.id')
  532. // ->select('programs.id', 'programs.name', 'programs.is_graduate', 'programs.school_id')
  533. // ->addSelect('courses.semester_id')
  534. // ->whereIn('semester_id', Session::get('semesters_ids'))
  535. // ->where('is_graduate', 0)
  536. // ->where('school_id', $school->id)
  537. // ->groupBy('id')
  538. // ->get();
  539. $output = array();
  540. // For each outcome
  541. foreach ($outcomes_undergrad as $outcome) {
  542. // $attempted_outcomes_per_undergrad_program[$outcome->id]=0;
  543. $achieved_outcomes_per_undergrad_program[$outcome->id] = 0;
  544. $attemptedUndergradProgramsPerOutcome[$outcome->id] = 0;
  545. $achievedUndergradProgramsPerOutcome[$outcome->id] = 0;
  546. $programs_attempted_in_school[$outcome->id] = $outcome->programs_attempted_in_school($semesters, $school->id);
  547. // var_dump($programs_attempted_in_school);exit();
  548. foreach ($programs_attempted_in_school[$outcome->id] as $program_id) {
  549. // var_dump($program_id->id);exit();
  550. $program = DB::table('programs')
  551. ->where('id', '=', $program_id->id)
  552. ->first();
  553. // $program=Program::where('id', $program_id->id);
  554. // var_dump($program);exit();
  555. if (!$program->is_graduate) {
  556. $attemptedUndergradProgramsPerOutcome[$outcome->id]++;
  557. }
  558. }
  559. $undergrad_outcomes_attempted[$outcome->id] = $outcome->attempted_by_school($semesters, $school->id, 0);
  560. $undergrad_outcomes_achieved[$outcome->id] = $outcome->achieved_by_school($semesters, $school->id, 0);
  561. // For each program with courses that do assessment
  562. $programs_with_courses = Program::with(array('courses' => function ($query) {
  563. // $query->whereNotNull('outcomes_attempted');
  564. $query->whereIn('semester_id', Session::get('semesters_ids'));
  565. }))->where('is_graduate', 0)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
  566. foreach ($programs_with_courses as $program) {
  567. if (in_array($program->id, $participating_programs)) {
  568. // To acummulate all criteria for one program
  569. // $achieved_outcomes_per_undergrad_program = array_fill(1, $outcomeCount, 0);
  570. // $attempted_outcomes_per_undergrad_program = array_fill(1, $outcomeCount, 0);
  571. //Flag for counting programs
  572. $flag = false;
  573. // For each course in the program
  574. // foreach ($program->courses as $course) {
  575. // if($course->isAssessed()){
  576. // // If the outcome in question is being evaluated
  577. // $course_outcomes_attempted2 = $course->outcomes_att();
  578. // // $course_outcomes_attempted2 = json_decode($course->outcomes_attempted, true);
  579. // // $course_outcomes_achieved2 = json_decode($course->outcomes_achieved, true);
  580. // $course_outcomes_achieved2 = $course->outcomes_ach();
  581. // if (
  582. // array_key_exists($outcome->id, $course_outcomes_attempted2) && array_key_exists($outcome->id, $course_outcomes_achieved2)
  583. // && $course_outcomes_attempted2[$outcome->id] > 0
  584. // ) {
  585. // $achieved_outcomes_per_undergrad_program[$outcome->id] += $course_outcomes_achieved2[$outcome->id];
  586. // // $attempted_outcomes_per_undergrad_program[$outcome->id] += $course_outcomes_attempted2[$outcome->id];
  587. //
  588. // // Add one to the programs assessing, if it wasn't added before
  589. // if (!$flag) {
  590. // $attemptedUndergradProgramsPerOutcome[$outcome->id] += 1;
  591. // $flag = true;
  592. // }
  593. // }
  594. //
  595. // // $output[] = 'ACHIEVED: '.$program->name.'-'.json_encode($achieved_outcomes_per_undergrad_program);
  596. // // $output[] = 'ATTEMPTED: '.$program->name.'-'.json_encode($attempted_outcomes_per_program);
  597. // }
  598. // }
  599. //If the accumulated achieved criteria for a specific outcome in a program divided by the accumulated attempted criteria for a specific outcome in a program is greated than the expected outcome
  600. // if ($attempted_outcomes_per_undergrad_program[$outcome->id] != 0 && (float)$achieved_outcomes_per_undergrad_program[$outcome->id] / $attempted_outcomes_per_undergrad_program[$outcome->id] * 100 >= $outcome->expected_outcome) {
  601. // $achievedUndergradProgramsPerOutcome[$outcome->id] += 1;
  602. // // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
  603. // }
  604. }
  605. }
  606. }
  607. /**
  608. * Calculate how many programs achieved and attempted each outcome in this school
  609. */
  610. // Number of programs that achieved a particular learning outcome
  611. // $achievedGradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
  612. // Number of programs that attempted a particular learning outcome
  613. // $attemptedGradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
  614. //
  615. // Fetch programs with participation for the school
  616. // $participating_grad_programs = DB::table('programs')
  617. // ->join('courses', 'courses.program_id', '=', 'programs.id')
  618. // ->select('programs.id', 'programs.name', 'programs.is_graduate', 'programs.school_id')
  619. // ->addSelect('courses.semester_id')
  620. // ->whereIn('semester_id', Session::get('semesters_ids'))
  621. // ->where('is_graduate', 1)
  622. // ->where('school_id', $school->id)
  623. // ->groupBy('id')
  624. // ->get();
  625. $output = array();
  626. // For each outcome
  627. foreach ($outcomes_grad as $outcome) {
  628. // $attempted_outcomes_per_grad_program[$outcome->id]=0;
  629. $achieved_outcomes_per_grad_program[$outcome->id] = 0;
  630. $attemptedGradProgramsPerOutcome[$outcome->id] = 0;
  631. $achievedGradProgramsPerOutcome[$outcome->id] = 0;
  632. $grad_outcomes_attempted[$outcome->id] = $outcome->attempted_by_school($semesters, $school->id, 1);
  633. $grad_outcomes_achieved[$outcome->id] = $outcome->achieved_by_school($semesters, $school->id, 1);
  634. // For each program with courses that do assessment
  635. foreach ($programs_attempted_in_school[$outcome->id] as $program_id) {
  636. // var_dump($program_id->id);exit();
  637. $program = DB::table('programs')
  638. ->where('id', '=', $program_id->id)
  639. ->first();
  640. // $program=Program::where('id', $program_id->id);
  641. // var_dump($program);exit();
  642. if ($program->is_graduate) {
  643. $attemptedGradProgramsPerOutcome[$outcome->id]++;
  644. }
  645. }
  646. $programs_with_courses = Program::with(array('courses' => function ($query) {
  647. // $query->whereNotNull('outcomes_attempted');
  648. $query->whereIn('semester_id', Session::get('semesters_ids'));
  649. }))->where('is_graduate', 1)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
  650. foreach ($programs_with_courses as $program) {
  651. if (in_array($program->id, $participating_programs)) {
  652. // To acummulate all criteria for one program
  653. // $achieved_outcomes_per_grad_program = array_fill(1, $outcomeCount, 0);
  654. // $attempted_outcomes_per_grad_program = array_fill(1, $outcomeCount, 0);
  655. //Flag for counting programs
  656. $flag = false;
  657. // For each course in the program
  658. foreach ($program->courses as $course) {
  659. if ($course->isAssessed()) {
  660. // If the outcome in question is being evaluated
  661. // $course_outcomes_attempted2 = json_decode($course->outcomes_attempted, true);
  662. $course_outcomes_attempted2 = ($course->outcomes_att());
  663. $course_outcomes_achieved2 = ($course->outcomes_ach());
  664. // $course_outcomes_achieved2 = json_decode($course->outcomes_achieved, true);
  665. if (
  666. array_key_exists($outcome->id, $course_outcomes_attempted2) && array_key_exists($outcome->id, $course_outcomes_achieved2)
  667. && $course_outcomes_attempted2[$outcome->id] > 0
  668. ) {
  669. $achieved_outcomes_per_grad_program[$outcome->id] += $course_outcomes_achieved2[$outcome->id];
  670. $attempted_outcomes_per_grad_program[$outcome->id] += $course_outcomes_attempted2[$outcome->id];
  671. // Add one to the programs assessing, if it wasn't added before
  672. if (!$flag) {
  673. $attemptedGradProgramsPerOutcome[$outcome->id] += 1;
  674. $flag = true;
  675. }
  676. }
  677. // $output[] = 'ACHIEVED: '.$program->name.'-'.json_encode($achieved_outcomes_per_grad_program);
  678. // $output[] = 'ATTEMPTED: '.$program->name.'-'.json_encode($attempted_outcomes_per_program);
  679. }
  680. }
  681. //If the accumulated achieved criteria for a specific outcome in a program divided by the accumulated attempted criteria for a specific outcome in a program is greated than the expected outcome
  682. 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) {
  683. $achievedGradProgramsPerOutcome[$outcome->id] += 1;
  684. // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
  685. }
  686. }
  687. }
  688. }
  689. if ($school->id == 13) {
  690. // return View::make('local.managers.shared.school-uhs', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
  691. return View::make('local.managers.shared.school-uhs', compact('title', 'outcomes_grad', 'outcomes_undergrad', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs'));
  692. } else {
  693. // return View::make('local.managers.shared.school', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
  694. return View::make('local.managers.shared.school', compact('title', 'outcomes_grad', 'outcomes_undergrad', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs'));
  695. }
  696. }
  697. public function print_school($id)
  698. {
  699. ini_set('memory_limit', '256M');
  700. DB::connection()->disableQueryLog();
  701. $school = School::find($id);
  702. $title = $school->name . ' Assessment Report - ' . date('m/d/Y');
  703. $outcomes = Outcome::orderBy('name', 'asc')->get();
  704. $outcomeCount = Outcome::all()->count();
  705. /**
  706. * List of courses (grouped sections)
  707. */
  708. $program_ids = $school->programs->lists('id');
  709. $grouped_courses = Course::
  710. // select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
  711. select(DB::raw('name, code, number, semester_id, program_id'))
  712. ->with('semester')
  713. ->with('program')
  714. ->whereIn('program_id', $program_ids)
  715. ->whereIn('semester_id', Session::get('semesters_ids'))
  716. ->groupBy(array('code', 'number', 'semester_id'))
  717. ->orderBy('code')
  718. ->orderBy('number')
  719. ->orderBy('semester_id')
  720. ->get();
  721. // Fetch programs with participation
  722. $participating_programs = $this->participatingPrograms($school);
  723. /**
  724. * Calculate how many sections are doing assessment
  725. */
  726. $outcomes_achieved = array_fill(1, $outcomeCount, 0);
  727. $outcomes_attempted = array_fill(1, $outcomeCount, 0);
  728. $assessed_sections_count = 0;
  729. $school_sections_count = 0;
  730. foreach ($school->programs as $program) {
  731. foreach ($program->courses as $course) {
  732. if ($course->outcomes_achieved != NULL) {
  733. $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
  734. $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
  735. for ($i = 1; $i <= count($outcomes_attempted); $i++) {
  736. $outcomes_achieved[$i] += $course_outcomes_achieved[$i];
  737. $outcomes_attempted[$i] += $course_outcomes_attempted[$i];
  738. }
  739. $assessed_sections_count += 1;
  740. }
  741. $school_sections_count += 1;
  742. }
  743. }
  744. /**
  745. * Calculate how many programs achieved and attempted each outcome in this school
  746. */
  747. // Number of programs that achieved a particular learning outcome
  748. $achievedProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
  749. // Number of programs that attempted a particular learning outcome
  750. $attemptedProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
  751. $output = array();
  752. // For each outcome
  753. foreach ($outcomes as $outcome) {
  754. // For each program with courses that do assessment
  755. foreach (Program::with(array('courses' => function ($query) {
  756. // $query->whereNotNull('outcomes_attempted');
  757. $query->whereIn('semester_id', Session::get('semesters_ids'));
  758. }))->where('school_id', $school->id)->orderBy('name', 'asc')->get() as $program) {
  759. // To acummulate all criteria for one program
  760. $achieved_outcomes_per_program = array_fill(1, $outcomeCount, 0);
  761. $attempted_outcomes_per_program = array_fill(1, $outcomeCount, 0);
  762. //Flag for counting programs
  763. $flag = false;
  764. // For each course in the program
  765. foreach ($program->courses as $course) {
  766. // If the outcome in question is being evaluated
  767. $course_outcomes_attempted2 = json_decode($course->outcomes_attempted, true);
  768. $course_outcomes_achieved2 = json_decode($course->outcomes_achieved, true);
  769. if (
  770. array_key_exists($outcome->id, $course_outcomes_attempted2)
  771. && $course_outcomes_attempted2[$outcome->id] > 0
  772. ) {
  773. $achieved_outcomes_per_program[$outcome->id] += $course_outcomes_achieved2[$outcome->id];
  774. $attempted_outcomes_per_program[$outcome->id] += $course_outcomes_attempted2[$outcome->id];
  775. // Add one to the programs assessing, if it wasn't added before
  776. if (!$flag) {
  777. $attemptedProgramsPerOutcome[$outcome->id] += 1;
  778. $flag = true;
  779. }
  780. }
  781. // $output[] = 'ACHIEVED: '.$program->name.'-'.json_encode($achieved_outcomes_per_program);
  782. // $output[] = 'ATTEMPTED: '.$program->name.'-'.json_encode($attempted_outcomes_per_program);
  783. }
  784. //If the accumulated achieved criteria for a specific outcome in a program divided by the accumulated attempted criteria for a specific outcome in a program is greated than the expected outcome
  785. if ($attempted_outcomes_per_program[$outcome->id] != 0 && (float)$achieved_outcomes_per_program[$outcome->id] / $attempted_outcomes_per_program[$outcome->id] * 100 >= $outcome->expected_outcome) {
  786. $achievedProgramsPerOutcome[$outcome->id] += 1;
  787. // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
  788. }
  789. }
  790. }
  791. return View::make('local.managers.shared.print_school', compact('title', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'school', 'assessed_sections_count', 'school_sections_count', 'achievedProgramsPerOutcome', 'attemptedProgramsPerOutcome', 'grouped_courses', 'participating_programs'));
  792. }
  793. }