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


PHP info::get_course方法代码示例

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


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

示例1: is_available

 /**
  * Determines whether a particular item is currently available
  * according to this availability condition.
  *
  * @param bool $not Set true if we are inverting the condition.
  * @param info $info Item we're checking.
  * @param bool $grabthelot Performance hint: if true, caches information
  *   required for all course-modules, to make the front page and similar
  *   pages work more quickly (works only for current user).
  * @param int $userid User ID to check availability for.
  * @return bool True if available.
  */
 public function is_available($not, \core_availability\info $info, $grabthelot, $userid)
 {
     $available = false;
     if ($this->requiredlvl > 0) {
         $currentlvl = $this->get_user_level($info->get_course()->id, $userid);
         if ($currentlvl >= $this->requiredlvl) {
             $available = true;
         } else {
             $available = false;
         }
         if ($not) {
             $available = !$available;
         }
     }
     return $available;
 }
开发者ID:antoniorodrigues,项目名称:redes-digitais,代码行数:28,代码来源:condition.php

示例2: is_available

 public function is_available($not, \core_availability\info $info, $grabthelot, $userid)
 {
     global $PAGE, $CFG;
     require_once $CFG->dirroot . '/enrol/locallib.php';
     $course = $info->get_course();
     $enrolmanager = new \course_enrolment_manager($PAGE, $course);
     $allow = true;
     if (!($enrolments = $enrolmanager->get_user_enrolments($userid))) {
         $allow = false;
     }
     foreach ($enrolments as $enrol) {
         if (time() - $enrol->timestart < $this->mintimesinceenrol) {
             $allow = false;
         }
     }
     if (!$not) {
         $allow = !$allow;
     }
     return $allow;
 }
开发者ID:danielneis,项目名称:moodle-availability_timesinceenrol,代码行数:20,代码来源:condition.php

示例3: get_description

 public function get_description($full, $not, \core_availability\info $info)
 {
     $course = $info->get_course();
     // Display the fieldname into current lang.
     if ($this->customfield) {
         // Is a custom profile field (will use multilang).
         $customfields = self::get_custom_profile_fields();
         if (array_key_exists($this->customfield, $customfields)) {
             $translatedfieldname = $customfields[$this->customfield]->name;
         } else {
             $translatedfieldname = get_string('missing', 'availability_profile', $this->customfield);
         }
     } else {
         $translatedfieldname = get_user_field_name($this->standardfield);
     }
     $context = \context_course::instance($course->id);
     $a = new \stdClass();
     $a->field = format_string($translatedfieldname, true, array('context' => $context));
     $a->value = s($this->value);
     if ($not) {
         // When doing NOT strings, we replace the operator with its inverse.
         // Some of them don't have inverses, so for those we use a new
         // identifier which is only used for this lang string.
         switch ($this->operator) {
             case self::OP_CONTAINS:
                 $opname = self::OP_DOES_NOT_CONTAIN;
                 break;
             case self::OP_DOES_NOT_CONTAIN:
                 $opname = self::OP_CONTAINS;
                 break;
             case self::OP_ENDS_WITH:
                 $opname = 'notendswith';
                 break;
             case self::OP_IS_EMPTY:
                 $opname = self::OP_IS_NOT_EMPTY;
                 break;
             case self::OP_IS_EQUAL_TO:
                 $opname = 'notisequalto';
                 break;
             case self::OP_IS_NOT_EMPTY:
                 $opname = self::OP_IS_EMPTY;
                 break;
             case self::OP_STARTS_WITH:
                 $opname = 'notstartswith';
                 break;
             default:
                 throw new \coding_exception('Unexpected operator: ' . $this->operator);
         }
     } else {
         $opname = $this->operator;
     }
     return get_string('requires_' . $opname, 'availability_profile', $a);
 }
开发者ID:abhilash1994,项目名称:moodle,代码行数:53,代码来源:condition.php

示例4: get_description

 public function get_description($full, $not, \core_availability\info $info)
 {
     $course = $info->get_course();
     // String depends on type of requirement. We are coy about
     // the actual numbers, in case grades aren't released to
     // students.
     if (is_null($this->min) && is_null($this->max)) {
         $string = 'any';
     } else {
         if (is_null($this->max)) {
             $string = 'min';
         } else {
             if (is_null($this->min)) {
                 $string = 'max';
             } else {
                 $string = 'range';
             }
         }
     }
     if ($not) {
         // The specific strings don't make as much sense with 'not'.
         if ($string === 'any') {
             $string = 'notany';
         } else {
             $string = 'notgeneral';
         }
     }
     $name = self::get_cached_grade_name($course->id, $this->gradeitemid);
     return get_string('requires_' . $string, 'availability_grade', $name);
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:30,代码来源:condition.php

示例5: get_description

 public function get_description($full, $not, \core_availability\info $info)
 {
     global $DB;
     $course = $info->get_course();
     // Need to get the name for the grouping. Unfortunately this requires
     // a database query. To save queries, get all groupings for course at
     // once in a static cache.
     $groupingid = $this->get_grouping_id($info);
     if (!array_key_exists($groupingid, self::$groupingnames)) {
         $coursegroupings = $DB->get_records('groupings', array('courseid' => $course->id), '', 'id, name');
         foreach ($coursegroupings as $rec) {
             self::$groupingnames[$rec->id] = $rec->name;
         }
     }
     // If it still doesn't exist, it must have been misplaced.
     if (!array_key_exists($groupingid, self::$groupingnames)) {
         $name = get_string('missing', 'availability_grouping');
     } else {
         $context = \context_course::instance($course->id);
         $name = format_string(self::$groupingnames[$groupingid], true, array('context' => $context));
     }
     return get_string($not ? 'requires_notgrouping' : 'requires_grouping', 'availability_grouping', $name);
 }
开发者ID:gwsd2015,项目名称:LogiClass,代码行数:23,代码来源:condition.php

示例6: get_user_list_sql

 public function get_user_list_sql($not, \core_availability\info $info, $onlyactive)
 {
     global $DB;
     // Get enrolled users with access all groups. These always are allowed.
     list($aagsql, $aagparams) = get_enrolled_sql($info->get_context(), 'moodle/site:accessallgroups', 0, $onlyactive);
     // Get all enrolled users.
     list($enrolsql, $enrolparams) = get_enrolled_sql($info->get_context(), '', 0, $onlyactive);
     // Condition for specified or any group.
     $matchparams = array();
     if ($this->groupid) {
         $matchsql = "SELECT 1\n                           FROM {groups_members} gm\n                          WHERE gm.userid = userids.id\n                                AND gm.groupid = " . self::unique_sql_parameter($matchparams, $this->groupid);
     } else {
         $matchsql = "SELECT 1\n                           FROM {groups_members} gm\n                           JOIN {groups} g ON g.id = gm.groupid\n                          WHERE gm.userid = userids.id\n                                AND g.courseid = " . self::unique_sql_parameter($matchparams, $info->get_course()->id);
     }
     // Overall query combines all this.
     $condition = $not ? 'NOT' : '';
     $sql = "SELECT userids.id\n                  FROM ({$enrolsql}) userids\n                 WHERE (userids.id IN ({$aagsql})) OR {$condition} EXISTS ({$matchsql})";
     return array($sql, array_merge($enrolparams, $aagparams, $matchparams));
 }
开发者ID:Keneth1212,项目名称:moodle,代码行数:19,代码来源:condition.php

示例7: filter_user_list

 public function filter_user_list(array $users, $not, \core_availability\info $info, \core_availability\capability_checker $checker)
 {
     global $CFG, $DB;
     require_once $CFG->libdir . '/grouplib.php';
     $course = $info->get_course();
     // List users for this course who match the condition.
     if ($this->groupid) {
         $groupusers = groups_get_members($this->groupid, 'u.id', 'u.id ASC');
     } else {
         $groupusers = $DB->get_records_sql("\n                    SELECT DISTINCT gm.userid\n                      FROM {groups} g\n                      JOIN {groups_members} gm ON gm.groupid = g.id\n                     WHERE g.courseid = ?", array($course->id));
     }
     // List users who have access all groups.
     $aagusers = $checker->get_users_by_capability('moodle/site:accessallgroups');
     // Filter the user list.
     $result = array();
     foreach ($users as $id => $user) {
         // Always include users with access all groups.
         if (array_key_exists($id, $aagusers)) {
             $result[$id] = $user;
             continue;
         }
         // Other users are included or not based on group membership.
         $allow = array_key_exists($id, $groupusers);
         if ($not) {
             $allow = !$allow;
         }
         if ($allow) {
             $result[$id] = $user;
         }
     }
     return $result;
 }
开发者ID:gwsd2015,项目名称:LogiClass,代码行数:32,代码来源:condition.php

示例8: get_description

 public function get_description($full, $not, \core_availability\info $info)
 {
     global $DB;
     $context = \context_course::instance($info->get_course()->id);
     $role = $DB->get_record('role', array('id' => $this->roleid));
     if (!$role) {
         $missing = get_string('missing', 'availability_role');
         return get_string($not ? 'requires_notrole' : 'requires_role', 'availability_role', $missing);
     } else {
         $name = role_get_name($role, $context);
         return get_string($not ? 'requires_notrole' : 'requires_role', 'availability_role', $name);
     }
 }
开发者ID:moodleuulm,项目名称:moodle-availability_role,代码行数:13,代码来源:condition.php


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