Skip to content
Snippets Groups Projects
Commit 7636a053 authored by Justus Dieckmann's avatar Justus Dieckmann
Browse files

Put data into interaction_remaining_table

parent 27fb0dd3
No related branches found
No related tags found
No related merge requests found
...@@ -61,11 +61,10 @@ class interaction_attention_table extends interaction_table { ...@@ -61,11 +61,10 @@ class interaction_attention_table extends interaction_table {
* Initialises the columns of the table. * Initialises the columns of the table.
*/ */
public function init() { public function init() {
$this->define_columns(['courseid', 'courseshortname', 'coursefullname', 'category', 'status', 'tools', 'date']); $this->define_columns(['courseid', 'coursefullname', 'category', 'status', 'tools', 'date']);
$this->define_headers([ $this->define_headers([
get_string('course'), get_string('course'),
get_string('shortnamecourse'), get_string('coursename', 'tool_lifecycle'),
get_string('fullnamecourse'),
get_string('category'), get_string('category'),
get_string('status', 'tool_lifecycle'), get_string('status', 'tool_lifecycle'),
get_string('tools', 'tool_lifecycle'), get_string('tools', 'tool_lifecycle'),
......
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Table listing past interactions
*
* @package tool_lifecycle
* @copyright 2019 Justus Dieckmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_lifecycle\table;
use core\plugininfo\format;
use tool_lifecycle\manager\interaction_manager;
use tool_lifecycle\manager\lib_manager;
use tool_lifecycle\manager\step_manager;
defined('MOODLE_INTERNAL') || die;
require_once($CFG->libdir . '/tablelib.php');
class interaction_log_table extends \table_sql {
public function __construct($uniqueid, $courseids) {
parent::__construct($uniqueid);
global $PAGE;
$fields = "l.id as id, c.id as courseid, c.fullname as coursefullname, c.shortname as courseshortname, " .
"w.title as workflow, s.subpluginname as subpluginname, s.instancename as stepname, u.id as user, "
. get_all_user_name_fields(true, 'u') . ", l.time, l.action";
$from = '{tool_lifecycle_action_log} l join ' .
'{course} c on l.courseid = c.id join ' .
'{tool_lifecycle_workflow} w on l.workflowid = w.id join ' .
'{tool_lifecycle_step} s on l.workflowid = s.workflowid AND l.stepindex = s.sortindex join ' .
'{user} u on l.userid = u.id';
$ids = implode(',', $courseids);
$where = 'FALSE';
if ($ids) {
$where = 'l.courseid IN (' . $ids . ')';
}
$this->column_nosort = array('step', 'action');
$this->set_sql($fields, $from, $where, []);
$this->define_baseurl($PAGE->url);
$this->init();
}
/**
* Initialises the columns of the table.
*/
public function init() {
$this->define_columns(['coursefullname', 'step', 'action', 'user', 'time']);
$this->define_headers([
get_string('course'),
get_string('step', 'tool_lifecycle'),
get_string('action', 'tool_lifecycle'),
get_string('byuser', 'tool_lifecycle'),
get_string('date'),
]);
$this->setup();
}
/**
* Render course column.
* @param $row
* @return string
*/
public function col_coursefullname($row) {
$courselink = \html_writer::link(course_get_url($row->courseid), $row->coursefullname);
return $courselink . '<br><span class="secondary-info">' . $row->courseshortname . '</span>';
}
/**
* Render process step column.
* @param $row
* @return string
*/
public function col_step($row) {
return $row->stepname . '<br><span class="secondary-info">Workflow: ' . $row->workflow . '</span>';
}
/**
* Render user column.
* @param $row
* @return string
*/
public function col_user($row) {
global $CFG;
return \html_writer::link($CFG->wwwroot . '/user/profile.php?id=' . $row->user, fullname($row));
}
/**
* Render time column.
* @param $row
* @return string
* @throws \coding_exception
*/
public function col_time($row) {
$dateformat = get_string('strftimedatetime', 'core_langconfig');
return userdate($row->time, $dateformat);
}
/**
* Render action column.
* @param $row
* @return string
*/
public function col_action($row) {
$interactionlib = lib_manager::get_step_interactionlib($row->subpluginname);
return $interactionlib->get_action_string($row->action);
}
public function print_nothing_to_display() {
global $OUTPUT;
// Render button to allow user to reset table preferences.
echo $this->render_reset_button();
$this->print_initials_bar();
echo $OUTPUT->box(get_string('nopastactions', 'tool_lifecycle'));
}
}
\ No newline at end of file
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
*/ */
namespace tool_lifecycle\table; namespace tool_lifecycle\table;
use tool_lifecycle\manager\lib_manager;
use tool_lifecycle\manager\workflow_manager; use tool_lifecycle\manager\workflow_manager;
defined('MOODLE_INTERNAL') || die; defined('MOODLE_INTERNAL') || die;
...@@ -40,11 +41,24 @@ class interaction_remaining_table extends interaction_table { ...@@ -40,11 +41,24 @@ class interaction_remaining_table extends interaction_table {
$this->availabletools = workflow_manager::get_manual_trigger_tools_for_active_workflows(); $this->availabletools = workflow_manager::get_manual_trigger_tools_for_active_workflows();
$fields = "c.id as courseid, p.id as processid, c.fullname as coursefullname, c.shortname as courseshortname, " . // COALESCE returns l.time if l.time != null and 0 otherwise.
"cc.name as category "; // We need to do this, so that courses without any action have a smaller timestamp than courses with an recorded action.
$from = '{course} c left join ' . // Otherwise, it would mess up the sorting.
'{tool_lifecycle_process} p on p.courseid = c.id ' . $fields = "c.id as courseid, p.id AS processid, c.fullname AS coursefullname, c.shortname AS courseshortname, " .
'left join {course_categories} cc on c.category = cc.id'; "cc.name AS category, COALESCE(l.time, 0) AS lastmodified, l.userid, l.action, s.subpluginname, " .
get_all_user_name_fields(true, 'u');
$from = '{course} c ' .
'LEFT JOIN {tool_lifecycle_action_log} l ON c.id = l.courseid ' .
'LEFT JOIN ( ' .
'SELECT a.courseid, MAX(a.time) AS maxtime ' .
'FROM {tool_lifecycle_action_log} a ' .
'GROUP BY a.courseid, a.time ' .
') m ' .
'ON l.courseid = m.courseid AND l.time = m.maxtime ' .
'LEFT JOIN {tool_lifecycle_process} p ON p.courseid = c.id ' .
'LEFT JOIN {course_categories} cc ON c.category = cc.id ' .
'LEFT JOIN {tool_lifecycle_step} s ON l.workflowid = s.workflowid AND l.stepindex = s.sortindex ' .
'LEFT JOIN {user} u ON l.userid = u.id';
$ids = implode(',', $courseids); $ids = implode(',', $courseids);
...@@ -53,8 +67,11 @@ class interaction_remaining_table extends interaction_table { ...@@ -53,8 +67,11 @@ class interaction_remaining_table extends interaction_table {
$where = 'c.id IN ('. $ids . ')'; $where = 'c.id IN ('. $ids . ')';
} }
$this->column_nosort = array('category', 'status', 'tools'); $order = ' ORDER BY lastmodified DESC';
$this->set_sql($fields, $from, $where, []);
$this->sortable(false);
$this->set_sql($fields, $from, $where . $order, []);
$this->set_count_sql("SELECT COUNT(1) FROM {course} c WHERE $where");
$this->define_baseurl($PAGE->url); $this->define_baseurl($PAGE->url);
$this->init(); $this->init();
} }
...@@ -63,13 +80,13 @@ class interaction_remaining_table extends interaction_table { ...@@ -63,13 +80,13 @@ class interaction_remaining_table extends interaction_table {
* Initialises the columns of the table. * Initialises the columns of the table.
*/ */
public function init() { public function init() {
$this->define_columns(['courseid', 'courseshortname', 'coursefullname', 'category', 'status', 'tools']); $this->define_columns(['courseid', 'coursefullname', 'category', 'status', 'lastmodified', 'tools']);
$this->define_headers([ $this->define_headers([
get_string('course'), get_string('course'),
get_string('shortnamecourse'), get_string('coursename', 'tool_lifecycle'),
get_string('fullnamecourse'),
get_string('category'), get_string('category'),
get_string('status', 'tool_lifecycle'), get_string('status', 'tool_lifecycle'),
get_string('lastaction', 'tool_lifecycle'),
get_string('tools', 'tool_lifecycle'), get_string('tools', 'tool_lifecycle'),
]); ]);
$this->setup(); $this->setup();
...@@ -110,4 +127,23 @@ class interaction_remaining_table extends interaction_table { ...@@ -110,4 +127,23 @@ class interaction_remaining_table extends interaction_table {
return $OUTPUT->render($menu); return $OUTPUT->render($menu);
} }
public function col_status($row) {
if (!$row->subpluginname) {
return '';
}
global $CFG;
$userlink = \html_writer::link($CFG->wwwroot . '/user/profile.php?id=' . $row->userid, fullname($row));
$interactionlib = lib_manager::get_step_interactionlib($row->subpluginname);
return $interactionlib->get_action_string($row->action, $userlink);
}
public function col_lastmodified($row) {
if (!$row->lastmodified)
return '';
$dateformat = get_string('strftimedatetime', 'core_langconfig');
return userdate($row->lastmodified, $dateformat);
}
} }
\ No newline at end of file
...@@ -54,22 +54,14 @@ abstract class interaction_table extends \table_sql { ...@@ -54,22 +54,14 @@ abstract class interaction_table extends \table_sql {
return \html_writer::link(course_get_url($row->courseid), $row->courseid); return \html_writer::link(course_get_url($row->courseid), $row->courseid);
} }
/**
* Render courseshortname column.
* @param $row
* @return string course link
*/
public function col_courseshortname($row) {
return \html_writer::link(course_get_url($row->courseid), $row->courseshortname);
}
/** /**
* Render coursefullname column. * Render coursefullname column.
* @param $row * @param $row
* @return string course link * @return string course link
*/ */
public function col_coursefullname($row) { public function col_coursefullname($row) {
return \html_writer::link(course_get_url($row->courseid), $row->coursefullname); $courselink = \html_writer::link(course_get_url($row->courseid), $row->coursefullname);
return $courselink . '<br><span class="secondary-info">' . $row->courseshortname . '</span>';
} }
/** /**
......
...@@ -102,14 +102,6 @@ class view_controller { ...@@ -102,14 +102,6 @@ class view_controller {
echo $renderer->box_start("lifecycle-enable-overflow lifecycle-table"); echo $renderer->box_start("lifecycle-enable-overflow lifecycle-table");
$table2->out(50, false); $table2->out(50, false);
echo $renderer->box_end(); echo $renderer->box_end();
echo $renderer->box("");
echo $renderer->heading(get_string('tablecourseslog', 'tool_lifecycle'), 3);
$table3 = new interaction_log_table('tool_lifecycle_log', $arrayofcourseids);
echo $renderer->box_start("lifecycle-enable-overflow lifecycle-table");
$table3->out(50, false);
echo $renderer->box_end();
} }
/** /**
......
...@@ -147,9 +147,8 @@ $string['interaction_success'] = 'Action successfully saved.'; ...@@ -147,9 +147,8 @@ $string['interaction_success'] = 'Action successfully saved.';
$string['manual_trigger_success'] = 'Workflow started successfully.'; $string['manual_trigger_success'] = 'Workflow started successfully.';
$string['manual_trigger_process_existed'] = 'A workflow for this course already exists.'; $string['manual_trigger_process_existed'] = 'A workflow for this course already exists.';
$string['nopastactions'] = 'There are no past actions'; $string['coursename'] = 'Course name';
$string['action'] = 'Action'; $string['lastaction'] = 'Last action on';
$string['byuser'] = 'By user';
$string['workflow_started'] = 'Workflow started.'; $string['workflow_started'] = 'Workflow started.';
$string['workflow_is_running'] = 'Workflow is running.'; $string['workflow_is_running'] = 'Workflow is running.';
......
...@@ -142,11 +142,11 @@ class interactionduplicate extends interactionlibbase { ...@@ -142,11 +142,11 @@ class interactionduplicate extends interactionlibbase {
/** /**
* Returns the display name for the given action. * Returns the display name for the given action.
* Used for the past actions table in view.php. * Used for the past actions table in view.php.
* * @param string $action Identifier of action
* @param $action * @param string $userlink html-link with username as text that refers to the user profile.
* @return string action display name * @return string action display name
*/ */
public function get_action_string($action) { public function get_action_string($action, $user) {
return get_string('action_new_course_data', 'lifecyclestep_duplicate'); return get_string('action_new_course_data', 'lifecyclestep_duplicate', $user);
} }
} }
\ No newline at end of file
...@@ -30,4 +30,4 @@ $string['duplicate_form'] = 'Enter data'; ...@@ -30,4 +30,4 @@ $string['duplicate_form'] = 'Enter data';
$string['duplicate_course_header'] = 'Duplicate Course'; $string['duplicate_course_header'] = 'Duplicate Course';
$string['status_message_duplication'] = 'Duplicated course will be available shortly.'; $string['status_message_duplication'] = 'Duplicated course will be available shortly.';
$string['status_message_form'] = 'Additional information required'; $string['status_message_form'] = 'Additional information required';
$string['action_new_course_data'] = 'New course data supplied'; $string['action_new_course_data'] = '{$a} supplied new course name';
\ No newline at end of file \ No newline at end of file
...@@ -109,11 +109,11 @@ class interactionemail extends interactionlibbase { ...@@ -109,11 +109,11 @@ class interactionemail extends interactionlibbase {
/** /**
* Returns the display name for the given action. * Returns the display name for the given action.
* Used for the past actions table in view.php. * Used for the past actions table in view.php.
* * @param string $action Identifier of action
* @param $action * @param string $userlink html-link with username as text that refers to the user profile.
* @return string action display name * @return string action display name
*/ */
public function get_action_string($action) { public function get_action_string($action, $user) {
return get_string('action_prevented_deletion', 'lifecyclestep_email'); return get_string('action_prevented_deletion', 'lifecyclestep_email', $user);
} }
} }
\ No newline at end of file
...@@ -50,4 +50,4 @@ $string['email:preventdeletion'] = 'Prevent Deletion'; ...@@ -50,4 +50,4 @@ $string['email:preventdeletion'] = 'Prevent Deletion';
$string['keep_course'] = 'Keep Course'; $string['keep_course'] = 'Keep Course';
$string['status_message_decision_keep'] = 'Course is still needed'; $string['status_message_decision_keep'] = 'Course is still needed';
$string['status_message_requiresattention'] = 'Course is marked for deletion'; $string['status_message_requiresattention'] = 'Course is marked for deletion';
$string['action_prevented_deletion'] = 'Prevented Deletion'; $string['action_prevented_deletion'] = '{$a} prevented deletion';
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
*/ */
namespace tool_lifecycle\step; namespace tool_lifecycle\step;
use core_user;
use tool_lifecycle\entity\process; use tool_lifecycle\entity\process;
use tool_lifecycle\entity\step_subplugin; use tool_lifecycle\entity\step_subplugin;
use tool_lifecycle\response\step_interactive_response; use tool_lifecycle\response\step_interactive_response;
...@@ -68,10 +69,11 @@ abstract class interactionlibbase { ...@@ -68,10 +69,11 @@ abstract class interactionlibbase {
/** /**
* Returns the display name for the given action. * Returns the display name for the given action.
* Used for the past actions table in view.php. * Used for the past actions table in view.php.
* @param $action * @param string $action Identifier of action
* @param string $userlink html-link with username as text that refers to the user profile.
* @return string action display name * @return string action display name
*/ */
public abstract function get_action_string($action); public abstract function get_action_string($action, $user);
/** /**
* Called when a user triggered an action for a process instance. * Called when a user triggered an action for a process instance.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment