説明なし

ProfessorsController.php 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <?php
  2. class ProfessorsController extends \BaseController
  3. {
  4. private $grouped_courses;
  5. public function __construct()
  6. {
  7. $this->courses = Auth::user()->courses;
  8. }
  9. public function overview()
  10. {
  11. $title = 'My Courses';
  12. $grouped_courses = Course::with('program')
  13. ->where('user_id', Auth::user()->id)
  14. ->whereIn('semester_id', Session::get('semesters_ids'))
  15. ->select("courses.*") //, 'programs.*')
  16. ->addSelect(DB::raw("1 as grouped"))
  17. ->groupBy(array('code', 'number', 'semester_id'))->get();
  18. $semesters = Session::get('semesters_ids');
  19. $semesters = DB::table('semesters')->whereIn('id', $semesters)->orderBy('start', 'ASC')->first();
  20. Log::info($semesters->start);
  21. $outcomes = Outcome::select(array('id', 'name', 'expected_outcome', 'level'))
  22. ->whereNull('deleted_at')
  23. ->whereRaw("(deactivation_date IS NULL or deactivation_date >= '{$semesters->start}')")
  24. ->orderBy('name', 'ASC')->get();
  25. $outcomeCount = count($outcomes);
  26. foreach ($grouped_courses as $index => $grouped_course) {
  27. // Blank outcomes for one course
  28. //$outcomes_achieved = array_fill(1, $outcomeCount, 0);
  29. //$outcomes_attempted = array_fill(1, $outcomeCount, 0);
  30. $outcomes_achieved = [];
  31. $outcomes_attempted = [];
  32. foreach ($outcomes as $outcome) {
  33. $outcomes_achieved[$outcome->id] = 0;
  34. $outcomes_attempted[$outcome->id] = 0;
  35. }
  36. // Find sections belonging to user with identifier of one course
  37. $sections = Course::with('program')
  38. ->where('user_id', Auth::user()->id)
  39. ->where('code', $grouped_course->code)
  40. ->whereIn('semester_id', Session::get('semesters_ids'))
  41. ->where('number', $grouped_course->number)
  42. ->where('semester_id', $grouped_course->semester_id)
  43. ->get();
  44. $results = $grouped_course->student_report_for_outcome;
  45. Log::info($results);
  46. foreach ($outcomes as $outcome) {
  47. $outcomes_attempted[$outcome->id] += isset($results[$outcome->id]) ? $results[$outcome->id]['calculations']['student_attempted'] : 0;
  48. $outcomes_achieved[$outcome->id] += isset($results[$outcome->id]) ? $results[$outcome->id]['calculations']['student_achieved'] : 0;
  49. }
  50. // Log::info($sections);
  51. // For each of the professor's course sections, add the attempted and achieved criteria per outcome
  52. /*
  53. foreach ($sections as $section) {
  54. $section_outcomes_achieved = $section->outcomes_ach();
  55. $section_outcomes_attempted = $section->outcomes_att();
  56. //if ($section->outcomes_achieved != NULL) {
  57. if (!empty($section_outcomes_achieved)) {
  58. //$section_outcomes_achieved = json_decode($section->outcomes_achieved, true);
  59. //$section_outcomes_attempted = json_decode($section->outcomes_attempted, true);
  60. foreach ($section_outcomes_attempted as $outcome_id => $score) {
  61. if (array_key_exists($outcome_id, $outcomes_achieved) && array_key_exists($outcome_id, $section_outcomes_achieved)) {
  62. $outcomes_achieved[$outcome_id] += $section_outcomes_achieved[$outcome_id];
  63. } elseif (array_key_exists($outcome_id, $outcomes_achieved)) {
  64. $outcomes_achieved[$outcome_id] += 0;
  65. } elseif (array_key_exists($outcome_id, $section_outcomes_achieved)) {
  66. $outcomes_achieved[$outcome_id] = $section_outcomes_achieved[$outcome_id];
  67. } else {
  68. $outcomes_achieved[$outcome_id] = 0;
  69. }
  70. if (array_key_exists($outcome_id, $outcomes_attempted)) {
  71. $outcomes_attempted[$outcome_id] += $section_outcomes_attempted[$outcome_id];
  72. } else {
  73. $outcomes_attempted[$outcome_id] = $section_outcomes_attempted[$outcome_id];
  74. }
  75. //$outcomes_achieved[$outcome_id] += $section_outcomes_achieved[$outcome_id];
  76. //$outcomes_attempted[$outcome_id] += $section_outcomes_attempted[$outcome_id];
  77. }
  78. }
  79. }*/
  80. $grouped_outcomes_achieved_results[] = $outcomes_achieved;
  81. $grouped_outcomes_attempted_results[] = $outcomes_attempted;
  82. $grouped_sections[] = $sections;
  83. }
  84. return View::make('local.professors.overview', compact('title', 'grouped_courses', 'outcomes', 'grouped_outcomes_attempted_results', 'grouped_outcomes_achieved_results', 'grouped_sections'));
  85. }
  86. public function program()
  87. {
  88. $program = Auth::user()->programs[0];
  89. $title = 'Your Program: ' . $program->name;
  90. $program_courses = Course::where('program_id', '=', $program->id)->whereIn('semester_id', Session::get('semesters_ids'))->get();
  91. $semesters = Session::get('semesters_ids');
  92. $semesters = DB::table('semesters')->whereIn('id', $semesters)->orderBy('start', 'ASC')->first();
  93. $semesters2 = Semester::whereIn('id', Session::get('semesters_ids'))->get();
  94. // $outcomes = Outcome::select(array('id', 'name', 'expected_outcome'))
  95. // ->where('level','=',)
  96. // ->whereNull('deleted_at')
  97. // ->whereRaw("(deactivation_date IS NULL or deactivation_date >= '{$semesters->start}')")
  98. // ->orderBy('name', 'ASC')->get();
  99. $outcomes = Outcome::active_by_semesters($semesters2, $program->is_graduate);
  100. $outcomeCount = count($outcomes);
  101. $outcomes_achieved = [];
  102. $outcomes_attempted = [];
  103. $program_outcomes_achieved = [];
  104. $program_outcomes_attempted = [];
  105. //Log::info($program_courses);
  106. foreach ($outcomes as $outcome) {
  107. $outcomes_achieved[$outcome->id] = 0;
  108. $outcomes_attempted[$outcome->id] = 0;
  109. $program_outcomes_achieved[$outcome->id] = 0;
  110. $program_outcomes_attempted[$outcome->id] = 0;
  111. }
  112. $program_outcomes_attempted = $program->program_students_per_outcome['program_info']['outcomes_attempted_combined'];
  113. $program_outcomes_achieved = $program->program_students_per_outcome['program_info']['outcomes_achieved_combined'];
  114. /*
  115. foreach ($program_courses as $course) {
  116. if ($course->outcomes_ach()) {
  117. $course_outcomes_achieved = $course->outcomes_ach();
  118. $course_outcomes_attempted = $course->outcomes_att();
  119. foreach ($course_outcomes_achieved as $outcome => $score) {
  120. if (array_key_exists($outcome, $outcomes_achieved))
  121. $outcomes_achieved[$outcome] += $score;
  122. else $outcomes_achieved[$outcome] = $score;
  123. }
  124. foreach ($course_outcomes_attempted as $outcome => $score) {
  125. if (array_key_exists($outcome, $outcomes_attempted))
  126. $outcomes_attempted[$outcome] += $score;
  127. else $outcomes_attempted[$outcome] = $score;
  128. }
  129. }
  130. }*/
  131. //Log::info($program->courses_students_score_per_outcome);
  132. $outcomes_achieved = $program->courses_students_score_per_outcome['program_info']['outcomes_achieved_combined'];
  133. $outcomes_attempted = $program->courses_students_score_per_outcome['program_info']['outcomes_attempted_combined'];
  134. /*
  135. foreach ($program_courses as $course) {
  136. $stu_ach = $course->student_report_for_outcome;
  137. foreach ($stu_ach as $outcome => $outcome_score) {
  138. if (array_key_exists($outcome, $outcomes_achieved))
  139. $outcomes_achieved[$outcome] += $outcome_score['calculations']['student_achieved'];
  140. else $outcomes_achieved[$outcome] = $outcome_score['calculations']['student_achieved'];
  141. if (array_key_exists($outcome, $outcomes_attempted))
  142. $outcomes_attempted[$outcome] += $outcome_score['calculations']['student_attempted'];
  143. else $outcomes_attempted[$outcome] = $outcome_score['calculations']['student_attempted'];
  144. }
  145. /*
  146. $course->with_program_report = 1;
  147. $stu_ach = $course->student_report_for_outcome;
  148. foreach ($stu_ach as $outcome => $outcome_score) {
  149. if (array_key_exists($outcome, $program_outcomes_achieved))
  150. $program_outcomes_achieved[$outcome] += $outcome_score['calculations']['student_achieved'];
  151. else $program_outcomes_achieved[$outcome] = $outcome_score['calculations']['student_achieved'];
  152. if (array_key_exists($outcome, $program_outcomes_attempted))
  153. $program_outcomes_attempted[$outcome] += $outcome_score['calculations']['student_attempted'];
  154. else $program_outcomes_attempted[$outcome] = $outcome_score['calculations']['student_attempted'];
  155. }
  156. }*/
  157. // Program contact information
  158. $scoords = User::where('school_id', $program->school_id)
  159. ->where('role', 2)
  160. ->get();
  161. $pcoords = User::select('users.*')
  162. ->join('program_user', 'users.id', '=', 'program_user.user_id')
  163. ->where('role', 3)
  164. ->where('program_id', $program->id)
  165. ->get();
  166. return View::make('local.professors.program', compact('title', 'outcomes', 'program_outcomes_achieved', 'program_outcomes_attempted', 'outcomes_attempted', 'program', 'outcomes_achieved', 'scoords', 'pcoords'));
  167. }
  168. public function generalStudiesOverview()
  169. {
  170. $title = 'General Component Assessment Overview';
  171. try {
  172. $programs = Program::generalComponentPrograms();
  173. } catch (Exception $e) {
  174. dd('Unable to find general component programs');
  175. }
  176. $outcomes = Outcome::orderBy('name', 'asc')->get();
  177. $schools = School::all();
  178. $program_packs = array();
  179. if (!$programs->isEmpty()) {
  180. foreach ($programs as $program) {
  181. $program_packs[] = $program->assessmentOverview();
  182. }
  183. }
  184. return View::make('local.managers.shared.general_studies_overview', compact('title', 'outcomes', 'schools', 'program_packs'));
  185. }
  186. }