本文整理汇总了PHP中Quiz::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Quiz::find方法的具体用法?PHP Quiz::find怎么用?PHP Quiz::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quiz
的用法示例。
在下文中一共展示了Quiz::find方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
}
示例2: update
public function update($id)
{
$quiz = Quiz::find($id);
$quiz->subject_id = Input::get('subject_id');
$quiz->employee_id = Input::get('employee_id');
$quiz->name = Input::get('name');
$quiz->quiz_date = Input::get('quiz_date');
$quiz->save();
Session::flash('message', 'Sukses mengupdate detail Quiz!');
}
示例3: editQuestion
public function editQuestion($id)
{
$ans = ['A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D'];
$quizItem = QuizItem::with('quizItemChoices', 'quizItemAnswer')->where('delFLag', 0)->whereId($id)->first();
$quiz = Quiz::find($quizItem->quizID);
return View::make('validated.quiz.edit', compact('quizItem', 'quiz', 'ans'));
}
示例4: listDetailSoalPraktikum
public function listDetailSoalPraktikum($lab_id, $praktikum_id, $modul_id, $quiz_id)
{
$labs = Lab::find($lab_id);
$praktikum = Praktikum::find($praktikum_id);
$moduls = Modul::find($modul_id);
$quizs = Quiz::find($quiz_id);
$soals = DB::table('tb_soal')->where('quiz_id', '=', $quiz_id)->get();
return View::make('dashboard.admin.Praktikum.soalDetail')->with('moduls', $moduls)->with('labs', $labs)->with('praktikum', $praktikum)->with('quizs', $quizs)->with('soals', $soals);
}
示例5: exportScores
public function exportScores($id)
{
//check if current user has created the quiz
$user_id = Auth::user()->id;
$quiz_schedule = QuizSchedule::find($id);
$quiz = Quiz::find($quiz_schedule->quiz_id);
$class = DB::table('classes')->where('id', '=', $quiz_schedule->class_id)->first();
if ($quiz_schedule->user_id != $user_id) {
return Redirect::to('/scores/' . $id)->with('message', array('type' => 'danger', 'text' => 'You do not have the permission to export scores for this quiz.'));
}
$filename = "{$class->name}-{$quiz->title}-{$quiz_schedule->datetime_from}";
Excel::create($filename, function ($excel) use($id, $quiz_schedule) {
$excel->sheet('score-sheet', function ($sheet) use($id, $quiz_schedule) {
$scores = DB::table('student_quizzes')->where('quiz_schedule_id', '=', $id)->lists('score', 'student_id');
$students = DB::table('students')->join('student_classes', 'students.id', '=', 'student_classes.student_id')->select('students.id', 'last_name', 'first_name', 'middle_initial')->where('student_classes.class_id', '=', $quiz_schedule->class_id)->orderBy('gender', 'DESC')->orderBy('last_name', 'ASC')->get();
$student_scores = array(array('ID Number', 'Student Name', 'Score'));
foreach ($students as $student) {
$score = '';
if (isset($scores[$student->id])) {
$score = $scores[$student->id];
}
$student_scores[] = array('id' => $student->id, 'name' => "{$student->last_name}, {$student->first_name} {$student->middle_initial}", 'score' => $score);
}
$sheet->fromArray($student_scores, null, 'A1', false, false);
});
})->export('xls');
}
示例6: edit
public function edit($resource_id, $id)
{
$resource = Resource::find($resource_id);
$quiz = Quiz::find($id);
return View::make('quizzes.edit', compact('resource', 'quiz'));
}