Skip to content

Commit

Permalink
Blog: Participation by user filter clears when clicking 'Next' #787694
Browse files Browse the repository at this point in the history
  • Loading branch information
toanlam authored and sammarshallou committed Jun 3, 2024
1 parent f15cc80 commit 8126df5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
12 changes: 11 additions & 1 deletion participation.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@
if ($submitted->end) {
$end = strtotime('23:59:59', $submitted->end);
}
} else if (!$timefilter->is_submitted()) {
// Recieved via post back.
if ($start = optional_param('start', null, PARAM_INT)) {
$timefilter->set_data(['start' => $start]);
$start = strtotime('00:00:00', $start);
}
if ($end = optional_param('end', null, PARAM_INT)) {
$timefilter->set_data(['end' => $end]);
$end = strtotime('23:59:59', $end);
}
}

$participation = oublog_get_participation($oublog, $context, $groupid, $cm, $course, $start, $end,
Expand Down Expand Up @@ -196,7 +206,7 @@

$oublogoutput->render_participation_list($cm, $course, $oublog, $groupid,
$download, $page, $participation, $coursecontext, $viewfullnames,
$groupname);
$groupname, $start, $end);

echo $oublogoutput->get_link_back_to_oublog($cm->name, $cm->id);

Expand Down
15 changes: 12 additions & 3 deletions participation_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ public function __construct($cm, $course, $oublog, $groupid,
/**
* Setup the columns and headers and other properties of the table and then
* call flexible_table::setup() method.
*
* @param string $download download type (csv only, default '')
* @param int $start Participation from
* @param int $end participation to
*/
public function setup($download = '') {
public function setup($download = '', $start = 0, $end = 0) {
global $CFG;

// extra headers for export only
Expand Down Expand Up @@ -106,8 +110,13 @@ public function setup($download = '') {

$this->define_columns($columns);
$this->define_headers($headers);
$this->define_baseurl($CFG->wwwroot . '/mod/oublog/participation.php?id=' .
$this->cm->id . '&group=' . $this->groupid);
$baseurl = new moodle_url("/mod/oublog/participation.php", [
'id' => $this->cm->id,
'group' => $this->groupid,
'start' => $start,
'end' => $end,
]);
$this->define_baseurl($baseurl);

$this->column_class('fullname', 'fullname');
$this->column_class('posts', 'posts');
Expand Down
8 changes: 5 additions & 3 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -556,10 +556,12 @@ public function render_time_limit_msg($stringname, $time, $capable = false, $typ
* @param array $participation mixed array of user participation values
* @param object $context current context
* @param bool $viewfullnames flag for global users fullnames capability
* @param string groupname group name for display, default ''
* @param string $groupname group name for display, default ''
* @param int $start participation from
* @param int $end participation to
*/
public function render_participation_list($cm, $course, $oublog, $groupid,
$download, $page, $participation, $context, $viewfullnames, $groupname) {
$download, $page, $participation, $context, $viewfullnames, $groupname, $start = 0, $end = 0) {
global $DB, $CFG, $OUTPUT;

require_once($CFG->dirroot.'/mod/oublog/participation_table.php');
Expand All @@ -574,7 +576,7 @@ public function render_participation_list($cm, $course, $oublog, $groupid,
$hasgrades = !empty($participation) && isset(reset($participation)->gradeobj);
$table = new oublog_participation_table($cm, $course, $oublog,
$groupid, $groupname, $hasgrades);
$table->setup($download);
$table->setup($download, $start, $end);
$table->is_downloading($download, $filename, get_string('participation', 'oublog'));

if (!empty($participation)) {
Expand Down

0 comments on commit 8126df5

Please sign in to comment.