설명 없음

OutcomesController.php 53KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134
  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('id', 'ASC')->get();
  13. // $outcomes = Outcome::withTrashed()->orderBy('name', 'ASC')->get();
  14. $schools = School::orderBy('name', 'ASC')->get();
  15. // $semesters_ids = Session::get('semesters_ids');
  16. // $semesters = Semester::whereIn('id',$semesters_ids)->get();
  17. return View::make('local.managers.admins.learning-outcomes', compact('title', 'outcomes', 'schools'));
  18. //return View::make('local.managers.admins.learning-outcomes', compact('title', 'outcomes', 'schools','semesters'));
  19. }
  20. public function adminProgramIndex()
  21. {
  22. }
  23. // TODO: Change to home page
  24. public function newIndex()
  25. {
  26. $title = "Learning Outcomes";
  27. // TODO: Check when semester doesnt exist or session is empty
  28. $selected_semester = Semester::find(Session::get('semesters_ids')[0]);
  29. $outcomes = Outcome::withTrashed()->where('deactivation_date', '>=', $selected_semester->start)->orWhere('deactivation_date', null)->orderBy('name', 'ASC')->get();
  30. $schools = School::orderBy('name', 'ASC')->get();
  31. return View::make('local.managers.admins.new-learning-outcomes', compact('title', 'outcomes', 'schools'));
  32. }
  33. public function show($id)
  34. {
  35. $outcome = Outcome::find($id);
  36. $selected_semesters = Semester::find(Session::get('semesters_ids'));
  37. $programs = $outcome->programs_attempted($selected_semesters);
  38. $undergradResults = array("names" => array(), "schools" => array(), "achieved" => array(), "attempted" => array(), "successRate" => array());
  39. $gradResults = array("names" => array(), "schools" => array(), "achieved" => array(), "attempted" => array(), "successRate" => array());
  40. foreach ($programs as $program_id) {
  41. // var_dump($program_id);
  42. // exit();
  43. $program = Program::where('id', '=', $program_id->id)->first();
  44. $school = School::where('id', '=', $program->school_id)->first();
  45. if ($program->is_graduate) {
  46. $gradResults['names'][] = $program->name;
  47. $gradResults['schools'][] = $school->name;
  48. $attempted = $program->attempted_criteria_by_outcome($id, $selected_semesters);
  49. $gradResults['attempted'][] = $attempted;
  50. $achieved = $program->achieved_criteria_by_outcome($id, $selected_semesters);
  51. $gradResults['achieved'][] = $achieved;
  52. $gradResults['successRate'][] = sprintf("%.2f", 100 * $achieved / $attempted);
  53. } else {
  54. $undergradResults['names'][] = $program->name;
  55. $undergradResults['schools'][] = $school->name;
  56. $attempted = $program->attempted_criteria_by_outcome($id, $selected_semesters);
  57. $undergradResults['attempted'][] = $attempted;
  58. $achieved = $program->achieved_criteria_by_outcome($id, $selected_semesters);
  59. $undergradResults['achieved'][] = $achieved;
  60. $undergradResults['successRate'][] = sprintf("%.2f", 100 * $achieved / $attempted);
  61. }
  62. }
  63. $title = "Outcome Results: " . $outcome->name;
  64. // $undergradResults["successRate"]
  65. return View::make('local.managers.admins.learning-outcome', compact('title', 'outcome', 'undergradResults', 'gradResults'));
  66. }
  67. // public function showOri($id)
  68. // {
  69. // DB::disableQueryLog();
  70. // $outcome = Outcome::find($id);
  71. //
  72. // $undergradResults=array("names"=>array(), "schools"=>array(), "achieved"=>array(), "attempted"=>array(), "successRate"=>array());
  73. // $gradResults = array("names"=>array(), "schools"=>array(), "achieved"=>array(), "attempted"=>array(), "successRate"=>array());
  74. //
  75. // //Calculate performance for this outcome for each undergrad program
  76. // $undergradPrograms = Program::where('is_graduate','=', 0)
  77. // ->where(function($query)
  78. // {
  79. // if(Auth::user()->school_id)
  80. // {
  81. // $query->where('school_id', Auth::user()->school_id);
  82. // }
  83. // })
  84. // ->with('courses')
  85. // ->orderBy('name', 'asc')->get();
  86. //
  87. // foreach($undergradPrograms as $program)
  88. // {
  89. // $undergradResults["names"][$program->id]=$program->name;
  90. // $undergradResults["schools"][$program->id]=$program->school->name;
  91. // $programAssessed=false;
  92. //
  93. // $undergradResults["attempted"][$program->id]=0;
  94. // $undergradResults["achieved"][$program->id]=0;
  95. //
  96. // foreach($program->courses as $course)
  97. // {
  98. // $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
  99. // $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
  100. //
  101. // $attemptedCriteriaCount=0;
  102. // $achievedCriteriaCount=0;
  103. //
  104. // // If this outcome was evaluated
  105. // if(
  106. // $course_outcomes_attempted
  107. // && array_key_exists($outcome->id, $course_outcomes_attempted)
  108. // && $course_outcomes_attempted[$outcome->id]!=0)
  109. // {
  110. // // Count +1 for attempted and achieved in the program
  111. // $attemptedCriteriaCount+=$course_outcomes_attempted[$outcome->id];
  112. // $achievedCriteriaCount+=$course_outcomes_achieved[$outcome->id];
  113. // $programAssessed=true;
  114. //
  115. // if($attemptedCriteriaCount>0 &&(float)$achievedCriteriaCount/$attemptedCriteriaCount*100 > $outcome->expected_outcome)
  116. // {
  117. // $undergradResults["achieved"][$program->id]+=1;
  118. // }
  119. // $undergradResults["attempted"][$program->id]+=1;
  120. // }
  121. // }
  122. //
  123. // // Calculate success rate for this program
  124. // if($programAssessed && $undergradResults["attempted"][$program->id]>0)
  125. // $undergradResults["successRate"][$program->id]= round((float)$undergradResults["achieved"][$program->id]/$undergradResults["attempted"][$program->id]*100, 2).'%';
  126. // else
  127. // $undergradResults["successRate"][$program->id]= 'N/M';
  128. // }
  129. //
  130. //
  131. // //Calculate performance for this outcome for each grad program
  132. // $gradPrograms = Program::where('is_graduate','=', 1)
  133. // ->where(function($query)
  134. // {
  135. // if(Auth::user()->school_id)
  136. // {
  137. // $query->where('school_id', Auth::user()->school_id);
  138. // }
  139. // })
  140. // ->with(array('courses'=>function($query)
  141. // {
  142. // $query->whereNotNull('outcomes_attempted');
  143. // }))
  144. // ->orderBy('name', 'asc')->get();
  145. //
  146. // foreach($gradPrograms as $program)
  147. // {
  148. // $gradResults["names"][$program->id]=$program->name;
  149. // $gradResults["schools"][$program->id]=$program->school->name;
  150. //
  151. // $programAssessed=false;
  152. //
  153. // $gradResults["attempted"][$program->id]=0;
  154. // $gradResults["achieved"][$program->id]=0;
  155. //
  156. // foreach($program->courses as $course)
  157. // {
  158. // $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
  159. // $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
  160. //
  161. // $attemptedCriteriaCount=0;
  162. // $achievedCriteriaCount=0;
  163. //
  164. // // If this outcome was evaluated
  165. // if(
  166. // $course_outcomes_attempted
  167. // && array_key_exists($outcome->id, $course_outcomes_attempted)
  168. // && $course_outcomes_attempted[$outcome->id]!=0)
  169. // {
  170. // // Count +1 for attempted and achieved in the program
  171. // $attemptedCriteriaCount+=$course_outcomes_attempted[$outcome->id];
  172. // $achievedCriteriaCount+=$course_outcomes_achieved[$outcome->id];
  173. // $programAssessed=true;
  174. //
  175. // if($attemptedCriteriaCount>0 &&(float)$achievedCriteriaCount/$attemptedCriteriaCount*100 > $outcome->expected_outcome)
  176. // {
  177. // $gradResults["achieved"][$program->id]+=1;
  178. // }
  179. // $gradResults["attempted"][$program->id]+=1;
  180. // }
  181. // }
  182. //
  183. // // Calculate success rate for this program
  184. // if($programAssessed && $gradResults["attempted"][$program->id]>0)
  185. // $gradResults["successRate"][$program->id]= round((float)$gradResults["achieved"][$program->id]/$gradResults["attempted"][$program->id]*100, 2).'%';
  186. // else
  187. // $gradResults["successRate"][$program->id]= 'N/M';
  188. // }
  189. //
  190. // $title = "Outcome Results: ".$outcome->name;
  191. //
  192. // return View::make('local.managers.admins.learning-outcome', compact('title', 'outcome', 'undergradResults', 'gradResults'));
  193. // }
  194. // TODO: Clean up and verify relationships are correct
  195. public function newShow($id)
  196. {
  197. // DB::disableQueryLog();
  198. // $outcome = null;
  199. if ($id === 'all') {
  200. $outcome = Outcome::with('objectives.criteria')->get();
  201. $title = 'All Outcomes';
  202. $criteria = $outcome->reduce(function ($carry, $outcome) {
  203. return $carry->merge($outcome->criteria);
  204. }, Collection::make([]));
  205. $report_link = URL::action('OutcomesController@newReportAll');
  206. } else {
  207. $outcome = Outcome::with(['objectives.criteria'])->find($id);
  208. $title = $outcome->name;
  209. $criteria = $outcome->criteria->load('rubrics');
  210. $report_link = URL::action('OutcomesController@newReport', ['id' => $outcome->id]);
  211. }
  212. // $objectives = $outcome->objectives;
  213. // var_dump(get_class_methods($criteria));
  214. // var_dump($criteria);
  215. $rubrics = $criteria->reduce(function ($carry, $crit) {
  216. return $carry->merge($crit->rubrics);
  217. }, Collection::make([]))->load('activities');
  218. $activities = $rubrics->reduce(function ($carry, $rubric) {
  219. return $carry->merge($rubric->activities);
  220. }, Collection::make([]));
  221. $courses = $activities->reduce(function ($carry, $activity) {
  222. if ($activity->course !== null) {
  223. $carry->push($activity->course);
  224. }
  225. return $carry;
  226. }, Collection::make([]));
  227. $activities = $activities->filter(function ($activity) {
  228. return ($activity->course === null);
  229. });
  230. // var_dump(DB::getQueryLog());
  231. return View::make('local.managers.admins.new-learning-outcome', compact('title', 'outcome', 'courses', 'activities', 'report_link'));
  232. }
  233. public function newReport($id)
  234. {
  235. $outcome = Outcome::find($id);
  236. $objectives = $outcome->objectives;
  237. $criteria = $outcome->criteria;
  238. $programs = $objectives->map(function ($objective) {
  239. return $objective->program;
  240. })
  241. ->merge($criteria->map(function ($criteria) {
  242. return $criteria->program;
  243. }))
  244. ->filter(function ($program) {
  245. return $program->users->contains(Auth::user());
  246. });
  247. $title = $outcome->name . ' Report';
  248. return View::make('local.managers.admins.new-report', compact('title', 'outcome', 'objectives'));
  249. }
  250. public function newReportAll()
  251. {
  252. $outcomes = Outcome::with('objectives')->get();
  253. $title = 'All Outcomes Report';
  254. return View::make('local.managers.admins.new-report-all', compact('title', 'outcomes'));
  255. }
  256. public function update()
  257. {
  258. $outcomeArray = json_decode(Input::get('outcomeArray'), true);
  259. Session::flash('status', 'success');
  260. Session::flash('message', 'Learning Outcomes updated.');
  261. foreach ($outcomeArray as $outcomeObject) {
  262. $validator = Validator::make(
  263. array(
  264. 'name' => $outcomeObject['name'],
  265. 'definition' => $outcomeObject['definition'],
  266. 'expected_outcome' => $outcomeObject['expected_outcome']
  267. ),
  268. array(
  269. 'name' => 'required',
  270. 'definition' => 'required',
  271. 'expected_outcome' => 'required|numeric'
  272. )
  273. );
  274. if (!$validator->fails()) {
  275. try {
  276. $outcome = Outcome::withTrashed()
  277. ->where('id', '=', $outcomeObject['id'])
  278. ->firstOrFail();
  279. $outcome->name = $outcomeObject['name'];
  280. $outcome->definition = $outcomeObject['definition'];
  281. $outcome->expected_outcome = $outcomeObject['expected_outcome'];
  282. $outcome->save();
  283. // If delete is 1, and outcome isn't already trashed, delete
  284. if ($outcomeObject['delete'] == 1 && !$outcome->trashed())
  285. $outcome->delete();
  286. // If delete is 0, and outcome is already trashed, restore
  287. elseif ($outcomeObject['delete'] == 0 && $outcome->trashed())
  288. $outcome->restore();
  289. } catch (Exception $e) {
  290. Session::flash('message', $e->getMessage());
  291. }
  292. } else {
  293. /** Prepare error message */
  294. $message = 'Error(s) updating the Learning Outcomes: <ul>';
  295. foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
  296. $message .= $validationError;
  297. }
  298. $message .= '</ul>';
  299. /** Send error message and old data */
  300. Session::flash('status', 'danger');
  301. Session::flash('message', $message);
  302. return;
  303. }
  304. }
  305. return;
  306. }
  307. /**
  308. *Copy of update(), but also updates activation_date, deactivation_date and level
  309. */
  310. public function delete()
  311. {
  312. $outcomeArray = json_decode(Input::get('outcomeArray'), true);
  313. // Log::info("delete".json_encode($outcomeArray));
  314. $outcome = Outcome::withTrashed()
  315. ->where('id', '=', $outcomeArray['id'])
  316. ->firstOrFail();
  317. // Log::info("delete2".json_encode($outcome));
  318. $outcome->forceDelete();
  319. // Log::info("sal".json_encode($sal));
  320. // if($sal)
  321. {
  322. Session::flash('status', 'success');
  323. Session::flash('message', 'Learning Outcome deleted.');
  324. }
  325. }
  326. public function updateMore()
  327. {
  328. $outcomeArray = json_decode(Input::get('outcomeArray'), true);
  329. Session::flash('status', 'success');
  330. Session::flash('message', 'Learning Outcomes updated.');
  331. Log::info("Ahora1".json_encode($outcomeArray));
  332. foreach ($outcomeArray as $outcomeObject) {
  333. $validator = Validator::make(
  334. array(
  335. 'name' => $outcomeObject['name'],
  336. 'definition' => $outcomeObject['definition'],
  337. 'expected_outcome' => $outcomeObject['expected_outcome'],
  338. 'activation_date' => $outcomeObject['activation_date'],
  339. // 'deactivation_date' => (isset($outcomeObject['deactivation_date'])?$outcomeObject['deactivation_date']:NULL),
  340. 'level' => $outcomeObject['level'],
  341. // 'new_outcome_id'=>$outcomeObject['new_outcome_id']
  342. // TODO- validar los otros 3 valores
  343. ),
  344. array(
  345. 'name' => 'required',
  346. 'definition' => 'required',
  347. 'expected_outcome' => 'required|numeric',
  348. 'activation_date' => 'required|date',
  349. // 'deactivation_date' => 'sometimes|required|date',
  350. 'level' => 'required|numeric'
  351. // 'new_outcome_id' => 'required|numeric'
  352. // TODO- los requisitos de los otros 3 valores
  353. )
  354. );
  355. if (!$validator->fails()) {
  356. try {
  357. $outcome = Outcome::withTrashed()
  358. ->where('id', '=', $outcomeObject['id'])
  359. ->firstOrFail();
  360. $outcome->name = $outcomeObject['name'];
  361. $outcome->definition = $outcomeObject['definition'];
  362. $outcome->expected_outcome = $outcomeObject['expected_outcome'];
  363. $outcome->activation_date = $outcomeObject['activation_date'];
  364. if($outcomeObject['deactivation_date']!="")
  365. {
  366. $outcome->deactivation_date = $outcomeObject['deactivation_date'];
  367. if(isset($outcomeObject['new_outcome_id']))$outcome->new_outcome_id = $outcomeObject['new_outcome_id'];
  368. }
  369. else
  370. {
  371. $outcome->deactivation_date = NULL;
  372. $outcome->new_outcome_id=NULL;
  373. }
  374. $outcome->level = $outcomeObject['level'];
  375. Log::info("Ahora2".json_encode($outcome));
  376. $outcome->save();
  377. // If delete is 1, and outcome isn't already trashed, delete
  378. if ($outcomeObject['delete'] == 1 && !$outcome->trashed())
  379. $outcome->delete();
  380. // If delete is 0, and outcome is already trashed, restore
  381. elseif ($outcomeObject['delete'] == 0 && $outcome->trashed())
  382. $outcome->restore();
  383. } catch (Exception $e) {
  384. Session::flash('message', $e->getMessage());
  385. }
  386. } else {
  387. /** Prepare error message */
  388. $message = 'Error(s) updating the Learning Outcomes: <ul>';
  389. foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
  390. $message .= $validationError;
  391. }
  392. $message .= '</ul>';
  393. /** Send error message and old data */
  394. Session::flash('status', 'danger');
  395. Session::flash('message', $message);
  396. return;
  397. }
  398. }
  399. return;
  400. }
  401. public function fetchCriteria()
  402. {
  403. // var_dump((Input::get('filter')));
  404. // exit();
  405. if (Input::get('filter')) {
  406. switch (Input::get('filter')) {
  407. case 'all':
  408. $criteria = DB::table('criteria')
  409. ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
  410. ->where('criterion_objective_outcome.outcome_id', '=', Input::get('outcome_id'))
  411. ->where('criterion_objective_outcome.objective_id', '=', Input::get('objective_id'))
  412. ->where('criteria.num_scales', '=', Input::get('num_scales'))
  413. ->where('criteria.max_score', '=', Input::get('maximum'))
  414. ->select('criterion_id as id', 'name')
  415. ->orderBy('name', 'ASC')
  416. ->get();
  417. foreach ($criteria as $criterion) {
  418. $criterion->program_ids = json_encode(DB::table('program_criterion')
  419. ->where('criterion_id', $criterion->id)
  420. ->lists('program_id'));
  421. $criterion->objectives = DB::table('criterion_objective_outcome')
  422. ->join('objectives', 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
  423. ->where('criterion_id', $criterion->id)
  424. ->select('objectives.*')
  425. ->distinct()
  426. ->lists('text');
  427. }
  428. return $criteria;
  429. break;
  430. case 'school':
  431. // If scoord
  432. if (Auth::user()->role == '2') {
  433. // Fetch all the programs whose school is the user's
  434. $program_ids = DB::table('programs')->where('school_id', Auth::user()->school_id)->lists('id');
  435. $criteria = DB::table('criteria')
  436. ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
  437. ->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
  438. ->where('criterion_objective_outcome.outcome_id', '=', Input::get('outcome_id'))
  439. ->where('criterion_objective_outcome.objective_id', '=', Input::get('objective_id'))
  440. ->where('criteria.num_scales', '=', Input::get('num_scales'))
  441. ->where('criteria.max_score', '=', Input::get('maximum'))
  442. ->whereIn('program_criterion.program_id', $program_ids)
  443. ->select('criterion_id as id', 'name')
  444. ->orderBy('name', 'ASC')
  445. ->get();
  446. foreach ($criteria as $criterion) {
  447. $criterion->program_ids = json_encode(DB::table('program_criterion')
  448. ->where('criterion_id', $criterion->id)
  449. ->lists('program_id'));
  450. $criterion->objectives = json_encode(DB::table('criterion_objective_outcome')
  451. ->join('objectives', 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
  452. ->where('criterion_id', $criterion->id)
  453. ->select('objectives.*')
  454. ->distinct()
  455. ->lists('text'));
  456. }
  457. // Return all criteria belonging to any of those programs
  458. return $criteria;
  459. }
  460. // If pcoord
  461. else {
  462. // Fetch all the programs from the user's school;
  463. // Fetch all the programs from the user's school;
  464. $program_ids = DB::table('programs')->where('school_id', Auth::user()->programs[0]->school->id)->lists('id');
  465. $criteria = DB::table('criteria')
  466. ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
  467. ->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
  468. ->where('criterion_objective_outcome.outcome_id', '=', Input::get('outcome_id'))
  469. ->where('criterion_objective_outcome.objective_id', '=', Input::get('objective_id'))
  470. ->where('criteria.num_scales', '=', Input::get('num_scales'))
  471. ->where('criteria.max_score', '=', Input::get('maximum'))
  472. ->whereIn('program_criterion.program_id', $program_ids)
  473. ->select('criterion_id as id', 'name')
  474. ->orderBy('name', 'ASC')
  475. ->get();
  476. foreach ($criteria as $criterion) {
  477. $criterion->program_ids = json_encode(DB::table('program_criterion')
  478. ->where('criterion_id', $criterion->id)
  479. ->lists('program_id'));
  480. $criterion->objectives = json_encode(DB::table('criterion_objective_outcome')
  481. ->join('objectives', 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
  482. ->where('criterion_id', $criterion->id)
  483. ->select('objectives.*')
  484. ->distinct()
  485. ->lists('text'));
  486. }
  487. return $criteria;
  488. }
  489. break;
  490. case 'program':
  491. $criteria = DB::table('criteria')
  492. ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
  493. ->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
  494. ->where('criterion_objective_outcome.outcome_id', '=', Input::get('outcome_id'))
  495. ->where('criterion_objective_outcome.objective_id', '=', Input::get('objective_id'))
  496. ->where('criteria.num_scales', '=', Input::get('num_scales'))
  497. ->where('criteria.max_score', '=', Input::get('maximum'))
  498. ->whereIn('program_criterion.program_id', Auth::user()->programs->lists('id'))
  499. ->select('criterion_id as id', 'name')
  500. ->orderBy('name', 'ASC')
  501. ->get();
  502. foreach ($criteria as $criterion) {
  503. $criterion->program_ids = json_encode(DB::table('program_criterion')
  504. ->where('criterion_id', $criterion->id)
  505. ->lists('program_id'));
  506. $criterion->objectives = json_encode(DB::table('criterion_objective_outcome')
  507. ->join('objectives', 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
  508. ->where('criterion_id', $criterion->id)
  509. ->select('objectives.*')
  510. ->distinct()
  511. ->lists('text'));
  512. }
  513. return $criteria;
  514. break;
  515. default:
  516. $criteria = DB::table('criteria')
  517. ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
  518. ->where('criterion_objective_outcome.outcome_id', '=', Input::get('outcome_id'))
  519. ->where('criterion_objective_outcome.objective_id', '=', Input::get('objective_id'))
  520. ->where('criteria.num_scales', '=', Input::get('num_scales'))
  521. ->where('criteria.max_score', '=', Input::get('maximum'))
  522. ->select('criterion_id as id', 'name')
  523. ->orderBy('name', 'ASC')
  524. ->get();
  525. foreach ($criteria as $criterion) {
  526. $criterion->program_ids = json_encode(DB::table('program_criterion')
  527. ->where('criterion_id', $criterion->id)
  528. ->lists('program_id'));
  529. $criterion->objectives = json_encode(DB::table('criterion_objective_outcome')
  530. ->join('objectives', 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
  531. ->where('criterion_id', $criterion->id)
  532. ->select('objectives.*')
  533. ->distinct()
  534. ->lists('text'));
  535. }
  536. return $criteria;
  537. break;
  538. }
  539. } else {
  540. $criteria = DB::table('criteria')
  541. ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
  542. ->where('criterion_objective_outcome.outcome_id', '=', Input::get('outcome_id'))
  543. ->where('criterion_objective_outcome.objective_id', '=', Input::get('objective_id'))
  544. ->where('criteria.num_scales', '=', Input::get('num_scales'))
  545. ->where('criteria.max_score', '=', Input::get('maximum'))
  546. ->select('criterion_id as id', 'name')
  547. ->orderBy('name', 'ASC')
  548. ->get();
  549. foreach ($criteria as $criterion) {
  550. $criterion->program_ids = json_encode(DB::table('program_criterion')
  551. ->where('criterion_id', $criterion->id)
  552. ->lists('program_id'));
  553. $criterion->objectives = json_encode(DB::table('criterion_objective_outcome')
  554. ->join('objectives', 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
  555. ->where('criterion_id', $criterion->id)
  556. ->select('objectives.*')
  557. ->distinct()
  558. ->lists('text'));
  559. }
  560. return $criteria;
  561. }
  562. }
  563. /**
  564. * Create a new learning outcome.
  565. */
  566. public function create()
  567. {
  568. /** Validation rules */
  569. $validator = Validator::make(
  570. array(
  571. 'name' => Input::get('name'),
  572. 'definition' => Input::get('definition')
  573. ),
  574. array(
  575. 'name' => 'required|unique:outcomes',
  576. 'definition' => 'required|min:10'
  577. )
  578. );
  579. /** If validation fails */
  580. if ($validator->fails()) {
  581. /** Prepare error message */
  582. $message = '<p>Error(s) creating a new Learning Outcome</p><ul>';
  583. foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
  584. $message .= $validationError;
  585. }
  586. $message .= '</ul>';
  587. /** Send error message and old data */
  588. Session::flash('status', 'warning');
  589. Session::flash('message', $message);
  590. return Redirect::to('learning-outcomes')->withInput();
  591. } else {
  592. /** Instantiate new outcome */
  593. $outcome = new Outcome;
  594. $outcome->name = Input::get('name');
  595. $outcome->definition = Input::get('definition');
  596. /** If outcome is saved, send success message */
  597. if ($outcome->save()) {
  598. Session::flash('status', 'success');
  599. Session::flash('message', '<p>Learning Outcome added.</p>');
  600. return Redirect::to('learning-outcomes');
  601. }
  602. /** If saving fails, send error message and old data */
  603. else {
  604. Session::flash('status', 'warning');
  605. Session::flash('message', '<p>Error adding Learning Outcome. Please try again later.</p>');
  606. return Redirect::to('learning-outcomes')->withInput();
  607. }
  608. }
  609. }
  610. public function fetchOutcome()
  611. {
  612. // original code using models
  613. // TODO: models have to be updated because of the database update
  614. $id = Input::get('id');
  615. $outcome_info = DB::table('outcomes')
  616. ->where('outcomes.id', $id)
  617. ->get();
  618. $outcome = $outcome_info[0];
  619. $criteria_array = array();
  620. // switch para el query, dependiendo del usuario
  621. $role = Auth::user()['role'];
  622. $semesters = Session::get('sesemster_ids');
  623. switch ($role) {
  624. case 1:
  625. $program_ids = DB::table('programs')->lists('id');
  626. break;
  627. case 2:
  628. $school_id = Auth::user()['school_id'];
  629. $program_ids = DB::table('programs')->where('school_id', $school_id)->lists('id');
  630. break;
  631. case 3:
  632. $program_ids = DB::table('program_user')->where('user_id', Auth::user()['id'])->lists('program_id');
  633. break;
  634. case 4:
  635. $program_ids = DB::table('program_user')->where('user_id', Auth::user()['id'])->lists('program_id');
  636. break;
  637. }
  638. $diferent_levels = DB::table('criterion_objective_outcome')
  639. ->join('criteria', 'criteria.id', '=', 'criterion_objective_outcome.criterion_id')
  640. // GASP, añadí programa, para que solo muestre niveles de criterios del programa
  641. ->join('program_criterion', 'criteria.id', '=', 'program_criterion.criterion_id')
  642. ->whereIn('program_id', $program_ids)
  643. ->where('criterion_objective_outcome.outcome_id', $id)
  644. ->distinct('criteria.num_scales')
  645. ->select('criteria.num_scales as levels')
  646. ->orderBy('criteria.num_scales', 'asc')
  647. ->get();
  648. $outcome->criteria = array();
  649. foreach ($diferent_levels as $level) {
  650. $level = $level->levels;
  651. // buscar todos los criterios con el level y ponerlos en un array
  652. // $outcome_criterias = DB::table('criterion_objective_outcome')
  653. // ->join('new_criteria', 'new_criteria.id', '=', 'criterion_objective_outcome.criterion_id')
  654. // ->join('objectives', 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
  655. // ->where('criterion_objective_outcome.outcome_id', $id)
  656. // ->where('new_criteria.number_of_scales', $level)
  657. // ->whereNull('new_criteria.deleted_at')
  658. // ->select('new_criteria.id', 'new_criteria.name')
  659. // ->orderBy('new_criteria.name', 'asc')
  660. // ->get();
  661. $outcome_criterias = DB::table('criterion_objective_outcome')
  662. ->join('criteria', 'criteria.id', '=', 'criterion_objective_outcome.criterion_id')
  663. ->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
  664. ->whereIn('program_criterion.program_id', $program_ids)
  665. ->where('criterion_objective_outcome.outcome_id', $id)
  666. ->where('criteria.num_scales', $level)
  667. ->select('criteria.id', 'criteria.name', 'criteria.deleted_at')
  668. ->distinct()
  669. ->orderBy('criteria.name', 'asc')
  670. ->get();
  671. // $outcome_criterias = $outcome_criterias;
  672. foreach ($outcome_criterias as $criteria_id) {
  673. $scales = DB::select("select * FROM scales INNER join `criterion_scale` on `criterion_scale`.`scale_id` = `scales`.`id` where criterion_scale.criterion_id ={$criteria_id->id} ORDER BY position");
  674. $programs = DB::table('programs')
  675. ->join('program_criterion', 'program_criterion.program_id', '=', 'programs.id')
  676. ->where('criterion_id', $criteria_id->id)
  677. ->lists('programs.name');
  678. Log::info($scales);
  679. /* $scales =
  680. DB::select(
  681. DB::raw("
  682. SELECT *
  683. FROM (
  684. SELECT criteria.id as criterion_id,
  685. ROW_NUMBER() OVER(PARTITION BY scales.id) rn,
  686. scales.position,
  687. scales.title, scales.description,
  688. criterion_objective_outcome.outcome_id,criterion_objective_outcome.objective_id,
  689. criterion_scale.scale_id
  690. FROM criteria,criterion_scale,scales, criterion_objective_outcome, objectives
  691. where criteria.id=criterion_scale.criterion_id
  692. and scales.id = criterion_scale.scale_id
  693. and criteria.id = criterion_objective_outcome.criterion_id
  694. and objectives.id = criterion_objective_outcome.objective_id
  695. and criterion_objective_outcome.outcome_id = $id
  696. and criteria.id = $criteria_id->id
  697. ORDER BY criteria.name ASC) a
  698. WHERE rn = 1
  699. ORDER BY `a`.`position` ASC
  700. ")
  701. );*/
  702. $criteria_id->programs = $programs;
  703. // insertar la informacion de los criterios con N niveles en el arreglo de arreglos
  704. $criteria_id->scales = $scales;
  705. // $i++;
  706. } //ends foreach criteria_id
  707. array_push($outcome->criteria, array($outcome_criterias, 'amount_of_levels' => $level));
  708. } //ends foreach level
  709. return array(
  710. 'outcome' => $outcome,
  711. );
  712. }
  713. public function managerAssessmentReports()
  714. {
  715. $outcomes = Outcome::select(array('id', 'name', 'expected_outcome'))->orderBy('name', 'ASC')->get();
  716. switch (Auth::user()->role) {
  717. case 1:
  718. $title = "Campus Assessment Reports";
  719. return View::make('local.managers.admins.assessment_reports', compact('title', 'outcomes'));
  720. break;
  721. case 2:
  722. $title = "School Assessment Reports";
  723. return View::make('local.managers.sCoords.assessment_reports', compact('title', 'outcomes'));
  724. break;
  725. case 3:
  726. $title = "Program Assessment Reports";
  727. $programs = Auth::user()->programs;
  728. return View::make('local.managers.pCoords.assessment_reports', compact('title', 'outcomes', 'programs'));
  729. break;
  730. default:
  731. App::abort('404');
  732. break;
  733. }
  734. }
  735. /**
  736. * Campus Assessment Reports
  737. */
  738. public function assessmentReport()
  739. {
  740. //$outcome = Outcome::find($outcome_id);
  741. set_time_limit(0);
  742. //if (!$outcome)
  743. // App::abort('404');
  744. $title = "Campus Assessment Report "; //. $outcome->name;
  745. $schools = School::has('courses')
  746. ->with(array('programs' => function ($query) /*use ($outcome_id)*/ {
  747. $query
  748. ->has('courses')
  749. ->with(array('courses' => function ($query2) /*use ($outcome_id)*/ {
  750. $query2
  751. /*->has('activities')
  752. // ->whereNotNull('outcomes_attempted')
  753. // ->where('outcomes_attempted', 'NOT LIKE', '%"'.$outcome_id.'":0%')
  754. ->whereIn('semester_id', Session::get('semesters_ids'))
  755. ->groupBy(array('code', 'number'));*/
  756. ->has('activities')
  757. ->join('activities', 'activities.course_id', '=', 'courses.id')
  758. ->join('activity_criterion as ac', 'ac.activity_id', '=', 'activities.id')
  759. ->join('assessments', 'assessments.activity_criterion_id', '=', 'ac.id')
  760. ->where('activities.draft', 0)
  761. ->where('activities.diagnostic', 0)
  762. ->select('courses.*')->distinct()
  763. //->whereNotNull('outcomes_attempted')
  764. ->whereIn('semester_id', Session::get('semesters_ids'))
  765. ->groupBy(array('code', 'number'));
  766. }));
  767. }))
  768. ->get();
  769. return View::make('local.managers.admins.new_assessment_report', compact('title', 'schools'));
  770. }
  771. public function totalAssessmentReport()
  772. {
  773. //SELECT sm.name, s.name, p.name, p.code, a.outcomes_attempted, stu.number, ass.scores, c.code, c.number, r.expected_points
  774. // FROM students stu, schools s, programs p, courses c, activities a, assessments ass, rubrics r, semesters sm
  775. // where stu.id=ass.student_id and sm.id=c.semester_id and s.id=p.school_id and p.id=c.program_id and a.course_id=c.id and ass.activity_id=a.id and a.rubric_id=r.id
  776. // and c.semester_id in (12,13) and a.outcomes_attempted is not null
  777. ini_set('memory_limit', -1);
  778. ini_set('max_execution_time', 300);
  779. // $total_assessments_temp = DB::table('assessments')
  780. // ->join('students', 'students.id', '=', 'assessments.student_id')
  781. // ->join('activities', 'activities.id', '=', 'assessments.activity_id')
  782. // ->join('rubrics', 'rubrics.id', '=', 'activities.rubric_id')
  783. // ->join('courses', 'courses.id', '=', 'activities.course_id')
  784. // ->join('programs', 'programs.id', '=', 'courses.program_id')
  785. // ->join('schools', 'schools.id', '=', 'programs.school_id')
  786. // ->join('semesters', 'semesters.id', '=', 'courses.semester_id')
  787. // ->whereIn('courses.semester_id', Session::get('semesters_ids'))
  788. // ->whereRaw('activities.outcomes_attempted is not null')
  789. // ->select('activities.id as activity_id','semesters.name as semester','schools.name as school','programs.name as program','programs.id as program_id','programs.code as program_code','students.number as student_number','students.conc_code as student_conc_code','assessments.scores as results','courses.name as course','courses.code as course_code','courses.number as course_number','rubrics.expected_points as expected_result')
  790. // ->orderBy('semesters.id','school','program','course','student_number')
  791. // ->distinct()
  792. // ->get();
  793. //
  794. // $total_assessments=array();
  795. // foreach($total_assessments_temp as $total_assessment)
  796. // {
  797. // $results=json_decode($total_assessment->results, TRUE);
  798. // $total_assessment->course=$total_assessment->course_code.$total_assessment->course_number." ".$total_assessment->course;
  799. // foreach($results as $criterion_id => $result)
  800. // {
  801. // if($result and $result!="N/A")
  802. // {
  803. // $trans_temp=clone $total_assessment;
  804. // $criterion=Criterion::find($criterion_id);
  805. // if($criterion)
  806. // {
  807. // // var_dump($total_assessment->activity_id);
  808. // // var_dump($criterion_id);
  809. // if($criterion_id==1398)var_dump($criterion);
  810. // // exit();
  811. // $trans_temp->result=$result;
  812. // $trans_temp->criterion=$criterion->name;
  813. // $trans_temp->outcome=Outcome::find($criterion->outcome_id)->name;
  814. // $total_assessments[]=$trans_temp;
  815. // }
  816. // }
  817. // }
  818. //
  819. // }
  820. $total_assessments = DB::table('assessments')
  821. ->join('students', 'students.id', '=', 'assessments.student_id')
  822. ->join('activity_criterion', 'activity_criterion.id', '=', 'assessments.activity_criterion_id')
  823. ->join('activities', 'activities.id', '=', 'activity_criterion.activity_id')
  824. ->join('criteria', 'criteria.id', '=', 'activity_criterion.criterion_id')
  825. ->join('criterion_objective_outcome', 'criteria.id', '=', 'criterion_objective_outcome.criterion_id')
  826. ->join('outcomes', 'outcomes.id', '=', 'criterion_objective_outcome.outcome_id')
  827. ->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
  828. ->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
  829. ->join('courses', 'courses.id', '=', 'activities.course_id')
  830. ->join('programs', 'programs.id', '=', 'courses.program_id')
  831. ->join('schools', 'schools.id', '=', 'programs.school_id')
  832. ->join('semesters', 'semesters.id', '=', 'courses.semester_id')
  833. ->whereIn('courses.semester_id', Session::get('semesters_ids'))
  834. ->select('criteria.name as criterion', 'outcomes.name as outcome', 'activities.id as activity_id', 'semesters.name as semester', 'schools.name as school', 'programs.name as program', 'programs.id as program_id', 'programs.code as program_code', 'students.number as student_number', 'students.conc_code as student_conc_code', 'assessments.score as result', 'courses.name as course', 'courses.code as course_code', 'courses.number as course_number', 'rubrics.expected_points as expected_result')
  835. ->orderBy('semesters.id', 'school', 'program', 'course', 'student_number')
  836. ->distinct()
  837. ->get();
  838. $title = "Total Assessment Report";
  839. return View::make('local.managers.admins.total_assessment', compact('title', 'total_assessments'));
  840. }
  841. // TODO: Change later
  842. public function newAssessmentReport($outcome_id)
  843. {
  844. $outcome = Outcome::find($outcome_id);
  845. if (!$outcome)
  846. App::abort('404');
  847. $title = "Assessment Report: " . $outcome->name;
  848. $schools = School::has('courses')
  849. ->with(array('programs' => function ($query) use ($outcome_id) {
  850. $query
  851. ->has('courses')
  852. ->with(array('courses' => function ($query2) use ($outcome_id) {
  853. $query2
  854. ->has('activities')
  855. // ->whereNotNull('outcomes_attempted')
  856. // ->where('outcomes_attempted', 'NOT LIKE', '%"'.$outcome_id.'":0%')
  857. ->join('activities', 'activities.course_id', '=', 'courses.id')
  858. ->join('activity_criterion as ac', 'ac.activity_id', '=', 'activities.id')
  859. ->join('assessments', 'assessments.activity_criterion_id', '=', 'ac.id')
  860. ->where('activities.draft', 0)
  861. ->where('activities.diagnostic', 0)
  862. ->select('courses.*')->distinct()
  863. ->whereIn('semester_id', Session::get('semesters_ids'))
  864. ->groupBy(array('code', 'number'));
  865. }));
  866. }))
  867. ->get();
  868. return View::make('local.managers.admins.assessment_report', compact('title', 'outcome', 'schools'));
  869. }
  870. /**
  871. * School Assessment Reports
  872. */
  873. private function cmp($a, $b)
  874. {
  875. return strcmp($a->name, $b->name);
  876. }
  877. public function schoolAssessmentReport()
  878. {
  879. //$outcome = Outcome::find($outcome_id);
  880. //if (!$outcome)
  881. // App::abort('404');
  882. $title = "School Assessment Reports";
  883. set_time_limit(0);
  884. $school = School::where('id', Auth::user()->school_id)
  885. ->has('courses')
  886. ->with(array('programs' => function ($query) {
  887. $query
  888. ->has('courses')
  889. ->with(array('courses' => function ($query2) {
  890. $query2
  891. ->has('activities')
  892. ->join('activities', 'activities.course_id', '=', 'courses.id')
  893. ->join('activity_criterion as ac', 'ac.activity_id', '=', 'activities.id')
  894. ->join('assessments', 'assessments.activity_criterion_id', '=', 'ac.id')
  895. ->where('activities.draft', 0)
  896. ->where('activities.diagnostic', 0)
  897. ->select('courses.*')->distinct()
  898. //->whereNotNull('outcomes_attempted')
  899. ->whereIn('semester_id', Session::get('semesters_ids'))
  900. ->groupBy(array('code', 'number'));
  901. }));
  902. }))
  903. ->first();
  904. return View::make('local.managers.sCoords.new_assessment_report', compact('title', 'school'));
  905. }
  906. /**
  907. * Program Assessment Reports
  908. */
  909. public function programAssessmentReport($program_id)
  910. {
  911. //$outcome = Outcome::find($outcome_id);
  912. //if (!$outcome)
  913. // App::abort('404');
  914. $title = "Program Courses Report";
  915. set_time_limit(0);
  916. $program = Program::where('id', $program_id)
  917. ->has('courses')
  918. ->with(array('courses' => function ($query) {
  919. $query
  920. ->has('activities')
  921. //->whereNotNull('outcomes_attempted')
  922. ->join('activities', 'activities.course_id', '=', 'courses.id')
  923. ->join('activity_criterion as ac', 'ac.activity_id', '=', 'activities.id')
  924. ->join('assessments', 'assessments.activity_criterion_id', '=', 'ac.id')
  925. ->where('activities.draft', 0)
  926. ->where('activities.diagnostic', 0)
  927. ->select('courses.*')->distinct()
  928. ->whereIn('semester_id', Session::get('semesters_ids'))
  929. ->groupBy(array('code', 'number'));
  930. }))
  931. ->first();
  932. Log::info($program);
  933. return View::make('local.managers.pCoords.new_assessment_report', compact('title', 'program'));
  934. }
  935. /*public function professorAssessmentReports()
  936. {
  937. $semesters = Session::get('semesters_ids');
  938. $semesters = DB::table('semesters')->whereIn('id', $semesters)->orderBy('start', 'ASC')->first();
  939. Log::info($semesters->start);
  940. $outcomes = Outcome::select(array('id', 'name', 'expected_outcome'))
  941. ->whereNull('deleted_at')
  942. ->whereRaw("(deactivation_date IS NULL or deactivation_date >= '{$semesters->start}')")
  943. ->orderBy('name', 'ASC')->get();
  944. Log::info($outcomes);
  945. $title = "My Courses' Assessment Reports";
  946. return View::make('local.professors.assessment_reports', compact('title', 'outcomes'));
  947. }*/
  948. // Report for a single professor //with a single learning outcome
  949. public function professorAssessmentReport()
  950. {
  951. //$outcome = Outcome::find($outcome_id);
  952. //if (!$outcome)
  953. set_time_limit(0);
  954. // App::abort('404');
  955. $title = "My Courses' Assessment Report";
  956. //$activity_criterion = DB::table('assessments')->lists('activity_criterion_id');
  957. $courses = DB::table("courses")
  958. ->join('activities', 'activities.course_id', '=', 'courses.id')
  959. ->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
  960. ->join('assessments', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
  961. //->whereIn('activity_criterion.id', $activity_criterion)
  962. ->where('courses.user_id', '=', Auth::user()->id)
  963. ->where('activities.draft', '=', 0)
  964. ->where('activities.diagnostic', 0)
  965. ->whereIn('courses.semester_id', Session::get('semesters_ids'))
  966. ->groupBy(array('code', 'number'))
  967. ->get();
  968. /*$courses = Course::has('activites')
  969. ->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
  970. ->where('user_id', Auth::user()->id)
  971. ->where('activities.draft', '=', 0)
  972. ->whereIn('semester_id', Semester::get('semester_ids'))
  973. ->whereIn('activity_criterion.id', $activity_criterion)
  974. ->groupBy(array('code', 'number'))
  975. ->get();*/
  976. /*$courses = Course::where('user_id', Auth::user()->id)
  977. ->has('activities')
  978. //->whereNotNull('outcomes_attempted')
  979. ->whereIn('semester_id', Session::get('semesters_ids'))
  980. ->groupBy(array('code', 'number'))
  981. ->get();*/
  982. return View::make('local.professors.new_assessment_report', compact('title', 'courses'));
  983. }
  984. public function annualReport($program_id)
  985. {
  986. $title = "Program Annual Report";
  987. $annual_plans = DB::select("
  988. select
  989. academic_year,
  990. semester_start,
  991. semester_end,
  992. program_id,
  993. annual_plans.id as annual_id,
  994. annual_cycle.*
  995. from annual_plans
  996. join annual_cycle on annual_cycle_id = annual_cycle.id
  997. where program_id = {$program_id}
  998. order by semester_start desc");
  999. $program = DB::table('programs')
  1000. ->where('id', $program_id)
  1001. ->first();
  1002. return View::make('local.managers.shared.annual_report', compact('title', 'program_id', 'annual_plans', 'program'));
  1003. }
  1004. }