Commit 18b78eab authored by Kevin Dibble's avatar Kevin Dibble Committed by Robert Lyon

Bug 1821267: Submission Email and Submission Report

Added new module to send emails to user on submissions.
Added a new report called "assessments" to show submission history

behatnotneeded

Change-Id: I0dc89e564af595c7a52e2efd6d5a9593e0121813
parent 762eb128
......@@ -433,6 +433,7 @@ $string['contentreports'] = 'Content overview';
$string['peoplereports'] = 'People overview';
$string['informationloginsreports'] = 'Logins';
$string['informationcomparisonsreports'] = 'Institution comparison';
$string['groupsassessmentsreports'] = 'Submissions';
$string['applyingfilters'] = 'Applying filters';
$string['nogroupdataperinstitution'] = 'Group reports can only be generated for the entire site. Please select "All institutions" from the institution selector if you have permission to view sitewide reports.';
......@@ -468,3 +469,17 @@ $string['usersbyinstitution'] = 'Users by institution';
$string['groupsbytype'] = 'Groups by type';
$string['earliestdate'] = 'Data for this report is only available from %s onwards.';
$string['noearliestdate'] = 'There is no data recorded for this report.';
$string['submissions'] = 'Submissions';
$string['reportdescassessments'] = '<ul>
<li>Submission type</li>
<li>Portfolio name</li>
<li>Portfolio owner</li>
<li>Group submitted to</li>
<li>Submission date</li>
<li>Released date</li>
<li>Released by</li>
</ul>';
$string['assessmenttype'] = 'Submission type';
$string['assessmensubmitted'] = 'Submission date';
$string['assessmentmarker'] = 'Released by';
$string['assessmentreleaseddate'] = 'Released date';
......@@ -158,6 +158,8 @@ class Collection {
}
delete_records('collection','id',$this->id);
delete_records('existingcopy', 'collection', $this->id);
// Delete any submission history
delete_records('module_assessmentreport_history', 'event', 'collection', 'itemid', $this->id);
// Secret url records belong to the collection, so remove them from the view.
// @todo: add user message to whatever calls this.
......@@ -1187,7 +1189,7 @@ class Collection {
handle_event('releasesubmission', array('releaseuser' => $releaseuser,
'id' => $this->get('id'),
'groupname' => $this->submittedgroup,
'groupname' => get_field('group', 'name', 'id', $this->submittedgroup),
'eventfor' => 'collection'));
// We don't send out notifications about the release of remote-submitted Views & Collections
......
......@@ -1354,5 +1354,12 @@ function xmldb_core_upgrade($oldversion=0) {
execute_sql("UPDATE {search_cron} SET minute = ? WHERE plugin = ? AND callfunction = ?", array('4-59/5', 'elasticsearch', 'cron'));
}
if ($oldversion < 2019062000) {
log_debug('Force install of assessmentreport module plugin');
if ($data = check_upgrades('module.assessmentreport')) {
upgrade_plugin($data);
}
}
return $status;
}
......@@ -954,6 +954,8 @@ function group_delete($groupid, $shortname=null, $institution=null, $notifymembe
}
delete_records('lti_assessment', 'group', $group->id);
}
// Delete any submission history
delete_records('module_assessmentreport_history', 'groupid', $group->id);
if ($notifymembers) {
require_once('activity.php');
......
This diff is collapsed.
......@@ -1600,6 +1600,9 @@ function delete_user($userid) {
delete_records('usr_agreement', 'usr', $userid);
delete_records('existingcopy', 'usr', $userid);
delete_records('artefact_internal_profile_email', 'owner', $userid);
// Delete any submission history
delete_records('module_assessmentreport_history', 'userid', $userid);
delete_records('module_assessmentreport_history', 'markerid', $userid);
if (is_plugin_active('framework', 'module')) {
delete_records('framework_assessment_feedback', 'usr', $userid);
......
......@@ -16,7 +16,7 @@ $config = new stdClass();
// See https://wiki.mahara.org/wiki/Developer_Area/Version_Numbering_Policy
// For upgrades on stable branches, increment the version by one. On master, use the date.
$config->version = 2019051600;
$config->version = 2019062000;
$config->series = '19.10';
$config->release = '19.10dev';
$config->minupgradefrom = 2017031605;
......
......@@ -1013,6 +1013,8 @@ class View {
}
}
}
// Delete any submission history
delete_records('module_assessmentreport_history', 'event', 'view', 'itemid', $this->id);
handle_event('deleteview', $eventdata);
delete_records('view_rows_columns', 'view', $this->id);
......
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="lib/db" VERSION="2013010705" COMMENT="XMLDB file for Assessmentreport mahara tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="module_assessmentreport_history" COMMENT="Keep a history of assessments submitted">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" COMMENT="Primary Key"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="false" COMMENT="The userid"/>
<FIELD NAME="event" TYPE="text" NOTNULL="false" COMMENT="The Event was for a collection or page"/>
<FIELD NAME="itemid" TYPE="int" LENGTH="10" NOTNULL="false" COMMENT="Page or Collection id"/>
<FIELD NAME="datesubmitted" TYPE="datetime" NOTNULL="false" COMMENT="Date the item was submitted for marking"/>
<FIELD NAME="datereleased" TYPE="datetime" NOTNULL="false" COMMENT="Date the item was released form marking"/>
<FIELD NAME="markerid" TYPE="int" LENGTH="10" NOTNULL="false" COMMENT="The person who Released the assessment"/>
<FIELD NAME="groupid" TYPE="int" LENGTH="10" NOTNULL="false" COMMENT="The group it was submitted to"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="userfk" TYPE="foreign" FIELDS="userid" REFTABLE="usr" REFFIELDS="id"/>
<KEY NAME="markerfk" TYPE="foreign" FIELDS="markerid" REFTABLE="usr" REFFIELDS="id"/>
<KEY NAME="groupfk" TYPE="foreign" FIELDS="groupid" REFTABLE="group" REFFIELDS="id"/>
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
\ No newline at end of file
<?php
defined('INTERNAL') || die();
$string["message"] = 'This is to confirm that you submitted the %s "%s" successfully to the group "%s" at %s.
If you have any questions about this submission, please contact the group administrator.';
$string["subject"] = 'Your submission of "%s" was successful';
$string["page"] = "page";
\ No newline at end of file
<?php
defined('INTERNAL') || die();
/**
* module plugin class. Used for registering the plugin and his functions.
*/
class PluginModuleAssessmentreport extends PluginModule {
/**
* Is the plugin activated or not?
*
* @return boolean true, if the plugin is activated, otherwise false
*/
public static function is_active() {
$active = false;
if (get_field('module_installed', 'active', 'name', 'assessmentreport')) {
$active = true;
}
return $active;
}
/**
* API-Function get the Plugin ShortName
*
* @return string ShortName of the plugin
*/
public static function get_plugin_name() {
return 'assessmentreport';
}
/**
* Hook addsubmission event.
*
* @return array
*/
public static function get_event_subscriptions() {
return array(
(object) array(
'plugin' => self::get_plugin_name(),
'event' => 'addsubmission',
'callfunction' => 'observe_on_addsubmission',
),
(object) array (
'plugin' => self::get_plugin_name(),
'event' => 'releasesubmission',
'callfunction' => 'observe_on_releasesubmission',
),
);
}
/**
* @param $event
* @param $data
* @throws CollectionNotFoundException
* @throws SQLException
* @throws ViewNotFoundException
*/
public static function observe_on_releasesubmission($event, $data) {
$releaseuserid = ($data['releaseuser'] instanceof User) ? $data['releaseuser']->get('id') : $data['releaseuser']->id;
$item = ($data['eventfor'] == "collection" ? new Collection($data['id']) : new View($data['id']));
$group = get_record('group', 'name', $data['groupname']);
$historyobj = (object) array(
'userid' => $item ? $item->get('owner') : 0,
'event' => $data['eventfor'],
'itemid' => $item ? $item->get('id') : 0,
'datereleased' => date('Y-m-d H:i:s'),
'groupid' => $group ? $group->id : 0,
'markerid' => $releaseuserid
);
if ($updateitem = get_record_sql('
SELECT * FROM {module_assessmentreport_history}
WHERE userid = ?
AND itemid = ?
AND event = ?
AND groupid = ?
AND markerid IS NULL ORDER BY id DESC LIMIT 1',
array(
$historyobj->userid,
$historyobj->itemid,
$historyobj->event,
$historyobj->groupid)
)) {
$historyobj->id = $updateitem->id;
update_record('module_assessmentreport_history', $historyobj);
}
}
/**
* @param $event
* @param $data
* @throws CollectionNotFoundException
* @throws SQLException
* @throws ViewNotFoundException
*/
public static function observe_on_addsubmission($event, $data) {
$item = ($data['eventfor'] == "collection" ? new Collection($data['id']) : new View($data['id']));
$group = get_record('group', 'name', $data['groupname']);
$historyobj = (object) array(
'userid' => $item ? $item->get('owner') : 0,
'event' => $data['eventfor'],
'itemid' => $item ? $item->get('id') : 0,
'datesubmitted' => date('Y-m-d H:i:s'),
'groupid' => $group ? $group->id : 0
);
insert_record('module_assessmentreport_history', $historyobj);
$type = get_string('page', 'module.assessmentreport');
if ($data['eventfor'] == "collection") {
$type = get_string('collection', 'collection');
}
$subject = get_string('subject', 'module.assessmentreport', $type);
$message = get_string('message', 'module.assessmentreport', $type, $data['name'], $data['groupname'], date("d-m-Y, H:i"));
activity_occurred(
'maharamessage',
array(
'users' => array($item->get('owner')),
'subject' => $subject,
'message' => $message
)
);
}
/**
* We want this module to be the default notification module so we
* will prevent it being disabled.
*/
public static function can_be_disabled() {
return true;
}
/**
* @param int $prevversion
* @return bool|void
*/
public static function postinst($prevversion) {
}
}
<?php
/**
*
* @package mahara
* @subpackage
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
defined('INTERNAL') || die();
$config = new stdClass();
$config->version = 2019080301;
$config->release = '0.0.2';
{foreach from=$data item=item key=key}
<tr class="{cycle values='r0,r1'}">
{if $columns.rownum}<td>{$offset + $dwoo.foreach.default.iteration}</td>{/if}
{if $columns.type}<td>{$item->type}</td>{/if}
{if $columns.viewname}<td>{$item->viewname}</td>{/if}
{if $columns.owner}<td><a href="{$WWWROOT}user/view.php?id={$item->userid}">{$item->owner}</a></td>{/if}
{if $columns.group}<td>{$item->groupname}</td>{/if}
{if $columns.submitted}<td>{format_date(strtotime($item->submitted))}</td>{/if}
{if $columns.released}<td>{if $item->released}{format_date(strtotime($item->released))}{/if}</td>{/if}
{if $columns.marker}<td>{if $item->markerid}<a href="{$WWWROOT}user/view.php?id={$item->markerid}">{$item->marker}</a> {/if}</td>{/if}
</tr>
{/foreach}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment