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
7f3210ee
Unverified
Commit
7f3210ee
authored
8 years ago
by
Tobias Reischmann
Browse files
Options
Downloads
Patches
Plain Diff
First working version of the view.php including interactions
parent
6475422c
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
classes/table/interaction_table.php
+68
-14
68 additions, 14 deletions
classes/table/interaction_table.php
lang/en/tool_cleanupcourses.php
+3
-0
3 additions, 0 deletions
lang/en/tool_cleanupcourses.php
version.php
+1
-1
1 addition, 1 deletion
version.php
view.php
+18
-4
18 additions, 4 deletions
view.php
with
90 additions
and
19 deletions
classes/table/interaction_table.php
+
68
−
14
View file @
7f3210ee
...
...
@@ -23,6 +23,7 @@
*/
namespace
tool_cleanupcourses\table
;
use
tool_cleanupcourses\entity\step_subplugin
;
use
tool_cleanupcourses\manager\interaction_manager
;
use
tool_cleanupcourses\manager\step_manager
;
...
...
@@ -32,26 +33,54 @@ require_once($CFG->libdir . '/tablelib.php');
class
interaction_table
extends
\table_sql
{
/** @var step_subplugin $stepinstance */
private
$stepinstance
;
public
function
__construct
(
$uniqueid
,
$stepid
)
{
parent
::
__construct
(
'tool_cleanupcourses_interaction_table'
);
$stepinstance
=
step_manager
::
get_step_instance
(
$stepid
);
global
$PAGE
,
$USER
;
$this
->
set_sql
(
'c.id as courseid, c.fullname as coursename, s.subpluginname as subpluginname '
,
'{tool_cleanupcourses_process} p join '
.
$this
->
stepinstance
=
step_manager
::
get_step_instance
(
$stepid
);
global
$PAGE
,
$USER
,
$DB
;
$fields
=
'p.id as processid, c.id as courseid, c.fullname as coursename'
;
$from
=
'{tool_cleanupcourses_process} p join '
.
'{course} c on p.courseid = c.id join '
.
'{tool_cleanupcourses_step} s on p.stepid = s.id'
,
"TRUE"
);
'{tool_cleanupcourses_step} s on p.stepid = s.id'
;
if
(
interaction_manager
::
show_relevant_courses_instance_dependent
(
$this
->
stepinstance
->
subpluginname
))
{
$where
=
'p.stepid = :stepid'
;
$params
=
array
(
'stepid'
=>
$stepid
);
}
else
{
$where
=
's.subpluginname = :subpluginname'
;
$params
=
array
(
'subpluginname'
=>
$this
->
stepinstance
->
subpluginname
);
}
$capability
=
interaction_manager
::
get_relevant_capability
(
$this
->
stepinstance
->
subpluginname
);
$courses
=
get_user_capability_course
(
$capability
,
$USER
,
false
);
if
(
$courses
)
{
$listofcourseids
=
array_reduce
(
$courses
,
function
(
$course1
,
$course2
)
{
if
(
!
$course1
)
{
return
$course2
->
id
;
}
if
(
!
$course2
)
{
return
$course1
->
id
;
}
return
$course1
->
id
.
','
.
$course2
->
id
;
});
$where
.
=
' AND c.id in (:listofcourseids)'
;
$params
[
'listofcourseids'
]
=
$listofcourseids
;
}
else
{
$where
.
=
' AND FALSE'
;
}
$this
->
set_sql
(
$fields
,
$from
,
$where
,
$params
);
$this
->
define_baseurl
(
$PAGE
->
url
);
$this
->
init
();
$capability
=
interaction_manager
::
get_relevant_capability
(
$stepinstance
->
subpluginname
);
$courses
=
get_user_capability_course
(
$capability
,
$USER
,
false
);
}
public
function
init
()
{
$this
->
define_columns
([
'course'
,
'
subplugin
'
]);
$this
->
define_headers
([
get_string
(
'course'
),
get_string
(
'
step
'
,
'tool_cleanupcourses'
)]);
$this
->
define_columns
([
'course'
,
'
tools
'
]);
$this
->
define_headers
([
get_string
(
'course'
),
get_string
(
'
tools
'
,
'tool_cleanupcourses'
)]);
$this
->
setup
();
}
...
...
@@ -69,10 +98,35 @@ class interaction_table extends \table_sql {
* @param $row
* @return string pluginname of the subplugin
*/
public
function
col_subplugin
(
$row
)
{
public
function
col_tools
(
$row
)
{
$output
=
''
;
$tools
=
interaction_manager
::
get_action_tools
(
$this
->
stepinstance
->
subpluginname
);
foreach
(
$tools
as
$tool
)
{
$output
.
=
$this
->
format_icon_link
(
$tool
[
'action'
],
$row
->
processid
,
$tool
[
'icon'
],
$tool
[
'alt'
]);
}
return
$output
;
}
$subpluginname
=
$row
->
subpluginname
;
/**
* Util function for writing an action icon link
*
* @param string $action URL parameter to include in the link
* @param string $processid URL parameter to include in the link
* @param string $icon The key to the icon to use (e.g. 't/up')
* @param string $alt The string description of the link used as the title and alt text
* @return string The icon/link
*/
private
function
format_icon_link
(
$action
,
$processid
,
$icon
,
$alt
)
{
global
$PAGE
,
$OUTPUT
;
return
get_string
(
'pluginname'
,
'cleanupcoursesstep_'
.
$subpluginname
);
return
$OUTPUT
->
action_icon
(
new
\moodle_url
(
$PAGE
->
url
,
array
(
'stepid'
=>
$this
->
stepinstance
->
id
,
'action'
=>
$action
,
'$processid'
=>
$processid
,
'sesskey'
=>
sesskey
()
)),
new
\pix_icon
(
$icon
,
$alt
,
'moodle'
,
array
(
'title'
=>
$alt
)),
null
,
array
(
'title'
=>
$alt
))
.
' '
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lang/en/tool_cleanupcourses.php
+
3
−
0
View file @
7f3210ee
...
...
@@ -59,3 +59,6 @@ $string['subplugintype_cleanupcoursestrigger'] = 'Trigger for starting the cours
$string
[
'subplugintype_cleanupcoursestrigger_plural'
]
=
'Triggers for starting the course cleanup'
;
$string
[
'subplugintype_cleanupcoursesstep'
]
=
'Step within a course cleanup process'
;
$string
[
'subplugintype_cleanupcoursesstep_plural'
]
=
'Steps within a course cleanup process'
;
$string
[
'nointeractioninterface'
]
=
'No Interaction Interface available!'
;
$string
[
'tools'
]
=
'Tools'
;
This diff is collapsed.
Click to expand it.
version.php
+
1
−
1
View file @
7f3210ee
...
...
@@ -23,5 +23,5 @@
defined
(
'MOODLE_INTERNAL'
)
||
die
;
$plugin
->
version
=
201705310
1
;
$plugin
->
version
=
201705310
2
;
$plugin
->
component
=
'tool_cleanupcourses'
;
This diff is collapsed.
Click to expand it.
view.php
+
18
−
4
View file @
7f3210ee
...
...
@@ -9,6 +9,8 @@
*/
require_once
(
dirname
(
__FILE__
)
.
'/../../../config.php'
);
use
tool_cleanupcourses\manager\step_manager
;
use
tool_cleanupcourses\manager\interaction_manager
;
use
tool_cleanupcourses\table\interaction_table
;
require_login
();
...
...
@@ -16,10 +18,11 @@ require_login();
$PAGE
->
set_context
(
context_system
::
instance
());
$PAGE
->
set_url
(
new
\moodle_url
(
'/admin/tool/cleanupcourses/view.php'
));
$s
ubplugin
id
=
required_param
(
's
ubplugin
id'
,
PARAM_INT
);
$s
tep
id
=
required_param
(
's
tep
id'
,
PARAM_INT
);
$action
=
optional_param
(
'action'
,
null
,
PARAM_ALPHA
);
$processid
=
optional_param
(
'processid'
,
null
,
PARAM_INT
);
$
table
=
new
interaction_table
(
'tool_cleanupcourses_interaction'
);
$
stepinstance
=
step_manager
::
get_step_instance
(
$stepid
);
$PAGE
->
set_title
(
"Title"
);
$PAGE
->
set_heading
(
"Heading"
);
...
...
@@ -28,6 +31,17 @@ $renderer = $PAGE->get_renderer('tool_cleanupcourses');
echo
$renderer
->
header
();
$table
->
out
(
50000
,
false
);
if
(
interaction_manager
::
interaction_available
(
$stepinstance
->
subpluginname
))
{
if
(
$action
&&
$processid
)
{
interaction_manager
::
handle_interaction
(
$action
,
$processid
);
}
$table
=
new
interaction_table
(
'tool_cleanupcourses_interaction'
,
$stepinstance
->
id
);
$table
->
out
(
5000
,
false
);
}
else
{
echo
get_string
(
'nointeractioninterface'
,
'tool_cleanupcourses'
);
}
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