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


PHP Quiz::save方法代码示例

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


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

示例1: store

 public function store()
 {
     $issues = Input::get('issues');
     $points = Input::get('points');
     if ($this->quizzed(Input::get('course_id'), Input::get('subject_id'), Input::get('quiz_date'))) {
         $quiz = Quiz::where('course_id', '=', Input::get('course_id'))->where('subject_id', '=', Input::get('subject_id'))->where('quiz_date', '=', Input::get('quiz_date'))->first();
     } else {
         $quiz = new Quiz();
         $quiz->project_id = Auth::user()->curr_project_id;
         $quiz->location_id = Auth::user()->location_id;
         $quiz->course_id = Input::get('course_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();
     }
     for ($i = 0; $i < count($issues); $i++) {
         if (!$this->existed('Quiz', $quiz->id, $issues[$i])) {
             $point = new Point();
             $point->project_id = Auth::user()->curr_project_id;
             $point->location_id = Auth::user()->location_id;
             $point->issue_id = $issues[$i];
             $point->pointable_type = 'Quiz';
             $point->pointable_id = $quiz->id;
             $point->point = $points[$i];
             $point->save();
         }
     }
 }
开发者ID:emanmks,项目名称:oneschool,代码行数:30,代码来源:QuizzesController.php

示例2: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Quiz();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Quiz'])) {
         $model->attributes = $_POST['Quiz'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:stan5621,项目名称:jp_edu_online,代码行数:17,代码来源:QuizController.php

示例3: createQuiz

 public function createQuiz()
 {
     $user_id = Auth::user()->id;
     $title = Input::get('title');
     $minutes = Input::get('minutes');
     $details = Input::get('details');
     $questions = Input::get('question');
     $answers = Input::get('answer');
     $choices = Input::get('choice');
     $quiz = new Quiz();
     $quiz->user_id = $user_id;
     $quiz->title = $title;
     $quiz->minutes = $minutes;
     $quiz->details = $details;
     $quiz->save();
     $quiz_id = $quiz->id;
     if (!empty($questions['new'])) {
         $new_questions = $questions['new'];
         $new_answers = $answers['new'];
         $new_choices = $choices['new'];
         foreach ($new_questions as $index => $question) {
             $quiz_item = new QuizItem();
             $quiz_item->quiz_id = $quiz_id;
             $quiz_item->question = $question;
             $quiz_item->save();
             $quiz_item_id = $quiz_item->id;
             if (!empty($new_answers[$index])) {
                 $item_answers = $new_answers[$index];
                 foreach ($item_answers as $answer) {
                     $quiz_item_answer = new QuizItemAnswer();
                     $quiz_item_answer->quiz_item_id = $quiz_item_id;
                     $quiz_item_answer->answer = $answer;
                     $quiz_item_answer->save();
                 }
             }
             if (!empty($new_choices[$index])) {
                 $item_choices = $new_choices[$index];
                 foreach ($item_choices as $choice) {
                     $quiz_item_choice = new QuizItemChoice();
                     $quiz_item_choice->quiz_item_id = $quiz_item_id;
                     $quiz_item_choice->choice = $choice;
                     $quiz_item_choice->save();
                 }
             }
         }
     }
     return Redirect::back()->with('message', array('type' => 'success', 'text' => 'Quiz Created!'));
 }
开发者ID:anchetaWern,项目名称:shotgun,代码行数:48,代码来源:AdminController.php

示例4: beforeSave

 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();
 }
开发者ID:stan5621,项目名称:eduwind,代码行数:57,代码来源:Lesson.php

示例5: isset

<?php

Ajax::requireLoggedIn();
$id = isset($_GET['id']) ? $_GET['id'] : null;
$color = isset($_GET['color']) ? $_GET['color'] : Quiz::DEFAULT_CUSTOMIZE_BGCOLOR;
$quiz = new Quiz($id);
$match = '/^[a-f0-9]{6}$/i';
if (!preg_match($match, $color)) {
    Ajax::outputError('Invalid color');
}
if (empty($quiz->id) || !$quiz->hasAccess()) {
    Ajax::outputError('You don\'t have access to this quiz');
}
$quiz->customize_bgcolor = $color;
$quiz->save();
开发者ID:robertpop,项目名称:NS,代码行数:15,代码来源:change-customize-bgcolor.php

示例6: beforeSave

 protected function beforeSave()
 {
     if ($this->mediaType !== $this->_oldMediaType || $this->mediaType === $this->_oldMediaType && $this->mediaId == $this->_oldMediaId) {
         if ($this->_oldMediaType == "video") {
             $this->file->delete();
         } else {
             if ($this->_oldMediaType == "link") {
                 $this->mediaLink->delete();
             }
         }
     }
     if ($this->mediaType == "quiz" && $this->mediaId == 0) {
         $quiz = new Quiz();
         $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();
 }
开发者ID:stan5621,项目名称:jp_edu_online,代码行数:47,代码来源:Lesson.php

示例7: storeQuiz

 public function storeQuiz()
 {
     $lab_id = Input::get('lab_id');
     $praktikum_id = Input::get('praktikum_id');
     $modul_id = Input::get('modul_id');
     $quiz = new Quiz();
     $quiz->quiz_nama = Input::get('quiz_nama');
     $quiz->quiz_keterangan = Input::get('quiz_keterangan');
     $quiz->quiz_intro = Input::get('quiz_intro');
     $quiz->modul_id = Input::get('modul_id');
     $quiz->quiz_durasi = Input::get('quiz_durasi');
     $quiz->save();
     return Redirect::to('lab/' . $lab_id . '/praktikum/' . $praktikum_id . '/modul/' . $modul_id . '/listsoal');
 }
开发者ID:rezpaditya,项目名称:indigolabs,代码行数:14,代码来源:AdminController.php

示例8: actionUpdateQuiz

 public function actionUpdateQuiz($id)
 {
     $lesson = $this->loadModel($id);
     if (!$lesson->quiz) {
         $quiz = new Quiz();
         $quiz->save();
         $lesson->deleteMedia();
         $lesson->mediaId = $quiz->getPrimaryKey();
         $lesson->save();
     }
     $this->redirect(array('quiz/view', 'id' => $quiz->id));
 }
开发者ID:stan5621,项目名称:eduwind,代码行数:12,代码来源:LessonController.php


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