当前位置: 首页>>代码示例>>PHP>>正文


PHP scorm_grade_user函数代码示例

本文整理汇总了PHP中scorm_grade_user函数的典型用法代码示例。如果您正苦于以下问题:PHP scorm_grade_user函数的具体用法?PHP scorm_grade_user怎么用?PHP scorm_grade_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了scorm_grade_user函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: scorm_get_user_grades

/**
 * Return grade for given user or all users.
 *
 * @param int $scormid id of scorm
 * @param int $userid optional user id, 0 means all users
 * @return array array of grades, false if none
 */
function scorm_get_user_grades($scorm, $userid = 0)
{
    global $CFG;
    require_once 'locallib.php';
    $grades = array();
    if (empty($userid)) {
        if ($scousers = get_records_select('scorm_scoes_track', "scormid='{$scorm->id}' GROUP BY userid", "", "userid,null")) {
            foreach ($scousers as $scouser) {
                $grades[$scouser->userid] = new object();
                $grades[$scouser->userid]->id = $scouser->userid;
                $grades[$scouser->userid]->userid = $scouser->userid;
                $grades[$scouser->userid]->rawgrade = scorm_grade_user($scorm, $scouser->userid);
            }
        } else {
            return false;
        }
    } else {
        if (!get_records_select('scorm_scoes_track', "scormid='{$scorm->id}' AND userid='{$userid}' GROUP BY userid", "", "userid,null")) {
            return false;
            //no attempt yet
        }
        $grades[$userid] = new object();
        $grades[$userid]->id = $userid;
        $grades[$userid]->userid = $userid;
        $grades[$userid]->rawgrade = scorm_grade_user($scorm, $userid);
    }
    return $grades;
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:35,代码来源:lib.php

示例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;
}
开发者ID:helenagarcia90,项目名称:moodle,代码行数:91,代码来源:locallib.php

示例3: scorm_get_user_grades

/**
 * Return grade for given user or all users.
 *
 * @global stdClass
 * @global object
 * @param int $scormid id of scorm
 * @param int $userid optional user id, 0 means all users
 * @return array array of grades, false if none
 */
function scorm_get_user_grades($scorm, $userid=0) {
    global $CFG, $DB;
    require_once($CFG->dirroot.'/mod/scorm/locallib.php');

    $grades = array();
    if (empty($userid)) {
        $scousers = $DB->get_records_select('scorm_scoes_track', "scormid=? GROUP BY userid",
                                            array($scorm->id), "", "userid,null");
        if ($scousers) {
            foreach ($scousers as $scouser) {
                $grades[$scouser->userid] = new stdClass();
                $grades[$scouser->userid]->id         = $scouser->userid;
                $grades[$scouser->userid]->userid     = $scouser->userid;
                $grades[$scouser->userid]->rawgrade = scorm_grade_user($scorm, $scouser->userid);
            }
        } else {
            return false;
        }

    } else {
        $preattempt = $DB->get_records_select('scorm_scoes_track', "scormid=? AND userid=? GROUP BY userid",
                                                array($scorm->id, $userid), "", "userid,null");
        if (!$preattempt) {
            return false; // No attempt yet.
        }
        $grades[$userid] = new stdClass();
        $grades[$userid]->id         = $userid;
        $grades[$userid]->userid     = $userid;
        $grades[$userid]->rawgrade = scorm_grade_user($scorm, $userid);
    }

    return $grades;
}
开发者ID:ruddj,项目名称:moodle,代码行数:42,代码来源:lib.php

示例4: userdate

    } else {
        $tt = userdate($scorm->timemodified);
    }
    $report = '&nbsp;';
    $reportshow = '&nbsp;';
    if (has_capability('mod/scorm:viewreport', $context)) {
        $trackedusers = scorm_get_count_users($scorm->id, $scorm->groupingid);
        if ($trackedusers > 0) {
            $reportshow = html_writer::link('report.php?id=' . $scorm->coursemodule, get_string('viewallreports', 'scorm', $trackedusers));
        } else {
            $reportshow = get_string('noreports', 'scorm');
        }
    } else {
        if (has_capability('mod/scorm:viewscores', $context)) {
            require_once 'locallib.php';
            $report = scorm_grade_user($scorm, $USER->id);
            $reportshow = get_string('score', 'scorm') . ": " . $report;
        }
    }
    $options = (object) array('noclean' => true);
    if (!$scorm->visible) {
        // Show dimmed if the mod is hidden.
        $table->data[] = array($tt, html_writer::link('view.php?id=' . $scorm->coursemodule, format_string($scorm->name), array('class' => 'dimmed')), format_module_intro('scorm', $scorm, $scorm->coursemodule), $reportshow);
    } else {
        // Show normal if the mod is visible.
        $table->data[] = array($tt, html_writer::link('view.php?id=' . $scorm->coursemodule, format_string($scorm->name)), format_module_intro('scorm', $scorm, $scorm->coursemodule), $reportshow);
    }
}
echo html_writer::empty_tag('br');
echo html_writer::table($table);
echo $OUTPUT->footer();
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:index.php

示例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;
}
开发者ID:richheath,项目名称:moodle,代码行数:83,代码来源:locallib.php

示例6: scorm_grades

/**
* Given a scorm id return all the grades of that activity
*
* @param int $scormid Scorm instance id
* @return mixed
*/
function scorm_grades($scormid)
{
    global $CFG;
    if (!($scorm = get_record('scorm', 'id', $scormid))) {
        return NULL;
    }
    if ($scorm->grademethod % 10 == 0) {
        // GRADESCOES
        if (!($return->maxgrade = count_records_select('scorm_scoes', "scorm='{$scormid}' AND launch<>'" . sql_empty() . "'"))) {
            return NULL;
        }
    } else {
        $return->maxgrade = $scorm->maxgrade;
    }
    $return->grades = NULL;
    if ($scousers = get_records_select('scorm_scoes_track', "scormid='{$scormid}' GROUP BY userid", "", "userid,null")) {
        require_once 'locallib.php';
        foreach ($scousers as $scouser) {
            $return->grades[$scouser->userid] = scorm_grade_user($scorm, $scouser->userid);
        }
    }
    return $return;
}
开发者ID:veritech,项目名称:pare-project,代码行数:29,代码来源:lib.php

示例7: certificate_activity_completed

function certificate_activity_completed(&$activity, &$cm, $userid = 0)
{
    global $CFG, $USER;
    static $quizid, $questid, $assid, $lessid, $feedid, $survid, $scormid, $facetofaceid;
    if (!$userid) {
        $userid = $USER->id;
    }
    if (empty($quizid)) {
        $quizid = get_field('modules', 'id', 'name', 'quiz');
        $questid = get_field('modules', 'id', 'name', 'questionnaire');
        $assid = get_field('modules', 'id', 'name', 'assignment');
        $lessid = get_field('modules', 'id', 'name', 'lesson');
        $feedid = get_field('modules', 'id', 'name', 'feedback');
        $survid = get_field('modules', 'id', 'name', 'survey');
        $scormid = get_field('modules', 'id', 'name', 'scorm');
        $facetofaceid = get_field('modules', 'id', 'name', 'facetoface');
    }
    /// If the module is not visible, it can't be accessed by students (assignment module
    /// will give us errors), so return true if its not visible.
    if (!empty($cm)) {
        $context = get_context_instance(CONTEXT_MODULE, $cm->id);
        if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $context)) {
            return true;
        }
        if ($cm->module == $quizid) {
            require_once $CFG->dirroot . '/mod/quiz/locallib.php';
            $quiz = get_record('quiz', 'id', $cm->instance);
            $score = quiz_get_best_grade($quiz, $userid);
            $grade = (int) ((double) $score / (double) $quiz->grade * 100.0);
            return $grade >= (int) $activity->linkgrade;
        } else {
            if ($cm->module == $assid) {
                require_once $CFG->dirroot . '/mod/assignment/lib.php';
                $assignment = get_record('assignment', 'id', $cm->instance);
                require_once "{$CFG->dirroot}/mod/assignment/type/{$assignment->assignmenttype}/assignment.class.php";
                $assignmentclass = "assignment_{$assignment->assignmenttype}";
                $assignmentinstance = new $assignmentclass($cm->id, $assignment, $cm);
                if (!($submission = $assignmentinstance->get_submission($userid))) {
                    return false;
                } else {
                    if ($assignmentinstance->assignment->grade <= 0) {
                        return true;
                    } else {
                        $grade = (int) ((double) $submission->grade / (double) $assignmentinstance->assignment->grade * 100.0);
                        return $grade >= (int) $activity->linkgrade;
                    }
                }
            } else {
                if ($cm->module == $questid) {
                    return get_record('questionnaire_attempts', 'qid', $cm->instance, 'userid', $userid) !== false;
                } else {
                    if ($cm->module == $feedid) {
                        return get_record('feedback_completed', 'feedback', $cm->instance, 'userid', $userid) !== false;
                    } else {
                        if ($cm->module == $survid) {
                            return get_record('survey_answers', 'id', $cm->instance, 'userid', $userid) !== false;
                        } else {
                            if ($cm->module == $scormid) {
                                require_once $CFG->dirroot . '/mod/scorm/locallib.php';
                                $scorm = get_record('scorm', 'id', $cm->instance);
                                $score = scorm_grade_user($scorm, $userid);
                                if ($scorm->grademethod % 10 == 0) {
                                    // GRADESCOES
                                    if (!($scorm->maxgrade = count_records_select('scorm_scoes', "scorm='{$scorm->id}' AND launch<>'" . sql_empty() . "'"))) {
                                        return true;
                                    }
                                }
                                $return->maxgrade = $scorm->maxgrade;
                                $grade = (int) ((double) $score / (double) $scorm->maxgrade * 100.0);
                                return $grade >= (int) $activity->linkgrade;
                            } else {
                                if ($cm->module == $lessid) {
                                    require_once $CFG->dirroot . '/mod/lesson/locallib.php';
                                    if (!($lesson = get_record('lesson', 'id', $cm->instance))) {
                                        return true;
                                    } else {
                                        $ntries = count_records('lesson_grades', 'lessonid', $lesson->id, 'userid', $userid) - 1;
                                        $gradeinfo = lesson_grade($lesson, $ntries);
                                        return $gradeinfo->grade >= (int) $activity->linkgrade;
                                    }
                                } else {
                                    if ($cm->module == $facetofaceid) {
                                        require_once $CFG->libdir . '/gradelib.php';
                                        $grading_info = grade_get_grades($cm->course, 'mod', 'facetoface', $cm->instance, $userid);
                                        if (empty($grading_info)) {
                                            return false;
                                        }
                                        $grade = $grading_info->items[0]->grades[$userid]->grade;
                                        return $grade >= (int) $activity->linkgrade;
                                    } else {
                                        return true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    } else {
//.........这里部分代码省略.........
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:101,代码来源:lib.php


注:本文中的scorm_grade_user函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。