Nessuna descrizione

ProgramsController.php 8.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <?php
  2. class ProgramsController extends \BaseController
  3. {
  4. /**
  5. * Shows a particular program
  6. */
  7. public function show($id)
  8. {
  9. $program = Program::find($id);
  10. $title= $program->school->name.': '.$program->name;
  11. $program_courses = $program->courses;
  12. $outcomes = Outcome::orderBy('name', 'asc')->get();
  13. $schools = School::all();
  14. $outcomeCount = Outcome::all()->count();
  15. $outcomes_achieved = array_fill(1, $outcomeCount, 0);
  16. $outcomes_attempted = array_fill(1, $outcomeCount, 0);
  17. $assessed_courses_count=0;
  18. foreach ($program_courses as $course)
  19. {
  20. if($course->outcomes_achieved!=NULL)
  21. {
  22. $course_outcomes_achieved =json_decode($course->outcomes_achieved, true);
  23. $course_outcomes_attempted =json_decode($course->outcomes_attempted, true);
  24. for($i=1; $i<=count($outcomes_attempted); $i++)
  25. {
  26. $outcomes_achieved[$i]+=$course_outcomes_achieved[$i];
  27. $outcomes_attempted[$i]+=$course_outcomes_attempted[$i];
  28. }
  29. $assessed_courses_count+=1;
  30. }
  31. }
  32. /**
  33. * List of grouped courses (grouped sections)
  34. */
  35. $grouped_courses = Course::
  36. select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
  37. ->with('semester')
  38. ->with('program')
  39. ->where('program_id', $program->id)
  40. ->whereIn('semester_id', Session::get('semesters_ids'))
  41. ->groupBy(array('code', 'number', 'semester_id'))
  42. ->orderBy('code')
  43. ->orderBy('number')
  44. ->orderBy('semester_id')
  45. ->get();
  46. // Program contact information
  47. $users = User::
  48. select('users.*')
  49. ->leftJoin('program_user', 'users.id', '=', 'program_user.user_id')
  50. ->where(function($query) use($program)
  51. {
  52. $query
  53. ->where('school_id', $program->school_id)
  54. ->where('role', 2);
  55. })
  56. ->orWhere(function($query) use($program)
  57. {
  58. $query
  59. ->where('role', 3)
  60. ->where('program_id', $program->id);
  61. })
  62. ->orWhere(function($query) use($program)
  63. {
  64. $query
  65. ->where('role', 4)
  66. ->where('program_id', $program->id);
  67. })
  68. ->get();
  69. return View::make('local.managers.shared.program', compact('title', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'schools', 'program_courses', 'assessed_courses_count', 'grouped_courses', 'program', 'users'));
  70. }
  71. public function showReport()
  72. {
  73. // create an array with the ID of Semesters selected in the form
  74. $selected_semesters_id = array();
  75. $semesters = Semester::all();
  76. foreach ($semesters as $semester) {
  77. if ($semester->is_visible){
  78. if (Input::get('semester'.$semester->id)!=null){
  79. array_push($selected_semesters_id, $semester->id);
  80. }
  81. }
  82. }
  83. $selected_semesters = DB::table('semesters')
  84. ->wherein('semesters.id',$selected_semesters_id)
  85. ->get();
  86. // create a srting with the selected metodos de divulgfacion
  87. $selected_divulgaciones = '';
  88. $divulgaciones = array('profesores','comiteDepartamental','comiteFacultadEscuela',
  89. 'pleno','estudiantes','administrativos','senado','comunidadWeb',
  90. 'otros');
  91. foreach ($divulgaciones as $divulgacion) {
  92. if (Input::get($divulgacion)!=null){
  93. $selected_divulgaciones = $selected_divulgaciones.'\n'.Input::get($divulgacion);
  94. }
  95. }
  96. //OUTCOMES Join criteria join program
  97. $programs = DB::table('programs')
  98. ->select('id','name')
  99. ->orderBy('name', 'asc')
  100. ->get();
  101. // $program
  102. $tables_names = '{';
  103. foreach ($programs as $program) {
  104. $tables_names = $tables_names.'"table'.$program->id.'" : "'.$program->name.'",';// code...
  105. }
  106. $tables_names = $tables_names.'}';
  107. $title = "Programs Reports";
  108. // $title = "Program Report: ".$program->name;
  109. $programs_info = array();
  110. //OUTCOMES Join criteria join program
  111. foreach ($programs as $program) {
  112. $info_by_id = Program::find($program->id);
  113. $domains = DB::table('outcomes')
  114. ->join('criteria','criteria.outcome_id','=','outcomes.id')
  115. ->join('programs','programs.id','=','criteria.program_id')
  116. ->join('courses','courses.program_id','=','programs.id')
  117. ->where('programs.id',$program->id)
  118. ->select('outcomes.name','outcomes.activation_date')
  119. ->distinct()
  120. ->orderBy('outcomes.name', 'asc')
  121. ->get();
  122. $courses_used = DB::table('outcomes')
  123. ->join('criteria','criteria.outcome_id','=','outcomes.id')
  124. ->join('programs','programs.id','=','criteria.program_id')
  125. ->join('courses','courses.program_id','=','programs.id')
  126. ->where('programs.id',$program->id)
  127. ->select('courses.number', 'outcomes.name as domain_name', 'courses.code')
  128. ->distinct()
  129. ->orderBy('courses.name', 'asc')
  130. ->get();
  131. $transformative_actions = DB::table('outcomes')
  132. ->join('criteria','criteria.outcome_id','=','outcomes.id')
  133. ->join('programs','programs.id','=','criteria.program_id')
  134. ->join('courses','courses.program_id','=','programs.id')
  135. ->join('activities','activities.course_id','=','courses.id')
  136. ->join('activity_criterion','activity_criterion.activity_id','=','activities.id')
  137. ->where('programs.id',$program->id)
  138. ->select('activity_criterion.transformative_actions', 'outcomes.name as domain_name')
  139. ->distinct()
  140. ->orderBy('activity_criterion.transformative_actions', 'asc')
  141. ->get();
  142. $info = array($info_by_id, $domains, $courses_used, $transformative_actions);
  143. array_push($programs_info, $info);
  144. }
  145. return View::make('local.managers.shared.program_report', compact('title','programs_info','selected_divulgaciones','selected_semesters','tables_names'));
  146. }
  147. /**
  148. * Info to print a program
  149. */
  150. public function print_program($id)
  151. {
  152. $program = Program::find($id);
  153. $title= $program->name.' Assessment Report - '.date('m/d/Y');
  154. $program_courses = $program->courses;
  155. $outcomes = Outcome::orderBy('name', 'asc')->get();
  156. $schools = School::all();
  157. $outcomeCount = Outcome::all()->count();
  158. $outcomes_achieved = array_fill(1, $outcomeCount, 0);
  159. $outcomes_attempted = array_fill(1, $outcomeCount, 0);
  160. $assessed_courses_count=0;
  161. foreach ($program_courses as $course)
  162. {
  163. if($course->outcomes_achieved!=NULL)
  164. {
  165. $course_outcomes_achieved =json_decode($course->outcomes_achieved, true);
  166. $course_outcomes_attempted =json_decode($course->outcomes_attempted, true);
  167. for($i=1; $i<=count($outcomes_attempted); $i++)
  168. {
  169. $outcomes_achieved[$i]+=$course_outcomes_achieved[$i];
  170. $outcomes_attempted[$i]+=$course_outcomes_attempted[$i];
  171. }
  172. $assessed_courses_count+=1;
  173. }
  174. }
  175. /**
  176. * List of grouped courses (grouped sections)
  177. */
  178. $grouped_courses = Course::
  179. select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
  180. ->with('semester')
  181. ->with('program')
  182. ->where('program_id', $program->id)
  183. ->whereIn('semester_id', Session::get('semesters_ids'))
  184. ->groupBy(array('code', 'number', 'semester_id'))
  185. ->orderBy('code')
  186. ->orderBy('number')
  187. ->orderBy('semester_id')
  188. ->get();
  189. return View::make('local.managers.shared.print_program', compact('title', 'program', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'schools', 'program_courses', 'assessed_courses_count', 'grouped_courses'));
  190. }
  191. /**
  192. * A list of all programs
  193. */
  194. public function index()
  195. {
  196. $title = "Programs by School";
  197. $programs = Program::orderBy('name')->get();
  198. $schools = School::all();
  199. $semesters = Semester::all();
  200. return View::make('local.managers.shared.programs', compact('programs', 'schools', 'semesters', 'title'));
  201. }
  202. /**
  203. * Fetch a program
  204. */
  205. public function fetch()
  206. {
  207. Log::info('id:'.Input::get('id'));
  208. return School::find(Input::get('id'))->programs;
  209. }
  210. }