Ei kuvausta

OutcomesController.php 27KB

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