public function matapelajaran() { $klslevel = isset($_GET['klslevel']) ? addslashes($_GET['klslevel']) : 1; //$kls = new Kelas(); //$kls->getByID($id); $mp = new Matapelajaran(); $mp_id = isset($_GET['mp_id']) ? addslashes($_GET['mp_id']) : die('MP ID empty'); $mp->getByID($mp_id); //get quizes $quiz = new Quiz(); $whereClause = "quiz_guru_id = guru_id AND quiz_mp_id = '{$mp_id}' AND quiz_tingkatan = '{$klslevel}' ORDER BY quiz_create_date DESC"; $arrTables = array("Guru"); $arrQuiz = $quiz->getWhereFromMultipleTable($whereClause, $arrTables); //pr($arrQuiz); //get topicmaps $tm = new Topicmap(); $whereClause = "tm_guru_id = guru_id AND tm_mp_id = '{$mp_id}' AND tm_kelas_tingkatan = '{$klslevel}' ORDER BY tm_updatedate DESC"; $arrTables = array("Guru"); $arrTM = $tm->getWhereFromMultipleTable($whereClause, $arrTables); //pr($arrTM); $return["mp"] = $mp; $return['kelas'] = $kls; $return['webClass'] = __CLASS__; $return['method'] = __FUNCTION__; $return['klslevel'] = $klslevel; $return['arrQuiz'] = $arrQuiz; $return['arrTM'] = $arrTM; Mold::both("elearning/mp_profile", $return); //pr($mp); }
function slide_presentation_quiz(Quiz $quiz, $name) { global $tr; $manageCourse = new CourseManager(); $c = $manageCourse->getById($quiz->getCourseId()); return "<div class='sp-presentation-content'>\r\n <div>\r\n <h4><strong>" . $tr->__("Author") . "</strong>: " . $name . "</h4>\r\n <h4><strong>" . $tr->__("Course") . "</strong>: " . $c->getName() . "</h4>\r\n <h4><strong>" . $tr->__("Duration") . "</strong>: " . $quiz->getDuration() . " min</h4>\r\n </div>\r\n <h2>" . $quiz->getName() . "</h2>\r\n\r\n </div>"; }
public function convert() { foreach (glob("Model/Json/*.json") as $filename) { $oldquiz = json_decode(file_get_contents($filename), true); $newquiz = new Quiz($oldquiz["name"], $oldquiz["description"]); foreach ($oldquiz["questions"] as $q) { $newquiz->addQuestion(new QuizQuestion($q["question"], $q["option"], $q["correct"])); } file_put_contents("Model/quizes/" . basename($filename) . ".bin", serialize($newquiz)); } }
public function index() { $totalQuizzesCount = Quiz::count(); $totalUsersCount = User::count(); $todayQuizzesCount = Quiz::whereRaw('DATE(created_at) = DATE(NOW())')->count(); $todayUsersCount = User::whereRaw('DATE(created_at) = DATE(NOW())')->count(); $overallActivities = QuizUserActivity::groupBy('type')->havingRaw("type in ('attempt', 'share')")->select('type', DB::raw('count(*) as count'))->get()->toArray(); $overallStats = array(); foreach ($overallActivities as $activity) { $overallStats[$activity['type']] = $activity['count']; } $overallStats['quizzes'] = $totalQuizzesCount; $overallStats['users'] = $totalUsersCount; $todayActivities = QuizUserActivity::whereRaw('DATE(created_at) = DATE(\'' . date('Y-m-d H:i:s') . '\')')->groupBy('type')->havingRaw("type in ('attempt', 'share')")->select('type', DB::raw('count(*) as count'))->get()->toArray(); $todayStats = array(); foreach ($todayActivities as $activity) { $todayStats[$activity['type']] = $activity['count']; } $todayStats['quizzes'] = $todayQuizzesCount; $todayStats['users'] = $todayUsersCount; //Filling stats vars that are not yet set self::fillNullStats($todayStats); self::fillNullStats($overallStats); View::share(array('overallStats' => $overallStats, 'todayStats' => $todayStats)); $last30DaysActivity = self::getLastNDaysActivity(30, 'attempt'); $last30DaysUserRegistrations = self::getLastNDaysUserRegistrations(30); View::share(array('last30DaysActivity' => json_encode($last30DaysActivity), 'last30DaysUserRegistrations' => json_encode($last30DaysUserRegistrations))); return View::make('admin/index'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store($quiz_id) { try { DB::beginTransaction(); $quiz = Quiz::find($quiz_id); foreach (Input::get('question') as $input_question) { $question_params = array("name" => $input_question['name']); $question_validator = Question::validate($question_params); if ($question_validator->fails()) { throw new Exception("Question can't be saved"); } $question = new Question($question_params); $question = $quiz->questions()->save($question); foreach ($input_question['options'] as $value) { $option_params = array("name" => $value['name'], "is_correct" => array_key_exists("is_correct", $value) ? true : false); $option_validator = Option::validate($option_params); if ($option_validator->fails()) { throw new Exception("Option can't be saved"); } $option = new Option($option_params); $option = $question->options()->save($option); } } DB::commit(); return Redirect::to("quizzes/" . $quiz->id . '/questions'); } catch (Exception $e) { DB::rollback(); //throw new Exception($e); return Redirect::to('quizzes/' . $quiz->id . '/questions/create'); } }
public function getNewestQuizzesInCategory($category) { $criteria = new CDbCriteria(); $criteria->condition = "category = '" . $category . "'"; $criteria->order = 'created_at DESC'; $data = Quiz::model()->findAll($criteria); return $data; }
public function takeQuiz() { //check if quiz can be taken by student, //based on the time and the ID number $page_title = 'Cannot Take Quiz'; $page_content = View::make('no_quiz'); $id_number = Session::get('id_number'); $quiz_code = Session::get('quiz_code'); $current_datetime = Carbon::now()->toDateTimeString(); $quiz_schedule = QuizSchedule::where('quiz_code', '=', $quiz_code)->whereRaw(DB::raw("'{$current_datetime}' BETWEEN datetime_from AND datetime_to"))->first(); if ($quiz_schedule) { $quiz_schedule_id = $quiz_schedule->id; $class_id = $quiz_schedule->class_id; $quiz_id = $quiz_schedule->quiz_id; $student = StudentClass::where('student_id', '=', $id_number)->where('class_id', '=', $class_id)->first(); if ($student) { //when a student takes a quiz, a row is created on the //student_quizzes table, add the started_at, quiz_id, and student_id //when another student comes along and inputs the same id number //and quiz code, they won't be allowed since the quiz is already taken $student_quiz_count = StudentQuiz::where('student_id', '=', $id_number)->where('quiz_id', '=', $quiz_id)->count(); if ($student_quiz_count === 0) { //can take //get quiz details and show it to the student $quiz = Quiz::where('id', '=', $quiz_id)->first(); Session::put('quiz_id', $quiz_id); Session::put('quiz_title', $quiz->title); $items = QuizItem::where('quiz_id', '=', $quiz_id)->orderByRaw("RAND()")->get(); $item_ids = DB::table('quiz_items')->where('quiz_id', '=', $quiz_id)->lists('id'); $quiz_items_answers = DB::table('quiz_items_answers')->whereIn('quiz_item_id', $item_ids)->get(); $quiz_items_choices = DB::table('quiz_items_choices')->whereIn('quiz_item_id', $item_ids)->get(); $quiz_items = array(); foreach ($items as $item) { $quiz_items[$item->id] = array('question' => $item->question); } foreach ($quiz_items_choices as $qic) { $quiz_items[$qic->quiz_item_id]['choices'][] = $qic->choice; } $seconds = $quiz->minutes * 60 + 1; $page_data = array('quiz' => $quiz, 'quiz_items' => $quiz_items, 'seconds' => $seconds); //create student quiz $student_quiz = new StudentQuiz(); $student_quiz->student_id = $id_number; $student_quiz->quiz_id = $quiz_id; $student_quiz->quiz_schedule_id = $quiz_schedule_id; $student_quiz->started_at = Carbon::now()->toDateTimeString(); $student_quiz->save(); $page_title = 'Take Quiz'; $page_content = View::make('quiz', $page_data); } } } $this->layout->title = $page_title; $this->layout->quiz = true; $this->layout->content = $page_content; }
public function actionDeleteRatingQuiz() { $request = Yii::app()->request; try { $id = StringHelper::filterString($request->getPost('id')); if (Quiz::model()->delelteRatingQuiz($id)) { ResponseHelper::JsonReturnSuccess(''); } else { ResponseHelper::JsonReturnError(''); } } catch (Exception $ex) { ResponseHelper::JsonReturnError($ex->getMessage()); } }
public function update($resource_id, $quiz_id) { $resource = Resource::find($resource_id); $validator = Quiz::validate(Input::all()); if ($validator->fails()) { return Redirect::to('resources/' . $resource->id . '/quizzes/' . $quiz_id . '/edit')->withErrors($validator)->withInput(Input::all()); } else { $quiz = $resource->quizzes()->find($quiz_id); $quiz->title = Input::get("title"); $quiz->description = Input::get('description'); $quiz->no_of_questions = Input::get('no_of_questions'); $quiz->save(); return Redirect::to('resources/' . $resource->id . '/quizzes')->with('success', 'you have succesfully updated the quiz'); } }
public function delete() { $quizId = Input::get('quizId', null); if (!$quizId) { return Response::error("Quiz not found"); } try { $quiz = Quiz::findOrFail($quizId ? $quizId : $quizData['id']); } catch (ModelNotFoundException $e) { return Response::error("Error finding quiz with id " . $quizId); } if ($quiz->delete()) { return Response::json(array('success' => true)); } else { return Response::error("Some error occured while deleting quiz : '" . $quizId->topic . "'"); } }
public function more() { $user = User::with('Course', 'Gender', 'userType')->where('StudentID', Auth::user()->StudentID)->first(); $adminGroupPages = GroupPage::where('StudentID', Auth::user()->StudentID)->where('delFlag', 0)->orderBy('created_at', 'DESC')->get(); $groupPages = GroupPageMember::with('groupPages')->where('StudentID', Auth::user()->StudentID)->where('delFlag', 0)->orderBy('created_at', 'DESC')->get(); if (Auth::user()->UserTypeID == 2) { $files = Files::where('delFlag', 0)->where('folderID', 0)->where('OwnerID', Auth::user()->StudentID)->get(); $fileFolders = FilesFolder::where('OwnerID', Auth::user()->StudentID)->where('delFlag', 0)->orderBy('created_at', 'DESC')->get(); $activities = GroupPageActivity::where('OwnerID', Auth::user()->StudentID)->where('delFlag', 0)->get(); $quizzes = Quiz::where('delFlag', 0)->orderBy('created_at', 'DESC')->get(); } else { $activities = GroupPageActivityGroup::with('groupPage', 'groupPageActivityFiles')->where('deadline', '>', date('Y-m-d H:i:s'))->whereExists(function ($q) { $q->select(DB::raw(0))->from('grouppagemember')->whereRaw('grouppagemember.grouppageID = grouppageactivitygroup.grouppageID')->where('StudentID', Auth::user()->StudentID)->whereRaw('grouppagemember.delFlag = 0'); })->orderBy('deadline', 'ASC')->get(); $quizzes = QuizGroupPage::with('groupPageMember', 'groupPage', 'quiz')->where('delFlag', 0)->whereNotExists(function ($q) { $q->select(DB::raw(0))->from('quiztaken', 'grouppagemember')->where('quiztaken.OwnerID', Auth::user()->StudentID)->whereRaw('quiztaken.quizID = quizgrouppage.quizID')->where('delFlag', 0); })->get(); } return View::make('validated.more', compact('user', 'adminGroupPages', 'groupPages', 'files', 'fileFolders', 'activities', 'quizzes')); }
protected function loadModel($id) { /** * TODO или сделать в один запрос? */ $criteria = new CDbCriteria(); $criteria->compare('t.active', Quiz::STATUS_ACTIVE); /** @var $quiz Quiz */ $quiz = Quiz::model()->findByPk($id, $criteria); if ($quiz === null) { throw new CHttpException(404, 'The requested page does not exist.'); } $criteria = new CDbCriteria(array('with' => 'answers', 'order' => 't.sequence ASC, answers.sequence ASC')); $criteria->compare('t.id_quiz', $id); $questions = QuizQuestion::model()->findAll($criteria); if (empty($questions)) { throw new CHttpException(404, 'The requested page does not exist.'); } $quiz->addRelatedRecord('questions', $questions, false); return $quiz; }
} ?> </div></td> </tr> </table> </div> <?php $result++; } while ($row_getQuery = mysql_fetch_assoc($getQuery)); } } elseif (isset($_GET['delete'])) { // delete the result require 'member.php'; require 'quiz.php'; // also pass in the member id for security check $quiz = new Quiz($_GET['id']); $member = new Member(); if (!$quiz->removeResult($_GET['result'], $member->id)) { echo "Delete not authorized"; } } else { $result = $_GET['resultNumber']; $unikey = $_GET['unikey']; $count = 1; ?> <div id="r<?php echo $result; ?> " class="resultWidget"> <table width="95%" border="0" align="center" cellpadding="5" cellspacing="0"> <tr>
/** * Build the Quiz-Questions * @param int $courseId Internal course ID */ public function build_quiz_questions($courseId = 0) { $table_qui = Database::get_course_table(TABLE_QUIZ_TEST); $table_rel = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION); $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION); $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER); // Building normal tests. $sql = "SELECT * FROM {$table_que}\n WHERE c_id = {$courseId} "; $result = Database::query($sql); while ($obj = Database::fetch_object($result)) { // find the question category // @todo : need to be adapted for multi category questions in 1.10 $question_category_id = TestCategory::getCategoryForQuestion($obj->id, $courseId); // build the backup resource question object $question = new QuizQuestion($obj->id, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture, $obj->level, $obj->extra, $question_category_id); $sql = 'SELECT * FROM ' . $table_ans . ' WHERE c_id = ' . $courseId . ' AND question_id = ' . $obj->id; $db_result2 = Database::query($sql); while ($obj2 = Database::fetch_object($db_result2)) { $question->add_answer($obj2->id, $obj2->answer, $obj2->correct, $obj2->comment, $obj2->ponderation, $obj2->position, $obj2->hotspot_coordinates, $obj2->hotspot_type); if ($obj->type == MULTIPLE_ANSWER_TRUE_FALSE) { $table_options = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION); $sql = 'SELECT * FROM ' . $table_options . ' WHERE c_id = ' . $courseId . ' AND question_id = ' . $obj->id; $db_result3 = Database::query($sql); while ($obj3 = Database::fetch_object($db_result3)) { $question_option = new QuizQuestionOption($obj3); $question->add_option($question_option); } } } $this->course->add_resource($question); } // Building a fictional test for collecting orphan questions. // When a course is emptied this option should be activated (true). $build_orphan_questions = !empty($_POST['recycle_option']); // 1st union gets the orphan questions from deleted exercises // 2nd union gets the orphan questions from question that were deleted in a exercise. $sql = " (\n SELECT question_id, q.* FROM {$table_que} q INNER JOIN {$table_rel} r\n ON (q.c_id = r.c_id AND q.id = r.question_id)\n INNER JOIN {$table_qui} ex\n ON (ex.id = r.exercice_id AND ex.c_id = r.c_id )\n WHERE ex.c_id = {$courseId} AND ex.active = '-1'\n )\n UNION\n (\n SELECT question_id, q.* FROM {$table_que} q left\n OUTER JOIN {$table_rel} r\n ON (q.c_id = r.c_id AND q.id = r.question_id)\n WHERE q.c_id = {$courseId} AND r.question_id is null\n )\n UNION\n (\n SELECT question_id, q.* FROM {$table_que} q\n INNER JOIN {$table_rel} r\n ON (q.c_id = r.c_id AND q.id = r.question_id)\n WHERE r.c_id = {$courseId} AND (r.exercice_id = '-1' OR r.exercice_id = '0')\n )\n "; $result = Database::query($sql); if (Database::num_rows($result) > 0) { $build_orphan_questions = true; $orphanQuestionIds = array(); while ($obj = Database::fetch_object($result)) { // Orphan questions if (!empty($obj->question_id)) { $obj->id = $obj->question_id; } // Avoid adding the same question twice if (!isset($this->course->resources[$obj->id])) { // find the question category // @todo : need to be adapted for multi category questions in 1.10 $question_category_id = TestCategory::getCategoryForQuestion($obj->id, $courseId); $question = new QuizQuestion($obj->id, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture, $obj->level, $obj->extra, $question_category_id); $sql = "SELECT * FROM {$table_ans}\n WHERE c_id = {$courseId} AND question_id = " . $obj->id; $db_result2 = Database::query($sql); if (Database::num_rows($db_result2)) { while ($obj2 = Database::fetch_object($db_result2)) { $question->add_answer($obj2->id, $obj2->answer, $obj2->correct, $obj2->comment, $obj2->ponderation, $obj2->position, $obj2->hotspot_coordinates, $obj2->hotspot_type); } $orphanQuestionIds[] = $obj->id; } $this->course->add_resource($question); } } } if ($build_orphan_questions) { $obj = array('id' => -1, 'title' => get_lang('OrphanQuestions', ''), 'type' => 2); $newQuiz = new Quiz((object) $obj); if (!empty($orphanQuestionIds)) { foreach ($orphanQuestionIds as $index => $orphanId) { $order = $index + 1; $newQuiz->add_question($orphanId, $order); } } $this->course->add_resource($newQuiz); } }
<?php require '../modules/quizrooDB.php'; require '../modules/uploadFunctions.php'; require "../modules/quiz.php"; if (isset($_GET['step'])) { // now check whether this quiz actually belongs to this user if (isset($_GET['id'])) { $quiz = new Quiz($_GET['id']); if ($quiz->exists() && $quiz->isOwner($member->id)) { $quiz_state = true; // unpublish the quiz $quiz->unpublish($member->id); $unikey = $quiz->quiz_key; } else { $quiz_state = false; unset($quiz); } } else { $quiz_state = false; unset($quiz); } if ($quiz_state) { // THE FIRST STEP (Returning): Quiz Information switch ($_GET['step']) { case 1: // populate the categories $query_listCat = "SELECT cat_id, cat_name FROM q_quiz_cat"; $listCat = mysql_query($query_listCat, $quizroo) or die(mysql_error()); $row_listCat = mysql_fetch_assoc($listCat); $totalRows_listCat = mysql_num_rows($listCat);
} if (!empty($_REQUEST['expire_Meridian'])) { $_REQUEST['expire_Hour'] = date('H', strtotime($_REQUEST['expire_Hour'] . ':00 ' . $_REQUEST['expire_Meridian'])); } $quiz_data["datePub"] = TikiLib::make_time($quiz_data["publish_Hour"], $quiz_data["publish_Minute"], 0, $quiz_data["publish_Month"], $quiz_data["publish_Day"], $quiz_data["publish_Year"]); $quiz_data["dateExp"] = TikiLib::make_time($quiz_data["expire_Hour"], $quiz_data["expire_Minute"], 0, $quiz_data["expire_Month"], $quiz_data["expire_Day"], $quiz_data["expire_Year"]); $fields = array('nQuestion', 'shuffleAnswers', 'shuffleQuestions', 'multiSession', 'additionalQuestions', 'limitDisplay', 'timeLimited', 'canRepeat', 'additionalQuestions', 'forum'); foreach ($fields as $field) { fetchYNOption($quiz_data, $quiz_data, $field); } return $quiz_data; } if (isset($_REQUEST["save"])) { check_ticket('edit-quiz-question'); $quiz_data = quiz_data_load(); $quizNew = new Quiz(); $quizNew->data_load($quiz_data); // if the id is 0, use just save the new data // otherwise we compare the data to what was there before. if ($quiz->id == 0 || $quizNew != $quiz) { $quizlib->quiz_store($quizNew); // tell user changes were stored (new quiz stored with id of x or quiz x modified), return to list of admin quizzes } die; echo "line: " . __LINE__ . "<br>"; echo "Sorry, this is only a prototype at present.<br>"; // Fixme, this doesn't work for a brand-new quiz because the quizId is zero! if ($cat_objid != 0) { $cat_href = "tiki-quiz.php?quizId=" . $cat_objid; $cat_name = $_REQUEST["name"]; $cat_desc = substr($_REQUEST["description"], 0, 200);
<?php $filterId = isset($_GET['filter']) ? intval($_GET['filter']) : null; $filter = new Filter($filterId); if (empty($filter->id)) { Ajax::outputError('Invalid report'); } $quiz = new Quiz($filter->quiz_id); if (!$quiz->hasAccess()) { Ajax::outputError('Invalid report'); } $filter->delete(); Ajax::output($filterId);
function parseTextField($input) { global $wqInputId; $wqInputId++; $title = $state = $size = $maxlength = $class = $style = $value = $disabled = $a_inputBeg = $a_inputEnd = $big = ''; # determine size and maxlength of the input. if (array_key_exists(3, $input)) { $size = $input[3]; if ($size < 3) { $size = 'size="1"'; } elseif ($size < 12) { $size = 'size="' . ($size - 2) . '"'; } else { $size = 'size="' . ($size - 1) . '"'; } $maxlength = 'maxlength="' . $input[3] . '"'; } # Syntax error if there is no input text. if (empty($input[1])) { $value = 'value="???"'; $state = 'error'; } else { if ($this->mBeingCorrected) { $value = trim($this->mRequest->getVal($wqInputId)); $a_inputBeg = '<a class="input" href="#nogo"><span class="correction">'; $state = 'NA'; $title = 'title="' . wfMsgHtml('quiz_colorNA') . '"'; } $class = 'class="numbers"'; foreach (preg_split('` *\\| *`', trim($input[1]), -1, PREG_SPLIT_NO_EMPTY) as $possibility) { if ($state == '' || $state == 'NA' || $state == 'wrong') { if (preg_match('`^(-?\\d+\\.?\\d*)(-(-?\\d+\\.?\\d*)| (\\d+\\.?\\d*)(%))?$`', str_replace(',', '.', $possibility), $matches)) { if (array_key_exists(5, $matches)) { $strlen = $size = $maxlength = ''; } elseif (array_key_exists(3, $matches)) { $strlen = strlen($matches[1]) > strlen($matches[3]) ? strlen($matches[1]) : strlen($matches[3]); } else { $strlen = strlen($matches[1]); } if ($this->mBeingCorrected && !empty($value)) { $value = str_replace(',', '.', $value); if (is_numeric($value) && (array_key_exists(5, $matches) && $value >= $matches[1] - $matches[1] * $matches[4] / 100 && $value <= $matches[1] + $matches[1] * $matches[4] / 100 || array_key_exists(3, $matches) && $value >= $matches[1] && $value <= $matches[3] || $value == $possibility)) { $state = 'right'; $title = 'title="' . wfMsgHtml('quiz_colorRight') . '"'; } else { $state = 'wrong'; $title = 'title="' . wfMsgHtml('quiz_colorWrong') . '"'; } } } else { $strlen = preg_match('` \\(i\\)$`', $possibility) ? mb_strlen($possibility) - 4 : mb_strlen($possibility); $class = 'class="words"'; if ($this->mBeingCorrected && !empty($value)) { if ($value == $possibility || preg_match('`^' . $value . ' \\(i\\)$`i', $possibility) || !$this->mCaseSensitive && preg_match('`^' . $value . '$`i', $possibility)) { $state = 'right'; $title = 'title="' . wfMsgHtml('quiz_colorRight') . '"'; } else { $state = 'wrong'; $title = 'title="' . wfMsgHtml('quiz_colorWrong') . '"'; } } } if (array_key_exists(3, $input) && $strlen > $input[3]) { # The textfield is too short for the answer $state = 'error'; $value = "<_{$possibility}_ >"; } } if ($this->mBeingCorrected) { $a_inputBeg .= "{$possibility}<br />"; } } $value = empty($value) ? '' : 'value="' . str_replace('"', '"', $value) . '"'; if ($this->mBeingCorrected) { $a_inputBeg .= '</span>'; $a_inputEnd = '</a>'; $big = '<em>▼</em>'; } } if ($state == 'error' || $this->mBeingCorrected) { global $wgContLang; $border = $wgContLang->isRTL() ? 'border-right' : 'border-left'; $style = "style=\"{$border}:3px solid " . Quiz::getColor($state) . '; "'; $this->setState(empty($value) ? 'new_NA' : $state); if ($state == 'error') { $size = ''; $maxlength = ''; $disabled = 'disabled="disabled"'; $title = 'title="' . wfMsgHtml('quiz_colorError') . '"'; } } return $output = "{$a_inputBeg}<span {$style}><input {$class} type=\"text\" name=\"{$wqInputId}\" {$title} {$size} {$maxlength} {$value} {$disabled} autocomplete=\"off\" />{$big}</span>{$a_inputEnd}"; }
<?php require '../modules/quizrooDB.php'; require '../modules/uploadFunctions.php'; require "../modules/quiz.php"; // now check whether this quiz actually belongs to this user if (isset($_GET['id'])) { $quiz = new Quiz($_GET['id']); if ($quiz->exists() && $quiz->isOwner($member->id)) { $quiz_state = true; // unpublish the quiz $quiz->unpublish($member->id); $unikey = $quiz->quiz_key; } else { $quiz_state = false; } } else { $quiz_state = false; } if ($quiz_state) { if (isset($_GET['step'])) { $step = $_GET['step']; } else { $step = 1; } switch ($step) { // THE FIRST STEP (Returning): Quiz Information default: case 1: // populate the categories $query_listCat = "SELECT cat_id, cat_name FROM q_quiz_cat";
public function __construct() { parent::__construct(15, 4, true, array_merge(array_fill(0, 5, 'facile'), array_fill(5, 5, 'moyen'), array_fill(10, 5, 'difficile'))); }
<?php include 'config.php'; include 'quiz.php'; $quiz = new Quiz(); $quiz->process($_GET[QUESTION_QUERY_PARAM], $_GET[ANSWER_QUERY_PARAM]);
require '../modules/quiz.php'; require '../modules/variables.php'; if (isset($_GET['id'])) { // check if id is empty if ($_GET['id'] == "") { // tell user it is invalid $url_id = 0; } else { // give the real id $url_id = $_GET['id']; } } else { // tell user id is missing $url_id = 0; } $quiz = new Quiz($url_id); $quiz_state = $quiz->exists(); if ($quiz_state) { ?> <title>Quizroo Quiz: <?php echo $quiz->quiz_name; ?> </title> <meta property="og:title" content="<?php echo $quiz->quiz_name; ?> " /> <meta property="og:type" content="article" /> <meta property="og:image" content="<?php echo $VAR_URL . "quiz_images/imgcrop.php?w=50&h=50&f=" . $quiz->quiz_picture; ?>
</tr> <tr> <td valign="top" class="desc" scope="row">Create a new option for this question</td> </tr> </table> </div> <?php $question++; } while ($row_getQuery = mysql_fetch_assoc($getQuery)); } } elseif (isset($_GET['delete'])) { // delete the question require 'member.php'; require 'quiz.php'; // also pass in the member id for security check $quiz = new Quiz($_GET['id']); $member = new Member(); if (!$quiz->removeQuestionTest($_GET['question'], $member->id)) { echo "Delete not authorized"; } } else { // get result number $question = $_GET['questionNumber']; $quiz = $_GET['id']; ?> <!--EDITED BY YL ON 24aug, removed the contributes to and weightage dropdown list and added correct answer checkbox--> <div id="q<?php echo $question; ?> " class="questionWidget"> <table width="100%" border="0" align="center" cellpadding="5" cellspacing="0">
include 'header.php'; echo "<h2>un processus est actif pour ce quiz. Vous ne pouvez pas le renommer actuellement.</h2>"; global $quiz; $quiz = $q; doMainMenu(); include 'footer.html'; exit; } $quiz = $q; $page_title = 'Renommer un quiz'; include 'header.php'; if (isset($_POST['action']) && $_POST['action'] == "rename") { $new_dir_name = str_replace($quiz->getName(), $_POST['new-name'], $quiz->getDir()); if (rename($quiz->getDir(), $new_dir_name)) { echo "Renommage réussi.<br>"; $quiz = Quiz::getQuizByName($_POST['new-name']); } else { echo "<br>Erreur: impossible de renommer le quiz.<br>"; } } else { ?> <form method="POST" action="rename_quiz.php?quiz-id=<?php echo $_GET['quiz-id']; ?> "> <input type="hidden" name="action" value="rename"> <table> <tr><td>Ancien nom : </td><td><?php echo $quiz->getName(); ?> </td></tr>
<?php Ajax::requireLoggedIn(); $quizHash = isset($_GET['quiz']) ? $_GET['quiz'] : null; $quiz = Quiz::getByHash($quizHash); if (empty($quiz->id) || !$quiz->hasAccess()) { Ajax::outputError('You don\'t have access to this quiz'); } $filter = new Filter(); $saveType = 'insert'; if (isset($_GET['filter_id']) && !empty($_GET['filter_id'])) { $filter->readId($_GET['filter_id']); if (empty($filter->id)) { Ajax::outputError('Invalid filter'); } if ($filter->quiz_id != $quiz->id) { Ajax::outputError('Invalid filter'); } $saveType = 'update'; } $data = new stdClass(); $data->question = isset($_GET['question']) ? $_GET['question'] : null; $data->answer = isset($_GET['answer']) ? $_GET['answer'] : null; if (!empty($_GET['name'])) { $filter->name = $_GET['name']; } $filter->setData($data); $filter->quiz_id = $quiz->id; $filter->save(); $out = new stdClass(); $out->name = $filter->name;
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Quiz $value A Quiz object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Quiz $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
if ($row_resultMode['display_mode'] == "multi_simple") { $mode = "simple"; } if ($row_resultMode['display_mode'] == "multi_accurate") { $mode = "accurate"; } if ($row_resultMode['display_mode'] == "test_simple") { $mode = "test_simple"; } if ($row_resultMode['display_mode'] == "test_custom") { $mode = "test_custom"; } } while ($row_resultMode = mysql_fetch_assoc($resultMode)); //***********************************************END OF ADD BY LIEN************************************************// // save the questions from step 3 $quiz = new Quiz($quiz_id); if ($mode == "simple" || $mode == "accurate") { require "../modules/variables.php"; $numResults = $quiz->getResultsMulti("count"); //function in quiz.php // Insert the questions and options $questionArray = explode("_", $_POST['optionCounts']); //array explode ( string $delimiter , string $string [, int $limit ] ) //explode a string by the delimitor to array $question = array(); for ($i = 0; $i < $_POST['questionCount']; $i++) { if (isset($_POST['question_' . $i])) { if (isset($_POST['uq' . $i])) { // uq:updateQuestion $question_id = $quiz->updateQuestion($_POST['question_' . $i], $_POST['uq' . $i], $member->id); } else {
if ($_GET['isPro' . $i] == '1') { $rattId = MinaQuiz::getRightAnswerById($frid); } else { $quizFraga = QuizFraga::loadById($frid); $rattId = $quizFraga->getRattSvarId(); } if ($rattId == $chid) { $nr_of_rights++; } else { $nr_of_wrongs++; } } //******************************************************// //Code for defining if the quiz was successfull or not //******************************************************// if ($save) { //Here the code for deciding if the quiz succeded $success = false; if ($nr_of_rights == 4) { $success = true; } if ($success) { $medlem_id = $USER->getId(); Quiz::saveQuiz($medlem_id, Kommun::convertFromUrlNamn($kommun_namn)); } } //******************************************************// $_SESSION["quiz_r"] = $nr_of_rights; $_SESSION["quiz_w"] = $nr_of_wrongs; header("Location: /pages/quiz_result.php?kommun={$kommun_namn}"); exit;
<?php require_once 'Quiz.class.php'; require_once 'quiz_common.php'; $quiz = Quiz::getQuizById($_GET['quiz-id']); $page_title = 'Accès aux fichiers de résultats'; include 'header.php'; ?> <p>Fichiers de résultats pour le quiz <?php if ($quiz) { echo $quiz->getName(); } else { echo 'inconnu'; } ?> :</p> <ul> <?php $no_file = true; $d = dir($quiz->getCorrectionDir()); while (false !== ($entry = $d->read())) { if (substr_compare($entry, ".csv", strlen($entry) - 4) == 0) { $no_file = false; echo "<li><a href=\"view_file.php?quiz-id=" . $_GET['quiz-id'] . "&attachment=true&filename=correction/", rawurlencode($entry), "\"><i class='icon-download'></i> " . $entry . "</a></li>"; } } if ($no_file) { echo "<li class='alert alert-error'>Aucun fichier CSV de résultat n'a été généré pour l'instant.</li>"; } ?>
protected function beforeSave() { //删除文件 // if(!$this->isNewRecord){ // if($this->mediaType!==$this->_oldMediaType // ||($this->mediaType===$this->_oldMediaType && $this->mediaId!==$this->_oldMediaId)){ // error_log(print_r($this,true)); // if($this->_oldMediaType=="video"){ // $this->file->delete(); // }else if($this->_oldMediaType=="link"){ // $this->mediaLink->delete(); // } // } // } //创建quiz if ($this->mediaType == "quiz" && $this->mediaId == 0) { $quiz = new Quiz(); $quiz->save(); $this->mediaId = $quiz->getPrimaryKey(); } if ($this->mediaType == "text" && $this->mediaId == 0) { $quiz = new Text(); $quiz->save(); $this->mediaId = $quiz->getPrimaryKey(); } //设置课时数 if (!$this->weight || !$this->number) { $criteria = new CDbCriteria(); $criteria->condition = "courseId=" . intval($this->courseId); $criteria->select = "max(weight) as maxWeight,max(number) as maxNumber"; $lesson = Lesson::model()->find($criteria); $chapter = Chapter::model()->find($criteria); } if (!$this->weight) { if (!$lesson && !chapter) { $this->weight = 1; } else { if (!$lesson) { $this->weight = $chapter->maxWeight + 1; } else { if (!$chapter) { $this->weight = $lesson->maxWeight + 1; } else { $this->weight = max(array($chapter->maxWeight, $lesson->maxWeight)) + 1; } } } } if (!$this->number) { if ($lesson) { $this->number = $lesson->maxNumber + 1; } else { $this->number = 1; } } return parent::beforeSave(); }