Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
moodle-tool_lifecycle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elc
moodle-tool_lifecycle
Commits
5cdf79ea
Unverified
Commit
5cdf79ea
authored
5 years ago
by
Tobias Reischmann
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #75 from learnweb/bug/copydisplaytitle
Copy the displaytitle upon duplicate
parents
0696e4f7
6530fff5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
classes/manager/workflow_manager.php
+9
-4
9 additions, 4 deletions
classes/manager/workflow_manager.php
tests/generator/lib.php
+1
-0
1 addition, 0 deletions
tests/generator/lib.php
tests/workflow_activate_disable_duplicate_test.php
+25
-1
25 additions, 1 deletion
tests/workflow_activate_disable_duplicate_test.php
with
35 additions
and
5 deletions
classes/manager/workflow_manager.php
+
9
−
4
View file @
5cdf79ea
...
@@ -353,14 +353,19 @@ class workflow_manager {
...
@@ -353,14 +353,19 @@ class workflow_manager {
}
}
/**
/**
* Creates a workflow with a specific title. Is used to create preset workflows for trigger plugins.
* Creates a workflow with a specific title. Is used to create preset workflows for trigger plugins or for
* duplication of workflows.
*
*
* @param $title string title of the workflow. Usually the pluginname of the trigger.
* @param $title string title of the workflow.
* @param $displaytitle string display title of the workflow.
* @return workflow the created workflow.
* @return workflow the created workflow.
*/
*/
public
static
function
create_workflow
(
$title
)
{
public
static
function
create_workflow
(
$title
,
$displaytitle
=
null
)
{
$record
=
new
\stdClass
();
$record
=
new
\stdClass
();
$record
->
title
=
$title
;
$record
->
title
=
$title
;
if
(
!
is_null
(
$displaytitle
))
{
$record
->
displaytitle
=
$displaytitle
;
}
$workflow
=
workflow
::
from_record
(
$record
);
$workflow
=
workflow
::
from_record
(
$record
);
self
::
insert_or_update
(
$workflow
);
self
::
insert_or_update
(
$workflow
);
return
$workflow
;
return
$workflow
;
...
@@ -379,7 +384,7 @@ class workflow_manager {
...
@@ -379,7 +384,7 @@ class workflow_manager {
}
catch
(
\coding_exception
$e
)
{
}
catch
(
\coding_exception
$e
)
{
$newtitle
=
$oldworkflow
->
title
;
$newtitle
=
$oldworkflow
->
title
;
}
}
$newworkflow
=
self
::
create_workflow
(
$newtitle
);
$newworkflow
=
self
::
create_workflow
(
$newtitle
,
$oldworkflow
->
displaytitle
);
$newworkflow
->
rollbackdelay
=
$oldworkflow
->
rollbackdelay
;
$newworkflow
->
rollbackdelay
=
$oldworkflow
->
rollbackdelay
;
$newworkflow
->
finishdelay
=
$oldworkflow
->
finishdelay
;
$newworkflow
->
finishdelay
=
$oldworkflow
->
finishdelay
;
$newworkflow
->
delayforallworkflows
=
$oldworkflow
->
delayforallworkflows
;
$newworkflow
->
delayforallworkflows
=
$oldworkflow
->
delayforallworkflows
;
...
...
This diff is collapsed.
Click to expand it.
tests/generator/lib.php
+
1
−
0
View file @
5cdf79ea
...
@@ -74,6 +74,7 @@ class tool_lifecycle_generator extends testing_module_generator {
...
@@ -74,6 +74,7 @@ class tool_lifecycle_generator extends testing_module_generator {
$record
=
new
stdClass
();
$record
=
new
stdClass
();
$record
->
id
=
null
;
$record
->
id
=
null
;
$record
->
title
=
'myworkflow'
;
$record
->
title
=
'myworkflow'
;
$record
->
displaytitle
=
'random displaystring:'
.
random_string
(
10
);
$workflow
=
workflow
::
from_record
(
$record
);
$workflow
=
workflow
::
from_record
(
$record
);
workflow_manager
::
insert_or_update
(
$workflow
);
workflow_manager
::
insert_or_update
(
$workflow
);
foreach
(
$stepnames
as
$subpluginname
)
{
foreach
(
$stepnames
as
$subpluginname
)
{
...
...
This diff is collapsed.
Click to expand it.
tests/workflow_activate_disable_duplicate_test.php
+
25
−
1
View file @
5cdf79ea
...
@@ -74,7 +74,31 @@ class tool_lifecycle_workflow_activate_disable_duplicate_testcase extends workfl
...
@@ -74,7 +74,31 @@ class tool_lifecycle_workflow_activate_disable_duplicate_testcase extends workfl
* Test to deactivate the first workflow.
* Test to deactivate the first workflow.
*/
*/
public
function
test_deactivate_first
()
{
public
function
test_deactivate_first
()
{
// TODO to be implemented.
workflow_manager
::
handle_action
(
action
::
WORKFLOW_ABORTDISABLE
,
$this
->
workflow1
->
id
);
$this
->
assertFalse
(
workflow_manager
::
is_active
(
$this
->
workflow1
->
id
));
}
/**
* Test to duplicate the first workflow.
*/
public
function
test_duplicate_first
()
{
workflow_manager
::
handle_action
(
action
::
WORKFLOW_DUPLICATE
,
$this
->
workflow1
->
id
);
$workflows
=
workflow_manager
::
get_workflows
();
$this
->
assertCount
(
4
,
$workflows
);
// Retrieve the duplicated workflow.
$duplicate
=
null
;
$existingworkflowids
=
[
$this
->
workflow1
->
id
,
$this
->
workflow2
->
id
,
$this
->
workflow3
->
id
];
foreach
(
$workflows
as
$workflow
)
{
if
(
!
array_search
(
$workflow
->
id
,
$existingworkflowids
))
{
$duplicate
=
$workflow
;
break
;
}
}
$this
->
assertEquals
(
$this
->
workflow1
->
displaytitle
,
$duplicate
->
displaytitle
);
$workflow1stepcount
=
count
(
\tool_lifecycle\manager\step_manager
::
get_step_instances
(
$this
->
workflow1
->
id
));
$duplicatestepcount
=
count
(
\tool_lifecycle\manager\step_manager
::
get_step_instances
(
$duplicate
->
id
));
$this
->
assertEquals
(
$workflow1stepcount
,
$duplicatestepcount
);
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment