mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
Introducing: managed posted forums. Optional ability to 'throttle' forums by adding
three new settings: warnafter, blockafter and blockperiod. Useful for tutors with big courses with some dominant students.
This commit is contained in:
parent
bdebe6c40c
commit
a4f495bf86
@ -12,6 +12,7 @@ $string['errorcreatingfile'] = 'Error creating file \"$a\"';
|
||||
$string['errorreadingfile'] = 'Error reading file \"$a\"';
|
||||
$string['erroronline'] = 'Error on line $a';
|
||||
$string['errorunzippingfiles'] = 'Error unzipping files';
|
||||
$string['forumblockingtoomanyposts'] = 'You have exceeded the posting threshold set for this forum.';
|
||||
$string['fieldrequired'] = '\"$a\" is a required field';
|
||||
$string['filenotfound'] = 'Sorry, the requested file could not be found';
|
||||
$string['groupalready'] = 'User already belongs to group $a';
|
||||
|
@ -16,6 +16,9 @@ $string['allsubscribe'] = 'Subscribe to all forums';
|
||||
$string['allunsubscribe'] = 'Unsubscribe from all forums';
|
||||
$string['anyfile'] = 'Any file';
|
||||
$string['attachment'] = 'Attachment';
|
||||
$string['blockafter'] = 'Post threshold for blocking';
|
||||
$string['blockperiod'] = 'Time period for blocking';
|
||||
$string['blockperioddisabled'] = 'Don\'t block';
|
||||
$string['bynameondate'] = 'by $a->name - $a->date';
|
||||
$string['configcleanreadtime'] = 'The hour of the day to clean old posts from the \'read\' table.';
|
||||
$string['configdisplaymode'] = 'The default display mode for discussions if one isn\'t set.';
|
||||
@ -69,6 +72,7 @@ $string['forumintro'] = 'Forum introduction';
|
||||
$string['forumname'] = 'Forum name';
|
||||
$string['forumposts'] = 'Forum posts';
|
||||
$string['forums'] = 'Forums';
|
||||
$string['forumblockingalmosttoomanyposts'] = 'You are approaching the posting threshold. You have posted $a->numposts times in the last $a->blockperiod and the limit is $a->blockafter posts.';
|
||||
$string['forumbodyhidden'] = 'This post cannot be viewed by you, probably because you have not posted in the discussion yet.';
|
||||
$string['forumauthorhidden'] = 'Author (hidden)';
|
||||
$string['forumsubjecthidden'] = 'Subject (hidden)';
|
||||
@ -204,6 +208,7 @@ $string['subscribestart'] = 'Send me email copies of posts to this forum';
|
||||
$string['subscribestop'] = 'I don\'t want email copies of posts to this forum';
|
||||
$string['subscription'] = 'Subscription';
|
||||
$string['subscriptions'] = 'Subscriptions';
|
||||
$string['thisforumisthrottled'] = 'This forum has a limit to the number of forum postings you can make in a given time period - this is currently set at $a->blockafter posting(s) in $a->blockperiod';
|
||||
$string['timestartenderror'] = 'Display end date cannot be earlier than the start date';
|
||||
$string['trackforum'] = 'Track unread messages';
|
||||
$string['tracking'] = 'Track';
|
||||
@ -218,6 +223,7 @@ $string['unreadpostsone'] = '1 unread post';
|
||||
$string['unsubscribe'] = 'Unsubscribe from this forum';
|
||||
$string['unsubscribed'] = 'Unsubscribed';
|
||||
$string['unsubscribeshort'] = 'Unsubscribe';
|
||||
$string['warnafter'] = 'Post threshold for warning';
|
||||
$string['yesforever'] = 'Yes, forever';
|
||||
$string['yesinitially'] = 'Yes, initially';
|
||||
$string['youratedthis'] = 'You rated this';
|
||||
|
13
lang/en/help/forum/manageposts.html
Normal file
13
lang/en/help/forum/manageposts.html
Normal file
@ -0,0 +1,13 @@
|
||||
<p align="center"><b>Managed Postings Forums</b></p>
|
||||
|
||||
<p>The concept of managed postings is very simple. Users
|
||||
will be blocked from posting after a given number
|
||||
of posts in a given period, and as they approach
|
||||
that number, they'll be warned that they are
|
||||
approaching the threshold.</p>
|
||||
|
||||
<p>Setting either the warn threshold to 0 will disable warnings,
|
||||
and setting the block threshhold to 0 will disable blocking.
|
||||
If blocking is disabled, warnings will automatically be disabled.</p>
|
||||
|
||||
<p>None of these settings affect teachers posting</p>
|
@ -1072,6 +1072,13 @@ $string['searchhelp'] = 'You can search for multiple words at once.<br /><br />w
|
||||
$string['searchresults'] = 'Search results';
|
||||
$string['sec'] = 'sec';
|
||||
$string['secs'] = 'secs';
|
||||
$string['secondstotime86400'] = '1 day';
|
||||
$string['secondstotime172800'] = '2 days';
|
||||
$string['secondstotime259200'] = '3 days';
|
||||
$string['secondstotime345600'] = '4 days';
|
||||
$string['secondstotime432000'] = '5 days';
|
||||
$string['secondstotime518400'] = '6 days';
|
||||
$string['secondstotime604800'] = '1 Week';
|
||||
$string['section'] = 'Section';
|
||||
$string['sections'] = 'Sections';
|
||||
$string['seealsostats'] = 'See also: stats';
|
||||
|
@ -83,6 +83,9 @@
|
||||
fwrite ($bf,full_tag("RSSTYPE",4,false,$forum->rsstype));
|
||||
fwrite ($bf,full_tag("RSSARTICLES",4,false,$forum->rssarticles));
|
||||
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$forum->timemodified));
|
||||
fwrite ($bf,full_tag("WARNAFTER",4,false,$forum->warnafter));
|
||||
fwrite ($bf,full_tag("BLOCKAFTER",4,false,$forum->blockafter));
|
||||
fwrite ($bf,full_tag("BLOCKPERIOD",4,false,$forum->blockperiod));
|
||||
|
||||
//if we've selected to backup users info, then execute backup_forum_suscriptions and
|
||||
//backup_forum_discussions
|
||||
|
@ -214,6 +214,12 @@ function forum_upgrade($oldversion) {
|
||||
execute_sql("alter table ".$CFG->prefix."forum change column type type enum('single','news','general','social','eachuser','teacher','qanda') not null default 'general'");
|
||||
}
|
||||
|
||||
if ($oldversion < 2006011601) {
|
||||
table_column('forum','','warnafter');
|
||||
table_column('forum','','blockafter');
|
||||
table_column('forum','','blockperiod');
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,9 @@ CREATE TABLE prefix_forum (
|
||||
rsstype tinyint(2) unsigned NOT NULL default '0',
|
||||
rssarticles tinyint(2) unsigned NOT NULL default '0',
|
||||
timemodified int(10) unsigned NOT NULL default '0',
|
||||
warnafter int(10) unsigned NOT NULL default '0',
|
||||
blockafter int(10) unsigned NOT NULL default '0',
|
||||
blockperiod int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY id (id),
|
||||
KEY course (course)
|
||||
|
@ -160,6 +160,12 @@ function forum_upgrade($oldversion) {
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}forum ADD CONSTRAINT {$CFG->prefix}forum_type CHECK (type IN ('single','news','general','social','eachuser','teacher','qanda')) ");
|
||||
}
|
||||
|
||||
if ($oldversion < 2006011601) {
|
||||
table_column('forum','','warnafter');
|
||||
table_column('forum','','blockafter');
|
||||
table_column('forum','','blockperiod');
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,10 @@ CREATE TABLE prefix_forum (
|
||||
trackingtype integer NOT NULL default '1',
|
||||
rsstype integer NOT NULL default '0',
|
||||
rssarticles integer NOT NULL default '0',
|
||||
timemodified integer NOT NULL default '0'
|
||||
timemodified integer NOT NULL default '0',
|
||||
warnafter integer NOT NULL default '0',
|
||||
blockafter integer NOT NULL default '0',
|
||||
blockperiod integer NOT NULL default '0'
|
||||
);
|
||||
|
||||
CREATE INDEX prefix_forum_course_idx ON prefix_forum (course);
|
||||
|
@ -218,6 +218,12 @@
|
||||
}
|
||||
echo "</td></tr></table>";
|
||||
|
||||
if (!empty($forum->blockafter) && !empty($forum->blockperiod)) {
|
||||
$a->blockafter = $forum->blockafter;
|
||||
$a->blockperiod = get_string('secondstotime'.$forum->blockperiod);
|
||||
notify(get_string('thisforumisthrottled','forum',$a));
|
||||
}
|
||||
|
||||
if ($forum->type == 'qanda' && !isteacher($forum->course) && !forum_user_has_posted($forum->id,$discussion->id,$USER->id)) {
|
||||
notify(get_string('qandanotify','forum'));
|
||||
}
|
||||
|
@ -3884,4 +3884,49 @@ function forum_get_separate_modules($courseid) {
|
||||
|
||||
}
|
||||
|
||||
function forum_check_throttling($forum) {
|
||||
global $USER,$CFG;
|
||||
|
||||
if (is_numeric($forum)) {
|
||||
$forum = get_record('forum','id',$forum);
|
||||
}
|
||||
if (!is_object($forum)) {
|
||||
return false; // this is broken.
|
||||
}
|
||||
|
||||
if (empty($forum->blockafter)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (empty($forum->blockperiod)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isteacher($forum->course)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// get the number of posts in the last period we care about
|
||||
$timenow = time();
|
||||
$timeafter = $timenow - $forum->blockperiod;
|
||||
|
||||
$numposts = count_records_sql('SELECT COUNT(p.id) FROM '.$CFG->prefix.'forum_posts p'
|
||||
.' JOIN '.$CFG->prefix.'forum_discussions d'
|
||||
.' ON p.discussion = d.id WHERE d.forum = '.$forum->id
|
||||
.' AND p.userid = '.$USER->id.' AND p.created > '.$timeafter);
|
||||
|
||||
$a->blockafter = $forum->blockafter;
|
||||
$a->numposts = $numposts;
|
||||
$a->blockperiod = get_string('secondstotime'.$forum->blockperiod);
|
||||
|
||||
if ($forum->blockafter <= $numposts) {
|
||||
error(get_string('forumblockingtoomanyposts','error',$a),$CFG->wwwroot.'/mod/forum/view.php?f='.$forum->id);
|
||||
}
|
||||
if ($forum->warnafter <= $numposts) {
|
||||
notify(get_string('forumblockingalmosttoomanyposts','forum',$a));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -43,6 +43,16 @@
|
||||
if (!isset($form->trackingtype)) {
|
||||
$form->trackingtype = FORUM_TRACKING_OPTIONAL;
|
||||
}
|
||||
if (!isset($form->warnafter)) {
|
||||
$form->warnafter = 0;
|
||||
}
|
||||
if (!isset($form->blockafter)) {
|
||||
$form->blockafter = 0;
|
||||
}
|
||||
if (!isset($form->blockperiod)) {
|
||||
$form->blockperiod = 0;
|
||||
}
|
||||
|
||||
?>
|
||||
<form name="form" method="post" action="mod.php">
|
||||
<table cellpadding="5">
|
||||
@ -287,6 +297,34 @@
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top"><b><?php print_string("warnafter", "forum") ?>:</b></td>
|
||||
<td><input type="text" name="warnafter" value="<?php p($form->warnafter); ?>" /><?php
|
||||
helpbutton('manageposts', get_string('warnafter', 'forum'),'forum'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top"><b><?php print_string("blockafter", "forum") ?>:</b></td>
|
||||
<td><input type="text" name="blockafter" value="<?php p($form->blockafter); ?>" /><?php
|
||||
helpbutton('manageposts', get_string('blockafter', 'forum'),'forum'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top"><b><?php print_string("blockperiod", "forum") ?>:</b></td>
|
||||
<td><?php
|
||||
unset($options);
|
||||
$options[0] = get_string('blockperioddisabled','forum');
|
||||
$options[60*60*24] = '1 '.get_string('day');
|
||||
$options[60*60*24*2] = '2 '.get_string('days');
|
||||
$options[60*60*24*3] = '3 '.get_string('days');
|
||||
$options[60*60*24*4] = '4 '.get_string('days');
|
||||
$options[60*60*24*5] = '5 '.get_string('days');
|
||||
$options[60*60*24*6] = '6 '.get_string('days');
|
||||
$options[60*60*24*7] = '1 '.get_string('week');
|
||||
choose_from_menu($options,'blockperiod',$form->blockperiod,'');
|
||||
helpbutton('manageposts', get_string('blockperiod', 'forum'),'forum'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php print_standard_coursemodule_settings($form); ?>
|
||||
</table>
|
||||
<center>
|
||||
|
@ -636,6 +636,8 @@
|
||||
notify(get_string('qandanotify','forum'));
|
||||
}
|
||||
|
||||
forum_check_throttling($forum);
|
||||
|
||||
if (!empty($parent)) {
|
||||
forum_print_post($parent, $course->id, $ownpost=false, $reply=false, $link=false);
|
||||
if (empty($post->edit)) {
|
||||
|
@ -5,7 +5,7 @@
|
||||
// This fragment is called by /admin/index.php
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$module->version = 2006011600;
|
||||
$module->version = 2006011601;
|
||||
$module->requires = 2005031000; // Requires this Moodle version
|
||||
$module->cron = 60;
|
||||
|
||||
|
@ -219,6 +219,12 @@
|
||||
|
||||
echo '</tr></table>';
|
||||
|
||||
if (!empty($forum->blockafter) && !empty($forum->blockperiod)) {
|
||||
$a->blockafter = $forum->blockafter;
|
||||
$a->blockperiod = get_string('secondstotime'.$forum->blockperiod);
|
||||
notify(get_string('thisforumisthrottled','forum',$a));
|
||||
}
|
||||
|
||||
if ($forum->type == 'qanda' && !isteacher($forum->course)) {
|
||||
notify(get_string('qandanotify','forum'));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user