Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature: restricted time for participation for moodleoverflow forums #138

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a24909b
add setting to enable a limited mode
TamaroWalter May 9, 2023
fa24912
Merge branch 'master' into feature/limitedanswermode
TamaroWalter May 22, 2023
3e3c9b2
Update upgrade.php
TamaroWalter May 22, 2023
e1b23c9
answer button functionality updated, new helpicon class
TamaroWalter May 23, 2023
d4960a4
functionality is finished, testing missing
TamaroWalter May 30, 2023
9e9cb7a
code cleaning with code/phpdoc checker
TamaroWalter May 31, 2023
d8f8c85
github workflow error fixed, difference between student and teacher
TamaroWalter May 31, 2023
19616b6
github workflows error fixed
TamaroWalter May 31, 2023
f0bba6e
last workflow errors fixed
TamaroWalter May 31, 2023
5d2247a
workflow errors fixed
TamaroWalter May 31, 2023
499c6bd
workflow behat errors fixed
TamaroWalter May 31, 2023
377364a
Merge branch 'master' into feature/limitedanswermode
TamaroWalter May 28, 2024
01035e8
add global cfg statement
TamaroWalter May 28, 2024
f0ff660
adapt workflow to update branch
TamaroWalter May 28, 2024
438bffe
Merge branch 'update/M4.4' of github.com:learnweb/moodle-mod_moodleov…
TamaroWalter May 28, 2024
76345d9
codecleaning
TamaroWalter May 30, 2024
d5ed8f8
change the version as it has been increased since the last merge
NinaHerrmann Jun 6, 2024
b924e07
merge branches
NinaHerrmann Jun 6, 2024
7bb058c
fixed proken SQL Statement
NinaHerrmann Jun 6, 2024
96d7bcc
behat test for limitedanswer feature
TamaroWalter Jun 11, 2024
52a406c
codecleaning
TamaroWalter Jun 11, 2024
0004695
add limitedanswer time to backup
TamaroWalter Jun 13, 2024
c3c131b
solve merge conflicts
TamaroWalter Jun 13, 2024
01217a6
added a endtime adjusting settings, locallib, post, langfiles
NinaHerrmann Jun 17, 2024
1e22011
adjusted behat
NinaHerrmann Jun 17, 2024
2dc8f65
review
NinaHerrmann Jun 18, 2024
92edcb8
adjusted the mod_form to show warning in case answers exists
NinaHerrmann Jun 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
behat test for limitedanswer feature
  • Loading branch information
TamaroWalter committed Jun 11, 2024
commit 96d7bcce8bb4bb31b6c62ee3cb1f2257623c7f69
2 changes: 1 addition & 1 deletion locallib.php
Original file line number Diff line number Diff line change
@@ -1306,7 +1306,7 @@ function moodleoverflow_print_post($post, $discussion, $moodleoverflow, $cm, $co
// Check if limitedanswertime is on.
if ($limitedanswertime > time()) {
// Change limitedanswertime to a readable date.
$date = gmdate('d.m.Y', $limitedanswertime);
$date = gmdate('d.m.Y H:i', $limitedanswertime);

// Check if user is a student or teacher.
$roleid = $DB->get_field('role', 'id', ['shortname' => 'editingteacher']);
20 changes: 20 additions & 0 deletions tests/behat/behat_mod_moodleoverflow.php
Original file line number Diff line number Diff line change
@@ -235,4 +235,24 @@ public function should_not_exist_in_the_moodleoverflow_discussion_card($element,
$this->getSession()
);
}

/**
* Sets the limited answer attribute of a moodleoverflow to the current time.
*
* @Given I set the :activity moodleoverflow limitedanswertime to now
* @param $activity
* @param $value
* @return void
*/
public function i_set_the_moodleoverflow_limitedanswertime_to_now($activity): void {
global $DB;

if (!$activityRecord = $DB->get_record('moodleoverflow', ['name' => $activity])) {
throw new Exception("Activity '$activity' not found");
}

// Update the specified field
$activityRecord->limitedanswer = time();
$DB->update_record('moodleoverflow', $activityRecord);
}
}
47 changes: 47 additions & 0 deletions tests/behat/limitedanswer.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@mod @mod_moodleoverflow @javascript
Feature: Moodleoverflows can start in a limited answer mode, where answers from
students are not enabled until a set date.

Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |

Scenario: With limited answer mode on, a teacher can answer a post that a student can not. When the teacher changes the
limitedanswer date to now, the student can now answer the post.
Given the following "activities" exist:
| activity | name | intro | course | idnumber | limitedanswer |
| moodleoverflow | Test Moodleoverflow | Test moodleoverflow description | C1 | 1 | ##now +1 day## |
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Test Moodleoverflow"
And I add a new discussion to "Test Moodleoverflow" moodleoverflow with:
| Subject | Forum post 1 |
| Message | This is the question message |
And I log out
And I log in as "student1"
And I am on "Course 1" course homepage
And I follow "Test Moodleoverflow"
And I follow "Forum post 1"
And I click on "Answer" "text"
Then I should not see "Your reply"
When I set the "Test Moodleoverflow" moodleoverflow limitedanswertime to now
And I am on "Course 1" course homepage
And I follow "Test Moodleoverflow"
And I follow "Forum post 1"
And I click on "Answer" "text"
Then I should see "Your reply"
And I set the following fields to these values:
| Subject | Re: Forum post 1 |
| Message | This is the answer message |
And I press "Post to forum"
Then I should see "This is the answer message"
And I should see "This is the question message"
1 change: 0 additions & 1 deletion version.php
Original file line number Diff line number Diff line change
@@ -28,7 +28,6 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'mod_moodleoverflow';

$plugin->version = 2024031105;
$plugin->release = 'v4.2-r4';
$plugin->requires = 2020061500; // Requires Moodle 3.9+.
Loading