After struggle with the moodle database and not finding function to get me the data I need, here is where I am right now:
I added the following function in scorm/locallib.php, but can't finish It (sorry for the pseudocode...)
function scorm_get_attempt_status_bool($user, $scorm, $cm='') {
global $DB, $PAGE, $OUTPUT;
//true if not failed
$attempts = scorm_get_attempt_count($user->id, $scorm, true);
if (empty($attempts)) {
$attemptcount = 0;
} else {
$attemptcount = count($attempts);
}
$result = '<p>'.get_string('noattemptsallowed', 'scorm').': ';
if ($scorm->maxattempt > 0) {
$result .= $scorm->maxattempt . '<br />';
} else {
$result = true;
}
//$result .= get_string('noattemptsmade', 'scorm').': ' . $attemptcount . '<br />';
/*
* while($scorm= next segment?? )
* {
* //see: scorm_get_user_grades
$user_score = scorm_grade_user($scorm, $userid);
* if($user_attempts == maxattempts && $user_score < $needed_score(from database?))
* return false
* }
* return true
* */
}
Does anybody has an advice how to finish it?
Thanks in advance.
S.