説明なし

OutcomesController.php 28KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. <?php
  2. use Illuminate\Database\Eloquent\Collection;
  3. class OutcomesController extends \BaseController
  4. {
  5. /**
  6. * Show all Learning Outcomes and expected values
  7. *
  8. */
  9. public function index()
  10. {
  11. $title = "Learning Outcomes";
  12. $outcomes = Outcome::withTrashed()->orderBy('name', 'ASC')->get();
  13. $schools = School::orderBy('name', 'ASC')->get();
  14. // $semesters_ids = Session::get('semesters_ids');
  15. // $semesters = Semester::whereIn('id',$semesters_ids)->get();
  16. return View::make('local.managers.admins.learning-outcomes', compact('title', 'outcomes', 'schools'));
  17. //return View::make('local.managers.admins.learning-outcomes', compact('title', 'outcomes', 'schools','semesters'));
  18. }
  19. // TODO: Change to home page
  20. public function newIndex()
  21. {
  22. $title = "Learning Outcomes";
  23. // TODO: Check when semester doesnt exist or session is empty
  24. $selected_semester = Semester::find(Session::get('semesters_ids')[0]);
  25. $outcomes = Outcome::withTrashed()->where('deactivation_date', '>=', $selected_semester->start)->orWhere('deactivation_date', null)->orderBy('name', 'ASC')->get();
  26. $schools = School::orderBy('name', 'ASC')->get();
  27. return View::make('local.managers.admins.new-learning-outcomes', compact('title', 'outcomes', 'schools'));
  28. }
  29. public function show($id)
  30. {
  31. $outcome = Outcome::find($id);
  32. $selected_semesters = Semester::find(Session::get('semesters_ids'));
  33. $programs = $outcome->programs_attempted($selected_semesters);
  34. $undergradResults = array("names" => array(), "schools" => array(), "achieved" => array(), "attempted" => array(), "successRate" => array());
  35. $gradResults = array("names" => array(), "schools" => array(), "achieved" => array(), "attempted" => array(), "successRate" => array());
  36. foreach ($programs as $program_id) {
  37. // var_dump($program_id);
  38. // exit();
  39. $program = Program::where('id', '=', $program_id->id)->first();
  40. $school = School::where('id', '=', $program->school_id)->first();
  41. if ($program->is_graduate) {
  42. $gradResults['names'][] = $program->name;
  43. $gradResults['schools'][] = $school->name;
  44. $attempted = $program->attempted_criteria_by_outcome($id, $selected_semesters);
  45. $gradResults['attempted'][] = $attempted;
  46. $achieved = $program->achieved_criteria_by_outcome($id, $selected_semesters);
  47. $gradResults['achieved'][] = $achieved;
  48. $gradResults['successRate'][] = sprintf("%.2f", 100 * $achieved / $attempted);
  49. } else {
  50. $undergradResults['names'][] = $program->name;
  51. $undergradResults['schools'][] = $school->name;
  52. $attempted = $program->attempted_criteria_by_outcome($id, $selected_semesters);
  53. $undergradResults['attempted'][] = $attempted;
  54. $achieved = $program->achieved_criteria_by_outcome($id, $selected_semesters);
  55. $undergradResults['achieved'][] = $achieved;
  56. $undergradResults['successRate'][] = sprintf("%.2f", 100 * $achieved / $attempted);
  57. }
  58. }
  59. $title = "Outcome Results: " . $outcome->name;
  60. // $undergradResults["successRate"]
  61. return View::make('local.managers.admins.learning-outcome_new', compact('title', 'outcome', 'undergradResults', 'gradResults'));
  62. }
  63. // public function show($id)
  64. // {
  65. // DB::disableQueryLog();
  66. // $outcome = Outcome::find($id);
  67. //
  68. // $undergradResults=array("names"=>array(), "schools"=>array(), "achieved"=>array(), "attempted"=>array(), "successRate"=>array());
  69. // $gradResults = array("names"=>array(), "schools"=>array(), "achieved"=>array(), "attempted"=>array(), "successRate"=>array());
  70. //
  71. // //Calculate performance for this outcome for each undergrad program
  72. // $undergradPrograms = Program::where('is_graduate','=', 0)
  73. // ->where(function($query)
  74. // {
  75. // if(Auth::user()->school_id)
  76. // {
  77. // $query->where('school_id', Auth::user()->school_id);
  78. // }
  79. // })
  80. // ->with('courses')
  81. // ->orderBy('name', 'asc')->get();
  82. //
  83. // foreach($undergradPrograms as $program)
  84. // {
  85. // $undergradResults["names"][$program->id]=$program->name;
  86. // $undergradResults["schools"][$program->id]=$program->school->name;
  87. // $programAssessed=false;
  88. //
  89. // $undergradResults["attempted"][$program->id]=0;
  90. // $undergradResults["achieved"][$program->id]=0;
  91. //
  92. // foreach($program->courses as $course)
  93. // {
  94. // $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
  95. // $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
  96. //
  97. // $attemptedCriteriaCount=0;
  98. // $achievedCriteriaCount=0;
  99. //
  100. // // If this outcome was evaluated
  101. // if(
  102. // $course_outcomes_attempted
  103. // && array_key_exists($outcome->id, $course_outcomes_attempted)
  104. // && $course_outcomes_attempted[$outcome->id]!=0)
  105. // {
  106. // // Count +1 for attempted and achieved in the program
  107. // $attemptedCriteriaCount+=$course_outcomes_attempted[$outcome->id];
  108. // $achievedCriteriaCount+=$course_outcomes_achieved[$outcome->id];
  109. // $programAssessed=true;
  110. //
  111. // if($attemptedCriteriaCount>0 &&(float)$achievedCriteriaCount/$attemptedCriteriaCount*100 > $outcome->expected_outcome)
  112. // {
  113. // $undergradResults["achieved"][$program->id]+=1;
  114. // }
  115. // $undergradResults["attempted"][$program->id]+=1;
  116. // }
  117. // }
  118. //
  119. // // Calculate success rate for this program
  120. // if($programAssessed && $undergradResults["attempted"][$program->id]>0)
  121. // $undergradResults["successRate"][$program->id]= round((float)$undergradResults["achieved"][$program->id]/$undergradResults["attempted"][$program->id]*100, 2).'%';
  122. // else
  123. // $undergradResults["successRate"][$program->id]= 'N/M';
  124. // }
  125. //
  126. //
  127. // //Calculate performance for this outcome for each grad program
  128. // $gradPrograms = Program::where('is_graduate','=', 1)
  129. // ->where(function($query)
  130. // {
  131. // if(Auth::user()->school_id)
  132. // {
  133. // $query->where('school_id', Auth::user()->school_id);
  134. // }
  135. // })
  136. // ->with(array('courses'=>function($query)
  137. // {
  138. // $query->whereNotNull('outcomes_attempted');
  139. // }))
  140. // ->orderBy('name', 'asc')->get();
  141. //
  142. // foreach($gradPrograms as $program)
  143. // {
  144. // $gradResults["names"][$program->id]=$program->name;
  145. // $gradResults["schools"][$program->id]=$program->school->name;
  146. //
  147. // $programAssessed=false;
  148. //
  149. // $gradResults["attempted"][$program->id]=0;
  150. // $gradResults["achieved"][$program->id]=0;
  151. //
  152. // foreach($program->courses as $course)
  153. // {
  154. // $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
  155. // $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
  156. //
  157. // $attemptedCriteriaCount=0;
  158. // $achievedCriteriaCount=0;
  159. //
  160. // // If this outcome was evaluated
  161. // if(
  162. // $course_outcomes_attempted
  163. // && array_key_exists($outcome->id, $course_outcomes_attempted)
  164. // && $course_outcomes_attempted[$outcome->id]!=0)
  165. // {
  166. // // Count +1 for attempted and achieved in the program
  167. // $attemptedCriteriaCount+=$course_outcomes_attempted[$outcome->id];
  168. // $achievedCriteriaCount+=$course_outcomes_achieved[$outcome->id];
  169. // $programAssessed=true;
  170. //
  171. // if($attemptedCriteriaCount>0 &&(float)$achievedCriteriaCount/$attemptedCriteriaCount*100 > $outcome->expected_outcome)
  172. // {
  173. // $gradResults["achieved"][$program->id]+=1;
  174. // }
  175. // $gradResults["attempted"][$program->id]+=1;
  176. // }
  177. // }
  178. //
  179. // // Calculate success rate for this program
  180. // if($programAssessed && $gradResults["attempted"][$program->id]>0)
  181. // $gradResults["successRate"][$program->id]= round((float)$gradResults["achieved"][$program->id]/$gradResults["attempted"][$program->id]*100, 2).'%';
  182. // else
  183. // $gradResults["successRate"][$program->id]= 'N/M';
  184. // }
  185. //
  186. // $title = "Outcome Results: ".$outcome->name;
  187. //
  188. // return View::make('local.managers.admins.learning-outcome', compact('title', 'outcome', 'undergradResults', 'gradResults'));
  189. // }
  190. // TODO: Clean up and verify relationships are correct
  191. public function newShow($id)
  192. {
  193. // DB::disableQueryLog();
  194. // $outcome = null;
  195. if ($id === 'all') {
  196. $outcome = Outcome::with('objectives.criteria')->get();
  197. $title = 'All Outcomes';
  198. $criteria = $outcome->reduce(function ($carry, $outcome) {
  199. return $carry->merge($outcome->criteria);
  200. }, Collection::make([]));
  201. $report_link = URL::action('OutcomesController@newReportAll');
  202. } else {
  203. $outcome = Outcome::with(['objectives.criteria'])->find($id);
  204. $title = $outcome->name;
  205. $criteria = $outcome->criteria->load('rubrics');
  206. $report_link = URL::action('OutcomesController@newReport', ['id' => $outcome->id]);
  207. }
  208. // $objectives = $outcome->objectives;
  209. // var_dump(get_class_methods($criteria));
  210. // var_dump($criteria);
  211. $rubrics = $criteria->reduce(function ($carry, $crit) {
  212. return $carry->merge($crit->rubrics);
  213. }, Collection::make([]))->load('activities');
  214. $activities = $rubrics->reduce(function ($carry, $rubric) {
  215. return $carry->merge($rubric->activities);
  216. }, Collection::make([]));
  217. $courses = $activities->reduce(function ($carry, $activity) {
  218. if ($activity->course !== null) {
  219. $carry->push($activity->course);
  220. }
  221. return $carry;
  222. }, Collection::make([]));
  223. $activities = $activities->filter(function ($activity) {
  224. return ($activity->course === null);
  225. });
  226. // var_dump(DB::getQueryLog());
  227. return View::make('local.managers.admins.new-learning-outcome', compact('title', 'outcome', 'courses', 'activities', 'report_link'));
  228. }
  229. public function newReport($id)
  230. {
  231. $outcome = Outcome::find($id);
  232. $objectives = $outcome->objectives;
  233. $criteria = $outcome->criteria;
  234. $programs = $objectives->map(function ($objective) {
  235. return $objective->program;
  236. })
  237. ->merge($criteria->map(function ($criteria) {
  238. return $criteria->program;
  239. }))
  240. ->filter(function ($program) {
  241. return $program->users->contains(Auth::user());
  242. });
  243. $title = $outcome->name . ' Report';
  244. return View::make('local.managers.admins.new-report', compact('title', 'outcome', 'objectives'));
  245. }
  246. public function newReportAll()
  247. {
  248. $outcomes = Outcome::with('objectives')->get();
  249. $title = 'All Outcomes Report';
  250. return View::make('local.managers.admins.new-report-all', compact('title', 'outcomes'));
  251. }
  252. public function update()
  253. {
  254. $outcomeArray = json_decode(Input::get('outcomeArray'), true);
  255. Session::flash('status', 'success');
  256. Session::flash('message', 'Learning Outcomes updated.');
  257. foreach ($outcomeArray as $outcomeObject) {
  258. $validator = Validator::make(
  259. array(
  260. 'name' => $outcomeObject['name'],
  261. 'definition' => $outcomeObject['definition'],
  262. 'expected_outcome' => $outcomeObject['expected_outcome']
  263. ),
  264. array(
  265. 'name' => 'required',
  266. 'definition' => 'required',
  267. 'expected_outcome' => 'required|numeric'
  268. )
  269. );
  270. if (!$validator->fails()) {
  271. try {
  272. $outcome = Outcome::withTrashed()
  273. ->where('id', '=', $outcomeObject['id'])
  274. ->firstOrFail();
  275. $outcome->name = $outcomeObject['name'];
  276. $outcome->definition = $outcomeObject['definition'];
  277. $outcome->expected_outcome = $outcomeObject['expected_outcome'];
  278. $outcome->save();
  279. // If delete is 1, and outcome isn't already trashed, delete
  280. if ($outcomeObject['delete'] == 1 && !$outcome->trashed())
  281. $outcome->delete();
  282. // If delete is 0, and outcome is already trashed, restore
  283. elseif ($outcomeObject['delete'] == 0 && $outcome->trashed())
  284. $outcome->restore();
  285. } catch (Exception $e) {
  286. Session::flash('message', $e->getMessage());
  287. }
  288. } else {
  289. /** Prepare error message */
  290. $message = 'Error(s) updating the Learning Outcomes: <ul>';
  291. foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
  292. $message .= $validationError;
  293. }
  294. $message .= '</ul>';
  295. /** Send error message and old data */
  296. Session::flash('status', 'danger');
  297. Session::flash('message', $message);
  298. return;
  299. }
  300. }
  301. return;
  302. }
  303. /**
  304. *Copy of update(), but also updates activation_date, deactivation_date and level
  305. */
  306. public function updateMore()
  307. {
  308. $outcomeArray = json_decode(Input::get('outcomeArray'), true);
  309. Session::flash('status', 'success');
  310. Session::flash('message', 'Learning Outcomes updated.');
  311. foreach ($outcomeArray as $outcomeObject) {
  312. $validator = Validator::make(
  313. array(
  314. 'name' => $outcomeObject['name'],
  315. 'definition' => $outcomeObject['definition'],
  316. 'expected_outcome' => $outcomeObject['expected_outcome']
  317. // TODO- validar los otros 3 valores
  318. ),
  319. array(
  320. 'name' => 'required',
  321. 'definition' => 'required',
  322. 'expected_outcome' => 'required|numeric'
  323. // TODO- los requisitos de los otros 3 valores
  324. )
  325. );
  326. if (!$validator->fails()) {
  327. try {
  328. $outcome = Outcome::withTrashed()
  329. ->where('id', '=', $outcomeObject['id'])
  330. ->firstOrFail();
  331. $outcome->name = $outcomeObject['name'];
  332. $outcome->definition = $outcomeObject['definition'];
  333. $outcome->expected_outcome = $outcomeObject['expected_outcome'];
  334. $outcome->activation_date = $outcomeObject['activation_date'];
  335. $outcome->deactivation_date = $outcomeObject['deactivation_date'];
  336. $outcome->level = $outcomeObject['level'];
  337. $outcome->save();
  338. // If delete is 1, and outcome isn't already trashed, delete
  339. if ($outcomeObject['delete'] == 1 && !$outcome->trashed())
  340. $outcome->delete();
  341. // If delete is 0, and outcome is already trashed, restore
  342. elseif ($outcomeObject['delete'] == 0 && $outcome->trashed())
  343. $outcome->restore();
  344. } catch (Exception $e) {
  345. Session::flash('message', $e->getMessage());
  346. }
  347. } else {
  348. /** Prepare error message */
  349. $message = 'Error(s) updating the Learning Outcomes: <ul>';
  350. foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
  351. $message .= $validationError;
  352. }
  353. $message .= '</ul>';
  354. /** Send error message and old data */
  355. Session::flash('status', 'danger');
  356. Session::flash('message', $message);
  357. return;
  358. }
  359. }
  360. return;
  361. }
  362. public function fetchCriteria()
  363. {
  364. if (Input::get('filter')) {
  365. switch (Input::get('filter')) {
  366. case 'all':
  367. return Outcome::find(Input::get('id'))->criteria;
  368. break;
  369. case 'school':
  370. // If scoord
  371. if (Auth::user()->role == '2') {
  372. // Fetch all the programs whose school is the user's
  373. $program_ids = DB::table('programs')->where('school_id', Auth::user()->school_id)->lists('id');
  374. // Return all criteria belonging to any of those programs
  375. return Criterion::where('outcome_id', Input::get('id'))
  376. ->whereIn('program_id', $program_ids)
  377. ->orderBy('name', 'ASC')
  378. ->get();
  379. }
  380. // If pcoord
  381. else {
  382. // Fetch all the programs from the user's school;
  383. $program_ids = DB::table('programs')->where('school_id', Auth::user()->programs[0]->school->id)->lists('id');
  384. return Criterion::where('outcome_id', Input::get('id'))
  385. ->whereIn('program_id', $program_ids)
  386. ->orderBy('name', 'ASC')
  387. ->get();
  388. }
  389. break;
  390. case 'program':
  391. return Criterion::where('outcome_id', Input::get('id'))
  392. ->whereIn('program_id', Auth::user()->programs->lists('id'))
  393. ->orderBy('name', 'ASC')
  394. ->get();
  395. break;
  396. default:
  397. return Outcome::find(Input::get('id'))->criteria;
  398. break;
  399. }
  400. } else {
  401. return Outcome::find(Input::get('id'))->criteria;
  402. }
  403. }
  404. /**
  405. * Create a new learning outcome.
  406. */
  407. public function create()
  408. {
  409. /** Validation rules */
  410. $validator = Validator::make(
  411. array(
  412. 'name' => Input::get('name'),
  413. 'definition' => Input::get('definition')
  414. ),
  415. array(
  416. 'name' => 'required|unique:outcomes',
  417. 'definition' => 'required|min:10'
  418. )
  419. );
  420. /** If validation fails */
  421. if ($validator->fails()) {
  422. /** Prepare error message */
  423. $message = '<p>Error(s) creating a new Learning Outcome</p><ul>';
  424. foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
  425. $message .= $validationError;
  426. }
  427. $message .= '</ul>';
  428. /** Send error message and old data */
  429. Session::flash('status', 'warning');
  430. Session::flash('message', $message);
  431. return Redirect::to('learning-outcomes')->withInput();
  432. } else {
  433. /** Instantiate new outcome */
  434. $outcome = new Outcome;
  435. $outcome->name = Input::get('name');
  436. $outcome->definition = Input::get('definition');
  437. /** If outcome is saved, send success message */
  438. if ($outcome->save()) {
  439. Session::flash('status', 'success');
  440. Session::flash('message', '<p>Learning Outcome added.</p>');
  441. return Redirect::to('learning-outcomes');
  442. }
  443. /** If saving fails, send error message and old data */
  444. else {
  445. Session::flash('status', 'warning');
  446. Session::flash('message', '<p>Error adding Learning Outcome. Please try again later.</p>');
  447. return Redirect::to('learning-outcomes')->withInput();
  448. }
  449. }
  450. }
  451. public function fetchOutcome()
  452. {
  453. $id = Input::get('id');
  454. $outcome = Outcome::find($id);
  455. $outcome->criteria;
  456. return array(
  457. 'outcome' => $outcome
  458. );
  459. }
  460. public function managerAssessmentReports()
  461. {
  462. $outcomes = Outcome::select(array('id', 'name', 'expected_outcome'))->orderBy('name', 'ASC')->get();
  463. switch (Auth::user()->role) {
  464. case 1:
  465. $title = "Campus Assessment Reports";
  466. return View::make('local.managers.admins.assessment_reports', compact('title', 'outcomes'));
  467. break;
  468. case 2:
  469. $title = "School Assessment Reports";
  470. return View::make('local.managers.sCoords.assessment_reports', compact('title', 'outcomes'));
  471. break;
  472. case 3:
  473. $title = "Program Assessment Reports";
  474. $programs = Auth::user()->programs;
  475. return View::make('local.managers.pCoords.assessment_reports', compact('title', 'outcomes', 'programs'));
  476. break;
  477. default:
  478. App::abort('404');
  479. break;
  480. }
  481. }
  482. /**
  483. * Campus Assessment Reports
  484. */
  485. public function assessmentReport($outcome_id)
  486. {
  487. $outcome = Outcome::find($outcome_id);
  488. if (!$outcome)
  489. App::abort('404');
  490. $title = "Assessment Report: " . $outcome->name;
  491. $schools = School::has('courses')
  492. ->with(array('programs' => function ($query) use ($outcome_id) {
  493. $query
  494. ->has('courses')
  495. ->with(array('courses' => function ($query2) use ($outcome_id) {
  496. $query2
  497. ->has('activities')
  498. ->whereNotNull('outcomes_attempted')
  499. // ->where('outcomes_attempted', 'NOT LIKE', '%"'.$outcome_id.'":0%')
  500. ->whereIn('semester_id', Session::get('semesters_ids'))
  501. ->groupBy(array('code', 'number'));
  502. }));
  503. }))
  504. ->get();
  505. return View::make('local.managers.admins.assessment_report', compact('title', 'outcome', 'schools'));
  506. }
  507. // TODO: Change later
  508. public function newAssessmentReport($outcome_id)
  509. {
  510. $outcome = Outcome::find($outcome_id);
  511. if (!$outcome)
  512. App::abort('404');
  513. $title = "Assessment Report: " . $outcome->name;
  514. $schools = School::has('courses')
  515. ->with(array('programs' => function ($query) use ($outcome_id) {
  516. $query
  517. ->has('courses')
  518. ->with(array('courses' => function ($query2) use ($outcome_id) {
  519. $query2
  520. ->has('activities')
  521. ->whereNotNull('outcomes_attempted')
  522. // ->where('outcomes_attempted', 'NOT LIKE', '%"'.$outcome_id.'":0%')
  523. ->whereIn('semester_id', Session::get('semesters_ids'))
  524. ->groupBy(array('code', 'number'));
  525. }));
  526. }))
  527. ->get();
  528. return View::make('local.managers.admins.assessment_report', compact('title', 'outcome', 'schools'));
  529. }
  530. /**
  531. * School Assessment Reports
  532. */
  533. public function schoolAssessmentReport($outcome_id)
  534. {
  535. $outcome = Outcome::find($outcome_id);
  536. if (!$outcome)
  537. App::abort('404');
  538. $title = "Assessment Report: " . $outcome->name;
  539. $school = School::where('id', Auth::user()->school_id)
  540. ->has('courses')
  541. ->with(array('programs' => function ($query) {
  542. $query
  543. ->has('courses')
  544. ->with(array('courses' => function ($query2) {
  545. $query2
  546. ->has('activities')
  547. ->whereNotNull('outcomes_attempted')
  548. ->whereIn('semester_id', Session::get('semesters_ids'))
  549. ->groupBy(array('code', 'number'));
  550. }));
  551. }))
  552. ->first();
  553. return View::make('local.managers.sCoords.assessment_report', compact('title', 'outcome', 'school'));
  554. }
  555. /**
  556. * Program Assessment Reports
  557. */
  558. public function programAssessmentReport($outcome_id, $program_id)
  559. {
  560. $outcome = Outcome::find($outcome_id);
  561. if (!$outcome)
  562. App::abort('404');
  563. $title = "Assessment Report: " . $outcome->name;
  564. $program = Program::where('id', $program_id)
  565. ->has('courses')
  566. ->with(array('courses' => function ($query) {
  567. $query
  568. ->has('activities')
  569. ->whereNotNull('outcomes_attempted')
  570. ->whereIn('semester_id', Session::get('semesters_ids'))
  571. ->groupBy(array('code', 'number'));
  572. }))
  573. ->first();
  574. return View::make('local.managers.pCoords.assessment_report', compact('title', 'outcome', 'program'));
  575. }
  576. public function professorAssessmentReports()
  577. {
  578. $outcomes = Outcome::select(array('id', 'name', 'expected_outcome'))->orderBy('name', 'ASC')->get();
  579. $title = "My Courses' Assessment Reports";
  580. return View::make('local.professors.assessment_reports', compact('title', 'outcomes'));
  581. }
  582. // Report for a single professor with a single learning outcome
  583. public function professorAssessmentReport($outcome_id)
  584. {
  585. $outcome = Outcome::find($outcome_id);
  586. if (!$outcome)
  587. App::abort('404');
  588. $title = "My Courses' Assessment Report: " . $outcome->name;
  589. $courses = Course::where('user_id', Auth::user()->id)
  590. ->has('activities')
  591. ->whereNotNull('outcomes_attempted')
  592. ->whereIn('semester_id', Session::get('semesters_ids'))
  593. ->groupBy(array('code', 'number'))
  594. ->get();
  595. return View::make('local.professors.assessment_report', compact('title', 'outcome', 'courses'));
  596. }
  597. }