本文整理汇总了PHP中scorm_grade_user_attempt函数的典型用法代码示例。如果您正苦于以下问题:PHP scorm_grade_user_attempt函数的具体用法?PHP scorm_grade_user_attempt怎么用?PHP scorm_grade_user_attempt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scorm_grade_user_attempt函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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_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;
}
}
示例2: scorm_get_attempt_status
/**
* Generate the user attempt status string
*
* @param object $user Current context user
* @param object $scorm a moodle scrom object - mdl_scorm
* @return string - Attempt status string
*/
function scorm_get_attempt_status($user, $scorm, $cm = '')
{
global $DB, $PAGE, $OUTPUT;
$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 .= get_string('unlimited') . '<br />';
}
$result .= get_string('noattemptsmade', 'scorm') . ': ' . $attemptcount . '<br />';
if ($scorm->maxattempt == 1) {
switch ($scorm->grademethod) {
case GRADEHIGHEST:
$grademethod = get_string('gradehighest', 'scorm');
break;
case GRADEAVERAGE:
$grademethod = get_string('gradeaverage', 'scorm');
break;
case GRADESUM:
$grademethod = get_string('gradesum', 'scorm');
break;
case GRADESCOES:
$grademethod = get_string('gradescoes', 'scorm');
break;
}
} else {
switch ($scorm->whatgrade) {
case HIGHESTATTEMPT:
$grademethod = get_string('highestattempt', 'scorm');
break;
case AVERAGEATTEMPT:
$grademethod = get_string('averageattempt', 'scorm');
break;
case FIRSTATTEMPT:
$grademethod = get_string('firstattempt', 'scorm');
break;
case LASTATTEMPT:
$grademethod = get_string('lastattempt', 'scorm');
break;
}
}
if (!empty($attempts)) {
$i = 1;
foreach ($attempts as $attempt) {
$gradereported = scorm_grade_user_attempt($scorm, $user->id, $attempt->attemptnumber);
if ($scorm->grademethod !== GRADESCOES && !empty($scorm->maxgrade)) {
$gradereported = $gradereported / $scorm->maxgrade;
$gradereported = number_format($gradereported * 100, 0) . '%';
}
$result .= get_string('gradeforattempt', 'scorm') . ' ' . $i . ': ' . $gradereported . '<br />';
$i++;
}
}
$calculatedgrade = scorm_grade_user($scorm, $user->id);
if ($scorm->grademethod !== GRADESCOES && !empty($scorm->maxgrade)) {
$calculatedgrade = $calculatedgrade / $scorm->maxgrade;
$calculatedgrade = number_format($calculatedgrade * 100, 0) . '%';
}
$result .= get_string('grademethod', 'scorm') . ': ' . $grademethod;
if (empty($attempts)) {
$result .= '<br />' . get_string('gradereported', 'scorm') . ': ' . get_string('none') . '<br />';
} else {
$result .= '<br />' . get_string('gradereported', 'scorm') . ': ' . $calculatedgrade . '<br />';
}
$result .= '</p>';
if ($attemptcount >= $scorm->maxattempt and $scorm->maxattempt > 0) {
$result .= '<p><font color="#cc0000">' . get_string('exceededmaxattempts', 'scorm') . '</font></p>';
}
if (!empty($cm)) {
$context = context_module::instance($cm->id);
if (has_capability('mod/scorm:deleteownresponses', $context) && $DB->record_exists('scorm_scoes_track', array('userid' => $user->id, 'scormid' => $scorm->id))) {
//check to see if any data is stored for this user:
$deleteurl = new moodle_url($PAGE->url, array('action' => 'delete', 'sesskey' => sesskey()));
$result .= $OUTPUT->single_button($deleteurl, get_string('deleteallattempts', 'scorm'));
}
}
return $result;
}
示例3: display
//.........这里部分代码省略.........
'firstname'=>$scouser->firstname,
'lastname'=>$scouser->lastname);
$row[] = $OUTPUT->user_picture($user, array('courseid'=>$course->id));
}
if (!$download) {
$row[] = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$scouser->userid.'&course='.$course->id.'">'.fullname($scouser).'</a>';
} else {
$row[] = fullname($scouser);
}
foreach ($extrafields as $field) {
$row[] = s($scouser->{$field});
}
if (empty($timetracks->start)) {
$row[] = '-';
$row[] = '-';
$row[] = '-';
$row[] = '-';
} else {
if (!$download) {
$row[] = '<a href="userreport.php?a='.$scorm->id.'&user='.$scouser->userid.'&attempt='.$scouser->attempt.'">'.$scouser->attempt.'</a>';
} else {
$row[] = $scouser->attempt;
}
if ($download =='ODS' || $download =='Excel' ) {
$row[] = userdate($timetracks->start, get_string("strftimedatetime", "langconfig"));
} else {
$row[] = userdate($timetracks->start);
}
if ($download =='ODS' || $download =='Excel' ) {
$row[] = userdate($timetracks->finish, get_string('strftimedatetime', 'langconfig'));
} else {
$row[] = userdate($timetracks->finish);
}
$row[] = scorm_grade_user_attempt($scorm, $scouser->userid, $scouser->attempt);
}
// print out all scores of attempt
foreach ($scoes as $sco) {
if ($sco->launch != '') {
if ($trackdata = scorm_get_tracks($sco->id, $scouser->userid, $scouser->attempt)) {
if ($trackdata->status == '') {
$trackdata->status = 'notattempted';
}
$strstatus = get_string($trackdata->status, 'scorm');
// if raw score exists, print it
if ($trackdata->score_raw != '') {
$score = $trackdata->score_raw;
// add max score if it exists
if ($scorm->version == 'SCORM_1.3') {
$maxkey = 'cmi.score.max';
} else {
$maxkey = 'cmi.core.score.max';
}
if (isset($trackdata->$maxkey)) {
$score .= '/'.$trackdata->$maxkey;
}
// else print out status
} else {
$score = $strstatus;
}
if (!$download) {
$row[] = '<img src="'.$OUTPUT->pix_url($trackdata->status, 'scorm').'" alt="'.$strstatus.'" title="'.$strstatus.'" /><br/>
<a href="userreport.php?b='.$sco->id.'&user='.$scouser->userid.'&attempt='.$scouser->attempt.
'" title="'.get_string('details', 'scorm').'">'.$score.'</a>';
} else {
$row[] = $score;
}
示例4: userdate
if (!$download) {
$row[] = '<a href="report.php?a=' . $scorm->id . '&user=' . $scouser->userid . '&attempt=' . $scouser->attempt . '">' . $scouser->attempt . '</a>';
} else {
$row[] = $scouser->attempt;
}
if ($download == 'ODS' || $download == 'Excel') {
$row[] = userdate($timetracks->start, get_string("strftimedatetime", "langconfig"));
} else {
$row[] = userdate($timetracks->start);
}
if ($download == 'ODS' || $download == 'Excel') {
$row[] = userdate($timetracks->finish, get_string('strftimedatetime', 'langconfig'));
} else {
$row[] = userdate($timetracks->finish);
}
$row[] = scorm_grade_user_attempt($scorm, $scouser->userid, $scouser->attempt);
}
// print out all scores of attempt
if ($scoes) {
foreach ($scoes as $sco) {
if ($sco->launch != '') {
if ($trackdata = scorm_get_tracks($sco->id, $scouser->userid, $scouser->attempt)) {
if ($trackdata->status == '') {
$trackdata->status = 'notattempted';
}
$strstatus = get_string($trackdata->status, 'scorm');
// if raw score exists, print it
if ($trackdata->score_raw != '') {
$score = $trackdata->score_raw;
// add max score if it exists
if ($scorm->version == 'SCORM_1.3') {
示例5: scorm_get_attempt_status
/**
* Generate the user attempt status string
*
* @param object $user Current context user
* @param object $scorm a moodle scrom object - mdl_scorm
* @return string - Attempt status string
*/
function scorm_get_attempt_status($user, $scorm)
{
global $DB;
$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 .= get_string('unlimited') . '<br />';
}
$result .= get_string('noattemptsmade', 'scorm') . ': ' . $attemptcount . '<br />';
if ($scorm->maxattempt == 1) {
switch ($scorm->grademethod) {
case GRADEHIGHEST:
$grademethod = get_string('gradehighest', 'scorm');
break;
case GRADEAVERAGE:
$grademethod = get_string('gradeaverage', 'scorm');
break;
case GRADESUM:
$grademethod = get_string('gradesum', 'scorm');
break;
case GRADESCOES:
$grademethod = get_string('gradescoes', 'scorm');
break;
}
} else {
switch ($scorm->whatgrade) {
case HIGHESTATTEMPT:
$grademethod = get_string('highestattempt', 'scorm');
break;
case AVERAGEATTEMPT:
$grademethod = get_string('averageattempt', 'scorm');
break;
case FIRSTATTEMPT:
$grademethod = get_string('firstattempt', 'scorm');
break;
case LASTATTEMPT:
$grademethod = get_string('lastattempt', 'scorm');
break;
}
}
if (!empty($attempts)) {
$i = 1;
foreach ($attempts as $attempt) {
$gradereported = scorm_grade_user_attempt($scorm, $user->id, $attempt->attemptnumber);
if ($scorm->grademethod !== GRADESCOES && !empty($scorm->maxgrade)) {
$gradereported = $gradereported / $scorm->maxgrade;
$gradereported = number_format($gradereported * 100, 0) . '%';
}
$result .= get_string('gradeforattempt', 'scorm') . ' ' . $i . ': ' . $gradereported . '<br />';
$i++;
}
}
$calculatedgrade = scorm_grade_user($scorm, $user->id);
if ($scorm->grademethod !== GRADESCOES && !empty($scorm->maxgrade)) {
$calculatedgrade = $calculatedgrade / $scorm->maxgrade;
$calculatedgrade = number_format($calculatedgrade * 100, 0) . '%';
}
$result .= get_string('grademethod', 'scorm') . ': ' . $grademethod;
if (empty($attempts)) {
$result .= '<br />' . get_string('gradereported', 'scorm') . ': ' . get_string('none') . '<br />';
} else {
$result .= '<br />' . get_string('gradereported', 'scorm') . ': ' . $calculatedgrade . '<br />';
}
$result .= '</p>';
if ($attemptcount >= $scorm->maxattempt and $scorm->maxattempt > 0) {
$result .= '<p><font color="#cc0000">' . get_string('exceededmaxattempts', 'scorm') . '</font></p>';
}
return $result;
}
示例6: display
//.........这里部分代码省略.........
$row[] = $OUTPUT->user_picture($user, array('courseid' => $course->id));
}
if (!$download) {
$url = new \moodle_url('/user/view.php', array('id' => $scouser->userid, 'course' => $course->id));
$row[] = \html_writer::link($url, fullname($scouser));
} else {
$row[] = fullname($scouser);
}
foreach ($extrafields as $field) {
$row[] = s($scouser->{$field});
}
if (empty($timetracks->start)) {
$row[] = '-';
$row[] = '-';
$row[] = '-';
$row[] = '-';
} else {
if (!$download) {
$url = new \moodle_url('/mod/scorm/report/userreport.php', array('id' => $cm->id, 'user' => $scouser->userid, 'attempt' => $scouser->attempt));
$row[] = \html_writer::link($url, $scouser->attempt);
} else {
$row[] = $scouser->attempt;
}
if ($download == 'ODS' || $download == 'Excel') {
$row[] = userdate($timetracks->start, get_string("strftimedatetime", "langconfig"));
} else {
$row[] = userdate($timetracks->start);
}
if ($download == 'ODS' || $download == 'Excel') {
$row[] = userdate($timetracks->finish, get_string('strftimedatetime', 'langconfig'));
} else {
$row[] = userdate($timetracks->finish);
}
$row[] = scorm_grade_user_attempt($scorm, $scouser->userid, $scouser->attempt);
}
// Print out all scores of attempt.
foreach ($scoes as $sco) {
if ($sco->launch != '') {
if ($trackdata = scorm_get_tracks($sco->id, $scouser->userid, $scouser->attempt)) {
if ($trackdata->status == '') {
$trackdata->status = 'notattempted';
}
$strstatus = get_string($trackdata->status, 'scorm');
if ($trackdata->score_raw != '') {
// If raw score exists, print it.
$score = $trackdata->score_raw;
// Add max score if it exists.
if (isset($trackdata->score_max)) {
$score .= '/' . $trackdata->score_max;
}
} else {
// ...else print out status.
$score = $strstatus;
}
if (!$download) {
$url = new \moodle_url('/mod/scorm/report/userreporttracks.php', array('id' => $cm->id, 'scoid' => $sco->id, 'user' => $scouser->userid, 'attempt' => $scouser->attempt));
$row[] = \html_writer::img($OUTPUT->pix_url($trackdata->status, 'scorm'), $strstatus, array('title' => $strstatus)) . \html_writer::empty_tag('br') . \html_writer::link($url, $score, array('title' => get_string('details', 'scorm')));
} else {
$row[] = $score;
}
// Iterate over tracks and match objective id against values.
$scorm2004 = false;
if (scorm_version_check($scorm->version, SCORM_13)) {
$scorm2004 = true;
$objectiveprefix = "cmi.objectives.";
} else {
示例7: 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;
}
}
示例8: scorm_get_attempt_status
/**
* Generate the user attempt status string
*
* @param object $user Current context user
* @param object $scorm a moodle scrom object - mdl_scorm
* @return string - Attempt status string
*/
function scorm_get_attempt_status($user, $scorm)
{
global $DB;
$attempts = $DB->get_records_select('scorm_scoes_track', "element='cmi.core.score.raw' AND userid=? AND scormid=?", array($user->id, $scorm->id), 'attempt', 'attempt AS attemptnumber, value AS grade');
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 .= get_string('unlimited') . '<BR>';
}
$result .= get_string('noattemptsmade', 'scorm') . ': ' . $attemptcount . '<BR>';
$gradereported = 0;
$gradesum = 0;
switch ($scorm->grademethod) {
case GRADEHIGHEST:
$grademethod = get_string('gradehighest', 'scorm');
break;
case GRADEAVERAGE:
$grademethod = get_string('gradeaverage', 'scorm');
break;
case GRADESUM:
$grademethod = get_string('gradesum', 'scorm');
break;
case GRADESCOES:
$grademethod = get_string('gradescoes', 'scorm');
break;
}
if (!empty($attempts)) {
foreach ($attempts as $attempt) {
$gradereported = scorm_grade_user_attempt($scorm, $user->id, $attempt->attemptnumber);
$result .= get_string('gradeforattempt', 'scorm') . ' ' . $attempt->attemptnumber . ': ' . $attempt->grade . '%<BR>';
}
}
$result .= get_string('grademethod', 'scorm') . ': ' . $grademethod;
if (empty($attempts)) {
$result .= '<BR>' . get_string('gradereported', 'scorm') . ': ' . get_string('none') . '<BR>';
} else {
$result .= '<BR>' . get_string('gradereported', 'scorm') . ': ' . $gradereported . ($scorm->grademethod == GRADESCOES ? '' : '%') . '<BR>';
}
$result .= '</p>';
if ($attemptcount >= $scorm->maxattempt and $scorm->maxattempt > 0) {
$result .= '<p><font color="#cc0000">' . get_string('exceededmaxattempts', 'scorm') . '</font></p>';
}
return $result;
}