本文整理汇总了PHP中Quiz::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Quiz::where方法的具体用法?PHP Quiz::where怎么用?PHP Quiz::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quiz
的用法示例。
在下文中一共展示了Quiz::where方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: quizzed
public function quizzed($course_id, $subject_id, $quiz_date)
{
$countMe = Quiz::where('course_id', '=', $course_id)->where('subject_id', '=', $subject_id)->where('quiz_date', '=', $quiz_date)->count();
if ($countMe > 0) {
return true;
} else {
return false;
}
}
示例2: 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;
}
示例3: 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'));
}
示例4: viewQuiz
public function viewQuiz($id)
{
$quiz = Quiz::where('delFlag', 0)->find($id);
$quizItems = QuizItem::with('quizItemChoices', 'quizItemAnswer')->where('delFLag', 0)->where('quizID', $id)->orderBy('created_at', 'DESC')->get();
return View::make('validated.quiz.view', compact('quiz', 'quizItems'));
}
示例5: _getQuizes
public static function _getQuizes($options = array())
{
$orderBy = !empty($options['order_by']) ? $options['order_by'] : self::DEFAULT_ORDER_BY;
$orderByType = !empty($options['order_by_type']) ? $options['order_by_type'] : self::DEFAULT_ORDER_BY_TYPE;
$quizesQuery = Quiz::where('active', '=', true)->orderBy($orderBy, $orderByType);
$limit = isset($options['limit']) ? $options['limit'] : self::DEFAULT_QUIZZES_LIMIT;
if (!empty($options['exclude'])) {
$quizesQuery->whereNotIn('id', array($options['exclude']));
}
if (!empty($options['categoryId'])) {
$quizesQuery->where('category', $options['categoryId']);
}
$quizes = $quizesQuery->simplePaginate($limit);
foreach ($quizes as $key => $quiz) {
$quizes[$key] = $quiz;
}
self::touchUpQuizes($quizes);
return $quizes;
}
示例6: quizSchedule
public function quizSchedule($schedule_id)
{
$user_id = Auth::user()->id;
$quizzes = Quiz::where('user_id', '=', $user_id)->lists('title', 'id');
$classes = DB::table('classes')->where('user_id', '=', $user_id)->lists('name', 'id');
$schedule = DB::table('quiz_schedules')->join('quiz', 'quiz_schedules.quiz_id', '=', 'quiz.id')->join('classes', 'quiz_schedules.class_id', '=', 'classes.id')->select('quiz.title', 'classes.name', 'datetime_from', 'datetime_to', 'quiz_schedules.id')->where('quiz_schedules.user_id', '=', $user_id)->where('quiz_schedules.id', '=', $schedule_id)->first();
$page_data = array('quizzes' => $quizzes, 'classes' => $classes, 'schedule' => $schedule);
$this->layout->title = 'Update Quiz Schedule';
$this->layout->content = View::make('admin.update_quiz_schedule', $page_data);
}