Example #1
0
/**
 * writes overview info for course_overview block - displays upcoming scorm objects that have a due date
 *
 * @param object $type - type of log(aicc,scorm12,scorm13) used as prefix for filename
 * @param array $htmlarray
 * @return mixed
 */
function scorm_print_overview($courses, &$htmlarray) {
    global $USER, $CFG, $DB;

    if (empty($courses) || !is_array($courses) || count($courses) == 0) {
        return array();
    }

    if (!$scorms = get_all_instances_in_courses('scorm', $courses)) {
        return;
    }

    $scormids = array();

    // Do scorm::isopen() here without loading the whole thing for speed
    foreach ($scorms as $key => $scorm) {
        $time = time();
        if ($scorm->timeopen) {
            $isopen = ($scorm->timeopen <= $time && $time <= $scorm->timeclose);
        }
        if (empty($scorm->displayattemptstatus) && (empty($isopen) || empty($scorm->timeclose))) {
            unset($scorms[$key]);
        } else {
            $scormids[] = $scorm->id;
        }
    }

    if (empty($scormids)) {
        // no scorms to look at - we're done
        return true;
    }
    $strscorm   = get_string('modulename', 'scorm');
    $strduedate = get_string('duedate', 'scorm');

    foreach ($scorms as $scorm) {
        $str = '<div class="scorm overview"><div class="name">'.$strscorm. ': '.
               '<a '.($scorm->visible ? '':' class="dimmed"').
               'title="'.$strscorm.'" href="'.$CFG->wwwroot.
               '/mod/scorm/view.php?id='.$scorm->coursemodule.'">'.
               $scorm->name.'</a></div>';
        if ($scorm->timeclose) {
            $str .= '<div class="info">'.$strduedate.': '.userdate($scorm->timeclose).'</div>';
        }
        if ($scorm->displayattemptstatus == 1) {
            require_once($CFG->dirroot.'/mod/scorm/locallib.php');
            $str .= '<div class="details">'.scorm_get_attempt_status($USER, $scorm).'</div>';
        }
        $str .= '</div>';
        if (empty($htmlarray[$scorm->course]['scorm'])) {
            $htmlarray[$scorm->course]['scorm'] = $str;
        } else {
            $htmlarray[$scorm->course]['scorm'] .= $str;
        }
    }
}
Example #2
0
        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) {
    echo $OUTPUT->box(get_string("notopenyet", "scorm", userdate($scorm->timeopen)), "generalbox boxaligncenter");
    $scormopen = false;
}
if (!empty($scorm->timeclose) && $timenow > $scorm->timeclose) {
    echo $OUTPUT->box(get_string("expired", "scorm", userdate($scorm->timeclose)), "generalbox boxaligncenter");
    $scormopen = false;
}
if ($scormopen && empty($launch)) {
    scorm_view_display($USER, $scorm, 'view.php?id=' . $cm->id, $cm);
}
Example #3
0
/**
 * writes overview info for course_overview block - displays upcoming scorm objects that have a due date
 *
 * @param object $type - type of log(aicc,scorm12,scorm13) used as prefix for filename
 * @param array $htmlarray
 * @return mixed
 */
function scorm_print_overview($courses, &$htmlarray) {
    global $USER, $CFG;

    if (empty($courses) || !is_array($courses) || count($courses) == 0) {
        return array();
    }

    if (!$scorms = get_all_instances_in_courses('scorm', $courses)) {
        return;
    }

    $strscorm   = get_string('modulename', 'scorm');
    $strduedate = get_string('duedate', 'scorm');

    foreach ($scorms as $scorm) {
        $time = time();
        $showattemptstatus = false;
        if ($scorm->timeopen) {
            $isopen = ($scorm->timeopen <= $time && $time <= $scorm->timeclose);
        }
        if ($scorm->displayattemptstatus == SCORM_DISPLAY_ATTEMPTSTATUS_ALL ||
                $scorm->displayattemptstatus == SCORM_DISPLAY_ATTEMPTSTATUS_MY) {
            $showattemptstatus = true;
        }
        if ($showattemptstatus || !empty($isopen) || !empty($scorm->timeclose)) {
            $str = '<div class="scorm overview"><div class="name">'.$strscorm. ': '.
                '<a '.($scorm->visible ? '':' class="dimmed"').
                'title="'.$strscorm.'" href="'.$CFG->wwwroot.
                '/mod/scorm/view.php?id='.$scorm->coursemodule.'">'.
                $scorm->name.'</a></div>';
            if ($scorm->timeclose) {
                $str .= '<div class="info">'.$strduedate.': '.userdate($scorm->timeclose).'</div>';
            }
            if ($showattemptstatus) {
                require_once($CFG->dirroot.'/mod/scorm/locallib.php');
                $str .= '<div class="details">'.scorm_get_attempt_status($USER, $scorm).'</div>';
            }
            $str .= '</div>';
            if (empty($htmlarray[$scorm->course]['scorm'])) {
                $htmlarray[$scorm->course]['scorm'] = $str;
            } else {
                $htmlarray[$scorm->course]['scorm'] .= $str;
            }
        }
    }
}
Example #4
-1
File: lib.php Project: ruddj/moodle
/**
 * writes overview info for course_overview block - displays upcoming scorm objects that have a due date
 *
 * @param object $type - type of log(aicc,scorm12,scorm13) used as prefix for filename
 * @param array $htmlarray
 * @return mixed
 */
function scorm_print_overview($courses, &$htmlarray) {
    global $USER, $CFG;

    if (empty($courses) || !is_array($courses) || count($courses) == 0) {
        return array();
    }

    if (!$scorms = get_all_instances_in_courses('scorm', $courses)) {
        return;
    }

    $strscorm   = get_string('modulename', 'scorm');
    $strduedate = get_string('duedate', 'scorm');

    foreach ($scorms as $scorm) {
        $time = time();
        $showattemptstatus = false;
        if ($scorm->timeopen) {
            $isopen = ($scorm->timeopen <= $time && $time <= $scorm->timeclose);
        }
        if ($scorm->displayattemptstatus == SCORM_DISPLAY_ATTEMPTSTATUS_ALL ||
                $scorm->displayattemptstatus == SCORM_DISPLAY_ATTEMPTSTATUS_MY) {
            $showattemptstatus = true;
        }
        if ($showattemptstatus || !empty($isopen) || !empty($scorm->timeclose)) {
            $str = html_writer::start_div('scorm overview').html_writer::div($strscorm. ': '.
                    html_writer::link($CFG->wwwroot.'/mod/scorm/view.php?id='.$scorm->coursemodule, $scorm->name,
                                        array('title' => $strscorm, 'class' => $scorm->visible ? '' : 'dimmed')), 'name');
            if ($scorm->timeclose) {
                $str .= html_writer::div($strduedate.': '.userdate($scorm->timeclose), 'info');
            }
            if ($showattemptstatus) {
                require_once($CFG->dirroot.'/mod/scorm/locallib.php');
                $str .= html_writer::div(scorm_get_attempt_status($USER, $scorm), 'details');
            }
            $str .= html_writer::end_div();
            if (empty($htmlarray[$scorm->course]['scorm'])) {
                $htmlarray[$scorm->course]['scorm'] = $str;
            } else {
                $htmlarray[$scorm->course]['scorm'] .= $str;
            }
        }
    }
}