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


PHP scorm_get_tracks函数代码示例

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


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

示例1: get_data

 /**
  * Get the data for the report.
  *
  * @param int $scoid The sco ID.
  * @param array $allowedlist The list of user IDs allowed to be displayed.
  * @return array of data indexed per bar.
  */
 protected function get_data($scoid, $allowedlist = [])
 {
     global $DB;
     $data = array_fill(0, self::BANDS, 0);
     if (empty($allowedlist)) {
         return $data;
     }
     list($usql, $params) = $DB->get_in_or_equal($allowedlist);
     $params[] = $scoid;
     // Construct the SQL.
     $sql = "SELECT DISTINCT " . $DB->sql_concat('st.userid', '\'#\'', 'COALESCE(st.attempt, 0)') . " AS uniqueid,\n                       st.userid AS userid,\n                       st.scormid AS scormid,\n                       st.attempt AS attempt,\n                       st.scoid AS scoid\n                  FROM {scorm_scoes_track} st\n                 WHERE st.userid {$usql} AND st.scoid = ?";
     $attempts = $DB->get_records_sql($sql, $params);
     $usergrades = [];
     foreach ($attempts as $attempt) {
         if ($trackdata = scorm_get_tracks($scoid, $attempt->userid, $attempt->attempt)) {
             if (isset($trackdata->score_raw)) {
                 $score = $trackdata->score_raw;
                 if (empty($trackdata->score_min)) {
                     $minmark = 0;
                 } else {
                     $minmark = $trackdata->score_min;
                 }
                 // TODO MDL-55004: Get this value from elsewhere?
                 if (empty($trackdata->score_max)) {
                     $maxmark = 100;
                 } else {
                     $maxmark = $trackdata->score_max;
                 }
                 $range = $maxmark - $minmark;
                 if (empty($range)) {
                     continue;
                 }
                 $percent = round($score * 100 / $range, 2);
                 if (empty($usergrades[$attempt->userid]) || !isset($usergrades[$attempt->userid]) || $percent > $usergrades[$attempt->userid] || $usergrades[$attempt->userid] === '*') {
                     $usergrades[$attempt->userid] = $percent;
                 }
                 unset($percent);
             } else {
                 // User has made an attempt but either SCO was not able to record the score or something else is broken in SCO.
                 if (!isset($usergrades[$attempt->userid])) {
                     $usergrades[$attempt->userid] = '*';
                 }
             }
         }
     }
     // Recording all users who attempted the SCO, but resulting data was invalid.
     foreach ($usergrades as $userpercent) {
         if ($userpercent === '*') {
             $data[0]++;
         } else {
             $gradeband = floor($userpercent / self::BANDWIDTH);
             if ($gradeband != self::BANDS - 1) {
                 $gradeband++;
             }
             $data[$gradeband]++;
         }
     }
     return $data;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:66,代码来源:report.php

示例2: scorm_simple_play

function scorm_simple_play($scorm, $user, $context)
{
    $result = false;
    if ($scorm->updatefreq == UPDATE_EVERYTIME) {
        if (strpos($scorm->version, 'AICC') !== false) {
            $scorm->pkgtype = 'AICC';
        } else {
            $scorm->pkgtype = 'SCORM';
        }
        scorm_parse($scorm);
    }
    if (has_capability('mod/scorm:viewreport', $context)) {
        //if this user can view reports, don't skipview so they can see links to reports.
        return $result;
    }
    $scoes = get_records_select('scorm_scoes', 'scorm=' . $scorm->id . ' AND launch<>\'' . sql_empty() . '\'', 'id', 'id');
    if ($scoes) {
        if ($scorm->skipview >= 1) {
            $sco = current($scoes);
            if (scorm_get_tracks($sco->id, $user->id) === false) {
                header('Location: player.php?a=' . $scorm->id . '&scoid=' . $sco->id);
                $result = true;
            } else {
                if ($scorm->skipview == 2) {
                    header('Location: player.php?a=' . $scorm->id . '&scoid=' . $sco->id);
                    $result = true;
                }
            }
        }
    }
    return $result;
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:32,代码来源:locallib.php

示例3: array

    $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
    $scorm = $DB->get_record('scorm', array('id'=>$cm->instance), '*', MUST_EXIST);
} else if (!empty($a)) {
    $scorm = $DB->get_record('scorm', array('id'=>$a), '*', MUST_EXIST);
    $course = $DB->get_record('course', array('id'=>$scorm->course), '*', MUST_EXIST);
    $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id, false, MUST_EXIST);
} else {
    print_error('missingparameter');
}

$PAGE->set_url('/mod/scorm/loaddatamodel.php', array('scoid'=>$scoid, 'id'=>$cm->id));

require_login($course, false, $cm);

$userdata = new stdClass();
if ($usertrack = scorm_get_tracks($scoid, $USER->id, $attempt)) {
    // According to SCORM 2004 spec(RTE V1, 4.2.8), only cmi.exit==suspend should allow previous datamodel elements on re-launch.
    if (!scorm_version_check($scorm->version, SCORM_13) ||
        (isset($usertrack->{'cmi.exit'}) && ($usertrack->{'cmi.exit'} == 'suspend'))) {
        foreach ($usertrack as $key => $value) {
            $userdata->$key = addslashes_js($value);
        }
    } else {
        $userdata->status = '';
        $userdata->score_raw = '';
    }
} else {
    $userdata->status = '';
    $userdata->score_raw = '';
}
$userdata->student_id = addslashes_js($USER->username);
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:31,代码来源:loaddatamodel.php

示例4: scorm_get_toc

function scorm_get_toc($user, $scorm, $liststyle, $currentorg = '', $scoid = '', $mode = 'normal', $attempt = '', $play = false)
{
    global $CFG, $DB, $PAGE, $OUTPUT;
    $strexpand = get_string('expcoll', 'scorm');
    $modestr = '';
    if ($mode == 'browse') {
        $modestr = '&amp;mode=' . $mode;
    }
    $result = new stdClass();
    $result->toc = "<ul id='s0' class='{$liststyle}'>\n";
    $tocmenus = array();
    $result->prerequisites = true;
    $incomplete = false;
    //
    // Get the current organization infos
    //
    if (!empty($currentorg)) {
        if (($organizationtitle = $DB->get_field('scorm_scoes', 'title', array('scorm' => $scorm->id, 'identifier' => $currentorg))) != '') {
            $result->toc .= "\t<li>{$organizationtitle}</li>\n";
            $tocmenus[] = $organizationtitle;
        }
    }
    //
    // If not specified retrieve the last attempt number
    //
    if (empty($attempt)) {
        $attempt = scorm_get_last_attempt($scorm->id, $user->id);
    }
    $result->attemptleft = $scorm->maxattempt - $attempt;
    if ($scoes = scorm_get_scoes($scorm->id, $currentorg)) {
        //
        // Retrieve user tracking data for each learning object
        //
        $usertracks = array();
        foreach ($scoes as $sco) {
            if (!empty($sco->launch)) {
                if ($usertrack = scorm_get_tracks($sco->id, $user->id, $attempt)) {
                    if ($usertrack->status == '') {
                        $usertrack->status = 'notattempted';
                    }
                    $usertracks[$sco->identifier] = $usertrack;
                }
            }
        }
        $level = 0;
        $sublist = 1;
        $previd = 0;
        $nextid = 0;
        $findnext = false;
        $parents[$level] = '/';
        foreach ($scoes as $pos => $sco) {
            $isvisible = false;
            $sco->title = $sco->title;
            if (!isset($sco->isvisible) || isset($sco->isvisible) && $sco->isvisible == 'true') {
                $isvisible = true;
            }
            if ($parents[$level] != $sco->parent) {
                if ($newlevel = array_search($sco->parent, $parents)) {
                    for ($i = 0; $i < $level - $newlevel; $i++) {
                        $result->toc .= "\t\t</ul></li>\n";
                    }
                    $level = $newlevel;
                } else {
                    $i = $level;
                    $closelist = '';
                    while ($i > 0 && $parents[$level] != $sco->parent) {
                        $closelist .= "\t\t</ul></li>\n";
                        $i--;
                    }
                    if ($i == 0 && $sco->parent != $currentorg) {
                        $style = '';
                        if (isset($_COOKIE['hide:SCORMitem' . $sco->id])) {
                            $style = ' style="display: none;"';
                        }
                        $result->toc .= "\t\t<li><ul id='s{$sublist}' class='{$liststyle}'{$style}>\n";
                        $level++;
                    } else {
                        $result->toc .= $closelist;
                        $level = $i;
                    }
                    $parents[$level] = $sco->parent;
                }
            }
            if (isset($scoes[$pos + 1])) {
                $nextsco = $scoes[$pos + 1];
            } else {
                $nextsco = false;
            }
            $nextisvisible = false;
            if (!isset($nextsco->isvisible) || isset($nextsco->isvisible) && $nextsco->isvisible == 'true') {
                $nextisvisible = true;
            }
            if ($nextisvisible && $nextsco !== false && $sco->parent != $nextsco->parent && ($level == 0 || $level > 0 && $nextsco->parent == $sco->identifier)) {
                $sublist++;
                $icon = 'minus';
                if (isset($_COOKIE['hide:SCORMitem' . $nextsco->id])) {
                    $icon = 'plus';
                }
                $result->toc .= "\t\t" . '<li><a href="javascript:expandCollide(\'img' . $sublist . '\',\'s' . $sublist . '\',' . $nextsco->id . ');">' . '<img id="img' . $sublist . '" src="' . $OUTPUT->mod_icon_url('pix/' . $icon, 'scorm') . '" alt="' . $strexpand . '" title="' . $strexpand . '"/></a>';
            } else {
//.........这里部分代码省略.........
开发者ID:ajv,项目名称:Offline-Caching,代码行数:101,代码来源:scorm_13lib.php

示例5: scorm_user_complete


//.........这里部分代码省略.........
                $scoes = array_values($scoes);
                $level = 0;
                $sublist = 1;
                $parents[$level] = '/';
                foreach ($scoes as $pos => $sco) {
                    if ($parents[$level] != $sco->parent) {
                        if ($level > 0 && $parents[$level - 1] == $sco->parent) {
                            $report .= html_writer::end_tag('ul').html_writer::end_tag('li');
                            $level--;
                        } else {
                            $i = $level;
                            $closelist = '';
                            while (($i > 0) && ($parents[$level] != $sco->parent)) {
                                $closelist .= html_writer::end_tag('ul').html_writer::end_tag('li');
                                $i--;
                            }
                            if (($i == 0) && ($sco->parent != $currentorg)) {
                                $report .= html_writer::start_tag('li');
                                $report .= html_writer::start_tag('ul', array('id' => $sublist, 'class' => $liststyle));
                                $level++;
                            } else {
                                $report .= $closelist;
                                $level = $i;
                            }
                            $parents[$level] = $sco->parent;
                        }
                    }
                    $report .= html_writer::start_tag('li');
                    if (isset($scoes[$pos + 1])) {
                        $nextsco = $scoes[$pos + 1];
                    } else {
                        $nextsco = false;
                    }
                    if (($nextsco !== false) && ($sco->parent != $nextsco->parent) &&
                            (($level == 0) || (($level > 0) && ($nextsco->parent == $sco->identifier)))) {
                        $sublist++;
                    } else {
                        $report .= $OUTPUT->spacer(array("height" => "12", "width" => "13"));
                    }

                    if ($sco->launch) {
                        $score = '';
                        $totaltime = '';
                        if ($usertrack = scorm_get_tracks($sco->id, $user->id)) {
                            if ($usertrack->status == '') {
                                $usertrack->status = 'notattempted';
                            }
                            $strstatus = get_string($usertrack->status, 'scorm');
                            $report .= html_writer::img($OUTPUT->pix_url($usertrack->status, 'scorm'),
                                                        $strstatus, array('title' => $strstatus));
                        } else {
                            if ($sco->scormtype == 'sco') {
                                $report .= html_writer::img($OUTPUT->pix_url('notattempted', 'scorm'),
                                                            get_string('notattempted', 'scorm'),
                                                            array('title' => get_string('notattempted', 'scorm')));
                            } else {
                                $report .= html_writer::img($OUTPUT->pix_url('asset', 'scorm'), get_string('asset', 'scorm'),
                                                            array('title' => get_string('asset', 'scorm')));
                            }
                        }
                        $report .= "&nbsp;$sco->title $score$totaltime".html_writer::end_tag('li');
                        if ($usertrack !== false) {
                            $sometoreport = true;
                            $report .= html_writer::start_tag('li').html_writer::start_tag('ul', array('class' => $liststyle));
                            foreach ($usertrack as $element => $value) {
                                if (substr($element, 0, 3) == 'cmi') {
                                    $report .= html_writer::tag('li', $element.' => '.s($value));
                                }
                            }
                            $report .= html_writer::end_tag('ul').html_writer::end_tag('li');
                        }
                    } else {
                        $report .= "&nbsp;$sco->title".html_writer::end_tag('li');
                    }
                }
                for ($i = 0; $i < $level; $i++) {
                    $report .= html_writer::end_tag('ul').html_writer::end_tag('li');
                }
            }
            $report .= html_writer::end_tag('ul').html_writer::empty_tag('br');
        }
        $report .= html_writer::end_div();
    }
    if ($sometoreport) {
        if ($firstmodify < $now) {
            $timeago = format_time($now - $firstmodify);
            echo get_string('firstaccess', 'scorm').': '.userdate($firstmodify).' ('.$timeago.")".html_writer::empty_tag('br');
        }
        if ($lastmodify > 0) {
            $timeago = format_time($now - $lastmodify);
            echo get_string('lastaccess', 'scorm').': '.userdate($lastmodify).' ('.$timeago.")".html_writer::empty_tag('br');
        }
        echo get_string('report', 'scorm').":".html_writer::empty_tag('br');
        echo $report;
    } else {
        print_string('noactivity', 'scorm');
    }

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

示例6: get_scorm_default

/**
 * Sets up $userdata array and default values for SCORM 1.3 .
 *
 * @param stdClass $userdata an empty stdClass variable that should be set up with user values
 * @param object $scorm package record
 * @param string $scoid SCO Id
 * @param string $attempt attempt number for the user
 * @param string $mode scorm display mode type
 * @return array The default values that should be used for SCORM 1.3 package
 */
function get_scorm_default(&$userdata, $scorm, $scoid, $attempt, $mode)
{
    global $DB, $USER;
    $userdata->student_id = $USER->username;
    $userdata->student_name = $USER->lastname . ', ' . $USER->firstname;
    if ($usertrack = scorm_get_tracks($scoid, $USER->id, $attempt)) {
        // According to SCORM 2004(RTE V1, 4.2.8), only cmi.exit==suspend should allow previous datamodel elements on re-launch.
        if (isset($usertrack->{'cmi.exit'}) && $usertrack->{'cmi.exit'} == 'suspend') {
            foreach ($usertrack as $key => $value) {
                $userdata->{$key} = $value;
            }
        } else {
            $userdata->status = '';
            $userdata->score_raw = '';
        }
    } else {
        $userdata->status = '';
        $userdata->score_raw = '';
    }
    if ($scodatas = scorm_get_sco($scoid, SCO_DATA)) {
        foreach ($scodatas as $key => $value) {
            $userdata->{$key} = $value;
        }
    } else {
        print_error('cannotfindsco', 'scorm');
    }
    if (!($sco = scorm_get_sco($scoid))) {
        print_error('cannotfindsco', 'scorm');
    }
    if (isset($userdata->status)) {
        if (!isset($userdata->{'cmi.exit'}) || $userdata->{'cmi.exit'} == 'time-out' || $userdata->{'cmi.exit'} == 'normal') {
            $userdata->entry = 'ab-initio';
        } else {
            if (isset($userdata->{'cmi.exit'}) && ($userdata->{'cmi.exit'} == 'suspend' || $userdata->{'cmi.exit'} == 'logout')) {
                $userdata->entry = 'resume';
            } else {
                $userdata->entry = '';
            }
        }
    }
    $userdata->mode = 'normal';
    if (!empty($mode)) {
        $userdata->mode = $mode;
    }
    if ($userdata->mode == 'normal') {
        $userdata->credit = 'credit';
    } else {
        $userdata->credit = 'no-credit';
    }
    $objectives = $DB->get_records('scorm_seq_objective', array('scoid' => $scoid));
    $index = 0;
    foreach ($objectives as $objective) {
        if (!empty($objective->minnormalizedmeasure)) {
            $userdata->{'cmi.scaled_passing_score'} = $objective->minnormalizedmeasure;
        }
        if (!empty($objective->objectiveid)) {
            $userdata->{'cmi.objectives.N' . $index . '.id'} = $objective->objectiveid;
            $index++;
        }
    }
    $def = array();
    $def['cmi.learner_id'] = $userdata->student_id;
    $def['cmi.learner_name'] = $userdata->student_name;
    $def['cmi.mode'] = $userdata->mode;
    $def['cmi.entry'] = $userdata->entry;
    $def['cmi.exit'] = scorm_isset($userdata, 'cmi.exit');
    $def['cmi.credit'] = scorm_isset($userdata, 'credit');
    $def['cmi.completion_status'] = scorm_isset($userdata, 'cmi.completion_status', 'unknown');
    $def['cmi.completion_threshold'] = scorm_isset($userdata, 'threshold');
    $def['cmi.learner_preference.audio_level'] = scorm_isset($userdata, 'cmi.learner_preference.audio_level', 1);
    $def['cmi.learner_preference.language'] = scorm_isset($userdata, 'cmi.learner_preference.language');
    $def['cmi.learner_preference.delivery_speed'] = scorm_isset($userdata, 'cmi.learner_preference.delivery_speed');
    $def['cmi.learner_preference.audio_captioning'] = scorm_isset($userdata, 'cmi.learner_preference.audio_captioning', 0);
    $def['cmi.location'] = scorm_isset($userdata, 'cmi.location');
    $def['cmi.max_time_allowed'] = scorm_isset($userdata, 'attemptAbsoluteDurationLimit');
    $def['cmi.progress_measure'] = scorm_isset($userdata, 'cmi.progress_measure');
    $def['cmi.scaled_passing_score'] = scorm_isset($userdata, 'cmi.scaled_passing_score');
    $def['cmi.score.scaled'] = scorm_isset($userdata, 'cmi.score.scaled');
    $def['cmi.score.raw'] = scorm_isset($userdata, 'cmi.score.raw');
    $def['cmi.score.min'] = scorm_isset($userdata, 'cmi.score.min');
    $def['cmi.score.max'] = scorm_isset($userdata, 'cmi.score.max');
    $def['cmi.success_status'] = scorm_isset($userdata, 'cmi.success_status', 'unknown');
    $def['cmi.suspend_data'] = scorm_isset($userdata, 'cmi.suspend_data');
    $def['cmi.time_limit_action'] = scorm_isset($userdata, 'timelimitaction');
    $def['cmi.total_time'] = scorm_isset($userdata, 'cmi.total_time', 'PT0H0M0S');
    return $def;
}
开发者ID:alanaipe2015,项目名称:moodle,代码行数:97,代码来源:scorm_13lib.php

示例7: userdate

         $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') {
                         $maxkey = 'cmi.score.max';
                     } else {
                         $maxkey = 'cmi.core.score.max';
                     }
                     if (isset($trackdata->{$maxkey})) {
                         $score .= '/' . $trackdata->{$maxkey};
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:31,代码来源:report.php

示例8: get_scorm_default

/**
 * Sets up $userdata array and default values for AICC package.
 *
 * @param stdClass $userdata an empty stdClass variable that should be set up with user values
 * @param object $scorm package record
 * @param string $scoid SCO Id
 * @param string $attempt attempt number for the user
 * @param string $mode scorm display mode type
 * @return array The default values that should be used for AICC package
 */
function get_scorm_default(&$userdata, $scorm, $scoid, $attempt, $mode)
{
    global $USER;
    $aiccuserid = get_config('scorm', 'aiccuserid');
    if (!empty($aiccuserid)) {
        $userdata->student_id = $USER->id;
    } else {
        $userdata->student_id = $USER->username;
    }
    $userdata->student_name = $USER->lastname . ', ' . $USER->firstname;
    if ($usertrack = scorm_get_tracks($scoid, $USER->id, $attempt)) {
        foreach ($usertrack as $key => $value) {
            $userdata->{$key} = $value;
        }
    } else {
        $userdata->status = '';
        $userdata->score_raw = '';
    }
    if ($scodatas = scorm_get_sco($scoid, SCO_DATA)) {
        foreach ($scodatas as $key => $value) {
            $userdata->{$key} = $value;
        }
    } else {
        print_error('cannotfindsco', 'scorm');
    }
    if (!($sco = scorm_get_sco($scoid))) {
        print_error('cannotfindsco', 'scorm');
    }
    $userdata->mode = 'normal';
    if (!empty($mode)) {
        $userdata->mode = $mode;
    }
    if ($userdata->mode == 'normal') {
        $userdata->credit = 'credit';
    } else {
        $userdata->credit = 'no-credit';
    }
    if (isset($userdata->status)) {
        if ($userdata->status == '') {
            $userdata->entry = 'ab-initio';
        } else {
            if (isset($userdata->{'cmi.core.exit'}) && $userdata->{'cmi.core.exit'} == 'suspend') {
                $userdata->entry = 'resume';
            } else {
                $userdata->entry = '';
            }
        }
    }
    $def = array();
    $def['cmi.core.student_id'] = $userdata->student_id;
    $def['cmi.core.student_name'] = $userdata->student_name;
    $def['cmi.core.credit'] = $userdata->credit;
    $def['cmi.core.entry'] = $userdata->entry;
    $def['cmi.launch_data'] = scorm_isset($userdata, 'datafromlms');
    $def['cmi.core.lesson_mode'] = $userdata->mode;
    $def['cmi.student_data.attempt_number'] = scorm_isset($userdata, 'cmi.student_data.attempt_number');
    $def['cmi.student_data.mastery_score'] = scorm_isset($userdata, 'mastery_score');
    $def['cmi.student_data.max_time_allowed'] = scorm_isset($userdata, 'max_time_allowed');
    $def['cmi.student_data.time_limit_action'] = scorm_isset($userdata, 'time_limit_action');
    $def['cmi.student_data.tries_during_lesson'] = scorm_isset($userdata, 'cmi.student_data.tries_during_lesson');
    $def['cmi.core.lesson_location'] = scorm_isset($userdata, 'cmi.core.lesson_location');
    $def['cmi.core.lesson_status'] = scorm_isset($userdata, 'cmi.core.lesson_status');
    $def['cmi.core.exit'] = scorm_isset($userdata, 'cmi.core.exit');
    $def['cmi.core.score.raw'] = scorm_isset($userdata, 'cmi.core.score.raw');
    $def['cmi.core.score.max'] = scorm_isset($userdata, 'cmi.core.score.max');
    $def['cmi.core.score.min'] = scorm_isset($userdata, 'cmi.core.score.min');
    $def['cmi.core.total_time'] = scorm_isset($userdata, 'cmi.core.total_time', '00:00:00');
    $def['cmi.suspend_data'] = scorm_isset($userdata, 'cmi.suspend_data');
    $def['cmi.comments'] = scorm_isset($userdata, 'cmi.comments');
    return $def;
}
开发者ID:evltuma,项目名称:moodle,代码行数:81,代码来源:aicclib.php

示例9: scorm_get_toc

function scorm_get_toc($user, $scorm, $liststyle, $currentorg = '', $scoid = '', $mode = 'normal', $attempt = '', $play = false, $tocheader = false)
{
    global $CFG, $DB, $PAGE, $OUTPUT;
    $strexpand = get_string('expcoll', 'scorm');
    $modestr = '';
    if ($mode == 'browse') {
        $modestr = '&amp;mode=' . $mode;
    }
    $result = new stdClass();
    //$result->toc = "<ul id='s0' class='$liststyle'>\n";
    if ($tocheader) {
        $result->toc = '<div id="scorm_layout">';
        $result->toc .= '<div id="scorm_toc">';
        $result->toc .= '<div id="scorm_tree">';
    }
    $result->toc .= '<ul>';
    $tocmenus = array();
    $result->prerequisites = true;
    $incomplete = false;
    //
    // Get the current organization infos
    //
    if (!empty($currentorg)) {
        if (($organizationtitle = $DB->get_field('scorm_scoes', 'title', array('scorm' => $scorm->id, 'identifier' => $currentorg))) != '') {
            if ($play) {
                $result->toctitle = "{$organizationtitle}";
            } else {
                $result->toc .= "\t<li>{$organizationtitle}</li>\n";
            }
            $tocmenus[] = $organizationtitle;
        }
    }
    //
    // If not specified retrieve the last attempt number
    //
    if (empty($attempt)) {
        $attempt = scorm_get_last_attempt($scorm->id, $user->id);
    }
    $result->attemptleft = $scorm->maxattempt - $attempt;
    if ($scoes = scorm_get_scoes($scorm->id, $currentorg)) {
        //
        // Retrieve user tracking data for each learning object
        //
        $usertracks = array();
        foreach ($scoes as $sco) {
            if (!empty($sco->launch)) {
                if (empty($scoid)) {
                    $scoid = $sco->id;
                }
                if ($usertrack = scorm_get_tracks($sco->id, $user->id, $attempt)) {
                    if ($usertrack->status == '') {
                        $usertrack->status = 'notattempted';
                    }
                    $usertracks[$sco->identifier] = $usertrack;
                }
            }
        }
        $level = 0;
        $sublist = 1;
        $previd = 0;
        $nextid = 0;
        $findnext = false;
        $parents[$level] = '/';
        foreach ($scoes as $pos => $sco) {
            $isvisible = false;
            $sco->title = $sco->title;
            if (!isset($sco->isvisible) || isset($sco->isvisible) && $sco->isvisible == 'true') {
                $isvisible = true;
            }
            if ($parents[$level] != $sco->parent) {
                if ($newlevel = array_search($sco->parent, $parents)) {
                    for ($i = 0; $i < $level - $newlevel; $i++) {
                        $result->toc .= "\t\t</li></ul></li>\n";
                    }
                    $level = $newlevel;
                } else {
                    $i = $level;
                    $closelist = '';
                    while ($i > 0 && $parents[$level] != $sco->parent) {
                        $closelist .= "\t\t</li></ul></li>\n";
                        $i--;
                    }
                    if ($i == 0 && $sco->parent != $currentorg) {
                        $style = '';
                        if (isset($_COOKIE['hide:SCORMitem' . $sco->id])) {
                            $style = ' style="display: none;"';
                        }
                        //$result->toc .= "\t\t<li><ul id='s$sublist' class='$liststyle'$style>\n";
                        $result->toc .= "\t\t<ul>\n";
                        $level++;
                    } else {
                        $result->toc .= $closelist;
                        $level = $i;
                    }
                    $parents[$level] = $sco->parent;
                }
            }
            if ($isvisible) {
                $result->toc .= "\t\t<li>";
            }
//.........这里部分代码省略.........
开发者ID:vuchannguyen,项目名称:web,代码行数:101,代码来源:aicclib.php

示例10: scorm_user_complete

/**
 * Print a detailed representation of what a user has done with
 * a given particular instance of this module, for user activity reports.
 *
 * @global stdClass
 * @global object
 * @param object $course
 * @param object $user
 * @param object $mod
 * @param object $scorm
 * @return boolean
 */
function scorm_user_complete($course, $user, $mod, $scorm)
{
    global $CFG, $DB, $OUTPUT;
    $liststyle = 'structlist';
    $now = time();
    $firstmodify = $now;
    $lastmodify = 0;
    $sometoreport = false;
    $report = '';
    if ($orgs = $DB->get_records('scorm_scoes', array('scorm' => $scorm->id, 'organization' => '', 'launch' => ''), 'id', 'id,identifier,title')) {
        if (count($orgs) <= 1) {
            unset($orgs);
            $orgs[]->identifier = '';
        }
        $report .= '<div class="mod-scorm">' . "\n";
        foreach ($orgs as $org) {
            $conditions = array();
            $currentorg = '';
            if (!empty($org->identifier)) {
                $report .= '<div class="orgtitle">' . $org->title . '</div>';
                $currentorg = $org->identifier;
                $conditions['organization'] = $currentorg;
            }
            $report .= "<ul id='0' class='{$liststyle}'>";
            $conditions['scorm'] = $scorm->id;
            if ($scoes = $DB->get_records('scorm_scoes', $conditions, "id ASC")) {
                // drop keys so that we can access array sequentially
                $scoes = array_values($scoes);
                $level = 0;
                $sublist = 1;
                $parents[$level] = '/';
                foreach ($scoes as $pos => $sco) {
                    if ($parents[$level] != $sco->parent) {
                        if ($level > 0 && $parents[$level - 1] == $sco->parent) {
                            $report .= "\t\t</ul></li>\n";
                            $level--;
                        } else {
                            $i = $level;
                            $closelist = '';
                            while ($i > 0 && $parents[$level] != $sco->parent) {
                                $closelist .= "\t\t</ul></li>\n";
                                $i--;
                            }
                            if ($i == 0 && $sco->parent != $currentorg) {
                                $report .= "\t\t<li><ul id='{$sublist}' class='{$liststyle}'>\n";
                                $level++;
                            } else {
                                $report .= $closelist;
                                $level = $i;
                            }
                            $parents[$level] = $sco->parent;
                        }
                    }
                    $report .= "\t\t<li>";
                    if (isset($scoes[$pos + 1])) {
                        $nextsco = $scoes[$pos + 1];
                    } else {
                        $nextsco = false;
                    }
                    if ($nextsco !== false && $sco->parent != $nextsco->parent && ($level == 0 || $level > 0 && $nextsco->parent == $sco->identifier)) {
                        $sublist++;
                    } else {
                        $report .= '<img src="' . $OUTPUT->mod_icon_url('pix/spacer', 'scorm') . '" alt="" />';
                    }
                    if ($sco->launch) {
                        require_once 'locallib.php';
                        $score = '';
                        $totaltime = '';
                        if ($usertrack = scorm_get_tracks($sco->id, $user->id)) {
                            if ($usertrack->status == '') {
                                $usertrack->status = 'notattempted';
                            }
                            $strstatus = get_string($usertrack->status, 'scorm');
                            $report .= "<img src='" . $OUTPUT->mod_icon_url('pix/' . $usertrack->status, 'scorm') . "' alt='{$strstatus}' title='{$strstatus}' />";
                            if ($usertrack->timemodified != 0) {
                                if ($usertrack->timemodified > $lastmodify) {
                                    $lastmodify = $usertrack->timemodified;
                                }
                                if ($usertrack->timemodified < $firstmodify) {
                                    $firstmodify = $usertrack->timemodified;
                                }
                            }
                        } else {
                            if ($sco->scormtype == 'sco') {
                                $report .= '<img src="' . $OUTPUT->mod_icon_url('pix/notattempted', 'scorm') . '" alt="' . get_string('notattempted', 'scorm') . '" title="' . get_string('notattempted', 'scorm') . '" />';
                            } else {
                                $report .= '<img src="' . $OUTPUT->mod_icon_url('pix/asset', 'scorm') . '" alt="' . get_string('asset', 'scorm') . '" title="' . get_string('asset', 'scorm') . '" />';
                            }
//.........这里部分代码省略.........
开发者ID:ajv,项目名称:Offline-Caching,代码行数:101,代码来源:lib.php

示例11: display


//.........这里部分代码省略.........
                 } 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 {
                                 $objectiveprefix = "cmi.objectives_";
                             }
                             $keywords = array(".id", $objectiveprefix);
                             $objectivestatus = array();
                             $objectivescore = array();
开发者ID:lucaboesch,项目名称:moodle,代码行数:67,代码来源:report.php

示例12: scorm_simple_play

function scorm_simple_play($scorm,$user, $context) {
    global $DB;

    $result = false;

    if ($scorm->updatefreq == UPDATE_EVERYTIME) {
        scorm_parse($scorm, false);
    }
    if (has_capability('mod/scorm:viewreport', $context)) { //if this user can view reports, don't skipview so they can see links to reports.
        return $result;
    }

    $scoes = $DB->get_records_select('scorm_scoes', 'scorm = ? AND '.$DB->sql_isnotempty('scorm_scoes', 'launch', false, true), array($scorm->id), 'id', 'id');

    if ($scoes) {
        if ($scorm->skipview >= 1) {
            $sco = current($scoes);
            if (scorm_get_tracks($sco->id,$user->id) === false) {
                header('Location: player.php?a='.$scorm->id.'&scoid='.$sco->id);
                $result = true;
            } else if ($scorm->skipview == 2) {
                header('Location: player.php?a='.$scorm->id.'&scoid='.$sco->id);
                $result = true;
            }
        }
    }
    return $result;
}
开发者ID:nfreear,项目名称:moodle,代码行数:28,代码来源:locallib.php

示例13: JLMS_APISCORM

function JLMS_APISCORM($option)
{
    global $JLMS_DB, $my, $Itemid;
    $id = intval(mosGetParam($_REQUEST, 'id', 0));
    $course_id = intval(mosGetParam($_REQUEST, 'course_id', 0));
    $skip_resume = intval(mosGetParam($_REQUEST, 'skip_resume', 0));
    if ($id) {
        $query = "SELECT * FROM #__lms_n_scorm WHERE id = {$id}";
        $JLMS_DB->SetQuery($query);
        $scorm = $JLMS_DB->LoadObject();
        if (is_object($scorm)) {
            $scoid = intval(mosGetParam($_REQUEST, 'scoid', 0));
            $attempt = intval(mosGetParam($_REQUEST, 'attempt', 0));
            $mode = strval(mosGetParam($_REQUEST, 'mode', ''));
            $track_attempt = $attempt;
            if ($track_attempt > 1) {
                global $JLMS_CONFIG;
                $course_params = $JLMS_CONFIG->get('course_params');
                $params = new JLMSParameters($course_params);
                if ($params->get('track_type', 0) == 1) {
                    //by the best attaempt
                    $track_attempt--;
                }
            }
            if ($skip_resume) {
                $userdata->status = '';
                $userdata->score_raw = '';
            } else {
                if ($usertrack = scorm_get_tracks($scoid, $my->id, $track_attempt)) {
                    if (isset($usertrack->{'cmi.exit'}) && $usertrack->{'cmi.exit'} != 'time-out' || $scorm->version != "SCORM_1.3") {
                        $userdata = $usertrack;
                    } else {
                        $userdata->status = '';
                        $userdata->score_raw = '';
                    }
                } else {
                    $userdata->status = '';
                    $userdata->score_raw = '';
                }
            }
            $userdata->student_id = addslashes($my->username);
            $userdata->student_name = addslashes($my->name);
            $userdata->mode = 'normal';
            if ($mode) {
                $userdata->mode = $mode;
            }
            if ($userdata->mode == 'normal') {
                $userdata->credit = 'credit';
            } else {
                $userdata->credit = 'no-credit';
            }
            if ($scodatas = scorm_get_sco($scoid, SCO_DATA)) {
                foreach ($scodatas as $key => $value) {
                    $userdata->{$key} = $value;
                }
            } else {
                // (DEN)
                //error('Sco not found');
                //echo 'SCO not found';
            }
            //$scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR));   // Just to be safe
            $scorm->version = strtolower(preg_replace('/[^a-zA-Z0-9_-]/i', '', $scorm->version));
            if (file_exists(_JOOMLMS_FRONT_HOME . '/includes/n_scorm/datamodels/' . $scorm->version . '.js.php')) {
                include_once _JOOMLMS_FRONT_HOME . '/includes/n_scorm/datamodels/' . $scorm->version . '.js.php';
            } else {
                include_once _JOOMLMS_FRONT_HOME . '/includes/n_scorm/datamodels/scorm_12.js.php';
            }
            /*if (file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'.js.php')) {
            			include_once($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'.js.php');
            		} else {
            			include_once($CFG->dirroot.'/mod/scorm/datamodels/scorm_12.js.php');
            		}*/
            ?>
			
var errorCode = "0";
function underscore(str) {
    str = str.replace(/.N/g,".");
    return str.replace(/\./g,"__");
}
<?php 
        }
    }
    exit;
}
开发者ID:parkmi,项目名称:dolschool14,代码行数:84,代码来源:joomla_lms.scorm.php

示例14: get_scorm_sco_tracks

    /**
     * Retrieves SCO tracking data for the given user id and attempt number
     *
     * @param int $scoid the sco id
     * @param int $userid the user id
     * @param int $attempt the attempt number
     * @return array warnings and the scoes data
     * @since Moodle 3.0
     */
    public static function get_scorm_sco_tracks($scoid, $userid, $attempt = 0) {
        global $USER, $DB;

        $params = self::validate_parameters(self::get_scorm_sco_tracks_parameters(),
                                            array('scoid' => $scoid, 'userid' => $userid, 'attempt' => $attempt));

        $tracks = array();
        $warnings = array();

        $sco = scorm_get_sco($params['scoid'], SCO_ONLY);
        if (!$sco) {
            throw new moodle_exception('cannotfindsco', 'scorm');
        }

        $scorm = $DB->get_record('scorm', array('id' => $sco->scorm), '*', MUST_EXIST);
        $cm = get_coursemodule_from_instance('scorm', $scorm->id);

        $context = context_module::instance($cm->id);
        self::validate_context($context);

        // Validate the user obtaining the context, it will fail if the user doesn't exists or have been deleted.
        context_user::instance($params['userid']);

        // Extra checks so only users with permissions can view other users attempts.
        if ($USER->id != $params['userid']) {
            require_capability('mod/scorm:viewreport', $context);
        }

        scorm_require_available($scorm, true, $context);

        if (empty($params['attempt'])) {
            $params['attempt'] = scorm_get_last_attempt($scorm->id, $params['userid']);
        }

        if ($scormtracks = scorm_get_tracks($sco->id, $params['userid'], $params['attempt'])) {
            foreach ($scormtracks as $element => $value) {
                $tracks[] = array(
                    'element' => $element,
                    'value' => $value,
                );
            }
        }

        $result = array();
        $result['data']['attempt'] = $params['attempt'];
        $result['data']['tracks'] = $tracks;
        $result['warnings'] = $warnings;
        return $result;
    }
开发者ID:rsturley,项目名称:moodle,代码行数:58,代码来源:external.php

示例15: display


//.........这里部分代码省略.........
                        $row[] = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$scouser->userid.'&amp;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.'&amp;user='.$scouser->userid.'&amp;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.'&amp;user='.$scouser->userid.'&amp;attempt='.$scouser->attempt.
                                            '" title="'.get_string('details', 'scorm').'">'.$score.'</a>';
                                } else {
                                    $row[] = $score;
                                }
                                // interaction data
                                $i=0;
                                $element='cmi.interactions_'.$i.'.id';
                                while(isset($trackdata->$element)) {
                                    if ($displayoptions['qtext']) {
开发者ID:numbas,项目名称:moodle,代码行数:67,代码来源:report.php


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