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
1850c457
Commit
1850c457
authored
7 years ago
by
TamaraGunkel
Browse files
Options
Downloads
Patches
Plain Diff
Refactored view controller: Handle actions before displaying view
parent
21f8c3ec
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
classes/view_controller.php
+40
-18
40 additions, 18 deletions
classes/view_controller.php
lang/en/tool_cleanupcourses.php
+2
-0
2 additions, 0 deletions
lang/en/tool_cleanupcourses.php
view.php
+16
-1
16 additions, 1 deletion
view.php
with
58 additions
and
19 deletions
classes/view_controller.php
+
40
−
18
View file @
1850c457
...
...
@@ -22,7 +22,9 @@
*/
namespace
tool_cleanupcourses
;
use
core\notification
;
use
tool_cleanupcourses\manager\interaction_manager
;
use
tool_cleanupcourses\manager\process_manager
;
use
tool_cleanupcourses\manager\step_manager
;
use
tool_cleanupcourses\table\interaction_remaining_table
;
use
tool_cleanupcourses\table\interaction_attention_table
;
...
...
@@ -40,18 +42,11 @@ class view_controller {
/**
* Handles actions triggered in the view.php and displays the view.
*
* @param $action string triggered action code.
* @param $processid int id of the process the action was triggered for.
* @param $stepid int id of the step the action was triggerd for.
* @param \renderer_base $renderer
*
*/
public
function
handle_view
(
$action
,
$processid
,
$stepid
)
{
global
$USER
,
$DB
,
$OUTPUT
;
// Handle action for step.
if
(
$action
&&
$processid
&&
$stepid
)
{
interaction_manager
::
handle_interaction
(
$stepid
,
$processid
,
$action
);
// TODO redirect.
}
public
function
handle_view
(
$renderer
)
{
global
$USER
,
$DB
;
$courses
=
get_user_capability_course
(
'tool/cleanupcourses:managecourses'
,
$USER
,
false
);
if
(
!
$courses
)
{
...
...
@@ -86,19 +81,46 @@ class view_controller {
}
}
echo
$
OUTPUT
->
heading
(
get_string
(
'tablecoursesrequiringattention'
,
'tool_cleanupcourses'
),
3
);
echo
$
renderer
->
heading
(
get_string
(
'tablecoursesrequiringattention'
,
'tool_cleanupcourses'
),
3
);
$table1
=
new
interaction_attention_table
(
'tool_cleanupcourses_interaction'
,
$requiresinteraction
);
echo
$
OUTPUT
->
box_start
();
echo
$
renderer
->
box_start
();
$table1
->
out
(
50
,
false
);
echo
$
OUTPUT
->
box_end
();
echo
$
renderer
->
box_end
();
echo
$
OUTPUT
->
box
(
""
);
echo
$
OUTPUT
->
heading
(
get_string
(
'tablecoursesremaining'
,
'tool_cleanupcourses'
),
3
);
echo
$
renderer
->
box
(
""
);
echo
$
renderer
->
heading
(
get_string
(
'tablecoursesremaining'
,
'tool_cleanupcourses'
),
3
);
$table2
=
new
interaction_remaining_table
(
'tool_cleanupcourses_remaining'
,
$arrayofcourseids
);
echo
$
OUTPUT
->
box_start
(
"cleanupcourses-enable-overflow"
);
echo
$
renderer
->
box_start
(
"cleanupcourses-enable-overflow"
);
$table2
->
out
(
50
,
false
);
echo
$OUTPUT
->
box_end
();
echo
$renderer
->
box_end
();
}
/**
* Handle the case that the user requested interaction.
*
* @param string $action triggered action code.
* @param int $processid id of the process the action was triggered for.
* @param int $stepid id of the step the action was triggered for.
*/
public
function
handle_interaction
(
$action
,
$processid
,
$stepid
)
{
global
$PAGE
;
interaction_manager
::
handle_interaction
(
$stepid
,
$processid
,
$action
);
redirect
(
$PAGE
->
url
,
get_string
(
'interaction_success'
,
'tool_cleanupcourses'
),
null
,
notification
::
SUCCESS
);
}
/**
* Handle the case that the user manually triggered a workflow.
*
* @param int $triggerid id of the trigger whose workflow was requested.
* @param int $courseid id of the course the workflow was requested for.
*/
public
function
handle_trigger
(
$triggerid
,
$courseid
)
{
global
$PAGE
;
//interaction_manager::handle_interaction($stepid, $processid, $action);
redirect
(
$PAGE
->
url
,
get_string
(
'manual_trigger_success'
,
'tool_cleanupcourses'
),
null
,
notification
::
SUCCESS
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lang/en/tool_cleanupcourses.php
+
2
−
0
View file @
1850c457
...
...
@@ -116,6 +116,8 @@ $string['workflownotfound'] = 'Workflow with id {$a} could not be found';
$string
[
'tablecoursesrequiringattention'
]
=
'Courses that require your attention'
;
$string
[
'tablecoursesremaining'
]
=
'Remaining courses'
;
$string
[
'viewheading'
]
=
'Manage courses'
;
$string
[
'interaction_success'
]
=
'Action successfully saved.'
;
$string
[
'manual_trigger_success'
]
=
'Workflow started successfully.'
;
$string
[
'workflow_started'
]
=
'Workflow started.'
;
$string
[
'workflow_is_running'
]
=
'Workflow is running.'
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
view.php
+
16
−
1
View file @
1850c457
...
...
@@ -33,10 +33,15 @@ $PAGE->set_context(context_system::instance());
$PAGE
->
set_pagelayout
(
'admin'
);
$PAGE
->
set_url
(
new
\moodle_url
(
'/admin/tool/cleanupcourses/view.php'
));
// Interaction params.
$action
=
optional_param
(
'action'
,
null
,
PARAM_ALPHA
);
$processid
=
optional_param
(
'processid'
,
null
,
PARAM_INT
);
$stepid
=
optional_param
(
'stepid'
,
null
,
PARAM_INT
);
// Manual trigger params.
$triggerid
=
optional_param
(
'triggerid'
,
null
,
PARAM_INT
);
$courseid
=
optional_param
(
'courseid'
,
null
,
PARAM_INT
);
$PAGE
->
set_title
(
get_string
(
'viewheading'
,
'tool_cleanupcourses'
));
$PAGE
->
set_heading
(
get_string
(
'viewheading'
,
'tool_cleanupcourses'
));
...
...
@@ -45,7 +50,17 @@ $renderer = $PAGE->get_renderer('tool_cleanupcourses');
echo
$renderer
->
header
();
$controller
=
new
\tool_cleanupcourses\view_controller
();
$controller
->
handle_view
(
$action
,
$processid
,
$stepid
);
if
(
$action
!==
null
&&
$processid
!==
null
&&
$stepid
!==
null
)
{
require_sesskey
();
$controller
->
handle_interaction
(
$action
,
$processid
,
$stepid
);
exit
;
}
else
if
(
$triggerid
!==
null
&&
$courseid
!==
null
)
{
require_sesskey
();
$controller
->
handle_trigger
(
$triggerid
,
$courseid
);
exit
;
}
$controller
->
handle_view
(
$renderer
);
echo
$renderer
->
footer
();
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