Skip to content

Commit

Permalink
fix upload workflow (#185)
Browse files Browse the repository at this point in the history
* fix upload workflow

* inserting feedback

* finally
  • Loading branch information
NinaHerrmann committed Jul 7, 2023
1 parent 160bc68 commit 8e08f2d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion classes/local/backup/restore_lifecycle_workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ class restore_lifecycle_workflow {
public function __construct($xmldata) {
$this->reader = new \XMLReader();
$this->reader->XML($xmldata);

}

/**
Expand Down Expand Up @@ -102,6 +101,7 @@ private function load_workflow() {
$this->workflow->timeactive = null;
$this->workflow->timedeactive = null;
$this->workflow->sortindex = null;
workflow_manager::insert_or_update($this->workflow);
}

/**
Expand Down
1 change: 1 addition & 0 deletions classes/local/manager/workflow_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public static function insert_or_update(workflow &$workflow) {
$workflow->id = $DB->insert_record('tool_lifecycle_workflow', $workflow);
}
$transaction->allow_commit();
return $workflow->id;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/manual_trigger.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@tool @tool_lifecycle
@tool @tool_lifecycle @manual_trigger
Feature: Add a manual trigger and test view and actions as a teacher

Background:
Expand Down
11 changes: 11 additions & 0 deletions tests/behat/upload_workflow.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@tool @tool_lifecycle @_file_upload @upload_workflow
Feature: Upload a workflow definition

@javascript
Scenario: Upload a new workflow
Given I log in as "admin"
And I navigate to "Plugins > Admin tools > Life Cycle > Workflow drafts" in site administration
And I click on "Upload workflow" "link"
And I upload "admin/tool/lifecycle/tests/fixtures/simpleworkflow.xml" file to "File" filemanager
And I press "Upload"
Then I should see "A Workflow"
15 changes: 15 additions & 0 deletions tests/fixtures/simpleworkflow.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<workflow id="3" title="A Workflow" manual="" displaytitle="Delete old courses" rollbackdelay="15811200" finishdelay="15811200" delayforallworkflows="0">
<step id="1" instancename="Create Backup" workflowid="3" subpluginname="createbackup" sortindex="1">
<setting name="maximumbackupspercron" value="10"/>
</step>
<step id="2" instancename="Delete Course" workflowid="3" subpluginname="deletecourse" sortindex="2">
<setting name="maximumdeletionspercron" value="10"/>
</step>
<trigger id="3" instancename="Date to trigger" workflowid="3" subpluginname="specificdate" sortindex="1">
<setting name="dates" value="01.08"/>
<setting name="timelastrun" value="0"/>
</trigger>
<trigger id="4" instancename="Age of course" workflowid="3" subpluginname="startdatedelay" sortindex="2">
<setting name="delay" value="31536000"/>
</trigger>
</workflow>
10 changes: 3 additions & 7 deletions uploadworkflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,17 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

use tool_lifecycle\action;
use tool_lifecycle\local\backup\restore_lifecycle_workflow;
use tool_lifecycle\local\entity\workflow;
use tool_lifecycle\local\form\form_upload_workflow;
use tool_lifecycle\local\form\form_workflow_instance;
use tool_lifecycle\local\manager\workflow_manager;
use tool_lifecycle\local\table\workflow_definition_table;
use tool_lifecycle\permission_and_navigation;
use tool_lifecycle\urls;

require_once(__DIR__ . '/../../../config.php');
require_once($CFG->libdir . '/adminlib.php');
require_login();
global $OUTPUT, $PAGE, $DB;

\tool_lifecycle\permission_and_navigation::setup_draft();
permission_and_navigation::setup_draft();

$PAGE->set_url(new \moodle_url(urls::UPLOAD_WORKFLOW));
$title = get_string('upload_workflow', 'tool_lifecycle');
Expand All @@ -63,7 +59,7 @@
die();
} else {
// Redirect to workflow page.
redirect(urls::WORKFLOW_DETAILS, ['wf' => $restore->get_workflow()->id]);
redirect(new moodle_url(urls::WORKFLOW_DETAILS, ['wf' => $restore->get_workflow()->id]));
}
}

Expand Down

0 comments on commit 8e08f2d

Please sign in to comment.