本文整理汇总了PHP中get_all_instances_in_course函数的典型用法代码示例。如果您正苦于以下问题:PHP get_all_instances_in_course函数的具体用法?PHP get_all_instances_in_course怎么用?PHP get_all_instances_in_course使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_all_instances_in_course函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_all_assignments_in_course
/**
* 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;
}
开发者ID:sk-unikent,项目名称:moodle-mod_turnitintooltwo-1,代码行数:14,代码来源:turnitintooltwo_assignment.class.php
示例2: get_content
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 . '&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 . '&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 . '&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 . ': ' . 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') . ': ' . $percent . ' %<br />';
$this->content->text .= get_string('attendancegrade', 'attforblock') . ": {$grade}<br />";
$this->content->text .= '<a href="' . $CFG->wwwroot . '/mod/attforblock/view.php?id=' . $cmid . '">' . get_string('indetail', 'attforblock') . '</a>';
}
}
return $this->content;
}
示例3: get_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;
}
示例4: book_search_get_readble_books
/**
* 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;
}
示例5: get_content
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;
}
示例6: data_preprocessing
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;
}
}
示例7: scorm_course_format_display
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 . '&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 . '&section=0&sesskey=' . sesskey() . '&add=scorm');
} else {
notify('Could not find a scorm course here');
}
}
echo '</div>';
}
示例8: error
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
//
示例9: error
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 = '';
示例10: required_param
* 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}");
示例11: add_to_log
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");
}
}
示例12: definition
//.........这里部分代码省略.........
$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'));
示例13: get_string
$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);
示例14: get_string
/// 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");
示例15: backup_fetch_prefs_from_request
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;
}