Skip to content
Snippets Groups Projects
Unverified Commit 91cc3b28 authored by Tobias Reischmann's avatar Tobias Reischmann
Browse files

Added an email setting specifying the timeout for user responses

parent 805b02eb
No related branches found
No related tags found
No related merge requests found
...@@ -50,6 +50,8 @@ class process { ...@@ -50,6 +50,8 @@ class process {
$this->waiting = $waiting; $this->waiting = $waiting;
if ($timestepchanged === null) { if ($timestepchanged === null) {
$this->timestepchanged = time(); $this->timestepchanged = time();
} else {
$this->timestepchanged = $timestepchanged;
} }
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
$string['pluginname'] = 'Email Step'; $string['pluginname'] = 'Email Step';
$string['email_responsetimeout'] = 'Time the user has for the response';
$string['email_subject'] = 'Subject Template'; $string['email_subject'] = 'Subject Template';
$string['email_content'] = 'Content Template'; $string['email_content'] = 'Content Template';
$string['email_content_html'] = 'Content HTML Template'; $string['email_content_html'] = 'Content HTML Template';
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
*/ */
namespace tool_cleanupcourses\step; namespace tool_cleanupcourses\step;
use tool_cleanupcourses\manager\process_manager;
use tool_cleanupcourses\manager\settings_manager; use tool_cleanupcourses\manager\settings_manager;
use tool_cleanupcourses\response\step_response; use tool_cleanupcourses\response\step_response;
use tool_cleanupcourses\manager\step_manager; use tool_cleanupcourses\manager\step_manager;
...@@ -81,6 +82,11 @@ class email extends libbase { ...@@ -81,6 +82,11 @@ class email extends libbase {
return step_response::rollback(); return step_response::rollback();
} }
} }
// When time runs up and no one wants to keep the course, then proceed.
$process = process_manager::get_process_by_id($processid);
if ($process->timestepchanged < time() - settings_manager::get_settings($instanceid)['responsetimeout']) {
return step_response::proceed();
}
return step_response::waiting(); return step_response::waiting();
} }
...@@ -139,6 +145,7 @@ class email extends libbase { ...@@ -139,6 +145,7 @@ class email extends libbase {
public function instance_settings() { public function instance_settings() {
return array( return array(
new instance_setting('responsetimeout', PARAM_INT),
new instance_setting('subject', PARAM_TEXT), new instance_setting('subject', PARAM_TEXT),
new instance_setting('content', PARAM_RAW), new instance_setting('content', PARAM_RAW),
new instance_setting('contenthtml', PARAM_RAW), new instance_setting('contenthtml', PARAM_RAW),
...@@ -150,6 +157,9 @@ class email extends libbase { ...@@ -150,6 +157,9 @@ class email extends libbase {
} }
public function extend_add_instance_form_definition($mform) { public function extend_add_instance_form_definition($mform) {
$elementname = 'responsetimeout';
$mform->addElement('duration', $elementname, get_string('email_responsetimeout', 'cleanupcoursesstep_email'));
$mform->setType($elementname, PARAM_INT);
$elementname = 'subject'; $elementname = 'subject';
$mform->addElement('text', $elementname, get_string('email_subject', 'cleanupcoursesstep_email')); $mform->addElement('text', $elementname, get_string('email_subject', 'cleanupcoursesstep_email'));
$mform->setType($elementname, PARAM_TEXT); $mform->setType($elementname, PARAM_TEXT);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment