No Description

routes.php 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <?php
  2. // Event::listen('illuminate.query', function($sql, $params)
  3. // {
  4. // print_r($sql);
  5. // echo '<pre>';
  6. // print_r($params);
  7. // echo "</pre>";
  8. // });
  9. /*
  10. |--------------------------------------------------------------------------
  11. | Application Routes
  12. |--------------------------------------------------------------------------
  13. |
  14. | Here is where you can register all of the routes for an application.
  15. | It's a breeze. Simply tell Laravel the URIs it should respond to
  16. | and give it the Closure to execute when that URI is requested.
  17. |
  18. */
  19. // Route model bindings
  20. Route::model('template', 'Template');
  21. Route::model('program', 'Program');
  22. Route::model('five_year_plan', 'FiveYearPlan');
  23. // Composers
  24. View::composer(array(
  25. 'local.professors._navigation',
  26. 'local.managers.admins._navigation',
  27. 'local.managers.sCoords._navigation',
  28. 'local.managers.pCoords._navigation',
  29. ), function ($view) {
  30. // Get user's courses' numbers
  31. $courses = Auth::user()->courses;
  32. $schools = School::orderBy('name', 'asc')->get();
  33. $view->with('courses', $courses)->with('schools', $schools);
  34. });
  35. View::composer(array(
  36. 'local.professors.*',
  37. 'local.managers.admins._navigation',
  38. 'local.managers.sCoords._navigation',
  39. 'local.managers.pCoords._navigation',
  40. 'local.managers.shared.limited-course',
  41. 'local.managers.shared.school',
  42. 'local.managers.shared.school-uhs',
  43. 'local.managers.shared.programs',
  44. 'local.managers.shared.program',
  45. 'local.managers.shared.rubrics',
  46. 'global.view-learning-outcomes-criteria',
  47. 'global.view-learning-outcomes-criteria'
  48. ), function ($view) {
  49. $view->with('role', Auth::user()->role);
  50. });
  51. /*
  52. * Login/logout routes
  53. */
  54. /** Use modified guest filter to redirect logged in user */
  55. Route::get('/', array('before' => 'guest', 'uses' => 'AuthController@showLogin'));
  56. Route::post('/login', array('uses' => 'AuthController@login'));
  57. /**
  58. * Protected Routes
  59. */
  60. Route::group(array('before' => 'auth|has_access'), function () {
  61. /**
  62. * Recalculate course outcomes
  63. *
  64. */
  65. Route::get('recalculateCourses', function () {
  66. DB::disableQueryLog();
  67. if (Auth::user()->id != 58)
  68. Redirect::action('AuthController@showLogin');
  69. try {
  70. $courses = Course::all();
  71. foreach ($courses as $course) {
  72. echo $course->id;
  73. // Recalculate course outcomes
  74. $activities = Activity::where('course_id', $course->id)
  75. ->whereNotNull('outcomes_attempted')
  76. ->where('draft', 0)
  77. ->get();
  78. //If there are still evaluated activities in the course, recalculate course outcomes
  79. if (!$activities->isEmpty()) {
  80. $outcomeCount = Outcome::all()->count();
  81. // Variables to hold recalculated outcomes for the course
  82. $course_outcomes_attempted = array_fill(1, $outcomeCount, 0);
  83. $course_outcomes_achieved = array_fill(1, $outcomeCount, 0);
  84. // For each activity
  85. foreach ($activities as $activity2) {
  86. // If activity has been assessed
  87. if ($activity2->outcomes_attempted != NULL) {
  88. echo '<ul>';
  89. // Get the achieved criteria
  90. $criteria_achievement = json_decode($activity2->criteria_achieved, true);
  91. foreach ($criteria_achievement as $criterion_id => $criterion_achieved) {
  92. // Find corresponding learning outcome;
  93. $criterion = Criterion::withTrashed()->where('id', $criterion_id)->first();
  94. print '<li>' . $criterion->id . '</li>';
  95. $outcome = Outcome::find($criterion->outcome_id);
  96. // If criterion is achieved (1), add 1 to both arrays
  97. if ($criterion_achieved === 1) {
  98. $course_outcomes_attempted[$outcome->id] += 1;
  99. $course_outcomes_achieved[$outcome->id] += 1;
  100. }
  101. // Else, only add to the attempted outcomes arrays
  102. elseif ($criterion_achieved === 0) {
  103. $course_outcomes_attempted[$outcome->id] += 1;
  104. }
  105. }
  106. echo '</ul>';
  107. }
  108. }
  109. // Update course
  110. DB::table('courses')
  111. ->where('id', $course->id)
  112. ->update(array(
  113. 'outcomes_attempted' => json_encode($course_outcomes_attempted),
  114. 'outcomes_achieved' => json_encode($course_outcomes_achieved),
  115. 'updated_at' => date('Y-m-d H:i:s')
  116. ));
  117. }
  118. // Otherwise, set them all to NULL
  119. else {
  120. DB::table('courses')
  121. ->where('id', $course->id)
  122. ->update(array(
  123. 'outcomes_attempted' => NULL,
  124. 'outcomes_achieved' => NULL,
  125. 'updated_at' => date('Y-m-d H:i:s')
  126. ));
  127. }
  128. }
  129. return 'success';
  130. } catch (Exception $e) {
  131. return 'failure (' . $e->getLine() . '): ' . $e->getMessage();
  132. }
  133. });
  134. /**
  135. * Shared Routes
  136. */
  137. // Fetch all criteria associated to an outcome
  138. Route::post('fetchCriteria', array(
  139. 'as' => 'fetchCriteria',
  140. 'uses' => 'OutcomesController@fetchCriteria'
  141. ));
  142. // Fetch a criterion for a rubric
  143. Route::post('fetchCriterion', array(
  144. 'as' => 'fetchCriterion',
  145. 'uses' => 'CriteriaController@fetchCriterion'
  146. ));
  147. // Fetch a criterion for a rubric
  148. Route::post('fetchCriterionWithTrashed', array(
  149. 'as' => 'fetchCriterionWithTrashed',
  150. 'uses' => 'CriteriaController@fetchCriterionWithTrashed'
  151. ));
  152. //Fetch objectives for criteria when outcome is chosen
  153. Route::post('fetchObjectivesForSelect', array(
  154. 'as' => 'fetchObjectivesForSelect',
  155. 'uses' => 'CriteriaController@fetchObjectivesForSelect'
  156. ));
  157. // Fetch a criterion for a rubric with custom content
  158. Route::post('fetchRubricCriterion', array(
  159. 'as' => 'fetchRubricCriterion',
  160. 'uses' => 'RubricsController@fetchRubricCriterion'
  161. ));
  162. // Load a rubric template
  163. Route::post('loadTemplate', array('uses' => 'TemplatesController@fetch'));
  164. Route::post('filterSemesters', array('uses' => 'SemestersController@filterSemesters'));
  165. // Log out user
  166. Route::get('logout', 'AuthController@logout');
  167. // Edit and update user profile
  168. Route::get('profile', 'UsersController@edit');
  169. Route::post('profile/update', array('before' => 'csrf', 'uses' => 'UsersController@update'));
  170. // Allows users to give feeback
  171. Route::post('feedback/send', array('before' => 'csrf', 'uses' => 'FeedbackController@send'));
  172. Route::resource(
  173. 'feedback',
  174. 'FeedbackController',
  175. array('only' => array('create'))
  176. );
  177. // Show users all learning outcomes and criteria
  178. Route::get('learning-outcomes-criteria', 'CriteriaController@index');
  179. Route::post('fetchOutcome', array('before' => 'csrf', 'uses' => 'OutcomesController@fetchOutcome'));
  180. // Show professor overview to users with courses
  181. Route::get('professor', 'ProfessorsController@overview');
  182. // Assessment reports for users' courses
  183. Route::get('my-assessment-reports', 'OutcomesController@professorAssessmentReports');
  184. Route::post('objectives/fetch', array('before' => 'csrf', 'uses' => 'ObjectivesController@fetch'));
  185. /**
  186. * Administrator Routes
  187. */
  188. Route::group(array('before' => 'admin'), function () {
  189. Route::get('/administrator', 'AdministratorsController@overview');
  190. Route::post('administrator/rubrics', array(
  191. 'as' => 'rubrics',
  192. 'before' => 'csrf',
  193. 'uses' => 'CriteriaController@fetch'
  194. ));
  195. Route::post('createOutcome', array('before' => 'csrf', 'uses' => 'OutcomesController@create'));
  196. Route::post('createCriterion', array('before' => 'csrf', 'uses' => 'CriteriaController@create'));
  197. Route::get('learning-outcomes', 'OutcomesController@index');
  198. // TODO: Change later
  199. Route::get('new-learning-outcomes', 'OutcomesController@newIndex');
  200. Route::post('learning-outcomes/update', array('before' => 'csrf', 'uses' => 'OutcomesController@update'));
  201. Route::post('crtiteria/update', array('before' => 'csrf', 'uses' => 'CriteriaController@update'));
  202. Route::delete('crtiteria/delete', array('before' => 'csrf', 'uses' => 'CriteriaController@destroy'));
  203. Route::get('administrator/users/{query?}', 'UsersController@index');
  204. Route::post('administrator/updateAccess', array('before' => 'csrf', 'uses' => 'UsersController@updateAccess'));
  205. Route::post('administrator/users/store', array('before' => 'csrf', 'uses' => 'UsersController@store'));
  206. Route::get('administrator/semesters', 'SemestersController@edit');
  207. Route::post('administrator/semesters/update', 'SemestersController@update');
  208. Route::get('assessment-report/{outcome_id}', 'OutcomesController@assessmentReport');
  209. // TODO: Change later
  210. Route::get('new-assessment-report/{outcome_id}', 'OutcomesController@newAssessmentReport');
  211. Route::get('template-list', 'TemplatesController@index');
  212. Route::get('template/{template}', 'TemplatesController@show');
  213. Route::get('courses/reassign', 'CoursesController@reassign');
  214. Route::post('courses/update', array('before' => 'csrf', 'uses' => 'CoursesController@update'));
  215. Route::get('activities/create', 'ActivitiesController@newCreate');
  216. });
  217. /**
  218. * School Coordinator Routes
  219. */
  220. Route::group(array('before' => 'scoord'), function () {
  221. Route::get('school-coordinator', 'SchoolCoordinatorsController@overview');
  222. Route::get('school/{id}', 'SchoolsController@show');
  223. Route::get('program/{id}', 'ProgramsController@show');
  224. Route::get('programs', 'ProgramsController@index');
  225. Route::get('template-list', 'TemplatesController@schoolCoordinatorIndex');
  226. // Print school report
  227. Route::get('print_school/{id}', 'SchoolsController@print_school');
  228. // Assessment reports
  229. Route::get('school-assessment-report/{outcome_id}', 'OutcomesController@schoolAssessmentReport');
  230. });
  231. /**
  232. * Program Coordinator Routes
  233. */
  234. Route::group(array('before' => 'pcoord'), function () {
  235. Route::get('program-coordinator', 'ProgramCoordinatorsController@overview');
  236. Route::get('rubrics', 'TemplatesController@newTemplate');
  237. Route::post('saveTemplate', array('before' => 'csrf', 'uses' => 'TemplatesController@create'));
  238. Route::post('updateTemplate', array('before' => 'csrf', 'uses' => 'TemplatesController@update'));
  239. Route::post('deleteTemplate', array('before' => 'csrf', 'uses' => 'TemplatesController@destroy'));
  240. Route::get('criteria', 'CriteriaController@edit');
  241. Route::get('course/{id}', 'CoursesController@showLimited');
  242. Route::get('rubrics/{template_id}/download', 'TemplatesController@download');
  243. Route::post('program/fetch', array('before' => 'csrf', 'uses' => 'ProgramsController@fetch'));
  244. Route::get('printRubric/{id}', 'TemplatesController@printview');
  245. Route::get('rubric/{rubric_id}', 'RubricsController@show_limited');
  246. Route::get('grouped_course/{code}/{number}/{semester_code}', 'CoursesController@showGrouped');
  247. // Print program report
  248. Route::get('print_program/{id}', 'ProgramsController@print_program');
  249. // Print course (grouped sections) report
  250. Route::get('print_course/{code}/{number}/{semester_code}', 'CoursesController@print_course');
  251. // Assessment reports
  252. Route::get('program-assessment-report/{outcome_id}/{program_id}', 'OutcomesController@programAssessmentReport');
  253. Route::get('assessment-reports', 'OutcomesController@managerAssessmentReports');
  254. // Learning Objectives
  255. Route::get('program/{program}/objectives', 'ObjectivesController@index');
  256. Route::post('updateObjective', array('before' => 'csrf', 'uses' => 'ObjectivesController@update'));
  257. Route::post('program/{id}/createObjective', array('before' => 'csrf', 'uses' => 'ObjectivesController@create'));
  258. Route::post('fetchObjective', array('before' => 'csrf', 'uses' => 'ObjectivesController@fetchObjective'));
  259. Route::post('fetchObjectivesForCriteria', array('before' => 'csrf', 'uses' => 'ObjectivesController@fetchObjectivesForCriteria'));
  260. //Objectives por Gabriel
  261. Route::get('objective', 'Objective2Controller@edit');
  262. Route::post('createObjective', array('before' => 'csrf', 'uses' => 'Objective2Controller@create'));
  263. Route::post('updateObjective', array('before' => 'csrf', 'uses' => 'Objective2Controller@update'));
  264. Route::post('fetchObjectiveWithTrashed', array('before' => 'csrf', 'uses' => 'Objective2Controller@fetchObjectiveWithTrashed'));
  265. // Five year plans,
  266. Route::get('five-year-plans', 'FiveYearPlansController@index');
  267. Route::get('program/{program}/five-year-plans/create', 'FiveYearPlansController@create');
  268. Route::get('program/{program}/five-year-plans/{five_year_plan}', 'FiveYearPlansController@show');
  269. Route::get('program/{program}/five-year-plans/{five_year_plan}/edit', 'FiveYearPlansController@edit');
  270. Route::get('five-year-plans/{five_year_plan}/ms-word', 'FiveYearPlansController@msWord');
  271. Route::post('five-year-plans/store', array('before' => 'csrf', 'uses' => 'FiveYearPlansController@store'));
  272. Route::post('five-year-plans/update', array('before' => 'csrf', 'uses' => 'FiveYearPlansController@update'));
  273. // Annual plans
  274. Route::get('annual-plans', 'AnnualPlansController@index');
  275. Route::get('program/{program}/annual-plans/create', 'AnnualPlansController@create');
  276. Route::get('program/{program}/annual-plans/{five_year_plan}', 'AnnualPlansController@show');
  277. Route::get('program/{program}/annual-plans/{five_year_plan}/edit', 'AnnualPlansController@edit');
  278. Route::post('annual-plans/store', array('before' => 'csrf', 'uses' => 'AnnualPlansController@store'));
  279. Route::post('annual-plans/update', array('before' => 'csrf', 'uses' => 'AnnualPlansController@update'));
  280. Route::get('learning-outcomes/show/{id}', 'OutcomesController@show');
  281. // TODO: Change route name
  282. Route::get('learning-outcomes/newshow/{id}', 'OutcomesController@newShow');
  283. Route::get('new-report/{id}', 'OutcomesController@newReport');
  284. Route::get('new-report-all', 'OutcomesController@newReportAll');
  285. Route::get('courses/{id}', 'CoursesController@newShow');
  286. });
  287. /**
  288. * Professor Routes
  289. */
  290. Route::group(array('prefix' => 'professor', 'before' => 'prof'), function () {
  291. Route::post('program', array('before' => 'csrf', 'uses' => 'ProfessorsController@program'));
  292. Route::get('activities/{activity_id}/rubrics', 'RubricsController@newRubric');
  293. Route::get('activities/{activity_id}/rubric', 'RubricsController@show');
  294. Route::get('activities/{activity_id}/rubric/{rubric_id}/download', 'RubricsController@download');
  295. Route::get('activities/{activity_id}/rubric/{rubric_id}/print', 'RubricsController@printview');
  296. Route::get('activities/{activity_id}/assess', 'ActivitiesController@assess');
  297. Route::get('activities/{activity_id}/view_assessment', 'ActivitiesController@viewAssessment');
  298. Route::get('activities/{activity_id}/print_assessment', 'ActivitiesController@printAssessment');
  299. Route::post('activities/saveAssessment', array('before' => 'csrf', 'uses' => 'ActivitiesController@saveAssessment'));
  300. Route::post('activities/deleteAssessment', array('before' => 'csrf', 'uses' => 'ActivitiesController@deleteAssessment'));
  301. Route::delete('activities/{activity_id}/delete', 'ActivitiesController@destroy');
  302. Route::post('activities/{activity_id}/update', array('before' => 'csrf', 'uses' => 'ActivitiesController@update'));
  303. Route::get('courses/{id}', 'CoursesController@show');
  304. Route::get('courses/{semester}/{id}/students/{number}', 'StudentsController@show');
  305. Route::get('courses/{semester}/{id}/students/{number}/print_report', 'StudentsController@printStudentReport');
  306. Route::get('activities/{id}', 'ActivitiesController@show');
  307. Route::post('activities/{id}', array('before' => 'csrf', 'uses' => 'ActivitiesController@create'));
  308. Route::get('students', 'StudentsController@students');
  309. Route::get('program', 'ProfessorsController@program');
  310. Route::get('personal-information', 'ProfessorsController@personalInformation');
  311. Route::get('manual', 'ProfessorsController@manual');
  312. Route::post('loadRubric', array('before' => 'csrf', 'uses' => 'RubricsController@fetch'));
  313. Route::post('saveRubric', array('before' => 'csrf', 'uses' => 'RubricsController@create'));
  314. Route::post('updateRubric', array('before' => 'csrf', 'uses' => 'RubricsController@update'));
  315. Route::post('deleteRubric', array('before' => 'csrf', 'uses' => 'RubricsController@destroy'));
  316. Route::get('learning-outcomes-criteria', 'CriteriaController@index');
  317. Route::get('export_grades/{id}', 'CoursesController@exportGrades');
  318. // Assessment reports
  319. Route::get('professor-assessment-report/{outcome_id}', 'OutcomesController@professorAssessmentReport');
  320. Route::get('professor-assessment-reports', 'OutcomesController@professorAssessmentReports');
  321. Route::get('general-studies-overview', 'ProfessorsController@generalStudiesOverview');
  322. });
  323. });