Нет описания

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