Commit 17e7e95f authored by Matt Clarkson's avatar Matt Clarkson Committed by Robert Lyon

Bug 1836653: Allow LTI submissions to be revoked

Change-Id: Ib0a677db1b04b328f0e679cffa0c4d52fa52ecee
parent 1b2123ce
......@@ -43,10 +43,11 @@ $string['notconfigured'] = 'Currently, this activity does not allow submissions.
$string['notreadylabel'] = 'Not ready';
$string['oauthprotocolenabled'] = 'OAuth protocol enabled';
$string['parentauthforlti'] = 'Parent authority';
$string['portfoliosubmitted'] = 'You submitted the portfolio "%s" for assessment on %s.';
$string['portfoliosubmittedforgrading'] = 'You submitted the portfolio "<strong><a href="%s">%s</a></strong>" for assessment on %s.';
$string['portfoliosubmittedheader'] = 'Portfolio Submitted';
$string['readylabel'] = 'Ready';
$string['restprotocolenabled'] = 'REST protocol enabled';
$string['revokesubmission'] = 'Revoke submission';
$string['usernameexists2'] = 'Username "%s" is not valid.';
$string['saveandrelease'] = 'Save and allow submissions';
$string['submitportfolio'] = 'Submit a portfolio for assessment';
......
......@@ -436,7 +436,7 @@ class PluginModuleLti extends PluginModule {
'text1' => array(
'type' => 'html',
'class' => 'text-inline',
'value' => get_string('submitto', 'module.lti', $assessment->resourcelinktitle, $assessment->contexttitle),
'value' => get_string('submitto', 'module.lti', $assessment->resourcelinktitle, $assessment->contexttitle) . '&nbsp;',
),
'inputgroup' => array(
'type' => 'fieldset',
......@@ -706,6 +706,83 @@ class PluginModuleLti extends PluginModule {
redirect('/module/lti/submission.php');
}
public static function can_revokesubmission() {
global $SESSION, $USER;
if (empty($SESSION->get('lti.assessment'))) {
return false;
}
if (!$sub = new ModuleLtiSubmission($SESSION->get('lti.assessment'), $USER->get('id'))) {
return false;
}
if (!$sub->is_submitted()) {
return false;
}
// If the assessment has been graded it can't be unsubmitted as
// the portfolio has either already been released or the submission option is locked
if ($sub->grade) {
return false;
}
return $sub;
}
public static function revokesubmission_form() {
if (!$sub = self::can_revokesubmission()) {
return false;
}
$form = array(
'name' => 'revokesubmission',
'successcallback' => 'PluginModuleLti::revokesubmission_submit',
'method' => 'post',
'action' => '',
'plugintype' => 'module',
'pluginname' => 'lti',
'elements' => array(
'id' => array(
'type' => 'hidden',
'value' => $sub->id,
),
'submit' => array(
'type' => 'submit',
'value' => get_string('revokesubmission', 'module.lti'),
'class' => 'btn btn-primary',
)
),
);
return (pieform($form));
}
public function revokesubmission_submit(Pieform $form, $values) {
global $USER;
if (!$sub = self::can_revokesubmission()) {
return false;
}
// Archive/Unlock if required by settings
if (!empty($sub->collectionid)) {
$portfolio = new Collection($sub->collectionid);
}
if (!empty($sub->viewid)) {
$portfolio = new View($sub->viewid);
}
$portfolio->release($USER);
delete_records('lti_assessment_submission', 'id', $values['id']);
redirect('/module/lti/submission.php');
}
}
class ModuleLtiSubmission {
......
......@@ -55,6 +55,7 @@ if (PluginModuleLti::can_grade()) {
else if (PluginModuleLti::can_submit_for_grading()) {
$sub = PluginModuleLti::get_submission();
$revokeform = PluginModuleLti::revokesubmission_form();
if ($sub && $sub->is_submitted()) {
$smarty->assign('PAGEHEADING', get_string('portfoliosubmittedheader', 'module.lti'));
......@@ -68,6 +69,7 @@ else if (PluginModuleLti::can_submit_for_grading()) {
$smarty->assign('grade', $sub->grade);
$smarty->assign('gradedby', empty($grader) ? '' : display_name($grader));
$smarty->assign('timegraded', $sub->timegraded);
$smarty->assign('revokeform', $revokeform);
$smarty->display('module:lti:submittedforgrading.tpl');
}
......
{include file="header.tpl"}
<p>{str tag='portfoliosubmitted' section='module.lti' arg1=$title arg2=$timesubmitted|strtotime|format_date}</p>
<p>{str tag='portfoliosubmittedforgrading' section='module.lti' arg1=$link arg2=$title arg3=$timesubmitted|strtotime|format_date}</p>
{$revokeform|safe}
{if $timegraded}
<p>{str tag='gradereceived' section='module.lti' arg1=$grade arg2=$gradedby arg3=$timegraded|strtotime|format_date}</p>
{/if}
......
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