本文整理匯總了PHP中scorm_get_last_completed_attempt函數的典型用法代碼示例。如果您正苦於以下問題:PHP scorm_get_last_completed_attempt函數的具體用法?PHP scorm_get_last_completed_attempt怎麽用?PHP scorm_get_last_completed_attempt使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了scorm_get_last_completed_attempt函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: scorm_grade_user
function scorm_grade_user($scorm, $userid)
{
// ensure we dont grade user beyond $scorm->maxattempt settings
$lastattempt = scorm_get_last_attempt($scorm->id, $userid);
if ($scorm->maxattempt != 0 && $lastattempt >= $scorm->maxattempt) {
$lastattempt = $scorm->maxattempt;
}
switch ($scorm->whatgrade) {
case FIRSTATTEMPT:
return scorm_grade_user_attempt($scorm, $userid, 1);
break;
case LASTATTEMPT:
return scorm_grade_user_attempt($scorm, $userid, scorm_get_last_completed_attempt($scorm->id, $userid));
break;
case HIGHESTATTEMPT:
$maxscore = 0;
for ($attempt = 1; $attempt <= $lastattempt; $attempt++) {
$attemptscore = scorm_grade_user_attempt($scorm, $userid, $attempt);
$maxscore = $attemptscore > $maxscore ? $attemptscore : $maxscore;
}
return $maxscore;
break;
case AVERAGEATTEMPT:
$attemptcount = scorm_get_attempt_count($userid, $scorm, true, true);
if (empty($attemptcount)) {
return 0;
} else {
$attemptcount = count($attemptcount);
}
$lastattempt = scorm_get_last_attempt($scorm->id, $userid);
$sumscore = 0;
for ($attempt = 1; $attempt <= $lastattempt; $attempt++) {
$attemptscore = scorm_grade_user_attempt($scorm, $userid, $attempt);
$sumscore += $attemptscore;
}
return round($sumscore / $attemptcount);
break;
}
}
示例2: scorm_grade_user
function scorm_grade_user($scorm, $userid, $time = false)
{
// insure we dont grade user beyond $scorm->maxattempt settings
$lastattempt = scorm_get_last_attempt($scorm->id, $userid);
if ($scorm->maxattempt != 0 && $lastattempt >= $scorm->maxattempt) {
$lastattempt = $scorm->maxattempt;
}
switch ($scorm->whatgrade) {
case FIRSTATTEMPT:
return scorm_grade_user_attempt($scorm, $userid, 1, $time);
break;
case LASTATTEMPT:
return scorm_grade_user_attempt($scorm, $userid, scorm_get_last_completed_attempt($scorm->id, $userid), $time);
break;
case HIGHESTATTEMPT:
$maxscore = 0;
$attempttime = 0;
for ($attempt = 1; $attempt <= $lastattempt; $attempt++) {
$attemptscore = scorm_grade_user_attempt($scorm, $userid, $attempt, $time);
if ($time) {
if ($attemptscore->score > $maxscore) {
$maxscore = $attemptscore->score;
$attempttime = $attemptscore->time;
}
} else {
$maxscore = $attemptscore > $maxscore ? $attemptscore : $maxscore;
}
}
if ($time) {
$result = new stdClass();
$result->score = $maxscore;
$result->time = $attempttime;
return $result;
} else {
return $maxscore;
}
break;
case AVERAGEATTEMPT:
$lastattempt = scorm_get_last_attempt($scorm->id, $userid);
$sumscore = 0;
for ($attempt = 1; $attempt <= $lastattempt; $attempt++) {
$attemptscore = scorm_grade_user_attempt($scorm, $userid, $attempt, $time);
if ($time) {
$sumscore += $attemptscore->score;
} else {
$sumscore += $attemptscore;
}
}
if ($lastattempt > 0) {
$score = $sumscore / $lastattempt;
} else {
$score = 0;
}
if ($time) {
$result = new stdClass();
$result->score = $score;
$result->time = $attemptscore->time;
return $result;
} else {
return $score;
}
break;
}
}
示例3: test_scorm_get_last_completed_attempt
/**
* Test scorm_get_last_completed_attempt
*
* @return void
*/
public function test_scorm_get_last_completed_attempt()
{
$this->assertEquals(1, scorm_get_last_completed_attempt($this->scorm->id, $this->student->id));
}
示例4: scorm_grade_user
function scorm_grade_user($scorm, $userid, $time = false)
{
// this treatment is necessary as the whatgrade field was not in the DB
// and so whatgrade and grademethod are combined in grademethod 10s are whatgrade
// and 1s are grademethod
$whatgrade = intval($scorm->grademethod / 10);
// insure we dont grade user beyond $scorm->maxattempt settings
$lastattempt = scorm_get_last_attempt($scorm->id, $userid);
if ($scorm->maxattempt != 0 && $lastattempt >= $scorm->maxattempt) {
$lastattempt = $scorm->maxattempt;
}
switch ($whatgrade) {
case FIRSTATTEMPT:
return scorm_grade_user_attempt($scorm, $userid, 1, $time);
break;
case LASTATTEMPT:
return scorm_grade_user_attempt($scorm, $userid, scorm_get_last_completed_attempt($scorm->id, $userid), $time);
break;
case HIGHESTATTEMPT:
$maxscore = 0;
$attempttime = 0;
for ($attempt = 1; $attempt <= $lastattempt; $attempt++) {
$attemptscore = scorm_grade_user_attempt($scorm, $userid, $attempt, $time);
if ($time) {
if ($attemptscore->score > $maxscore) {
$maxscore = $attemptscore->score;
$attempttime = $attemptscore->time;
}
} else {
$maxscore = $attemptscore > $maxscore ? $attemptscore : $maxscore;
}
}
if ($time) {
$result = new stdClass();
$result->score = $maxscore;
$result->time = $attempttime;
return $result;
} else {
return $maxscore;
}
break;
case AVERAGEATTEMPT:
$lastattempt = scorm_get_last_attempt($scorm->id, $userid);
$sumscore = 0;
for ($attempt = 1; $attempt <= $lastattempt; $attempt++) {
$attemptscore = scorm_grade_user_attempt($scorm, $userid, $attempt, $time);
if ($time) {
$sumscore += $attemptscore->score;
} else {
$sumscore += $attemptscore;
}
}
if ($lastattempt > 0) {
$score = $sumscore / $lastattempt;
} else {
$score = 0;
}
if ($time) {
$result = new stdClass();
$result->score = $score;
$result->time = $attemptscore->time;
return $result;
} else {
return $score;
}
break;
}
}