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


PHP question_extract_responses函数代码示例

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


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

示例1: unset

 // Unset any variables we know are not responses
 unset($responses->id);
 unset($responses->q);
 unset($responses->oldpage);
 unset($responses->newpage);
 unset($responses->review);
 unset($responses->questionids);
 unset($responses->saveattempt);
 // responses get saved anway
 unset($responses->finishattempt);
 // same as $finishattempt
 unset($responses->markall);
 unset($responses->forcenewattempt);
 // extract responses
 // $actions is an array indexed by the questions ids
 $actions = question_extract_responses($questions, $responses, $event);
 // Process each question in turn
 $questionidarray = explode(',', $questionids);
 $success = true;
 foreach ($questionidarray as $i) {
     if (!isset($actions[$i])) {
         $actions[$i]->responses = array('' => '');
         $actions[$i]->event = QUESTION_EVENTOPEN;
     }
     $actions[$i]->timestamp = $timestamp;
     if (question_process_responses($questions[$i], $states[$i], $actions[$i], $quiz, $attempt)) {
         save_question_session($questions[$i], $states[$i]);
     } else {
         $success = false;
     }
 }
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:31,代码来源:attempt.php

示例2: game_sudoku_checkanswers

function game_sudoku_checkanswers()
{
    $responses = data_submitted();
    $actions = question_extract_responses($questions, $responses, $event);
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:5,代码来源:play.php

示例3: array

    // Create a new item in the history of question states (don't simplify!)
    $states[$historylength + 1] = array();
    $states[$historylength + 1][$id] = clone $states[$historylength][$id];
    $historylength++;
    $curstate =& $states[$historylength][$id];
    $curstate->changed = false;
    // Process the responses
    unset($form['id']);
    unset($form['quizid']);
    unset($form['continue']);
    unset($form['markall']);
    unset($form['finishattempt']);
    unset($form['back']);
    unset($form['startagain']);
    $event = $finishattempt ? QUESTION_EVENTCLOSE : QUESTION_EVENTSUBMIT;
    if ($actions = question_extract_responses($questions, $form, $event)) {
        $actions[$id]->timestamp = 0;
        // We do not care about timelimits here
        if (!question_process_responses($questions[$id], $curstate, $actions[$id], $quiz, $attempt)) {
            unset($SESSION->quizpreview);
            print_error('errorprocessingresponses', 'question', $url->out());
        }
        if (!$curstate->changed) {
            // Update the current state rather than creating a new one
            $historylength--;
            unset($states[$historylength]);
            $states = array_values($states);
            $curstate =& $states[$historylength][$id];
        }
    }
} else {
开发者ID:r007,项目名称:PMoodle,代码行数:31,代码来源:preview.php

示例4: game_hiddenpicture_check_questions

function game_hiddenpicture_check_questions($id, $game, &$attempt, &$hiddenpicture, $finishattempt)
{
    global $QTYPES, $DB;
    $responses = data_submitted();
    $offsetquestions = game_sudoku_compute_offsetquestions($game->sourcemodule, $attempt, $numbers, $correctquestions);
    $questionlist = game_sudoku_getquestionlist($offsetquestions);
    $questions = game_sudoku_getquestions($questionlist);
    $actions = question_extract_responses($questions, $responses, QUESTION_EVENTSUBMIT);
    $correct = $wrong = 0;
    foreach ($questions as $question) {
        if (!array_key_exists($question->id, $actions)) {
            //no answered
            continue;
        }
        unset($state);
        unset($cmoptions);
        $question->maxgrade = 100;
        $state->responses = $actions[$question->id]->responses;
        $state->event = QUESTION_EVENTGRADE;
        $cmoptions = array();
        $QTYPES[$question->qtype]->grade_responses($question, $state, $cmoptions);
        unset($query);
        $select = "attemptid={$attempt->id}";
        $select .= " AND questionid={$question->id}";
        if (($query->id = $DB->get_field_select('game_queries', 'id', $select)) == 0) {
            print_error("problem game_hiddenpicture_check_questions (select={$select})");
        }
        $answertext = $state->responses[''];
        if ($answertext != '') {
            $grade = $state->raw_grade;
            if ($grade < 50) {
                //wrong answer
                game_update_queries($game, $attempt, $query, $grade / 100, $answertext);
                $wrong++;
            } else {
                //correct answer
                game_update_queries($game, $attempt, $query, 1, $answertext);
                $correct++;
            }
        }
    }
    $hiddenpicture->correct += $correct;
    $hiddenpicture->wrong += $wrong;
    if (!$DB->update_record('game_hiddenpicture', $hiddenpicture)) {
        print_error('game_hiddenpicture_check_questions: error updating in game_hiddenpicture');
    }
    $attempt->score = game_hidden_picture_computescore($game, $hiddenpicture);
    if (!$DB->update_record('game_attempts', $attempt)) {
        print_error('game_hiddenpicture_check_questions: error updating in game_attempt');
    }
    game_sudoku_check_last($id, $game, $attempt, $hiddenpicture, $finishattempt);
    return true;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:53,代码来源:play.php

示例5: unset

    $event = QUESTION_EVENTCLOSE;
} else {
    $event = QUESTION_EVENTSAVE;
}
/// Unset any variables we know are not responses
unset($responses->id);
unset($responses->q);
unset($responses->oldpage);
unset($responses->newpage);
unset($responses->review);
unset($responses->questionids);
unset($responses->finishattempt);
// same as $finishattempt
unset($responses->forcenewattempt);
/// Extract the responses. $actions will be an array indexed by the questions ids.
$actions = question_extract_responses($attemptobj->get_questions($submittedquestionids), $responses, $event);
/// Process each question in turn
$success = true;
$attempt = $attemptobj->get_attempt();
foreach ($submittedquestionids as $id) {
    if (!isset($actions[$id])) {
        $actions[$id]->responses = array('' => '');
        $actions[$id]->event = QUESTION_EVENTOPEN;
    }
    $actions[$id]->timestamp = $timenow;
    /// If a particular question was submitted, update the nexturl to go back to that question.
    if ($actions[$id]->event == QUESTION_EVENTSUBMIT) {
        $nexturl = $attemptobj->attempt_url($id);
    }
    $state = $attemptobj->get_question_state($id);
    if (question_process_responses($attemptobj->get_question($id), $state, $actions[$id], $attemptobj->get_quiz(), $attempt)) {
开发者ID:vuchannguyen,项目名称:web,代码行数:31,代码来源:processattempt.php

示例6: game_snakes_check_questions

function game_snakes_check_questions($id, $game, $attempt, $snakes)
{
    global $QTYPES, $CFG, $DB;
    $responses = data_submitted();
    if ($responses->queryid != $snakes->queryid) {
        game_snakes_play($id, $game, $attempt, $snakes);
        return;
    }
    $questionlist = $DB->get_field('game_queries', 'questionid', array('id' => $responses->queryid));
    $questions = game_sudoku_getquestions($questionlist);
    $actions = question_extract_responses($questions, $responses, QUESTION_EVENTSUBMIT);
    $correct = false;
    $query = '';
    foreach ($questions as $question) {
        if (!array_key_exists($question->id, $actions)) {
            //no answered
            continue;
        }
        unset($state);
        unset($cmoptions);
        $question->maxgrade = 100;
        $state->responses = $actions[$question->id]->responses;
        $state->event = QUESTION_EVENTGRADE;
        $state->responses[''] = game_upper($state->responses['']);
        $cmoptions = array();
        $QTYPES[$question->qtype]->grade_responses($question, $state, $cmoptions);
        unset($query);
        $query->id = $snakes->queryid;
        $grade = $state->raw_grade;
        if ($grade < 50) {
            //wrong answer
            game_update_queries($game, $attempt, $query, 0, '');
            continue;
        }
        //correct answer
        $correct = true;
        game_update_queries($game, $attempt, $query, 1, '');
    }
    //set the grade of the whole game
    game_snakes_position($id, $game, $attempt, $snakes, $correct, $query);
}
开发者ID:nfreear,项目名称:moodle-mod_game,代码行数:41,代码来源:play.php

示例7: game_sudoku_check_questions

function game_sudoku_check_questions($id, $game, $attempt, $sudoku, $finishattempt)
{
    global $QTYPES, $CFG;
    $responses = data_submitted();
    $offsetquestions = game_sudoku_compute_offsetquestions($game->sourcemodule, $attempt, $numbers, $correctquestions);
    $questionlist = game_sudoku_getquestionlist($offsetquestions);
    $questions = game_sudoku_getquestions($questionlist);
    $actions = question_extract_responses($questions, $responses, QUESTION_EVENTSUBMIT);
    foreach ($questions as $question) {
        if (!array_key_exists($question->id, $actions)) {
            //no answered
            continue;
        }
        unset($state);
        unset($cmoptions);
        $question->maxgrade = 100;
        $state->responses = $actions[$question->id]->responses;
        $state->event = QUESTION_EVENTGRADE;
        $cmoptions = array();
        $QTYPES[$question->qtype]->grade_responses($question, $state, $cmoptions);
        unset($query);
        $select = "attemptid={$attempt->id} and score < 0.5";
        $select .= " AND questionid={$question->id}";
        if (($query->id = get_field_select('game_queries', 'id', $select)) == 0) {
            die("problem game_sudoku_check_questions (select={$select})");
            continue;
        }
        $answertext = $state->responses[''];
        $grade = $state->raw_grade;
        if ($grade < 50) {
            //wrong answer
            game_update_queries($game, $attempt, $query, $grade / 100, $answertext);
            continue;
        }
        //correct answer
        game_update_queries($game, $attempt, $query, 1, $answertext);
    }
    game_sudoku_check_last($id, $game, $attempt, $sudoku, $finishattempt);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:39,代码来源:play.php

示例8: game_bookquiz_check_questions

function game_bookquiz_check_questions($id, $game, $attempt, $bookquiz)
{
    global $QTYPES, $CFG, $USER;
    $responses = data_submitted();
    $questionlist = $responses->questionids;
    $questions = game_sudoku_getquestions($questionlist);
    $actions = question_extract_responses($questions, $responses, QUESTION_EVENTSUBMIT);
    $scorequestion = 0;
    $scoreattempt = 0;
    foreach ($questions as $question) {
        if (!array_key_exists($question->id, $actions)) {
            //no answered
            continue;
        }
        unset($state);
        unset($cmoptions);
        $question->maxgrade = 100;
        $state->responses = $actions[$question->id]->responses;
        $state->event = QUESTION_EVENTGRADE;
        $cmoptions = array();
        $QTYPES[$question->qtype]->grade_responses($question, $state, $cmoptions);
        if ($state->raw_grade < 50) {
            continue;
        }
        //found one correct answer
        $chapterid = $responses->chapterid;
        if (!get_field('game_bookquiz_chapters', 'id', 'attemptid', $attempt->id, 'chapterid', $chapterid)) {
            unset($newrec);
            $newrec->attemptid = $attempt->id;
            $newrec->chapterid = $chapterid;
            if (!insert_record('game_bookquiz_chapters', $newrec, false)) {
                print_object($newrec);
                error("Can't insert to table game_bookquiz_chapters");
            }
        }
        //Have to go to next page.
        $bookquiz->lastchapterid = $responses->nextchapterid;
        if (!set_field('game_bookquiz', 'lastchapterid', $bookquiz->lastchapterid, 'id', $bookquiz->id)) {
            error("Can't compute next chapter");
        }
        $scorequestion = 1;
        $scoreattempt = $_POST['scoreattempt'];
        break;
    }
    $query->id = 0;
    $query->attemptid = $attempt->id;
    $query->gameid = $game->id;
    $query->userid = $USER->id;
    $query->sourcemodule = 'question';
    $query->questionid = $question->id;
    $query->glossaryentryid = 0;
    $query->questiontext = $question->questiontext;
    $query->timelastattempt = time();
    game_update_queries($game, $attempt, $query, $scorequestion, '');
    game_updateattempts($game, $attempt, $scoreattempt, 0);
    game_bookquiz_continue($id, $game, $attempt, $bookquiz);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:57,代码来源:play.php

示例9: evaluate_quiz

function evaluate_quiz($acode, $jobid, $newattempt, $blended)
{
    global $USER;
    global $CFG;
    mtrace("Evaluation QUIZ Processing..." . "<BR><BR>");
    try {
        print "New Attempt is: " . $newattempt . "<BR/>";
        $detected_userid = find_userid($acode, $jobid);
        if ($detected_userid == null or $detected_userid == '') {
            throw new EvaluationError(get_string('ErrorUserIDEmpty', 'blended'), EvaluationError::USERID_IS_EMPTY);
        }
        $user_reg = blended_get_user($detected_userid, $blended);
        if ($user_reg == null) {
            throw new EvaluationError(get_string('ErrorUserNotInCourse', 'blended'), EvaluationError::USER_NOT_IN_THIS_COURSE);
        }
        $userid = $user_reg->id;
        mtrace('Obtained USERID value: ' . $userid . " OK. <BR/>");
        $quiz = get_quiz($acode);
        $attempts = quiz_get_user_attempts($quiz->id, $userid, 'all', true);
        mtrace("Searching quiz... Success." . "<BR/>");
        $uniqueid = get_uniqueid($acode);
        mtrace('Obtained uniqueid: OK. <BR/>');
        $timestamp = get_timestamp($acode);
        mtrace('Obtained timestamp: OK. <BR/>');
        if (!get_record('quiz_attempts', 'uniqueid', $uniqueid)) {
            $newattempt = true;
        } else {
            $newattempt = false;
            mtrace("User {$userid} had opened this attempt already.");
        }
        $attemptnumber = 1;
        if ($newattempt == false) {
            mtrace('Obtaining user attempt...<BR/>');
            set_attempt_unfinished($uniqueid);
            $attempt = quiz_get_user_attempt_unfinished($quiz->id, $userid);
        } elseif ($newattempt == true) {
            mtrace('Creating new attempt...<BR/>');
            $attempt = create_new_attempt($quiz, $attemptnumber, $userid, $acode, $uniqueid, $timestamp);
            // Save the attempt
            if (!insert_record('quiz_attempts', $attempt)) {
                throw new EvaluationError(get_string('ErrorCouldNotCreateAttempt', 'blended'), EvaluationError::CREATE_QUIZ_ATTEMPT_ERROR);
            }
            // Actualizamos el estado de las imágenes para indicar que ya está creado un nuevo attempt
            update_images_status($acode, $jobid);
        }
        update_question_attempts($uniqueid);
        // /*
        mtrace('<BR>Getting questions and question options... ');
        $questions = get_questions($attempt, $quiz);
        if (!get_question_options($questions)) {
            error('Could not load question options');
        }
        mtrace('Success! <BR>');
        //	print ("<BR>He obtenido questions: ");
        //print_object($questions);
        $lastattemptid = false;
        //	 if ($attempt->attempt > 1 and $quiz->attemptonlast and !$attempt->preview) {
        // Find the previous attempt
        //      if (!$lastattemptid = get_field('quiz_attempts', 'uniqueid', 'quiz', $attempt->quiz, 'userid', $attempt->userid, 'attempt', $attempt->attempt-1)) {
        //        error('Could not find previous attempt to build on');
        //  }
        //}
        //print ('He obtenido lastattemptid');
        mtrace('Getting question states... ');
        if (!($states = get_question_states($questions, $quiz, $attempt, $lastattemptid))) {
            error('Could not restore question sessions');
        }
        mtrace('Success! <BR>');
        mtrace('Getting responses... <BR>');
        $responses = get_responses($acode, $jobid, $attempt);
        //print('Estas son las responses:');
        //print_object($responses);
        //$timestamp=time();
        $event = 8;
        $actions = question_extract_responses($questions, $responses, $event);
        $questionids = get_questionids($acode);
        //	print $questionids;
        $questionidarray = explode(',', $questionids);
        $success = true;
        mtrace('<BR> Processing responses and saving session... ');
        foreach ($questionidarray as $i) {
            if (!isset($actions[$i])) {
                $actions[$i]->responses = array('' => '');
                $actions[$i]->event = QUESTION_EVENTOPEN;
            }
            $actions[$i]->timestamp = $timestamp;
            if (question_process_responses($questions[$i], $states[$i], $actions[$i], $quiz, $attempt)) {
                save_question_session($questions[$i], $states[$i]);
            } else {
                $success = false;
            }
        }
        mtrace('Success! <BR>');
        // Set the attempt to be finished
        $timestamp = time();
        //$attempt->timefinish = $timestamp;
        // Update the quiz attempt and the overall grade for the quiz
        mtrace('<BR> Finishing the attempt... ');
        // print_object ($attempt);
        if (set_field('quiz_attempts', 'timefinish', $timestamp, 'uniqueid', $uniqueid) == false) {
//.........这里部分代码省略.........
开发者ID:juacas,项目名称:moodle-mod_blended,代码行数:101,代码来源:evaluationlib.php


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