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

Added new field to process table: Time the step instance changed

parent da87dcc2
No related branches found
No related tags found
No related merge requests found
...@@ -40,11 +40,17 @@ class process { ...@@ -40,11 +40,17 @@ class process {
/** bool true if course is in status waiting*/ /** bool true if course is in status waiting*/
public $waiting; public $waiting;
public function __construct($id, $stepid, $courseid, $waiting = false) { /** timestamp date the process was moved to the current step instance */
public $timestepchanged;
public function __construct($id, $stepid, $courseid, $waiting = false, $timestepchanged = null) {
$this->id = $id; $this->id = $id;
$this->stepid = $stepid; $this->stepid = $stepid;
$this->courseid = $courseid; $this->courseid = $courseid;
$this->waiting = $waiting; $this->waiting = $waiting;
if ($timestepchanged === null) {
$this->timestepchanged = time();
}
} }
/** /**
...@@ -62,13 +68,16 @@ class process { ...@@ -62,13 +68,16 @@ class process {
if (!object_property_exists($record, 'courseid')) { if (!object_property_exists($record, 'courseid')) {
return null; return null;
} }
if (!object_property_exists($record, 'timestepchanged')) {
return null;
}
if ($record->waiting) { if ($record->waiting) {
$waiting = true; $waiting = true;
} else { } else {
$waiting = false; $waiting = false;
} }
$instance = new self($record->id, $record->stepid, $record->courseid, $waiting); $instance = new self($record->id, $record->stepid, $record->courseid, $waiting, $record->timestepchanged);
return $instance; return $instance;
} }
......
...@@ -41,6 +41,7 @@ class process_manager { ...@@ -41,6 +41,7 @@ class process_manager {
$record = new \stdClass(); $record = new \stdClass();
$record->courseid = $courseid; $record->courseid = $courseid;
$record->stepid = $trigger->followedby; $record->stepid = $trigger->followedby;
$record->timestepchanged = time();
$DB->insert_record('tool_cleanupcourses_process', $record); $DB->insert_record('tool_cleanupcourses_process', $record);
} }
} }
...@@ -85,6 +86,7 @@ class process_manager { ...@@ -85,6 +86,7 @@ class process_manager {
if ($step->followedby) { if ($step->followedby) {
$process->stepid = $step->followedby; $process->stepid = $step->followedby;
$process->waiting = false; $process->waiting = false;
$process->timestepchanged = time();
$DB->update_record('tool_cleanupcourses_process', $process); $DB->update_record('tool_cleanupcourses_process', $process);
return true; return true;
} else { } else {
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<FIELD NAME="courseid" TYPE="int" LENGTH="20" NOTNULL="true" SEQUENCE="false" COMMENT="course id"/> <FIELD NAME="courseid" TYPE="int" LENGTH="20" NOTNULL="true" SEQUENCE="false" COMMENT="course id"/>
<FIELD NAME="stepid" TYPE="int" LENGTH="20" NOTNULL="true" SEQUENCE="false" COMMENT="Id of the step currently responsible for this course"/> <FIELD NAME="stepid" TYPE="int" LENGTH="20" NOTNULL="true" SEQUENCE="false" COMMENT="Id of the step currently responsible for this course"/>
<FIELD NAME="waiting" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="tells if the process is in status waiting"/> <FIELD NAME="waiting" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="tells if the process is in status waiting"/>
<FIELD NAME="timestepchanged" TYPE="int" LENGTH="11" NOTNULL="true" SEQUENCE="false" COMMENT="unix timestamp - time the step instance of the process was changed last."/>
</FIELDS> </FIELDS>
<KEYS> <KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/> <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment