public function students($count = false) { //We get the role 'student' $student_role = \Pinom\Models\Role::where('shortname', '=', 'student')->first(); //We look for the role assignments to retrieve it for the $student_role->id $role_assignments = \Pinom\Models\RoleAssignments::where('roleid', '=', $student_role->id)->get(); //Using the query following guidelines from http://stackoverflow.com/a/24593266 answer return \Pinom\Models\Courses::select(array('mdl_role_assignments.userid'))->join('mdl_context', 'mdl_context.instanceid', '=', 'mdl_course.id')->leftJoin('mdl_role_assignments', 'mdl_role_assignments.contextid', '=', 'mdl_context.id')->where('mdl_context.contextlevel', '=', CONTEXT_COURSE)->where('mdl_role_assignments.roleid', '=', $student_role->id)->where('mdl_course.id', '=', $this->id)->get(); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { // $this->html->course = \Pinom\Models\Courses::find($id); if (!isset($this->html->course)) { return Redirect::to('/'); } $this->html->modules = array(); $courses_sections = \Pinom\Models\CoursesSections::where('course', '=', $id)->orderBy('section', 'ASC')->get(); foreach ($courses_sections as $cs) { $this->html->modules[$cs->section] = \Pinom\Models\CoursesModules::whereIn('id', explode(',', $cs->sequence))->get(); } return view($this->html->config->theme_folder . '.course-detail')->with('html', $this->html); }
/** * Display a listing of the resource. * * @return Response */ public function index() { //Loading courses $this->html->courses = \Pinom\Models\Courses::where('visible', '=', 1)->orderBy('sortorder', 'ASC')->get(); return view($this->html->config->theme_folder . '.index')->with('html', $this->html); }