暂无描述

ProfessorsController.php 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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::where('user_id', Auth::user()->id)->whereIn('semester_id', Session::get('semesters_ids'))->groupBy(array('code', 'number', 'semester_id'))->get();
  13. $semesters = Session::get('semesters_ids');
  14. $semesters = DB::table('semesters')->whereIn('id', $semesters)->orderBy('start', 'ASC')->first();
  15. Log::info($semesters->start);
  16. $outcomes = Outcome::select(array('id', 'name', 'expected_outcome'))
  17. ->whereNull('deleted_at')
  18. ->whereRaw("(deactivation_date IS NULL or deactivation_date >= '{$semesters->start}')")
  19. ->orderBy('name', 'ASC')->get();
  20. $outcomeCount = count($outcomes);
  21. $grouped_outcomes_achieved_results = array();
  22. $grouped_outcomes_attempted_results = array();
  23. $grouped_sections = array();
  24. foreach ($grouped_courses as $index => $grouped_course) {
  25. // Blank outcomes for one course
  26. //$outcomes_achieved = array_fill(1, $outcomeCount, 0);
  27. //$outcomes_attempted = array_fill(1, $outcomeCount, 0);
  28. $outcomes_achieved = [];
  29. $outcomes_attempted = [];
  30. // Find sections belonging to user with identifier of one course
  31. $sections = Course::where('user_id', Auth::user()->id)
  32. ->where('code', $grouped_course->code)
  33. ->whereIn('semester_id', Session::get('semesters_ids'))
  34. ->where('number', $grouped_course->number)
  35. ->where('semester_id', $grouped_course->semester_id)
  36. ->get();
  37. // For each of the professor's course sections, add the attempted and achieved criteria per outcome
  38. foreach ($sections as $section) {
  39. $section_outcomes_achieved = $section->outcomes_ach();
  40. $section_outcomes_attempted = $section->outcomes_att();
  41. //if ($section->outcomes_achieved != NULL) {
  42. if (!empty($section_outcomes_achieved)) {
  43. //$section_outcomes_achieved = json_decode($section->outcomes_achieved, true);
  44. //$section_outcomes_attempted = json_decode($section->outcomes_attempted, true);
  45. foreach ($section_outcomes_attempted as $outcome_id => $score) {
  46. if (array_key_exists($outcome_id, $outcomes_achieved)) $outcomes_achieved[$outcome_id] += $section_outcomes_achieved[$outcome_id];
  47. else $outcomes_achieved[$outcome_id] = $section_outcomes_achieved[$outcome_id];
  48. if (array_key_exists($outcome_id, $outcomes_attempted)) $outcomes_attempted[$outcome_id] += $section_outcomes_attempted[$outcome_id];
  49. else $outcomes_attempted[$outcome_id] = $section_outcomes_attempted[$outcome_id];
  50. //$outcomes_achieved[$outcome_id] += $section_outcomes_achieved[$outcome_id];
  51. //$outcomes_attempted[$outcome_id] += $section_outcomes_attempted[$outcome_id];
  52. }
  53. }
  54. }
  55. $grouped_outcomes_achieved_results[] = $outcomes_achieved;
  56. $grouped_outcomes_attempted_results[] = $outcomes_attempted;
  57. $grouped_sections[] = $sections;
  58. }
  59. return View::make('local.professors.overview', compact('title', 'grouped_courses', 'outcomes', 'grouped_outcomes_attempted_results', 'grouped_outcomes_achieved_results', 'grouped_sections'));
  60. }
  61. public function program()
  62. {
  63. $program = Auth::user()->programs[0];
  64. $title = 'Your Program: ' . $program->name;
  65. $program_courses = Course::where('program_id', '=', $program->id)->whereIn('semester_id', Session::get('semesters_ids'))->get();
  66. $semesters = Session::get('semesters_ids');
  67. $semesters = DB::table('semesters')->whereIn('id', $semesters)->orderBy('start', 'ASC')->first();
  68. $outcomes = Outcome::select(array('id', 'name', 'expected_outcome'))
  69. ->whereNull('deleted_at')
  70. ->whereRaw("(deactivation_date IS NULL or deactivation_date >= '{$semesters->start}')")
  71. ->orderBy('name', 'ASC')->get();
  72. $outcomeCount = count($outcomes);
  73. $outcomes_achieved = [];
  74. $outcomes_attempted = [];
  75. Log::info($program_courses);
  76. foreach ($program_courses as $course) {
  77. if ($course->outcomes_ach()) {
  78. $course_outcomes_achieved = $course->outcomes_ach();
  79. $course_outcomes_attempted = $course->outcomes_att();
  80. foreach ($course_outcomes_achieved as $outcome => $score) {
  81. if (array_key_exists($outcome, $outcomes_achieved))
  82. $outcomes_achieved[$outcome] += $score;
  83. else $outcomes_achieved[$outcome] = $score;
  84. }
  85. foreach ($course_outcomes_attempted as $outcome => $score) {
  86. if (array_key_exists($outcome, $outcomes_attempted))
  87. $outcomes_attempted[$outcome] += $score;
  88. else $outcomes_attempted[$outcome] = $score;
  89. }
  90. }
  91. }
  92. // Program contact information
  93. $scoords = User::where('school_id', $program->school_id)
  94. ->where('role', 2)
  95. ->get();
  96. $pcoords = User::select('users.*')
  97. ->join('program_user', 'users.id', '=', 'program_user.user_id')
  98. ->where('role', 3)
  99. ->where('program_id', $program->id)
  100. ->get();
  101. return View::make('local.professors.program', compact('title', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'scoords', 'pcoords'));
  102. }
  103. public function generalStudiesOverview()
  104. {
  105. $title = 'General Component Assessment Overview';
  106. try {
  107. $programs = Program::generalComponentPrograms();
  108. } catch (Exception $e) {
  109. dd('Unable to find general component programs');
  110. }
  111. $outcomes = Outcome::orderBy('name', 'asc')->get();
  112. $schools = School::all();
  113. $program_packs = array();
  114. if (!$programs->isEmpty()) {
  115. foreach ($programs as $program) {
  116. $program_packs[] = $program->assessmentOverview();
  117. }
  118. }
  119. return View::make('local.managers.shared.general_studies_overview', compact('title', 'outcomes', 'schools', 'program_packs'));
  120. }
  121. }