コード例 #1
0
 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>';
 }
コード例 #2
0
ファイル: locallib.php プロジェクト: OctaveBabel/moodle-itop
/**
 * 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;
}
コード例 #3
0
 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);
 }
コード例 #4
0
 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;
 }
コード例 #5
0
 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;
 }
コード例 #6
0
ファイル: lib_test.php プロジェクト: evltuma/moodle
 /**
  * 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;
 }
コード例 #7
0
 /**
  * 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;
 }
コード例 #8
0
ファイル: helper.php プロジェクト: EsdrasCaleb/moodle
 /**
  * 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;
 }
 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');
 }
コード例 #10
0
 /**
  * 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;
 }
コード例 #11
0
 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;
 }
コード例 #12
0
ファイル: renderer.php プロジェクト: Jtgadbois/Pedadida
    /**
     * 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;
    }
コード例 #13
0
ファイル: renderer.php プロジェクト: alanaipe2015/moodle
 /**
  * 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;
 }
コード例 #14
0
 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 (&amp; &quot; &lt; &gt;) 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;
     }
 }
コード例 #15
0
            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
コード例 #16
0
 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);
 }
コード例 #17
0
ファイル: filter.php プロジェクト: Jtgadbois/Pedadida
 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 (&amp; &quot; &lt; &gt;) 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;
     }
 }
コード例 #18
0
ファイル: condition_test.php プロジェクト: dg711/moodle
 /**
  * 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);
 }
コード例 #19
0
ファイル: lib_test.php プロジェクト: evltuma/moodle
 /**
  * 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);
 }
コード例 #20
0
ファイル: lib_test.php プロジェクト: Gavinthisisit/Moodle
 /**
  * Setup testing environment
  */
 protected function setUp()
 {
     parent::setUp();
     $this->resetAfterTest();
     $this->setAdminUser();
     $course = $this->getDataGenerator()->create_course();
     $teamwork = $this->getDataGenerator()->create_module('teamwork', array('evaluation' => 'best', 'course' => $course));
     $cm = get_fast_modinfo($course)->instances['teamwork'][$teamwork->id];
     $this->teamwork = new teamwork($teamwork, $cm, $course);
     $this->evaluator = new testable_teamwork_best_evaluation($this->teamwork);
 }
コード例 #21
0
ファイル: lib_test.php プロジェクト: Gavinthisisit/Moodle
 /**
  * Setup testing environment
  */
 protected function setUp()
 {
     parent::setUp();
     $this->resetAfterTest();
     $this->setAdminUser();
     $course = $this->getDataGenerator()->create_course();
     $teamwork = $this->getDataGenerator()->create_module('teamwork', array('strategy' => 'accumulative', 'course' => $course));
     $cm = get_fast_modinfo($course)->instances['teamwork'][$teamwork->id];
     $this->teamwork = new teamwork($teamwork, $cm, $course);
     $this->strategy = new testable_teamwork_accumulative_strategy($this->teamwork);
 }
コード例 #22
0
/**
 * Get a list of mediagallery's the current user has permission to import a
 * gallery into.
 * @return array List of mediagallery's.'
 */
function mediagallery_get_sample_targets($course, $gallery)
{
    $list = array();
    $modinfo = get_fast_modinfo($course);
    foreach ($modinfo->get_instances_of('mediagallery') as $mgid => $cm) {
        if (!$cm->uservisible) {
            continue;
        }
        $list[$cm->instance] = $cm->name;
    }
    return $list;
}
コード例 #23
0
ファイル: lib.php プロジェクト: masaterutakeno/MoodleMobile
 /**
  * Allows course format to execute code on moodle_page::set_course()
  *
  * If user is on course view page and there is no scorm module added to the course
  * and the user has 'moodle/course:update' capability, redirect to create module
  * form. This function is executed before the output starts
  *
  * @param moodle_page $page instance of page calling set_course
  */
 public function page_set_course(moodle_page $page)
 {
     global $PAGE;
     if ($PAGE == $page && $page->has_set_url() && $page->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
         $modinfo = get_fast_modinfo($this->courseid);
         if (empty($modinfo->instances['scorm']) && has_capability('moodle/course:update', context_course::instance($this->courseid))) {
             // Redirect to create a new activity
             $url = new moodle_url('/course/modedit.php', array('course' => $this->courseid, 'section' => 0, 'add' => 'scorm'));
             redirect($url);
         }
     }
 }
コード例 #24
0
ファイル: base_mod.php プロジェクト: IFPBMoodle/moodle
 /**
  * Gets the course module for the required instanceid + modulename.
  *
  * The returned data depends on the logged user, when calling this through
  * self::get_document the admin user is used so everything would be returned.
  *
  * No need more internal caching here, modinfo is already cached.
  *
  * @throws \dml_missing_record_exception
  * @param string $modulename The module name
  * @param int $instanceid Module instance id (depends on the module)
  * @param int $courseid Helps speeding up things
  * @return \cm_info
  */
 protected function get_cm($modulename, $instanceid, $courseid)
 {
     $modinfo = get_fast_modinfo($courseid);
     // Hopefully not many, they are indexed by cmid.
     $instances = $modinfo->get_instances_of($modulename);
     foreach ($instances as $cminfo) {
         if ($cminfo->instance == $instanceid) {
             return $cminfo;
         }
     }
     // Nothing found.
     throw new \dml_missing_record_exception($modulename);
     return $cm;
 }
コード例 #25
0
 function createLO(LOId $loId)
 {
     // get the id of the section in Moodle
     $id = Intuitel::getIDFactory()->getIdfromLoId($loId);
     $cm = block_intuitel_get_cm($id);
     if ($cm == false) {
         throw new UnknownLOException();
     } else {
         $courseinfo = get_fast_modinfo(block_intuitel_get_cm($id)->course);
         $cm_info = $courseinfo->get_cm($id);
         //set the data of the object from Moodle internal data
         $LOModule = $this->createLOFromNative($cm_info);
         return $LOModule;
     }
 }
コード例 #26
0
ファイル: lib.php プロジェクト: jrlamb/alexBado
/**
 *
 * @return NULL
 */
function get_course_jcode()
{
    if ($this->coursemodule) {
        return $this->coursemodule;
    }
    if (!$this->context) {
        return null;
    }
    if ($this->context->contextlevel == CONTEXT_MODULE) {
        $modinfo = get_fast_modinfo($this->get_course());
        $this->coursemodule = $modinfo->get_cm($this->context->instanceid);
        return $this->coursemodule;
    }
    return null;
}
コード例 #27
0
ファイル: locallib.php プロジェクト: CTANZ/moodle-mod_equella
function equella_get_course_contents($courseid, $sectionid)
{
    global $DB, $CFG;
    $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
    if ($course->format != 'site') {
        if (!file_exists($CFG->dirroot . '/course/format/' . $course->format . '/lib.php')) {
            throw new moodle_exception('cannotgetcoursecontents', 'webservice', '', null, get_string('courseformatnotfound', 'error', '', $course->format));
        } else {
            require_once $CFG->dirroot . '/course/format/' . $course->format . '/lib.php';
        }
    }
    $context = context_course::instance($course->id, IGNORE_MISSING);
    $coursecontents = new stdClass();
    $coursecontents->id = $course->id;
    $coursecontents->code = $course->idnumber;
    $coursecontents->name = $course->fullname;
    $coursecontents->targetable = false;
    $coursecontents->folders = array();
    if ($course->visible or has_capability('moodle/course:viewhiddencourses', $context)) {
        // retrieve sections
        $modinfo = get_fast_modinfo($course);
        $sections = $modinfo->get_section_info_all();
        // for each sections (first displayed to last displayed)
        foreach ($sections as $key => $section) {
            $sectionvalues = new stdClass();
            if ((int) $section->section == (int) $sectionid) {
                $sectionvalues->selected = true;
            }
            $sectionvalues->id = $section->section;
            $sectionvalues->name = get_section_name($course, $section);
            $sectionvalues->folders = array();
            $sectioncontents = array();
            // foreach ($modinfo->sections[$section->section] as $cmid) {
            // $cm = $modinfo->cms[$cmid];
            // if (!$cm->uservisible) {
            // continue;
            // }
            // $module = array();
            // $module['id'] = $cm->id;
            // $module['name'] = format_string($cm->name, true);
            // $sectioncontents[] = $module;
            // }
            // $sectionvalues->folders = $sectioncontents;
            $coursecontents->folders[] = $sectionvalues;
        }
    }
    return $coursecontents;
}
コード例 #28
0
 /**
  * Creates an Intuitel LO of type course
  * @param LOId $loId
  * @return \intuitel\course
  */
 function createLO(LOId $loId)
 {
     $hasParent = null;
     // Courses do not have parents.
     $hasPrecedingSib = null;
     // Courses do not have following LOs.
     // Get the id of the course in Moodle.
     $id = Intuitel::getIDFactory()->getIdfromLoId($loId);
     // get information of the course
     try {
         $course_fast_info = get_fast_modinfo($id);
         $course = $this->createLOFromNative($course_fast_info);
         return $course;
     } catch (\dml_missing_record_exception $ex) {
         throw new UnknownLOException();
     }
 }
コード例 #29
0
 private function parse_activity($param)
 {
     global $COURSE;
     try {
         $modinfo = get_fast_modinfo($COURSE->id);
         $sections = array();
         if (isset($param['section'])) {
             $section[] = $modinfo->sections[$param['section']];
         } else {
             $section = $modinfo->sections;
         }
         foreach ($section as $s) {
             foreach ($s as $key => $m) {
                 $mi = $modinfo->get_cm($m);
                 if (!$mi->uservisible && empty($mi->availableinfo)) {
                     continue;
                 }
                 if (empty($mi->url)) {
                     continue;
                 }
                 if (isset($param['name']) && $param['name'] == $mi->name || isset($param['id']) && $param['id'] == $mi->id) {
                     if (isset($param['title'])) {
                         $title = $param['title'];
                     } else {
                         $title = $mi->name;
                     }
                     $attrs = array();
                     if (isset($param['target'])) {
                         $attrs['target'] = $param['target'];
                     }
                     if (isset($param['class'])) {
                         $attrs['class'] = $param['class'];
                     }
                     if (isset($param['role'])) {
                         $attrs['role'] = $param['role'];
                     }
                     return html_writer::link($mi->url, $title, $attrs);
                 }
             }
         }
         return "ERROR: ACTIVITY NOT FOUND";
     } catch (Exception $e) {
         print_r($e);
         return "EXCEPTION";
     }
 }
コード例 #30
0
 /**
  * Finds all subscribed users
  *
  * @param string $search
  * @return array
  */
 public function find_users($search)
 {
     global $DB;
     list($wherecondition, $params) = $this->search_sql($search, 'u');
     $params['twfid'] = $this->twfid;
     // only active enrolled or everybody on the frontpage
     list($esql, $eparams) = get_enrolled_sql($this->context, '', $this->currentgroup, true);
     $fields = $this->required_fields_sql('u');
     list($sort, $sortparams) = users_order_by_sql('u', $search, $this->accesscontext);
     $params = array_merge($params, $eparams, $sortparams);
     $subscribers = $DB->get_records_sql("SELECT {$fields}\n                                               FROM {user} u\n                                               JOIN ({$esql}) je ON je.id = u.id\n                                               JOIN {twf_subscriptions} s ON s.userid = u.id\n                                              WHERE {$wherecondition} AND s.twf = :twfid\n                                           ORDER BY {$sort}", $params);
     $cm = get_coursemodule_from_instance('twf', $this->twfid);
     $modinfo = get_fast_modinfo($cm->course);
     $info = new \core_availability\info_module($modinfo->get_cm($cm->id));
     $subscribers = $info->filter_user_list($subscribers);
     return array(get_string("existingsubscribers", 'twf') => $subscribers);
 }