Skip to content
Snippets Groups Projects
Unverified Commit 32fe33d7 authored by Tobias Reischmann's avatar Tobias Reischmann Committed by GitHub
Browse files

Merge pull request #82 from learnweb/feature/improve_interaction_tables

Better interactiontables 2
parents 50346ccf 45f65540
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,8 @@ class interaction_attention_table extends interaction_table {
global $PAGE;
$fields = "p.id as processid, c.id as courseid, c.fullname as coursefullname, c.shortname as courseshortname, " .
"cc.name as category , s.id as stepinstanceid, s.instancename as stepinstancename, s.subpluginname as subpluginname";
"c.startdate, cc.name as category , s.id as stepinstanceid, s.instancename as stepinstancename, ".
"s.subpluginname as subpluginname";
$from = '{tool_lifecycle_process} p join ' .
'{course} c on p.courseid = c.id join ' .
'{tool_lifecycle_step} s ' .
......@@ -51,7 +52,7 @@ class interaction_attention_table extends interaction_table {
$where = 'p.courseid IN (' . $ids . ')';
}
$this->column_nosort = array('category', 'status', 'tools');
$this->column_nosort = array('status', 'tools');
$this->set_sql($fields, $from, $where, []);
$this->define_baseurl($PAGE->url);
$this->init();
......@@ -61,10 +62,10 @@ class interaction_attention_table extends interaction_table {
* Initialises the columns of the table.
*/
public function init() {
$this->define_columns(['courseid', 'coursefullname', 'category', 'status', 'tools', 'date']);
$this->define_columns(['coursefullname', 'startdate', 'category', 'status', 'tools', 'date']);
$this->define_headers([
get_string('course'),
get_string('coursename', 'tool_lifecycle'),
get_string('startdate'),
get_string('category'),
get_string('status', 'tool_lifecycle'),
get_string('tools', 'tool_lifecycle'),
......
......@@ -45,7 +45,8 @@ class interaction_remaining_table extends interaction_table {
// We need to do this, so that courses without any action have a smaller timestamp than courses with an recorded action.
// Otherwise, it would mess up the sorting.
$fields = "c.id as courseid, p.id AS processid, c.fullname AS coursefullname, c.shortname AS courseshortname, " .
"cc.name AS category, COALESCE(l.time, 0) AS lastmodified, l.userid, l.action, s.subpluginname, " .
"c.startdate, 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 (' .
......@@ -70,10 +71,9 @@ class interaction_remaining_table extends interaction_table {
$where = 'c.id IN ('. $ids . ')';
}
$order = ' ORDER BY lastmodified DESC';
$this->sortable(false);
$this->set_sql($fields, $from, $where . $order, []);
$this->column_nosort = array('status', 'tools');
$this->sortable(true, 'lastmodified', 'DESC');
$this->set_sql($fields, $from, $where, []);
$this->set_count_sql("SELECT COUNT(1) FROM {course} c WHERE $where");
$this->define_baseurl($PAGE->url);
$this->init();
......@@ -83,10 +83,10 @@ class interaction_remaining_table extends interaction_table {
* Initialises the columns of the table.
*/
public function init() {
$this->define_columns(['courseid', 'coursefullname', 'category', 'status', 'lastmodified', 'tools']);
$this->define_columns(['coursefullname', 'startdate', 'category', 'status', 'lastmodified', 'tools']);
$this->define_headers([
get_string('course'),
get_string('coursename', 'tool_lifecycle'),
get_string('startdate'),
get_string('category'),
get_string('status', 'tool_lifecycle'),
get_string('lastaction', 'tool_lifecycle'),
......
......@@ -46,22 +46,28 @@ abstract class interaction_table extends \table_sql {
public abstract function init();
/**
* Render courseid column.
* Render coursefullname column.
* @param $row
* @return string course link
*/
public function col_courseid($row) {
return \html_writer::link(course_get_url($row->courseid), $row->courseid);
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 coursefullname column.
* Render startdate column.
* @param $row
* @return string course link
* @return string human readable date
* @throws \coding_exception
*/
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>';
public function col_startdate($row) {
if ($row->startdate) {
$dateformat = get_string('strftimedate', 'langconfig');
return userdate($row->startdate, $dateformat);
} else {
return "-";
}
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment