本文整理汇总了PHP中get_course_section函数的典型用法代码示例。如果您正苦于以下问题:PHP get_course_section函数的具体用法?PHP get_course_section怎么用?PHP get_course_section使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_course_section函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_content
function get_content()
{
global $USER, $CFG, $DB, $OUTPUT;
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
if (empty($this->instance)) {
return $this->content;
}
$course = $this->page->course;
require_once $CFG->dirroot . '/course/lib.php';
$context = context_course::instance($course->id);
$isediting = $this->page->user_is_editing() && has_capability('moodle/course:manageactivities', $context);
$modinfo = get_fast_modinfo($course);
/// extra fast view mode
if (!$isediting) {
if (!empty($modinfo->sections[0])) {
$options = array('overflowdiv' => true);
foreach ($modinfo->sections[0] as $cmid) {
$cm = $modinfo->cms[$cmid];
if (!$cm->uservisible) {
continue;
}
list($content, $instancename) = get_print_section_cm_text($cm, $course);
if (!($url = $cm->get_url())) {
$this->content->items[] = $content;
$this->content->icons[] = '';
} else {
$linkcss = $cm->visible ? '' : ' class="dimmed" ';
//Accessibility: incidental image - should be empty Alt text
$icon = '<img src="' . $cm->get_icon_url() . '" class="icon" alt="" /> ';
$this->content->items[] = '<a title="' . $cm->modplural . '" ' . $linkcss . ' ' . $cm->extra . ' href="' . $url . '">' . $icon . $instancename . '</a>';
}
}
}
return $this->content;
}
/// slow & hacky editing mode
$ismoving = ismoving($course->id);
$section = get_course_section(0, $course->id);
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
$groupbuttons = $course->groupmode;
$groupbuttonslink = !$course->groupmodeforce;
if ($ismoving) {
$strmovehere = get_string('movehere');
$strmovefull = strip_tags(get_string('movefull', '', "'{$USER->activitycopyname}'"));
$strcancel = get_string('cancel');
$stractivityclipboard = $USER->activitycopyname;
}
/// Casting $course->modinfo to string prevents one notice when the field is null
$editbuttons = '';
if ($ismoving) {
$this->content->icons[] = '<img src="' . $OUTPUT->pix_url('t/move') . '" class="iconsmall" alt="" />';
$this->content->items[] = $USER->activitycopyname . ' (<a href="' . $CFG->wwwroot . '/course/mod.php?cancelcopy=true&sesskey=' . sesskey() . '">' . $strcancel . '</a>)';
}
if (!empty($section->sequence)) {
$sectionmods = explode(',', $section->sequence);
$options = array('overflowdiv' => true);
foreach ($sectionmods as $modnumber) {
if (empty($mods[$modnumber])) {
continue;
}
$mod = $mods[$modnumber];
if (!$ismoving) {
if ($groupbuttons) {
if (!($mod->groupmodelink = $groupbuttonslink)) {
$mod->groupmode = $course->groupmode;
}
} else {
$mod->groupmode = false;
}
$editbuttons = '<div class="buttons">' . make_editing_buttons($mod, true, true) . '</div>';
} else {
$editbuttons = '';
}
if ($mod->visible || has_capability('moodle/course:viewhiddenactivities', $context)) {
if ($ismoving) {
if ($mod->id == $USER->activitycopy) {
continue;
}
$this->content->items[] = '<a title="' . $strmovefull . '" href="' . $CFG->wwwroot . '/course/mod.php?moveto=' . $mod->id . '&sesskey=' . sesskey() . '">' . '<img style="height:16px; width:80px; border:0px" src="' . $OUTPUT->pix_url('movehere') . '" alt="' . $strmovehere . '" /></a>';
$this->content->icons[] = '';
}
list($content, $instancename) = get_print_section_cm_text($modinfo->cms[$modnumber], $course);
$linkcss = $mod->visible ? '' : ' class="dimmed" ';
if (!($url = $mod->get_url())) {
$this->content->items[] = $content . $editbuttons;
$this->content->icons[] = '';
} else {
//Accessibility: incidental image - should be empty Alt text
$icon = '<img src="' . $mod->get_icon_url() . '" class="icon" alt="" /> ';
$this->content->items[] = '<a title="' . $mod->modfullname . '" ' . $linkcss . ' ' . $mod->extra . ' href="' . $url . '">' . $icon . $instancename . '</a>' . $editbuttons;
}
}
}
}
//.........这里部分代码省略.........
开发者ID:JP-Git,项目名称:moodle,代码行数:101,代码来源:block_site_main_menu.php
示例2: link_to_gdoc
function link_to_gdoc($name, $link, $type = null, $modtype = 'url')
{
global $COURSE, $DB, $CFG, $USER;
require_once "{$CFG->dirroot}/mod/{$modtype}/lib.php";
//add
$fromform = new stdClass();
$newform = new stdClass();
$mform = new MoodleQuickForm(null, 'POST', 'nothing');
$module = $DB->get_record("modules", array('name' => $modtype));
$course = $COURSE;
$cw = get_course_section(0, $course->id);
$cm = null;
// fields for mdl_url
$fromform->course = $course->id;
$fromform->name = $name;
$fromform->introformat = 0;
$fromform->introeditor = 0;
$fromform->externalurl = $link;
/* if ($type !== 'dir') {
$fromform->display = 6;
$fromform->displayoptions = 'a:2:{s:10:"popupwidth";i:1024;s:11:"popupheight";i:768;}';
} else {
*/
$fromform->display = 0;
$fromform->popupwidth = 1024;
$fromform->popupheight = 768;
$fromform->popupwidth = null;
$fromform->popupheight = null;
$fromform->displayoptions = 'a:1:{s:10:"printintro";i:0;}';
// }
// fields for mdl_course_module
$fromform->module = $module->id;
$fromform->instance = '';
$fromform->section = 0;
// The section number itself - relative!!! (section column in course_sections)
$fromform->idnumber = null;
$fromform->score = 0;
$fromform->indent = 0;
$fromform->visible = 1;
$fromform->visibleold = 1;
$fromform->groupmode = $course->groupmode;
$fromform->groupingid = 0;
$fromform->groupmembersonly = 0;
$fromform->completion = 0;
$fromform->completionview = 0;
$fromform->completionexpected = 0;
$fromform->availablefrom = 0;
$fromform->availableuntil = 0;
$fromform->showavailability = 0;
$fromform->showdescription = 0;
$fromform->conditiongradegroup = array();
$fromform->conditionfieldgroup = array();
// fields for mdl_course_sections
$fromform->summaryformat = 0;
$fromform->modulename = clean_param($module->name, PARAM_SAFEDIR);
// For safety
// $fromform->add = 'resource';
// $fromform->type = $type == 'dir' ? 'collection' : 'file';
// $fromform->return = 0; //must be false if this is an add, go back to course view on cancel
// $fromform->coursemodule = '';
// $fromform->popup = 'resizable=1,scrollbars=1,directories=1,location=1,menubar=1,toolbar=1,status=1,width=1024,height=768';
// require_login($course->id); // needed to setup proper $COURSE
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('moodle/course:manageactivities', $context);
if (!empty($course->groupmodeforce) or !isset($fromform->groupmode)) {
$fromform->groupmode = 0;
// do not set groupmode
}
if (!course_allowed_module($course, $fromform->modulename)) {
print_error('moduledisable', '', '', $fromform->modulename);
}
// first add course_module record because we need the context
$newcm = new stdClass();
$newcm->course = $course->id;
$newcm->module = $fromform->module;
$newcm->instance = 0;
// not known yet, will be updated later (this is similar to restore code)
$newcm->visible = $fromform->visible;
$newcm->groupmode = $fromform->groupmode;
$newcm->groupingid = $fromform->groupingid;
$newcm->groupmembersonly = $fromform->groupmembersonly;
$completion = new completion_info($course);
if ($completion->is_enabled()) {
$newcm->completion = $fromform->completion;
$newcm->completiongradeitemnumber = $fromform->completiongradeitemnumber;
$newcm->completionview = $fromform->completionview;
$newcm->completionexpected = $fromform->completionexpected;
}
if (!empty($CFG->enableavailability)) {
$newcm->availablefrom = $fromform->availablefrom;
$newcm->availableuntil = $fromform->availableuntil;
$newcm->showavailability = $fromform->showavailability;
}
if (isset($fromform->showdescription)) {
$newcm->showdescription = $fromform->showdescription;
} else {
$newcm->showdescription = 0;
}
if (!($fromform->coursemodule = add_course_module($newcm))) {
print_error('cannotaddcoursemodule');
//.........这里部分代码省略.........
开发者ID:rlorenzo,项目名称:moodle-block_morsle,代码行数:101,代码来源:morslelib.php
示例3: setup
/**
* Setup the DB fixture data
*/
public function setup()
{
parent::setUp();
$tables = array('block_instance', 'cache_flags', 'capabilities', 'context', 'context_temp', 'course', 'course_modules', 'course_categories', 'course_sections', 'files', 'files_cleanup', 'grade_items', 'grade_categories', 'groups', 'groups_members', 'modules', 'role', 'role_names', 'role_context_levels', 'role_assignments', 'role_capabilities', 'user');
$this->create_test_tables($tables, 'lib');
$this->create_test_table('forum', 'mod/forum');
$this->switch_to_test_db();
global $DB, $CFG;
// Insert needed capabilities
$DB->insert_record('capabilities', array('id' => 45, 'name' => 'moodle/course:update', 'cattype' => 'write', 'contextlevel' => 50, 'component' => 'moodle', 'riskbitmask' => 4));
$DB->insert_record('capabilities', array('id' => 14, 'name' => 'moodle/site:backup', 'cattype' => 'write', 'contextlevel' => 50, 'component' => 'moodle', 'riskbitmask' => 28));
$DB->insert_record('capabilities', array('id' => 17, 'name' => 'moodle/site:restore', 'cattype' => 'write', 'contextlevel' => 50, 'component' => 'moodle', 'riskbitmask' => 28));
$DB->insert_record('capabilities', array('id' => 52, 'name' => 'moodle/course:managefiles', 'cattype' => 'write', 'contextlevel' => 50, 'component' => 'moodle', 'riskbitmask' => 4));
$DB->insert_record('capabilities', array('id' => 73, 'name' => 'moodle/user:editownprofile', 'cattype' => 'write', 'contextlevel' => 10, 'component' => 'moodle', 'riskbitmask' => 16));
// Insert system context
$DB->insert_record('context', array('id' => 1, 'contextlevel' => 10, 'instanceid' => 0, 'path' => '/1', 'depth' => 1));
$DB->insert_record('context', array('id' => 2, 'contextlevel' => 50, 'instanceid' => 1, 'path' => '/1/2', 'depth' => 2));
// Insert site course
$DB->insert_record('course', array('category' => 0, 'sortorder' => 1, 'fullname' => 'Test site', 'shortname' => 'test', 'format' => 'site', 'modinfo' => 'a:0:{}'));
// User and capability stuff (stolen from testaccesslib.php)
$syscontext = get_system_context(false);
$adminrole = create_role(get_string('administrator'), 'admin', get_string('administratordescription'), 'moodle/legacy:admin');
/// Now is the correct moment to install capabilities - after creation of legacy roles, but before assigning of roles
assign_capability('moodle/site:doanything', CAP_ALLOW, $adminrole, $syscontext->id);
update_capabilities('moodle');
update_capabilities('mod/forum');
$contexts = $this->load_test_data('context', array('contextlevel', 'instanceid', 'path', 'depth'), array(1 => array(40, 666, '', 2)));
$contexts[0] = $syscontext;
$contexts[1]->path = $contexts[0]->path . '/' . $contexts[1]->id;
$this->testdb->set_field('context', 'path', $contexts[1]->path, array('id' => $contexts[1]->id));
$users = $this->load_test_data('user', array('username', 'confirmed', 'deleted'), array('a' => array('a', 1, 0)));
$admin = $this->testdb->get_record('role', array('shortname' => 'admin'));
$ras = $this->load_test_data('role_assignments', array('userid', 'roleid', 'contextid'), array('a' => array($users['a']->id, $admin->id, $contexts[0]->id)));
$this->switch_global_user_id(1);
accesslib_clear_all_caches_for_unit_testing();
// Create a coursecat
$newcategory = new stdClass();
$newcategory->name = 'test category';
$newcategory->sortorder = 999;
if (!($newcategory->id = $DB->insert_record('course_categories', $newcategory))) {
print_error('cannotcreatecategory', '', '', format_string($newcategory->name));
}
$newcategory->context = get_context_instance(CONTEXT_COURSECAT, $newcategory->id);
mark_context_dirty($newcategory->context->path);
fix_course_sortorder();
// Required to build course_categories.depth and .path.
$this->coursecat = $DB->get_record('course_categories', array('id' => $newcategory->id));
// Create a course
$coursedata = new stdClass();
$coursedata->category = $newcategory->id;
$coursedata->shortname = 'testcourse';
$coursedata->fullname = 'Test Course';
try {
$this->course = create_course($coursedata);
} catch (moodle_exception $e) {
// Most likely the result of an aborted unit test: the test course was not correctly deleted
$this->course = $DB->get_record('course', array('shortname' => $coursedata->shortname));
}
// Create a user
$this->user = new stdClass();
$this->user->username = 'testuser09987654321';
$this->user->password = 'password';
$this->user->firstname = 'TestUser';
$this->user->lastname = 'TestUser';
$this->user->email = '[email protected]';
try {
$this->user->id = create_user($this->user);
} catch (moodle_exception $e) {
// Most likely the result of an aborted unit test: the test user was not correctly deleted
$this->user->id = $DB->get_field('user', 'id', array('username' => $this->user->username));
}
// Assign user to course
// role_assign(5, $this->user->id, 0, get_context_instance(CONTEXT_COURSE, $this->course->id)->id);
// Create a module
$module = new stdClass();
$module->intro = 'Forum used for testing filelib API';
$module->type = 'general';
$module->forcesubscribe = 1;
$module->format = 1;
$module->name = 'Test Forum';
$module->module = $DB->get_field('modules', 'id', array('name' => 'forum'));
$module->modulename = 'forum';
$module->add = 'forum';
$module->cmidnumber = '';
$module->course = $this->course->id;
$module->instance = forum_add_instance($module, '');
$this->section = get_course_section(1, $this->course->id);
$module->section = $this->section->id;
$module->coursemodule = add_course_module($module);
add_mod_to_section($module);
$module->cmidnumber = set_coursemodule_idnumber($module->coursemodule, '');
rebuild_course_cache($this->course->id);
$this->module = $DB->get_record('forum', array('id' => $module->instance));
$this->module->instance = $module->instance;
// Update local copy of course
$this->course = $DB->get_record('course', array('id' => $this->course->id));
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:100,代码来源:testfilelib.php
示例4: project_restore_course_files
/**
* コースファイルのコピー
*
* @param object $restore
* @return
*/
function project_restore_course_files(&$restore)
{
global $CFG;
$status = true;
$counter = 0;
// 対象のコース情報の取得
if (!($course = get_record("course", "id", $restore->course_id))) {
error("Course ID was incorrect (can't find it)");
}
// 対象のセクション情報の取得
if (!($section = get_course_section($restore->section, $restore->course_id))) {
error("Section data was incorrect (can't find it)");
}
// 現在のセクションのディレクトリ名を取得
if (!($sectiontitle = project_format_get_title($course, $section->id))) {
error("Section directory was incorrect");
}
//First, we check to "course_id" exists and create is as necessary
//in CFG->dataroot
$dest_dir = $CFG->dataroot . "/" . $restore->course_id . '/' . $restore->newdirectoryname;
$status = check_dir_exists($dest_dir, true);
//Now, we iterate over "course_files" records to check if that file/dir must be
//copied to the "dest_dir" dir.
$rootdir = $CFG->dataroot . "/temp/backup/" . $restore->backup_unique_code . "/course_files/" . $restore->olddirectoryname;
// ディレクトリをまるごとコピーする
if (is_dir($rootdir)) {
$status = backup_copy_file($rootdir, $dest_dir);
}
return $status;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:36,代码来源:restorelib.php
示例5: generate_modules
//.........这里部分代码省略.........
case 'label':
$module->content = $content;
$module->intro = $description;
break;
case 'lesson':
$module->lessondefault = 1;
$module->available = mktime();
$module->deadline = mktime() + 719891987;
$module->grade = 100;
break;
case 'quiz':
$module->intro = $description;
$module->feedbacktext = 'blah';
$module->feedback = 1;
$module->feedbackboundaries = array(2, 1);
$module->grade = 10;
$module->timeopen = time();
$module->timeclose = time() + 68854;
$module->shufflequestions = true;
$module->shuffleanswers = true;
$module->quizpassword = '';
break;
case 'resource':
$module->type = $this->get_module_type('resource');
$module->alltext = $content;
$module->summary = $description;
$module->windowpopup = rand(0, 1);
$module->display = rand(0, 1);
$module->resizable = rand(0, 1);
$module->scrollbars = rand(0, 1);
$module->directories = rand(0, 1);
$module->location = 'file.txt';
$module->menubar = rand(0, 1);
$module->toolbar = rand(0, 1);
$module->status = rand(0, 1);
$module->width = rand(200, 600);
$module->height = rand(200, 600);
$module->directories = rand(0, 1);
$module->files = false;
$module->param_navigationmenu = rand(0, 1);
$module->param_navigationbuttons = rand(0, 1);
$module->reference = 1;
$module->forcedownload = 1;
break;
case 'survey':
$module->template = rand(1, 5);
$module->intro = $description;
break;
case 'wiki':
$module->intro = $description;
$module->summary = $description;
break;
}
$module->name = ucfirst($moduledata->name) . ' ' . $moduledata->count++;
$module->course = $courseid;
$module->section = $i;
$module->module = $moduledata->id;
$module->modulename = $moduledata->name;
$module->add = $moduledata->name;
$module->cmidnumber = '';
$module->coursemodule = '';
$add_instance_function = $moduledata->name . '_add_instance';
$section = get_course_section($i, $courseid);
$module->section = $section->id;
$module->coursemodule = add_course_module($module);
$module->section = $i;
if (function_exists($add_instance_function)) {
$this->verbose("Calling module function {$add_instance_function}");
$module->instance = $add_instance_function($module, '');
$DB->set_field('course_modules', 'instance', $module->instance, array('id' => $module->coursemodule));
} else {
$this->verbose("Function {$add_instance_function} does not exist!");
if (!$this->get('ignore_errors')) {
die;
}
}
add_mod_to_section($module);
$module->cmidnumber = set_coursemodule_idnumber($module->coursemodule, '');
$this->verbose("A {$moduledata->name} module was added to section {$i} (id {$module->section}) " . "of course {$courseid}.");
rebuild_course_cache($courseid);
$module_instance = $DB->get_field('course_modules', 'instance', array('id' => $module->coursemodule));
$module_record = $DB->get_record($moduledata->name, array('id' => $module_instance));
$module_record->instance = $module_instance;
if (empty($modules_array[$moduledata->name])) {
$modules_array[$moduledata->name] = array();
}
// TODO Find out why some $module_record end up empty here... (particularly quizzes)
if (!empty($module_record->instance)) {
$modules_array[$moduledata->name][] = $module_record;
}
}
}
}
if (!$this->get('quiet')) {
echo "Successfully generated " . $this->get('number_of_modules') * $this->get('number_of_sections') . " modules in each course!{$this->eolchar}";
}
return $modules_array;
}
return null;
}
开发者ID:vuchannguyen,项目名称:web,代码行数:101,代码来源:generator.php
示例6: print_multiple_section_page
/**
* Output the html for a multiple section page
*
* @param stdClass $course The course entry from DB
* @param array $sections The course_sections entries from the DB
* @param array $mods used for print_section()
* @param array $modnames used for print_section()
* @param array $modnamesused used for print_section()
*/
public function print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused)
{
global $PAGE;
$context = context_course::instance($course->id);
// Title with completion help icon.
$completioninfo = new completion_info($course);
echo $completioninfo->display_help_icon();
echo $this->output->heading($this->page_title(), 2, 'accesshide');
// Copy activity clipboard..
echo $this->course_activity_clipboard($course);
// Now the list of sections..
echo $this->start_section_list();
// General section if non-empty.
$thissection = $sections[0];
unset($sections[0]);
if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) {
echo $this->section_header($thissection, $course, true);
print_section($course, $thissection, $mods, $modnamesused, true);
if ($PAGE->user_is_editing()) {
print_section_add_menus($course, 0, $modnames);
}
echo $this->section_footer();
}
$canviewhidden = has_capability('moodle/course:viewhiddensections', $context);
for ($section = 1; $section <= $course->numsections; $section++) {
if (!empty($sections[$section])) {
$thissection = $sections[$section];
} else {
// This will create a course section if it doesn't exist..
$thissection = get_course_section($section, $course->id);
// The returned section is only a bare database object rather than
// a section_info object - we will need at least the uservisible
// field in it.
$thissection->uservisible = true;
$thissection->availableinfo = null;
$thissection->showavailability = 0;
}
// Show the section if the user is permitted to access it, OR if it's not available
// but showavailability is turned on
$showsection = $thissection->uservisible || $thissection->visible && !$thissection->available && $thissection->showavailability;
if (!$showsection) {
// Hidden section message is overridden by 'unavailable' control
// (showavailability option).
if (!$course->hiddensections && $thissection->available) {
echo $this->section_hidden($section);
}
unset($sections[$section]);
continue;
}
if (!$PAGE->user_is_editing() && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
// Display section summary only.
echo $this->section_summary($thissection, $course);
} else {
echo $this->section_header($thissection, $course, false);
if ($thissection->uservisible) {
print_section($course, $thissection, $mods, $modnamesused);
if ($PAGE->user_is_editing()) {
print_section_add_menus($course, $section, $modnames);
}
}
echo $this->section_footer();
}
unset($sections[$section]);
}
if ($PAGE->user_is_editing() and has_capability('moodle/course:update', $context)) {
// Print stealth sections if present.
$modinfo = get_fast_modinfo($course);
foreach ($sections as $section => $thissection) {
if (empty($modinfo->sections[$section])) {
continue;
}
echo $this->stealth_section_header($section);
print_section($course, $thissection, $mods, $modnamesused);
echo $this->stealth_section_footer();
}
echo $this->end_section_list();
echo html_writer::start_tag('div', array('id' => 'changenumsections', 'class' => 'mdl-right'));
// Increase number of sections.
$straddsection = get_string('increasesections', 'moodle');
$url = new moodle_url('/course/changenumsections.php', array('courseid' => $course->id, 'increase' => true, 'sesskey' => sesskey()));
$icon = $this->output->pix_icon('t/switch_plus', $straddsection);
echo html_writer::link($url, $icon . get_accesshide($straddsection), array('class' => 'increase-sections'));
if ($course->numsections > 0) {
// Reduce number of sections sections.
$strremovesection = get_string('reducesections', 'moodle');
$url = new moodle_url('/course/changenumsections.php', array('courseid' => $course->id, 'increase' => false, 'sesskey' => sesskey()));
$icon = $this->output->pix_icon('t/switch_minus', $strremovesection);
echo html_writer::link($url, $icon . get_accesshide($strremovesection), array('class' => 'reduce-sections'));
}
echo html_writer::end_tag('div');
} else {
//.........这里部分代码省略.........
开发者ID:nicusX,项目名称:moodle,代码行数:101,代码来源:renderer.php
示例7: RWSSQDMoodle
//.........这里部分代码省略.........
$r_qiz->correctnessclosed = $r_dfs->reviewcorrectness & RWSRAF;
if (!$r_qiz->correctnessclosed) {
unset($r_qiz->correctnessclosed);
}
$r_qiz->marksclosed = $r_dfs->reviewmarks & RWSRAF;
if (!$r_qiz->marksclosed) {
unset($r_qiz->marksclosed);
}
$r_qiz->specificfeedbackclosed = $r_dfs->reviewspecificfeedback & RWSRAF;
if (!$r_qiz->specificfeedbackclosed) {
unset($r_qiz->specificfeedbackclosed);
}
$r_qiz->generalfeedbackclosed = $r_dfs->reviewgeneralfeedback & RWSRAF;
if (!$r_qiz->generalfeedbackclosed) {
unset($r_qiz->generalfeedbackclosed);
}
$r_qiz->rightanswerclosed = $r_dfs->reviewrightanswer & RWSRAF;
if (!$r_qiz->rightanswerclosed) {
unset($r_qiz->rightanswerclosed);
}
$r_qiz->overallfeedbackclosed = $r_dfs->reviewoverallfeedback & RWSRAF;
if (!$r_qiz->overallfeedbackclosed) {
unset($r_qiz->overallfeedbackclosed);
}
} else {
$r_qiz->responsesclosed = $r_dfs->review & RWSRRE & RWSRCL;
if (!$r_qiz->responsesclosed) {
unset($r_qiz->responsesclosed);
}
$r_qiz->answersclosed = $r_dfs->review & RWSRAN & RWSRCL;
if (!$r_qiz->answersclosed) {
unset($r_qiz->answersclosed);
}
$r_qiz->feedbackclosed = $r_dfs->review & RWSRFE & RWSRCL;
if (!$r_qiz->feedbackclosed) {
unset($r_qiz->feedbackclosed);
}
$r_qiz->generalfeedbackclosed = $r_dfs->review & RWSRGE & RWSRCL;
if (!$r_qiz->generalfeedbackclosed) {
unset($r_qiz->generalfeedbackclosed);
}
$r_qiz->scoreclosed = $r_dfs->review & RWSRSC & RWSRCL;
if (!$r_qiz->scoreclosed) {
unset($r_qiz->scoreclosed);
}
$r_qiz->overallfeedbackclosed = $r_dfs->review & RWSROV & RWSRCL;
if (!$r_qiz->overallfeedbackclosed) {
unset($r_qiz->overallfeedbackclosed);
}
}
$r_qiz->showuserpicture = $r_dfs->showuserpicture;
$r_qiz->decimalpoints = $r_dfs->decimalpoints;
$r_qiz->questiondecimalpoints = $r_dfs->questiondecimalpoints;
$r_qiz->showblocks = $r_dfs->showblocks;
$r_qiz->quizpassword = $r_dfs->password;
$r_qiz->subnet = $r_dfs->subnet;
$r_qiz->delay1 = $r_dfs->delay1;
$r_qiz->delay2 = $r_dfs->delay2;
if (isset($r_dfs->browsersecurity)) {
$r_qiz->browsersecurity = $r_dfs->browsersecurity;
} else {
$r_qiz->popup = $r_dfs->popup;
}
$r_nf = 5;
for ($r_i = 0; $r_i < $r_nf; $r_i++) {
$r_drf = 0;
$r_cmp = "mod_quiz";
$r_far = "feedback";
$r_iti = null;
$r_op = null;
$r_txt = "";
$r_qiz->feedbacktext[$r_i]["text"] = file_prepare_draft_area($r_drf, $r_ctxi, $r_cmp, $r_far, $r_iti, $r_op, $r_txt);
$r_qiz->feedbacktext[$r_i]["format"] = FORMAT_HTML;
$r_qiz->feedbacktext[$r_i]["itemid"] = $r_drf;
if ($r_i < $r_nf - 1) {
$r_qiz->feedbackboundaries[$r_i] = "";
}
}
$r_qiz->groupmode = NOGROUPS;
$r_qiz->groupingid = 0;
$r_qiz->visible = 1;
$r_qiz->cmidnumber = "";
if (!empty($r_qiz->course)) {
$r_crs = $DB->get_record("course", array("id" => $r_qiz->course));
if ($r_crs !== false) {
$r_qiz->groupmode = $r_crs->groupmode;
$r_qiz->groupingid = $r_crs->defaultgroupingid;
if (!empty($r_qiz->section)) {
if (respondusws_floatcompare($CFG->version, 2012120300, 2) >= 0) {
$modinfo = get_fast_modinfo($r_qiz->course);
$r_sec = $modinfo->get_section_info($r_qiz->section);
} else {
$r_sec = get_course_section($r_qiz->section, $r_qiz->course);
}
$r_qiz->visible = $r_sec->visible;
}
}
}
$r_qiz->grade = $r_dfs->maximumgrade;
}
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:101,代码来源:servicelib.php
示例8: required_param
if (!empty($return)) {
$url->param('return', $return);
}
if (!empty($add)) {
$section = required_param('section', PARAM_INT);
$course = required_param('course', PARAM_INT);
$url->param('add', $add);
$url->param('section', $section);
$url->param('course', $course);
$PAGE->set_url($url);
$course = $DB->get_record('course', array('id' => $course), '*', MUST_EXIST);
$module = $DB->get_record('modules', array('name' => $add), '*', MUST_EXIST);
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('moodle/course:manageactivities', $context);
$cw = get_course_section($section, $course->id);
if (!course_allowed_module($course, $module->id)) {
print_error('moduledisable');
}
$cm = null;
$data = new stdClass();
$data->section = $section;
// The section number itself - relative!!! (section column in course_sections)
$data->visible = $cw->visible;
$data->course = $course->id;
$data->module = $module->id;
$data->modulename = $module->name;
$data->groupmode = $course->groupmode;
$data->groupingid = $course->defaultgroupingid;
$data->groupmembersonly = 0;
$data->id = '';
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:31,代码来源:modedit.php
示例9: add_section
/**
* Adds a new section object to be used by this subpage
*
* @return object
*/
public function add_section($name = '', $summary = '')
{
global $DB, $CFG;
require_once $CFG->dirroot . '/course/lib.php';
// Needed for get_course_section.
$transaction = $DB->start_delegated_transaction();
// Extra condition if the oucontent module (which has similar but simpler
// behaviour) is installed, so they don't tread on each others' toes.
$oucontentjoin = '';
$oucontentwhere = '';
if (file_exists($CFG->dirroot . '/mod/oucontent')) {
$oucontentjoin = 'LEFT JOIN {oucontent} o ' . 'ON o.course = cs.course AND o.coursesectionid = cs2.id';
$oucontentwhere = 'AND o.id IS NULL';
}
// Pick a section number. This query finds the first section
// on the course that is at least the minimum number, and does not have
// a used section in the following number, and returns that following
// section number. (This means it can fill up gaps if sections are
// deleted.)
$sql = "\nSELECT\n cs.section+1 AS num\nFROM\n {course_sections} cs\n LEFT JOIN {course_sections} cs2 ON cs2.course = cs.course AND cs2.section = cs.section+1\n LEFT JOIN {subpage_sections} ss2 ON ss2.sectionid = cs2.id\n {$oucontentjoin}\nWHERE\n cs.course = ?\n AND cs.section >= ?\n AND ss2.id IS NULL\n {$oucontentwhere}\nORDER BY\n cs.section";
$result = $DB->get_records_sql($sql, array($this->course->id, self::SECTION_NUMBER_MIN), 0, 1);
if (count($result) == 0) {
// If no existing sections, use the min number.
$sectionnum = self::SECTION_NUMBER_MIN;
} else {
$sectionnum = reset($result)->num;
}
// Create a section entry with this section number - this function creates
// and returns the section.
$section = get_course_section($sectionnum, $this->course->id);
// Now update summary/name if set above.
if (!empty($name) or !empty($summary)) {
$section->name = format_string($name);
$section->summary = format_text($summary);
$DB->update_record('course_sections', $section);
}
$sql = "SELECT MAX(pageorder) FROM {subpage_sections} WHERE subpageid = ?";
// Get highest pageorder and add 1.
$pageorder = $DB->get_field_sql($sql, array($this->subpage->id)) + 1;
$subpage_section = new stdClass();
$subpage_section->subpageid = $this->subpage->id;
$subpage_section->sectionid = $section->id;
$subpage_section->pageorder = $pageorder;
$subpage_section->stealth = 0;
$ss = $DB->insert_record('subpage_sections', $subpage_section);
$transaction->allow_commit();
return array('subpagesectionid' => $ss, 'sectionid' => $section->id);
}
开发者ID:nadavkav,项目名称:moodle-mod_subpage,代码行数:53,代码来源:locallib.php
示例10: verbose
$module->course = $courseid;
$module->section = $i;
$module->module = $moduledata->id;
$module->modulename = $moduledata->name;
$module->add = $moduledata->name;
$module->cmidnumber = '';
$add_instance_function = $moduledata->name . '_add_instance';
if (function_exists($add_instance_function)) {
$module->instance = $add_instance_function($module, '');
} else {
verbose("Function {$add_instance_function} does not exist!");
if (!$settings['ignore-errors']) {
die;
}
}
$section = get_course_section($i, $courseid);
$module->section = $section->id;
$module->coursemodule = add_course_module($module);
$module->section = $i;
add_mod_to_section($module);
$module->cmidnumber = set_coursemodule_idnumber($module->coursemodule, '');
verbose("A {$moduledata->name} module was added to section {$i} (id {$module->section}) of course {$courseid}.");
rebuild_course_cache($courseid);
if ($moduledata->name == 'quiz') {
$quiz_instance = $DB->get_field('course_modules', 'instance', array('id' => $module->coursemodule));
$quiz = $DB->get_record('quiz', array('id' => $quiz_instance));
$quiz->instance = $quiz_instance;
$quizzes[] = $quiz;
} elseif ($moduledata->name == 'assignment') {
$assignment_instance = $DB->get_field('course_modules', 'instance', array('id' => $module->coursemodule));
$assignment = $DB->get_record('assignment', array('id' => $assignment_instance));
开发者ID:nicolasconnault,项目名称:moodle-data-generator,代码行数:31,代码来源:generator.php
示例11: get_content
function get_content()
{
global $USER, $CFG, $COURSE;
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new object();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
if (empty($this->instance)) {
return $this->content;
}
if ($COURSE->id == $this->instance->pageid) {
$course = $COURSE;
} else {
$course = get_record('course', 'id', $this->instance->pageid);
}
require_once $CFG->dirroot . '/course/lib.php';
$context = get_context_instance(CONTEXT_COURSE, $course->id);
$isediting = isediting($this->instance->pageid) && has_capability('moodle/course:manageactivities', $context);
$modinfo =& get_fast_modinfo($course);
/// extra fast view mode
if (!$isediting) {
if (!empty($modinfo->sections[0])) {
foreach ($modinfo->sections[0] as $cmid) {
$cm = $modinfo->cms[$cmid];
if (!$cm->uservisible) {
continue;
}
if ($cm->modname == 'label') {
$this->content->items[] = format_text($cm->extra, FORMAT_HTML);
$this->content->icons[] = '';
} else {
$linkcss = $cm->visible ? '' : ' class="dimmed" ';
$instancename = format_string($cm->name, true, $course->id);
$this->content->items[] = '<a title="' . $cm->modplural . '" ' . $linkcss . ' ' . $cm->extra . ' href="' . $CFG->wwwroot . '/mod/' . $cm->modname . '/view.php?id=' . $cm->id . '">' . $instancename . '</a>';
//Accessibility: incidental image - should be empty Alt text
if (!empty($cm->icon)) {
$icon = $CFG->pixpath . '/' . $cm->icon;
} else {
$icon = $CFG->modpixpath . '/' . $cm->modname . '/icon.gif';
}
$this->content->icons[] = '<img src="' . $icon . '" class="icon" alt="" />';
}
}
}
return $this->content;
}
/// slow & hacky editing mode
$ismoving = ismoving($this->instance->pageid);
$section = get_course_section(0, $this->instance->pageid);
get_all_mods($this->instance->pageid, $mods, $modnames, $modnamesplural, $modnamesused);
$groupbuttons = $course->groupmode;
$groupbuttonslink = !$course->groupmodeforce;
if ($ismoving) {
$strmovehere = get_string('movehere');
$strmovefull = strip_tags(get_string('movefull', '', "'{$USER->activitycopyname}'"));
$strcancel = get_string('cancel');
$stractivityclipboard = $USER->activitycopyname;
}
/// Casting $course->modinfo to string prevents one notice when the field is null
$editbuttons = '';
if ($ismoving) {
$this->content->icons[] = '<img src="' . $CFG->pixpath . '/t/move.gif" class="iconsmall" alt="" />';
$this->content->items[] = $USER->activitycopyname . ' (<a href="' . $CFG->wwwroot . '/course/mod.php?cancelcopy=true&sesskey=' . $USER->sesskey . '">' . $strcancel . '</a>)';
}
if (!empty($section->sequence)) {
$sectionmods = explode(',', $section->sequence);
foreach ($sectionmods as $modnumber) {
if (empty($mods[$modnumber])) {
continue;
}
$mod = $mods[$modnumber];
if (!$ismoving) {
if ($groupbuttons) {
if (!($mod->groupmodelink = $groupbuttonslink)) {
$mod->groupmode = $course->groupmode;
}
} else {
$mod->groupmode = false;
}
$editbuttons = '<div class="buttons">' . make_editing_buttons($mod, true, true) . '</div>';
} else {
$editbuttons = '';
}
if ($mod->visible || has_capability('moodle/course:viewhiddenactivities', $context)) {
if ($ismoving) {
if ($mod->id == $USER->activitycopy) {
continue;
}
$this->content->items[] = '<a title="' . $strmovefull . '" href="' . $CFG->wwwroot . '/course/mod.php?moveto=' . $mod->id . '&sesskey=' . $USER->sesskey . '">' . '<img style="height:16px; width:80px; border:0px" src="' . $CFG->pixpath . '/movehere.gif" alt="' . $strmovehere . '" /></a>';
$this->content->icons[] = '';
}
$instancename = $modinfo->cms[$modnumber]->name;
$instancename = format_string($instancename, true, $this->instance->pageid);
$linkcss = $mod->visible ? '' : ' class="dimmed" ';
if (!empty($modinfo->cms[$modnumber]->extra)) {
$extra = $modinfo->cms[$modnumber]->extra;
} else {
//.........这里部分代码省略.........
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:101,代码来源:block_site_main_menu.php
示例12: project_course_files_check_backup
/**
* バックアップするセクションファイルのチェック
*
* Calculate the number of course files to backup
* under $CFG->dataroot/$course, except $CFG->moddata, and backupdata
* and put them (their path) in backup_ids
* Return an array of info (name,value)
*/
function project_course_files_check_backup($courseid, $sectionnumber, $backup_unique_code)
{
global $CFG;
// 対象のコース情報の取得
if (!($course = get_record("course", "id", $courseid))) {
error("Course ID was incorrect (can't find it)");
}
// セクション情報の取得
if (!($section = get_course_section($sectionnumber, $course->id))) {
error("Section data was incorrect (can't find it)");
}
// セクションタイトルの取得
if (!($sectiontitle = get_record('course_project_title', 'sectionid', $section->id))) {
error("Could not find section title");
}
// バックアップ対象ディレクトリ
$rootdir
|
请发表评论