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 { ...@@ -38,7 +38,8 @@ class interaction_attention_table extends interaction_table {
global $PAGE; global $PAGE;
$fields = "p.id as processid, c.id as courseid, c.fullname as coursefullname, c.shortname as courseshortname, " . $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 ' . $from = '{tool_lifecycle_process} p join ' .
'{course} c on p.courseid = c.id join ' . '{course} c on p.courseid = c.id join ' .
'{tool_lifecycle_step} s ' . '{tool_lifecycle_step} s ' .
...@@ -51,7 +52,7 @@ class interaction_attention_table extends interaction_table { ...@@ -51,7 +52,7 @@ class interaction_attention_table extends interaction_table {
$where = 'p.courseid IN (' . $ids . ')'; $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->set_sql($fields, $from, $where, []);
$this->define_baseurl($PAGE->url); $this->define_baseurl($PAGE->url);
$this->init(); $this->init();
...@@ -61,10 +62,10 @@ class interaction_attention_table extends interaction_table { ...@@ -61,10 +62,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', 'coursefullname', 'category', 'status', 'tools', 'date']); $this->define_columns(['coursefullname', 'startdate', 'category', 'status', 'tools', 'date']);
$this->define_headers([ $this->define_headers([
get_string('course'),
get_string('coursename', 'tool_lifecycle'), get_string('coursename', 'tool_lifecycle'),
get_string('startdate'),
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'),
......
...@@ -45,7 +45,8 @@ class interaction_remaining_table extends interaction_table { ...@@ -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. // 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. // Otherwise, it would mess up the sorting.
$fields = "c.id as courseid, p.id AS processid, c.fullname AS coursefullname, c.shortname AS courseshortname, " . $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'); get_all_user_name_fields(true, 'u');
$from = '{course} c ' . $from = '{course} c ' .
'LEFT JOIN (' . 'LEFT JOIN (' .
...@@ -70,10 +71,9 @@ class interaction_remaining_table extends interaction_table { ...@@ -70,10 +71,9 @@ class interaction_remaining_table extends interaction_table {
$where = 'c.id IN ('. $ids . ')'; $where = 'c.id IN ('. $ids . ')';
} }
$order = ' ORDER BY lastmodified DESC'; $this->column_nosort = array('status', 'tools');
$this->sortable(true, 'lastmodified', 'DESC');
$this->sortable(false); $this->set_sql($fields, $from, $where, []);
$this->set_sql($fields, $from, $where . $order, []);
$this->set_count_sql("SELECT COUNT(1) FROM {course} c WHERE $where"); $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();
...@@ -83,10 +83,10 @@ class interaction_remaining_table extends interaction_table { ...@@ -83,10 +83,10 @@ 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', 'coursefullname', 'category', 'status', 'lastmodified', 'tools']); $this->define_columns(['coursefullname', 'startdate', 'category', 'status', 'lastmodified', 'tools']);
$this->define_headers([ $this->define_headers([
get_string('course'),
get_string('coursename', 'tool_lifecycle'), get_string('coursename', 'tool_lifecycle'),
get_string('startdate'),
get_string('category'), get_string('category'),
get_string('status', 'tool_lifecycle'), get_string('status', 'tool_lifecycle'),
get_string('lastaction', 'tool_lifecycle'), get_string('lastaction', 'tool_lifecycle'),
......
...@@ -46,22 +46,28 @@ abstract class interaction_table extends \table_sql { ...@@ -46,22 +46,28 @@ abstract class interaction_table extends \table_sql {
public abstract function init(); public abstract function init();
/** /**
* Render courseid column. * Render coursefullname column.
* @param $row * @param $row
* @return string course link * @return string course link
*/ */
public function col_courseid($row) { public function col_coursefullname($row) {
return \html_writer::link(course_get_url($row->courseid), $row->courseid); $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 * @param $row
* @return string course link * @return string human readable date
* @throws \coding_exception
*/ */
public function col_coursefullname($row) { public function col_startdate($row) {
$courselink = \html_writer::link(course_get_url($row->courseid), $row->coursefullname); if ($row->startdate) {
return $courselink . '<br><span class="secondary-info">' . $row->courseshortname . '</span>'; $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