當前位置: 首頁>>代碼示例>>PHP>>正文


PHP info::get_course_module方法代碼示例

本文整理匯總了PHP中core_availability\info::get_course_module方法的典型用法代碼示例。如果您正苦於以下問題:PHP info::get_course_module方法的具體用法?PHP info::get_course_module怎麽用?PHP info::get_course_module使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在core_availability\info的用法示例。


在下文中一共展示了info::get_course_module方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: get_description

 /**
  * Obtains a string describing this restriction (whether or not
  * it actually applies). Used to obtain information that is displayed to
  * students if the activity is not available to them, and for staff to see
  * what conditions are.
  *
  * The $full parameter can be used to distinguish between 'staff' cases
  * (when displaying all information about the activity) and 'student' cases
  * (when displaying only conditions they don't meet).
  *
  * If implementations require a course or modinfo, they should use
  * the get methods in $info.
  *
  * The special string <AVAILABILITY_CMNAME_123/> can be returned, where
  * 123 is any number. It will be replaced with the correctly-formatted
  * name for that activity.
  *
  * @param bool $full Set true if this is the 'full information' view
  * @param bool $not Set true if we are inverting the condition
  * @param info $info Item we're checking
  * @return string Information string (for admin) about all restrictions on
  *   this item
  */
 public function get_description($full, $not, info $info)
 {
     global $USER, $PAGE;
     static $jsadded = false;
     if (!$info instanceof info_module) {
         return '';
         // Should only be possible against activities, not sections.
     }
     $cm = $info->get_course_module();
     if ($not) {
         $str = get_string('requires_nopassword', 'availability_password');
     } else {
         $str = get_string('requires_password', 'availability_password');
     }
     if (!$full || !$this->is_available($not, $info, false, $USER->id)) {
         $url = new \moodle_url('/availability/condition/password/index.php', array('id' => $cm->id));
         $str = \html_writer::link($url, $str, array('class' => 'availability_password-popup'));
         if (!$jsadded) {
             $PAGE->requires->strings_for_js(['enterpassword', 'wrongpassword', 'passwordintro'], 'availability_password');
             $PAGE->requires->strings_for_js(['submit', 'cancel'], 'core');
             $jsadded = true;
             $PAGE->requires->yui_module('moodle-availability_password-popup', 'M.availability_password.popup.init');
         }
     }
     return $str;
 }
開發者ID:synergylearning,項目名稱:moodle-availability_password,代碼行數:49,代碼來源:condition.php

示例2: get_grouping_id

 /**
  * Gets the actual grouping id for the condition. This is either a specified
  * id, or a special flag indicating that we use the one for the current cm.
  *
  * @param \core_availability\info $info Info about context cm
  * @return int Grouping id
  * @throws \coding_exception If it's set to use a cm but there isn't grouping
  */
 protected function get_grouping_id(\core_availability\info $info)
 {
     if ($this->activitygrouping) {
         $groupingid = $info->get_course_module()->groupingid;
         if (!$groupingid) {
             throw new \coding_exception('Not supposed to be able to turn on activitygrouping when no grouping');
         }
         return $groupingid;
     } else {
         return $this->groupingid;
     }
 }
開發者ID:gwsd2015,項目名稱:LogiClass,代碼行數:20,代碼來源:condition.php


注:本文中的core_availability\info::get_course_module方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。