Açıklama Yok

ProfessorsController.php 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. $outcomes = Outcome::orderBy('name', 'asc')->get();
  67. $outcomeCount = Outcome::all()->count();
  68. $outcomes_achieved = array_fill(1, $outcomeCount, 0);
  69. $outcomes_attempted = array_fill(1, $outcomeCount, 0);
  70. foreach ($program_courses as $course) {
  71. if ($course->outcomes_achieved != NULL) {
  72. $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
  73. $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
  74. for ($i = 1; $i <= count($outcomes_attempted); $i++) {
  75. $outcomes_achieved[$i] += $course_outcomes_achieved[$i];
  76. $outcomes_attempted[$i] += $course_outcomes_attempted[$i];
  77. }
  78. }
  79. }
  80. // Program contact information
  81. $scoords = User::where('school_id', $program->school_id)
  82. ->where('role', 2)
  83. ->get();
  84. $pcoords = User::select('users.*')
  85. ->join('program_user', 'users.id', '=', 'program_user.user_id')
  86. ->where('role', 3)
  87. ->where('program_id', $program->id)
  88. ->get();
  89. return View::make('local.professors.program', compact('title', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'scoords', 'pcoords'));
  90. }
  91. public function generalStudiesOverview()
  92. {
  93. $title = 'General Component Assessment Overview';
  94. try {
  95. $programs = Program::generalComponentPrograms();
  96. } catch (Exception $e) {
  97. dd('Unable to find general component programs');
  98. }
  99. $outcomes = Outcome::orderBy('name', 'asc')->get();
  100. $schools = School::all();
  101. $program_packs = array();
  102. if (!$programs->isEmpty()) {
  103. foreach ($programs as $program) {
  104. $program_packs[] = $program->assessmentOverview();
  105. }
  106. }
  107. return View::make('local.managers.shared.general_studies_overview', compact('title', 'outcomes', 'schools', 'program_packs'));
  108. }
  109. }