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
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion backup/moodle2/backup_moodleoverflow_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function define_structure() {
'name', 'intro', 'introformat', 'maxbytes', 'maxattachments', 'timecreated', 'timemodified',
'forcesubscribe', 'trackingtype', 'ratingpreference', 'coursewidereputation', 'allowrating',
'allowreputation', 'allownegativereputation', 'grademaxgrade', 'gradescalefactor', 'gradecat',
'anonymous', 'allowmultiplemarks', ]);
'anonymous', 'allowmultiplemarks', 'la_starttime', 'la_endtime', ]);

// Define each element separated.
$discussions = new backup_nested_element('discussions');
Expand Down
68 changes: 68 additions & 0 deletions classes/output/helpicon.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?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.png';
$icon = \html_writer::img($iconurl, $content);
$class = $htmlclass;
$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>' . $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;
}
}
4 changes: 2 additions & 2 deletions classes/output/moodleoverflow_email.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ class moodleoverflow_email implements \renderable, \templatable {
/**
* Whether the user can reply to this post.
*
* @var boolean $canreply
* @var bool $canreply
*/
protected $canreply = false;

/**
* Whether to override forum display when displaying usernames.
* @var boolean $viewfullnames
* @var bool $viewfullnames
*/
protected $viewfullnames = false;

Expand Down
4 changes: 2 additions & 2 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class provider implements
*
* @return collection the updated collection of metadata items.
*/
public static function get_metadata(collection $collection) : collection {
public static function get_metadata(collection $collection): collection {
$collection->add_database_table('moodleoverflow_discussions',
[
'name' => 'privacy:metadata:moodleoverflow_discussions:name',
Expand Down Expand Up @@ -135,7 +135,7 @@ public static function get_metadata(collection $collection) : collection {
*
* @return contextlist $contextlist The list of contexts used in this plugin.
*/
public static function get_contexts_for_userid(int $userid) : contextlist {
public static function get_contexts_for_userid(int $userid): contextlist {
// Fetch all Moodleoverflow discussions, moodleoverflow posts, ratings, tracking settings and subscriptions.
$sql = "SELECT c.id
FROM {context} c
Expand Down
4 changes: 4 additions & 0 deletions classes/tables/userstats_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use mod_moodleoverflow\ratings;
require_once($CFG->dirroot . '/mod/moodleoverflow/lib.php');
require_once($CFG->libdir . '/tablelib.php');
use mod_moodleoverflow\output\helpicon;

/**
* Table listing all user statistics of a course
Expand Down Expand Up @@ -262,6 +263,9 @@ public function get_usertable() {
*/
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,
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
30 changes: 30 additions & 0 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,5 +292,35 @@ function xmldb_moodleoverflow_upgrade($oldversion) {
upgrade_mod_savepoint(true, 2023040400, 'moodleoverflow');
}

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

// Define field limitedanswer to be added to moodleoverflow.
$field = new xmldb_field('limitedanswer', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'allowmultiplemarks');

// Conditionally launch add field limitedanswer.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}

// Moodleoverflow savepoint reached.
upgrade_mod_savepoint(true, 2024031105, 'moodleoverflow');
}
if ($oldversion < 2024061700) {
// Rename the first setting, to have a start and endtime for the limited answer mode.
$table = new xmldb_table('moodleoverflow');
$field = new xmldb_field('limitedanswer', XMLDB_TYPE_INTEGER, '10', null, null, null, 0, 'allowmultiplemarks');
if ($dbman->field_exists($table, $field)) {
$dbman->rename_field($table, $field, 'la_starttime');
}
// Create the field for the end time.
$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, 2024061700, 'moodleoverflow');
}

return true;
}
4 changes: 3 additions & 1 deletion discussion.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,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 @@ -160,7 +162,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();
16 changes: 13 additions & 3 deletions lang/en/moodleoverflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@

// Default strings.
$string['modulename'] = 'Moodleoverflow';
$string['modulenameplural'] = 'Moodleoverflows';
$string['modulename_help'] = 'The Moodleoverflow module enables participants to use a question-answer forum structure. The forum display is non-chronological as the ordering depends on collaborative voting instead of on time.';
$string['modulenameplural'] = 'Moodleoverflows';
$string['moodleoverflow'] = 'Moodleoverflow';
$string['moodleoverflowfieldset'] = 'Custom example fieldset';
$string['moodleoverflowname'] = 'Moodleoverflow name';
$string['moodleoverflow'] = 'Moodleoverflow';
$string['pluginadministration'] = 'Moodleoverflow administration';
$string['pluginname'] = 'Moodleoverflow';

Expand Down Expand Up @@ -344,7 +344,17 @@
$string['attachment_help'] = 'You can optionally attach one or more files to a forum post. If you attach an image, it will be displayed after the message.';
$string['allowmultiplemarks'] = 'Multiple marks?';
$string['allowmultiplemarks_help'] = 'A post can be marked as helpful or solved. Within a discussion, only one post can be marked as helpful/solved. Click the checkbox to mark multiple posts as helpful/solved.';

$string['limitedanswerheading'] = 'Limited Answer Mode';
$string['la_starttime'] = 'Start time students can answer';
$string['la_endtime'] = 'End time students can answer';
$string['limitedanswerwarning_answers'] = 'There are already answered posts in this Moodleoverflow.';
$string['limitedanswerwarning_conclusion'] = 'Activating or changing limited answer mode might confuse users.';
$string['la_starttime_help'] = 'Students can not answer to questions until the set up date';
$string['la_endtime_help'] = 'Students can not answer to qustions after the set up date';
$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['limitedanswer_info_endtime'] = 'Posts can not be answered after {$a->limitedanswerdate}.';
$string['limitedanswer_helpicon_teacher'] = 'This can be changed in the settings of the Moodleoverflow.';
// Templates.
$string['reputation'] = 'Reputation';
$string['action_remove_upvote'] = 'Click to remove upvote';
Expand Down
Loading
Loading