本文整理汇总了PHP中get_coursemodules_in_course函数的典型用法代码示例。如果您正苦于以下问题:PHP get_coursemodules_in_course函数的具体用法?PHP get_coursemodules_in_course怎么用?PHP get_coursemodules_in_course使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_coursemodules_in_course函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: definition
function definition()
{
global $COURSE;
$mform =& $this->_form;
$mform->addElement('header', 'general', get_string('general', 'form'));
$options = array();
if ($quizes = get_coursemodules_in_course('quiz', $COURSE->id)) {
foreach ($quizes as $quiz) {
$options[$quiz->id] = $quiz->name;
}
}
$mform->addElement('select', 'quiz', get_string('originalquiz', 'quizcopy'), $options);
$mform->addRule('quiz', null, 'required', null, 'client');
/// Adding the standard "name" field
$mform->addElement('text', 'name', get_string('quizcopyname', 'quizcopy'), array('size' => '64'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client');
$this->standard_hidden_coursemodule_elements();
$this->add_action_buttons();
}
示例2: block_resources_get_all_resources
/**
* get all resources!
*
*/
function block_resources_get_all_resources()
{
global $DB;
// get courses list in wich logged user was enrolled
$courses = enrol_get_my_courses();
if (empty($courses)) {
return false;
}
$ids = implode(',', array_keys($courses));
// --------- cycle by courses
foreach ($courses as $key => $course) {
if (!isset($courses[$key]->resources)) {
$courses[$key]->resources = array();
}
// get videoresources list from courses and then render it
// * link to videoresource = link to course modules
$courses[$key]->videoresources = get_coursemodules_in_course('videoresource', $course->id);
}
// get resources list from all courses with AVG rating
$resources = $DB->get_records_sql('
SELECT DISTINCT rl.course * 10000 + si.id as id, si.id as section_id, rl.course, r.id as resource_id, r.url, r.title, r.internal_title, r.description, r.author, r.source
, (SELECT AVG(t.rating) FROM mdl_rating t
LEFT JOIN mdl_resource_section_items si ON si.id = t.itemid WHERE si.resource_item_id = r.id) as avgrate
FROM mdl_resourcelib rl
RIGHT JOIN mdl_resourcelib_content rc ON rl.id = rc.resourcelib_id
RIGHT JOIN mdl_resource_lists l ON rc.instance_id = l.id
RIGHT JOIN mdl_resource_list_sections ls ON l.id = ls.resource_list_id
RIGHT JOIN mdl_resource_section_items si ON ls.resource_section_id = si.resource_section_id
RIGHT JOIN mdl_resource_items r ON r.id = si.resource_item_id
WHERE rl.course IN (' . $ids . ')
ORDER BY ls.sort_order, si.sort_order');
foreach ($resources as $key => $resource) {
if (!isset($courses[$resource->course]->resources[$resource->resource_id])) {
$courses[$resource->course]->resources[$resource->resource_id] = $resource;
}
}
return $courses;
}
示例3: definition
function definition()
{
$mform =& $this->_form;
$id = $this->vpl->get_course_module()->id;
$mform->addElement('hidden', 'id', $id);
$mform->setType('id', PARAM_INT);
$mform->addElement('header', 'header_execution_options', get_string('executionoptions', VPL));
$strbasedon = get_string('basedon', VPL);
$basedonlist = array();
$basedonlist[0] = '';
$courseid = $this->vpl->get_course()->id;
$listcm = get_coursemodules_in_course(VPL, $courseid);
$instance = $this->vpl->get_instance();
$vplid = $instance->id;
foreach ($listcm as $aux) {
if ($aux->instance != $vplid) {
$vpl = new mod_vpl($aux->id);
$basedonlist[$aux->instance] = $vpl->get_printable_name();
}
}
asort($basedonlist);
$basedonlist[0] = get_string('select');
$mform->addElement('select', 'basedon', $strbasedon, $basedonlist);
$mform->setDefault('basedon', $instance->basedon);
$mform->addElement('selectyesno', 'run', get_string('run', VPL));
$mform->setDefault('run', 1);
$mform->addElement('selectyesno', 'debug', get_string('debug', VPL));
$mform->setDefault('debug', $instance->debug);
$mform->addElement('selectyesno', 'evaluate', get_string('evaluate', VPL));
$mform->setDefault('evaluate', 1);
$mform->addElement('selectyesno', 'evaluateonsubmission', get_string('evaluateonsubmission', VPL));
$mform->setDefault('evaluateonsubmission', 1);
$mform->disabledIf('evaluateonsubmission', 'evaluate', 'eq', 0);
$mform->addElement('selectyesno', 'automaticgrading', get_string('automaticgrading', VPL));
$mform->setDefault('automaticgrading', 1);
$mform->disabledIf('automaticgrading', 'evaluate', 'eq', 0);
$mform->addElement('submit', 'saveoptions', get_string('saveoptions', VPL));
}
示例4: get_assignments
/**
* Returns an array of courses the user is enrolled, and for each course all of the assignments that the user can
* view within that course.
*
* @param array $courseids An optional array of course ids. If provided only assignments within the given course
* will be returned. If the user is not enrolled in or can't view a given course a warning will be generated and returned.
* @param array $capabilities An array of additional capability checks you wish to be made on the course context.
* @param bool $includenotenrolledcourses Wheter to return courses that the user can see even if is not enroled in.
* This requires the parameter $courseids to not be empty.
* @return An array of courses and warnings.
* @since Moodle 2.4
*/
public static function get_assignments($courseids = array(), $capabilities = array(), $includenotenrolledcourses = false)
{
global $USER, $DB, $CFG;
$params = self::validate_parameters(self::get_assignments_parameters(), array('courseids' => $courseids, 'capabilities' => $capabilities, 'includenotenrolledcourses' => $includenotenrolledcourses));
$warnings = array();
$courses = array();
$fields = 'sortorder,shortname,fullname,timemodified';
// If the courseids list is empty, we return only the courses where the user is enrolled in.
if (empty($params['courseids'])) {
$courses = enrol_get_users_courses($USER->id, true, $fields);
$courseids = array_keys($courses);
} else {
if ($includenotenrolledcourses) {
// In this case, we don't have to check here for enrolmnents. Maybe the user can see the course even if is not enrolled.
$courseids = $params['courseids'];
} else {
// We need to check for enrolments.
$mycourses = enrol_get_users_courses($USER->id, true, $fields);
$mycourseids = array_keys($mycourses);
foreach ($params['courseids'] as $courseid) {
if (!in_array($courseid, $mycourseids)) {
unset($courses[$courseid]);
$warnings[] = array('item' => 'course', 'itemid' => $courseid, 'warningcode' => '2', 'message' => 'User is not enrolled or does not have requested capability');
} else {
$courses[$courseid] = $mycourses[$courseid];
}
}
$courseids = array_keys($courses);
}
}
foreach ($courseids as $cid) {
try {
$context = context_course::instance($cid);
self::validate_context($context);
// Check if this course was already loaded (by enrol_get_users_courses).
if (!isset($courses[$cid])) {
$courses[$cid] = get_course($cid);
}
$courses[$cid]->contextid = $context->id;
} catch (Exception $e) {
unset($courses[$cid]);
$warnings[] = array('item' => 'course', 'itemid' => $cid, 'warningcode' => '1', 'message' => 'No access rights in course context ' . $e->getMessage());
continue;
}
if (count($params['capabilities']) > 0 && !has_all_capabilities($params['capabilities'], $context)) {
unset($courses[$cid]);
}
}
$extrafields = 'm.id as assignmentid, ' . 'm.course, ' . 'm.nosubmissions, ' . 'm.submissiondrafts, ' . 'm.sendnotifications, ' . 'm.sendlatenotifications, ' . 'm.sendstudentnotifications, ' . 'm.duedate, ' . 'm.allowsubmissionsfromdate, ' . 'm.grade, ' . 'm.timemodified, ' . 'm.completionsubmit, ' . 'm.cutoffdate, ' . 'm.teamsubmission, ' . 'm.requireallteammemberssubmit, ' . 'm.teamsubmissiongroupingid, ' . 'm.blindmarking, ' . 'm.revealidentities, ' . 'm.attemptreopenmethod, ' . 'm.maxattempts, ' . 'm.markingworkflow, ' . 'm.markingallocation, ' . 'm.requiresubmissionstatement, ' . 'm.preventsubmissionnotingroup, ' . 'm.intro, ' . 'm.introformat';
$coursearray = array();
foreach ($courses as $id => $course) {
$assignmentarray = array();
// Get a list of assignments for the course.
if ($modules = get_coursemodules_in_course('assign', $courses[$id]->id, $extrafields)) {
foreach ($modules as $module) {
$context = context_module::instance($module->id);
try {
self::validate_context($context);
require_capability('mod/assign:view', $context);
} catch (Exception $e) {
$warnings[] = array('item' => 'module', 'itemid' => $module->id, 'warningcode' => '1', 'message' => 'No access rights in module context');
continue;
}
$assign = new assign($context, null, null);
// Get configurations for only enabled plugins.
$plugins = $assign->get_submission_plugins();
$plugins = array_merge($plugins, $assign->get_feedback_plugins());
$configarray = array();
foreach ($plugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
$configrecords = $plugin->get_config_for_external();
foreach ($configrecords as $name => $value) {
$configarray[] = array('plugin' => $plugin->get_type(), 'subtype' => $plugin->get_subtype(), 'name' => $name, 'value' => $value);
}
}
}
$assignment = array('id' => $module->assignmentid, 'cmid' => $module->id, 'course' => $module->course, 'name' => $module->name, 'nosubmissions' => $module->nosubmissions, 'submissiondrafts' => $module->submissiondrafts, 'sendnotifications' => $module->sendnotifications, 'sendlatenotifications' => $module->sendlatenotifications, 'sendstudentnotifications' => $module->sendstudentnotifications, 'duedate' => $module->duedate, 'allowsubmissionsfromdate' => $module->allowsubmissionsfromdate, 'grade' => $module->grade, 'timemodified' => $module->timemodified, 'completionsubmit' => $module->completionsubmit, 'cutoffdate' => $module->cutoffdate, 'teamsubmission' => $module->teamsubmission, 'requireallteammemberssubmit' => $module->requireallteammemberssubmit, 'teamsubmissiongroupingid' => $module->teamsubmissiongroupingid, 'blindmarking' => $module->blindmarking, 'revealidentities' => $module->revealidentities, 'attemptreopenmethod' => $module->attemptreopenmethod, 'maxattempts' => $module->maxattempts, 'markingworkflow' => $module->markingworkflow, 'markingallocation' => $module->markingallocation, 'requiresubmissionstatement' => $module->requiresubmissionstatement, 'preventsubmissionnotingroup' => $module->preventsubmissionnotingroup, 'configs' => $configarray);
// Return or not intro and file attachments depending on the plugin settings.
if ($assign->show_intro()) {
list($assignment['intro'], $assignment['introformat']) = external_format_text($module->intro, $module->introformat, $context->id, 'mod_assign', 'intro', null);
$assignment['introfiles'] = external_util::get_area_files($context->id, 'mod_assign', 'intro', false, false);
$assignment['introattachments'] = external_util::get_area_files($context->id, 'mod_assign', ASSIGN_INTROATTACHMENT_FILEAREA, 0);
}
if ($module->requiresubmissionstatement) {
// Submission statement is required, return the submission statement value.
$adminconfig = get_config('assign');
list($assignment['submissionstatement'], $assignment['submissionstatementformat']) = external_format_text($adminconfig->submissionstatement, FORMAT_MOODLE, $context->id, 'mod_assign', '', 0);
}
//.........这里部分代码省略.........
示例5: vpl_reset_userdata
/**
* This function is used by the reset_course_userdata function in moodlelib.
* This function will remove all posts from the specified vpl instance
* and clean up any related data.
* @param $data the data submitted from the reset course.
* @return array status array
*/
function vpl_reset_userdata($data)
{
global $CFG, $DB;
$status = array();
if ($data->reset_vpl_submissions) {
$componentstr = get_string('modulenameplural', VPL);
if ($cms = get_coursemodules_in_course(VPL, $data->courseid)) {
foreach ($cms as $cmid => $cm) {
//For each vpl instance in course
$vpl = new mod_vpl($cmid);
$instance = $vpl->get_instance();
//Delete submissions records
$DB->delete_records(VPL_SUBMISSIONS, array('vpl' => $instance->id));
//Delete variations assigned
$DB->delete_records(VPL_ASSIGNED_VARIATIONS, array('vpl' => $instance->id));
//Delete submission files
fulldelete($CFG->dataroot . '/vpl_data/' . $data->courseid . '/' . $instance->id . '/usersdata');
$status[] = array('component' => $componentstr, 'item' => get_string('resetvpl', VPL, $instance->name), 'error' => false);
}
}
}
return $status;
}
示例6: require_course_login
require_course_login($course);
add_to_log($course->id, "assignment", "view all", "index.php?id={$course->id}", "");
$strassignments = get_string("modulenameplural", "assignment");
$strassignment = get_string("modulename", "assignment");
$strassignmenttype = get_string("assignmenttype", "assignment");
$strweek = get_string("week");
$strtopic = get_string("topic");
$strname = get_string("name");
$strduedate = get_string("duedate", "assignment");
$strsubmitted = get_string("submitted", "assignment");
$strgrade = get_string("grade");
$navlinks = array();
$navlinks[] = array('name' => $strassignments, 'link' => '', 'type' => 'activity');
$navigation = build_navigation($navlinks);
print_header_simple($strassignments, "", $navigation, "", "", true, "", navmenu($course));
if (!($cms = get_coursemodules_in_course('assignment', $course->id, 'm.assignmenttype, m.timedue'))) {
notice(get_string('noassignments', 'assignment'), "../../course/view.php?id={$course->id}");
die;
}
$timenow = time();
if ($course->format == "weeks") {
$table->head = array($strweek, $strname, $strassignmenttype, $strduedate, $strsubmitted, $strgrade);
$table->align = array("center", "left", "left", "left", "right");
} else {
if ($course->format == "topics") {
$table->head = array($strtopic, $strname, $strassignmenttype, $strduedate, $strsubmitted, $strgrade);
$table->align = array("center", "left", "left", "left", "right");
} else {
$table->head = array($strname, $strassignmenttype, $strduedate, $strsubmitted, $strgrade);
$table->align = array("left", "left", "left", "right");
}
示例7: emarking_json_resultset
}
emarking_json_resultset($results);
} else {
if ($action === 'courses') {
$rs = get_user_capability_course($capability, $user->id);
$results = array();
foreach ($rs as $r) {
$results[] = $r;
}
emarking_json_resultset($results);
} else {
if ($action === 'activities') {
if (!($course = $DB->get_record('course', array('id' => $courseid)))) {
emarking_json_error('Invalid course id');
}
$rs = get_coursemodules_in_course('emarking', $course->id);
$results = array();
foreach ($rs as $r) {
$results[] = $r;
}
emarking_json_resultset($results);
} else {
if ($action === 'courseinfo') {
if (!($course = $DB->get_record('course', array('id' => $courseid)))) {
emarking_json_error('Invalid course id');
}
$results = array();
$results[] = $course;
emarking_json_resultset($results);
} else {
if ($action === 'coursesearch') {
示例8: RWSGUVQList
function RWSGUVQList($r_cid)
{
global $RWSUID;
$r_vqms = array();
$r_qzms = get_coursemodules_in_course("quiz", $r_cid);
if ($r_qzms === false || count($r_qzms) == 0) {
return $r_vqms;
}
foreach ($r_qzms as $r_qzm) {
if (coursemodule_visible_for_user($r_qzm, $RWSUID)) {
$r_vqms[] = $r_qzm;
}
}
return $r_vqms;
}
示例9: lockdownbrowser_MonitorActionExamSync
function lockdownbrowser_MonitorActionExamSync($parameters)
{
global $DB;
if (!isloggedin()) {
lockdownbrowser_MonitorServiceError(2004, "Must be logged in to perform the requested action");
}
if (!is_siteadmin()) {
lockdownbrowser_MonitorServiceError(2024, "Must be logged in as admin to perform the requested action");
}
if (!isset($parameters["courseRefId"]) || strlen($parameters["courseRefId"]) == 0) {
lockdownbrowser_MonitorServiceError(2025, "No courseRefId parameter was specified");
}
$course_id = intval($parameters["courseRefId"]);
$coursemodules = get_coursemodules_in_course("quiz", $course_id);
if ($coursemodules === FALSE) {
$coursemodules = array();
}
$body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
if (empty($coursemodules)) {
$body .= "<assessmentList />\r\n";
lockdownbrowser_MonitorServiceResponse("text/xml", $body, TRUE);
}
$body .= "<assessmentList>\r\n";
foreach ($coursemodules as $cm) {
$modrec = $DB->get_record("modules", array("id" => $cm->module));
if ($modrec === FALSE) {
continue;
}
$quiz = $DB->get_record($modrec->name, array("id" => $cm->instance));
if ($quiz === FALSE) {
continue;
}
$body .= "\t<assessment>\r\n";
$body .= "\t\t<id>";
$body .= utf8_encode(htmlspecialchars(trim($cm->id)));
$body .= "</id>\r\n";
$body .= "\t\t<title>";
$body .= utf8_encode(htmlspecialchars(trim($cm->name)));
$body .= "</title>\r\n";
$settings = lockdownbrowser_get_quiz_options($cm->instance);
if ($settings !== FALSE) {
$body .= "\t\t<ldbEnabled>true</ldbEnabled>\r\n";
} else {
$body .= "\t\t<ldbEnabled>false</ldbEnabled>\r\n";
}
if ($settings !== FALSE && isset($settings->password) && !is_null($settings->password) && strlen($settings->password) > 0) {
$body .= "\t\t<exitPassword>";
$body .= utf8_encode(htmlspecialchars($settings->password));
$body .= "</exitPassword>\r\n";
}
if ($settings !== FALSE && isset($settings->monitor) && !is_null($settings->monitor) && strlen($settings->monitor) > 0) {
$body .= "\t\t<monitorEnabled>true</monitorEnabled>\r\n";
$body .= "\t\t<extendedData>";
$body .= utf8_encode(htmlspecialchars($settings->monitor));
$body .= "</extendedData>\r\n";
} else {
$body .= "\t\t<monitorEnabled>false</monitorEnabled>\r\n";
}
// Moodle browser security
// popup (0=none, 1=full screen pop-up with some JavaScript security)
// Moodle 2.2.0+ (quiz module 2011100600+)
// browsersecurity ('-', 'securewindow', 'safebrowser')
// if this setting is not disabled, it will interfere with the LDB integration
if (isset($quiz->browsersecurity)) {
if ($quiz->browsersecurity != "-") {
$launch_in_new_window = TRUE;
} else {
$launch_in_new_window = FALSE;
}
} else {
if ($quiz->popup != 0) {
$launch_in_new_window = TRUE;
} else {
$launch_in_new_window = FALSE;
}
}
if ($launch_in_new_window) {
$body .= "\t\t<launchInNewWindow>true</launchInNewWindow>\r\n";
} else {
$body .= "\t\t<launchInNewWindow>false</launchInNewWindow>\r\n";
}
if ($settings !== FALSE && $launch_in_new_window) {
$body .= "\t\t<ok>false</ok>\r\n";
} else {
$body .= "\t\t<ok>true</ok>\r\n";
}
$body .= "\t</assessment>\r\n";
}
$body .= "</assessmentList>\r\n";
lockdownbrowser_MonitorServiceResponse("text/xml", $body, TRUE);
}
示例10: test_get_coursemodules_in_course
public function test_get_coursemodules_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");
$this->assertFileExists("{$CFG->dirroot}/mod/label/lib.php");
$course1 = $this->getDataGenerator()->create_course();
$course2 = $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));
$modules = get_coursemodules_in_course('folder', $course1->id);
$this->assertCount(2, $modules);
$cm = $modules[$folder1a->cmid];
$this->assertSame('folder', $cm->modname);
$this->assertSame($folder1a->id, $cm->instance);
$this->assertSame($folder1a->course, $cm->course);
$this->assertObjectNotHasAttribute('sectionnum', $cm);
$this->assertObjectNotHasAttribute('revision', $cm);
$this->assertObjectNotHasAttribute('display', $cm);
$cm = $modules[$folder1b->cmid];
$this->assertSame('folder', $cm->modname);
$this->assertSame($folder1b->id, $cm->instance);
$this->assertSame($folder1b->course, $cm->course);
$this->assertObjectNotHasAttribute('sectionnum', $cm);
$this->assertObjectNotHasAttribute('revision', $cm);
$this->assertObjectNotHasAttribute('display', $cm);
$modules = get_coursemodules_in_course('folder', $course1->id, 'revision, display');
$this->assertCount(2, $modules);
$cm = $modules[$folder1a->cmid];
$this->assertSame('folder', $cm->modname);
$this->assertSame($folder1a->id, $cm->instance);
$this->assertSame($folder1a->course, $cm->course);
$this->assertObjectNotHasAttribute('sectionnum', $cm);
$this->assertObjectHasAttribute('revision', $cm);
$this->assertObjectHasAttribute('display', $cm);
$modules = get_coursemodules_in_course('label', $course1->id);
$this->assertCount(0, $modules);
try {
get_coursemodules_in_course('a b', $course1->id);
$this->fail('coding_exception expected');
} catch (moodle_exception $e) {
$this->assertInstanceOf('coding_exception', $e);
}
try {
get_coursemodules_in_course('abc', $course1->id);
$this->fail('dml_read_exception expected');
} catch (moodle_exception $e) {
$this->assertInstanceOf('dml_read_exception', $e);
}
}
示例11: get_string
$strassignment = get_string("modulename", "assignment");
$strassignmenttype = get_string("assignmenttype", "assignment");
$strsectionname = get_string('sectionname', 'format_'.$course->format);
$strname = get_string("name");
$strduedate = get_string("duedate", "assignment");
$strsubmitted = get_string("submitted", "assignment");
$strgrade = get_string("grade");
$PAGE->set_url('/mod/assignment/index.php', array('id'=>$course->id));
$PAGE->navbar->add($strassignments);
$PAGE->set_title($strassignments);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
if (!$cms = get_coursemodules_in_course('assignment', $course->id, 'cm.idnumber, m.assignmenttype, m.timedue')) {
notice(get_string('noassignments', 'assignment'), "../../course/view.php?id=$course->id");
die;
}
$usesections = course_format_uses_sections($course->format);
if ($usesections) {
$sections = get_all_sections($course->id);
}
$timenow = time();
$table = new html_table();
if ($usesections) {
$table->head = array ($strsectionname, $strname, $strassignmenttype, $strduedate, $strsubmitted, $strgrade);
示例12: require_course_login
require_course_login($course);
$PAGE->set_pagelayout('incourse');
$event = \mod_publication\event\course_module_instance_list_viewed::create(array('context' => context_course::instance($course->id)));
$event->trigger();
$strmodulenameplural = get_string('modulenameplural', 'publication');
$strmodulname = get_string('modulename', 'publication');
$strsectionname = get_string('sectionname', 'format_' . $course->format);
$strname = get_string('name');
$strdesc = get_string('description');
$PAGE->set_url('/mod/publication/index.php', array('id' => $course->id));
$PAGE->navbar->add($strmodulenameplural);
$PAGE->set_title($strmodulenameplural);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
echo $OUTPUT->heading($strmodulname);
if (!($cms = get_coursemodules_in_course('publication', $course->id, 'cm.idnumber'))) {
notice(get_string('nopublicationsincourse', 'publication'), '../../course/view.php?id=' . $course->id);
die;
}
$usesections = course_format_uses_sections($course->format);
if ($usesections) {
$sections = get_fast_modinfo($course->id)->get_section_info_all();
}
$timenow = time();
$table = new html_table();
if ($usesections) {
$table->head = array($strsectionname, $strname, $strdesc);
} else {
$table->head = array($strname, $strdesc);
}
$currentsection = '';
示例13: oublog_reset_userdata
/**
* Actual implementation of the reset course functionality, delete all
* oublog posts.
*
* @global object
* @global object
* @param object $data the data submitted from the reset course.
* @return array status array
*/
function oublog_reset_userdata($data)
{
global $DB;
$componentstr = get_string('modulenameplural', 'oublog');
$status = array();
if (!empty($data->reset_oublog)) {
// Delete post-related data.
$postidsql = "\n SELECT pst.id\n FROM {oublog_posts} pst\n JOIN {oublog_instances} ins ON (ins.id = pst.oubloginstancesid)\n JOIN {oublog} obl ON (obl.id = ins.oublogid)\n WHERE obl.course = ?\n ";
$params = array($data->courseid);
$DB->delete_records_select('oublog_comments', "postid IN ({$postidsql})", $params);
$DB->delete_records_select('oublog_comments_moderated', "postid IN ({$postidsql})", $params);
$DB->delete_records_select('oublog_edits', "postid IN ({$postidsql})", $params);
// Delete instance-related data.
$insidsql = "\n SELECT ins.id\n FROM {oublog_instances} ins\n JOIN {oublog} obl ON (obl.id = ins.oublogid)\n WHERE obl.course = ?\n ";
$DB->delete_records_select('oublog_links', "oubloginstancesid IN ({$insidsql})", $params);
$DB->delete_records_select('oublog_taginstances', "oubloginstancesid IN ({$insidsql})", $params);
$DB->delete_records_select('oublog_posts', "oubloginstancesid IN ({$insidsql})", $params);
$blogidsql = "\n SELECT obl.id\n FROM {oublog} obl\n WHERE obl.course = ?\n ";
// Delete instances:
$DB->delete_records_select('oublog_instances', "oublogid IN ({$blogidsql})", $params);
// Reset views:
$DB->execute("UPDATE {oublog} SET views = 0 WHERE course = ?", $params);
// Now get rid of all attachments.
$fs = get_file_storage();
$oublogs = get_coursemodules_in_course('oublog', $data->courseid);
if ($oublogs) {
foreach ($oublogs as $oublogid => $unused) {
if (!($cm = get_coursemodule_from_instance('oublog', $oublogid))) {
continue;
}
$context = context_module::instance($cm->id);
$fs->delete_area_files($context->id, 'mod_oublog', 'attachment');
$fs->delete_area_files($context->id, 'mod_oublog', 'message');
$fs->delete_area_files($context->id, 'mod_oublog', 'messagecomment');
}
}
$status[] = array('component' => $componentstr, 'item' => get_string('removeblogs', 'oublog'), 'error' => false);
}
return $status;
}
示例14: moodle_url
$event->trigger();
//Print selection by instance state
$url_base = new moodle_url('/mod/vpl/index.php', array('id' => $id, 'sort' => $sort, 'sortdir' => $sortdir));
$urls = array();
$urlindex = array();
$url_base->param('selection', 'all');
$selected = $url_base->out(false);
$urls[$selected] = get_string('all');
$urlindex['all'] = $selected;
foreach (array('open', 'closed', 'timelimited', 'timeunlimited', 'automaticgrading', 'manualgrading', 'examples') as $sel) {
$url_base->param('selection', $sel);
$urls[$url_base->out(false)] = get_string($sel, VPL);
$urlindex[$sel] = $url_base->out(false);
}
echo $OUTPUT->url_select($urls, $urlindex[$instanceselection], array());
if (!($cms = get_coursemodules_in_course(VPL, $course->id, "m.shortdescription, m.startdate, m.duedate"))) {
notice($strnopls, vpl_abs_href('/course/view.php', 'id', $course->id));
die;
}
$ovpls = get_all_instances_in_course(VPL, $course);
$timenow = time();
$vpls = array();
//Get and select vpls to show
foreach ($ovpls as $ovpl) {
$vpl = new mod_vpl(false, $ovpl->id);
$instance = $vpl->get_instance();
if ($vpl->is_visible()) {
switch ($instanceselection) {
case 'all':
$vpls[] = $vpl;
break;
示例15: emarking_get_parallel_emarkings
/**
* Returns a recordset of emarking objects which are in courses parallel
* to a course parameter
*
* @param unknown $course
* @param unknown $includeown
* @return multitype:
*/
function emarking_get_parallel_emarkings($course, $includeown)
{
global $DB;
$parallelcourses = emarking_get_parallel_courses($course, $includeown);
if (!$parallelcourses) {
return false;
}
$parallelsids = array();
foreach ($parallelcourses as $parallelcourse) {
if ($parallelcourse->id == $course->id) {
continue;
}
foreach (get_coursemodules_in_course('emarking', $parallelcourse->id) as $cmdst) {
$parallelsids[] = $cmdst->instance;
}
}
$parallelsids = implode(",", $parallelsids);
$parallelemarkings = $DB->get_records_sql("\n SELECT e.*, c.id as courseid, c.shortname, c.fullname\n FROM {emarking} AS e\n INNER JOIN {course} AS c ON (e.course = c.id AND c.id <> ?)\n WHERE e.id IN ({$parallelsids})\n ORDER BY c.fullname, e.name", array($course->id));
return $parallelemarkings;
}