protected static function _init() { $session = Registry::get("session"); if (!self::$_classroom) { if (!$session->get('StudentService:$classroom')) { $enrollment = \Enrollment::first(array("user_id = ?" => self::$_student->user_id), array("classroom_id")); $c = \Classroom::first(array("id = ?" => $enrollment->classroom_id), array("grade_id", "section", "year", "id", "created")); $g = \Grade::first(array("id = ?" => $c->grade_id), array("title", "id")); $classroom = array("id" => $c->id, "grade" => $g->title, "grade_id" => $g->id, "section" => $c->section, "year" => $c->year, "created" => $c->created); $classroom = ArrayMethods::toObject($classroom); $session->set('StudentService:$classroom', $classroom); } self::$_classroom = $session->get('StudentService:$classroom'); } if (!self::$_courses) { if (!$session->get('StudentService:$courses')) { $courses = \Course::all(array("grade_id = ?" => self::$_classroom->grade_id)); $subject = array(); foreach ($courses as $c) { $subject[$c->id] = $c; } $session->set('StudentService:$courses', $subject); } self::$_courses = $session->get('StudentService:$courses'); } }
public function profile($id) { $user = User::with('gender', 'course', 'userType')->where('StudentID', $id)->first(); $courses = Course::all()->lists('CourseAbbr', 'CourseID'); $genders = Gender::all()->lists('Gender', 'GenderID'); return View::make('validated.profile.edit', compact('user', 'courses', 'genders')); }
public static function sandbox() { // Testaa koodiasi täällä // echo 'Hello World!'; // View::make('helloworld.html'); $tali = Course::find(2); $courses = Course::all(); Kint::dump($tali); Kint::dump($courses); }
/** * @before _secure, _school */ public function manage($grade_id) { $grade = \Grade::first(array("id = ?" => $grade_id), array("title", "id", "organization_id")); if (!$grade || $grade->organization_id != $this->organization->id) { self::redirect("/school"); } $this->setSEO(array("title" => "School | Manage Subjects (Courses)")); $view = $this->getActionView(); $courses = Course::all(array("grade_id = ?" => $grade_id)); $view->set("courses", $courses); $view->set("grade", $grade); }
/** * Checks if round is ready to be saved. If not, displays round edit page with information already inputted. If yes, attempts to update selected round and related scores. * * @param int $id Id of selected round. */ public static function update($id) { $player = self::get_user_logged_in(); if (!$player) { View::make('player/login.html', array('error' => 'Vain kirjautuneet käyttäjät voivat muokata ratoja.')); } $params = $_POST; $players = Player::all(); $course = Course::find($params['course']); $courses = Course::all(); $played = $params['played']; $round = Round::find($id); $holes = Hole::find_by_course($course->id); $scores = Score::find_by_round($id); $numberOfPlayers = sizeof($scores); if ($params['course'] != $params['course_orig']) { // If course selection has changed we need to display edit page again with new information. $playerScores = array(); $numberOfHoles = Hole::count_holes($params['course_orig']); for ($i = 1; $i <= $numberOfPlayers; $i++) { $holeScores = array(); for ($j = 1; $j <= $numberOfHoles; $j++) { $holeScores[] = $params['p' . $i . '_h' . $j]; } $playerScores[] = array('player' => Player::find($params['player_' . $i]), 'holes' => $holeScores); } View::make('round/edit.html', array('numberOfPlayers' => $numberOfPlayers, 'players' => $players, 'course' => $course, 'holes' => $holes, 'courses' => $courses, 'playerScores' => $playerScores, 'round' => $round, 'scores' => $scores, 'played' => $played)); } else { $attributes = array('courseId' => $params['course'], 'played' => $params['played']); $playerScores = array(); $numberOfHoles = Hole::count_holes($params['course_orig']); $round = new Round(array_merge(array("id" => $round->id), $attributes)); $errors = $round->errors(); if (count($errors) == 0) { $round->update(); for ($i = 1; $i <= $numberOfPlayers; $i++) { $holeScores = array(); $scoreId = $params['score_' . $i]; for ($j = 1; $j <= $numberOfHoles; $j++) { $hole = Hole::find_by_course_and_holenumber($params['course_orig'], $j); $holeScores[] = array('throws' => $params['p' . $i . '_h' . $j], 'holeId' => $hole->id, 'holenumber' => $j); } $score = new Score(array('id' => $scoreId, 'playerId' => $params['player_' . $i], 'roundId' => $round->id, 'scores' => $holeScores)); $score->update(); } Redirect::to('/round/' . $round->id, array('message' => 'Kierrosta muokattu.')); } else { View::make('round/new.html', array('errors' => $errors, 'attributes' => $attributes)); } } }
public static function show($gameid) { $game = Game::find_format_gamedate($gameid); $games = array($game); View::make('game/show.html', array('games' => $games, 'courses' => Course::all())); }
private function _findStudents() { $session = Registry::get("session"); if (RequestMethods::post("action") == "findStudents") { $exam = RequestMethods::post("exam"); preg_match("/(.*);(.*)/", $exam, $matches); $exam_type = $matches[1]; $exam_year = $matches[2]; $classroom_id = RequestMethods::post("classroom_id"); $grade_id = RequestMethods::post("grade"); $enrollments = Enrollment::all(array("classroom_id = ?" => $classroom_id)); $exams = Exam::all(array("grade_id = ?" => $grade_id, "type = ?" => $exam_type), array("id", "grade_id", "course_id")); $courses = Course::all(array("organization_id = ?" => $this->organization->id), array("title", "id")); $arr = array(); foreach ($courses as $c) { $arr["{$c->id}"] = $c->title; } $courses = array(); foreach ($exams as $e) { $courses[] = array("title" => $arr["{$e->course_id}"], "id" => $e->course_id); } $courses = ArrayMethods::toObject($courses); $session->set('Exams\\Result:$exams', $exams); $session->set('Exams\\Result:$grade_id', $grade_id); return array("courses" => $courses, "exams" => $exams, "enrollments" => $enrollments); } return false; }
public function index() { $courses = Course::all(); $menu = 'project'; return View::make('courses.index', compact('courses', 'menu')); }
public static function index() { $courses = Course::all(); View::make('course/index.html', array('courses' => $courses)); }
public static function list_courses() { $courses = Course::all(); View::make('course/list.html', array('courses' => $courses)); }
/** * Attempts to update an edited users information. * * @param int $id Id of edited user. */ public static function update($id) { $params = $_POST; if (!is_numeric($params['courseid'])) { $params['courseid'] = null; } $attributes = array('id' => $id, 'name' => $params['name'], 'courseId' => $params['courseid'], 'username' => $params['username'], 'password' => $params['new_password'], 'verify' => $params['password_verify'], 'newPassword' => strlen($params['new_password']) != 0); $player = new Player($attributes); $errors = $player->errors(); if (Player::authenticate(self::get_user_logged_in()->username, $params['password']) == null) { $player = Player::find($id); $courses = Course::all(); View::make('player/edit.html', array('errors' => $errors, 'attributes' => $attributes, 'player' => $player, 'courses' => $courses, 'error' => 'Väärä salasana tämänhetkiselle käyttäjälle.')); } if (count($errors) == 0) { $player->update(); Redirect::to('/player', array('message' => 'Käyttäjän tietoja muutettu.')); } else { $player = Player::find($id); $courses = Course::all(); View::make('player/edit.html', array('errors' => $errors, 'attributes' => $attributes, 'player' => $player, 'courses' => $courses)); } }
public function getMasterList() { $sql = "SELECT sm.*, cr.id AS course_id, cr.code AS course\n\t\t\t\tFROM student_master AS sm \n\t\t\t\tINNER JOIN course AS cr\n\t\t\t\tON sm.course_id = cr.id\n\t\t\t\tORDER BY last_name ASC"; $master = DB::select($sql); $course = Course::all(); return View::make('admin.master_list')->with('master', $master)->with('course', $course); }
public function getSummaryEmploymentStatus() { // $test = $_GET['test']; // if($test == 1) // return '1'; // else // return '2'; $academic_years = array(); $data = array(); $program = array(); $from = $_GET['from']; $to = $_GET['to']; $department = $_GET['department']; $emp_status = $_GET['emp_status']; $acad_in = 0; for ($i = $from; $i <= $to; $i++) { $academic_years[$acad_in] = $i; $acad_in++; } if ($department == 0) { $courses = Course::all(); $i = 0; foreach ($courses as $crs) { $crs_id = $crs->id; $temp_data = array(); $index = 0; for ($j = $from; $j <= $to; $j++) { $sql = "SELECT tr.choice_id, COUNT(tr.choice_id) AS 'count'\n\t\t\t\t\t\t\tFROM alumni_tracer AS tr\n\t\t\t\t\t\t\tINNER JOIN alumni AS al\n\t\t\t\t\t\t\tON al.id = tr.alumni_id\n\t\t\t\t\t\t\tWHERE al.year_graduated = ? \n\t\t\t\t\t\t\tAND tr.choice_id = ? \n\t\t\t\t\t\t\tAND al.course_id = ?"; $result = DB::select($sql, array($j, $emp_status, $crs_id)); if ($result[0]->choice_id == null) { $temp_data[$index] = 0; } else { $temp_data[$index] = $result[0]->count; } $index++; } $program[$i] = $crs->code; $data[$i] = $temp_data; $i++; } } else { $courses = DB::select("SELECT * FROM course WHERE dept_id = ?", array($department)); $i = 0; foreach ($courses as $crs) { $crs_id = $crs->id; $temp_data = array(); $index = 0; for ($j = $from; $j <= $to; $j++) { $sql = "SELECT tr.choice_id, COUNT(tr.choice_id) AS 'count'\n\t\t\t\t\t\t\tFROM alumni_tracer AS tr\n\t\t\t\t\t\t\tINNER JOIN alumni AS al\n\t\t\t\t\t\t\tON al.id = tr.alumni_id\n\t\t\t\t\t\t\tWHERE al.year_graduated = ? \n\t\t\t\t\t\t\tAND tr.choice_id = ? \n\t\t\t\t\t\t\tAND al.course_id = ?"; $result = DB::select($sql, array($j, $emp_status, $crs_id)); if ($result[0]->choice_id == null) { $temp_data[$index] = 0; } else { $temp_data[$index] = $result[0]->count; } $index++; } $program[$i] = $crs->code; $data[$i] = $temp_data; $i++; } } return View::make('analytics.summary_employment')->with('academic_years', $academic_years)->with('program', $program)->with('data', $data); // return json_encode($academic_years); }
public static function display_score_card_pictures_by_year($year) { $full_path = getcwd(); $path = str_replace("/disc-golf-stats/app/controllers", "", $full_path); $path = str_replace("/xamppfiles", "", $path); $echo = ImageDisplayer::display($path . "/score_cards", $year); View::make('game/score_card_images.html', array('current_year' => $year, 'images' => $echo, 'players' => Player::all(), 'courses' => Course::all(), 'game_years' => Game::game_years())); }
public function filters($offset = 0) { $string = '%' . $this->input->post('curso') . '%'; $c = $this->input->post('level_id'); $div = $this->input->post('division_id'); $condiciones = ''; $valores = array(); if ($string != '%%') { $condiciones .= " course LIKE ?"; $valores['curso'] = $string; } if ($div > 0) { if ($condiciones != '') { $condiciones .= " AND "; } $condiciones .= " division_id = ?"; $valores['div'] = $div; } if ($c > 0) { if ($condiciones != '') { $condiciones .= " AND "; } $condiciones .= " level_id = ?"; $valores['nivel'] = $c; } $this->session->set_userdata('filtros_cursos', $valores); $conditions = array_merge(array($condiciones), $valores); $config['base_url'] = site_url('cursos/index'); $config['total_rows'] = Course::count(array('joins' => array('level', 'division'), 'conditions' => $conditions)); $config['per_page'] = '10'; $config['num_links'] = '10'; $config['first_link'] = '← primero'; $config['last_link'] = 'último →'; $this->load->library('pagination', $config); $cursos = Course::all(array('joins' => array('level', 'division'), 'conditions' => $conditions, 'limit' => $config['per_page'], 'offset' => $offset)); $this->table->set_heading('Curso', 'División', 'Nivel', 'Acciones'); foreach ($cursos as $curso) { $this->table->add_row($curso->course, $curso->division->division, $curso->level->descripcion, anchor('cursos/editar/' . $curso->id, img('static/img/icon/pencil.png'), 'class="tipwe" title="Editar"') . ' ' . anchor('cursos/eliminar/' . $curso->id, img('static/img/icon/trash.png'), 'class="tipwe eliminar" title="Eliminar"')); } echo $this->table->generate(); echo '<div class="pagination">'; echo $this->pagination->create_links(); echo '</div>'; }