New mini-feature. When choosing ratings in a forum, one can now

specify a range of dates.  Only posts within this range can be rated.
If the range isn't specified then all posts can be rated.
This commit is contained in:
moodler 2003-08-25 07:39:06 +00:00
parent 34b7a42851
commit 98914efdbe
10 changed files with 98 additions and 11 deletions

View File

@ -98,6 +98,7 @@ $string['ratingonlyteachers'] = "Only \$a can rate posts";
$string['rating'] = "Rating";
$string['ratings'] = "Ratings";
$string['ratingssaved'] = "Ratings saved";
$string['ratingtime'] = "Restrict ratings to posts with dates in this range:";
$string['re'] = "Re:"; // Put in front of subjects that are replies to another post
$string['readtherest'] = "Read the rest of this topic";
$string['replies'] = "Replies";

View File

@ -51,6 +51,8 @@
fwrite ($bf,full_tag("INTRO",4,false,$forum->intro));
fwrite ($bf,full_tag("OPEN",4,false,$forum->open));
fwrite ($bf,full_tag("ASSESSED",4,false,$forum->assessed));
fwrite ($bf,full_tag("ASSESSTIMESTART",4,false,$forum->assesstimestart));
fwrite ($bf,full_tag("ASSESSTIMEFINISH",4,false,$forum->assesstimefinish));
fwrite ($bf,full_tag("SCALE",4,false,$forum->scale));
fwrite ($bf,full_tag("FORCESUBSCRIBE",4,false,$forum->forcesubscribe));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$forum->timemodified));

View File

@ -65,6 +65,11 @@ function forum_upgrade($oldversion) {
if ($oldversion < 2003081403) {
table_column("forum", "assessed", "assessed", "integer", "10", "unsigned", "0");
}
if ($oldversion < 2003082500) {
table_column("forum", "", "assesstimestart", "integer", "10", "unsigned", "0", "", "assessed");
table_column("forum", "", "assesstimefinish", "integer", "10", "unsigned", "0", "", "assesstimestart");
}
return true;

View File

@ -10,6 +10,8 @@ CREATE TABLE prefix_forum (
intro text NOT NULL,
open tinyint(2) unsigned NOT NULL default '2',
assessed int(10) unsigned NOT NULL default '0',
assesstimestart int(10) unsigned NOT NULL default '0',
assesstimefinish int(10) unsigned NOT NULL default '0',
scale int(10) unsigned NOT NULL default '0',
forcesubscribe tinyint(1) unsigned NOT NULL default '0',
timemodified int(10) unsigned NOT NULL default '0',

View File

@ -10,6 +10,10 @@ function forum_upgrade($oldversion) {
execute_sql("INSERT INTO {$CFG->prefix}log_display VALUES ('forum', 'move discussion', 'forum_discussions', 'name')");
}
if ($oldversion < 2003082500) {
table_column("forum", "", "assesstimestart", "integer", "10", "unsigned", "0", "", "assessed");
table_column("forum", "", "assesstimefinish", "integer", "10", "unsigned", "0", "", "assesstimestart");
}
return true;

View File

@ -10,6 +10,8 @@ CREATE TABLE prefix_forum (
intro text NOT NULL default '',
open integer NOT NULL default '2',
assessed integer NOT NULL default '0',
assesstimestart integer NOT NULL default '0',
assesstimefinish integer NOT NULL default '0',
scale integer NOT NULL default '0',
forcesubscribe integer NOT NULL default '0',
timemodified integer NOT NULL default '0'

View File

@ -51,8 +51,17 @@ function forum_add_instance($forum) {
return false;
}
if ($forum->type == "single") { // Create related discussion.
if (!empty($forum->ratingtime)) {
$forum->assesstimestart = make_timestamp($forum->startyear, $forum->startmonth, $forum->startday,
$forum->starthour, $forum->startminute, 0);
$forum->assesstimefinish = make_timestamp($forum->finishyear, $forum->finishmonth, $forum->finishday,
$forum->finishhour, $forum->finishminute, 0);
} else {
$forum->assesstimestart = 0;
$forum->assesstimefinish = 0;
}
if ($forum->type == "single") { // Create related discussion.
$discussion->course = $forum->course;
$discussion->forum = $forum->id;
$discussion->name = $forum->name;
@ -77,6 +86,16 @@ function forum_update_instance($forum) {
$forum->timemodified = time();
$forum->id = $forum->instance;
if (!empty($forum->ratingtime)) {
$forum->assesstimestart = make_timestamp($forum->startyear, $forum->startmonth, $forum->startday,
$forum->starthour, $forum->startminute, 0);
$forum->assesstimefinish = make_timestamp($forum->finishyear, $forum->finishmonth, $forum->finishday,
$forum->finishhour, $forum->finishminute, 0);
} else {
$forum->assesstimestart = 0;
$forum->assesstimefinish = 0;
}
if ($forum->type == "single") { // Update related discussion and post.
if (! $discussion = get_record("forum_discussions", "forum", $forum->id)) {
if ($discussions = get_records("forum_discussions", "forum", $forum->id, "timemodified ASC")) {
@ -968,7 +987,8 @@ function forum_make_mail_post(&$post, $user, $touser, $course,
}
function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link=false, $ratings=NULL, $footer="", $highlight="") {
function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link=false,
$ratings=NULL, $footer="", $highlight="") {
global $THEME, $USER, $CFG;
echo "<a name=\"$post->id\"></a>";
@ -1049,15 +1069,23 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link
echo "<div align=right><p align=right>";
if (!empty($ratings) and !empty($USER->id)) {
if (isteacher($courseid)) {
forum_print_ratings_mean($post->id, $ratings->scale);
if ($USER->id != $post->userid) {
forum_print_rating_menu($post->id, $USER->id, $ratings->scale);
$useratings = true;
if ($ratings->assesstimestart and $ratings->assesstimefinish) {
if ($post->created < $ratings->assesstimestart or $post->created > $ratings->assesstimefinish) {
$useratings = false;
}
}
if ($useratings) {
if (isteacher($courseid)) {
forum_print_ratings_mean($post->id, $ratings->scale);
if ($USER->id != $post->userid) {
forum_print_rating_menu($post->id, $USER->id, $ratings->scale);
}
} else if ($USER->id == $post->userid) {
forum_print_ratings_mean($post->id, $ratings->scale);
} else if (!empty($ratings->allow) ) {
forum_print_rating_menu($post->id, $USER->id, $ratings->scale);
}
} else if ($USER->id == $post->userid) {
forum_print_ratings_mean($post->id, $ratings->scale);
} else if (!empty($ratings->allow) ) {
forum_print_rating_menu($post->id, $USER->id, $ratings->scale);
}
}
@ -1913,6 +1941,8 @@ function forum_print_discussion($course, $forum, $discussion, $post, $mode) {
if ($forum->assessed and !empty($USER->id)) {
if ($scale = get_record("scale", "id", $forum->scale)) {
$ratings->scale = make_menu_from_list($scale->scale);
$ratings->assesstimestart = $forum->assesstimestart;
$ratings->assesstimefinish = $forum->assesstimefinish;
if ($forum->assessed == 2 and !isteacher($course->id)) {
$ratings->allow = false;
} else {

View File

@ -94,6 +94,45 @@
helpbutton("ratings", get_string("allowratings", "forum"), "forum");
echo "<br />";
print_scale_menu($course->id, "scale", $form->scale);
echo "<br />";
echo "<script>";
echo " var subitems = ['startday','startmonth','startyear','starthour', 'startminute',".
"'finishday','finishmonth','finishyear','finishhour','finishminute'];";
echo "</script>";
echo "<input name=\"ratingtime\" type=checkbox value=1 ";
echo " onclick=\"return lockoptions('form','ratingtime', subitems)\" ";
if ($form->assesstimestart and $form->assesstimefinish and $form->assessed) {
$form->ratingtime = 1;
echo " checked ";
}
echo ">";
print_string("ratingtime", "forum");
echo "<table align=left><tr><td align=right nowrap>";
echo get_string("from").":";
print_date_selector("startday", "startmonth", "startyear", $form->assesstimestart);
print_time_selector("starthour", "startminute", $form->assesstimestart);
echo "<br />";
echo get_string("to").":";
print_date_selector("finishday", "finishmonth", "finishyear", $form->assesstimefinish);
print_time_selector("finishhour", "finishminute", $form->assesstimefinish);
echo "<br />";
echo "</td></tr></table>";
echo "<input type=\"hidden\" name=\"hstartday\" value=0>";
echo "<input type=\"hidden\" name=\"hstartmonth\" value=0>";
echo "<input type=\"hidden\" name=\"hstartyear\" value=0>";
echo "<input type=\"hidden\" name=\"hstarthour\" value=0>";
echo "<input type=\"hidden\" name=\"hstartminute\" value=0>";
echo "<input type=\"hidden\" name=\"hfinishday\" value=0>";
echo "<input type=\"hidden\" name=\"hfinishmonth\" value=0>";
echo "<input type=\"hidden\" name=\"hfinishyear\" value=0>";
echo "<input type=\"hidden\" name=\"hfinishhour\" value=0>";
echo "<input type=\"hidden\" name=\"hfinishminute\" value=0>";
if (empty($form->ratingtime)) {
echo "<script>";
echo "lockoptions('form','ratingtime', subitems);";
echo "</script>";
}
?>
</td>
</tr>

View File

@ -54,6 +54,8 @@
$forum->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']);
$forum->open = backup_todb($info['MOD']['#']['OPEN']['0']['#']);
$forum->assessed = backup_todb($info['MOD']['#']['ASSESSED']['0']['#']);
$forum->assesstimestart = backup_todb($info['MOD']['#']['ASSESSTIMESTART']['0']['#']);
$forum->assesstimefinish = backup_todb($info['MOD']['#']['ASSESSTIMEFINISH']['0']['#']);
$forum->scale = backup_todb($info['MOD']['#']['SCALE']['0']['#']);
$forum->forcesubscribe = backup_todb($info['MOD']['#']['FORCESUBSCRIBE']['0']['#']);
$forum->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);

View File

@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
$module->version = 2003081403;
$module->version = 2003082500;
$module->cron = 60;
?>