/**
  * Get all the assignments in the course
  *
  * @param object $course
  * @return array instances of each assignment
  */
 public static function get_all_assignments_in_course($course)
 {
     if (!($turnitintooltwos = get_all_instances_in_course("turnitintooltwo", $course))) {
         turnitintooltwo_print_error('noturnitinassignemnts', 'turnitintooltwo', null, null, __FILE__, __LINE__);
         exit;
     }
     return $turnitintooltwos;
 }
 function get_content()
 {
     global $CFG, $USER, $COURSE;
     if (!empty($this->content)) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->footer = '';
     $this->content->text = '';
     if (!($att = array_pop(get_all_instances_in_course('attforblock', $COURSE, NULL, true)))) {
         $this->content->text = get_string('needactivity', 'block_attendance');
         return $this->content;
     }
     $cmid = $att->coursemodule;
     require_once $CFG->dirroot . '/mod/attforblock/locallib.php';
     if (!($context = get_context_instance(CONTEXT_MODULE, $cmid))) {
         print_error('badcontext');
     }
     // link to attendance
     if (has_capability('mod/attforblock:takeattendances', $context) or has_capability('mod/attforblock:changeattendances', $context)) {
         $this->content->text .= '<a href="' . $CFG->wwwroot . '/mod/attforblock/manage.php?id=' . $cmid . '&amp;from=block">' . get_string('takeattendance', 'attforblock') . '</a><br />';
     }
     if (has_capability('mod/attforblock:manageattendances', $context)) {
         $this->content->text .= '<a href="' . $CFG->wwwroot . '/mod/attforblock/sessions.php?id=' . $cmid . '&amp;action=add">' . get_string('add', 'attforblock') . '</a><br />';
     }
     if (has_capability('mod/attforblock:viewreports', $context)) {
         $this->content->text .= '<a href="' . $CFG->wwwroot . '/mod/attforblock/report.php?id=' . $cmid . '&amp;view=weeks">' . get_string('report', 'attforblock') . '</a><br />';
     }
     if (has_capability('mod/attforblock:export', $context)) {
         $this->content->text .= '<a href="' . $CFG->wwwroot . '/mod/attforblock/export.php?id=' . $cmid . '">' . get_string('export', 'quiz') . '</a><br />';
     }
     if (has_capability('mod/attforblock:changepreferences', $context)) {
         $this->content->text .= '<a href="' . $CFG->wwwroot . '/mod/attforblock/attsettings.php?id=' . $cmid . '">' . get_string('settings', 'attforblock') . '</a><br />';
     }
     $context2 = get_context_instance(CONTEXT_COURSE, $COURSE->id);
     if (has_capability('moodle/course:view', $context) && has_capability('mod/attforblock:view', $context)) {
         $complete = get_attendance($USER->id, $COURSE);
         if ($complete == 0) {
             //attendance not generated yet
             $this->content->text .= get_string('attendancenotstarted', 'attforblock');
         } else {
             //attendance taken
             $statuses = get_statuses($COURSE->id);
             foreach ($statuses as $st) {
                 $this->content->text .= $st->description . ':&nbsp;' . get_attendance($USER->id, $COURSE, $st->id) . '<br />';
             }
             $percent = get_percent($USER->id, $COURSE);
             $grade = get_grade($USER->id, $COURSE);
             $this->content->text .= get_string('attendancepercent', 'attforblock') . ':&nbsp;' . $percent . '&nbsp;%<br />';
             $this->content->text .= get_string('attendancegrade', 'attforblock') . ":&nbsp;{$grade}<br />";
             $this->content->text .= '<a href="' . $CFG->wwwroot . '/mod/attforblock/view.php?id=' . $cmid . '">' . get_string('indetail', 'attforblock') . '</a>';
         }
     }
     return $this->content;
 }
 /**
  * Gets the content for this block
  *
  * @return object $this->content
  */
 public function get_content()
 {
     global $CFG, $USER, $COURSE;
     if ($this->content !== null) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->footer = '';
     $this->content->text = '';
     $attendances = get_all_instances_in_course('attendance', $COURSE, null, true);
     if (count($attendances) == 0) {
         $this->content->text = get_string('needactivity', 'block_attendance');
         return $this->content;
     }
     require_once $CFG->dirroot . '/mod/attendance/locallib.php';
     require_once $CFG->dirroot . '/mod/attendance/renderhelpers.php';
     foreach ($attendances as $attinst) {
         $cmid = $attinst->coursemodule;
         $cm = get_coursemodule_from_id('attendance', $cmid, $COURSE->id, false, MUST_EXIST);
         $context = context_module::instance($cmid, MUST_EXIST);
         $divided = $this->divide_databasetable_and_coursemodule_data($attinst);
         $att = new attendance($divided->atttable, $divided->cm, $COURSE, $context);
         $this->content->text .= html_writer::link($att->url_view(), html_writer::tag('b', format_string($att->name)));
         $this->content->text .= html_writer::empty_tag('br');
         // Link to attendance.
         if ($att->perm->can_take() or $att->perm->can_change()) {
             $this->content->text .= html_writer::link($att->url_manage(array('from' => 'block')), get_string('takeattendance', 'attendance'));
             $this->content->text .= html_writer::empty_tag('br');
         }
         if ($att->perm->can_manage()) {
             $url = $att->url_sessions(array('action' => att_sessions_page_params::ACTION_ADD));
             $this->content->text .= html_writer::link($url, get_string('add', 'attendance'));
             $this->content->text .= html_writer::empty_tag('br');
         }
         if ($att->perm->can_view_reports()) {
             $this->content->text .= html_writer::link($att->url_report(), get_string('report', 'attendance'));
             $this->content->text .= html_writer::empty_tag('br');
         }
         if ($att->perm->can_be_listed() && $att->perm->can_view()) {
             $this->content->text .= construct_full_user_stat_html_table($attinst, $COURSE, $USER, $cm);
         }
         $this->content->text .= "<br />";
     }
     return $this->content;
 }
/**
 * return a list of book ids for the books which can be read/viewed
 *
 * @param stdClass $course  course object
 * @return array of book ids
 */
function book_search_get_readble_books($course)
{
    $bookids = array();
    if (!($books = get_all_instances_in_course('book', $course))) {
        notice(get_string('thereareno', 'moodle', get_string('modulenameplural', 'book')), "../../course/view.php?id={$course->id}");
        die;
    }
    foreach ($books as $book) {
        $cm = get_coursemodule_from_instance("book", $book->id, $course->id);
        $context = context_module::instance($cm->id);
        if ($cm->visible || has_capability('moodle/course:viewhiddenactivities', $context)) {
            if (has_capability('mod/book:read', $context)) {
                $bookids[] = $book->id;
            }
        }
    }
    return $bookids;
}
 function get_content()
 {
     global $USER, $CFG, $COURSE;
     if (empty($this->instance)) {
         $this->content = '';
         return $this->content;
     }
     $context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
     $viewassignments = has_capability('mod/plagiarismdetector:view', $context);
     $viewself = has_capability('mod/plagiarismdetector:view', $context);
     if (!$viewassignments && !$viewself) {
         //Should not see the block
         return null;
     }
     if ($viewassignments) {
         $assignments = get_all_instances_in_course("assignment", $COURSE);
         //var_dump($assignments);
         $this->content = new stdClass();
         $this->content->items = array();
         $this->content->icons = array();
         $this->content->footer = '';
         if (count($assignments)) {
             foreach ($assignments as $assignment) {
                 $this->content->icons[] = '<img src="' . $CFG->modpixpath . '/assignment/icon.gif"></img>';
                 $this->content->items[] = '<a href="' . $CFG->wwwroot . '/mod/plagiarismdetector/index.php?a=' . $assignment->id . '">' . format_string($assignment->name, true) . '</a>';
             }
             //var_dump($assignments);
             /*$this->content->footer = 'footer';*/
             //$this->content->footer = '<a href="'.$CFG->wwwroot.'/mod/plagiarismdetector/index.php">'.get_string('blockmanual','block_plagiarism_detector').'</a>';
         }
     } else {
         if ($viewself) {
             //$this->content->text = 'Tu práctica no ha sido revisada';
         }
     }
     return $this->content;
 }
Exemplo n.º 6
0
 function data_preprocessing(&$default_values)
 {
     global $COURSE;
     if (isset($default_values['popup']) && $default_values['popup'] == 1 && isset($default_values['options'])) {
         if (!empty($default_values['options'])) {
             $options = explode(',', $default_values['options']);
             foreach ($options as $option) {
                 list($element, $value) = explode('=', $option);
                 $element = trim($element);
                 $default_values[$element] = trim($value);
             }
         }
     }
     if (isset($default_values['grademethod'])) {
         $default_values['whatgrade'] = intval($default_values['grademethod'] / 10);
         $default_values['grademethod'] = $default_values['grademethod'] % 10;
     }
     if (isset($default_value['width']) && strpos($default_value['width'], '%') === false && $default_value['width'] <= 100) {
         $default_value['width'] .= '%';
     }
     if (isset($default_value['width']) && strpos($default_value['height'], '%') === false && $default_value['height'] <= 100) {
         $default_value['height'] .= '%';
     }
     $scorms = get_all_instances_in_course('scorm', $COURSE);
     $coursescorm = current($scorms);
     if ($COURSE->format == 'scorm' && (count($scorms) == 0 || $default_values['instance'] == $coursescorm->id)) {
         $default_values['redirect'] = 'yes';
         $default_values['redirecturl'] = '../course/view.php?id=' . $default_values['course'];
     } else {
         $default_values['redirect'] = 'no';
         $default_values['redirecturl'] = '../mod/scorm/view.php?id=' . $default_values['coursemodule'];
     }
     if (isset($default_values['version'])) {
         $default_values['pkgtype'] = substr($default_values['version'], 0, 5) == 'SCORM' ? 'scorm' : 'aicc';
     }
     if (isset($default_values['instance'])) {
         $default_values['datadir'] = $default_values['instance'];
     }
     if (empty($default_values['timeopen'])) {
         $default_values['timerestrict'] = 0;
     } else {
         $default_values['timerestrict'] = 1;
     }
 }
Exemplo n.º 7
0
if ($course->id != SITEID) {
    require_login($course->id);
}
add_to_log($course->id, "resource", "view all", "index.php?id={$course->id}", "");
$strresource = get_string("modulename", "resource");
$strresources = get_string("modulenameplural", "resource");
$strweek = get_string("week");
$strtopic = get_string("topic");
$strname = get_string("name");
$strsummary = get_string("summary");
$strlastmodified = get_string("lastmodified");
$navlinks = array();
$navlinks[] = array('name' => $strresources, 'link' => '', 'type' => 'activityinstance');
$navigation = build_navigation($navlinks);
print_header("{$course->shortname}: {$strresources}", $course->fullname, $navigation, "", "", true, "", user_login_string($course) . '<hr style="width:95%">' . navmenu($course));
if (!($resources = get_all_instances_in_course("resource", $course))) {
    notice(get_string('thereareno', 'moodle', $strresources), "../../course/view.php?id={$course->id}");
    exit;
}
if ($course->format == "weeks") {
    $table->head = array($strweek, $strname, $strsummary);
    $table->align = array("center", "left", "left");
} else {
    if ($course->format == "topics") {
        $table->head = array($strtopic, $strname, $strsummary);
        $table->align = array("center", "left", "left");
    } else {
        $table->head = array($strlastmodified, $strname, $strsummary);
        $table->align = array("left", "left", "left");
    }
}
Exemplo n.º 8
0
function scorm_course_format_display($user, $course)
{
    global $CFG;
    $strupdate = get_string('update');
    $strmodule = get_string('modulename', 'scorm');
    $context = get_context_instance(CONTEXT_COURSE, $course->id);
    echo '<div class="mod-scorm">';
    if ($scorms = get_all_instances_in_course('scorm', $course)) {
        // The module SCORM activity with the least id is the course
        $scorm = current($scorms);
        if (!($cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id))) {
            error('Course Module ID was incorrect');
        }
        $colspan = '';
        $headertext = '<table width="100%"><tr><td class="title">' . get_string('name') . ': <b>' . format_string($scorm->name) . '</b>';
        if (has_capability('moodle/course:manageactivities', $context)) {
            if (isediting($course->id)) {
                // Display update icon
                $path = $CFG->wwwroot . '/course';
                $headertext .= '<span class="commands">' . '<a title="' . $strupdate . '" href="' . $path . '/mod.php?update=' . $cm->id . '&amp;sesskey=' . sesskey() . '">' . '<img src="' . $CFG->pixpath . '/t/edit.gif" class="iconsmall" alt="' . $strupdate . '" /></a></span>';
            }
            $headertext .= '</td>';
            // Display report link
            $trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c');
            if ($trackedusers->c > 0) {
                $headertext .= '<td class="reportlink">' . '<a ' . $CFG->frametarget . '" href="' . $CFG->wwwroot . '/mod/scorm/report.php?id=' . $cm->id . '">' . get_string('viewallreports', 'scorm', $trackedusers->c) . '</a>';
            } else {
                $headertext .= '<td class="reportlink">' . get_string('noreports', 'scorm');
            }
            $colspan = ' colspan="2"';
        }
        $headertext .= '</td></tr><tr><td' . $colspan . '>' . format_text(get_string('summary') . ':<br />' . $scorm->summary) . '</td></tr></table>';
        print_simple_box($headertext, '', '100%');
        scorm_view_display($user, $scorm, 'view.php?id=' . $course->id, $cm, '100%');
    } else {
        if (has_capability('moodle/course:update', $context)) {
            // Create a new activity
            redirect($CFG->wwwroot . '/course/mod.php?id=' . $course->id . '&amp;section=0&sesskey=' . sesskey() . '&amp;add=scorm');
        } else {
            notify('Could not find a scorm course here');
        }
    }
    echo '</div>';
}
Exemplo n.º 9
0
function scorm_course_format_display($user, $course) {
    global $CFG, $DB, $PAGE, $OUTPUT;

    $strupdate = get_string('update');
    $context = get_context_instance(CONTEXT_COURSE, $course->id);

    echo '<div class="mod-scorm">';
    if ($scorms = get_all_instances_in_course('scorm', $course)) {
        // The module SCORM activity with the least id is the course
        $scorm = current($scorms);
        if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) {
            print_error('invalidcoursemodule');
        }
        $contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id);
        if ((has_capability('mod/scorm:skipview', $contextmodule))) {
            scorm_simple_play($scorm, $user, $contextmodule, $cm->id);
        }
        $colspan = '';
        $headertext = '<table width="100%"><tr><td class="title">'.get_string('name').': <b>'.format_string($scorm->name).'</b>';
        if (has_capability('moodle/course:manageactivities', $context)) {
            if ($PAGE->user_is_editing()) {
                // Display update icon
                $path = $CFG->wwwroot.'/course';
                $headertext .= '<span class="commands">'.
                        '<a title="'.$strupdate.'" href="'.$path.'/mod.php?update='.$cm->id.'&amp;sesskey='.sesskey().'">'.
                        '<img src="'.$OUTPUT->pix_url('t/edit') . '" class="iconsmall" alt="'.$strupdate.'" /></a></span>';
            }
            $headertext .= '</td>';
            // Display report link
            $trackedusers = $DB->get_record('scorm_scoes_track', array('scormid'=>$scorm->id), 'count(distinct(userid)) as c');
            if ($trackedusers->c > 0) {
                $headertext .= '<td class="reportlink">'.
                              '<a href="'.$CFG->wwwroot.'/mod/scorm/report.php?id='.$cm->id.'">'.
                               get_string('viewallreports', 'scorm', $trackedusers->c).'</a>';
            } else {
                $headertext .= '<td class="reportlink">'.get_string('noreports', 'scorm');
            }
            $colspan = ' colspan="2"';
        }
        $headertext .= '</td></tr><tr><td'.$colspan.'>'.get_string('summary').':<br />'.format_module_intro('scorm', $scorm, $scorm->coursemodule).'</td></tr></table>';
        echo $OUTPUT->box($headertext, 'generalbox boxwidthwide');
        scorm_view_display($user, $scorm, 'view.php?id='.$course->id, $cm);
    } else {
        if (has_capability('moodle/course:update', $context)) {
            // Create a new activity
            $url = new moodle_url('/course/mod.php', array('id'=>$course->id, 'section'=>'0', 'sesskey'=>sesskey(),'add'=>'scorm'));
            redirect($url);
        } else {
            echo $OUTPUT->notification('Could not find a scorm course here');
        }
    }
    echo '</div>';
}
Exemplo n.º 10
0
        if (!($cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id))) {
            error("Course Module ID was incorrect");
        }
    } else {
        error('A required parameter is missing');
    }
}
require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
if (isset($SESSION->scorm_scoid)) {
    unset($SESSION->scorm_scoid);
}
$strscorms = get_string("modulenameplural", "scorm");
$strscorm = get_string("modulename", "scorm");
if ($course->id != SITEID) {
    if ($scorms = get_all_instances_in_course('scorm', $course)) {
        // The module SCORM activity with the least id is the course
        $firstscorm = current($scorms);
        if (!($course->format == 'scorm' && $firstscorm->id == $scorm->id)) {
            $navlinks[] = array('name' => $strscorms, 'link' => "index.php?id={$course->id}", 'type' => 'activity');
        }
    }
}
$pagetitle = strip_tags($course->shortname . ': ' . format_string($scorm->name));
add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id=' . $cm->id, "{$scorm->id}");
if (has_capability('mod/scorm:skipview', get_context_instance(CONTEXT_MODULE, $cm->id)) && scorm_simple_play($scorm, $USER)) {
    exit;
}
//
// Print the page header
//
Exemplo n.º 11
0
    error("Course ID is incorrect");
}
require_course_login($course);
add_to_log($course->id, "survey", "view all", "index.php?id={$course->id}", "");
$strsurveys = get_string("modulenameplural", "survey");
$strweek = get_string("week");
$strtopic = get_string("topic");
$strname = get_string("name");
$strstatus = get_string("status");
$strdone = get_string("done", "survey");
$strnotdone = get_string("notdone", "survey");
$navlinks = array();
$navlinks[] = array('name' => $strsurveys, 'link' => '', 'type' => 'activity');
$navigation = build_navigation($navlinks);
print_header_simple("{$strsurveys}", "", $navigation, "", "", true, "", navmenu($course));
if (!($surveys = get_all_instances_in_course("survey", $course))) {
    notice("There are no surveys.", "../../course/view.php?id={$course->id}");
}
if ($course->format == "weeks") {
    $table->head = array($strweek, $strname, $strstatus);
    $table->align = array("CENTER", "LEFT", "LEFT");
} else {
    if ($course->format == "topics") {
        $table->head = array($strtopic, $strname, $strstatus);
        $table->align = array("CENTER", "LEFT", "LEFT");
    } else {
        $table->head = array($strname, $strstatus);
        $table->align = array("LEFT", "LEFT");
    }
}
$currentsection = '';
 * This page lists all the instances of studynotes in a particular course
 *
 * @author
 * @version $Id: index.php,v 1.3 2009/06/22 07:37:09 fabiangebert Exp $
 * @package studynotes
 **/
/// Replace studynotes with the name of your module
require_once "../../config.php";
require_once "lib.php";
$id = required_param('id', PARAM_INT);
// course
if (!($course = get_record("course", "id", $id))) {
    error("Course ID is incorrect");
}
require_login($course->id);
$studynotess = get_all_instances_in_course("studynotes", $course);
if (count($studynotess) == 1) {
    header("Location: " . $CFG->wwwroot . '/mod/studynotes/view.php?id=' . $studynotess[0]->coursemodule);
}
add_to_log($course->id, "studynotes", "view all", "index.php?id={$course->id}", "");
/// Get all required stringsstudynotes
$strstudynotess = get_string("modulenameplural", "studynotes");
$strstudynotes = get_string("modulename", "studynotes");
/// Print the header
$navlinks = array();
$navlinks[] = array('name' => $strstudynotess, 'link' => '', 'type' => 'activity');
$navigation = build_navigation($navlinks);
print_header_simple("{$strstudynotess}", "", $navigation, "", "", true, "", navmenu($course));
/// Get all the appropriate data
if (!$studynotess) {
    notice("There are no studynotess", "../../course/view.php?id={$course->id}");
Exemplo n.º 13
0
add_to_log($course->id, "udutu", "view all", "index.php?id={$course->id}", "");
$strudutu = get_string("modulename", "udutu");
$strudutus = get_string("modulenameplural", "udutu");
$strweek = get_string("week");
$strtopic = get_string("topic");
$strname = get_string("name");
$strsummary = get_string("summary");
$strreport = get_string("report", 'udutu');
$strlastmodified = get_string("lastmodified");
print_header_simple("{$strudutus}", "", "{$strudutus}", "", "", true, "", navmenu($course));
if ($course->format == "weeks" or $course->format == "topics") {
    $sortorder = "cw.section ASC";
} else {
    $sortorder = "m.timemodified DESC";
}
if (!($udutus = get_all_instances_in_course("udutu", $course))) {
    notice("There are no udutus", "../../course/view.php?id={$course->id}");
    exit;
}
if ($course->format == "weeks") {
    $table->head = array($strweek, $strname, $strsummary, $strreport);
    $table->align = array("center", "left", "left", "left");
} else {
    if ($course->format == "topics") {
        $table->head = array($strtopic, $strname, $strsummary, $strreport);
        $table->align = array("center", "left", "left", "left");
    } else {
        $table->head = array($strlastmodified, $strname, $strsummary, $strreport);
        $table->align = array("left", "left", "left", "left");
    }
}
Exemplo n.º 14
0
 function definition()
 {
     global $LESSON_NEXTPAGE_ACTION, $COURSE;
     $mform =& $this->_form;
     //-------------------------------------------------------------------------------
     $mform->addElement('header', 'general', get_string('general', 'form'));
     $mform->addElement('text', 'name', get_string('name'), array('size' => '64'));
     $mform->setType('name', PARAM_TEXT);
     $mform->addRule('name', null, 'required', null, 'client');
     $mform->addElement('selectyesno', 'timed', get_string('timed', 'lesson'));
     $mform->setDefault('timed', 0);
     $mform->setHelpButton('timed', array('timed', get_string('timed', 'lesson'), 'lesson'));
     $mform->addElement('text', 'maxtime', get_string('maxtime', 'lesson'));
     $mform->setDefault('maxtime', 20);
     $mform->addRule('maxtime', null, 'required', null, 'client');
     $mform->addRule('maxtime', null, 'numeric', null, 'client');
     $mform->setType('maxtime', PARAM_INT);
     $numbers = array();
     for ($i = 20; $i > 1; $i--) {
         $numbers[$i] = $i;
     }
     $mform->addElement('select', 'maxanswers', get_string('maximumnumberofanswersbranches', 'lesson'), $numbers);
     $mform->setDefault('maxanswers', 4);
     $mform->setHelpButton('maxanswers', array('maxanswers', get_string('displayformat', 'lesson'), 'lesson'));
     //-------------------------------------------------------------------------------
     $mform->addElement('header', '', get_string('gradeoptions', 'lesson'));
     $mform->addElement('selectyesno', 'practice', get_string('practice', 'lesson'));
     $mform->setHelpButton('practice', array('practice', get_string('practice', 'lesson'), 'lesson'));
     $mform->setDefault('practice', 0);
     $mform->addElement('selectyesno', 'custom', get_string('customscoring', 'lesson'));
     $mform->setHelpButton('custom', array('custom', get_string('customscoring', 'lesson'), 'lesson'));
     $mform->setDefault('custom', 1);
     $grades = array();
     for ($i = 100; $i >= 0; $i--) {
         $grades[$i] = $i;
     }
     $mform->addElement('select', 'grade', get_string('maximumgrade'), $grades);
     $mform->setDefault('grade', 0);
     $mform->setHelpButton('grade', array('grade', get_string('maximumgrade', 'lesson'), 'lesson'));
     $mform->addElement('selectyesno', 'retake', get_string('canretake', 'lesson', $COURSE->student));
     $mform->setHelpButton('retake', array('retake', get_string('canretake', 'lesson', $COURSE->student), 'lesson'));
     $mform->setDefault('retake', 0);
     $options = array();
     $options[0] = get_string('usemean', 'lesson');
     $options[1] = get_string('usemaximum', 'lesson');
     $mform->addElement('select', 'usemaxgrade', get_string('handlingofretakes', 'lesson'), $options);
     $mform->setHelpButton('usemaxgrade', array('handlingofretakes', get_string('handlingofretakes', 'lesson'), 'lesson'));
     $mform->setDefault('usemaxgrade', 0);
     $mform->addElement('selectyesno', 'ongoing', get_string('ongoing', 'lesson'));
     $mform->setHelpButton('ongoing', array('ongoing', get_string('ongoing', 'lesson'), 'lesson'));
     $mform->setDefault('ongoing', 0);
     //-------------------------------------------------------------------------------
     $mform->addElement('header', '', get_string('flowcontrol', 'lesson'));
     $mform->addElement('selectyesno', 'modattempts', get_string('modattempts', 'lesson'));
     $mform->setHelpButton('modattempts', array('modattempts', get_string('modattempts', 'lesson'), 'lesson'));
     $mform->setDefault('modattempts', 0);
     $mform->addElement('selectyesno', 'review', get_string('displayreview', 'lesson'));
     $mform->setHelpButton('review', array('review', get_string('displayreview', 'lesson'), 'lesson'));
     $mform->setDefault('review', 0);
     $numbers = array();
     for ($i = 10; $i > 0; $i--) {
         $numbers[$i] = $i;
     }
     $mform->addElement('select', 'maxattempts', get_string('maximumnumberofattempts', 'lesson'), $numbers);
     $mform->setHelpButton('maxattempts', array('maxattempts', get_string('maximumnumberofattempts', 'lesson'), 'lesson'));
     $mform->setDefault('maxattempts', 1);
     $mform->addElement('select', 'nextpagedefault', get_string('actionaftercorrectanswer', 'lesson'), $LESSON_NEXTPAGE_ACTION);
     $mform->setHelpButton('nextpagedefault', array('nextpageaction', get_string('actionaftercorrectanswer', 'lesson'), 'lesson'));
     $mform->setDefault('nextpagedefault', 0);
     $mform->addElement('selectyesno', 'feedback', get_string('displaydefaultfeedback', 'lesson'));
     $mform->setHelpButton('feedback', array('feedback', get_string('displaydefaultfeedback', 'lesson'), 'lesson'));
     $mform->setDefault('feedback', 0);
     $numbers = array();
     for ($i = 100; $i >= 0; $i--) {
         $numbers[$i] = $i;
     }
     $mform->addElement('select', 'minquestions', get_string('minimumnumberofquestions', 'lesson'), $numbers);
     $mform->setHelpButton('minquestions', array('minquestions', get_string('minimumnumberofquestions', 'lesson'), 'lesson'));
     $mform->setDefault('minquestions', 0);
     $numbers = array();
     for ($i = 100; $i >= 0; $i--) {
         $numbers[$i] = $i;
     }
     $mform->addElement('select', 'maxpages', get_string('numberofpagestoshow', 'lesson'), $numbers);
     $mform->setHelpButton('maxpages', array('maxpages', get_string('numberofpagestoshow', 'lesson'), 'lesson'));
     $mform->setDefault('maxpages', 0);
     //-------------------------------------------------------------------------------
     $mform->addElement('header', '', get_string('lessonformating', 'lesson'));
     $mform->addElement('selectyesno', 'slideshow', get_string('slideshow', 'lesson'));
     $mform->setHelpButton('slideshow', array('slideshow', get_string('slideshow', 'lesson'), 'lesson'));
     $mform->setDefault('slideshow', 0);
     $mform->addElement('text', 'width', get_string('slideshowwidth', 'lesson'));
     $mform->setDefault('width', 640);
     $mform->addRule('width', null, 'required', null, 'client');
     $mform->addRule('width', null, 'numeric', null, 'client');
     $mform->setHelpButton('width', array('width', get_string('slideshowwidth', 'lesson'), 'lesson'));
     $mform->setType('width', PARAM_INT);
     $mform->addElement('text', 'height', get_string('slideshowheight', 'lesson'));
     $mform->setDefault('height', 480);
     $mform->addRule('height', null, 'required', null, 'client');
     $mform->addRule('height', null, 'numeric', null, 'client');
     $mform->setHelpButton('height', array('height', get_string('slideshowheight', 'lesson'), 'lesson'));
     $mform->setType('height', PARAM_INT);
     $mform->addElement('text', 'bgcolor', get_string('slideshowbgcolor', 'lesson'));
     $mform->setDefault('bgcolor', '#FFFFFF');
     $mform->addRule('bgcolor', null, 'required', null, 'client');
     $mform->setHelpButton('bgcolor', array('bgcolor', get_string('slideshowbgcolor', 'lesson'), 'lesson'));
     $mform->setType('bgcolor', PARAM_TEXT);
     $mform->addElement('selectyesno', 'displayleft', get_string('displayleftmenu', 'lesson'));
     $mform->setHelpButton('displayleft', array('displayleft', get_string('displayleftmenu', 'lesson'), 'lesson'));
     $mform->setDefault('displayleft', 0);
     $options = array();
     for ($i = 100; $i >= 0; $i--) {
         $options[$i] = $i . '%';
     }
     $mform->addElement('select', 'displayleftif', get_string('displayleftif', 'lesson'), $options);
     $mform->setDefault('displayleftif', 0);
     $mform->addElement('selectyesno', 'progressbar', get_string('progressbar', 'lesson'));
     $mform->setHelpButton('progressbar', array('progressbar', get_string('progressbar', 'lesson'), 'lesson'));
     $mform->setDefault('progressbar', 0);
     //-------------------------------------------------------------------------------
     $mform->addElement('header', '', get_string('accesscontrol', 'lesson'));
     $mform->addElement('selectyesno', 'usepassword', get_string('usepassword', 'lesson'));
     $mform->setHelpButton('usepassword', array('usepassword', get_string('usepassword', 'lesson'), 'lesson'));
     $mform->setDefault('usepassword', 0);
     $mform->addElement('text', 'password', get_string('password', 'lesson'));
     $mform->setHelpButton('password', array('password', get_string('password', 'lesson'), 'lesson'));
     $mform->setDefault('password', '');
     //never displayed converted to md5
     $mform->setType('password', PARAM_RAW);
     $mform->addElement('date_time_selector', 'available', get_string('available', 'lesson'));
     $mform->setDefault('available', 0);
     $mform->addElement('date_time_selector', 'deadline', get_string('deadline', 'lesson'));
     $mform->setDefault('deadline', 0);
     //-------------------------------------------------------------------------------
     $mform->addElement('header', '', get_string('dependencyon', 'lesson'));
     $options = array(0 => get_string('none'));
     if ($lessons = get_all_instances_in_course('lesson', $COURSE)) {
         foreach ($lessons as $lesson) {
             if ($lesson->id != $this->_instance) {
                 $options[$lesson->id] = format_string($lesson->name, true);
             }
         }
     }
     $mform->addElement('select', 'dependency', get_string('dependencyon', 'lesson'), $options);
     $mform->setHelpButton('dependency', array('dependency', get_string('dependency', 'lesson'), 'lesson'));
     $mform->setDefault('dependency', 0);
     $mform->addElement('text', 'timespent', get_string('timespentminutes', 'lesson'));
     $mform->setDefault('timespent', 0);
     $mform->setType('timespent', PARAM_INT);
     $mform->addElement('checkbox', 'completed', get_string('completed', 'lesson'));
     $mform->setDefault('completed', 0);
     $mform->addElement('text', 'gradebetterthan', get_string('gradebetterthan', 'lesson'));
     $mform->setDefault('gradebetterthan', 0);
     $mform->setType('gradebetterthan', PARAM_INT);
     //-------------------------------------------------------------------------------
     $mform->addElement('header', '', get_string('mediafile', 'lesson'));
     $mform->addElement('choosecoursefile', 'mediafile', get_string('mediafile', 'lesson'), array('courseid' => $COURSE->id));
     $mform->setHelpButton('mediafile', array('mediafile', get_string('mediafile', 'lesson'), 'lesson'));
     $mform->setDefault('mediafile', '');
     $mform->setType('mediafile', PARAM_RAW);
     $mform->addElement('selectyesno', 'mediaclose', get_string('mediaclose', 'lesson'));
     $mform->setDefault('mediaclose', 0);
     $mform->addElement('text', 'mediaheight', get_string('mediaheight', 'lesson'));
     $mform->setHelpButton('mediaheight', array('mediaheight', get_string('mediaheight', 'lesson'), 'lesson'));
     $mform->setDefault('mediaheight', 100);
     $mform->addRule('mediaheight', null, 'required', null, 'client');
     $mform->addRule('mediaheight', null, 'numeric', null, 'client');
     $mform->setType('mediaheight', PARAM_INT);
     $mform->addElement('text', 'mediawidth', get_string('mediawidth', 'lesson'));
     $mform->setHelpButton('mediawidth', array('mediawidth', get_string('mediawidth', 'lesson'), 'lesson'));
     $mform->setDefault('mediawidth', 650);
     $mform->addRule('mediawidth', null, 'required', null, 'client');
     $mform->addRule('mediawidth', null, 'numeric', null, 'client');
     $mform->setType('mediawidth', PARAM_INT);
     //-------------------------------------------------------------------------------
     $mform->addElement('header', '', get_string('other', 'lesson'));
     // get the modules
     if ($mods = get_course_mods($COURSE->id)) {
         $modinstances = array();
         foreach ($mods as $mod) {
             // get the module name and then store it in a new array
             if ($module = get_coursemodule_from_instance($mod->modname, $mod->instance, $COURSE->id)) {
                 if (isset($this->_cm->id) and $this->_cm->id != $mod->id) {
                     $modinstances[$mod->id] = $mod->modname . ' - ' . $module->name;
                 }
             }
         }
         asort($modinstances);
         // sort by module name
         $modinstances = array(0 => get_string('none')) + $modinstances;
         $mform->addElement('select', 'activitylink', get_string('activitylink', 'lesson'), $modinstances);
         $mform->setHelpButton('activitylink', array('activitylink', get_string('activitylink', 'lesson'), 'lesson'));
         $mform->setDefault('activitylink', 0);
     }
     $mform->addElement('text', 'maxhighscores', get_string('maxhighscores', 'lesson'));
     $mform->setHelpButton('maxhighscores', array('maxhighscores', get_string('maxhighscores', 'lesson'), 'lesson'));
     $mform->setDefault('maxhighscores', 10);
     $mform->addRule('maxhighscores', null, 'required', null, 'client');
     $mform->addRule('maxhighscores', null, 'numeric', null, 'client');
     $mform->setType('maxhighscores', PARAM_INT);
     $mform->addElement('selectyesno', 'lessondefault', get_string('lessondefault', 'lesson'));
     $mform->setHelpButton('lessondefault', array('lessondefault', get_string('lessondefault', 'lesson'), 'lesson'));
     $mform->setDefault('lessondefault', 0);
     //-------------------------------------------------------------------------------
     $this->standard_coursemodule_elements(false);
     //-------------------------------------------------------------------------------
     // buttons
     $this->add_action_buttons();
 }
Exemplo n.º 15
0
$PAGE->set_pagelayout('incourse');
// Trigger instances list viewed event.
$event = \mod_page\event\instances_list_viewed::create(array('context' => context_course::instance($course->id)));
$event->trigger();
$strpage = get_string('modulename', 'page');
$strpages = get_string('modulenameplural', 'page');
$strname = get_string('name');
$strintro = get_string('moduleintro');
$strlastmodified = get_string('lastmodified');
$PAGE->set_url('/mod/page/index.php', array('id' => $course->id));
$PAGE->set_title($course->shortname . ': ' . $strpages);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add($strpages);
echo $OUTPUT->header();
echo $OUTPUT->heading($strpages);
if (!($pages = get_all_instances_in_course('page', $course))) {
    notice(get_string('thereareno', 'moodle', $strpages), "{$CFG->wwwroot}/course/view.php?id={$course->id}");
    exit;
}
$usesections = course_format_uses_sections($course->format);
$table = new html_table();
$table->attributes['class'] = 'generaltable mod_index';
if ($usesections) {
    $strsectionname = get_string('sectionname', 'format_' . $course->format);
    $table->head = array($strsectionname, $strname, $strintro);
    $table->align = array('center', 'left', 'left');
} else {
    $table->head = array($strlastmodified, $strname, $strintro);
    $table->align = array('left', 'left', 'left');
}
$modinfo = get_fast_modinfo($course);
Exemplo n.º 16
0
/// Get all required strings

$strglossarys = get_string("modulenameplural", "glossary");
$strglossary  = get_string("modulename", "glossary");
$strrss = get_string("rss");


/// Print the header
$PAGE->navbar->add($strglossarys, "index.php?id=$course->id");
$PAGE->set_title($strglossarys);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();

/// Get all the appropriate data

if (! $glossarys = get_all_instances_in_course("glossary", $course)) {
    notice(get_string('thereareno', 'moodle', $strglossarys), "../../course/view.php?id=$course->id");
    die;
}

$usesections = course_format_uses_sections($course->format);
if ($usesections) {
    $sections = get_all_sections($course->id);
}

/// Print the list of instances (your module will probably extend this)

$timenow = time();
$strsectionname  = get_string('sectionname', 'format_'.$course->format);
$strname  = get_string("name");
$strentries  = get_string("entries", "glossary");
Exemplo n.º 17
0
function backup_fetch_prefs_from_request(&$preferences, &$count, $course)
{
    global $CFG, $SESSION;
    // check to see if it's in the session already
    if (!empty($SESSION->backupprefs) && array_key_exists($course->id, $SESSION->backupprefs) && !empty($SESSION->backupprefs[$course->id])) {
        $sprefs = $SESSION->backupprefs[$course->id];
        $preferences = $sprefs;
        // refetch backup_name just in case.
        $bn = optional_param('backup_name', '', PARAM_FILE);
        if (!empty($bn)) {
            $preferences->backup_name = $bn;
        }
        $count = 1;
        return true;
    }
    if ($allmods = get_records("modules")) {
        foreach ($allmods as $mod) {
            $modname = $mod->name;
            $modfile = "{$CFG->dirroot}/mod/{$modname}/backuplib.php";
            $modbackup = $modname . "_backup_mods";
            $modbackupone = $modname . "_backup_one_mod";
            $modcheckbackup = $modname . "_check_backup_mods";
            if (!file_exists($modfile)) {
                continue;
            }
            include_once $modfile;
            if (!function_exists($modbackup) || !function_exists($modcheckbackup)) {
                continue;
            }
            $var = "exists_" . $modname;
            $preferences->{$var} = true;
            $count++;
            // check that there are instances and we can back them up individually
            if (!count_records('course_modules', 'course', $course->id, 'module', $mod->id) || !function_exists($modbackupone)) {
                continue;
            }
            $var = 'exists_one_' . $modname;
            $preferences->{$var} = true;
            $varname = $modname . '_instances';
            $preferences->{$varname} = get_all_instances_in_course($modname, $course, NULL, true);
            foreach ($preferences->{$varname} as $instance) {
                $preferences->mods[$modname]->instances[$instance->id]->name = $instance->name;
                $var = 'backup_' . $modname . '_instance_' . $instance->id;
                ${$var} = optional_param($var, 0);
                $preferences->{$var} = ${$var};
                $preferences->mods[$modname]->instances[$instance->id]->backup = ${$var};
                $var = 'backup_user_info_' . $modname . '_instance_' . $instance->id;
                ${$var} = optional_param($var, 0);
                $preferences->{$var} = ${$var};
                $preferences->mods[$modname]->instances[$instance->id]->userinfo = ${$var};
                $var = 'backup_' . $modname . '_instances';
                $preferences->{$var} = 1;
                // we need this later to determine what to display in modcheckbackup.
            }
            //Check data
            //Check module info
            $preferences->mods[$modname]->name = $modname;
            $var = "backup_" . $modname;
            ${$var} = optional_param($var, 0);
            $preferences->{$var} = ${$var};
            $preferences->mods[$modname]->backup = ${$var};
            //Check include user info
            $var = "backup_user_info_" . $modname;
            ${$var} = optional_param($var, 0);
            $preferences->{$var} = ${$var};
            $preferences->mods[$modname]->userinfo = ${$var};
        }
    }
    //Check other parameters
    $preferences->backup_metacourse = optional_param('backup_metacourse', 1, PARAM_INT);
    $preferences->backup_users = optional_param('backup_users', 1, PARAM_INT);
    $preferences->backup_logs = optional_param('backup_logs', 0, PARAM_INT);
    $preferences->backup_user_files = optional_param('backup_user_files', 1, PARAM_INT);
    $preferences->backup_course_files = optional_param('backup_course_files', 1, PARAM_INT);
    $preferences->backup_gradebook_history = optional_param('backup_gradebook_history', 1, PARAM_INT);
    $preferences->backup_site_files = optional_param('backup_site_files', 1, PARAM_INT);
    $preferences->backup_messages = optional_param('backup_messages', 1, PARAM_INT);
    $preferences->backup_blogs = optional_param('backup_blogs', 1, PARAM_INT);
    $preferences->backup_course = $course->id;
    $preferences->backup_name = required_param('backup_name', PARAM_FILE);
    $preferences->backup_unique_code = required_param('backup_unique_code');
    $roles = get_records('role', '', '', 'sortorder');
    $preferences->backuproleassignments = array();
    foreach ($roles as $role) {
        if (optional_param('backupassignments_' . $role->shortname, 0, PARAM_INT)) {
            $preferences->backuproleassignments[$role->id] = $role;
        }
    }
    // put it (back) in the session
    $SESSION->backupprefs[$course->id] = $preferences;
}
Exemplo n.º 18
0
$strname = get_string("name");
$strsummary = get_string("summary");
$strreport = get_string("report", 'scorm');
$strlastmodified = get_string("lastmodified");
$PAGE->set_title($strscorms);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add($strscorms);
echo $OUTPUT->header();
echo $OUTPUT->heading($strscorms);
$usesections = course_format_uses_sections($course->format);
if ($usesections) {
    $sortorder = "cw.section ASC";
} else {
    $sortorder = "m.timemodified DESC";
}
if (!($scorms = get_all_instances_in_course("scorm", $course))) {
    notice(get_string('thereareno', 'moodle', $strscorms), "../../course/view.php?id={$course->id}");
    exit;
}
$table = new html_table();
if ($usesections) {
    $strsectionname = get_string('sectionname', 'format_' . $course->format);
    $table->head = array($strsectionname, $strname, $strsummary, $strreport);
    $table->align = array("center", "left", "left", "left");
} else {
    $table->head = array($strlastmodified, $strname, $strsummary, $strreport);
    $table->align = array("left", "left", "left", "left");
}
foreach ($scorms as $scorm) {
    $context = context_module::instance($scorm->coursemodule);
    $tt = "";
Exemplo n.º 19
0
// course
if (!($course = get_record("course", "id", $id))) {
    error("Course ID is incorrect");
}
require_login($course->id);
add_to_log($course->id, "lams", "view all", "index.php?id={$course->id}", "");
/// Get all required strings
$strlamss = get_string("modulenameplural", "lams");
$strlams = get_string("modulename", "lams");
/// Print the header
if ($course->id != SITEID) {
    $navigation = "<a href=\"../../course/view.php?id={$course->id}\">{$course->shortname}</a> ->";
}
print_header("{$course->shortname}: {$strlamss}", $course->fullname, "{$navigation} {$strlamss}", "", "", true, "", navmenu($course));
/// Get all the appropriate data
if (!($lamss = get_all_instances_in_course("lams", $course))) {
    notice("There are no lams", "../../course/view.php?id={$course->id}");
    die;
}
/// Print the list of instances (your module will probably extend this)
$timenow = time();
$strname = get_string("name");
$strweek = get_string("week");
$strtopic = get_string("topic");
if ($course->format == "weeks") {
    $table->head = array($strweek, $strname);
    $table->align = array('center', 'left');
} else {
    if ($course->format == "topics") {
        $table->head = array($strtopic, $strname);
        $table->align = array('center', 'left', 'left', 'left');
Exemplo n.º 20
0
$id = required_param('id', PARAM_INT);
// course
if (!($course = get_record("course", "id", $id))) {
    error("Course ID is incorrect");
}
require_course_login($course);
add_to_log($course->id, "journal", "view all", "index.php?id={$course->id}", "");
$strjournal = get_string("modulename", "journal");
$strjournals = get_string("modulenameplural", "journal");
$strweek = get_string("week");
$strtopic = get_string("topic");
$navlinks = array();
$navlinks[] = array('name' => $strjournals, 'link' => '', 'type' => 'activity');
$navigation = build_navigation($navlinks);
print_header_simple("{$strjournals}", "", $navigation, "", "", true, "", navmenu($course));
if (!($journals = get_all_instances_in_course("journal", $course))) {
    notice(get_string('thereareno', 'moodle', $strjournals), "../../course/view.php?id={$course->id}");
    die;
}
$timenow = time();
if ($course->format == "weeks") {
    $strsection = $strweek;
} else {
    if ($course->format == "topics") {
        $strsection = $strtopic;
    } else {
        $strsection = "";
    }
}
foreach ($journals as $journal) {
    $journal->timestart = $course->startdate + ($journal->section - 1) * 608400;
Exemplo n.º 21
0
$timenow = time();
// Strings used multiple times
$strcertificates = get_string('modulenameplural', 'certificate');
$strissued = get_string('issued', 'certificate');
$strname = get_string("name");
$strsectionname = get_string('sectionname', 'format_' . $course->format);
// Print the header
$PAGE->set_pagelayout('incourse');
$PAGE->set_url('/mod/certificate/index.php', array('id' => $course->id));
$PAGE->navbar->add($strcertificates);
$PAGE->set_title($strcertificates);
$PAGE->set_heading($course->fullname);
// Add the page view to the Moodle log
add_to_log($course->id, 'certificate', 'view all', 'index.php?id=' . $course->id, '');
// Get the certificates, if there are none display a notice
if (!($certificates = get_all_instances_in_course('certificate', $course))) {
    echo $OUTPUT->header();
    notice(get_string('nocertificates', 'certificate'), "{$CFG->wwwroot}/course/view.php?id={$course->id}");
    echo $OUTPUT->footer();
    exit;
}
if ($usesections = course_format_uses_sections($course->format)) {
    $sections = get_all_sections($course->id);
}
$table = new html_table();
if ($usesections) {
    $table->head = array($strsectionname, $strname, $strissued);
} else {
    $table->head = array($strname, $strissued);
}
foreach ($certificates as $certificate) {
Exemplo n.º 22
0
/**
* Function to generate the $preferences variable that
* backup uses.  This will back up all modules and instances in a course.
*
* @param object $course course object
* @param array $prefs can contain:
        backup_metacourse
        backup_users
        backup_logs
        backup_user_files
        backup_course_files
        backup_site_files
        backup_messages
* and if not provided, they will not be included.
*/
function backup_generate_preferences_artificially($course, $prefs)
{
    global $CFG, $DB;
    $preferences = new StdClass();
    $preferences->backup_unique_code = time();
    $preferences->backup_users = isset($prefs['backup_users']) ? $prefs['backup_users'] : 0;
    $preferences->backup_name = backup_get_zipfile_name($course, $preferences->backup_unique_code);
    $count = 0;
    if ($allmods = $DB->get_records("modules")) {
        foreach ($allmods as $mod) {
            $modname = $mod->name;
            $modfile = "{$CFG->dirroot}/mod/{$modname}/backuplib.php";
            $modbackup = $modname . "_backup_mods";
            $modbackupone = $modname . "_backup_one_mod";
            $modcheckbackup = $modname . "_check_backup_mods";
            if (!file_exists($modfile)) {
                continue;
            }
            include_once $modfile;
            if (!function_exists($modbackup) || !function_exists($modcheckbackup)) {
                continue;
            }
            $modcheckbackup($course->id, $preferences->backup_users, $preferences->backup_unique_code);
            $var = "exists_" . $modname;
            $preferences->{$var} = true;
            $count++;
            // check that there are instances and we can back them up individually
            if (!$DB->count_records('course_modules', array('course' => $course->id), array('module' => $mod->id)) || !function_exists($modbackupone)) {
                continue;
            }
            $var = 'exists_one_' . $modname;
            $preferences->{$var} = true;
            $varname = $modname . '_instances';
            $preferences->{$varname} = get_all_instances_in_course($modname, $course, NULL, true);
            foreach ($preferences->{$varname} as $instance) {
                $preferences->mods[$modname]->instances[$instance->id]->name = $instance->name;
                $var = 'backup_' . $modname . '_instance_' . $instance->id;
                $preferences->{$var} = true;
                $preferences->mods[$modname]->instances[$instance->id]->backup = true;
                $var = 'backup_user_info_' . $modname . '_instance_' . $instance->id;
                $preferences->{$var} = true;
                $preferences->mods[$modname]->instances[$instance->id]->userinfo = true;
                $var = 'backup_' . $modname . '_instances';
                $preferences->{$var} = 1;
                // we need this later to determine what to display in modcheckbackup.
            }
            //Check data
            //Check module info
            $preferences->mods[$modname]->name = $modname;
            $var = "backup_" . $modname;
            $preferences->{$var} = true;
            $preferences->mods[$modname]->backup = true;
            //Check include user info
            $var = "backup_user_info_" . $modname;
            $preferences->{$var} = true;
            $preferences->mods[$modname]->userinfo = true;
        }
    }
    //Check other parameters
    $preferences->backup_metacourse = isset($prefs['backup_metacourse']) ? $prefs['backup_metacourse'] : 0;
    $preferences->backup_logs = isset($prefs['backup_logs']) ? $prefs['backup_logs'] : 0;
    $preferences->backup_user_files = isset($prefs['backup_user_files']) ? $prefs['backup_user_files'] : 0;
    $preferences->backup_course_files = isset($prefs['backup_course_files']) ? $prefs['backup_course_files'] : 0;
    $preferences->backup_site_files = isset($prefs['backup_site_files']) ? $prefs['backup_site_files'] : 0;
    $preferences->backup_messages = isset($prefs['backup_messages']) ? $prefs['backup_messages'] : 0;
    $preferences->backup_gradebook_history = isset($prefs['backup_gradebook_history']) ? $prefs['backup_gradebook_history'] : 0;
    $preferences->backup_blogs = isset($prefs['backup_blogs']) ? $prefs['backup_blogs'] : 0;
    $preferences->backup_course = $course->id;
    //Check users
    user_check_backup($course->id, $preferences->backup_unique_code, $preferences->backup_users, $preferences->backup_messages, $preferences->backup_blogs);
    //Check logs
    log_check_backup($course->id);
    //Check user files
    user_files_check_backup($course->id, $preferences->backup_unique_code);
    //Check course files
    course_files_check_backup($course->id, $preferences->backup_unique_code);
    //Check site files
    site_files_check_backup($course->id, $preferences->backup_unique_code);
    //Role assignments
    $roles = get_records('role', '', '', 'sortorder');
    foreach ($roles as $role) {
        $preferences->backuproleassignments[$role->id] = $role;
    }
    backup_add_static_preferences($preferences);
    return $preferences;
}
Exemplo n.º 23
0
/**
 * Add subscriptions for new users
 *
 * @global object
 * @uses CONTEXT_SYSTEM
 * @uses CONTEXT_COURSE
 * @uses CONTEXT_COURSECAT
 * @uses FORUM_INITIALSUBSCRIBE
 * @param int $userid
 * @param object $context
 * @return bool
 */
function forum_add_user_default_subscriptions($userid, $context) {
    global $DB;
    if (empty($context->contextlevel)) {
        return false;
    }

    switch ($context->contextlevel) {

        case CONTEXT_SYSTEM:   // For the whole site
             $rs = $DB->get_recordset('course',null,'','id');
             foreach ($rs as $course) {
                 $subcontext = get_context_instance(CONTEXT_COURSE, $course->id);
                 forum_add_user_default_subscriptions($userid, $subcontext);
             }
             $rs->close();
             break;

        case CONTEXT_COURSECAT:   // For a whole category
             $rs = $DB->get_recordset('course', array('category' => $context->instanceid),'','id');
             foreach ($rs as $course) {
                 $subcontext = get_context_instance(CONTEXT_COURSE, $course->id);
                 forum_add_user_default_subscriptions($userid, $subcontext);
             }
             $rs->close();
             if ($categories = $DB->get_records('course_categories', array('parent' => $context->instanceid))) {
                 foreach ($categories as $category) {
                     $subcontext = get_context_instance(CONTEXT_COURSECAT, $category->id);
                     forum_add_user_default_subscriptions($userid, $subcontext);
                 }
             }
             break;


        case CONTEXT_COURSE:   // For a whole course
             if (is_enrolled($context, $userid)) {
                if ($course = $DB->get_record('course', array('id' => $context->instanceid))) {
                     if ($forums = get_all_instances_in_course('forum', $course, $userid, false)) {
                         foreach ($forums as $forum) {
                             if ($forum->forcesubscribe != FORUM_INITIALSUBSCRIBE) {
                                 continue;
                             }
                             if ($modcontext = get_context_instance(CONTEXT_MODULE, $forum->coursemodule)) {
                                 if (has_capability('mod/forum:viewdiscussion', $modcontext, $userid)) {
                                     forum_subscribe($userid, $forum->id);
                                 }
                             }
                         }
                     }
                 }
             }
             break;

        case CONTEXT_MODULE:   // Just one forum
            if (has_capability('mod/forum:initialsubscriptions', $context, $userid)) {
                 if ($cm = get_coursemodule_from_id('forum', $context->instanceid)) {
                     if ($forum = $DB->get_record('forum', array('id' => $cm->instance))) {
                         if ($forum->forcesubscribe != FORUM_INITIALSUBSCRIBE) {
                             continue;
                         }
                         if (has_capability('mod/forum:viewdiscussion', $context, $userid)) {
                             forum_subscribe($userid, $forum->id);
                         }
                     }
                 }
            }
            break;
    }

    return true;
}
Exemplo n.º 24
0
    $generaltable->align[] = 'center';
}
if ($can_subscribe = has_capability('moodle/course:view', $coursecontext)) {
    $generaltable->head[] = $strsubscribed;
    $generaltable->align[] = 'center';
}
if ($show_rss = ($can_subscribe || $course->id == SITEID) && isset($CFG->enablerssfeeds) && isset($CFG->forum_enablerssfeeds) && $CFG->enablerssfeeds && $CFG->forum_enablerssfeeds) {
    $generaltable->head[] = $strrss;
    $generaltable->align[] = 'center';
}
// Parse and organise all the forums.  Most forums are course modules but
// some special ones are not.  These get placed in the general forums
// category with the forums in section 0.
$generalforums = array();
// For now
$learningforums = get_all_instances_in_course("forum", $course);
if ($forums = get_records("forum", "course", $id, "name ASC")) {
    // All known forums
    if ($learningforums) {
        // Copy "full" data into this complete array
        foreach ($learningforums as $key => $learningforum) {
            $learningforum->keyreference = $key;
            $forums[$learningforum->id] = $learningforum;
        }
    }
    foreach ($forums as $forum) {
        $cm = get_coursemodule_from_instance("forum", $forum->id, $course->id);
        $context = get_context_instance(CONTEXT_MODULE, $cm->id);
        if (!has_capability('mod/forum:viewdiscussion', $context)) {
            if (isset($forum->keyreference)) {
                unset($learningforums[$forum->keyreference]);
Exemplo n.º 25
0
 function definition()
 {
     global $CFG, $COURSE, $DB;
     $mform = $this->_form;
     $config = get_config('lesson');
     $mform->addElement('header', 'general', get_string('general', 'form'));
     /** Legacy slideshow width element to maintain backwards compatibility */
     $mform->addElement('hidden', 'width');
     $mform->setType('width', PARAM_INT);
     $mform->setDefault('width', $CFG->lesson_slideshowwidth);
     /** Legacy slideshow height element to maintain backwards compatibility */
     $mform->addElement('hidden', 'height');
     $mform->setType('height', PARAM_INT);
     $mform->setDefault('height', $CFG->lesson_slideshowheight);
     /** Legacy slideshow background color element to maintain backwards compatibility */
     $mform->addElement('hidden', 'bgcolor');
     $mform->setType('bgcolor', PARAM_TEXT);
     $mform->setDefault('bgcolor', $CFG->lesson_slideshowbgcolor);
     /** Legacy media popup width element to maintain backwards compatibility */
     $mform->addElement('hidden', 'mediawidth');
     $mform->setType('mediawidth', PARAM_INT);
     $mform->setDefault('mediawidth', $CFG->lesson_mediawidth);
     /** Legacy media popup height element to maintain backwards compatibility */
     $mform->addElement('hidden', 'mediaheight');
     $mform->setType('mediaheight', PARAM_INT);
     $mform->setDefault('mediaheight', $CFG->lesson_mediaheight);
     /** Legacy media popup close button element to maintain backwards compatibility */
     $mform->addElement('hidden', 'mediaclose');
     $mform->setType('mediaclose', PARAM_BOOL);
     $mform->setDefault('mediaclose', $CFG->lesson_mediaclose);
     $mform->addElement('text', 'name', get_string('name'), array('size' => '64'));
     if (!empty($CFG->formatstringstriptags)) {
         $mform->setType('name', PARAM_TEXT);
     } else {
         $mform->setType('name', PARAM_CLEANHTML);
     }
     $mform->addRule('name', null, 'required', null, 'client');
     $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
     $this->standard_intro_elements();
     // Appearance.
     $mform->addElement('header', 'appearancehdr', get_string('appearance'));
     $filemanageroptions = array();
     $filemanageroptions['filetypes'] = '*';
     $filemanageroptions['maxbytes'] = $this->course->maxbytes;
     $filemanageroptions['subdirs'] = 0;
     $filemanageroptions['maxfiles'] = 1;
     $mform->addElement('filemanager', 'mediafile', get_string('mediafile', 'lesson'), null, $filemanageroptions);
     $mform->addHelpButton('mediafile', 'mediafile', 'lesson');
     $mform->addElement('selectyesno', 'progressbar', get_string('progressbar', 'lesson'));
     $mform->addHelpButton('progressbar', 'progressbar', 'lesson');
     $mform->setDefault('progressbar', 0);
     $mform->addElement('selectyesno', 'ongoing', get_string('ongoing', 'lesson'));
     $mform->addHelpButton('ongoing', 'ongoing', 'lesson');
     $mform->setDefault('ongoing', 0);
     $mform->addElement('selectyesno', 'displayleft', get_string('displayleftmenu', 'lesson'));
     $mform->addHelpButton('displayleft', 'displayleftmenu', 'lesson');
     $mform->setDefault('displayleft', 0);
     $options = array();
     for ($i = 100; $i >= 0; $i--) {
         $options[$i] = $i . '%';
     }
     $mform->addElement('select', 'displayleftif', get_string('displayleftif', 'lesson'), $options);
     $mform->addHelpButton('displayleftif', 'displayleftif', 'lesson');
     $mform->setDefault('displayleftif', 0);
     $mform->addElement('selectyesno', 'slideshow', get_string('slideshow', 'lesson'));
     $mform->addHelpButton('slideshow', 'slideshow', 'lesson');
     $mform->setDefault('slideshow', 0);
     $numbers = array();
     for ($i = 20; $i > 1; $i--) {
         $numbers[$i] = $i;
     }
     $mform->addElement('select', 'maxanswers', get_string('maximumnumberofanswersbranches', 'lesson'), $numbers);
     $mform->setDefault('maxanswers', $CFG->lesson_maxanswers);
     $mform->setType('maxanswers', PARAM_INT);
     $mform->addHelpButton('maxanswers', 'maximumnumberofanswersbranches', 'lesson');
     $mform->addElement('selectyesno', 'feedback', get_string('displaydefaultfeedback', 'lesson'));
     $mform->addHelpButton('feedback', 'displaydefaultfeedback', 'lesson');
     $mform->setDefault('feedback', 0);
     // Get the modules.
     if ($mods = get_course_mods($COURSE->id)) {
         $modinstances = array();
         foreach ($mods as $mod) {
             // Get the module name and then store it in a new array.
             if ($module = get_coursemodule_from_instance($mod->modname, $mod->instance, $COURSE->id)) {
                 // Exclude this lesson, if it's already been saved.
                 if (!isset($this->_cm->id) || $this->_cm->id != $mod->id) {
                     $modinstances[$mod->id] = $mod->modname . ' - ' . $module->name;
                 }
             }
         }
         asort($modinstances);
         // Sort by module name.
         $modinstances = array(0 => get_string('none')) + $modinstances;
         $mform->addElement('select', 'activitylink', get_string('activitylink', 'lesson'), $modinstances);
         $mform->addHelpButton('activitylink', 'activitylink', 'lesson');
         $mform->setDefault('activitylink', 0);
     }
     // Availability.
     $mform->addElement('header', 'availabilityhdr', get_string('availability'));
     $mform->addElement('date_time_selector', 'available', get_string('available', 'lesson'), array('optional' => true));
     $mform->setDefault('available', 0);
     $mform->addElement('date_time_selector', 'deadline', get_string('deadline', 'lesson'), array('optional' => true));
     $mform->setDefault('deadline', 0);
     // Time limit.
     $mform->addElement('duration', 'timelimit', get_string('timelimit', 'lesson'), array('optional' => true));
     $mform->addHelpButton('timelimit', 'timelimit', 'lesson');
     $mform->addElement('selectyesno', 'usepassword', get_string('usepassword', 'lesson'));
     $mform->addHelpButton('usepassword', 'usepassword', 'lesson');
     $mform->setDefault('usepassword', 0);
     $mform->addElement('passwordunmask', 'password', get_string('password', 'lesson'));
     $mform->setDefault('password', '');
     $mform->setType('password', PARAM_RAW);
     $mform->disabledIf('password', 'usepassword', 'eq', 0);
     $mform->disabledIf('passwordunmask', 'usepassword', 'eq', 0);
     // Dependent on.
     if ($this->current && isset($this->current->dependency) && $this->current->dependency) {
         $mform->addElement('header', 'dependencyon', get_string('prerequisitelesson', 'lesson'));
         $mform->addElement('static', 'warningobsolete', get_string('warning', 'lesson'), get_string('prerequisiteisobsolete', 'lesson'));
         $options = array(0 => get_string('none'));
         if ($lessons = get_all_instances_in_course('lesson', $COURSE)) {
             foreach ($lessons as $lesson) {
                 if ($lesson->id != $this->_instance) {
                     $options[$lesson->id] = format_string($lesson->name, true);
                 }
             }
         }
         $mform->addElement('select', 'dependency', get_string('dependencyon', 'lesson'), $options);
         $mform->addHelpButton('dependency', 'dependencyon', 'lesson');
         $mform->setDefault('dependency', 0);
         $mform->addElement('text', 'timespent', get_string('timespentminutes', 'lesson'));
         $mform->setDefault('timespent', 0);
         $mform->setType('timespent', PARAM_INT);
         $mform->disabledIf('timespent', 'dependency', 'eq', 0);
         $mform->addElement('checkbox', 'completed', get_string('completed', 'lesson'));
         $mform->setDefault('completed', 0);
         $mform->disabledIf('completed', 'dependency', 'eq', 0);
         $mform->addElement('text', 'gradebetterthan', get_string('gradebetterthan', 'lesson'));
         $mform->setDefault('gradebetterthan', 0);
         $mform->setType('gradebetterthan', PARAM_INT);
         $mform->disabledIf('gradebetterthan', 'dependency', 'eq', 0);
     } else {
         $mform->addElement('hidden', 'dependency', 0);
         $mform->setType('dependency', PARAM_INT);
         $mform->addElement('hidden', 'timespent', 0);
         $mform->setType('timespent', PARAM_INT);
         $mform->addElement('hidden', 'completed', 0);
         $mform->setType('completed', PARAM_INT);
         $mform->addElement('hidden', 'gradebetterthan', 0);
         $mform->setType('gradebetterthan', PARAM_INT);
         $mform->setConstants(array('dependency' => 0, 'timespent' => 0, 'completed' => 0, 'gradebetterthan' => 0));
     }
     // Flow control.
     $mform->addElement('header', 'flowcontrol', get_string('flowcontrol', 'lesson'));
     $mform->addElement('selectyesno', 'modattempts', get_string('modattempts', 'lesson'));
     $mform->addHelpButton('modattempts', 'modattempts', 'lesson');
     $mform->setDefault('modattempts', 0);
     $mform->addElement('selectyesno', 'review', get_string('displayreview', 'lesson'));
     $mform->addHelpButton('review', 'displayreview', 'lesson');
     $mform->setDefault('review', 0);
     $numbers = array();
     for ($i = 10; $i > 0; $i--) {
         $numbers[$i] = $i;
     }
     $mform->addElement('select', 'maxattempts', get_string('maximumnumberofattempts', 'lesson'), $numbers);
     $mform->addHelpButton('maxattempts', 'maximumnumberofattempts', 'lesson');
     $mform->setDefault('maxattempts', 1);
     $defaultnextpages = array();
     $defaultnextpages[0] = get_string('normal', 'lesson');
     $defaultnextpages[LESSON_UNSEENPAGE] = get_string('showanunseenpage', 'lesson');
     $defaultnextpages[LESSON_UNANSWEREDPAGE] = get_string('showanunansweredpage', 'lesson');
     $mform->addElement('select', 'nextpagedefault', get_string('actionaftercorrectanswer', 'lesson'), $defaultnextpages);
     $mform->addHelpButton('nextpagedefault', 'actionaftercorrectanswer', 'lesson');
     $mform->setDefault('nextpagedefault', $CFG->lesson_defaultnextpage);
     $numbers = array();
     for ($i = 100; $i >= 0; $i--) {
         $numbers[$i] = $i;
     }
     $mform->addElement('select', 'maxpages', get_string('numberofpagestoshow', 'lesson'), $numbers);
     $mform->addHelpButton('maxpages', 'numberofpagestoshow', 'lesson');
     $mform->setDefault('maxpages', 0);
     // Grade.
     $this->standard_grading_coursemodule_elements();
     // No header here, so that the following settings are displayed in the grade section.
     $mform->addElement('selectyesno', 'practice', get_string('practice', 'lesson'));
     $mform->addHelpButton('practice', 'practice', 'lesson');
     $mform->setDefault('practice', 0);
     $mform->addElement('selectyesno', 'custom', get_string('customscoring', 'lesson'));
     $mform->addHelpButton('custom', 'customscoring', 'lesson');
     $mform->setDefault('custom', 1);
     $mform->addElement('selectyesno', 'retake', get_string('retakesallowed', 'lesson'));
     $mform->addHelpButton('retake', 'retakesallowed', 'lesson');
     $mform->setDefault('retake', 0);
     $options = array();
     $options[0] = get_string('usemean', 'lesson');
     $options[1] = get_string('usemaximum', 'lesson');
     $mform->addElement('select', 'usemaxgrade', get_string('handlingofretakes', 'lesson'), $options);
     $mform->addHelpButton('usemaxgrade', 'handlingofretakes', 'lesson');
     $mform->setDefault('usemaxgrade', 0);
     $mform->disabledIf('usemaxgrade', 'retake', 'eq', '0');
     $numbers = array();
     for ($i = 100; $i >= 0; $i--) {
         $numbers[$i] = $i;
     }
     $mform->addElement('select', 'minquestions', get_string('minimumnumberofquestions', 'lesson'), $numbers);
     $mform->addHelpButton('minquestions', 'minimumnumberofquestions', 'lesson');
     $mform->setDefault('minquestions', 0);
     //-------------------------------------------------------------------------------
     $this->standard_coursemodule_elements();
     //-------------------------------------------------------------------------------
     // buttons
     $this->add_action_buttons();
 }
Exemplo n.º 26
0
$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
require_course_login($course, true);
add_to_log($course->id, 'folder', 'view all', "index.php?id={$course->id}", '');
$strfolder = get_string('modulename', 'folder');
$strfolders = get_string('modulenameplural', 'folder');
$strweek = get_string('week');
$strtopic = get_string('topic');
$strname = get_string('name');
$strintro = get_string('moduleintro');
$strlastmodified = get_string('lastmodified');
$PAGE->set_url('mod/folder/index.php', array('id' => $course->id));
$PAGE->set_title($course->shortname . ': ' . $strfolders);
$PAGE->set_heading($course->fullname);
$navlinks = array(array('name' => $strfolders, 'link' => '', 'type' => 'activityinstance'));
echo $OUTPUT->header(build_navigation($navlinks), navmenu($course));
if (!($folders = get_all_instances_in_course('folder', $course))) {
    notice(get_string('thereareno', 'moodle', $strfolders), "{$CFG->wwwroot}/course/view.php?id={$course->id}");
    exit;
}
$table = new html_table();
$table->set_classes(array('generaltable', 'mod_index'));
if ($course->format == 'weeks') {
    $table->head = array($strweek, $strname, $strintro);
    $table->align = array('center', 'left', 'left');
} else {
    if ($course->format == 'topics') {
        $table->head = array($strtopic, $strname, $strintro);
        $table->align = array('center', 'left', 'left');
    } else {
        $table->head = array($strlastmodified, $strname, $strintro);
        $table->align = array('left', 'left', 'left');
Exemplo n.º 27
0
require_course_login($course);
$PAGE->set_pagelayout('incourse');
$params = array('context' => context_course::instance($id));
$event = \mod_chat\event\instances_list_viewed::create($params);
$event->trigger();
/// Get all required strings
$strchats = get_string('modulenameplural', 'chat');
$strchat = get_string('modulename', 'chat');
/// Print the header
$PAGE->navbar->add($strchats);
$PAGE->set_title($strchats);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
echo $OUTPUT->heading($strchats, 2);
/// Get all the appropriate data
if (!($chats = get_all_instances_in_course('chat', $course))) {
    notice(get_string('thereareno', 'moodle', $strchats), "../../course/view.php?id={$course->id}");
    die;
}
$usesections = course_format_uses_sections($course->format);
/// Print the list of instances (your module will probably extend this)
$timenow = time();
$strname = get_string('name');
$table = new html_table();
if ($usesections) {
    $strsectionname = get_string('sectionname', 'format_' . $course->format);
    $table->head = array($strsectionname, $strname);
    $table->align = array('center', 'left');
} else {
    $table->head = array($strname);
    $table->align = array('left');
Exemplo n.º 28
0
 public function test_get_all_instances_in_course()
 {
     global $CFG;
     $this->resetAfterTest();
     $this->setAdminUser();
     // Some generators have bogus access control.
     $this->assertFileExists("{$CFG->dirroot}/mod/folder/lib.php");
     $this->assertFileExists("{$CFG->dirroot}/mod/glossary/lib.php");
     $course1 = $this->getDataGenerator()->create_course();
     $course2 = $this->getDataGenerator()->create_course();
     $course3 = $this->getDataGenerator()->create_course();
     $folder1a = $this->getDataGenerator()->create_module('folder', array('course' => $course1, 'section' => 3));
     $folder1b = $this->getDataGenerator()->create_module('folder', array('course' => $course1));
     $glossary1 = $this->getDataGenerator()->create_module('glossary', array('course' => $course1));
     $folder2 = $this->getDataGenerator()->create_module('folder', array('course' => $course2));
     $glossary2a = $this->getDataGenerator()->create_module('glossary', array('course' => $course2));
     $glossary2b = $this->getDataGenerator()->create_module('glossary', array('course' => $course2));
     $folder3 = $this->getDataGenerator()->create_module('folder', array('course' => $course3));
     $modules = get_all_instances_in_course('folder', $course1);
     $this->assertCount(2, $modules);
     foreach ($modules as $cm) {
         if ($folder1a->cmid == $cm->coursemodule) {
             $folder = $folder1a;
         } else {
             if ($folder1b->cmid == $cm->coursemodule) {
                 $folder = $folder1b;
             } else {
                 $this->fail('Unexpected cm' . $cm->coursemodule);
             }
         }
         $this->assertSame($folder->name, $cm->name);
         $this->assertSame($folder->course, $cm->course);
     }
     try {
         get_all_instances_in_course('a b', $course1);
         $this->fail('coding_exception expected');
     } catch (moodle_exception $e) {
         $this->assertInstanceOf('coding_exception', $e);
     }
     try {
         get_all_instances_in_course('', $course1);
         $this->fail('coding_exception expected');
     } catch (moodle_exception $e) {
         $this->assertInstanceOf('coding_exception', $e);
     }
 }
Exemplo n.º 29
0
require_course_login($course, true);
$PAGE->set_pagelayout('incourse');
// Get all required strings
$strbooks = get_string('modulenameplural', 'mod_book');
$strbook = get_string('modulename', 'mod_book');
$strname = get_string('name');
$strintro = get_string('moduleintro');
$strlastmodified = get_string('lastmodified');
$PAGE->set_url('/mod/book/index.php', array('id' => $course->id));
$PAGE->set_title($course->shortname . ': ' . $strbooks);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add($strbooks);
echo $OUTPUT->header();
\mod_book\event\course_module_instance_list_viewed::create_from_course($course)->trigger();
// Get all the appropriate data
if (!($books = get_all_instances_in_course('book', $course))) {
    notice(get_string('thereareno', 'moodle', $strbooks), "{$CFG->wwwroot}/course/view.php?id={$course->id}");
    die;
}
$usesections = course_format_uses_sections($course->format);
$table = new html_table();
$table->attributes['class'] = 'generaltable mod_index';
if ($usesections) {
    $strsectionname = get_string('sectionname', 'format_' . $course->format);
    $table->head = array($strsectionname, $strname, $strintro);
    $table->align = array('center', 'left', 'left');
} else {
    $table->head = array($strlastmodified, $strname, $strintro);
    $table->align = array('left', 'left', 'left');
}
$modinfo = get_fast_modinfo($course);
Exemplo n.º 30
0
$coursecontext = get_context_instance(CONTEXT_COURSE, $id);
require_login($course->id);
add_to_log($course->id, "quiz", "view all", "index.php?id={$course->id}", "");
// Print the header
$strquizzes = get_string("modulenameplural", "quiz");
$streditquestions = '';
$editqcontexts = new question_edit_contexts($coursecontext);
if ($editqcontexts->have_one_edit_tab_cap('questions')) {
    $streditquestions = "<form target=\"_parent\" method=\"get\" action=\"{$CFG->wwwroot}/question/edit.php\">\n                   <div>\n                   <input type=\"hidden\" name=\"courseid\" value=\"{$course->id}\" />\n                   <input type=\"submit\" value=\"" . get_string("editquestions", "quiz") . "\" />\n                   </div>\n                 </form>";
}
$navlinks = array();
$navlinks[] = array('name' => $strquizzes, 'link' => '', 'type' => 'activity');
$navigation = build_navigation($navlinks);
print_header_simple($strquizzes, '', $navigation, '', '', true, $streditquestions, navmenu($course));
// Get all the appropriate data
if (!($quizzes = get_all_instances_in_course("quiz", $course))) {
    notice(get_string('thereareno', 'moodle', $strquizzes), "../../course/view.php?id={$course->id}");
    die;
}
// Configure table for displaying the list of instances.
$headings = array(get_string('name'), get_string('quizcloses', 'quiz'));
$align = array('left', 'left');
if ($course->format == 'weeks' or $course->format == 'weekscss') {
    array_unshift($headings, get_string('week'));
} else {
    array_unshift($headings, get_string('section'));
}
array_unshift($align, 'center');
$showing = '';
// default
if (has_capability('mod/quiz:viewreports', $coursecontext)) {