Без опису

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