Skip to content
Snippets Groups Projects
Commit 11d8ae25 authored by TamaraGunkel's avatar TamaraGunkel
Browse files

seperated tables for interaction and remaining courses

parent e9451312
Branches
No related tags found
No related merge requests found
...@@ -36,7 +36,7 @@ class interaction_table extends \table_sql { ...@@ -36,7 +36,7 @@ class interaction_table extends \table_sql {
/** @var step_subplugin $stepinstance */ /** @var step_subplugin $stepinstance */
private $stepinstance; private $stepinstance;
public function __construct($uniqueid) { public function __construct($uniqueid, $courseids) {
parent::__construct($uniqueid); parent::__construct($uniqueid);
global $PAGE, $USER; global $PAGE, $USER;
...@@ -45,36 +45,11 @@ class interaction_table extends \table_sql { ...@@ -45,36 +45,11 @@ class interaction_table extends \table_sql {
'{course} c on p.courseid = c.id join ' . '{course} c on p.courseid = c.id join ' .
'{tool_cleanupcourses_step} s '. '{tool_cleanupcourses_step} s '.
'on p.workflowid = s.workflowid AND p.stepindex = s.sortindex'; 'on p.workflowid = s.workflowid AND p.stepindex = s.sortindex';
// if (interaction_manager::show_relevant_courses_instance_dependent($this->stepinstance->subpluginname)) {
// $where = 's.id = :stepid'; $ids = join(',', $courseids);
// $params = array('stepid' => $stepid);
// } else { $where = 'p.courseid IN ('. $ids . ')';
// $where = 's.subpluginname = :subpluginname';
// $params = array('subpluginname' => $this->stepinstance->subpluginname);
// }
//$capability = interaction_manager::get_relevant_capability($this->stepinstance->subpluginname);
$courses = get_user_capability_course('tool/cleanupcourses:managecourse', $USER, false);
if ($courses) {
$listofcourseids = array_reduce($courses, function ($course1, $course2) {
if (!$course1) {
return $course2->id;
}
if (!$course2) {
return $course1->id;
}
if (is_object($course1) && object_property_exists($course1, 'id')) {
$course1 = $course1->id;
}
if (is_object($course2) && object_property_exists($course2, 'id')) {
$course2 = $course2->id;
}
return $course1 . ',' . $course2;
});
$where = 'p.courseid IN ('. $listofcourseids . ')';
} else {
$where = 'FALSE';
}
$this->set_sql($fields, $from, $where, []); $this->set_sql($fields, $from, $where, []);
$this->define_baseurl($PAGE->url); $this->define_baseurl($PAGE->url);
...@@ -129,17 +104,11 @@ class interaction_table extends \table_sql { ...@@ -129,17 +104,11 @@ class interaction_table extends \table_sql {
public function col_tools($row) { public function col_tools($row) {
$output = ''; $output = '';
$step = step_manager::get_step_instance($row->stepinstanceid); $step = step_manager::get_step_instance($row->stepinstanceid);
$capability = interaction_manager::get_relevant_capability($step->subpluginname);
if(has_capability($capability, \context_course::instance($row->courseid), null, false)) {
$tools = interaction_manager::get_action_tools($step->subpluginname, $row->processid); $tools = interaction_manager::get_action_tools($step->subpluginname, $row->processid);
foreach ($tools as $tool) { foreach ($tools as $tool) {
$output .= $this->format_icon_link($tool['action'], $row->processid, $step->id, $tool['icon'], $tool['alt']); $output .= $this->format_icon_link($tool['action'], $row->processid, $step->id, $tool['icon'], $tool['alt']);
} }
}
else {
// TODO show explanation.
}
return $output; return $output;
} }
...@@ -190,6 +159,6 @@ class interaction_table extends \table_sql { ...@@ -190,6 +159,6 @@ class interaction_table extends \table_sql {
$this->print_initials_bar(); $this->print_initials_bar();
echo $OUTPUT->heading(get_string('nocoursestodisplay', 'tool_cleanupcourses')); echo $OUTPUT->box(get_string('nocoursestodisplay', 'tool_cleanupcourses'));
} }
} }
\ No newline at end of file
...@@ -24,7 +24,7 @@ defined('MOODLE_INTERNAL') || die(); ...@@ -24,7 +24,7 @@ defined('MOODLE_INTERNAL') || die();
$capabilities = array( $capabilities = array(
'tool/cleanupcourses:managecourse' => array( 'tool/cleanupcourses:managecourses' => array(
'contextlevel' => CONTEXT_COURSE, 'contextlevel' => CONTEXT_COURSE,
'captype' => 'write', 'captype' => 'write',
'archetypes' => array( 'archetypes' => array(
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
$string['pluginname'] = 'Cleanup Courses'; $string['pluginname'] = 'Cleanup Courses';
$string['plugintitle'] = 'Cleanup Courses'; $string['plugintitle'] = 'Cleanup Courses';
$string['cleanupcourses:managecourse'] = 'May manage courses in tool_cleanupcourses'; $string['cleanupcourses:managecourses'] = 'May manage courses in tool_cleanupcourses';
$string['general_config_header'] = "General & Subplugins"; $string['general_config_header'] = "General & Subplugins";
$string['config_delay_duration'] = 'Duration of a course delay'; $string['config_delay_duration'] = 'Duration of a course delay';
......
...@@ -34,7 +34,7 @@ $capabilities = array( ...@@ -34,7 +34,7 @@ $capabilities = array(
'teacher' => CAP_PREVENT, 'teacher' => CAP_PREVENT,
'students' => CAP_PREVENT, 'students' => CAP_PREVENT,
), ),
'clonepermissionsfrom' => 'tool/cleanupcourses:managecourse' 'clonepermissionsfrom' => 'tool/cleanupcourses:managecourses'
), ),
); );
......
...@@ -23,5 +23,5 @@ ...@@ -23,5 +23,5 @@
defined('MOODLE_INTERNAL') || die; defined('MOODLE_INTERNAL') || die;
$plugin->version = 2018022005; $plugin->version = 2018022010;
$plugin->component = 'tool_cleanupcourses'; $plugin->component = 'tool_cleanupcourses';
...@@ -30,14 +30,12 @@ use tool_cleanupcourses\table\interaction_table; ...@@ -30,14 +30,12 @@ use tool_cleanupcourses\table\interaction_table;
require_login(); require_login();
$PAGE->set_context(context_system::instance()); $PAGE->set_context(context_system::instance());
$PAGE->set_pagelayout('admin');
$PAGE->set_url(new \moodle_url('/admin/tool/cleanupcourses/view.php')); $PAGE->set_url(new \moodle_url('/admin/tool/cleanupcourses/view.php'));
//$stepid = required_param('stepid', PARAM_INT);
$action = optional_param('action', null, PARAM_ALPHA); $action = optional_param('action', null, PARAM_ALPHA);
$processid = optional_param('processid', null, PARAM_INT); $processid = optional_param('processid', null, PARAM_INT);
//$stepinstance = step_manager::get_step_instance($stepid);
$PAGE->set_title("Title"); $PAGE->set_title("Title");
$PAGE->set_heading("Heading"); $PAGE->set_heading("Heading");
...@@ -45,17 +43,8 @@ $renderer = $PAGE->get_renderer('tool_cleanupcourses'); ...@@ -45,17 +43,8 @@ $renderer = $PAGE->get_renderer('tool_cleanupcourses');
echo $renderer->header(); echo $renderer->header();
//if (interaction_manager::interaction_available($stepinstance->subpluginname)) { $controller = new \tool_cleanupcourses\view_controller();
// if ($action && $processid) { $controller->handle_view();
// interaction_manager::handle_interaction($stepinstance->id, $processid, $action);
// }
$table = new interaction_table('tool_cleanupcourses_interaction');
$table->out(50, false);
//} else {
// echo get_string('nointeractioninterface', 'tool_cleanupcourses');
//}
echo $renderer->footer(); echo $renderer->footer();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment