} else {
$admindata[]="<A HREF=\"view.php?id=$course->id&edit=on\">Turn editing on</A>";
}
+ if ($teacherforum = get_course_teacher_forum($course->id)) {
+ $admindata[]="<A HREF=\"../mod/forum/view.php?f=$teacherforum->id\">Teacher Forum...</A>";
+ $adminicon[]="<IMG SRC=\"../mod/forum/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"Teacher Forum\">";
+ }
$admindata[]="<A HREF=\"edit.php?id=$course->id\">Course settings...</A>";
- $adminicon[]="<IMG SRC=\"../pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"Course\">";
+ $adminicon[]="<IMG SRC=\"../pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"Course settings\">";
$admindata[]="<A HREF=\"log.php?id=$course->id\">Logs...</A>";
$adminicon[]="<IMG SRC=\"../pix/i/log.gif\" HEIGHT=16 WIDTH=16 ALT=\"Log\">";
$admindata[]="<A HREF=\"../files/index.php?id=$course->id\">Files...</A>";
$admindata[]="<A HREF=\"view.php?id=$course->id&edit=on\">Turn editing on</A>";
}
+ if ($teacherforum = get_course_teacher_forum($course->id)) {
+ $admindata[]="<A HREF=\"../mod/forum/view.php?f=$teacherforum->id\">Teacher Forum...</A>";
+ $adminicon[]="<IMG SRC=\"../mod/forum/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"Teacher Forum\">";
+ }
$admindata[]="<A HREF=\"edit.php?id=$course->id\">Course settings...</A>";
$adminicon[]="<IMG SRC=\"../pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"Course\">";
$admindata[]="<A HREF=\"log.php?id=$course->id\">Logs...</A>";
CREATE TABLE forum (
id int(10) unsigned NOT NULL auto_increment,
course int(10) unsigned NOT NULL default '0',
- type enum('discussion','news','general','social','eachuser') NOT NULL default 'general',
+ type enum('discussion','news','general','social','eachuser','teacher') NOT NULL default 'general',
name varchar(255) NOT NULL default '',
intro tinytext NOT NULL,
open tinyint(1) unsigned NOT NULL default '0',
if ($forums = get_records("forum", "course", $id, "name ASC")) {
foreach ($forums as $forum) {
+ if ($forum->type == "teacher") {
+ if (!isteacher($course->id)) {
+ continue;
+ }
+ }
$count = count_records("discuss", "forum", "$forum->id");
if ($can_subscribe) {
if ($forum->type == "eachuser") {
return (! user_has_posted_discussion($forum->id, $USER->id));
+ } else if ($forum->type == "teacher") {
+ return isteacher($forum->course);
} else if (isteacher($forum->course)) {
return true;
} else {
}
}
+function get_course_teacher_forum($courseid) {
+ if ($forum = get_record_sql("SELECT * from forum WHERE course = '$courseid' AND type = 'teacher'")) {
+ return $forum;
+ } else {
+ // Doesn't exist, so create one now.
+ $forum->course = $courseid;
+ $forum->type = "teacher";
+ $forum->name = "Teacher Forum";
+ $forum->intro= "For teacher-only notes and discussion";
+ $forum->open = 0;
+ $forum->assessed = 0;
+ $forum->timemodified = time();
+ $forum->id = insert_record("forum", $forum);
+ return get_record_sql("SELECT * from forum WHERE id = '$forum->id'");
+ }
+}
+
function print_forum_latest_topics($forum_id=0, $forum_numtopics=5, $forum_style="plain", $forum_sort="DESC") {
global $CFG, $USER;
require_login();
}
+ if ($forum->type == "teacher") {
+ if (!isteacher($course->id)) {
+ error("You must be a $course->teacher to subscribe to this forum");
+ }
+ }
+
+
$returnto = go_back_to("index.php?id=$course->id");
if ( is_subscribed($USER->id, $forum->id) ) {
<A HREF=\"index.php?id=$course->id\">Forums</A> ->";
}
+ if ($forum->type == "teacher") {
+ if (!isteacher($course->id)) {
+ error("You must be a $course->teacher to view this forum");
+ }
+ }
+
+
add_to_log($course->id, "forum", "view forum", "view.php?f=$forum->id", "$forum->id");
print_header("$course->shortname: $forum->name", "$course->fullname",