3
moodle1.9如何將用戶嘗試測驗結果保存在數據庫中,並在用戶嘗試進行測驗時更新哪些表?moodle如何在數據庫中保存用戶測驗回覆?
請指導我。
如果可能請更新我,哪些函數用於在moodle1.9數據庫中插入用戶測驗數據?
moodle1.9如何將用戶嘗試測驗結果保存在數據庫中,並在用戶嘗試進行測驗時更新哪些表?moodle如何在數據庫中保存用戶測驗回覆?
請指導我。
如果可能請更新我,哪些函數用於在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;
}
請參閱主要信息源代碼。
謝謝@Roberto – Vivek 2010-03-17 10:08:57
相關:Moodle開發者文檔 - http://docs.moodle.org/en/Development – Sampson 2010-03-16 12:55:10
@vkwave你的問題涉及到編程嗎? – Sampson 2010-03-16 15:32:56
@Jonathan Sampson:我認爲它確實如此。看起來他正在開發一些Moodle擴展。問題也應該標記爲php。 – 2010-03-16 15:43:05