本文整理汇总了PHP中get_fast_modinfo函数 的典型用法代码示例。如果您正苦于以下问题:PHP get_fast_modinfo函数的具体用法?PHP get_fast_modinfo怎么用?PHP get_fast_modinfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_fast_modinfo函数 的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: display
public function display($discussion)
{
// Obtain list of other forums in this course where the user has the
// 'move discussion' feature
$course = $discussion->get_forum()->get_course();
$modinfo = get_fast_modinfo($course);
$results = array();
foreach ($modinfo->instances['forumng'] as $other) {
// Don't let user move discussion to its current forum
if ($other->instance == $discussion->get_forum()->get_id() || $other->id == $discussion->get_forum()->get_course_module_id()) {
continue;
}
$othercontext = context_module::instance($other->id);
if (has_capability('mod/forumng:movediscussions', $othercontext)) {
$results[$other->id] = $other->name;
}
}
if (count($results) == 0) {
return '';
}
// Make list alphabetical
uasort($results, array('forumngfeature_move', 'sort_ignore_case'));
// Build select using the list
$out = mod_forumng_utils::get_renderer();
$select = html_writer::select($results, 'target', '', array('' => get_string('movethisdiscussionto', 'forumngfeature_move')));
return '<form method="post" action="feature/move/move.php"><div>' . $discussion->get_link_params(mod_forumng::PARAM_FORM) . $select . '<input class="forumng-zero-disable" ' . 'type="submit" value="' . get_string('move') . '" /></div></form>';
}
开发者ID:nadavkav, 项目名称:Moodle2-Hebrew-plugins, 代码行数:27, 代码来源:forumngfeature_move.php
示例2: customlabel_get_candidate_modules
/**
* Get the course modules that can be linked as work to do
*/
function customlabel_get_candidate_modules()
{
global $COURSE, $DB, $CFG;
if (!empty($CFG->upgraderunning)) {
return;
}
$modinfo = get_fast_modinfo($COURSE);
$modules = array();
foreach ($modinfo->get_cms() as $cminfo) {
if (!$cminfo->visible) {
continue;
}
if (preg_match('/label$/', $cminfo->modname)) {
continue;
}
include_once $CFG->dirroot . '/mod/' . $cminfo->modname . '/lib.php';
$supportf = $cminfo->modname . '_supports';
if (!$supportf(FEATURE_GRADE_HAS_GRADE) && !$supportf(FEATURE_GRADE_OUTCOMES)) {
// Module seems it is not gradable so not a worktodo module
continue;
}
$modules[$cminfo->module] = $cminfo->name;
}
return $modules;
}
开发者ID:OctaveBabel, 项目名称:moodle-itop, 代码行数:28, 代码来源:locallib.php
示例3: definition
function definition()
{
global $DB, $PAGE, $OUTPUT;
$id = required_param('id', PARAM_INT);
// course module
if (!($cm = get_coursemodule_from_id('blended', $id))) {
error("Course Module ID was incorrect");
}
if (!($course = get_course($cm->course))) {
error("Course is misconfigured");
}
if (!($blended = $DB->get_record('blended', array('id' => $cm->instance)))) {
error("Course module is incorrect");
}
$form =& $this->_form;
$calificables = new grade_tree($course->id);
$items = $calificables->items;
$ins = array();
$assignmentname = array();
// Obtenemos las referencias a toda la informaci�n sobre los modulos dentro del curso
$modinfo = get_fast_modinfo($course->id);
foreach ($modinfo->instances as $abc) {
foreach ($abc as $cmd) {
foreach ($items as $r => $ite) {
$ins[$r] = $ite->iteminstance;
if ($cmd->instance == $ins[$r]) {
$assignmentname[$r] = $cmd->name;
}
}
}
}
$form->addElement('select', 'activities', 'Selecciona la Tarea', $assignmentname);
}
开发者ID:juacas, 项目名称:moodle-mod_blended, 代码行数:33, 代码来源:select_activity_form.php
示例4: get_children
public function get_children()
{
$children = array();
if ($child = $this->browser->get_file_info($this->context, 'course_intro', 0)) {
$children[] = $child;
}
if ($child = $this->browser->get_file_info($this->context, 'course_section')) {
$children[] = $child;
}
if ($child = $this->browser->get_file_info($this->context, 'course_backup', 0)) {
$children[] = $child;
}
if ($child = $this->browser->get_file_info($this->context, 'course_content', 0)) {
$children[] = $child;
}
$modinfo = get_fast_modinfo($this->course);
foreach ($modinfo->cms as $cminfo) {
if (empty($cminfo->uservisible)) {
continue;
}
$modcontext = get_context_instance(CONTEXT_MODULE, $cminfo->id);
if ($child = $this->browser->get_file_info($modcontext)) {
$children[] = $child;
}
}
return $children;
}
开发者ID:nicolasconnault, 项目名称:moodle2.0, 代码行数:27, 代码来源:file_info_course.php
示例5: get_other_values
protected function get_other_values(renderer_base $output)
{
// Arrays are copy on assign.
$related = $this->related;
$result = new stdClass();
// Remove course from related as it is not wanted by the user_competency_summary_exporter.
unset($related['course']);
$related['usercompetencyplan'] = null;
$related['usercompetency'] = null;
$exporter = new user_competency_summary_exporter(null, $related);
$result->usercompetencysummary = $exporter->export($output);
$result->usercompetencysummary->cangrade = user_competency::can_grade_user_in_course($this->related['user']->id, $this->related['course']->id);
$context = context_course::instance($this->related['course']->id);
$exporter = new course_summary_exporter($this->related['course'], array('context' => $context));
$result->course = $exporter->export($output);
$coursemodules = api::list_course_modules_using_competency($this->related['competency']->get_id(), $this->related['course']->id);
$fastmodinfo = get_fast_modinfo($this->related['course']->id);
$exportedmodules = array();
foreach ($coursemodules as $cm) {
$cminfo = $fastmodinfo->cms[$cm];
$cmexporter = new course_module_summary_exporter(null, array('cm' => $cminfo));
$exportedmodules[] = $cmexporter->export($output);
}
$result->coursemodules = $exportedmodules;
return (array) $result;
}
开发者ID:evltuma, 项目名称:moodle, 代码行数:26, 代码来源:user_competency_summary_in_course_exporter.php
示例6: setUp
/**
* Setup testing environment
*/
protected function setUp()
{
parent::setUp();
$this->resetAfterTest();
$this->setAdminUser();
$course = $this->getDataGenerator()->create_course();
$workshop = $this->getDataGenerator()->create_module('workshop', array('strategy' => 'rubric', 'course' => $course));
$cm = get_fast_modinfo($course)->instances['workshop'][$workshop->id];
$this->workshop = new workshop($workshop, $cm, $course);
$this->strategy = new testable_workshop_rubric_strategy($this->workshop);
// prepare dimensions definition
$dim = new stdclass();
$dim->id = 6;
$dim->levels[10] = (object) array('id' => 10, 'grade' => 0);
$dim->levels[13] = (object) array('id' => 13, 'grade' => 2);
$dim->levels[14] = (object) array('id' => 14, 'grade' => 6);
$dim->levels[16] = (object) array('id' => 16, 'grade' => 8);
$this->strategy->dimensions[$dim->id] = $dim;
$dim = new stdclass();
$dim->id = 8;
$dim->levels[17] = (object) array('id' => 17, 'grade' => 0);
$dim->levels[18] = (object) array('id' => 18, 'grade' => 1);
$dim->levels[19] = (object) array('id' => 19, 'grade' => 2);
$dim->levels[20] = (object) array('id' => 20, 'grade' => 3);
$this->strategy->dimensions[$dim->id] = $dim;
$dim = new stdclass();
$dim->id = 10;
$dim->levels[27] = (object) array('id' => 27, 'grade' => 10);
$dim->levels[28] = (object) array('id' => 28, 'grade' => 20);
$dim->levels[29] = (object) array('id' => 29, 'grade' => 30);
$dim->levels[30] = (object) array('id' => 30, 'grade' => 40);
$this->strategy->dimensions[$dim->id] = $dim;
}
开发者ID:evltuma, 项目名称:moodle, 代码行数:36, 代码来源:lib_test.php
示例7: subscriber_overview
/**
* This function generates HTML to display a subscriber overview, primarily used on
* the subscribers page if editing was turned off
*
* @param array $users
* @param object $anonforum
* @param object $course
* @return string
*/
public function subscriber_overview($users, $anonforum, $course)
{
$output = '';
$modinfo = get_fast_modinfo($course);
if (!$users || !is_array($users) || count($users) === 0) {
$output .= $this->output->heading(get_string("nosubscribers", "anonforum"));
} else {
if (!isset($modinfo->instances['anonforum'][$anonforum->id])) {
$output .= $this->output->heading(get_string("invalidmodule", "error"));
} else {
$cm = $modinfo->instances['anonforum'][$anonforum->id];
$canviewemail = in_array('email', get_extra_user_fields(context_module::instance($cm->id)));
$output .= $this->output->heading(get_string("subscribersto", "anonforum", "'" . format_string($anonforum->name) . "'"));
$table = new html_table();
$table->cellpadding = 5;
$table->cellspacing = 5;
$table->tablealign = 'center';
$table->data = array();
foreach ($users as $user) {
$info = array($this->output->user_picture($user, array('courseid' => $course->id)), fullname($user));
if ($canviewemail) {
array_push($info, $user->email);
}
$table->data[] = $info;
}
$output .= html_writer::table($table);
}
}
return $output;
}
开发者ID:MoodleMetaData, 项目名称:MoodleMetaData, 代码行数:39, 代码来源:renderer.php
示例8: get_course_detail_array
/**
* Returns course details in an array ready to be printed.
*
* @global \moodle_database $DB
* @param \course_in_list $course
* @return array
*/
public static function get_course_detail_array(\course_in_list $course)
{
global $DB;
$canaccess = $course->can_access();
$format = \course_get_format($course->id);
$modinfo = \get_fast_modinfo($course->id);
$modules = $modinfo->get_used_module_names();
$sections = array();
if ($format->uses_sections()) {
foreach ($modinfo->get_section_info_all() as $section) {
if ($section->uservisible) {
$sections[] = $format->get_section_name($section);
}
}
}
$category = \coursecat::get($course->category);
$categoryurl = new \moodle_url('/course/management.php', array('categoryid' => $course->category));
$categoryname = $category->get_formatted_name();
$details = array('fullname' => array('key' => \get_string('fullname'), 'value' => $course->get_formatted_fullname()), 'shortname' => array('key' => \get_string('shortname'), 'value' => $course->get_formatted_shortname()), 'idnumber' => array('key' => \get_string('idnumber'), 'value' => s($course->idnumber)), 'category' => array('key' => \get_string('category'), 'value' => \html_writer::link($categoryurl, $categoryname)));
if (has_capability('moodle/site:accessallgroups', $course->get_context())) {
$groups = \groups_get_course_data($course->id);
$details += array('groupings' => array('key' => \get_string('groupings', 'group'), 'value' => count($groups->groupings)), 'groups' => array('key' => \get_string('groups'), 'value' => count($groups->groups)));
}
if ($canaccess) {
$names = \role_get_names($course->get_context());
$sql = 'SELECT ra.roleid, COUNT(ra.id) AS rolecount
FROM {role_assignments} ra
WHERE ra.contextid = :contextid
GROUP BY ra.roleid';
$rolecounts = $DB->get_records_sql($sql, array('contextid' => $course->get_context()->id));
$roledetails = array();
foreach ($rolecounts as $result) {
$a = new \stdClass();
$a->role = $names[$result->roleid]->localname;
$a->count = $result->rolecount;
$roledetails[] = \get_string('assignedrolecount', 'moodle', $a);
}
$details['roleassignments'] = array('key' => \get_string('roleassignments'), 'value' => join('<br />', $roledetails));
}
if ($course->can_review_enrolments()) {
$enrolmentlines = array();
$instances = \enrol_get_instances($course->id, true);
$plugins = \enrol_get_plugins(true);
foreach ($instances as $instance) {
if (!isset($plugins[$instance->enrol])) {
// Weird.
continue;
}
$plugin = $plugins[$instance->enrol];
$enrolmentlines[] = $plugin->get_instance_name($instance);
}
$details['enrolmentmethods'] = array('key' => \get_string('enrolmentmethods'), 'value' => join('<br />', $enrolmentlines));
}
if ($canaccess) {
$details['format'] = array('key' => \get_string('format'), 'value' => \course_get_format($course)->get_format_name());
$details['sections'] = array('key' => \get_string('sections'), 'value' => join('<br />', $sections));
$details['modulesused'] = array('key' => \get_string('modulesused'), 'value' => join('<br />', $modules));
}
return $details;
}
开发者ID:EsdrasCaleb, 项目名称:moodle, 代码行数:67, 代码来源:helper.php
示例9: definition
function definition()
{
global $DB, $COURSE;
$mform =& $this->_form;
$mform->addElement('header', 'displayinfo', get_string('unlocksystemaddheading', 'block_game_content_unlock'));
$eventsarray = content_unlock_generate_events_list();
$mform->addElement('select', 'event', 'Evento', $eventsarray, null);
$mform->addRule('event', null, 'required', null, 'client');
$mform->setType('event', PARAM_TEXT);
$mform->addElement('text', 'description', 'Descrição');
$mform->setType('description', PARAM_TEXT);
$coursemodulessarray = array();
$course = $DB->get_record('course', array('id' => $this->courseid));
$info = get_fast_modinfo($course);
foreach ($info->cms as $cm) {
$coursemodulessarray[$cm->id] = $cm->name;
}
$mform->addElement('select', 'coursemodule', 'Módulo', $coursemodulessarray, null);
$mform->addRule('coursemodule', null, 'required', null, 'client');
$mform->setType('coursemodule', PARAM_INT);
$mform->addElement('select', 'mode', 'Modo', array(0 => 'Por visibilidade', 1 => 'Por grupo'), null);
$mform->addRule('mode', null, 'required', null, 'client');
$mform->setType('mode', PARAM_INT);
$mform->addElement('html', '<hr></hr>');
$mform->addElement('select', 'coursemodulevisibility', 'Visibilidade', array(0 => 'Ocultar', 1 => 'Mostrar'), null);
$mform->setType('coursemodulevisibility', PARAM_INT);
$mform->disabledIf('coursemodulevisibility', 'mode', 'neq', 0);
$mform->addElement('hidden', 'blockid');
$mform->setType('blockid', PARAM_INT);
$mform->addElement('hidden', 'courseid');
$mform->setType('courseid', PARAM_INT);
$this->add_action_buttons(true, 'Adicionar');
}
开发者ID:LoysGibertoni, 项目名称:mdl_block_content_unlock, 代码行数:33, 代码来源:block_game_content_unlock_add_form.php
示例10: section_activity_summary
/**
* Taken from /format/renderer.php
* Generate a summary of the activites in a section
*
* @param stdClass $section The course_section entry from DB
* @param stdClass $course the course record from DB
* @param array $mods (argument not used)
* @return string HTML to output.
*/
public static function section_activity_summary($section, $course, $mods)
{
global $CFG;
require_once $CFG->libdir . '/completionlib.php';
$modinfo = get_fast_modinfo($course);
if (empty($modinfo->sections[$section->section])) {
return '';
}
// Generate array with count of activities in this section.
$sectionmods = array();
$total = 0;
$complete = 0;
$cancomplete = isloggedin() && !isguestuser();
$completioninfo = new completion_info($course);
foreach ($modinfo->sections[$section->section] as $cmid) {
$thismod = $modinfo->cms[$cmid];
if ($thismod->uservisible) {
if (isset($sectionmods[$thismod->modname])) {
$sectionmods[$thismod->modname]['name'] = $thismod->modplural;
$sectionmods[$thismod->modname]['count']++;
} else {
$sectionmods[$thismod->modname]['name'] = $thismod->modfullname;
$sectionmods[$thismod->modname]['count'] = 1;
}
if ($cancomplete && $completioninfo->is_enabled($thismod) != COMPLETION_TRACKING_NONE) {
$total++;
$completiondata = $completioninfo->get_data($thismod, true);
if ($completiondata->completionstate == COMPLETION_COMPLETE || $completiondata->completionstate == COMPLETION_COMPLETE_PASS) {
$complete++;
}
}
}
}
if (empty($sectionmods)) {
// No sections.
return '';
}
// Output section activities summary.
$o = '';
$o .= "<div class='section-summary-activities mdl-right'>";
foreach ($sectionmods as $mod) {
$o .= "<span class='activity-count'>";
$o .= $mod['name'] . ': ' . $mod['count'];
$o .= "</span>";
}
$o .= "</div>";
$a = false;
// Output section completion data.
if ($total > 0) {
$a = new stdClass();
$a->complete = $complete;
$a->total = $total;
$a->percentage = $complete / $total * 100;
$o .= "<div class='section-summary-activities mdl-right'>";
$o .= "<span class='activity-count'>" . get_string('progresstotal', 'completion', $a) . "</span>";
$o .= "</div>";
}
$retobj = (object) array('output' => $o, 'progress' => $a, 'complete' => $complete, 'total' => $total);
return $retobj;
}
开发者ID:nbartley, 项目名称:moodle-theme_snap, 代码行数:69, 代码来源:snap_shared.php
示例11: get_content
function get_content()
{
global $CFG, $COURSE;
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
if ($COURSE->id == $this->instance->pageid) {
$course = $COURSE;
} else {
$course = get_record('course', 'id', $this->instance->pageid);
}
require_once $CFG->dirroot . '/course/lib.php';
$modinfo = get_fast_modinfo($course);
$modfullnames = array();
foreach ($modinfo->cms as $cm) {
if (!$cm->uservisible) {
continue;
}
$modfullnames[$cm->modname] = $cm->modplural;
}
asort($modfullnames, SORT_LOCALE_STRING);
foreach ($modfullnames as $modname => $modfullname) {
if ($modname != 'label') {
$this->content->items[] = '<a href="' . $CFG->wwwroot . '/mod/' . $modname . '/index.php?id=' . $this->instance->pageid . '">' . $modfullname . '</a>';
$this->content->icons[] = '<img src="' . $CFG->modpixpath . '/' . $modname . '/icon.gif" class="icon" alt="" />';
}
}
return $this->content;
}
开发者ID:r007, 项目名称:PMoodle, 代码行数:33, 代码来源:block_activity_modules.php
示例12: display_folder
/**
* Returns html to display the content of mod_folder
* (Description, folder files and optionally Edit button)
*
* @param stdClass $folder record from 'folder' table (please note
* it may not contain fields 'revision' and 'timemodified')
* @return string
*/
public function display_folder(stdClass $folder) {
$output = '';
$folderinstances = get_fast_modinfo($folder->course)->get_instances_of('folder');
if (!isset($folderinstances[$folder->id]) ||
!($cm = $folderinstances[$folder->id]) ||
!$cm->uservisible ||
!($context = context_module::instance($cm->id)) ||
!has_capability('mod/folder:view', $context)) {
// some error in parameters or module is not visible to the user
// don't throw any errors in renderer, just return empty string
return $output;
}
if (trim($folder->intro)) {
if ($folder->display != FOLDER_DISPLAY_INLINE) {
$output .= $this->output->box(format_module_intro('folder', $folder, $cm->id),
'generalbox', 'intro');
} else if ($cm->showdescription) {
// for "display inline" do not filter, filters run at display time.
$output .= format_module_intro('folder', $folder, $cm->id, false);
}
}
$output .= $this->output->box($this->render(new folder_tree($folder, $cm)),
'generalbox foldertree');
// Do not append the edit button on the course page.
if ($folder->display != FOLDER_DISPLAY_INLINE && has_capability('mod/folder:managefiles', $context)) {
$output .= $this->output->container(
$this->output->single_button(new moodle_url('/mod/folder/edit.php',
array('id' => $cm->id)), get_string('edit')),
'mdl-align folder-edit-button');
}
return $output;
}
开发者ID:Jtgadbois, 项目名称:Pedadida, 代码行数:43, 代码来源:renderer.php
示例13: display_folder
/**
* Returns html to display the content of mod_folder
* (Description, folder files and optionally Edit button)
*
* @param stdClass $folder record from 'folder' table (please note
* it may not contain fields 'revision' and 'timemodified')
* @return string
*/
public function display_folder(stdClass $folder)
{
$output = '';
$folderinstances = get_fast_modinfo($folder->course)->get_instances_of('folder');
if (!isset($folderinstances[$folder->id]) || !($cm = $folderinstances[$folder->id]) || !($context = context_module::instance($cm->id))) {
// Some error in parameters.
// Don't throw any errors in renderer, just return empty string.
// Capability to view module must be checked before calling renderer.
return $output;
}
if (trim($folder->intro)) {
if ($folder->display != FOLDER_DISPLAY_INLINE) {
$output .= $this->output->box(format_module_intro('folder', $folder, $cm->id), 'generalbox', 'intro');
} else {
if ($cm->showdescription) {
// for "display inline" do not filter, filters run at display time.
$output .= format_module_intro('folder', $folder, $cm->id, false);
}
}
}
$foldertree = new folder_tree($folder, $cm);
if ($folder->display == FOLDER_DISPLAY_INLINE) {
// Display module name as the name of the root directory.
$foldertree->dir['dirname'] = $cm->get_formatted_name();
}
$output .= $this->output->box($this->render($foldertree), 'generalbox foldertree');
// Do not append the edit button on the course page.
if ($folder->display != FOLDER_DISPLAY_INLINE && has_capability('mod/folder:managefiles', $context)) {
$output .= $this->output->container($this->output->single_button(new moodle_url('/mod/folder/edit.php', array('id' => $cm->id)), get_string('edit')), 'mdl-align folder-edit-button');
}
return $output;
}
开发者ID:alanaipe2015, 项目名称:moodle, 代码行数:40, 代码来源:renderer.php
示例14: filter
function filter($text, array $options = array())
{
$coursectx = $this->context->get_course_context(false);
if (!$coursectx) {
return $text;
}
$courseid = $coursectx->instanceid;
// Initialise/invalidate our trivial cache if dealing with a different course
if (!isset(self::$cachedcourseid) || self::$cachedcourseid !== (int) $courseid) {
self::$activitylist = null;
}
self::$cachedcourseid = (int) $courseid;
/// It may be cached
if (is_null(self::$activitylist)) {
self::$activitylist = array();
$modinfo = get_fast_modinfo($courseid);
if (!empty($modinfo->cms)) {
self::$activitylist = array();
// We will store all the created filters here.
// Create array of visible activities sorted by the name length (we are only interested in properties name and url).
$sortedactivities = array();
foreach ($modinfo->cms as $cm) {
// Exclude labels, hidden activities and activities for group members only.
if ($cm->visible and empty($cm->groupmembersonly) and $cm->has_view()) {
$sortedactivities[] = (object) array('name' => $cm->name, 'url' => $cm->url, 'id' => $cm->id, 'namelen' => strlen($cm->name));
}
}
core_collator::asort_objects_by_property($sortedactivities, 'namelen', SORT_NUMERIC);
foreach ($sortedactivities as $cm) {
$title = s(trim(strip_tags($cm->name)));
$currentname = trim($cm->name);
$entitisedname = s($currentname);
// Avoid empty or unlinkable activity names.
if (!empty($title)) {
$href_tag_begin = html_writer::start_tag('a', array('class' => 'autolink', 'title' => $title, 'href' => $cm->url));
self::$activitylist[$cm->id] = new filterobject($currentname, $href_tag_begin, '</a>', false, true);
if ($currentname != $entitisedname) {
// If name has some entity (& " < >) add that filter too. MDL-17545.
self::$activitylist[$cm->id . '-e'] = new filterobject($entitisedname, $href_tag_begin, '</a>', false, true);
}
}
}
}
}
$filterslist = array();
if (self::$activitylist) {
$cmid = $this->context->instanceid;
if ($this->context->contextlevel == CONTEXT_MODULE && isset(self::$activitylist[$cmid])) {
// remove filterobjects for the current module
$filterslist = array_values(array_diff_key(self::$activitylist, array($cmid => 1, $cmid . '-e' => 1)));
} else {
$filterslist = array_values(self::$activitylist);
}
}
if ($filterslist) {
return $text = filter_phrases($text, $filterslist);
} else {
return $text;
}
}
开发者ID:tyleung, 项目名称:CMPUT401MoodleExams, 代码行数:60, 代码来源:filter.php
示例15: section_activities
function section_activities($secid,$cid){
$course=get_course($cid);
$modinfo = get_fast_modinfo($course);
$mods = $modinfo->get_cms();
$sections = $modinfo->get_section_info_all();
$sec_array = get_sections($sections);
$arr = array();
$cnt=0;
//preparing an array which contains sections and activities
foreach ($mods as $mod) {
$arr[$cnt++]=array('secid'=>$mod->section,'modid'=>$mod->id,'modname'=>$mod->name,'modcontent'=>$mod->content);
//print_r($mod->name);
}
//returns the all activities associated to perticular section in a course
function get_activities($sectionid,$arr)
{
$cnt=0;
$sec_activity_array = array();
for($i=0;$i<count($arr);$i++) {
if($arr[$i]['secid']==$sectionid){
$sec_activity_array[$cnt] = array('modid'=>$arr[$i]['modid'],'modname'=>$arr[$i]['modname'],'modcontent'=>$arr[$i]['modcontent']);
$cnt++;
}
}
return $sec_activity_array;
}
// Get all course sections in a array
function get_sections($sections)
{ $cnt=0;
$sec_array = array();
foreach ($sections as $sec) {
$sec_array[$cnt++] = array('secid'=>$sec->id,'secname'=>$sec->name);
}
return $sec_array;
}
$activities=get_activities($secid,$arr);
$html='';global $CFG;
for($i=0;$i<count($activities);$i++) {
$html .= '<tr >
<td ><span class="mod' . $activities[$i]['modid'] . '">' . ($i + 1) . '</span></td>
<td ><span class="mod' . $activities[$i]['modid'] . '">' . $activities[$i]['modname'] . '</span></td>
<td ><span class="mod' . $activities[$i]['modid'] . '">' . $activities[$i]['modcontent'] . '</span></td>
<td >
<button class="showhide" id="show" value=' . $activities[$i]['modid'] . '>
<img alt="start" src="'.$CFG->wwwroot.'/teacher/testcenter/images/start.png" width="16px"/></button>
<button class="showhide" id="hide" value=' . $activities[$i]['modid'] . '>
<img alt="stop" src="'.$CFG->wwwroot.'/teacher/testcenter/images/stop.png" width="16px"/></button>
</td>
</tr>';
}
echo $html;
}//end of section_activities() function
开发者ID:kmahesh541, 项目名称:mitclone, 代码行数:58, 代码来源:testcenterutil.php
示例16: get_modinfo
public function get_modinfo()
{
// Allow modinfo usage outside is_available etc., so we can use this
// to directly call into condition is_available.
if (!$this->userid) {
throw new \coding_exception('Need to set mock_info userid');
}
return get_fast_modinfo($this->course, $this->userid);
}
开发者ID:janaece, 项目名称:globalclassroom4_clean, 代码行数:9, 代码来源:mock_info.php
示例17: filter
function filter($text, array $options = array())
{
if (!($courseid = get_courseid_from_context($this->context))) {
return $text;
}
// Initialise/invalidate our trivial cache if dealing with a different course
if (!isset(self::$cachedcourseid) || self::$cachedcourseid !== (int) $courseid) {
self::$activitylist = null;
}
self::$cachedcourseid = (int) $courseid;
/// It may be cached
if (is_null(self::$activitylist)) {
self::$activitylist = array();
$modinfo = get_fast_modinfo($courseid);
if (!empty($modinfo->cms)) {
self::$activitylist = array();
/// We will store all the activities here
//Sort modinfo by name length
$sortedactivities = fullclone($modinfo->cms);
usort($sortedactivities, 'filter_activitynames_comparemodulenamesbylength');
foreach ($sortedactivities as $cm) {
//Exclude labels, hidden activities and activities for group members only
if ($cm->visible and empty($cm->groupmembersonly) and $cm->has_view()) {
$title = s(trim(strip_tags($cm->name)));
$currentname = trim($cm->name);
$entitisedname = s($currentname);
/// Avoid empty or unlinkable activity names
if (!empty($title)) {
$href_tag_begin = html_writer::start_tag('a', array('class' => 'autolink', 'title' => $title, 'href' => $cm->get_url()));
self::$activitylist[$cm->id] = new filterobject($currentname, $href_tag_begin, '</a>', false, true);
if ($currentname != $entitisedname) {
/// If name has some entity (& " < >) add that filter too. MDL-17545
self::$activitylist[$cm->id . '-e'] = new filterobject($entitisedname, $href_tag_begin, '</a>', false, true);
}
}
}
}
}
}
$filterslist = array();
if (self::$activitylist) {
$cmid = $this->context->instanceid;
if ($this->context->contextlevel == CONTEXT_MODULE && isset(self::$activitylist[$cmid])) {
// remove filterobjects for the current module
$filterslist = array_diff_key(self::$activitylist, array($cmid => 1, $cmid . '-e' => 1));
} else {
$filterslist = self::$activitylist;
}
}
if ($filterslist) {
return $text = filter_phrases($text, $filterslist);
} else {
return $text;
}
}
开发者ID:Jtgadbois, 项目名称:Pedadida, 代码行数:55, 代码来源:filter.php
示例18: test_usage
/**
* Tests constructing and using condition.
*/
public function test_usage()
{
global $CFG, $USER;
$this->resetAfterTest();
$CFG->enableavailability = true;
// Erase static cache before test.
condition::wipe_static_cache();
// Make a test course and user.
$generator = $this->getDataGenerator();
$course = $generator->create_course();
$user = $generator->create_user();
$generator->enrol_user($user->id, $course->id);
$info = new \core_availability\mock_info($course, $user->id);
// Make 2 test groups, one in a grouping and one not.
$grouping = $generator->create_grouping(array('courseid' => $course->id));
$group1 = $generator->create_group(array('courseid' => $course->id, 'name' => 'G1!'));
groups_assign_grouping($grouping->id, $group1->id);
$group2 = $generator->create_group(array('courseid' => $course->id, 'name' => 'G2!'));
// Do test (not in group).
$cond = new condition((object) array('id' => (int) $group1->id));
// Check if available (when not available).
$this->assertFalse($cond->is_available(false, $info, true, $user->id));
$information = $cond->get_description(false, false, $info);
$this->assertRegExp('~You belong to.*G1!~', $information);
$this->assertTrue($cond->is_available(true, $info, true, $user->id));
// Add user to groups and refresh cache.
groups_add_member($group1, $user);
groups_add_member($group2, $user);
get_fast_modinfo($course->id, 0, true);
// Recheck.
$this->assertTrue($cond->is_available(false, $info, true, $user->id));
$this->assertFalse($cond->is_available(true, $info, true, $user->id));
$information = $cond->get_description(false, true, $info);
$this->assertRegExp('~do not belong to.*G1!~', $information);
// Check group 2 works also.
$cond = new condition((object) array('id' => (int) $group2->id));
$this->assertTrue($cond->is_available(false, $info, true, $user->id));
// What about an 'any group' condition?
$cond = new condition((object) array());
$this->assertTrue($cond->is_available(false, $info, true, $user->id));
$this->assertFalse($cond->is_available(true, $info, true, $user->id));
$information = $cond->get_description(false, true, $info);
$this->assertRegExp('~do not belong to any~', $information);
// Admin user doesn't belong to a group, but they can access it
// either way (positive or NOT).
$this->setAdminUser();
$this->assertTrue($cond->is_available(false, $info, true, $USER->id));
$this->assertTrue($cond->is_available(true, $info, true, $USER->id));
// Group that doesn't exist uses 'missing' text.
$cond = new condition((object) array('id' => $group2->id + 1000));
$this->assertFalse($cond->is_available(false, $info, true, $user->id));
$information = $cond->get_description(false, false, $info);
$this->assertRegExp('~You belong to.*\\(Missing group\\)~', $information);
}
开发者ID:dg711, 项目名称:moodle, 代码行数:57, 代码来源:condition_test.php
示例19: setUp
/**
* Setup testing environment
*/
protected function setUp()
{
parent::setUp();
$this->resetAfterTest();
$this->setAdminUser();
$course = $this->getDataGenerator()->create_course();
$workshop = $this->getDataGenerator()->create_module('workshop', array('strategy' => 'numerrors', 'course' => $course));
$cm = get_fast_modinfo($course)->instances['workshop'][$workshop->id];
$this->workshop = new workshop($workshop, $cm, $course);
$this->strategy = new testable_workshop_numerrors_strategy($this->workshop);
}
开发者ID:evltuma, 项目名称:moodle, 代码行数:14, 代码来源:lib_test.php
PacktPublishing/Python-Machine-Learning-Second-Edition: Python Machine Learning
阅读:974| 2022-08-18
sussillo/hfopt-matlab: A parallel, cpu-based matlab implemention of the Hessian
阅读:998| 2022-08-17
win7系统电脑使用过程中有不少朋友表示遇到过win7系统USB驱动器RAM的状况,当出现win7
阅读:890| 2022-11-06
emersion/go-ostatus: An OStatus library written in Go
阅读:751| 2022-08-17
The vCenter Server contains a server-side request forgery (SSRF) vulnerability.
阅读:1068| 2022-07-29
page { background-color: #fbf9fe; height: 100%; } /*这个100%屏幕高度*/ .containe
阅读:569| 2022-07-18
elipapa/markdown-cv: a simple template to write your CV in a readable markdown f
阅读:514| 2022-08-17
zju-sclab/NDT-library: These is ndt library for ndt_mapping and ndt_localization
阅读:734| 2022-08-16
Call Me Maybe 中英字幕 对于加拿大歌手卡莉·蕾·吉普森很多人有些陌生,她隶属于贾
阅读:632| 2022-11-06
TComponent类TComponent类直接由TPersistent派生。TComponent的独特特征是它的属性能
阅读:894| 2022-07-18
请发表评论