Merge branch 'MDL-51886-master' of git://github.com/dpalou/moodle
Conflicts: version.php
This commit is contained in:
@@ -1274,6 +1274,8 @@ $services = array(
|
||||
'mod_imscp_get_imscps_by_courses',
|
||||
'mod_glossary_get_glossaries_by_courses',
|
||||
'mod_wiki_get_wikis_by_courses',
|
||||
'mod_wiki_view_wiki',
|
||||
'mod_wiki_view_page',
|
||||
),
|
||||
'enabled' => 0,
|
||||
'restrictedusers' => 0,
|
||||
|
||||
@@ -174,4 +174,150 @@ class mod_wiki_external extends external_api {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the parameters for view_wiki.
|
||||
*
|
||||
* @return external_function_parameters
|
||||
* @since Moodle 3.1
|
||||
*/
|
||||
public static function view_wiki_parameters() {
|
||||
return new external_function_parameters (
|
||||
array(
|
||||
'wikiid' => new external_value(PARAM_INT, 'Wiki instance ID.')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the course module viewed event and update the module completion status.
|
||||
*
|
||||
* @param int $wikiid The wiki instance ID.
|
||||
* @return array of warnings and status result.
|
||||
* @since Moodle 3.1
|
||||
*/
|
||||
public static function view_wiki($wikiid) {
|
||||
|
||||
$params = self::validate_parameters(self::view_wiki_parameters(),
|
||||
array(
|
||||
'wikiid' => $wikiid
|
||||
));
|
||||
$warnings = array();
|
||||
|
||||
// Get wiki instance.
|
||||
if (!$wiki = wiki_get_wiki($params['wikiid'])) {
|
||||
throw new moodle_exception('incorrectwikiid', 'wiki');
|
||||
}
|
||||
|
||||
// Permission validation.
|
||||
list($course, $cm) = get_course_and_cm_from_instance($wiki, 'wiki');
|
||||
$context = context_module::instance($cm->id);
|
||||
self::validate_context($context);
|
||||
|
||||
// Check if user can view this wiki.
|
||||
// We don't use wiki_user_can_view because it requires to have a valid subwiki for the user.
|
||||
if (!has_capability('mod/wiki:viewpage', $context)) {
|
||||
throw new moodle_exception('cannotviewpage', 'wiki');
|
||||
}
|
||||
|
||||
// Trigger course_module_viewed event and completion.
|
||||
wiki_view($wiki, $course, $cm, $context);
|
||||
|
||||
$result = array();
|
||||
$result['status'] = true;
|
||||
$result['warnings'] = $warnings;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the view_wiki return value.
|
||||
*
|
||||
* @return external_single_structure
|
||||
* @since Moodle 3.1
|
||||
*/
|
||||
public static function view_wiki_returns() {
|
||||
return new external_single_structure(
|
||||
array(
|
||||
'status' => new external_value(PARAM_BOOL, 'Status: true if success.'),
|
||||
'warnings' => new external_warnings()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the parameters for view_page.
|
||||
*
|
||||
* @return external_function_parameters
|
||||
* @since Moodle 3.1
|
||||
*/
|
||||
public static function view_page_parameters() {
|
||||
return new external_function_parameters (
|
||||
array(
|
||||
'pageid' => new external_value(PARAM_INT, 'Wiki page ID.'),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the page viewed event and update the module completion status.
|
||||
*
|
||||
* @param int $pageid The page ID.
|
||||
* @return array of warnings and status result.
|
||||
* @since Moodle 3.1
|
||||
* @throws moodle_exception if page is not valid.
|
||||
*/
|
||||
public static function view_page($pageid) {
|
||||
|
||||
$params = self::validate_parameters(self::view_page_parameters(),
|
||||
array(
|
||||
'pageid' => $pageid
|
||||
));
|
||||
$warnings = array();
|
||||
|
||||
// Get wiki page.
|
||||
if (!$page = wiki_get_page($params['pageid'])) {
|
||||
throw new moodle_exception('incorrectpageid', 'wiki');
|
||||
}
|
||||
|
||||
// Get wiki instance.
|
||||
if (!$wiki = wiki_get_wiki_from_pageid($params['pageid'])) {
|
||||
throw new moodle_exception('incorrectwikiid', 'wiki');
|
||||
}
|
||||
|
||||
// Permission validation.
|
||||
list($course, $cm) = get_course_and_cm_from_instance($wiki, 'wiki');
|
||||
$context = context_module::instance($cm->id);
|
||||
self::validate_context($context);
|
||||
|
||||
// Check if user can view this wiki.
|
||||
if (!$subwiki = wiki_get_subwiki($page->subwikiid)) {
|
||||
throw new moodle_exception('incorrectsubwikiid', 'wiki');
|
||||
}
|
||||
if (!wiki_user_can_view($subwiki, $wiki)) {
|
||||
throw new moodle_exception('cannotviewpage', 'wiki');
|
||||
}
|
||||
|
||||
// Trigger page_viewed event and completion.
|
||||
wiki_page_view($wiki, $page, $course, $cm, $context);
|
||||
|
||||
$result = array();
|
||||
$result['status'] = true;
|
||||
$result['warnings'] = $warnings;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the view_page return value.
|
||||
*
|
||||
* @return external_single_structure
|
||||
* @since Moodle 3.1
|
||||
*/
|
||||
public static function view_page_returns() {
|
||||
return new external_single_structure(
|
||||
array(
|
||||
'status' => new external_value(PARAM_BOOL, 'Status: true if success.'),
|
||||
'warnings' => new external_warnings()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,5 +33,21 @@ $functions = array(
|
||||
'no courses are provided then all the wiki instances the user has access to will be returned.',
|
||||
'type' => 'read',
|
||||
'capabilities' => 'mod/wiki:viewpage'
|
||||
),
|
||||
|
||||
'mod_wiki_view_wiki' => array(
|
||||
'classname' => 'mod_wiki_external',
|
||||
'methodname' => 'view_wiki',
|
||||
'description' => 'Trigger the course module viewed event and update the module completion status.',
|
||||
'type' => 'write',
|
||||
'capabilities' => 'mod/wiki:viewpage'
|
||||
),
|
||||
|
||||
'mod_wiki_view_page' => array(
|
||||
'classname' => 'mod_wiki_external',
|
||||
'methodname' => 'view_page',
|
||||
'description' => 'Trigger the page viewed event and update the module completion status.',
|
||||
'type' => 'write',
|
||||
'capabilities' => 'mod/wiki:viewpage'
|
||||
)
|
||||
);
|
||||
|
||||
@@ -659,3 +659,72 @@ function wiki_page_type_list($pagetype, $parentcontext, $currentcontext) {
|
||||
);
|
||||
return $module_pagetype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the activity completed (if required) and trigger the course_module_viewed event.
|
||||
*
|
||||
* @param stdClass $wiki Wiki object.
|
||||
* @param stdClass $course Course object.
|
||||
* @param stdClass $cm Course module object.
|
||||
* @param stdClass $context Context object.
|
||||
* @since Moodle 3.1
|
||||
*/
|
||||
function wiki_view($wiki, $course, $cm, $context) {
|
||||
// Trigger course_module_viewed event.
|
||||
$params = array(
|
||||
'context' => $context,
|
||||
'objectid' => $wiki->id
|
||||
);
|
||||
$event = \mod_wiki\event\course_module_viewed::create($params);
|
||||
$event->add_record_snapshot('course_modules', $cm);
|
||||
$event->add_record_snapshot('course', $course);
|
||||
$event->add_record_snapshot('wiki', $wiki);
|
||||
$event->trigger();
|
||||
|
||||
// Completion.
|
||||
$completion = new completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the activity completed (if required) and trigger the page_viewed event.
|
||||
*
|
||||
* @param stdClass $wiki Wiki object.
|
||||
* @param stdClass $page Page object.
|
||||
* @param stdClass $course Course object.
|
||||
* @param stdClass $cm Course module object.
|
||||
* @param stdClass $context Context object.
|
||||
* @param int $uid Optional User ID.
|
||||
* @param array $other Optional Other params: title, wiki ID, group ID, groupanduser, prettyview.
|
||||
* @param stdClass $subwiki Optional Subwiki.
|
||||
* @since Moodle 3.1
|
||||
*/
|
||||
function wiki_page_view($wiki, $page, $course, $cm, $context, $uid = null, $other = null, $subwiki = null) {
|
||||
|
||||
// Trigger course_module_viewed event.
|
||||
$params = array(
|
||||
'context' => $context,
|
||||
'objectid' => $page->id
|
||||
);
|
||||
if ($uid != null) {
|
||||
$params['relateduserid'] = $uid;
|
||||
}
|
||||
if ($other != null) {
|
||||
$params['other'] = $other;
|
||||
}
|
||||
|
||||
$event = \mod_wiki\event\page_viewed::create($params);
|
||||
|
||||
$event->add_record_snapshot('wiki_pages', $page);
|
||||
$event->add_record_snapshot('course_modules', $cm);
|
||||
$event->add_record_snapshot('course', $course);
|
||||
$event->add_record_snapshot('wiki', $wiki);
|
||||
if ($subwiki != null) {
|
||||
$event->add_record_snapshot('wiki_subwikis', $subwiki);
|
||||
}
|
||||
$event->trigger();
|
||||
|
||||
// Completion.
|
||||
$completion = new completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
}
|
||||
|
||||
+3
-11
@@ -62,17 +62,9 @@ $wikipage = new page_wiki_prettyview($wiki, $subwiki, $cm);
|
||||
$wikipage->set_page($page);
|
||||
|
||||
$context = context_module::instance($cm->id);
|
||||
$event = \mod_wiki\event\page_viewed::create(
|
||||
array(
|
||||
'context' => $context,
|
||||
'objectid' => $pageid,
|
||||
'other' => array('prettyview' => true)
|
||||
)
|
||||
);
|
||||
$event->add_record_snapshot('wiki_pages', $page);
|
||||
$event->add_record_snapshot('wiki', $wiki);
|
||||
$event->add_record_snapshot('wiki_subwikis', $subwiki);
|
||||
$event->trigger();
|
||||
|
||||
$other = array('prettyview' => true);
|
||||
wiki_page_view($wiki, $page, $course, $cm, $context, null, $other, $subwiki);
|
||||
|
||||
$wikipage->print_header();
|
||||
$wikipage->print_content();
|
||||
|
||||
@@ -196,6 +196,123 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase {
|
||||
$wikis = mod_wiki_external::get_wikis_by_courses(array($this->course->id));
|
||||
$wikis = external_api::clean_returnvalue(mod_wiki_external::get_wikis_by_courses_returns(), $wikis);
|
||||
$this->assertFalse($wikis['wikis'][0]['cancreatepages']);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test view_wiki.
|
||||
*/
|
||||
public function test_view_wiki() {
|
||||
|
||||
// Test invalid instance id.
|
||||
try {
|
||||
mod_wiki_external::view_wiki(0);
|
||||
$this->fail('Exception expected due to invalid mod_wiki instance id.');
|
||||
} catch (moodle_exception $e) {
|
||||
$this->assertEquals('incorrectwikiid', $e->errorcode);
|
||||
}
|
||||
|
||||
// Test not-enrolled user.
|
||||
$usernotenrolled = self::getDataGenerator()->create_user();
|
||||
$this->setUser($usernotenrolled);
|
||||
try {
|
||||
mod_wiki_external::view_wiki($this->wiki->id);
|
||||
$this->fail('Exception expected due to not enrolled user.');
|
||||
} catch (moodle_exception $e) {
|
||||
$this->assertEquals('requireloginerror', $e->errorcode);
|
||||
}
|
||||
|
||||
// Test user with full capabilities.
|
||||
$this->setUser($this->student);
|
||||
|
||||
// Trigger and capture the event.
|
||||
$sink = $this->redirectEvents();
|
||||
|
||||
$result = mod_wiki_external::view_wiki($this->wiki->id);
|
||||
$result = external_api::clean_returnvalue(mod_wiki_external::view_wiki_returns(), $result);
|
||||
|
||||
$events = $sink->get_events();
|
||||
$this->assertCount(1, $events);
|
||||
$event = array_shift($events);
|
||||
|
||||
// Checking that the event contains the expected values.
|
||||
$this->assertInstanceOf('\mod_wiki\event\course_module_viewed', $event);
|
||||
$this->assertEquals($this->context, $event->get_context());
|
||||
$moodlewiki = new \moodle_url('/mod/wiki/view.php', array('id' => $this->cm->id));
|
||||
$this->assertEquals($moodlewiki, $event->get_url());
|
||||
$this->assertEventContextNotUsed($event);
|
||||
$this->assertNotEmpty($event->get_name());
|
||||
|
||||
// Test user with no capabilities.
|
||||
// We need a explicit prohibit since this capability is allowed for students by default.
|
||||
assign_capability('mod/wiki:viewpage', CAP_PROHIBIT, $this->studentrole->id, $this->context->id);
|
||||
accesslib_clear_all_caches_for_unit_testing();
|
||||
|
||||
try {
|
||||
mod_wiki_external::view_wiki($this->wiki->id);
|
||||
$this->fail('Exception expected due to missing capability.');
|
||||
} catch (moodle_exception $e) {
|
||||
$this->assertEquals('cannotviewpage', $e->errorcode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test view_page.
|
||||
*/
|
||||
public function test_view_page() {
|
||||
|
||||
// Test invalid page id.
|
||||
try {
|
||||
mod_wiki_external::view_page(0);
|
||||
$this->fail('Exception expected due to invalid view_page page id.');
|
||||
} catch (moodle_exception $e) {
|
||||
$this->assertEquals('incorrectpageid', $e->errorcode);
|
||||
}
|
||||
|
||||
// Test not-enrolled user.
|
||||
$usernotenrolled = self::getDataGenerator()->create_user();
|
||||
$this->setUser($usernotenrolled);
|
||||
try {
|
||||
mod_wiki_external::view_page($this->firstpage->id);
|
||||
$this->fail('Exception expected due to not enrolled user.');
|
||||
} catch (moodle_exception $e) {
|
||||
$this->assertEquals('requireloginerror', $e->errorcode);
|
||||
}
|
||||
|
||||
// Test user with full capabilities.
|
||||
$this->setUser($this->student);
|
||||
|
||||
// Trigger and capture the event.
|
||||
$sink = $this->redirectEvents();
|
||||
|
||||
$result = mod_wiki_external::view_page($this->firstpage->id);
|
||||
$result = external_api::clean_returnvalue(mod_wiki_external::view_page_returns(), $result);
|
||||
|
||||
$events = $sink->get_events();
|
||||
$this->assertCount(1, $events);
|
||||
$event = array_shift($events);
|
||||
|
||||
// Checking that the event contains the expected values.
|
||||
$this->assertInstanceOf('\mod_wiki\event\page_viewed', $event);
|
||||
$this->assertEquals($this->context, $event->get_context());
|
||||
$pageurl = new \moodle_url('/mod/wiki/view.php', array('pageid' => $this->firstpage->id));
|
||||
$this->assertEquals($pageurl, $event->get_url());
|
||||
$this->assertEventContextNotUsed($event);
|
||||
$this->assertNotEmpty($event->get_name());
|
||||
|
||||
// Test user with no capabilities.
|
||||
// We need a explicit prohibit since this capability is allowed for students by default.
|
||||
assign_capability('mod/wiki:viewpage', CAP_PROHIBIT, $this->studentrole->id, $this->context->id);
|
||||
accesslib_clear_all_caches_for_unit_testing();
|
||||
|
||||
try {
|
||||
mod_wiki_external::view_page($this->firstpage->id);
|
||||
$this->fail('Exception expected due to missing capability.');
|
||||
} catch (moodle_exception $e) {
|
||||
$this->assertEquals('cannotviewpage', $e->errorcode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for mod_wiki lib
|
||||
*
|
||||
* @package mod_wiki
|
||||
* @category external
|
||||
* @copyright 2015 Dani Palou <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.1
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/mod/wiki/lib.php');
|
||||
require_once($CFG->libdir . '/completionlib.php');
|
||||
|
||||
/**
|
||||
* Unit tests for mod_wiki lib
|
||||
*
|
||||
* @package mod_wiki
|
||||
* @category external
|
||||
* @copyright 2015 Dani Palou <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.1
|
||||
*/
|
||||
class mod_wiki_lib_testcase extends advanced_testcase {
|
||||
|
||||
/**
|
||||
* Test wiki_view.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_wiki_view() {
|
||||
global $CFG;
|
||||
|
||||
$CFG->enablecompletion = COMPLETION_ENABLED;
|
||||
$this->resetAfterTest();
|
||||
|
||||
$this->setAdminUser();
|
||||
// Setup test data.
|
||||
$course = $this->getDataGenerator()->create_course(array('enablecompletion' => COMPLETION_ENABLED));
|
||||
$options = array('completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionview' => COMPLETION_VIEW_REQUIRED);
|
||||
$wiki = $this->getDataGenerator()->create_module('wiki', array('course' => $course->id), $options);
|
||||
$context = context_module::instance($wiki->cmid);
|
||||
$cm = get_coursemodule_from_instance('wiki', $wiki->id);
|
||||
|
||||
// Trigger and capture the event.
|
||||
$sink = $this->redirectEvents();
|
||||
|
||||
wiki_view($wiki, $course, $cm, $context);
|
||||
|
||||
$events = $sink->get_events();
|
||||
// 2 additional events thanks to completion.
|
||||
$this->assertCount(3, $events);
|
||||
$event = array_shift($events);
|
||||
|
||||
// Checking that the event contains the expected values.
|
||||
$this->assertInstanceOf('\mod_wiki\event\course_module_viewed', $event);
|
||||
$this->assertEquals($context, $event->get_context());
|
||||
$moodleurl = new \moodle_url('/mod/wiki/view.php', array('id' => $cm->id));
|
||||
$this->assertEquals($moodleurl, $event->get_url());
|
||||
$this->assertEventContextNotUsed($event);
|
||||
$this->assertNotEmpty($event->get_name());
|
||||
|
||||
// Check completion status.
|
||||
$completion = new completion_info($course);
|
||||
$completiondata = $completion->get_data($cm);
|
||||
$this->assertEquals(1, $completiondata->completionstate);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test wiki_page_view.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_wiki_page_view() {
|
||||
global $CFG;
|
||||
|
||||
$CFG->enablecompletion = COMPLETION_ENABLED;
|
||||
$this->resetAfterTest();
|
||||
|
||||
$this->setAdminUser();
|
||||
// Setup test data.
|
||||
$course = $this->getDataGenerator()->create_course(array('enablecompletion' => COMPLETION_ENABLED));
|
||||
$options = array('completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionview' => COMPLETION_VIEW_REQUIRED);
|
||||
$wiki = $this->getDataGenerator()->create_module('wiki', array('course' => $course->id), $options);
|
||||
$context = context_module::instance($wiki->cmid);
|
||||
$cm = get_coursemodule_from_instance('wiki', $wiki->id);
|
||||
$firstpage = $this->getDataGenerator()->get_plugin_generator('mod_wiki')->create_first_page($wiki);
|
||||
|
||||
// Trigger and capture the event.
|
||||
$sink = $this->redirectEvents();
|
||||
|
||||
wiki_page_view($wiki, $firstpage, $course, $cm, $context);
|
||||
|
||||
$events = $sink->get_events();
|
||||
// 2 additional events thanks to completion.
|
||||
$this->assertCount(3, $events);
|
||||
$event = array_shift($events);
|
||||
|
||||
// Checking that the event contains the expected values.
|
||||
$this->assertInstanceOf('\mod_wiki\event\page_viewed', $event);
|
||||
$this->assertEquals($context, $event->get_context());
|
||||
$pageurl = new \moodle_url('/mod/wiki/view.php', array('pageid' => $firstpage->id));
|
||||
$this->assertEquals($pageurl, $event->get_url());
|
||||
$this->assertEventContextNotUsed($event);
|
||||
$this->assertNotEmpty($event->get_name());
|
||||
|
||||
// Check completion status.
|
||||
$completion = new completion_info($course);
|
||||
$completiondata = $completion->get_data($cm);
|
||||
$this->assertEquals(1, $completiondata->completionstate);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2015111601; // The current module version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2015111602; // The current module version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2015111000; // Requires this Moodle version
|
||||
$plugin->component = 'mod_wiki'; // Full name of the plugin (used for diagnostics)
|
||||
$plugin->cron = 0;
|
||||
|
||||
+12
-38
@@ -275,11 +275,6 @@ if (!wiki_user_can_view($subwiki, $wiki)) {
|
||||
print_error('cannotviewpage', 'wiki');
|
||||
}
|
||||
|
||||
// Update 'viewed' state if required by completion system
|
||||
require_once($CFG->libdir . '/completionlib.php');
|
||||
$completion = new completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
if (($edit != - 1) and $PAGE->user_allowed_editing()) {
|
||||
$USER->editing = $edit;
|
||||
}
|
||||
@@ -290,40 +285,19 @@ $wikipage->set_gid($currentgroup);
|
||||
$wikipage->set_page($page);
|
||||
|
||||
$context = context_module::instance($cm->id);
|
||||
if($pageid) {
|
||||
$event = \mod_wiki\event\page_viewed::create(
|
||||
array(
|
||||
'context' => $context,
|
||||
'objectid' => $pageid
|
||||
)
|
||||
);
|
||||
$event->add_record_snapshot('wiki_pages', $page);
|
||||
} else if($id) {
|
||||
$event = \mod_wiki\event\course_module_viewed::create(
|
||||
array(
|
||||
'context' => $context,
|
||||
'objectid' => $wiki->id
|
||||
)
|
||||
);
|
||||
} else if($wid && $title) {
|
||||
$event = \mod_wiki\event\page_viewed::create(
|
||||
array(
|
||||
'context' => $context,
|
||||
'objectid' => $page->id,
|
||||
'relateduserid' => $uid,
|
||||
'other' => array(
|
||||
'title' => $title,
|
||||
'wid' => $wid,
|
||||
'group' => $gid,
|
||||
'groupanduser' => $groupanduser)
|
||||
)
|
||||
);
|
||||
$event->add_record_snapshot('wiki_pages', $page);
|
||||
if ($pageid) {
|
||||
wiki_page_view($wiki, $page, $course, $cm, $context, null, null, $subwiki);
|
||||
} else if ($id) {
|
||||
wiki_view($wiki, $course, $cm, $context);
|
||||
} else if ($wid && $title) {
|
||||
$other = array(
|
||||
'title' => $title,
|
||||
'wid' => $wid,
|
||||
'group' => $gid,
|
||||
'groupanduser' => $groupanduser
|
||||
);
|
||||
wiki_page_view($wiki, $page, $course, $cm, $context, $uid, $other, $subwiki);
|
||||
}
|
||||
$event->add_record_snapshot('course_modules', $cm);
|
||||
$event->add_record_snapshot('course', $course);
|
||||
$event->add_record_snapshot('wiki', $wiki);
|
||||
$event->trigger();
|
||||
|
||||
$wikipage->print_header();
|
||||
$wikipage->print_content();
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2015122100.01; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
$version = 2015122100.02; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
// RR = release increments - 00 in DEV branches.
|
||||
// .XX = incremental changes.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user