Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
e10ea84e
Commit
e10ea84e
authored
Nov 19, 2013
by
Ankit Agarwal
Browse files
MDL-42962 events: Remove duplicate code from all course_module_viewed events
parent
3c248288
Changes
14
Hide whitespace changes
Inline
Side-by-side
mod/book/classes/event/course_module_viewed.php
View file @
e10ea84e
...
...
@@ -32,44 +32,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
course_module_viewed
extends
\
core\event\content_viewed
{
/**
* Returns description of what happened.
*
* @return string
*/
public
function
get_description
()
{
return
'User with id '
.
$this
->
userid
.
' viewed book activity with instance id '
.
$this
->
objectid
;
}
/**
* Return the legacy event log data.
*
* @return array|null
*/
protected
function
get_legacy_logdata
()
{
return
array
(
$this
->
courseid
,
'book'
,
'view'
,
'view.php?id='
.
$this
->
context
->
instanceid
,
$this
->
objectid
,
$this
->
context
->
instanceid
);
}
/**
* Return localised event name.
*
* @return string
*/
public
static
function
get_name
()
{
return
get_string
(
'event_course_module_viewed'
,
'mod_book'
);
}
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public
function
get_url
()
{
return
new
\
moodle_url
(
'/mod/book/view.php'
,
array
(
'id'
=>
$this
->
context
->
instanceid
));
}
class
course_module_viewed
extends
\
core\event\course_module_viewed
{
/**
* Init method.
...
...
@@ -81,17 +44,4 @@ class course_module_viewed extends \core\event\content_viewed {
$this
->
data
[
'level'
]
=
self
::
LEVEL_PARTICIPATING
;
$this
->
data
[
'objecttable'
]
=
'book'
;
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected
function
validate_data
()
{
// Hack to please the parent class. 'view' was the key used in old add_to_log().
$this
->
data
[
'other'
][
'content'
]
=
'view'
;
parent
::
validate_data
();
}
}
mod/book/lang/en/book.php
View file @
e10ea84e
...
...
@@ -51,7 +51,6 @@ $string['event_chapter_deleted'] = 'Chapter deleted';
$string
[
'event_chapter_updated'
]
=
'Chapter updated'
;
$string
[
'event_chapter_viewed'
]
=
'Chapter viewed'
;
$string
[
'event_instances_list_viewed'
]
=
'Instances list viewed'
;
$string
[
'event_course_module_viewed'
]
=
'Course module viewed'
;
$string
[
'subchapter'
]
=
'Subchapter'
;
$string
[
'nocontent'
]
=
'No content has been added to this book yet.'
;
$string
[
'numbering'
]
=
'Chapter formatting'
;
...
...
mod/choice/classes/event/course_module_viewed.php
View file @
e10ea84e
...
...
@@ -32,7 +32,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2013 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
course_module_viewed
extends
\
core\event\co
ntent
_viewed
{
class
course_module_viewed
extends
\
core\event\co
urse_module
_viewed
{
/**
* Init method.
...
...
@@ -42,41 +42,4 @@ class course_module_viewed extends \core\event\content_viewed {
$this
->
data
[
'level'
]
=
self
::
LEVEL_PARTICIPATING
;
$this
->
data
[
'objecttable'
]
=
'choice'
;
}
/**
* Returns localised general event name.
*
* @return string
*/
public
static
function
get_name
()
{
return
get_string
(
'event_choice_viewed'
,
'choice'
);
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public
function
get_description
()
{
return
'User with id '
.
$this
->
userid
.
' viewed choice activity with instance id '
.
$this
->
objectid
;
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public
function
get_url
()
{
$url
=
'/mod/choice/view.php'
;
return
new
\
moodle_url
(
$url
,
array
(
'id'
=>
$this
->
context
->
instanceid
));
}
/**
* replace add_to_log() statement.
*
* @return array of parameters to be passed to legacy add_to_log() function.
*/
protected
function
get_legacy_logdata
()
{
$url
=
new
\
moodle_url
(
'view.php'
,
array
(
'id'
=>
$this
->
context
->
instanceid
));
return
array
(
$this
->
courseid
,
'choice'
,
'view'
,
$url
->
out
(),
$this
->
objectid
,
$this
->
context
->
instanceid
);
}
}
mod/choice/lang/en/choice.php
View file @
e10ea84e
...
...
@@ -32,7 +32,6 @@ $string['displaymode'] = 'Display mode for the options';
$string
[
'displayvertical'
]
=
'Display vertically'
;
$string
[
'event_answer_created'
]
=
'Choice made'
;
$string
[
'event_answer_updated'
]
=
'Choice updated'
;
$string
[
'event_choice_viewed'
]
=
'Choice viewed'
;
$string
[
'event_report_viewed'
]
=
'Choice report viewed'
;
$string
[
'event_instances_list_viewed'
]
=
'Instances list viewed'
;
$string
[
'expired'
]
=
'Sorry, this activity closed on {$a} and is no longer available'
;
...
...
mod/choice/view.php
View file @
e10ea84e
...
...
@@ -82,10 +82,8 @@
$eventdata
[
'objectid'
]
=
$choice
->
id
;
$eventdata
[
'context'
]
=
$context
;
$eventdata
[
'courseid'
]
=
$course
->
id
;
$eventdata
[
'other'
][
'content'
]
=
'pageresourceview'
;
$event
=
\
mod_choice\event\course_module_viewed
::
create
(
$eventdata
);
$event
->
set_page_detail
();
$event
->
trigger
();
/// Check to see if groups are being used in this choice
...
...
mod/feedback/classes/event/course_module_viewed.php
View file @
e10ea84e
...
...
@@ -32,7 +32,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2013 Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
course_module_viewed
extends
\
core\event\co
ntent
_viewed
{
class
course_module_viewed
extends
\
core\event\co
urse_module
_viewed
{
/**
* Init method.
...
...
@@ -43,33 +43,6 @@ class course_module_viewed extends \core\event\content_viewed {
$this
->
data
[
'objecttable'
]
=
'feedback'
;
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public
function
get_description
()
{
return
'User with id '
.
$this
->
userid
.
' viewed feedback activity '
.
$this
->
get_url
();
}
/**
* Returns localised general event name.
*
* @return string
*/
public
static
function
get_name
()
{
return
get_string
(
'eventcoursemoduleviewed'
,
'mod_feedback'
);
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public
function
get_url
()
{
return
new
\
moodle_url
(
'/mod/feedback/view.php'
,
array
(
'id'
=>
$this
->
other
[
'cmid'
]));
}
/**
* Define whether a user can view the event or not. Make sure no one except admin can see details of an anonymous response.
*
...
...
@@ -99,8 +72,7 @@ class course_module_viewed extends \core\event\content_viewed {
if
(
$this
->
other
[
'anonymous'
]
==
FEEDBACK_ANONYMOUS_YES
)
{
return
null
;
}
else
{
return
array
(
$this
->
courseid
,
'feedback'
,
'view'
,
'view.php?id='
.
$this
->
other
[
'cmid'
],
$this
->
objectid
,
$this
->
other
[
'cmid'
]);
return
parent
::
get_legacy_logdata
();
}
}
...
...
mod/feedback/lang/en/feedback.php
View file @
e10ea84e
...
...
@@ -102,7 +102,6 @@ You can view it <a href="{$a->url}">here</a>.';
$string
[
'entries_saved'
]
=
'Your answers have been saved. Thank you.'
;
$string
[
'export_questions'
]
=
'Export questions'
;
$string
[
'export_to_excel'
]
=
'Export to Excel'
;
$string
[
'eventcoursemoduleviewed'
]
=
'Course module viewed'
;
$string
[
'eventresponsedeleted'
]
=
'Response deleted'
;
$string
[
'eventresponsesubmitted'
]
=
'Response submitted'
;
$string
[
'eventinstanceslistviewed'
]
=
'Instances list viewed'
;
...
...
mod/feedback/view.php
View file @
e10ea84e
...
...
@@ -103,8 +103,7 @@ $event = \mod_feedback\event\course_module_viewed::create(array(
'other'
=>
array
(
'cmid'
=>
$cm
->
id
,
'instanceid'
=>
$feedback
->
id
,
'anonymous'
=>
$feedback
->
anonymous
,
'content'
=>
'feedbackmoduleview'
'anonymous'
=>
$feedback
->
anonymous
)
));
$event
->
add_record_snapshot
(
'course_modules'
,
$cm
);
...
...
mod/page/classes/event/course_module_viewed.php
View file @
e10ea84e
...
...
@@ -32,7 +32,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2013 Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
course_module_viewed
extends
\
core\event\co
ntent
_viewed
{
class
course_module_viewed
extends
\
core\event\co
urse_module
_viewed
{
/**
* Init method.
...
...
@@ -42,42 +42,5 @@ class course_module_viewed extends \core\event\content_viewed {
$this
->
data
[
'level'
]
=
self
::
LEVEL_PARTICIPATING
;
$this
->
data
[
'objecttable'
]
=
'page'
;
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public
function
get_description
()
{
return
'User with id '
.
$this
->
userid
.
' viewed page resource with instance id '
.
$this
->
objectid
;
}
/**
* Returns localised general event name.
*
* @return string
*/
public
static
function
get_name
()
{
return
get_string
(
'eventcoursemoduleviewed'
,
'mod_page'
);
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public
function
get_url
()
{
return
new
\
moodle_url
(
'/mod/page/view.php'
,
array
(
'id'
=>
$this
->
context
->
instanceid
));
}
/**
* Replace add_to_log() statement.
*
* @return array of parameters to be passed to legacy add_to_log() function.
*/
protected
function
get_legacy_logdata
()
{
return
array
(
$this
->
courseid
,
'page'
,
'view'
,
'view.php?id='
.
$this
->
context
->
instanceid
,
$this
->
objectid
,
$this
->
context
->
instanceid
);
}
}
mod/page/lang/en/page.php
View file @
e10ea84e
...
...
@@ -31,7 +31,6 @@ $string['displayoptions'] = 'Available display options';
$string
[
'displayselect'
]
=
'Display'
;
$string
[
'displayselectexplain'
]
=
'Select display type.'
;
$string
[
'legacyfiles'
]
=
'Migration of old course file'
;
$string
[
'eventcoursemoduleviewed'
]
=
'Page resource viewed'
;
$string
[
'eventinstanceslistviewed'
]
=
'Page instances list viewed'
;
$string
[
'legacyfilesactive'
]
=
'Active'
;
$string
[
'legacyfilesdone'
]
=
'Finished'
;
...
...
mod/page/view.php
View file @
e10ea84e
...
...
@@ -54,8 +54,7 @@ require_capability('mod/page:view', $context);
// Trigger module viewed event.
$event
=
\
mod_page\event\course_module_viewed
::
create
(
array
(
'objectid'
=>
$page
->
id
,
'context'
=>
$context
,
'other'
=>
array
(
'content'
=>
'pageresourceview'
)
'context'
=>
$context
));
$event
->
add_record_snapshot
(
'course_modules'
,
$cm
);
$event
->
add_record_snapshot
(
'course'
,
$course
);
...
...
mod/workshop/classes/event/course_module_viewed.php
View file @
e10ea84e
...
...
@@ -32,7 +32,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2013 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
course_module_viewed
extends
\
core\event\co
ntent
_viewed
{
class
course_module_viewed
extends
\
core\event\co
urse_module
_viewed
{
/**
* Init method.
...
...
@@ -52,33 +52,6 @@ class course_module_viewed extends \core\event\content_viewed {
return
'workshop_viewed'
;
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public
function
get_description
()
{
return
'User with id '
.
$this
->
userid
.
' viewed workshop activity with instance id '
.
$this
->
objectid
;
}
/**
* Returns localised general event name.
*
* @return string
*/
public
static
function
get_name
()
{
return
get_string
(
'workshopviewed'
,
'workshop'
);
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public
function
get_url
()
{
$url
=
'/mod/workshop/view.php'
;
return
new
\
moodle_url
(
$url
,
array
(
'id'
=>
$this
->
context
->
instanceid
));
}
/**
* Legacy event data if get_legacy_eventname() is not empty.
*
...
...
@@ -93,14 +66,4 @@ class course_module_viewed extends \core\event\content_viewed {
$workshop
=
new
\
workshop
(
$workshop
,
$cm
,
$course
);
return
(
object
)
array
(
'workshop'
=>
$workshop
,
'user'
=>
$USER
);
}
/**
* replace add_to_log() statement.
*
* @return array of parameters to be passed to legacy add_to_log() function.
*/
protected
function
get_legacy_logdata
()
{
$url
=
new
\
moodle_url
(
'view.php'
,
array
(
'id'
=>
$this
->
context
->
instanceid
));
return
array
(
$this
->
courseid
,
'workshop'
,
'view'
,
$url
->
out
(),
$this
->
objectid
,
$this
->
context
->
instanceid
);
}
}
mod/workshop/lang/en/workshop.php
View file @
e10ea84e
...
...
@@ -311,7 +311,6 @@ $string['workshop:viewauthornames'] = 'View author names';
$string
[
'workshop:viewauthorpublished'
]
=
'View authors of published submissions'
;
$string
[
'workshop:viewpublishedsubmissions'
]
=
'View published submissions'
;
$string
[
'workshop:viewreviewernames'
]
=
'View reviewer names'
;
$string
[
'workshopviewed'
]
=
'Workshop viewed'
;
$string
[
'yourassessment'
]
=
'Your assessment'
;
$string
[
'yourgrades'
]
=
'Your grades'
;
$string
[
'yoursubmission'
]
=
'Your submission'
;
mod/workshop/view.php
View file @
e10ea84e
...
...
@@ -63,14 +63,12 @@ $eventdata = array();
$eventdata
[
'objectid'
]
=
$workshop
->
id
;
$eventdata
[
'context'
]
=
$workshop
->
context
;
$eventdata
[
'courseid'
]
=
$course
->
id
;
$eventdata
[
'other'
][
'content'
]
=
$workshop
->
phase
;
$PAGE
->
set_url
(
$workshop
->
view_url
());
$event
=
\
mod_workshop\event\course_module_viewed
::
create
(
$eventdata
);
$event
->
add_record_snapshot
(
'course'
,
$course
);
$event
->
add_record_snapshot
(
'workshop'
,
$workshoprecord
);
$event
->
add_record_snapshot
(
'course_modules'
,
$cm
);
$event
->
set_page_detail
();
$event
->
trigger
();
// If the phase is to be switched, do it asap. This just has to happen after triggering
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment