No Description

School.php 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  1. <?php
  2. class School extends Eloquent
  3. {
  4. public function programs()
  5. {
  6. return $this->hasMany('Program')->orderBy('name', 'asc');
  7. }
  8. public function coordinators()
  9. {
  10. return $this->hasMany('User');
  11. }
  12. public function courses()
  13. {
  14. return $this->hasManyThrough('Course', 'Program')->orderBy('name', 'asc');
  15. }
  16. public function templates()
  17. {
  18. return $this->hasMany('Template')->orderBy('name', 'asc');
  19. }
  20. public function getUndergraduateProgramsAttribute()
  21. {
  22. return $this->hasMany("Program")->where('is_graduate', 0)->orderBy("name", 'asc');
  23. }
  24. public function getGraduateProgramsAttribute()
  25. {
  26. return $this->hasMany("Program")->where('is_graduate', 1)->orderBy("name", 'asc');
  27. }
  28. //Esto envia
  29. /*
  30. [
  31. undergraduate_info:[
  32. outcomes_attempted_uncombined:{
  33. outcome_1: count(students),
  34. }
  35. outcomes_attempted_combined:{
  36. }
  37. outcomes_achieved_uncombined:{
  38. }
  39. outcomes_achieved_combined:{
  40. }
  41. ],
  42. graduate_info:[
  43. ]
  44. ]
  45. */
  46. public function getSchoolCoursesPerOutcomeAttribute()
  47. {
  48. $semesters = Semester::whereIn('id', Session::get('semesters_ids'))->get();
  49. $outcomes_grad = Outcome::active_by_semesters($semesters, 1);
  50. $outcomes_undergrad = Outcome::active_by_semesters($semesters, 0);
  51. $outcomes = Outcome::orderBy('name', 'asc')->get();
  52. $array_to_send = [];
  53. $undergraduate_students =
  54. DB::table('assessments')
  55. ->join('activity_criterion', 'activity_criterion.id', '=', 'assessments.activity_criterion_id')
  56. ->join('activities', 'activities.id', '=', 'activity_criterion.activity_id')
  57. ->join('courses', 'courses.id', '=', 'activities.course_id')
  58. ->join('students', 'students.id', '=', 'assessments.student_id')
  59. ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'activity_criterion.criterion_id')
  60. ->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
  61. ->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
  62. ->join('outcomes', 'criterion_objective_outcome.outcome_id', '=', 'outcomes.id')
  63. ->join('semesters', 'semesters.id', '=', 'courses.semester_id')
  64. ->whereIn('courses.program_id', $this->undergraduate_programs->lists('id'))
  65. ->whereIn('semester_id', Session::get('semesters_ids'))
  66. ->where('semesters.is_visible', '=', 1)
  67. ->select('student_id', 'courses.program_id', 'semesters.code', 'outcome_id', 'outcomes.expected_outcome', 'criterion_objective_outcome.criterion_id', 'score', 'expected_points')
  68. ->addSelect(DB::raw("count(activity_criterion.criterion_id) as criteria_attempted"))
  69. ->addSelect(DB::raw("count(CASE WHEN score>= expected_points then 1 else null END) as criteria_achieved"))
  70. ->groupBy('students.id', 'outcome_id');
  71. //->get();
  72. $undergraduate_students = $undergraduate_students->get();
  73. //$array_to_send["undergraduate_students"] = $undergraduate_students;
  74. $graduate_students = DB::table('assessments')
  75. ->join('activity_criterion', 'activity_criterion.id', '=', 'assessments.activity_criterion_id')
  76. ->join('activities', 'activities.id', '=', 'activity_criterion.activity_id')
  77. ->join('courses', 'courses.id', '=', 'activities.course_id')
  78. ->join('students', 'students.id', '=', 'assessments.student_id')
  79. ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'activity_criterion.criterion_id')
  80. ->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
  81. ->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
  82. ->join('semesters', 'semesters.id', '=', 'courses.semester_id')
  83. ->join('outcomes', 'criterion_objective_outcome.outcome_id', '=', 'outcomes.id')
  84. ->whereIn('courses.program_id', $this->graduate_programs->lists('id'))
  85. ->whereIn('semester_id', Session::get('semesters_ids'))
  86. ->where('semesters.is_visible', '=', 1)
  87. ->select('student_id', 'courses.program_id', 'semesters.code', 'outcome_id', 'outcomes.expected_outcome', 'criterion_objective_outcome.criterion_id', 'score', 'expected_points')
  88. ->addSelect(DB::raw("count(activity_criterion.criterion_id) as criteria_attempted"))
  89. ->addSelect(DB::raw("count(CASE WHEN score>= expected_points then 1 else null END) as criteria_achieved"))
  90. ->groupBy('students.id', 'outcome_id', 'courses.program_id')
  91. ->get();
  92. //$array_to_send["graduate_students"] = $graduate_students;
  93. //Log::info(count($graduate_students));
  94. //Log::info(count($undergraduate_students));
  95. $outcome_ids = DB::table("outcomes")
  96. ->whereNotNull('new_outcome_id')
  97. ->get();
  98. $combined_outcomes = [];
  99. foreach ($outcome_ids as $outcome) {
  100. $combined_outcomes[$outcome->id] = $outcome->new_outcome_id;
  101. }
  102. //Necesito undergraduateCombined, undergraduateUncombined,
  103. //lo mismo pa graduate
  104. $array_to_send['undergraduate_info'] = [];
  105. $array_to_send['graduate_info'] = [];
  106. $array_to_send['undergraduate_info']['outcomes_attempted_uncombined'] = [];
  107. $array_to_send['undergraduate_info']['outcomes_achieved_uncombined'] = [];
  108. $array_to_send['graduate_info']['outcomes_attempted_uncombined'] = [];
  109. $array_to_send['graduate_info']['outcomes_achieved_uncombined'] = [];
  110. $under_out_att = [];
  111. $under_out_ach = [];
  112. $program_out_att = [];
  113. $program_out_ach = [];
  114. foreach ($outcomes as $outcome) {
  115. $under_out_att[$outcome->id] = 0;
  116. $under_out_ach[$outcome->id] = 0;
  117. $program_out_att[$outcome->id] = [];
  118. $program_out_ach[$outcome->id] = [];
  119. }
  120. //Para los programas attempted, voy a tener, un arreglo por dominio, y cada dominio tendra
  121. //indices por cada programa, y cada programa tendrá conteo del estudiantes que intentaron y
  122. // estudiantes que fallaron.
  123. //las filas son , estudiante, outcome que intentó, criterios_attempted, criterion_achieved,
  124. foreach ($undergraduate_students as $result) {
  125. $crit_att = $result->criteria_attempted;
  126. $crit_ach = $result->criteria_achieved;
  127. $expected_outcome = $result->expected_outcome;
  128. $program_id = $result->program_id;
  129. if (!isset($program_out_att[$result->outcome_id][$program_id])) {
  130. $program_out_att[$result->outcome_id][$program_id] = 0;
  131. }
  132. $program_out_att[$result->outcome_id][$program_id] += 1;
  133. $under_out_att[$result->outcome_id] += 1;
  134. if ($crit_att != 0 && ($crit_ach / $crit_att) * 100 >= $expected_outcome) {
  135. if (!isset($program_out_ach[$result->outcome_id][$program_id])) {
  136. $program_out_ach[$result->outcome_id][$program_id] = 0;
  137. }
  138. $program_out_ach[$result->outcome_id][$program_id] += 1;
  139. $under_out_ach[$result->outcome_id] += 1;
  140. }
  141. }
  142. $array_to_send['undergraduate_info']['programs_attempted_uncombined'] = $program_out_att;
  143. $array_to_send['undergraduate_info']['programs_achieved_uncombined'] = $program_out_ach;
  144. $array_to_send['undergraduate_info']['outcomes_attempted_uncombined'] = $under_out_att;
  145. $array_to_send['undergraduate_info']['outcomes_achieved_uncombined'] = $under_out_ach;
  146. $grad_out_att = [];
  147. $grad_out_ach = [];
  148. foreach ($outcomes as $outcome) {
  149. $grad_out_att[$outcome->id] = 0;
  150. $grad_out_ach[$outcome->id] = 0;
  151. $program_out_att[$outcome->id] = [];
  152. $program_out_ach[$outcome->id] = [];
  153. }
  154. //las filas son , estudiante, outcome que intentó, criterios_attempted, criterion_achieved,
  155. foreach ($graduate_students as $result) {
  156. $crit_att = $result->criteria_attempted;
  157. $crit_ach = $result->criteria_achieved;
  158. $expected_outcome = $result->expected_outcome;
  159. $program_id = $result->program_id;
  160. if (!isset($program_out_att[$result->outcome_id][$program_id])) {
  161. $program_out_att[$result->outcome_id][$program_id] = 0;
  162. }
  163. $program_out_att[$result->outcome_id][$program_id] += 1;
  164. $grad_out_att[$result->outcome_id] += 1;
  165. if ($crit_att != 0 && ($crit_ach / $crit_att) * 100 >= $expected_outcome) {
  166. if (!isset($program_out_ach[$result->outcome_id][$program_id])) {
  167. $program_out_ach[$result->outcome_id][$program_id] = 0;
  168. }
  169. $program_out_ach[$result->outcome_id][$program_id] += 1;
  170. $grad_out_ach[$result->outcome_id] += 1;
  171. }
  172. }
  173. $array_to_send['graduate_info']['outcomes_attempted_uncombined'] = $grad_out_att;
  174. $array_to_send['graduate_info']['outcomes_achieved_uncombined'] = $grad_out_ach;
  175. $array_to_send['graduate_info']['programs_attempted_uncombined'] = $program_out_att;
  176. $array_to_send['graduate_info']['programs_achieved_uncombined'] = $program_out_ach;
  177. $array_to_send['undergraduate_info']['outcomes_attempted_combined'] = [];
  178. $array_to_send['undergraduate_info']['outcomes_achieved_combined'] = [];
  179. $array_to_send['graduate_info']['outcomes_attempted_combined'] = [];
  180. $array_to_send['graduate_info']['outcomes_achieved_combined'] = [];
  181. $under_out_att = [];
  182. $under_out_ach = [];
  183. foreach ($outcomes as $outcome) {
  184. $under_out_att[$outcome->id] = 0;
  185. $under_out_ach[$outcome->id] = 0;
  186. $program_out_att[$outcome->id] = [];
  187. $program_out_ach[$outcome->id] = [];
  188. }
  189. //preprocess para combined_students
  190. $the_processed_table = [];
  191. foreach ($undergraduate_students as $result) {
  192. $student_id = $result->student_id;
  193. $outcome_id = $result->outcome_id;
  194. $expected_outcome = $result->expected_outcome;
  195. if (isset($combined_outcomes[$outcome_id]))
  196. $outcome_id = $combined_outcomes[$outcome_id];
  197. if (!isset($the_processed_table[$student_id])) {
  198. $the_processed_table[$student_id] = [];
  199. }
  200. //si en esta tabla, el estudiante no está pareado con este dominio, entonces registra
  201. // los criterios, achieved y attempted
  202. if (!isset($the_processed_table[$student_id][$outcome_id])) {
  203. $the_processed_table[$student_id][$outcome_id] = array(
  204. "criteria_attempted" => $result->criteria_attempted,
  205. "criteria_achieved" => $result->criteria_achieved,
  206. 'expected_outcome' => $expected_outcome,
  207. "program_id" => $result->program_id
  208. );
  209. }
  210. //si este estudiante está pareado a este dominio, significa que ahora estoy en los
  211. //deprecated outcomes.
  212. else {
  213. $the_processed_table[$student_id][$outcome_id]['criteria_attempted'] += $result->criteria_attempted;
  214. $the_processed_table[$student_id][$outcome_id]['criteria_achieved'] += $result->criteria_achieved;
  215. }
  216. }
  217. foreach ($the_processed_table as $student_id => $outcome_ids) {
  218. foreach ($outcome_ids as $outcome_id => $crit_information) {
  219. $crit_att = $crit_information['criteria_attempted'];
  220. $crit_ach = $crit_information['criteria_achieved'];
  221. $program_id = $crit_information['program_id'];
  222. $expected_outcome = $crit_information['expected_outcome'];
  223. $under_out_att[$outcome_id] += 1;
  224. if (!isset($program_out_att[$outcome_id][$program_id])) {
  225. $program_out_att[$outcome_id][$program_id] = 0;
  226. }
  227. $program_out_att[$outcome_id][$program_id] += 1;
  228. if ($crit_att != 0 && ($crit_ach / $crit_att) * 100 >= $expected_outcome) {
  229. if (!isset($program_out_ach[$outcome_id][$program_id])) {
  230. $program_out_ach[$outcome_id][$program_id] = 0;
  231. }
  232. $program_out_ach[$outcome_id][$program_id] += 1;
  233. $under_out_ach[$outcome_id] += 1;
  234. }
  235. }
  236. }
  237. $array_to_send['undergraduate_info']['outcomes_attempted_combined'] = $under_out_att;
  238. $array_to_send['undergraduate_info']['outcomes_achieved_combined'] = $under_out_ach;
  239. $array_to_send['undergraduate_info']['programs_attempted_combined'] = $program_out_att;
  240. $array_to_send['undergraduate_info']['programs_achieved_combined'] = $program_out_ach;
  241. $grad_out_att = [];
  242. $grad_out_ach = [];
  243. foreach ($outcomes as $outcome) {
  244. $grad_out_att[$outcome->id] = 0;
  245. $grad_out_ach[$outcome->id] = 0;
  246. $program_out_att[$outcome->id] = [];
  247. $program_out_ach[$outcome->id] = [];
  248. }
  249. //preprocess para combined_students
  250. $the_processed_table = [];
  251. foreach ($graduate_students as $result) {
  252. $student_id = $result->student_id;
  253. $outcome_id = $result->outcome_id;
  254. $expected_outcome = $result->expected_outcome;
  255. if (isset($combined_outcomes[$outcome_id]))
  256. $outcome_id = $combined_outcomes[$outcome_id];
  257. if (!isset($the_processed_table[$student_id])) {
  258. $the_processed_table[$student_id] = [];
  259. }
  260. //si en esta tabla, el estudiante no está pareado con este dominio, entonces registra
  261. // los criterios, achieved y attempted
  262. if (!isset($the_processed_table[$student_id][$outcome_id])) {
  263. $the_processed_table[$student_id][$outcome_id] = array(
  264. "criteria_attempted" => $result->criteria_attempted,
  265. "criteria_achieved" => $result->criteria_achieved,
  266. 'expected_outcome' => $expected_outcome,
  267. 'program_id' => $result->program_id
  268. );
  269. }
  270. //si este estudiante está pareado a este dominio, significa que ahora estoy en los
  271. //deprecated outcomes.
  272. else {
  273. $the_processed_table[$student_id][$outcome_id]['criteria_attempted'] += $result->criteria_attempted;
  274. $the_processed_table[$student_id][$outcome_id]['criteria_achieved'] += $result->criteria_achieved;
  275. }
  276. }
  277. foreach ($the_processed_table as $student_id => $outcome_ids) {
  278. foreach ($outcome_ids as $out_id => $crit_information) {
  279. $crit_att = $crit_information['criteria_attempted'];
  280. $crit_ach = $crit_information['criteria_achieved'];
  281. $program_id = $crit_information['program_id'];
  282. $expected_outcome = $crit_information['expected_outcome'];
  283. $grad_out_att[$out_id] += 1;
  284. if (!isset($program_out_att[$out_id][$program_id])) {
  285. $program_out_att[$out_id][$program_id] = 0;
  286. }
  287. $program_out_att[$out_id][$program_id] += 1;
  288. if ($crit_att != 0 && ($crit_ach / $crit_att) * 100 >= $expected_outcome) {
  289. if (!isset($program_out_ach[$out_id][$program_id])) {
  290. $program_out_ach[$out_id][$program_id] = 0;
  291. }
  292. $program_out_ach[$out_id][$program_id] += 1;
  293. $grad_out_ach[$out_id] += 1;
  294. }
  295. }
  296. }
  297. $array_to_send['graduate_info']['outcomes_attempted_combined'] = $grad_out_att;
  298. $array_to_send['graduate_info']['outcomes_achieved_combined'] = $grad_out_ach;
  299. $array_to_send['graduate_info']['programs_attempted_combined'] = $program_out_att;
  300. $array_to_send['graduate_info']['programs_achieved_combined'] = $program_out_ach;
  301. Log::info($array_to_send);
  302. return $array_to_send;
  303. }
  304. public function getSchoolStudentsPerOutcomeAttribute()
  305. {
  306. $semesters = Semester::whereIn('id', Session::get('semesters_ids'))->get();
  307. $outcomes_grad = Outcome::active_by_semesters($semesters, 1);
  308. $outcomes_undergrad = Outcome::active_by_semesters($semesters, 0);
  309. $outcomes = Outcome::orderBy('name', 'asc')->get();
  310. $array_to_send = [];
  311. $undergraduate_students =
  312. DB::table('assessments')
  313. ->join('activity_criterion', 'activity_criterion.id', '=', 'assessments.activity_criterion_id')
  314. ->join('activities', 'activities.id', '=', 'activity_criterion.activity_id')
  315. ->join('courses', 'courses.id', '=', 'activities.course_id')
  316. ->join('students', 'students.id', '=', 'assessments.student_id')
  317. ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'activity_criterion.criterion_id')
  318. ->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
  319. ->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
  320. ->join('semesters', 'semesters.id', '=', 'courses.semester_id')
  321. ->join('outcomes', 'criterion_objective_outcome.outcome_id', '=', 'outcomes.id')
  322. ->whereIn('students.program_id', $this->undergraduate_programs->lists('id'))
  323. ->whereIn('semester_id', Session::get('semesters_ids'))
  324. ->where('semesters.is_visible', '=', 1)
  325. ->select('student_id', 'students.program_id', 'semesters.code', 'outcome_id', 'outcomes.expected_outcome', 'criterion_objective_outcome.criterion_id', 'score', 'expected_points')
  326. ->addSelect(DB::raw("count(activity_criterion.criterion_id) as criteria_attempted"))
  327. ->addSelect(DB::raw("count(CASE WHEN score>= expected_points then 1 else null END) as criteria_achieved"))
  328. ->groupBy('students.id', 'outcome_id');
  329. //->get();
  330. $undergraduate_students = $undergraduate_students->get();
  331. //$array_to_send["undergraduate_students"] = $undergraduate_students;
  332. $graduate_students = DB::table('assessments')
  333. ->join('activity_criterion', 'activity_criterion.id', '=', 'assessments.activity_criterion_id')
  334. ->join('activities', 'activities.id', '=', 'activity_criterion.activity_id')
  335. ->join('courses', 'courses.id', '=', 'activities.course_id')
  336. ->join('students', 'students.id', '=', 'assessments.student_id')
  337. ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'activity_criterion.criterion_id')
  338. ->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
  339. ->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
  340. ->join('semesters', 'semesters.id', '=', 'courses.semester_id')
  341. ->join('outcomes', 'criterion_objective_outcome.outcome_id', '=', 'outcomes.id')
  342. ->whereIn('students.program_id', $this->graduate_programs->lists('id'))
  343. ->whereIn('semester_id', Session::get('semesters_ids'))
  344. ->where('semesters.is_visible', '=', 1)
  345. ->select('student_id', 'students.program_id', 'semesters.code', 'outcome_id', 'outcomes.expected_outcome', 'criterion_objective_outcome.criterion_id', 'score', 'expected_points')
  346. ->addSelect(DB::raw("count(activity_criterion.criterion_id) as criteria_attempted"))
  347. ->addSelect(DB::raw("count(CASE WHEN score>= expected_points then 1 else null END) as criteria_achieved"))
  348. ->groupBy('students.id', 'outcome_id')
  349. ->get();
  350. //$array_to_send["graduate_students"] = $graduate_students;
  351. //Log::info(count($graduate_students));
  352. //Log::info(count($undergraduate_students));
  353. $outcome_ids = DB::table("outcomes")
  354. ->whereNotNull('new_outcome_id')
  355. ->get();
  356. $combined_outcomes = [];
  357. foreach ($outcome_ids as $outcome) {
  358. $combined_outcomes[$outcome->id] = $outcome->new_outcome_id;
  359. }
  360. //Necesito undergraduateCombined, undergraduateUncombined,
  361. //lo mismo pa graduate
  362. $array_to_send['undergraduate_info'] = [];
  363. $array_to_send['graduate_info'] = [];
  364. $array_to_send['undergraduate_info']['outcomes_attempted_uncombined'] = [];
  365. $array_to_send['undergraduate_info']['outcomes_achieved_uncombined'] = [];
  366. $array_to_send['graduate_info']['outcomes_attempted_uncombined'] = [];
  367. $array_to_send['graduate_info']['outcomes_achieved_uncombined'] = [];
  368. $under_out_att = [];
  369. $under_out_ach = [];
  370. $program_out_att = [];
  371. $program_out_ach = [];
  372. foreach ($outcomes as $outcome) {
  373. $under_out_att[$outcome->id] = 0;
  374. $under_out_ach[$outcome->id] = 0;
  375. $program_out_att[$outcome->id] = [];
  376. $program_out_ach[$outcome->id] = [];
  377. }
  378. //Para los programas attempted, voy a tener, un arreglo por dominio, y cada dominio tendra
  379. //indices por cada programa, y cada programa tendrá conteo del estudiantes que intentaron y
  380. // estudiantes que fallaron.
  381. //las filas son , estudiante, outcome que intentó, criterios_attempted, criterion_achieved,
  382. foreach ($undergraduate_students as $result) {
  383. $crit_att = $result->criteria_attempted;
  384. $crit_ach = $result->criteria_achieved;
  385. $expected_outcome = $result->expected_outcome;
  386. $program_id = $result->program_id;
  387. if (!isset($program_out_att[$result->outcome_id][$program_id])) {
  388. $program_out_att[$result->outcome_id][$program_id] = 0;
  389. }
  390. $program_out_att[$result->outcome_id][$program_id] += 1;
  391. $under_out_att[$result->outcome_id] += 1;
  392. if ($crit_att != 0 && ($crit_ach / $crit_att) * 100 >= $expected_outcome) {
  393. if (!isset($program_out_ach[$result->outcome_id][$program_id])) {
  394. $program_out_ach[$result->outcome_id][$program_id] = 0;
  395. }
  396. $program_out_ach[$result->outcome_id][$program_id] += 1;
  397. $under_out_ach[$result->outcome_id] += 1;
  398. }
  399. }
  400. $array_to_send['undergraduate_info']['programs_attempted_uncombined'] = $program_out_att;
  401. $array_to_send['undergraduate_info']['programs_achieved_uncombined'] = $program_out_ach;
  402. $array_to_send['undergraduate_info']['outcomes_attempted_uncombined'] = $under_out_att;
  403. $array_to_send['undergraduate_info']['outcomes_achieved_uncombined'] = $under_out_ach;
  404. $grad_out_att = [];
  405. $grad_out_ach = [];
  406. foreach ($outcomes as $outcome) {
  407. $grad_out_att[$outcome->id] = 0;
  408. $grad_out_ach[$outcome->id] = 0;
  409. $program_out_att[$outcome->id] = [];
  410. $program_out_ach[$outcome->id] = [];
  411. }
  412. //las filas son , estudiante, outcome que intentó, criterios_attempted, criterion_achieved,
  413. foreach ($graduate_students as $result) {
  414. $crit_att = $result->criteria_attempted;
  415. $crit_ach = $result->criteria_achieved;
  416. $expected_outcome = $result->expected_outcome;
  417. $program_id = $result->program_id;
  418. if (!isset($program_out_att[$result->outcome_id][$program_id])) {
  419. $program_out_att[$result->outcome_id][$program_id] = 0;
  420. }
  421. $program_out_att[$result->outcome_id][$program_id] += 1;
  422. $grad_out_att[$result->outcome_id] += 1;
  423. if ($crit_att != 0 && ($crit_ach / $crit_att) * 100 >= $expected_outcome) {
  424. if (!isset($program_out_ach[$result->outcome_id][$program_id])) {
  425. $program_out_ach[$result->outcome_id][$program_id] = 0;
  426. }
  427. $program_out_ach[$result->outcome_id][$program_id] += 1;
  428. $grad_out_ach[$result->outcome_id] += 1;
  429. }
  430. }
  431. $array_to_send['graduate_info']['outcomes_attempted_uncombined'] = $grad_out_att;
  432. $array_to_send['graduate_info']['outcomes_achieved_uncombined'] = $grad_out_ach;
  433. $array_to_send['graduate_info']['programs_attempted_uncombined'] = $program_out_att;
  434. $array_to_send['graduate_info']['programs_achieved_uncombined'] = $program_out_ach;
  435. $array_to_send['undergraduate_info']['outcomes_attempted_combined'] = [];
  436. $array_to_send['undergraduate_info']['outcomes_achieved_combined'] = [];
  437. $array_to_send['graduate_info']['outcomes_attempted_combined'] = [];
  438. $array_to_send['graduate_info']['outcomes_achieved_combined'] = [];
  439. $under_out_att = [];
  440. $under_out_ach = [];
  441. foreach ($outcomes as $outcome) {
  442. $under_out_att[$outcome->id] = 0;
  443. $under_out_ach[$outcome->id] = 0;
  444. $program_out_att[$outcome->id] = [];
  445. $program_out_ach[$outcome->id] = [];
  446. }
  447. //preprocess para combined_students
  448. $the_processed_table = [];
  449. foreach ($undergraduate_students as $result) {
  450. $student_id = $result->student_id;
  451. $outcome_id = $result->outcome_id;
  452. $expected_outcome = $result->expected_outcome;
  453. if (isset($combined_outcomes[$outcome_id]))
  454. $outcome_id = $combined_outcomes[$outcome_id];
  455. if (!isset($the_processed_table[$student_id])) {
  456. $the_processed_table[$student_id] = [];
  457. }
  458. //si en esta tabla, el estudiante no está pareado con este dominio, entonces registra
  459. // los criterios, achieved y attempted
  460. if (!isset($the_processed_table[$student_id][$outcome_id])) {
  461. $the_processed_table[$student_id][$outcome_id] = array(
  462. "criteria_attempted" => $result->criteria_attempted,
  463. "criteria_achieved" => $result->criteria_achieved,
  464. "program_id" => $result->program_id,
  465. 'expected_outcome' => $expected_outcome
  466. );
  467. }
  468. //si este estudiante está pareado a este dominio, significa que ahora estoy en los
  469. //deprecated outcomes.
  470. else {
  471. $the_processed_table[$student_id][$outcome_id]['criteria_attempted'] += $result->criteria_attempted;
  472. $the_processed_table[$student_id][$outcome_id]['criteria_achieved'] += $result->criteria_achieved;
  473. }
  474. }
  475. foreach ($the_processed_table as $student_id => $outcome_ids) {
  476. foreach ($outcome_ids as $outcome_id => $crit_information) {
  477. $crit_att = $crit_information['criteria_attempted'];
  478. $crit_ach = $crit_information['criteria_achieved'];
  479. $program_id = $crit_information['program_id'];
  480. $expected_outcome = $crit_information['expected_outcome'];
  481. $under_out_att[$outcome_id] += 1;
  482. if (!isset($program_out_att[$outcome_id][$program_id])) {
  483. $program_out_att[$outcome_id][$program_id] = 0;
  484. }
  485. $program_out_att[$outcome_id][$program_id] += 1;
  486. if ($crit_att != 0 && ($crit_ach / $crit_att) * 100 >= $expected_outcome) {
  487. if (!isset($program_out_ach[$outcome_id][$program_id])) {
  488. $program_out_ach[$outcome_id][$program_id] = 0;
  489. }
  490. $program_out_ach[$outcome_id][$program_id] += 1;
  491. $under_out_ach[$outcome_id] += 1;
  492. }
  493. }
  494. }
  495. $array_to_send['undergraduate_info']['outcomes_attempted_combined'] = $under_out_att;
  496. $array_to_send['undergraduate_info']['outcomes_achieved_combined'] = $under_out_ach;
  497. $array_to_send['undergraduate_info']['programs_attempted_combined'] = $program_out_att;
  498. $array_to_send['undergraduate_info']['programs_achieved_combined'] = $program_out_ach;
  499. $grad_out_att = [];
  500. $grad_out_ach = [];
  501. foreach ($outcomes as $outcome) {
  502. $grad_out_att[$outcome->id] = 0;
  503. $grad_out_ach[$outcome->id] = 0;
  504. $program_out_att[$outcome->id] = [];
  505. $program_out_ach[$outcome->id] = [];
  506. }
  507. //preprocess para combined_students
  508. $the_processed_table = [];
  509. foreach ($graduate_students as $result) {
  510. $student_id = $result->student_id;
  511. $outcome_id = $result->outcome_id;
  512. $expected_outcome = $result->expected_outcome;
  513. if (isset($combined_outcomes[$outcome_id]))
  514. $outcome_id = $combined_outcomes[$outcome_id];
  515. if (!isset($the_processed_table[$student_id])) {
  516. $the_processed_table[$student_id] = [];
  517. }
  518. //si en esta tabla, el estudiante no está pareado con este dominio, entonces registra
  519. // los criterios, achieved y attempted
  520. if (!isset($the_processed_table[$student_id][$outcome_id])) {
  521. $the_processed_table[$student_id][$outcome_id] = array(
  522. "criteria_attempted" => $result->criteria_attempted,
  523. "criteria_achieved" => $result->criteria_achieved,
  524. 'program_id' => $result->program_id,
  525. 'expected_outcome' => $expected_outcome
  526. );
  527. }
  528. //si este estudiante está pareado a este dominio, significa que ahora estoy en los
  529. //deprecated outcomes.
  530. else {
  531. $the_processed_table[$student_id][$outcome_id]['criteria_attempted'] += $result->criteria_attempted;
  532. $the_processed_table[$student_id][$outcome_id]['criteria_achieved'] += $result->criteria_achieved;
  533. }
  534. }
  535. foreach ($the_processed_table as $student_id => $outcome_ids) {
  536. foreach ($outcome_ids as $out_id => $crit_information) {
  537. $crit_att = $crit_information['criteria_attempted'];
  538. $crit_ach = $crit_information['criteria_achieved'];
  539. $program_id = $crit_information['program_id'];
  540. $expected_outcome = $crit_information['expected_outcome'];
  541. $grad_out_att[$out_id] += 1;
  542. if (!isset($program_out_att[$out_id][$program_id])) {
  543. $program_out_att[$out_id][$program_id] = 0;
  544. }
  545. $program_out_att[$out_id][$program_id] += 1;
  546. if ($crit_att != 0 && ($crit_ach / $crit_att) * 100 >= $expected_outcome) {
  547. if (!isset($program_out_ach[$out_id][$program_id])) {
  548. $program_out_ach[$out_id][$program_id] = 0;
  549. }
  550. $program_out_ach[$out_id][$program_id] += 1;
  551. $grad_out_ach[$out_id] += 1;
  552. }
  553. }
  554. }
  555. $array_to_send['graduate_info']['outcomes_attempted_combined'] = $grad_out_att;
  556. $array_to_send['graduate_info']['outcomes_achieved_combined'] = $grad_out_ach;
  557. $array_to_send['graduate_info']['programs_attempted_combined'] = $program_out_att;
  558. $array_to_send['graduate_info']['programs_achieved_combined'] = $program_out_ach;
  559. Log::info($array_to_send);
  560. return $array_to_send;
  561. }
  562. }