本文整理汇总了PHP中core_competency\api::read_template方法的典型用法代码示例。如果您正苦于以下问题:PHP api::read_template方法的具体用法?PHP api::read_template怎么用?PHP api::read_template使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_competency\api
的用法示例。
在下文中一共展示了api::read_template方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_update_template
/**
* Test updating a template.
*
* @expectedException coding_exception
*/
public function test_update_template()
{
$cat = $this->getDataGenerator()->create_category();
$this->resetAfterTest(true);
$this->setAdminUser();
$syscontext = context_system::instance();
$template = api::create_template((object) array('shortname' => 'testing', 'contextid' => $syscontext->id));
$this->assertEquals('testing', $template->get_shortname());
$this->assertEquals($syscontext->id, $template->get_contextid());
// Simple update.
api::update_template((object) array('id' => $template->get_id(), 'shortname' => 'success'));
$template = api::read_template($template->get_id());
$this->assertEquals('success', $template->get_shortname());
// Trying to change the context.
api::update_template((object) array('id' => $template->get_id(), 'contextid' => context_coursecat::instance($cat->id)));
}
示例2: required_param
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* List cohorts linked to a template.
*
* @package tool_lp
* @copyright 2015 Frédéric Massart - FMCorz.net
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require __DIR__ . '/../../../config.php';
$id = required_param('id', PARAM_INT);
$pagecontextid = required_param('pagecontextid', PARAM_INT);
// Reference to the context we came from.
require_login(0, false);
\core_competency\api::require_enabled();
$template = \core_competency\api::read_template($id);
$context = $template->get_context();
$canreadtemplate = $template->can_read();
$canmanagetemplate = $template->can_manage();
$duedatereached = $template->get_duedate() > 0 && $template->get_duedate() < time();
if (!$canreadtemplate) {
throw new required_capability_exception($context, 'moodle/competency:templateview', 'nopermissions', '');
}
// Set up the page.
$url = new moodle_url('/admin/tool/lp/template_cohorts.php', array('id' => $id, 'pagecontextid' => $pagecontextid));
list($title, $subtitle) = \tool_lp\page_helper::setup_for_template($pagecontextid, $url, $template, get_string('cohortssyncedtotemplate', 'tool_lp'));
// Remove cohort.
if ($canmanagetemplate && ($removecohort = optional_param('removecohort', false, PARAM_INT)) !== false && confirm_sesskey()) {
\core_competency\api::delete_template_cohort($template, $removecohort);
}
// Capture the form submission.
示例3: template_viewed
/**
* Log the template viewed event.
*
* @param int $id the template id
* @return array of warnings and status result
* @throws moodle_exception
*/
public static function template_viewed($id)
{
$params = self::validate_parameters(self::view_book_parameters(), array('id' => $id));
$template = api::read_template($params['id']);
self::validate_context($template->get_context());
return api::template_viewed($params['id']);
}
示例4: data_for_template_competencies_page
/**
* Loads the data required to render the template_competencies_page template.
*
* @param int $templateid Template id.
* @param array $pagecontext The page context info.
* @return boolean
*/
public static function data_for_template_competencies_page($templateid, $pagecontext)
{
global $PAGE;
$params = self::validate_parameters(self::data_for_template_competencies_page_parameters(), array('templateid' => $templateid, 'pagecontext' => $pagecontext));
$context = self::get_context_from_params($params['pagecontext']);
self::validate_context($context);
$template = api::read_template($params['templateid']);
$renderable = new output\template_competencies_page($template, $context);
$renderer = $PAGE->get_renderer('tool_lp');
$data = $renderable->export_for_template($renderer);
return $data;
}