public function submit() { $question = $this->question->get_or_create_by_game($this->game_sessions["game_id"]); $estimate = $this->input->post("estimate"); for ($i = 1; $i < 32; $i++) { if (isset($estimate[$i])) { $data["estimate"] = $estimate[$i]; $part_id = $i; $this->answer->update_by_question($data, $question->id, $part_id); } } if ($this->input->post("save") == "1") { $level_sessions = need_level(); $margin = get_margin($level_sessions["level_id"]); $data["total_score"] = $this->answer->calculate_score_by_questions($question->id, $margin); $data["game_id"] = $this->game_sessions["game_id"]; $data["timestamp"] = $date = date('m/d/Y h:i:s a', time()); // $this->summary->insert($data); $this->session->set_flashdata("notice", "permainan telah berakhir"); redirect(base_url() . "quiz_cost/index"); //redirect(base_url()."games/run"); } else { redirect(base_url() . "users/endgame"); // redirect(base_url()."quiz_cost/index"); } }
public function run() { $success = false; if (need_level() == false) { redirect(base_url() . "games/chose_level"); } $params["notice"] = get_notice(); $game_sessions = need_game(); if ($game_sessions != false) { $params['is_resume'] = 'true'; $this->htmllib->add_js('pages/game.js'); $this->load->view('plain/default_header'); $this->load->view("games/home", $params); $this->load->view('plain/default_footer'); // $this->load->view("games/run",$params); } else { if ($this->input->post("game_id") != "0") { $game_id = $this->input->post("game_id"); $game = $this->game->get_by_id($game_id); $success = true; } else { $data["user_id"] = $this->session->userdata("user_id"); $data["level_id"] = $this->session->userdata("level_id"); $success = true; $game_id = $this->game->insert($data); $game = $this->game->get_by_id($game_id); } $this->session->set_userdata("game_id", $game_id); $this->session->set_userdata("game", $game); // $this->load->view("games/run",$params); echo json_encode($success); } }
public function submit() { $data["wst"] = $this->input->post("wst"); $data["engine_power"] = $this->input->post("engine_power"); $data["type_of_engine"] = $this->input->post("type_of_engine"); $data["lwt"] = $this->input->post("lwt"); $this->tebak_regresi->update_by_game($data, $this->game_sessions["game_id"]); if ($this->input->post("save") == "1") { $level_sessioins = need_level(); $margin = get_margin($level_sessioins["level_id"]); $this->tebak_regresi->calculate_score_by_game($this->game_sessions["game_id"], $margin); $this->session->set_flashdata("notice", "permainan telah berakhir"); //redirect(base_url()."games/run"); redirect(base_url() . "quiz_regresi/index"); } else { // redirect(base_url()."quiz_regresi/index"); redirect(base_url() . "quiz_cost"); } }