当前位置: 首页>>代码示例>>PHP>>正文


PHP Quiz类代码示例

本文整理汇总了PHP中Quiz的典型用法代码示例。如果您正苦于以下问题:PHP Quiz类的具体用法?PHP Quiz怎么用?PHP Quiz使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Quiz类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: matapelajaran

 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);
 }
开发者ID:CapsuleCorpIndonesia,项目名称:elang-combo,代码行数:30,代码来源:Elearningweb.php

示例2: slide_presentation_quiz

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>";
}
开发者ID:Cossumo,项目名称:studypress,代码行数:7,代码来源:player-quiz.controller.php

示例3: convert

 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));
     }
 }
开发者ID:KevinUd2014,项目名称:Php_newProject,代码行数:11,代码来源:QuizDAL.php

示例4: index

 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');
 }
开发者ID:thunderclap560,项目名称:quizkpop,代码行数:29,代码来源:AdminController.php

示例5: store

 /**
  * 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');
     }
 }
开发者ID:shankargiri,项目名称:Quantum-Vic-La-Trobe-L4,代码行数:36,代码来源:QuestionsController.php

示例6: getNewestQuizzesInCategory

 public function getNewestQuizzesInCategory($category)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = "category = '" . $category . "'";
     $criteria->order = 'created_at DESC';
     $data = Quiz::model()->findAll($criteria);
     return $data;
 }
开发者ID:huynt57,项目名称:quizder,代码行数:8,代码来源:Quiz.php

示例7: takeQuiz

 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;
 }
开发者ID:anchetaWern,项目名称:shotgun,代码行数:56,代码来源:HomeController.php

示例8: actionDeleteRatingQuiz

 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());
     }
 }
开发者ID:huynt57,项目名称:quizder,代码行数:14,代码来源:QuizController.php

示例9: update

 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');
     }
 }
开发者ID:shankargiri,项目名称:Quantum-Vic-La-Trobe-L4,代码行数:15,代码来源:QuizzesController.php

示例10: delete

 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 . "'");
     }
 }
开发者ID:thunderclap560,项目名称:quizkpop,代码行数:17,代码来源:AdminQuizesController.php

示例11: more

 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'));
 }
开发者ID:NoName1771,项目名称:QCPU-Social-Web-App,代码行数:20,代码来源:AppController.php

示例12: loadModel

 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;
 }
开发者ID:Cranky4,项目名称:npfs,代码行数:21,代码来源:DefaultController.php

示例13: while

            }
            ?>
</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>
开发者ID:Jessicasoon,项目名称:ProjectKentRidgeV2,代码行数:31,代码来源:createResultObject.php

示例14: build_quiz_questions

 /**
  * 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);
     }
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:82,代码来源:CourseBuilder.class.php

示例15: Quiz

<?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);
开发者ID:hienvuong,项目名称:Quizroo,代码行数:31,代码来源:createQuizMain.php


注:本文中的Quiz类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。