本文整理汇总了PHP中scorm_update_grades函数的典型用法代码示例。如果您正苦于以下问题:PHP scorm_update_grades函数的具体用法?PHP scorm_update_grades怎么用?PHP scorm_update_grades使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scorm_update_grades函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scorm_insert_track
function scorm_insert_track($userid, $scormid, $scoid, $attempt, $element, $value)
{
$id = null;
if ($track = get_record_select('scorm_scoes_track', "userid='{$userid}' AND scormid='{$scormid}' AND scoid='{$scoid}' AND attempt='{$attempt}' AND element='{$element}'")) {
$track->value = addslashes_js($value);
$track->timemodified = time();
$id = update_record('scorm_scoes_track', $track);
} else {
$track->userid = $userid;
$track->scormid = $scormid;
$track->scoid = $scoid;
$track->attempt = $attempt;
$track->element = $element;
$track->value = addslashes_js($value);
$track->timemodified = time();
$id = insert_record('scorm_scoes_track', $track);
}
if (strstr($element, '.score.raw') || ($element == 'cmi.core.lesson_status' || $element == 'cmi.completion_status') && ($track->value == 'completed' || $track->value == 'passed')) {
$scorm = get_record('scorm', 'id', $scormid);
$grademethod = $scorm->grademethod % 10;
include_once 'lib.php';
scorm_update_grades($scorm, $userid);
}
return $id;
}
示例2: scorm_delete_attempt
/**
* Delete Scorm tracks for selected users
*
* @param int $userid ID of User
* @param int $scormid ID of Scorm
* @param int $attemptid user attempt that need to be deleted
*
* return bool true suceeded
*/
function scorm_delete_attempt($userid, $scorm, $attemptid)
{
global $DB;
$DB->delete_records('scorm_scoes_track', array('userid' => $userid, 'scormid' => $scorm->id, 'attempt' => $attemptid));
include_once 'lib.php';
scorm_update_grades($scorm, $userid, true);
return true;
}
示例3: scorm_seq_set
function scorm_seq_set($what, $scoid, $userid, $attempt = 0, $value = 'true')
{
global $DB;
$sco = scorm_get_sco($scoid);
// Set passed activity to active or not.
if ($value == false) {
$DB->delete_records('scorm_scoes_track', array('scoid' => $scoid, 'userid' => $userid, 'attempt' => $attempt, 'element' => $what));
} else {
scorm_insert_track($userid, $sco->scorm, $sco->id, $attempt, $what, $value);
}
// Update grades in gradebook.
$scorm = $DB->get_record('scorm', array('id' => $sco->scorm));
scorm_update_grades($scorm, $userid, true);
}
示例4: scorm_update_grades
/**
* Update grades in central gradebook
*
* @param object $scorm null means all scormbases
* @param int $userid specific user only, 0 mean all
*/
function scorm_update_grades($scorm = null, $userid = 0, $nullifnone = true)
{
global $CFG;
if (!function_exists('grade_update')) {
//workaround for buggy PHP versions
require_once $CFG->libdir . '/gradelib.php';
}
if ($scorm != null) {
if ($grades = scorm_get_user_grades($scorm, $userid)) {
grade_update('mod/scorm', $scorm->course, 'mod', 'scorm', $scorm->id, 0, $grades);
} else {
if ($userid and $nullifnone) {
$grade = new object();
$grade->userid = $userid;
$grade->rawgrade = NULL;
grade_update('mod/scorm', $scorm->course, 'mod', 'scorm', $scorm->id, 0, $grade);
}
}
} else {
$sql = "SELECT s.*, cm.idnumber as cmidnumber\n FROM {$CFG->prefix}scorm s, {$CFG->prefix}course_modules cm, {$CFG->prefix}modules m\n WHERE m.name='scorm' AND m.id=cm.module AND cm.instance=s.id";
if ($rs = get_recordset_sql($sql)) {
if ($rs->RecordCount() > 0) {
while ($scorm = rs_fetch_next_record($rs)) {
scorm_grade_item_update($scorm);
scorm_update_grades($scorm, 0, false);
}
}
rs_close($rs);
}
}
}
示例5: scorm_add_time
$value = scorm_add_time($track->value, $SESSION->scorm_session_time);
$track->value = $value;
$track->timemodified = time();
update_record('scorm_scoes_track', $track);
$id = $track->id;
} else {
$track = new object();
$track->userid = $USER->id;
$track->scormid = $scorm->id;
$track->scoid = $sco->id;
$track->element = 'cmi.core.total_time';
$track->value = $SESSION->scorm_session_time;
$track->timemodified = time();
$id = insert_record('scorm_scoes_track', $track);
}
scorm_update_grades($scorm, $USER->id);
}
$SESSION->scorm_status = 'Terminated';
$SESSION->scorm_session_time = '';
echo "error=0\r\nerror_text=Successful\r\n";
} else {
if ($status == 'Terminated') {
echo "error=1\r\nerror_text=Terminated\r\n";
} else {
echo "error=1\r\nerror_text=Not Initialized\r\n";
}
}
break;
default:
echo "error=1\r\nerror_text=Invalid Command\r\n";
break;
示例6: scorm_update_instance
/**
* Given an object containing all the necessary data,
* (defined by the form in mod_form.php) this function
* will update an existing instance with new data.
*
* @global stdClass
* @global object
* @uses CONTEXT_MODULE
* @uses SCORM_TYPE_LOCAL
* @uses SCORM_TYPE_LOCALSYNC
* @uses SCORM_TYPE_EXTERNAL
* @param object $scorm Form data
* @param object $mform
* @return bool
*/
function scorm_update_instance($scorm, $mform=null) {
global $CFG, $DB;
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
if (empty($scorm->timeopen)) {
$scorm->timeopen = 0;
}
if (empty($scorm->timeclose)) {
$scorm->timeclose = 0;
}
$cmid = $scorm->coursemodule;
$cmidnumber = $scorm->cmidnumber;
$courseid = $scorm->course;
$scorm->id = $scorm->instance;
$context = context_module::instance($cmid);
if ($scorm->scormtype === SCORM_TYPE_LOCAL) {
if (!empty($scorm->packagefile)) {
$fs = get_file_storage();
$fs->delete_area_files($context->id, 'mod_scorm', 'package');
file_save_draft_area_files($scorm->packagefile, $context->id, 'mod_scorm', 'package',
0, array('subdirs' => 0, 'maxfiles' => 1));
// Get filename of zip that was uploaded.
$files = $fs->get_area_files($context->id, 'mod_scorm', 'package', 0, '', false);
$file = reset($files);
$filename = $file->get_filename();
if ($filename !== false) {
$scorm->reference = $filename;
}
}
} else if ($scorm->scormtype === SCORM_TYPE_LOCALSYNC) {
$scorm->reference = $scorm->packageurl;
} else if ($scorm->scormtype === SCORM_TYPE_EXTERNAL) {
$scorm->reference = $scorm->packageurl;
} else if ($scorm->scormtype === SCORM_TYPE_AICCURL) {
$scorm->reference = $scorm->packageurl;
$scorm->hidetoc = SCORM_TOC_DISABLED; // TOC is useless for direct AICCURL so disable it.
} else {
return false;
}
$scorm = scorm_option2text($scorm);
$scorm->width = (int)str_replace('%', '', $scorm->width);
$scorm->height = (int)str_replace('%', '', $scorm->height);
$scorm->timemodified = time();
if (!isset($scorm->whatgrade)) {
$scorm->whatgrade = 0;
}
$DB->update_record('scorm', $scorm);
$scorm = $DB->get_record('scorm', array('id' => $scorm->id));
// Extra fields required in grade related functions.
$scorm->course = $courseid;
$scorm->idnumber = $cmidnumber;
$scorm->cmid = $cmid;
scorm_parse($scorm, (bool)$scorm->updatefreq);
scorm_grade_item_update($scorm);
scorm_update_grades($scorm);
return true;
}
示例7: xmldb_scorm_upgrade
//.........这里部分代码省略.........
$table->addKeyInfo('scorm_rulecond_ruleconditionsid', XMLDB_KEY_FOREIGN, array('ruleconditionsid'), 'scorm_seq_ruleconds', array('id'));
/// Launch create table for scorm_seq_rulecond
$result = $result && create_table($table);
/// Define table scorm_seq_rolluprule to be created
$table = new XMLDBTable('scorm_seq_rolluprule');
/// Adding fields to table scorm_seq_rolluprule
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('scoid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('childactivityset', XMLDB_TYPE_CHAR, '15', null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('minimumcount', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('minimumpercent', XMLDB_TYPE_FLOAT, '11, 4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0.0000');
$table->addFieldInfo('conditioncombination', XMLDB_TYPE_CHAR, '3', null, XMLDB_NOTNULL, null, null, null, 'all');
$table->addFieldInfo('action', XMLDB_TYPE_CHAR, '15', null, XMLDB_NOTNULL, null, null, null, null);
/// Adding keys to table scorm_seq_rolluprule
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('scorm_rolluprule_uniq', XMLDB_KEY_UNIQUE, array('scoid', 'id'));
$table->addKeyInfo('scorm_rolluprule_scoid', XMLDB_KEY_FOREIGN, array('scoid'), 'scorm_scoes', array('id'));
/// Launch create table for scorm_seq_rolluprule
$result = $result && create_table($table);
/// Define table scorm_seq_rolluprulecond to be created
$table = new XMLDBTable('scorm_seq_rolluprulecond');
/// Adding fields to table scorm_seq_rolluprulecond
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('scoid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('rollupruleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('operator', XMLDB_TYPE_CHAR, '5', null, XMLDB_NOTNULL, null, null, null, 'noOp');
$table->addFieldInfo('cond', XMLDB_TYPE_CHAR, '25', null, XMLDB_NOTNULL, null, null, null, null);
/// Adding keys to table scorm_seq_rolluprulecond
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('scorm_rulluprulecond_uniq', XMLDB_KEY_UNIQUE, array('scoid', 'rollupruleid', 'id'));
$table->addKeyInfo('scorm_rolluprulecond_scoid', XMLDB_KEY_FOREIGN, array('scoid'), 'scorm_scoes', array('id'));
$table->addKeyInfo('scorm_rolluprulecond_rolluprule', XMLDB_KEY_FOREIGN, array('rollupruleid'), 'scorm_seq_rolluprule', array('id'));
/// Launch create table for scorm_seq_rolluprulecond
$result = $result && create_table($table);
}
//Adding new field to table scorm
if ($result && $oldversion < 2007011800) {
/// Define field format to be added to data_comments
$table = new XMLDBTable('scorm');
$field = new XMLDBField('md5_result');
$field->setAttributes(XMLDB_TYPE_CHAR, '32', null, null, null, null, null, null, null);
/// Launch add field format
$result = $result && add_field($table, $field);
$field = new XMLDBField('external');
$field->setAttributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', null);
$result = $result && add_field($table, $field);
}
if ($result && $oldversion < 2007012400) {
/// Rename field external on table scorm to updatefreq
$table = new XMLDBTable('scorm');
$field = new XMLDBField('external');
if (field_exists($table, $field)) {
$field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'maxattempt');
/// Launch rename field updatefreq
$result = $result && rename_field($table, $field, 'updatefreq');
} else {
$field = new XMLDBField('updatefreq');
$field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'maxattempt');
$result = $result && add_field($table, $field);
}
/// Rename field md5_result on table scorm to md5hash
$field = new XMLDBField('md5_result');
if (field_exists($table, $field)) {
$field->setAttributes(XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, null, null, 'updatefreq');
/// Launch rename field md5hash
$result = $result && rename_field($table, $field, 'md5hash');
} else {
$field = new XMLDBField('md5hash');
$field->setAttributes(XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, null, '', 'updatefreq');
$result = $result && add_field($table, $field);
}
}
if ($result && $oldversion < 2007031300) {
if ($scorms = get_records('scorm')) {
foreach ($scorms as $scorm) {
if ($scoes = get_records('scorm_scoes', 'scorm', $scorm->id)) {
foreach ($scoes as $sco) {
if ($tracks = get_records('scorm_scoes_track', 'scoid', $sco->id)) {
foreach ($tracks as $track) {
$element = preg_replace('/\\.N(\\d+)\\./', ".\$1.", $track->element);
if ($track->element != $element) {
$track->element = $element;
update_record('scorm_scoes_track', $track);
}
}
}
}
}
}
}
}
if ($result && $oldversion < 2007081001) {
require_once $CFG->dirroot . '/mod/scorm/lib.php';
// too much debug output
$db->debug = false;
scorm_update_grades();
$db->debug = true;
}
return $result;
}
示例8: scorm_add_time
$value = scorm_add_time($track->value, $scormsession->sessiontime);
$track->value = $value;
$track->timemodified = time();
$DB->update_record('scorm_scoes_track', $track);
} else {
$track = new stdClass();
$track->userid = $aiccuser->id;
$track->scormid = $scorm->id;
$track->scoid = $sco->id;
$track->element = 'cmi.core.total_time';
$track->value = $scormsession->sessiontime;
$track->attempt = $attempt;
$track->timemodified = time();
$id = $DB->insert_record('scorm_scoes_track', $track);
}
scorm_update_grades($scorm, $aiccuser->id);
}
$scormsession->scormstatus = 'Terminated';
$scormsession->session_time = '';
echo "error=0\r\nerror_text=Successful\r\n";
} else {
if ($status == 'Terminated') {
echo "error=1\r\nerror_text=Terminated\r\n";
} else {
echo "error=1\r\nerror_text=Not Initialized\r\n";
}
}
break;
default:
echo "error=1\r\nerror_text=Invalid Command\r\n";
break;
示例9: scorm_seq_set
function scorm_seq_set($what, $scoid, $userid, $attempt = 0, $value = 'true')
{
$sco = scorm_get_sco($scoid);
/// set passed activity to active or not
if ($value == false) {
delete_record('scorm_scoes_track', 'scoid', $scoid, 'userid', $userid, 'attempt', $attempt, 'element', $what);
} else {
scorm_insert_track($userid, $sco->scorm, $sco->id, 0, $what, $value);
}
// update grades in gradebook
$scorm = get_record('scorm', 'id', $sco->scorm);
scorm_update_grades($scorm, $userid, true);
}
示例10: moodle_url
//
$PAGE->set_title($pagetitle);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($scorm->name));
if (!empty($action) && confirm_sesskey() && has_capability('mod/scorm:deleteownresponses', $contextmodule)) {
if ($action == 'delete') {
$confirmurl = new moodle_url($PAGE->url, array('action' => 'deleteconfirm'));
echo $OUTPUT->confirm(get_string('deleteuserattemptcheck', 'scorm'), $confirmurl, $PAGE->url);
echo $OUTPUT->footer();
exit;
} else {
if ($action == 'deleteconfirm') {
//delete this users attempts.
$DB->delete_records('scorm_scoes_track', array('userid' => $USER->id, 'scormid' => $scorm->id));
scorm_update_grades($scorm, $USER->id, true);
echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess');
}
}
}
$currenttab = 'info';
require $CFG->dirroot . '/mod/scorm/tabs.php';
// Print the main part of the page
$attemptstatus = '';
if (empty($launch) && ($scorm->displayattemptstatus == SCORM_DISPLAY_ATTEMPTSTATUS_ALL || $scorm->displayattemptstatus == SCORM_DISPLAY_ATTEMPTSTATUS_ENTRY)) {
$attemptstatus = scorm_get_attempt_status($USER, $scorm, $cm);
}
echo $OUTPUT->box(format_module_intro('scorm', $scorm, $cm->id) . $attemptstatus, 'generalbox boxaligncenter boxwidthwide', 'intro');
$scormopen = true;
$timenow = time();
if (!empty($scorm->timeopen) && $scorm->timeopen > $timenow) {
示例11: scorm_delete_attempt
/**
* Delete Scorm tracks for selected users
*
* @param int $userid ID of User
* @param stdClass $scorm Scorm object
* @param int $attemptid user attempt that need to be deleted
*
* @return bool true suceeded
*/
function scorm_delete_attempt($userid, $scorm, $attemptid) {
global $DB;
$DB->delete_records('scorm_scoes_track', array('userid' => $userid, 'scormid' => $scorm->id, 'attempt' => $attemptid));
$cm = get_coursemodule_from_instance('scorm', $scorm->id);
// Trigger instances list viewed event.
$event = \mod_scorm\event\attempt_deleted::create(array(
'other' => array('attemptid' => $attemptid),
'context' => context_module::instance($cm->id),
'relateduserid' => $userid
));
$event->add_record_snapshot('course_modules', $cm);
$event->add_record_snapshot('scorm', $scorm);
$event->trigger();
include_once('lib.php');
scorm_update_grades($scorm, $userid, true);
return true;
}
示例12: scorm_upgrade_grades
/**
* Update all grades in gradebook.
*
* @global object
*/
function scorm_upgrade_grades()
{
global $DB;
$sql = "SELECT COUNT('x')\n FROM {scorm} s, {course_modules} cm, {modules} m\n WHERE m.name='scorm' AND m.id=cm.module AND cm.instance=s.id";
$count = $DB->count_records_sql($sql);
$sql = "SELECT s.*, cm.idnumber AS cmidnumber, s.course AS courseid\n FROM {scorm} s, {course_modules} cm, {modules} m\n WHERE m.name='scorm' AND m.id=cm.module AND cm.instance=s.id";
$rs = $DB->get_recordset_sql($sql);
if ($rs->valid()) {
$pbar = new progress_bar('scormupgradegrades', 500, true);
$i = 0;
foreach ($rs as $scorm) {
$i++;
upgrade_set_timeout(60 * 5);
// set up timeout, may also abort execution
scorm_update_grades($scorm, 0, false);
$pbar->update($i, $count, "Updating Scorm grades ({$i}/{$count}).");
}
}
$rs->close();
}
示例13: scorm_insert_track
function scorm_insert_track($userid, $scormid, $scoid, $attempt, $element, $value)
{
global $CFG;
$id = null;
if ($track = get_record_select('scorm_scoes_track', "userid='{$userid}' AND scormid='{$scormid}' AND scoid='{$scoid}' AND attempt='{$attempt}' AND element='{$element}'")) {
if ($element != 'x.start.time') {
//don't update x.start.time - keep the original value.
$track->value = addslashes_js($value);
$track->timemodified = time();
$id = update_record('scorm_scoes_track', $track);
}
} else {
$track->userid = $userid;
$track->scormid = $scormid;
$track->scoid = $scoid;
$track->attempt = $attempt;
$track->element = $element;
$track->value = addslashes_js($value);
$track->timemodified = time();
$id = insert_record('scorm_scoes_track', $track);
}
if (strstr($element, '.score.raw') || ($element == 'cmi.core.lesson_status' || $element == 'cmi.completion_status') && ($track->value == 'completed' || $track->value == 'passed')) {
$scorm = get_record('scorm', 'id', $scormid);
include_once $CFG->dirroot . '/mod/scorm/lib.php';
scorm_update_grades($scorm, $userid);
}
return $id;
}
示例14: scorm_insert_track
function scorm_insert_track($userid, $scormid, $scoid, $attempt, $element, $value, $forcecompleted = false)
{
global $DB;
$id = null;
if ($forcecompleted) {
//TODO - this could be broadened to encompass SCORM 2004 in future
if ($element == 'cmi.core.lesson_status' && $value == 'incomplete') {
if ($track = $DB->get_record_select('scorm_scoes_track', 'userid=? AND scormid=? AND scoid=? AND attempt=? AND element=\'cmi.core.score.raw\'', array($userid, $scormid, $scoid, $attempt))) {
$value = 'completed';
}
}
if ($element == 'cmi.core.score.raw') {
if ($tracktest = $DB->get_record_select('scorm_scoes_track', 'userid=? AND scormid=? AND scoid=? AND attempt=? AND element=\'cmi.core.lesson_status\'', array($userid, $scormid, $scoid, $attempt))) {
if ($tracktest->value == "incomplete") {
$tracktest->value = "completed";
$idtest = $DB->update_record('scorm_scoes_track', $tracktest);
}
}
}
}
if ($track = $DB->get_record('scorm_scoes_track', array('userid' => $userid, 'scormid' => $scormid, 'scoid' => $scoid, 'attempt' => $attempt, 'element' => $element))) {
$track->value = addslashes_js($value);
$track->timemodified = time();
$id = $DB->update_record('scorm_scoes_track', $track);
} else {
$track->userid = $userid;
$track->scormid = $scormid;
$track->scoid = $scoid;
$track->attempt = $attempt;
$track->element = $element;
$track->value = addslashes_js($value);
$track->timemodified = time();
$id = $DB->insert_record('scorm_scoes_track', $track);
}
if (strstr($element, '.score.raw') || ($element == 'cmi.core.lesson_status' || $element == 'cmi.completion_status') && ($track->value == 'completed' || $track->value == 'passed')) {
$scorm = $DB->get_record('scorm', array('id' => $scormid));
$grademethod = $scorm->grademethod % 10;
include_once 'lib.php';
scorm_update_grades($scorm, $userid);
}
return $id;
}