mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 08:55:15 +02:00
New forum type: question and answer: requires students to post their answer before being able to view other posts. After initial post, students can view & respond normally
This commit is contained in:
parent
e746e4dd99
commit
098d27d46e
@ -4,6 +4,7 @@
|
||||
|
||||
|
||||
$string['addanewdiscussion'] = 'Add a new discussion topic';
|
||||
$string['addanewquestion'] = 'Add a new question';
|
||||
$string['addanewtopic'] = 'Add a new topic';
|
||||
$string['advancedsearch'] = 'Advanced search';
|
||||
$string['allforums'] = 'All forums';
|
||||
@ -41,6 +42,8 @@ $string['digestmailheader'] = 'This is your daily digest of new posts from the $
|
||||
$string['digestmailprefs'] = 'your user profile';
|
||||
$string['digestmailsubject'] = '$a: forum digest';
|
||||
$string['digestsentusers'] = 'Email digests successfully sent to $a users.';
|
||||
$string['disallowsubscribe'] = 'Subscriptions not allowed';
|
||||
$string['disallowsubscribeteacher'] = 'Subscriptions not allowed (except for teachers)';
|
||||
$string['discussion'] = 'Discussion';
|
||||
$string['discussionmoved'] = 'This discussion has been moved to \'$a\'.';
|
||||
$string['discussionname'] = 'Discussion name';
|
||||
@ -66,6 +69,9 @@ $string['forumintro'] = 'Forum introduction';
|
||||
$string['forumname'] = 'Forum name';
|
||||
$string['forumposts'] = 'Forum posts';
|
||||
$string['forums'] = 'Forums';
|
||||
$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)';
|
||||
$string['forumtype'] = 'Forum type';
|
||||
$string['generalforum'] = 'Standard forum for general use';
|
||||
$string['generalforums'] = 'General forums';
|
||||
@ -105,6 +111,7 @@ $string['nomorepostscontaining'] = 'No more posts containing \'$a\' were found';
|
||||
$string['nonews'] = 'No news has been posted yet';
|
||||
$string['noposts'] = 'No posts';
|
||||
$string['nopostscontaining'] = 'No posts containing \'$a\' were found';
|
||||
$string['noquestions'] = 'There are no questions yet in this forum';
|
||||
$string['nosubscribers'] = 'There are no subscribers yet for this forum';
|
||||
$string['nothingnew'] = 'Nothing new for $a';
|
||||
$string['notingroup'] = 'Sorry, but you need to be part of a group to see this forum.';
|
||||
@ -143,6 +150,9 @@ $string['processingpost'] = 'Processing post $a';
|
||||
$string['prune'] = 'Split';
|
||||
$string['prunedpost'] = 'A new discussion has been created from that post';
|
||||
$string['pruneheading'] = 'Split the discussion and move this post to a new discussion';
|
||||
$string['qandaforum'] = 'Q and A forum';
|
||||
$string['qandanotify'] = 'This is a Question and Answer forum. In order to see other responses to these Questions, you must first post your Answer';
|
||||
$string['cannotviewpostyet'] = 'You cannot read other students questions in this discussion yet because you haven\'t posted';
|
||||
$string['rate'] = 'Rate';
|
||||
$string['rating'] = 'Rating';
|
||||
$string['ratingeveryone'] = 'Everyone can rate posts';
|
||||
@ -212,6 +222,7 @@ $string['yesforever'] = 'Yes, forever';
|
||||
$string['yesinitially'] = 'Yes, initially';
|
||||
$string['youratedthis'] = 'You rated this';
|
||||
$string['yournewtopic'] = 'Your new discussion topic';
|
||||
$string['yournewquestion'] = 'Your new question';
|
||||
$string['yourreply'] = 'Your reply';
|
||||
|
||||
?>
|
||||
|
@ -13,4 +13,10 @@ new discussion topic (everyone can reply to them though). This is useful when
|
||||
you want each student to start a discussion about, say, their reflections on
|
||||
the week's topic, and everyone else responds to these.</p>
|
||||
|
||||
<p><b>Q And A Forum</b> - The Q & A forum requires students to post their
|
||||
perspectives before viewing other students' postings. After the initial posting,
|
||||
students can view and respond to others' postings. This feature allows equal
|
||||
initial posting opportunity among all students, thus encouraging original and
|
||||
independent thinking.</p>
|
||||
|
||||
<p>(More development to come in future versions of Moodle)</p>
|
||||
|
@ -209,6 +209,10 @@ function forum_upgrade($oldversion) {
|
||||
table_column('forum_discussions','','timestart','integer');
|
||||
table_column('forum_discussions','','timeend','integer');
|
||||
}
|
||||
|
||||
if ($oldversion < 2006011600) {
|
||||
execute_sql("alter table mdl_forum change column type type enum('single','news','general','social','eachuser','teacher','qanda') not null default 'general'");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
CREATE TABLE prefix_forum (
|
||||
id int(10) unsigned NOT NULL auto_increment,
|
||||
course int(10) unsigned NOT NULL default '0',
|
||||
type enum('single','news','general','social','eachuser','teacher') NOT NULL default 'general',
|
||||
type enum('single','news','general','social','eachuser','teacher','qanda') NOT NULL default 'general',
|
||||
name varchar(255) NOT NULL default '',
|
||||
intro text NOT NULL,
|
||||
open tinyint(2) unsigned NOT NULL default '2',
|
||||
|
@ -155,6 +155,11 @@ function forum_upgrade($oldversion) {
|
||||
table_column('forum_discussions','','timeend','integer');
|
||||
}
|
||||
|
||||
if ($oldversion < 2006011600) {
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}forum DROP CONSTRAINT {$CFG->prefix}forum_type");
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}forum ADD CONSTRAINT {$CFG->prefix}forum_type CHECK (type IN ('single','news','general','social','eachuser','teacher','qanda')) ");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
CREATE TABLE prefix_forum (
|
||||
id SERIAL PRIMARY KEY,
|
||||
course integer NOT NULL default '0',
|
||||
type varchar(10) CHECK (type IN ('single','news','general','social','eachuser','teacher')) NOT NULL default 'general',
|
||||
type varchar(10) CHECK (type IN ('single','news','general','social','eachuser','teacher','qanda')) NOT NULL default 'general',
|
||||
name varchar(255) NOT NULL default '',
|
||||
intro text NOT NULL default '',
|
||||
open integer NOT NULL default '2',
|
||||
|
@ -218,6 +218,10 @@
|
||||
}
|
||||
echo "</td></tr></table>";
|
||||
|
||||
if ($forum->type == 'qanda' && !isteacher($forum->course) && !forum_user_has_posted($forum->id,$discussion->id,$USER->id)) {
|
||||
notify(get_string('qandanotify','forum'));
|
||||
}
|
||||
|
||||
if (isset($discussionmoved)) {
|
||||
notify(get_string("discussionmoved", "forum", format_string($forum->name,true)));
|
||||
}
|
||||
|
@ -237,7 +237,11 @@
|
||||
$subscribed = $strno;
|
||||
$subtitle = get_string("subscribe", "forum");
|
||||
}
|
||||
$sublink = "<a title=\"$subtitle\" href=\"subscribe.php?id=$forum->id\">$subscribed</a>";
|
||||
if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE && !isteacher($forum->course)) {
|
||||
$sublink = '-';
|
||||
} else {
|
||||
$sublink = "<a title=\"$subtitle\" href=\"subscribe.php?id=$forum->id\">$subscribed</a>";
|
||||
}
|
||||
}
|
||||
}
|
||||
$row = array ($forumlink, $forum->intro, $discussionlink);
|
||||
|
@ -11,6 +11,7 @@ define('FORUM_MODE_NESTED', 3);
|
||||
|
||||
define('FORUM_FORCESUBSCRIBE', 1);
|
||||
define('FORUM_INITIALSUBSCRIBE', 2);
|
||||
define('FORUM_DISALLOWSUBSCRIBE',3);
|
||||
|
||||
define('FORUM_TRACKING_OFF', 0);
|
||||
define('FORUM_TRACKING_OPTIONAL', 1);
|
||||
@ -24,7 +25,9 @@ $FORUM_LAYOUT_MODES = array ( FORUM_MODE_FLATOLDEST => get_string('modeflatoldes
|
||||
// These are course content forums that can be added to the course manually
|
||||
$FORUM_TYPES = array ('general' => get_string('generalforum', 'forum'),
|
||||
'eachuser' => get_string('eachuserforum', 'forum'),
|
||||
'single' => get_string('singleforum', 'forum') );
|
||||
'single' => get_string('singleforum', 'forum'),
|
||||
'qanda' => get_string('qandaforum', 'forum')
|
||||
);
|
||||
|
||||
$FORUM_OPEN_MODES = array ('2' => get_string('openmode2', 'forum'),
|
||||
'1' => get_string('openmode1', 'forum'),
|
||||
@ -328,6 +331,11 @@ function forum_cron () {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// make sure we're allowed to see it...
|
||||
if (!forum_user_can_see_post($forum,$discussion,$post,$userto)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($userto->maildigest > 0) {
|
||||
// This user wants the mails to be in digest form
|
||||
@ -1641,12 +1649,43 @@ 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="", $post_read=-99) {
|
||||
|
||||
global $USER, $CFG;
|
||||
global $USER, $CFG, $SESSION;
|
||||
|
||||
static $stredit, $strdelete, $strreply, $strparent, $strprune, $strpruneheading, $threadedmode, $isteacher, $adminedit;
|
||||
|
||||
static $strmarkread, $strmarkunread, $istracked;
|
||||
|
||||
if (!forum_user_can_see_post($post->forum,$post->discussion,$post)) {
|
||||
if (empty($SESSION->forum_search)) {
|
||||
// just viewing, return
|
||||
return;
|
||||
}
|
||||
echo '<a name="'.$post->id.'"></a>';
|
||||
echo '<table cellspacing="0" class="forumpost">';
|
||||
echo '<tr class="header"><td class="picture left">';
|
||||
// print_user_picture($post->userid, $courseid, $post->picture);
|
||||
echo '</td>';
|
||||
if ($post->parent) {
|
||||
echo '<td class="topic">';
|
||||
} else {
|
||||
echo '<td class="topic starter">';
|
||||
}
|
||||
echo '<div class="subject">'.get_string('forumsubjecthidden','forum').'</div>';
|
||||
echo '<div class="author">';
|
||||
print_string('forumauthorhidden','forum');
|
||||
echo '</div></td></tr>';
|
||||
|
||||
echo '<tr><td class="left side">';
|
||||
echo ' ';
|
||||
|
||||
/// Actual content
|
||||
|
||||
echo '</td><td class="content">'."\n";
|
||||
echo get_string('forumbodyhidden','forum');
|
||||
echo '</td></tr></table>';
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($stredit)) {
|
||||
$stredit = get_string('edit', 'forum');
|
||||
$strdelete = get_string('delete', 'forum');
|
||||
@ -1969,6 +2008,7 @@ function forum_print_discussion_header(&$post, $forum, $group=-1, $datestring=""
|
||||
echo '<td class="lastpost">';
|
||||
$usedate = (empty($post->timemodified)) ? $post->modified : $post->timemodified; // Just in case
|
||||
$parenturl = (empty($post->lastpostid)) ? '' : '&parent='.$post->lastpostid;
|
||||
$usermodified->id = $post->usermodified;
|
||||
$usermodified->firstname = $post->umfirstname;
|
||||
$usermodified->lastname = $post->umlastname;
|
||||
echo '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$post->usermodified.'&course='.$forum->course.'">'.
|
||||
@ -2616,12 +2656,18 @@ function forum_user_has_posted_discussion($forumid, $userid) {
|
||||
}
|
||||
}
|
||||
|
||||
function forum_user_has_posted($forumid,$did,$userid) {
|
||||
return record_exists('forum_posts','discussion',$did,'userid',$userid);
|
||||
}
|
||||
|
||||
function forum_user_can_post_discussion($forum, $currentgroup=false, $groupmode='') {
|
||||
// $forum is an object
|
||||
global $USER, $SESSION;
|
||||
|
||||
if ($forum->type == "eachuser") {
|
||||
return (! forum_user_has_posted_discussion($forum->id, $USER->id));
|
||||
} else if ($forum->type == 'qanda') {
|
||||
return isteacher($forum->course);
|
||||
} else if ($forum->type == "teacher") {
|
||||
return isteacher($forum->course);
|
||||
} else if ($currentgroup) {
|
||||
@ -2705,6 +2751,70 @@ function forum_user_can_view_post($post, $course, $user=NULL){
|
||||
}
|
||||
}
|
||||
|
||||
function forum_user_can_see_discussion($forum,$discussion,$user=NULL) {
|
||||
global $USER;
|
||||
|
||||
if (empty($user) || empty($user->id)) {
|
||||
$user = $USER;
|
||||
}
|
||||
|
||||
// retrive objects (yuk)
|
||||
if (is_numeric($forum)) {
|
||||
if (!$forum = get_record('forum','id',$forum)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (is_numeric($discussion)) {
|
||||
if (!$discussion = get_record('forum_discussions','id',$discussion)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($forum->type == 'qanda') {
|
||||
return (forum_user_has_posted($forum->id,$discussion->id,$user->id) || isteacher($forum->course));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function forum_user_can_see_post($forum,$discussion,$post,$user=NULL) {
|
||||
global $USER;
|
||||
|
||||
if (empty($user) || empty($user->id)) {
|
||||
$user = $USER;
|
||||
}
|
||||
|
||||
// retrive objects (yuk)
|
||||
if (is_numeric($forum)) {
|
||||
if (!$forum = get_record('forum','id',$forum)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (isteacher($forum->course)) {
|
||||
return true;
|
||||
}
|
||||
if (is_numeric($discussion)) {
|
||||
if (!$discussion = get_record('forum_discussions','id',$discussion)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (is_numeric($post)) {
|
||||
if (!$post = get_record('forum_posts','id',$post)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($post->id) && isset($post->parent)) {
|
||||
$post->id = $post->parent;
|
||||
}
|
||||
|
||||
if ($forum->type == 'qanda') {
|
||||
$firstpost = forum_get_firstpost_from_discussion($discussion->id);
|
||||
return (forum_user_has_posted($forum->id,$discussion->id,$user->id) || $firstpost->id == $post->id || isteacher($forum->course));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints the discussion view screen for a forum.
|
||||
*
|
||||
@ -2763,7 +2873,10 @@ function forum_print_latest_discussions($course, $forum, $maxdiscussions=5, $dis
|
||||
echo "<form name=\"newdiscussionform\" method=\"get\" action=\"$CFG->wwwroot/mod/forum/post.php\">";
|
||||
echo "<input type=\"hidden\" name=\"forum\" value=\"$forum->id\" />";
|
||||
echo '<input type="submit" value="';
|
||||
echo ($forum->type == 'news') ? get_string('addanewtopic', 'forum') : get_string('addanewdiscussion', 'forum');
|
||||
echo ($forum->type == 'news') ? get_string('addanewtopic', 'forum')
|
||||
: (($forum->type == 'qanda')
|
||||
? get_string('addanewquestion','forum')
|
||||
: get_string('addanewdiscussion', 'forum'));
|
||||
echo '" />';
|
||||
echo '</form>';
|
||||
echo "</div>\n";
|
||||
@ -2778,6 +2891,8 @@ function forum_print_latest_discussions($course, $forum, $maxdiscussions=5, $dis
|
||||
echo '<div class="forumnodiscuss">';
|
||||
if ($forum->type == 'news') {
|
||||
echo '('.get_string('nonews', 'forum').')';
|
||||
} else if ($forum->type == 'qanda') {
|
||||
echo '('.get_string('noquestions','forum').')';
|
||||
} else {
|
||||
echo '('.get_string('nodiscussions', 'forum').')';
|
||||
}
|
||||
@ -3077,6 +3192,9 @@ function forum_print_posts_threaded($parent, $courseid, $depth, $ratings, $reply
|
||||
$ratingsmenuused = true;
|
||||
}
|
||||
} else {
|
||||
if (!forum_user_can_see_post($post->forum,$post->discussion,$post)) {
|
||||
continue;
|
||||
}
|
||||
$by->name = fullname($post, isteacher($courseid));
|
||||
$by->date = userdate($post->modified);
|
||||
|
||||
|
@ -114,6 +114,7 @@
|
||||
$options[0] = get_string('no');
|
||||
$options[1] = get_string('yesforever', 'forum');
|
||||
$options[FORUM_INITIALSUBSCRIBE] = get_string('yesinitially', 'forum');
|
||||
$options[FORUM_DISALLOWSUBSCRIBE] = get_string('disallowsubscribe','forum');
|
||||
choose_from_menu($options, 'forcesubscribe', $form->forcesubscribe, '');
|
||||
helpbutton('subscription2', get_string('forcesubscribeq', 'forum'), 'forum');
|
||||
?>
|
||||
|
@ -59,7 +59,7 @@ if (!isset($discussion->timeend)) {
|
||||
<?php
|
||||
if (forum_is_forcesubscribed($forum->id)) {
|
||||
print_string("everyoneissubscribed", "forum");
|
||||
} else {
|
||||
} else if ($forum->forcesubscribe != FORUM_DISALLOWSUBSCRIBE || isteacher($forum->course)){
|
||||
unset($options);
|
||||
if (forum_is_subscribed($USER->id, $post->forum)) {
|
||||
$options[0] = get_string("subscribestart", "forum");
|
||||
@ -74,6 +74,8 @@ if (!isset($discussion->timeend)) {
|
||||
$options[1] = get_string("subscribestart", "forum");
|
||||
choose_from_menu($options, "subscribe", $default, "");
|
||||
}
|
||||
} else if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE) {
|
||||
print_string('disallowsubscribe','forum');
|
||||
}
|
||||
helpbutton("subscription", get_string("subscription", "forum"), "forum");
|
||||
?>
|
||||
|
@ -624,6 +624,18 @@
|
||||
|
||||
}
|
||||
|
||||
// checkup
|
||||
if (!empty($parent) && !forum_user_can_see_post($forum,$discussion,$post)) {
|
||||
error("You cannot reply to this post");
|
||||
}
|
||||
if (empty($parent) && !forum_user_can_post_discussion($forum)) {
|
||||
error("You cannot start a new discussion in this forum");
|
||||
}
|
||||
|
||||
if ($forum->type == 'qanda' && !isteacher($forum->course) && !forum_user_has_posted($forum->id,$discussion->id,$USER->id)) {
|
||||
notify(get_string('qandanotify','forum'));
|
||||
}
|
||||
|
||||
if (!empty($parent)) {
|
||||
forum_print_post($parent, $course->id, $ownpost=false, $reply=false, $link=false);
|
||||
if (empty($post->edit)) {
|
||||
@ -632,7 +644,9 @@
|
||||
} else {
|
||||
$user_read_array = array();
|
||||
}
|
||||
forum_print_posts_threaded($parent->id, $course->id, 0, false, false, $user_read_array, $discussion->forum);
|
||||
if ($forum->type != 'qanda' || forum_user_can_see_discussion($forum,$discussion)) {
|
||||
forum_print_posts_threaded($parent->id, $course->id, 0, false, false, $user_read_array, $discussion->forum);
|
||||
}
|
||||
}
|
||||
print_heading(get_string("yourreply", "forum").':');
|
||||
} else {
|
||||
@ -640,7 +654,11 @@
|
||||
if (!empty($forum->intro)) {
|
||||
print_simple_box(format_text($forum->intro), 'center');
|
||||
}
|
||||
print_heading(get_string('yournewtopic', 'forum'));
|
||||
if ($forum->type == 'qanda') {
|
||||
print_heading(get_string('yournewquestion','forum'));
|
||||
} else {
|
||||
print_heading(get_string('yournewtopic', 'forum'));
|
||||
}
|
||||
}
|
||||
echo '<center>';
|
||||
if (!empty($post->error)) {
|
||||
|
@ -225,7 +225,9 @@
|
||||
|
||||
$fulllink = "<a href=\"discuss.php?d=$post->discussion#$post->id\">".get_string("postincontext", "forum")."</a>";
|
||||
//search terms already highlighted - fiedorow - 9/2/2005
|
||||
$SESSION->forum_search = true;
|
||||
forum_print_post($post, $course->id, false, false, false, false, $fulllink);
|
||||
unset($SESSION->forum_search);
|
||||
|
||||
echo "<br />";
|
||||
}
|
||||
|
@ -97,6 +97,9 @@
|
||||
}
|
||||
|
||||
} else { // subscribe
|
||||
if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE && !isteacher($forum->course)) {
|
||||
error(get_string('disallowsubscribe'),$_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
if (forum_subscribe($user->id, $forum->id) ) {
|
||||
add_to_log($course->id, "forum", "subscribe", "view.php?f=$forum->id", $forum->id, $cm->id);
|
||||
redirect($returnto, get_string("nowsubscribed", "forum", $info), 1);
|
||||
|
@ -5,7 +5,7 @@
|
||||
// This fragment is called by /admin/index.php
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$module->version = 2005111100;
|
||||
$module->version = 2006011600;
|
||||
$module->requires = 2005031000; // Requires this Moodle version
|
||||
$module->cron = 60;
|
||||
|
||||
|
@ -152,6 +152,10 @@
|
||||
}
|
||||
echo '</span>';
|
||||
|
||||
} else if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE) {
|
||||
$strsubscriptionsoff = get_string('disallowsubscribe','forum');
|
||||
echo $strsubscriptionsoff;
|
||||
helpbutton("subscription", $strsubscriptionsoff, "forum");
|
||||
} else {
|
||||
$streveryonecanchoose = get_string("everyonecanchoose", "forum");
|
||||
$strforcesubscribe = get_string("forcesubscribe", "forum");
|
||||
@ -215,6 +219,10 @@
|
||||
|
||||
echo '</tr></table>';
|
||||
|
||||
if ($forum->type == 'qanda' && !isteacher($forum->course)) {
|
||||
notify(get_string('qandanotify','forum'));
|
||||
}
|
||||
|
||||
$forum->intro = trim($forum->intro);
|
||||
|
||||
switch ($forum->type) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user