Skip to content
New issue

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

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

Already on GitHub? # to your account

Feature/limitedanswermode #207

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 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
7dbcaa9
synchronize with master
TamaroWalter Mar 6, 2025
97c7bb6
add m4.5 check
TamaroWalter Mar 6, 2025
4be841f
fix helpicon
TamaroWalter Mar 12, 2025
0c66db7
codecleaning
TamaroWalter Mar 12, 2025
346fe3b
upgrade and version update
TamaroWalter Mar 12, 2025
bc2d091
improve settings elements
TamaroWalter Mar 17, 2025
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
8 changes: 4 additions & 4 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
php: ['8.3']
moodle-branch: ['MOODLE_404_STABLE']
moodle-branch: ['MOODLE_405_STABLE']
database: ['pgsql']

steps:
Expand Down Expand Up @@ -111,17 +111,17 @@ jobs:
fail-fast: false
matrix:
php: ['8.0', '8.1', '8.2', '8.3']
moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_402_STABLE', 'MOODLE_403_STABLE', 'MOODLE_404_STABLE']
moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_403_STABLE', 'MOODLE_404_STABLE', 'MOODLE_405_STABLE']
database: ['mariadb', 'pgsql']
exclude:
- php: '8.0'
moodle-branch: 'MOODLE_404_STABLE'
- php: '8.0'
moodle-branch: 'MOODLE_405_STABLE'
- php: '8.2'
moodle-branch: 'MOODLE_401_STABLE'
- php: '8.3'
moodle-branch: 'MOODLE_401_STABLE'
- php: '8.3'
moodle-branch: 'MOODLE_402_STABLE'
- php: '8.3'
moodle-branch: 'MOODLE_403_STABLE'
include:
Expand Down
25 changes: 14 additions & 11 deletions backup/moodle2/backup_moodleoverflow_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,35 +39,41 @@ class backup_moodleoverflow_activity_structure_step extends backup_activity_stru
* @return backup_nested_element
*/
protected function define_structure() {

// To know if we are including userinfo.
$userinfo = $this->get_setting_value('userinfo');

// Define the root element describing the moodleoverflow instance.
$moodleoverflow = new backup_nested_element('moodleoverflow', ['id'], [
'name', 'intro', 'introformat', 'maxbytes', 'maxattachments', 'timecreated', 'timemodified', 'forcesubscribe',
'trackingtype', 'ratingpreference', 'coursewidereputation', 'allowrating', 'allowreputation', 'allownegativereputation',
'grademaxgrade', 'gradescalefactor', 'gradecat', 'anonymous', 'allowmultiplemarks', ]);
'name', 'intro', 'introformat', 'maxbytes', 'maxattachments', 'timecreated', 'timemodified',
'forcesubscribe', 'trackingtype', 'ratingpreference', 'coursewidereputation', 'allowrating',
'allowreputation', 'allownegativereputation', 'grademaxgrade', 'gradescalefactor', 'gradecat',
'anonymous', 'allowmultiplemarks', 'la_starttime', 'la_endtime', ]);

// Define each element separated.
$discussions = new backup_nested_element('discussions');
$discussion = new backup_nested_element('discussion', ['id'], [
'name', 'firstpost', 'userid', 'timestart', 'timemodified', 'usermodified', ]);

$posts = new backup_nested_element('posts');
$post = new backup_nested_element('post', ['id'], ['parent', 'userid', 'created', 'modified', 'message',
'messageformat', 'attachment', 'mailed', 'reviewed', 'timereviewed', ]);
$post = new backup_nested_element('post', ['id'], [
'parent', 'userid', 'created', 'modified',
'message', 'messageformat', 'attachment', 'mailed', 'reviewed', 'timereviewed', ]);

$ratings = new backup_nested_element('ratings');
$rating = new backup_nested_element('rating', ['id'], ['userid', 'rating', 'firstrated', 'lastchanged']);
$rating = new backup_nested_element('rating', ['id'], [
'userid', 'rating', 'firstrated', 'lastchanged', ]);

$discussionsubs = new backup_nested_element('discuss_subs');
$discussionsub = new backup_nested_element('discuss_sub', ['id'], ['userid', 'preference']);
$discussionsub = new backup_nested_element('discuss_sub', ['id'], [
'userid', 'preference', ]);

$subscriptions = new backup_nested_element('subscriptions');
$subscription = new backup_nested_element('subscription', ['id'], ['userid']);

$readposts = new backup_nested_element('readposts');
$read = new backup_nested_element('read', ['id'], ['userid', 'discussionid', 'postid', 'firstread', 'lastread']);
$read = new backup_nested_element('read', ['id'], [
'userid', 'discussionid', 'postid', 'firstread', 'lastread', ]);

$grades = new backup_nested_element('grades');
$grade = new backup_nested_element('grade', ['id'], ['userid', 'grade']);
Expand All @@ -94,9 +100,6 @@ protected function define_structure() {
$moodleoverflow->add_child($readposts);
$readposts->add_child($read);

$moodleoverflow->add_child($grades);
$grades->add_child($grade);

$moodleoverflow->add_child($tracking);
$tracking->add_child($track);

Expand Down
72 changes: 72 additions & 0 deletions classes/output/helpicon.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Use of the Helpicon from Moodle core.
* @package mod_moodleoverflow
* @copyright 2023 Tamaro Walter
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace mod_moodleoverflow\output;

/**
* Builds a Helpicon, that shows a String when hovering over it.
* @package mod_moodleoverflow
* @copyright 2023 Tamaro Walter
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class helpicon {

/** @var object The Helpicon*/
private $helpobject;

/**
* Builds a Helpicon and stores it in helpobject.
*
* @param string $htmlclass The classname in which the icon will be.
* @param string $content A string that shows the information that the icon has.
*/
public function __construct($htmlclass, $content) {
global $CFG;
$iconurl = $CFG->wwwroot . '/pix/a/help.svg';
$iconstyle = ['style' =>
'max-width: 20px; max-height: 20px; margin: 0; padding: 0; box-sizing: content-box; margin-right: .5rem;'];
$icon = \html_writer::img($iconurl, $content, $iconstyle);

$class = $htmlclass;
$iconattributes = ['role' => 'button',
'style' => 'display: inline;',
'data-container' => 'body',
'data-toggle' => 'popover',
'data-placement' => 'right',
'data-action' => 'showhelpicon',
'data-html' => 'true',
'data-trigger' => 'focus',
'tabindex' => '0',
'data-content' => '<div class=&quot;no-overflow&quot;><p>' . $content . '</p> </div>', ];
$this->helpobject = \html_writer::span($icon, $class, $iconattributes);
}

/**
* Returns the Helpicon, so that it can be used.
*
* @return object The Helpicon
*/
public function get_helpicon() {
return $this->helpobject;
}
}
25 changes: 5 additions & 20 deletions classes/tables/userstats_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
require_once($CFG->dirroot . '/mod/moodleoverflow/lib.php');
require_once($CFG->dirroot . '/mod/moodleoverflow/locallib.php');
require_once($CFG->libdir . '/tablelib.php');
use mod_moodleoverflow\output\helpicon;

/**
* Table listing all user statistics of a course
Expand Down Expand Up @@ -151,27 +152,11 @@ public function get_usertable() {
* Setup the help icon for amount of activity
*/
public function set_helpactivity() {
global $CFG;
$htmlclass = 'helpactivityclass btn btn-link';
$content = get_string('helpamountofactivity', 'moodleoverflow');
$helpobject = new helpicon($htmlclass, $content);
$this->helpactivity = new \stdClass();
$this->helpactivity->iconurl = $CFG->wwwroot . '/pix/a/help.png';
$this->helpactivity->icon = \html_writer::img($this->helpactivity->iconurl,
get_string('helpamountofactivity', 'moodleoverflow'));
$this->helpactivity->class = 'helpactivityclass btn btn-link';
$this->helpactivity->iconattributes = ['role' => 'button',
'data-container' => 'body',
'data-toggle' => 'popover',
'data-placement' => 'right',
'data-action' => 'showhelpicon',
'data-html' => 'true',
'data-trigger' => 'focus',
'tabindex' => '0',
'data-content' => '<div class=&quot;no-overflow&quot;><p>' .
get_string('helpamountofactivity', 'moodleoverflow') .
'</p> </div>', ];

$this->helpactivity->object = \html_writer::span($this->helpactivity->icon,
$this->helpactivity->class,
$this->helpactivity->iconattributes);
$this->helpactivity->object = $helpobject->get_helpicon();
}

// Functions that show the data.
Expand Down
2 changes: 2 additions & 0 deletions db/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
<FIELD NAME="anonymous" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="needsreview" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="allowmultiplemarks" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="la_starttime" TYPE="int" LENGTH="10" NOTNULL="false" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="la_endtime" TYPE="int" LENGTH="10" NOTNULL="false" DEFAULT="0" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
Expand Down
17 changes: 17 additions & 0 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,5 +300,22 @@ function xmldb_moodleoverflow_upgrade($oldversion) {
upgrade_mod_savepoint(true, 2024072600, 'moodleoverflow');
}

if ($oldversion < 2025031200) {
// Define table moodleoverflow to be edited.
$table = new xmldb_table('moodleoverflow');

// Create the field fot the start time for the limited answer mode.
$field = new xmldb_field('la_starttime', XMLDB_TYPE_INTEGER, '10', null, null, null, 0, 'allowmultiplemarks');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Create the field for the end time for the limited answer mode.
$field = new xmldb_field('la_endtime', XMLDB_TYPE_INTEGER, '10', null, null, null, 0, 'la_starttime');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
upgrade_mod_savepoint(true, 2025031200, 'moodleoverflow');
}

return true;
}
4 changes: 3 additions & 1 deletion discussion.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
if ($marksetting->allowmultiplemarks == 1) {
$multiplemarks = true;
}
// Setting of limitedanswer. Limitedanswertime saves the timestamp, until the limitedanswer is on (0 if off).
$limitedanswersetting = $DB->get_record('moodleoverflow', ['id' => $moodleoverflow->id], 'la_starttime, la_endtime');

// Get the related coursemodule and its context.
if (!$cm = get_coursemodule_from_instance('moodleoverflow', $moodleoverflow->id, $course->id)) {
Expand Down Expand Up @@ -156,7 +158,7 @@

echo '<div id="moodleoverflow-posts"><div id="moodleoverflow-root">';

moodleoverflow_print_discussion($course, $cm, $moodleoverflow, $discussion, $post, $multiplemarks);
moodleoverflow_print_discussion($course, $cm, $moodleoverflow, $discussion, $post, $multiplemarks, $limitedanswersetting);
echo '</div></div>';

echo $OUTPUT->footer();
14 changes: 14 additions & 0 deletions lang/en/moodleoverflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,21 @@
$string['invalidpostid'] = 'Invalid post ID - {$a}';
$string['invalidratingid'] = 'The submitted rating is neither an upvote nor a downvote.';
$string['jump_to_next_post_needing_review'] = 'Jump to next post needing to be reviewed.';
$string['la_endtime'] = 'Time at which students can no longer answer';
$string['la_endtime_help'] = 'Students can not answer to qustions after the set up date';
$string['la_endtime_ruleerror'] = 'End time must be in the future';
$string['la_sequence_error'] = 'The end time must be after the start time';
$string['la_starttime'] = 'Time at which students can start to answer';
$string['la_starttime_help'] = 'Students can not answer to questions until the set up date';
$string['la_starttime_ruleerror'] = 'Start time must be in the future';
$string['lastpost'] = 'Last post';
$string['limitedanswer_helpicon_teacher'] = 'This can be changed in the settings of the Moodleoverflow.';
$string['limitedanswer_info_endtime'] = 'Posts can not be answered after {$a->limitedanswerdate}.';
$string['limitedanswer_info_start'] = 'This Moodleoverflow is in a limited answer mode.';
$string['limitedanswer_info_starttime'] = 'Posts can not be answered until {$a->limitedanswerdate}.';
$string['limitedanswerheading'] = 'Limited Answer Mode';
$string['limitedanswerwarning_answers'] = 'There are already answered posts in this Moodleoverflow.';
$string['limitedanswerwarning_conclusion'] = 'You can only set a time until students are able to answer';
$string['mailindexlink'] = 'Change your forum preferences: {$a}';
$string['manydiscussions'] = 'Discussions per page';
$string['markallread'] = 'Mark all posts in this discussion as read';
Expand Down
Loading
Loading