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


PHP Exercise::createExercise方法代码示例

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


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

示例1: saveExercises

 public function saveExercises()
 {
     $successful = true;
     $updateAmount = isset($_POST['exercise_id']) && !empty($_POST['exercise_id']) ? count($_POST['exercise_id']) : 0;
     $i = 0;
     // update exercises that were present in DB already
     while ($i < $updateAmount) {
         $id = $this->secureString($_POST['exercise_id'][$i]);
         $question = $this->secureString($_POST['question'][$i]);
         $answerEN = $this->secureString($_POST['answer_en'][$i]);
         $answerDE = $this->secureString($_POST['answer_de'][$i]);
         // do not update exercises with empty fields
         if (empty($id) || empty($question) || empty($answerEN) || empty($answerDE)) {
             $i++;
             continue;
         }
         if (!Exercise::update($id, $question, $answerEN, $answerDE)) {
             $successful = false;
         }
         $i++;
     }
     // add new exercises to DB
     while ($i < count($_POST['question'])) {
         $question = $this->secureString($_POST['question'][$i]);
         $answerEN = $this->secureString($_POST['answer_en'][$i]);
         $answerDE = $this->secureString($_POST['answer_de'][$i]);
         // do not add exercises with empty fields
         if (empty($question) || empty($answerEN) || empty($answerDE)) {
             $i++;
             continue;
         }
         if (!Exercise::createExercise($this->lesson->getId(), $question, $answerEN, $answerDE)) {
             $successful = false;
         }
         $i++;
     }
     if ($successful) {
         $this->getView()->addSuccessMessage('Exercises were successfully saved!');
     } else {
         $this->getView()->addErrorMessage('There was a problem saving one or more exercises..');
     }
     $this->defaultAction();
 }
开发者ID:stoeffu,项目名称:hiragana.ch,代码行数:43,代码来源:exerciseadmincontroller.class.php

示例2: lp_upload_quiz_action_handling


//.........这里部分代码省略.........
        }
    }
    // Get answers
    for ($i = 0; $i < count($question_name_index_init); $i++) {
        for ($j = $question_name_index_init[$i]; $j <= $question_name_index_end[$i]; $j++) {
            if (is_array($data->sheets[0]['cells'][$j])) {
                $column_data = $data->sheets[0]['cells'][$j];
                // Fill all column with data
                for ($x = 1; $x <= $data->sheets[0]['numCols']; $x++) {
                    if (empty($column_data[$x])) {
                        $data->sheets[0]['cells'][$j][$x] = '';
                    }
                }
                $column_data = $data->sheets[0]['cells'][$j];
                // Array filled of data
                if (is_array($data->sheets[0]['cells'][$j]) && count($data->sheets[0]['cells'][$j]) > 0) {
                    $new_answer[$i][$j] = $data->sheets[0]['cells'][$j];
                }
            }
        }
    }
    // Quiz title.
    $quiz_title = $quiz[2];
    if ($quiz_title != '') {
        // Variables
        $type = 2;
        $random = $active = $results = $max_attempt = $expired_time = 0;
        // Make sure feedback is enabled (3 to disable), otherwise the fields
        // added to the XLS are not shown, which is confusing
        $feedback = 0;
        // Quiz object
        $exercise = new Exercise();
        //
        $quiz_id = $exercise->createExercise($quiz_title, $expired_time, $type, $random, $active, $results, $max_attempt, $feedback, $propagateNegative);
        if ($quiz_id) {
            // insert into the item_property table
            api_item_property_update($_course, TOOL_QUIZ, $quiz_id, 'QuizAdded', api_get_user_id());
            // Import questions.
            for ($i = 0; $i < $number_questions; $i++) {
                // Question name
                $question_title = $question[$i][2];
                $question_description_text = "<p></p>";
                if (isset($question_description[$i][2])) {
                    // Question description.
                    $question_description_text = "<p>" . $question_description[$i][2] . "</p>";
                }
                // Unique answers are the only question types available for now
                // through xls-format import
                $question_id = null;
                $detectQuestionType = detectQuestionType($new_answer[$i], $score_list);
                /** @var Question $answer */
                switch ($detectQuestionType) {
                    case FREE_ANSWER:
                        $answer = new FreeAnswer();
                        break;
                    case GLOBAL_MULTIPLE_ANSWER:
                        $answer = new GlobalMultipleAnswer();
                        break;
                    case MULTIPLE_ANSWER:
                        $answer = new MultipleAnswer();
                        break;
                    case UNIQUE_ANSWER:
                    default:
                        $answer = new UniqueAnswer();
                        break;
                }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:67,代码来源:upload_exercise.php

示例3: rtrim

     $exercise[$key2]['exerciseType'] = rtrim($exercise[$key2]['exerciseType'], "b");
 } else {
     $bonus = "0";
 }
 // create exercise
 $exerciseId = isset($exercise[$key2]['id']) ? $exercise[$key2]['id'] : null;
 if ($exerciseId === null) {
     $exerciseId = $newExerciseId;
     $newExerciseId--;
 }
 $exercise[$key2]['id'] = $exerciseId;
 $submittable = '1';
 if (isset($exercise[$key2]['submittable']) && $exercise[$key2]['submittable'] == '0') {
     $submittable = '0';
 }
 $subexerciseObj = Exercise::createExercise($exerciseId, $cid, $sheetId, $exercise[$key2]['maxPoints'], $exercise[$key2]['exerciseType'], $key1 + 1, $bonus, $key2 + 1, $submittable);
 // set FileTypes (only as an array with strings in it)
 $subexerciseObj->setFileTypes($exercise[$key2]['mime-type']);
 // add attachement if given
 if (isset($_FILES['exercises']['error'][$key1]['subexercises'][$key2]['attachment']) && $_FILES['exercises']['error'][$key1]['subexercises'][$key2]['attachment'] != 4) {
     $filePath = $_FILES['exercises']['tmp_name'][$key1]['subexercises'][$key2]['attachment'];
     $displayName = $_FILES['exercises']['name'][$key1]['subexercises'][$key2]['attachment'];
     $attachments = array();
     $attachementFile = File::createFile(NULL, $displayName, NULL, $timestamp, NULL, NULL, NULL);
     $attachementFile->setBody(Reference::createReference($filePath));
     $subexerciseObj->setAttachments(array($attachementFile));
 } elseif (isset($_POST['exercises'][$key1]['subexercises'][$key2]['attachment']['fileId'])) {
     $attachementFile = File::createFile(NULL, null, NULL, null, NULL, NULL, NULL);
     $attachementFile->setFileId(isset($_POST['exercises'][$key1]['subexercises'][$key2]['attachment']['fileId']) ? $_POST['exercises'][$key1]['subexercises'][$key2]['attachment']['fileId'] : null);
     $attachementFile->setAddress(isset($_POST['exercises'][$key1]['subexercises'][$key2]['attachment']['address']) ? $_POST['exercises'][$key1]['subexercises'][$key2]['attachment']['address'] : null);
     $attachementFile->setDisplayName(isset($_POST['exercises'][$key1]['subexercises'][$key2]['attachment']['displayName']) ? $_POST['exercises'][$key1]['subexercises'][$key2]['attachment']['displayName'] : null);
开发者ID:sawh,项目名称:ostepu-system,代码行数:31,代码来源:CreateSheet.php


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