当前位置: 首页>>代码示例>>PHP>>正文


PHP course_modinfo::get_instances_of方法代码示例

本文整理汇总了PHP中course_modinfo::get_instances_of方法的典型用法代码示例。如果您正苦于以下问题:PHP course_modinfo::get_instances_of方法的具体用法?PHP course_modinfo::get_instances_of怎么用?PHP course_modinfo::get_instances_of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在course_modinfo的用法示例。


在下文中一共展示了course_modinfo::get_instances_of方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_course_test_data

 /**
  * Gets the data required to fill the test plan template with the database contents.
  *
  * @param int $targetcourseid The target course id
  * @return stdClass The ids required by the test plan
  */
 protected static function get_course_test_data($targetcourseid)
 {
     global $DB, $USER;
     $data = new stdClass();
     // Getting course contents info as the current user (will be an admin).
     $course = new stdClass();
     $course->id = $targetcourseid;
     $courseinfo = new course_modinfo($course, $USER->id);
     // Getting the first page module instance.
     if (!($pages = $courseinfo->get_instances_of('page'))) {
         print_error('error_nopageinstances', 'tool_generator');
     }
     $data->pageid = reset($pages)->id;
     // Getting the first forum module instance and it's first discussion and reply as well.
     if (!($forums = $courseinfo->get_instances_of('forum'))) {
         print_error('error_noforuminstances', 'tool_generator');
     }
     $forum = reset($forums);
     // Getting the first discussion (and reply).
     if (!($discussions = forum_get_discussions($forum, 'd.timemodified ASC', false, -1, 1))) {
         print_error('error_noforumdiscussions', 'tool_generator');
     }
     $discussion = reset($discussions);
     $data->forumid = $forum->id;
     $data->forumdiscussionid = $discussion->discussion;
     $data->forumreplyid = $discussion->id;
     // According to the current test plan.
     return $data;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:35,代码来源:testplan_backend.php

示例2: fill_table_recursive

 private function fill_table_recursive(&$element)
 {
     global $DB, $CFG;
     $type = $element['type'];
     $depth = $element['depth'];
     $grade_object = $element['object'];
     $eid = $grade_object->id;
     $element['userid'] = $this->user->id;
     $fullname = $this->gtree->get_element_header($element, true, true, true);
     $data = array();
     $hidden = '';
     $excluded = '';
     $class = '';
     $classfeedback = '';
     // If this is a hidden grade category, hide it completely from the user
     if ($type == 'category' && $grade_object->is_hidden() && !$this->canviewhidden && ($this->showhiddenitems == GRADE_REPORT_USER_HIDE_HIDDEN || $this->showhiddenitems == GRADE_REPORT_USER_HIDE_UNTIL && !$grade_object->is_hiddenuntil())) {
         return false;
     }
     if ($type == 'category') {
         $this->evenodd[$depth] = ($this->evenodd[$depth] + 1) % 2;
     }
     $alter = $this->evenodd[$depth] == 0 ? 'even' : 'odd';
     /// Process those items that have scores associated
     if ($type == 'item' or $type == 'categoryitem' or $type == 'courseitem') {
         $header_row = "row_{$eid}_{$this->user->id}";
         $header_cat = "cat_{$grade_object->categoryid}_{$this->user->id}";
         if (!($grade_grade = grade_grade::fetch(array('itemid' => $grade_object->id, 'userid' => $this->user->id)))) {
             $grade_grade = new grade_grade();
             $grade_grade->userid = $this->user->id;
             $grade_grade->itemid = $grade_object->id;
         }
         $grade_grade->load_grade_item();
         /// Hidden Items
         if ($grade_grade->grade_item->is_hidden()) {
             $hidden = ' dimmed_text';
         }
         $hide = false;
         // If this is a hidden grade item, hide it completely from the user.
         if ($grade_grade->is_hidden() && !$this->canviewhidden && ($this->showhiddenitems == GRADE_REPORT_USER_HIDE_HIDDEN || $this->showhiddenitems == GRADE_REPORT_USER_HIDE_UNTIL && !$grade_grade->is_hiddenuntil())) {
             $hide = true;
         } else {
             if (!empty($grade_object->itemmodule) && !empty($grade_object->iteminstance)) {
                 // The grade object can be marked visible but still be hidden if
                 // the student cannot see the activity due to conditional access
                 // and it's set to be hidden entirely.
                 $instances = $this->modinfo->get_instances_of($grade_object->itemmodule);
                 if (!empty($instances[$grade_object->iteminstance])) {
                     $cm = $instances[$grade_object->iteminstance];
                     if (!$cm->uservisible) {
                         // If there is 'availableinfo' text then it is only greyed
                         // out and not entirely hidden.
                         if (!$cm->availableinfo) {
                             $hide = true;
                         }
                     }
                 }
             }
         }
         if (!$hide) {
             /// Excluded Item
             if ($grade_grade->is_excluded()) {
                 $fullname .= ' [' . get_string('excluded', 'grades') . ']';
                 $excluded = ' excluded';
             }
             /// Other class information
             $class = "{$hidden} {$excluded}";
             if ($this->switch) {
                 // alter style based on whether aggregation is first or last
                 $class .= ($type == 'categoryitem' or $type == 'courseitem') ? " " . $alter . "d{$depth} baggt b2b" : " item b1b";
             } else {
                 $class .= ($type == 'categoryitem' or $type == 'courseitem') ? " " . $alter . "d{$depth} baggb" : " item b1b";
             }
             if ($type == 'categoryitem' or $type == 'courseitem') {
                 $header_cat = "cat_{$grade_object->iteminstance}_{$this->user->id}";
             }
             /// Name
             $data['itemname']['content'] = $fullname;
             $data['itemname']['class'] = $class;
             $data['itemname']['colspan'] = $this->maxdepth - $depth;
             $data['itemname']['celltype'] = 'th';
             $data['itemname']['id'] = $header_row;
             /// Actual Grade
             $gradeval = $grade_grade->finalgrade;
             if (!$this->canviewhidden) {
                 /// Virtual Grade (may be calculated excluding hidden items etc).
                 $adjustedgrade = $this->blank_hidden_total_and_adjust_bounds($this->courseid, $grade_grade->grade_item, $gradeval);
                 $gradeval = $adjustedgrade['grade'];
                 // We temporarily adjust the view of this grade item - because the min and
                 // max are affected by the hidden values in the aggregation.
                 $grade_grade->grade_item->grademax = $adjustedgrade['grademax'];
                 $grade_grade->grade_item->grademin = $adjustedgrade['grademin'];
             }
             if ($this->showfeedback) {
                 // Copy $class before appending itemcenter as feedback should not be centered
                 $classfeedback = $class;
             }
             $class .= " itemcenter ";
             if ($this->showweight) {
                 $data['weight']['class'] = $class;
                 $data['weight']['content'] = '-';
//.........这里部分代码省略.........
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:101,代码来源:lib.php

示例3: fill_table_recursive

    /**
     * Fill the table with data.
     *
     * @param $element - An array containing the table data for the current row.
     */
    private function fill_table_recursive(&$element) {
        global $DB, $CFG;

        $type = $element['type'];
        $depth = $element['depth'];
        $grade_object = $element['object'];
        $eid = $grade_object->id;
        $element['userid'] = $this->user->id;
        $fullname = $this->gtree->get_element_header($element, true, true, true, true, true);
        $data = array();
        $hidden = '';
        $excluded = '';
        $itemlevel = ($type == 'categoryitem' || $type == 'category' || $type == 'courseitem') ? $depth : ($depth + 1);
        $class = 'level' . $itemlevel . ' level' . ($itemlevel % 2 ? 'odd' : 'even');
        $classfeedback = '';

        // If this is a hidden grade category, hide it completely from the user
        if ($type == 'category' && $grade_object->is_hidden() && !$this->canviewhidden && (
                $this->showhiddenitems == GRADE_REPORT_USER_HIDE_HIDDEN ||
                ($this->showhiddenitems == GRADE_REPORT_USER_HIDE_UNTIL && !$grade_object->is_hiddenuntil()))) {
            return false;
        }

        if ($type == 'category') {
            $this->evenodd[$depth] = (($this->evenodd[$depth] + 1) % 2);
        }
        $alter = ($this->evenodd[$depth] == 0) ? 'even' : 'odd';

        /// Process those items that have scores associated
        if ($type == 'item' or $type == 'categoryitem' or $type == 'courseitem') {
            $header_row = "row_{$eid}_{$this->user->id}";
            $header_cat = "cat_{$grade_object->categoryid}_{$this->user->id}";

            if (! $grade_grade = grade_grade::fetch(array('itemid'=>$grade_object->id,'userid'=>$this->user->id))) {
                $grade_grade = new grade_grade();
                $grade_grade->userid = $this->user->id;
                $grade_grade->itemid = $grade_object->id;
            }

            $grade_grade->load_grade_item();

            /// Hidden Items
            if ($grade_grade->grade_item->is_hidden()) {
                $hidden = ' dimmed_text';
            }

            $hide = false;
            // If this is a hidden grade item, hide it completely from the user.
            if ($grade_grade->is_hidden() && !$this->canviewhidden && (
                    $this->showhiddenitems == GRADE_REPORT_USER_HIDE_HIDDEN ||
                    ($this->showhiddenitems == GRADE_REPORT_USER_HIDE_UNTIL && !$grade_grade->is_hiddenuntil()))) {
                $hide = true;
            } else if (!empty($grade_object->itemmodule) && !empty($grade_object->iteminstance)) {
                // The grade object can be marked visible but still be hidden if
                // the student cannot see the activity due to conditional access
                // and it's set to be hidden entirely.
                $instances = $this->modinfo->get_instances_of($grade_object->itemmodule);
                if (!empty($instances[$grade_object->iteminstance])) {
                    $cm = $instances[$grade_object->iteminstance];
                    if (!$cm->uservisible) {
                        // If there is 'availableinfo' text then it is only greyed
                        // out and not entirely hidden.
                        if (!$cm->availableinfo) {
                            $hide = true;
                        }
                    }
                }
            }

            // Actual Grade - We need to calculate this whether the row is hidden or not.
            $gradeval = $grade_grade->finalgrade;
            $hint = $grade_grade->get_aggregation_hint();
            if (!$this->canviewhidden) {
                /// Virtual Grade (may be calculated excluding hidden items etc).
                $adjustedgrade = $this->blank_hidden_total_and_adjust_bounds($this->courseid,
                                                                             $grade_grade->grade_item,
                                                                             $gradeval);

                $gradeval = $adjustedgrade['grade'];

                // We temporarily adjust the view of this grade item - because the min and
                // max are affected by the hidden values in the aggregation.
                $grade_grade->grade_item->grademax = $adjustedgrade['grademax'];
                $grade_grade->grade_item->grademin = $adjustedgrade['grademin'];
                $hint['status'] = $adjustedgrade['aggregationstatus'];
                $hint['weight'] = $adjustedgrade['aggregationweight'];
            } else {
                // The max and min for an aggregation may be different to the grade_item.
                if (!is_null($gradeval)) {
                    $grade_grade->grade_item->grademax = $grade_grade->rawgrademax;
                    $grade_grade->grade_item->grademin = $grade_grade->rawgrademin;
                }
            }


//.........这里部分代码省略.........
开发者ID:anilch,项目名称:Personel,代码行数:101,代码来源:lib.php


注:本文中的course_modinfo::get_instances_of方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。