gpt4 book ai didi

php - moodle 如何在数据库中保存用户测验响应?

转载 作者:可可西里 更新时间:2023-11-01 01:10:28 26 4
gpt4 key购买 nike

moodle1.9如何将用户尝试测验结果保存到数据库中,以及当用户尝试任何测验时更新哪些表?

请指导我。

如果可能,请更新我,哪些函数用于在moodle1.9数据库中插入用户测验尝试数据?

最佳答案

来自 attempt.php 文件(Moodle 1.9.7):

$attempt = quiz_create_attempt($quiz, $attemptnumber);

然后:

if (!$attempt->id = insert_record('quiz_attempts', $attempt)) {
error('Could not create new attempt');
}

来自locallib.php:

/**
* Creates an object to represent a new attempt at a quiz
*
* Creates an attempt object to represent an attempt at the quiz by the current
* user starting at the current time. The ->id field is not set. The object is
* NOT written to the database.
* @return object The newly created attempt object.
* @param object $quiz The quiz to create an attempt for.
* @param integer $attemptnumber The sequence number for the attempt.
*/
function quiz_create_attempt($quiz, $attemptnumber) {
global $USER, $CFG;

if (!$attemptnumber > 1 or !$quiz->attemptonlast or !$attempt = get_record('quiz_attempts', 'quiz', $quiz->id, 'userid', $USER->id, 'attempt', $attemptnumber-1)) {
// we are not building on last attempt so create a new attempt
$attempt->quiz = $quiz->id;
$attempt->userid = $USER->id;
$attempt->preview = 0;
if ($quiz->shufflequestions) {
$attempt->layout = quiz_repaginate($quiz->questions, $quiz->questionsperpage, true);
} else {
$attempt->layout = $quiz->questions;
}
}

$timenow = time();
$attempt->attempt = $attemptnumber;
$attempt->sumgrades = 0.0;
$attempt->timestart = $timenow;
$attempt->timefinish = 0;
$attempt->timemodified = $timenow;
$attempt->uniqueid = question_new_attempt_uniqueid();

return $attempt;
}

主要细节请引用源码。

关于php - moodle 如何在数据库中保存用户测验响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2452647/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com