Skip to content

Commit

Permalink
Blog: Error when end date earlier than start date in View all partici…
Browse files Browse the repository at this point in the history
…pation page #739803
  • Loading branch information
Emanoil Manoylov authored and sammarshallou committed Feb 13, 2024
1 parent f0de10d commit 00ee07e
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 14 deletions.
28 changes: 14 additions & 14 deletions participationlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
$PAGE->set_pagelayout('incourse');
require_course_login($course, true, $cm);

$start = optional_param('from', null, PARAM_INT);
$end = optional_param('to', null, PARAM_INT);

// Create time filter options form.
$customdata = array(
'cmid' => $cm->id,
Expand All @@ -78,6 +81,12 @@
'params' => array( 'tab' => $tab)
);
$timefilter = new oublog_participation_timefilter_form(null, $customdata);
if ($start) {
$timefilter->set_data(array('start' => $start));
}
if ($end) {
$timefilter->set_data(array('end' => $end));
}

$start = $end = 0;
// If data has been received from this form.
Expand All @@ -88,17 +97,8 @@
if ($submitted->end) {
$end = strtotime('23:59:59', $submitted->end);
}
} else {
// Recieved via post back for tab useage.
if ($start = optional_param('start', null, PARAM_INT)) {
$timefilter->set_data(array('start' => $start));
$start = strtotime('00:00:00', $start);
}
if ($end = optional_param('end', null, PARAM_INT)) {
$timefilter->set_data(array('end' => $end));
$end = strtotime('23:59:59', $end);
}
}

// Customise data sought based on current tab.
switch($tab) {
case 1:
Expand All @@ -110,7 +110,7 @@
break;
}

$url->params(array('individual' => $curindividual, 'start' => $start, 'end' => $end, 'group' => $groupid));
$url->params(array('individual' => $curindividual, 'from' => $start, 'to' => $end, 'group' => $groupid));
$PAGE->set_url($url);
// Add extra navigation link for users who can see all participation.
$PAGE->navbar->add(get_string('viewallparticipation', 'oublog'));
Expand All @@ -129,7 +129,7 @@
$curindividual = $individualdetails->activeindividual;
$oublog->individual = $individualdetails->mode;
echo $individualdetails->display;
$url->params(array('individual' => $curindividual, 'start' => $start, 'end' => $end));
$url->params(array('individual' => $curindividual, 'from' => $start, 'to' => $end));
$PAGE->set_url($url);
}
}
Expand Down Expand Up @@ -157,7 +157,7 @@
$participation = oublog_get_participation_details($oublog, $groupid, $curindividual,
$start, $end, $page, $getposts, $getcomments, $limitfrom, $limitnum, $masterblog);

$url->params(array('individual' => $curindividual, 'start' => $start, 'end' => $end));
$url->params(array('individual' => $curindividual, 'from' => $start, 'to' => $end));
echo html_writer::tag('h2', $info, array('class' => 'oublog-post-title'));
$timefilter->display();

Expand Down Expand Up @@ -190,7 +190,7 @@

$pagingurl = new moodle_url('/mod/oublog/participationlist.php',
array('id' => $cm->id, 'individual' => $curindividual,
'page' => $page, 'start' => $start, 'end' => $end, 'tab' => $tab, 'group' => $groupid));
'page' => $page, 'from' => $start, 'to' => $end, 'tab' => $tab, 'group' => $groupid));

echo $oublogoutput->render_all_users_participation_table($cm, $course, $oublog,
$page, $limitnum, $participation, $getposts, $getcomments,
Expand Down
49 changes: 49 additions & 0 deletions tests/behat/basic.feature
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,55 @@ Feature: Test Post and Comment on OUBlog entry
Then I should see "2 comments"
And I log out

@javascript
Scenario: Check date validation for user participation
Given I log in as "teacher1"
And I create "1" sample posts for blog with id "oublog1"
And I create "1" sample comments for blog with id "oublog1"
And I wait "2" seconds
And I reload the page

Given I am on "Course 1" course homepage
And I follow "Test oublog basics"

# Go to participation list page.
And I click on "Participation" "text" in the ".oublog-accordion-view" "css_element"
And I click on "View all participation" "link" in the ".oublog_statsview_content_participation" "css_element"
# Start date.
And I click on "#id_start_enabled" "css_element"
And I set the field "id_start_day" to "15"
And I set the field "id_start_year" to "2023"
# Set an invalid end date.
And I click on "#id_end_enabled" "css_element"
And I set the field "id_end_day" to "10"
And I set the field "id_end_year" to "2023"
When I click on "Update" "button"
Then I should see "Selection end date cannot be earlier than the start date"
# Set a valid end date.
And I set the field "id_end_day" to "15"
When I click on "Update" "button"
Then I should not see "Selection end date cannot be earlier than the start date"

Given I am on "Course 1" course homepage
And I follow "Test oublog basics"

# Go to participation page.
Given I press "Participation by user"
# Start date.
And I click on "#id_start_enabled" "css_element"
And I set the field "id_start_day" to "15"
And I set the field "id_start_year" to "2023"
# Set an invalid end date.
And I click on "#id_end_enabled" "css_element"
And I set the field "id_end_day" to "10"
And I set the field "id_end_year" to "2023"
When I click on "Update" "button"
Then I should see "Selection end date cannot be earlier than the start date"
# Set a valid end date.
And I set the field "id_end_day" to "15"
When I click on "Update" "button"
Then I should not see "Selection end date cannot be earlier than the start date"

Scenario: Check user participation
# Post as student
Given I log in as "student1"
Expand Down

0 comments on commit 00ee07e

Please sign in to comment.