public function addQuiz() { $in = Input::all(); $rules = ['name' => 'required', 'topic' => 'required']; $validation = Validator::make($in, $rules); if ($validation->passes()) { $quiz = Quiz::create(['name' => $in['name'], 'OwnerID' => Auth::user()->StudentID, 'quizTopic' => $in['topic']])->id; return Redirect::to('/')->with('message', 'Quiz successfully created')->with('url', '/quiz/view/' . $quiz); } return Redirect::to('/')->with('message', 'Error quiz creation. Click view to create again')->with('url', '/quiz/create/'); }
break; case 1: // save the quiz information // get the unikey from the form $key = $_POST['unikey']; $type = $_GET['type']; $mode = $_GET['mode']; // save the data from step 1 $quiz_picture = $_POST['result_picture_0'] != "" ? $_POST['result_picture_0'] : "none.gif"; if (isset($_POST['id'])) { $quiz = new Quiz($_POST['id']); $quiz_id = $quiz->update($_POST['quiz_title'], $_POST['quiz_description'], $_POST['quiz_cat'], $quiz_picture, $member->id); } else { $quiz = new Quiz(); //function createQuiz($title, $description, $cat, $picture, $member_id, $key, $display_mode) from quiz.php $quiz_id = $quiz->create($_POST['quiz_title'], $_POST['quiz_description'], $_POST['quiz_cat'], $quiz_picture, $member->id, $key, $mode); } // direct them to step 2 //if($_POST['save'] == "Previous Step"){ //header("Location: ../webroot/createQuiz.php?step=0"); //}else{ header("Location: ../webroot/createQuiz.php?step=2&id=" . $quiz_id); //} break; case 2: // save the quiz results // get the id from the form $quiz_id = $_POST['id']; //***********************************************ADD BY LIEN************************************************// $queryMode = sprintf("SELECT display_mode FROM q_quizzes WHERE quiz_id = %d", $quiz->quiz_id); $resultMode = mysql_query($queryMode, $quizroo) or die(mysql_error());