123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718 |
- <?php
-
- use Illuminate\Support\Facades\Input;
-
- class CriteriaController extends \BaseController
- {
-
- /**
- * Display a listing of the resource.
- *
- *
- * @return Response
- */
- public function editProgram()
- {
- $userProgram = Auth::user()['id'];
-
- $userProgram = DB::select("select program_user.program_id from program_user where user_id = {$userProgram}");
- Log::info($userProgram);
- $title = "Criteria";
- $outcomes = Outcome::orderBy('name', 'ASC')->lists('name', 'id');
-
- $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
- $programs = Program::where("id", "=", $userProgram[0]->program_id)->get();
- return View::make('local.managers.pCoords.criteria', compact('title', 'outcomes', 'schools', 'criteria', 'programs', 'objectives'));
- }
-
- public function editSchool()
- {
- $userSchool = Auth::user()['school_id'];
- Log::info($userSchool);
- $title = "Criteria";
- $outcomes = Outcome::orderBy('name', 'ASC')->lists('name', 'id');
-
- $schools = School::find($userSchool)->get();
- $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
- $programs = Program::where("school_id", "=", $userSchool)->orderBy('name', 'ASC')->get();
- $listOfId = array();
- foreach ($programs as $program) {
-
- $listOfId[] = $program->id;
- }
-
- $objectives = DB::table('objectives')->whereIn('program_id', $listOfId)->orderBy('text', 'ASC')->lists('text', 'id');
-
-
-
-
-
- return View::make('local.managers.sCoords.criteria', compact('title', 'outcomes', 'schools', 'criteria', 'programs', 'objectives'));
- }
-
-
- public function fetchCriterion()
- {
- return Criterion::find(Input::get('id'));
- }
- public function fetchAllCriterion()
- {
- $program_id = Input::get('program_fetch');
- $outcome_id = Input::get('outcome_fetch');
- $json = array();
- $json['criterion'] = DB::select("SELECT * FROM `new_criteria` where id in (select criterion_id from criterion_objective_outcome where outcome_id ={$outcome_id}) and id in(select criterion_id from program_criterion where program_id = {$program_id})");
- return json_encode($json);
- }
- public function fetchObjectivesForSelect()
- {
-
- $json = array();
- Log::info("GET COCKEd");
- Log::info(Input::get('allOutcomes'));
- foreach (Input::get('allOutcomes') as $id) {
- $json['outcomes'][$id] = DB::select("select name from outcomes where id = {$id}");
- $json['objectives'][$id] = DB::select("select objectives.id, objectives.text, outcomes.name from objectives, objective_outcome, outcomes where objective_outcome.outcome_id ={$id} and objective_outcome.objective_id = objectives.id and objectives.active=1 and outcomes.id = objective_outcome.outcome_id");
- }
- Log::info(print_r($json, true));
- return json_encode($json);
- }
- public function fetchCriterionWithTrashed()
- {
-
- $json = array();
- $json['criteria'] = DB::select(" select * from new_criteria where id = ?", array(Input::get('id')));
- $json['outcomes'] = DB::select("select DISTINCT outcomes.id, outcomes.name from outcomes , criterion_objective_outcome where criterion_objective_outcome.criterion_id = ? and outcomes.id = criterion_objective_outcome.outcome_id order by outcomes.id", array(Input::get('id')));
- $json['objectives'] = DB::select("SELECT DISTINCT objectives.id, objectives.text FROM objectives, criterion_objective_outcome where criterion_objective_outcome.criterion_id = ? and criterion_objective_outcome.objective_id= objectives.id ", array(Input::get('id')));
- $json['objectives_outcome'] = DB::select("select objectives.id, objectives.text, objective_outcome.outcome_id from objective_outcome, objectives where objective_outcome.outcome_id in(select DISTINCT outcomes.id from outcomes , criterion_objective_outcome where criterion_objective_outcome.criterion_id = ? and outcomes.id = criterion_objective_outcome.outcome_id) and objectives.id = objective_outcome.objective_id ORDER BY outcome_id", array(Input::get('id')));
- $json['scales'] = DB::select("select title, description, min_score, max_score from scales, criterion_scale where criterion_scale.scale_id = scales.id and criterion_id = ?", array(Input::get('id')));
- $json['program'] = DB::select("select criterion_id, program_id from program_criterion where criterion_id =?", array(Input::get('id')));
- $json['activity_criterion'] = DB::select("select * from new_assessments where activity_criterion_id in (select id from activity_criterion where criterion_id = ?)", array(Input::get('id')));
-
- foreach ($json['outcomes'] as $id) {
- $outId = $id->id;
- $json['outcomes_assoc'][$outId] = DB::select("select name from outcomes where id = {$outId}");
- $json['objectives_assoc'][$outId] = DB::select("select objectives.id, objectives.text, outcomes.name from objectives, objective_outcome, outcomes where objective_outcome.outcome_id ={$outId} and objective_outcome.objective_id = objectives.id and objectives.active=1 and outcomes.id = objective_outcome.outcome_id");
- }
-
- return json_encode($json);
- }
-
- public function delete()
- {
- DB::delete("delete from new_criteria where id = ?", array(Input::get('criterion_delete')));
- $role = Auth::user()['role'];
- switch ($role) {
- case 1:
- return Redirect::to('criteria')->withInput();
-
- case 2:
- return Redirect::to('school-criteria')->withInput();
-
- case 3:
- return Redirect::to('program-criteria')->withInput();
- }
- }
- public function isCriterionUnique($input, $existing_criterion = NULL)
- {
- // dd($input);
- Log::info('isCriterionUnique');
-
- if (Input::get('program_id') != 0)
- $program_id = $input['program_id'];
- else
- $program_id = NULL;
-
- $saved_criterion = Criterion::withTrashed()
- ->where('name', '=', $input['name'])
- ->where('outcome_id', '=', $input['outcome_id'])
- ->where('program_id', '=', $program_id)
- ->first();
-
-
-
- if ($saved_criterion)
- return false;
- else
- return true;
- }
-
- private function cleanInput()
- {
- $clean_input = array();
-
- $clean_input['name'] = trim(preg_replace('/\t+/', '', Input::get('name')));
-
-
- $trimmed = trim(preg_replace('/\t+/', '', Input::get('subcriteria')));
-
- Log::info('trimmed 1 -->' . $trimmed . '<--');
-
-
- if ($trimmed == '') {
- $trimmed = NULL;
- } else {
- $trimmed = json_encode(preg_split('/\r\n/', $trimmed));
- }
-
- Log::info('trimmed 2 -->' . $trimmed . '<--');
-
-
- $clean_input['subcriteria'] = $trimmed;
- $clean_input['outcome_id'] = Input::get('outcome');
-
-
-
- $clean_input['objective_id'] = Input::get('objective');
-
-
-
-
- $clean_input['program_id'] = Input::get('program_id');
-
- $clean_input['copyright'] = trim(preg_replace('/\t+/', '', Input::get('copyright')));
- $clean_input['notes'] = trim(preg_replace('/\t+/', '', Input::get('notes')));
- $clean_input['maximum_score'] = (int) Input::get('maximum_score');
- $clean_input['scale_title'] = Input::get('title');
- $clean_input['scale_description'] = Input::get('Scales');
- $clean_input['min_score'] = Input::get('min');
- $clean_input['max_score'] = Input::get('max');
-
- $clean_input['number_of_scales'] = sizeof($clean_input['scale_title']);
-
-
- return $clean_input;
- }
-
- private function makeValidator($clean_input)
- {
- /** Validation rules */
- return Validator::make(
- array(
- 'name' => $clean_input['name'],
- 'subcriteria' => $clean_input['subcriteria'],
- 'outcome_id' => $clean_input['outcome_id'],
- 'notes' => $clean_input['notes'],
- 'copyright' => $clean_input['copyright'],
- 'maximum_score' => $clean_input['maximum_score']
- ),
- array(
- 'name' => 'required|string',
- 'subcriteria' => 'string',
- 'outcome_id' => 'required|array',
-
- 'notes' => 'string',
- 'copyright' => 'string',
- 'maximum_score' => 'required|integer'
- )
-
- );
- }
-
- /**
- * Create a new criterion.
- *
- * @return Redirect Redirect back to form page
- */
- public function create()
- {
- $clean_input = $this->cleanInput();
-
- /** Validation rules */
- $validator = $this->makeValidator($clean_input);
-
- /** If validation fails */
- if ($validator->fails()) {
- /** Prepare error message */
- $message = '<p>Error(s) creating a new Criterion:</p><ul>';
-
- foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
- $message .= $validationError;
- }
-
- $message .= '</ul>';
-
- /** Send error message and old data */
- Session::flash('status', 'danger');
- Session::flash('message', $message);
- $role = Auth::user()['role'];
- switch ($role) {
- case 1:
- return Redirect::to('criteria')->withInput();
-
- case 2:
- return Redirect::to('school-criteria')->withInput();
-
- case 3:
- return Redirect::to('program-criteria')->withInput();
- }
- } else {
- // Check criterion uniqueness
- /*if (!$this->isCriterionUnique($clean_input)) {
- /** Send error message and old data
- Session::flash('status', 'danger');
- Session::flash('message', 'This criterion is a duplicate of an already saved criterion because its name and associated program are the same.');
- return Redirect::to('criteria')->withInput();
- }*/
-
- /** Instantiate new criterion */
- $criterion = new Criterion;
- $criterion->name = $clean_input['name'];
- $criterion->subcriteria = $clean_input['subcriteria'];
-
-
- //gabriel añadió aqui
-
- $criterion->number_of_scales = $clean_input['number_of_scales'];
- $criterion->maximum_score = $clean_input['maximum_score'];
-
- if (Input::get('copyright'))
- $criterion->copyright = $clean_input['copyright'];
-
- if (Input::get('notes'))
- $criterion->notes = $clean_input['notes'];
-
-
-
- /** If criterion is saved, send success message */
- if ($criterion->save()) {
-
- $criterionId = $criterion->id;
- foreach ($clean_input['outcome_id'] as $outcome_id) {
- foreach ($clean_input['objective_id'] as $objective_id) {
-
- DB::insert("insert into `criterion_objective_outcome` (`objective_id`, `outcome_id`, `criterion_id`, `objective_outcome_id`) values ({$objective_id},{$outcome_id}, {$criterionId}, 0)");
- }
- }
-
- for ($i = 0; $i < sizeof($clean_input['scale_title']); $i++) {
- $scale = new Scale;
- $scale->title = $clean_input['scale_title'][$i];
- $scale->position = $i + 1;
- $scale->description = $clean_input['scale_description'][$i];
- $scale->min_score = $clean_input['min_score'][$i];
- $scale->max_score = $clean_input['max_score'][$i];
-
- if ($scale->save()) {
- DB::insert("insert into `criterion_scale` (`criterion_id`, `scale_id`) values({$criterionId},{$scale->id})");
- } else {
- Session::flash('status', 'danger');
- Session::flash('message', '<p>Error creating the Scales</p>');
- $role = Auth::user()['role'];
- switch ($role) {
- case 1:
- return Redirect::to('criteria')->withInput();
-
- case 2:
- return Redirect::to('school-criteria')->withInput();
-
- case 3:
- return Redirect::to('program-criteria')->withInput();
- }
- }
- }
-
- foreach ($clean_input['program_id'] as $program_id) {
- DB::insert("insert into `program_criterion` (`criterion_id`, `program_id`) values({$criterionId},{$program_id})");
- }
-
- Session::flash('status', 'success');
- Session::flash('message', 'Criterion created: "' . $criterion->name . '".');
- $role = Auth::user()['role'];
- switch ($role) {
- case 1:
- return Redirect::to('criteria')->withInput();
-
- case 2:
- return Redirect::to('school-criteria')->withInput();
-
- case 3:
- return Redirect::to('program-criteria')->withInput();
- }
- }
-
- /** If saving fails, send error message and old data */
- else {
- Session::flash('status', 'danger');
- Session::flash('message', '<p>Error creating Criterion. Please try again later.</p>');
- $role = Auth::user()['role'];
- switch ($role) {
- case 1:
- return Redirect::to('criteria')->withInput();
-
- case 2:
- return Redirect::to('school-criteria')->withInput();
-
- case 3:
- return Redirect::to('program-criteria')->withInput();
- }
- }
- }
- }
-
-
-
- public function edit()
- {
- $title = "Criteria";
- $outcomes = Outcome::orderBy('name', 'ASC')->lists('name', 'id');
-
- $schools = School::orderBy('name', 'ASC')->get();
- $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
- $programs = Program::orderBy('name', 'ASC')->get();
- $objectives = DB::table('objectives')->orderBy('text', 'ASC')->lists('text', 'id');
-
-
-
-
-
- return View::make('local.managers.admins.criteria', compact('title', 'outcomes', 'schools', 'criteria', 'programs', 'objectives'));
- }
-
- private function cleanInputEdit()
- {
- $clean_input = array();
-
- $clean_input['name'] = trim(preg_replace('/\t+/', '', Input::get('name')));
-
-
- $trimmed = trim(preg_replace('/\t+/', '', Input::get('subcriteria')));
-
- Log::info('trimmed 1 -->' . $trimmed . '<--');
-
-
- if ($trimmed == '') {
- $trimmed = NULL;
- } else {
- $trimmed = json_encode(preg_split('/\r\n/', $trimmed));
- }
-
- Log::info('trimmed 2 -->' . $trimmed . '<--');
-
-
- $clean_input['subcriteria'] = $trimmed;
- $clean_input['outcome_id'] = Input::get('assoc_outcome');
-
-
-
- $clean_input['objective_id'] = Input::get('assoc_objective');
-
-
-
-
- $clean_input['program_id'] = Input::get('program_id');
-
- $clean_input['copyright'] = trim(preg_replace('/\t+/', '', Input::get('copyright')));
- $clean_input['notes'] = trim(preg_replace('/\t+/', '', Input::get('notes')));
- $clean_input['maximum_score'] = (int) Input::get('assoc_maximum_score');
- $clean_input['scale_title'] = Input::get('assoc_title');
- $clean_input['scale_description'] = Input::get('assoc_scales');
- $clean_input['number_of_scales'] = sizeof($clean_input['scale_title']);
-
-
- return $clean_input;
- }
-
- public function update()
- {
- $criterion = Criterion::withTrashed()->find(Input::get('id'));
-
- $clean_input = $this->cleanInputEdit();
-
- /** Validation rules */
- $validator = $this->makeValidator($clean_input);
-
- /** If validation fails */
- if ($validator->fails()) {
- /** Prepare error message */
- $message = 'Error(s) updating the Criterion: <ul>';
-
- foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
- $message .= $validationError;
- }
-
- $message .= '</ul>';
-
- /** Send error message and old data */
- Session::flash('status', 'danger');
- Session::flash('message', $message);
- $role = Auth::user()['role'];
- switch ($role) {
- case 1:
- return Redirect::to('objective')->withInput();
-
- case 2:
- return Redirect::to('school-objective')->withInput();
-
- case 3:
- return Redirect::to('program-objective')->withInput();
- }
- } else {
-
- // // Check criterion uniqueness
- // if(!$this->isCriterionUnique($clean_input, $criterion))
- // {
- // /** Send error message and old data */
- // Session::flash('status', 'danger');
- // Session::flash('message', 'This criterion is a duplicate of an already saved criterion because its name, assoaciated school or program, and progress indicators are the same.');
- // return Redirect::to('criteria')->withInput();
- // }
-
- /** Set info */
- $criterion->name = $clean_input['name'];
- $criterion->subcriteria = $clean_input['subcriteria'];
-
-
-
- $criterion->number_of_scales = $clean_input['number_of_scales'];
- $criterion->maximum_score = $clean_input['maximum_score'];
-
-
-
- // Set program
- if (Input::get('program_id') != 0)
- $criterion->program_id = Input::get('program_id');
- else
- $criterion->program_id = NULL;
-
- // Set status
- if (Input::get('status') == 0)
- $criterion->deleted_at = date('Y-m-d H:i:s');
- else
- $criterion->deleted_at = NULL;
-
- if (Input::get('copyright'))
- $criterion->copyright = $clean_input['copyright'];
- else
- $criterion->copyright = NULL;
-
- if (Input::get('notes'))
- $criterion->notes = $clean_input['notes'];
- else
- $criterion->notes = NULL;
-
- /** If criterion is updated, send success message */
- if ($criterion->save()) {
- $criterionId = $criterion->id;
- DB::delete("delete from `criterion_objective_outcome` where `criterion_id` ={$criterionId}");
-
- foreach ($clean_input['outcome_id'] as $outcome_id) {
- foreach ($clean_input['objective_id'] as $objective_id) {
-
- DB::insert("insert into `criterion_objective_outcome` (`objective_id`, `outcome_id`, `criterion_id`,`objective_outcome_id`) values ({$objective_id},{$outcome_id}, {$criterionId}, 0)");
- }
- }
- DB::delete("delete from `scales` where id in (select scale_id id from criterion_scale where criterion_id = {$criterionId})");
-
- for ($i = 0; $i < sizeof($clean_input['scale_title']); $i++) {
- $scale = new Scale;
- $scale->title = $clean_input['scale_title'][$i];
- $scale->position = $i + 1;
- $scale->description = $clean_input['scale_description'][$i];
- if ($scale->save()) {
- DB::insert("insert into `criterion_scale` (`criterion_id`, `scale_id`) values({$criterionId},{$scale->id})");
- } else {
- Session::flash('status', 'danger');
- Session::flash('message', '<p>Error creating the Scales</p>');
- $role = Auth::user()['role'];
- switch ($role) {
- case 1:
- return Redirect::to('objective')->withInput();
-
- case 2:
- return Redirect::to('school-objective')->withInput();
-
- case 3:
- return Redirect::to('program-objective')->withInput();
- }
- }
- }
-
-
-
- Session::flash('status', 'success');
- Session::flash('message', 'Updated criterion: "' . $criterion->name . '"');
- $role = Auth::user()['role'];
- switch ($role) {
- case 1:
- return Redirect::to('objective')->withInput();
-
- case 2:
- return Redirect::to('school-objective')->withInput();
-
- case 3:
- return Redirect::to('program-objective')->withInput();
- }
- }
-
- /** If saving fails, send error message and old data */
- else {
- Session::flash('status', 'danger');
- Session::flash('message', 'Error updating the Criterion. Please try again later.');
- $role = Auth::user()['role'];
- switch ($role) {
- case 1:
- return Redirect::to('objective')->withInput();
-
- case 2:
- return Redirect::to('school-objective')->withInput();
-
- case 3:
- return Redirect::to('program-objective')->withInput();
- }
- }
- }
- }
-
- public function index()
- {
- // el ID de los semestres que el usuario tiene seleccionado.
- $semesters_ids = Session::get('semesters_ids');
- // buscar informacion de los semestres seleccionados
- $semesters = Semester::whereIn('id', $semesters_ids)->get();
-
- $title = "Learning Outcomes and Criteria";
- $outcomes = Outcome::orderBy('name', 'ASC')->get();
- // $outcomes = DB::table('outcomes')
- // ->orderBy('name', 'asc')
- // ->get();
- $schools = School::orderBy('name', 'ASC')->get();
- // $schools = DB::table('schools')
- // ->orderBy('name', 'asc')
- // ->get();
- $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
- // $criteria = DB::table('criteria')
- // ->orderBy('name', 'asc')
- // ->get();
-
- // se annadio la nueva variable
- return View::make('global.view-learning-outcomes-criteria', compact('title', 'outcomes', 'schools', 'criteria', 'semesters'));
-
- }
-
-
- // copie index() y lo edite
- public function objectivesIndex()
- {
- if (Auth::user()->role == 1) {
- //uscar todos los objetivos
- $objectives = DB::table('program_user')
- ->join('objectives', 'objectives.program_id', '=', 'program_user.program_id')
- ->join('programs', 'programs.id', '=', 'program_user.program_id')
- ->select('objectives.id', 'objectives.text', 'programs.name')
- ->orderBy('objectives.text', 'asc')
- ->get();
- } elseif (Auth::user()->role == 2) {
- //buscar los objetivos de la departamento (school)
- $objectives = DB::table('program_user')
- ->join('objectives', 'objectives.program_id', '=', 'program_user.program_id')
- ->join('programs', 'programs.id', '=', 'program_user.program_id')
- ->where('programs.school_id', Auth::user()->school_id)
- ->select('objectives.id', 'objectives.text', 'programs.name')
- ->orderBy('objectives.text', 'asc')
- ->get();
- } elseif ((Auth::user()->role == 3) || (Auth::user()->role == 4)) {
- //buscar los objetivos de los programas cuales el profesor esta
- $objectives = DB::table('program_user')
- ->join('objectives', 'objectives.program_id', '=', 'program_user.program_id')
- ->join('programs', 'programs.id', '=', 'program_user.program_id')
- ->where('program_user.user_id', Auth::user()->id)
- ->select('objectives.id', 'objectives.text', 'programs.name')
- ->orderBy('objectives.text', 'asc')
- ->get();
- }
-
- $title = "Learning Objectives and Criteria";
-
- return View::make('global.view-objectives-criteria', compact('title', 'objectives'));
- }
-
- public function destroy()
- {
- $criterion = Criterion::withTrashed()->find(Input::get('id'));
- if (!$criterion->trashed()) {
- try {
- $criterion->delete();
- Session::flash('status', 'success');
- Session::flash('message', 'Deactivated criterion: "' . $criterion->name . '"');
- } catch (Exception $e) {
- Session::flash('status', 'danger');
- Session::flash('message', 'Error deactivating criterion."' . $criterion->name . '"');
- }
- $role = Auth::user()['role'];
- switch ($role) {
- case 1:
- return Redirect::to('objective')->withInput();
-
- case 2:
- return Redirect::to('school-objective')->withInput();
-
- case 3:
- return Redirect::to('program-objective')->withInput();
- }
- } else {
- try {
- $criterion->restore();
- Session::flash('status', 'success');
- Session::flash('message', 'Reactivated criterion: "' . $criterion->name . '"');
- } catch (Exception $e) {
- Session::flash('status', 'danger');
- Session::flash('message', 'Error reactivating criterion: "' . $criterion->name . '".');
- }
- $role = Auth::user()['role'];
- switch ($role) {
- case 1:
- return Redirect::to('objective')->withInput();
-
- case 2:
- return Redirect::to('school-objective')->withInput();
-
- case 3:
- return Redirect::to('program-objective')->withInput();
- }
- }
- }
-
- public function filterCriteria()
- {
- switch (Input::get('filter')) {
- case 'all':
- return Criteria::all();
- break;
-
- case 'school':
- // If scoord
- if (Auth::user()->role == '2') {
-
- // Fetch all the programs whose school is the user's
- $program_ids = DB::table('programs')->where('school_id', Auth::user()->school_id)->lists('id');
-
- // Return all criteria belonging to any of those programs
- return Criterion::whereIn('program_id', $program_ids)
- ->orderBy('name', 'ASC')
- ->get();
- }
-
- // If pcoord
- else {
- // Fetch all the programs from the user's school;
- $program_ids = DB::table('programs')->where('school_id', Auth::user()->programs[0]->school->id)->lists('id');
-
- return Criterion::whereIn('program_id', $program_ids)
- ->orderBy('name', 'ASC')
- ->get();
- }
-
- break;
-
- case 'program':
- return Criterion::whereIn('program_id', Auth::user()->programs->lists('id'))
- ->orderBy('name', 'ASC')
- ->get();
- break;
-
- default:
- return Criteria::all();
- break;
- }
- }
- }
|