Events associated to hidden activities are now invisible in calendar, using new field 'visible' in table 'event' which is updated each time a course module is hidden or unhidden.
This commit is contained in:
+1
-1
@@ -474,7 +474,7 @@ function calendar_sql_where($tstart, $tend, $users, $groups, $courses, $withdura
|
||||
// Just basic time filtering
|
||||
$whereclause = $timeclause;
|
||||
}
|
||||
return $whereclause;
|
||||
return $whereclause.' AND visible = 1';
|
||||
}
|
||||
|
||||
function calendar_top_controls($type, $data) {
|
||||
|
||||
+19
-1
@@ -754,7 +754,11 @@ function set_section_visible($courseid, $sectionnumber, $visibility) {
|
||||
if (!empty($section->sequence)) {
|
||||
$modules = explode(",", $section->sequence);
|
||||
foreach ($modules as $moduleid) {
|
||||
set_field("course_modules", "visible", "$visibility", "id", $moduleid);
|
||||
if ($visibility) {
|
||||
show_course_module($moduleid);
|
||||
} else {
|
||||
hide_course_module($moduleid);
|
||||
}
|
||||
}
|
||||
}
|
||||
rebuild_course_cache($courseid);
|
||||
@@ -1639,10 +1643,24 @@ function set_groupmode_for_module($id, $groupmode) {
|
||||
}
|
||||
|
||||
function hide_course_module($mod) {
|
||||
$cm = get_record('course_modules', 'id', $mod);
|
||||
$modulename = get_field('modules', 'name', 'id', $cm->module);
|
||||
if ($events = get_records_select('event', "instance = '$cm->instance' AND modulename = '$modulename'")) {
|
||||
foreach($events as $event) {
|
||||
hide_event($event);
|
||||
}
|
||||
}
|
||||
return set_field("course_modules", "visible", 0, "id", $mod);
|
||||
}
|
||||
|
||||
function show_course_module($mod) {
|
||||
$cm = get_record('course_modules', 'id', $mod);
|
||||
$modulename = get_field('modules', 'name', 'id', $cm->module);
|
||||
if ($events = get_records_select('event', "instance = '$cm->instance' AND modulename = '$modulename'")) {
|
||||
foreach($events as $event) {
|
||||
show_event($event);
|
||||
}
|
||||
}
|
||||
return set_field("course_modules", "visible", 1, "id", $mod);
|
||||
}
|
||||
|
||||
|
||||
+19
-6
@@ -258,15 +258,15 @@ function main_upgrade($oldversion=0) {
|
||||
// Commented out - see below where it's done properly
|
||||
}
|
||||
|
||||
if ($oldversion < 2003032500) {
|
||||
modify_database("", "CREATE TABLE `prefix_user_coursecreators` (
|
||||
if ($oldversion < 2003032500) {
|
||||
modify_database("", "CREATE TABLE `prefix_user_coursecreators` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`userid` int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `id` (`id`)
|
||||
) TYPE=MyISAM COMMENT='One record per course creator';");
|
||||
}
|
||||
if ($oldversion < 2003032602) {
|
||||
}
|
||||
if ($oldversion < 2003032602) {
|
||||
// Redoing it because of no prefix last time
|
||||
execute_sql(" ALTER TABLE `{$CFG->prefix}log_display` CHANGE `module` `module` VARCHAR( 20 ) NOT NULL ");
|
||||
// Add some indexes for speed
|
||||
@@ -274,11 +274,11 @@ function main_upgrade($oldversion=0) {
|
||||
execute_sql(" ALTER TABLE `{$CFG->prefix}log` ADD INDEX(userid) ");
|
||||
}
|
||||
|
||||
if ($oldversion < 2003041400) {
|
||||
if ($oldversion < 2003041400) {
|
||||
table_column("course_modules", "", "visible", "integer", "1", "unsigned", "1", "not null", "score");
|
||||
}
|
||||
|
||||
if ($oldversion < 2003042104) { // Try to update permissions of all files
|
||||
if ($oldversion < 2003042104) { // Try to update permissions of all files
|
||||
if ($files = get_directory_list($CFG->dataroot)) {
|
||||
echo "Attempting to update permissions for all files... ignore any errors.";
|
||||
foreach ($files as $file) {
|
||||
@@ -752,6 +752,19 @@ function main_upgrade($oldversion=0) {
|
||||
table_column("course", "hiddentopics", "hiddensections", "integer", "2", "unsigned", "0", "not null");
|
||||
}
|
||||
|
||||
if ($oldversion < 2004050400) { /// add a visible field for events
|
||||
table_column("event", "", "visible", "tinyint", "1", "", "1", "not null", "timeduration");
|
||||
if ($events = get_records('event')) {
|
||||
foreach($events as $event) {
|
||||
if ($moduleid = get_field('modules', 'id', 'name', $event->modulename)) {
|
||||
if (get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $event->instance) == 0) {
|
||||
set_field('event', 'visible', 0, 'id', $event->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
@@ -151,6 +151,7 @@ CREATE TABLE `prefix_event` (
|
||||
`eventtype` varchar(20) NOT NULL default '',
|
||||
`timestart` int(10) unsigned NOT NULL default '0',
|
||||
`timeduration` int(10) unsigned NOT NULL default '0',
|
||||
`visible` tinyint(4) NOT NULL default '1',
|
||||
`timemodified` int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `id` (`id`),
|
||||
|
||||
@@ -493,6 +493,19 @@ function main_upgrade($oldversion=0) {
|
||||
if ($oldversion < 2004043001) { /// Add hiddentopics field to control hidden topics behaviour
|
||||
table_column("course", "", "hiddensections", "integer", "2", "unsigned", "0", "not null", "visible");
|
||||
}
|
||||
|
||||
if ($oldversion < 2004050400) { /// add a visible field for events
|
||||
table_column("event", "", "visible", "tinyint", "1", "", "1", "not null", "timeduration");
|
||||
if ($events = get_records('event')) {
|
||||
foreach($events as $event) {
|
||||
if ($moduleid = get_field('modules', 'id', 'name', $event->modulename)) {
|
||||
if (get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $event->instance) == 0) {
|
||||
set_field('event', 'visible', 0, 'id', $event->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
|
||||
@@ -95,6 +95,7 @@ CREATE TABLE prefix_event (
|
||||
eventtype varchar(20) NOT NULL default '',
|
||||
timestart integer NOT NULL default '0',
|
||||
timeduration integer NOT NULL default '0',
|
||||
visible integer NOT NULL default '1',
|
||||
timemodified integer NOT NULL default '0'
|
||||
);
|
||||
|
||||
|
||||
+1
-57
@@ -1,57 +1 @@
|
||||
<?xml version="1.0"?>
|
||||
<schema>
|
||||
<table name="event">
|
||||
<field name="id" type="I" size="10">
|
||||
<KEY/>
|
||||
<AUTOINCREMENT/>
|
||||
</field>
|
||||
<field name="name" type="X">
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
<field name="description" type="C" size="255" default="">
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
<field name="courseid" type="I" size="10" default="0">
|
||||
<KEY/>
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
<field name="groupid" type="I" size="10" default="0">
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
<field name="userid" type="I" size="10" default="0">
|
||||
<KEY/>
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
<field name="modulename" type="C" size="20" default="">
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
<field name="instance" type="I" size="10" default="0">
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
<field name="eventtype" type="C" size="20" default="">
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
<field name="timestart" type="I" size="10" default="0">
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
<field name="timeduration" type="I" size="10" default="0">
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
<field name="timemodified" type="I" size="10" default="0">
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
</table>
|
||||
<sql>
|
||||
<descr>Insert 1 row for testing only...comment out later</descr>
|
||||
<query platform="postgres|postgres7">
|
||||
insert into event values (1,1,1,1,1,1,1,1,1,1,1,1)
|
||||
</query>
|
||||
<query platform="mysql">
|
||||
insert into event values (1,1,1,1,1,1,1,1,1,1,1,1)
|
||||
</query>
|
||||
<query platform="oci8po">
|
||||
insert into event values (1,1,1,1,1,1,1,1,1,1,1,1)
|
||||
</query>
|
||||
</sql>
|
||||
</schema>
|
||||
|
||||
<?xml version="1.0"?>
|
||||
+43
-7
@@ -1036,7 +1036,7 @@ function remove_course_contents($courseid, $showfeedback=true) {
|
||||
/**
|
||||
* Returns a boolean: is the user a member of the given group?
|
||||
*
|
||||
* @param type description
|
||||
* @param type description
|
||||
*/
|
||||
function ismember($groupid, $userid=0) {
|
||||
global $USER;
|
||||
@@ -1063,7 +1063,7 @@ function ismember($groupid, $userid=0) {
|
||||
/**
|
||||
* Returns the group ID of the current user in the given course
|
||||
*
|
||||
* @param type description
|
||||
* @param type description
|
||||
*/
|
||||
function mygroupid($courseid) {
|
||||
global $USER;
|
||||
@@ -1080,7 +1080,7 @@ function mygroupid($courseid) {
|
||||
* what the current default groupmode is:
|
||||
* NOGROUPS, SEPARATEGROUPS or VISIBLEGROUPS
|
||||
*
|
||||
* @param type description
|
||||
* @param type description
|
||||
*/
|
||||
function groupmode($course, $cm=null) {
|
||||
|
||||
@@ -1094,7 +1094,7 @@ function groupmode($course, $cm=null) {
|
||||
/**
|
||||
* Sets the current group in the session variable
|
||||
*
|
||||
* @param type description
|
||||
* @param type description
|
||||
*/
|
||||
function set_current_group($courseid, $groupid) {
|
||||
global $SESSION;
|
||||
@@ -1106,7 +1106,7 @@ function set_current_group($courseid, $groupid) {
|
||||
/**
|
||||
* Gets the current group for the current user as an id or an object
|
||||
*
|
||||
* @param type description
|
||||
* @param type description
|
||||
*/
|
||||
function get_current_group($courseid, $full=false) {
|
||||
global $SESSION, $USER;
|
||||
@@ -1133,7 +1133,7 @@ function get_current_group($courseid, $full=false) {
|
||||
* It will use a given "groupid" parameter and try to use
|
||||
* that to reset the current group for the user.
|
||||
*
|
||||
* @param type description
|
||||
* @param type description
|
||||
*/
|
||||
function get_and_set_current_group($course, $groupmode, $groupid=-1) {
|
||||
|
||||
@@ -1177,7 +1177,7 @@ function get_and_set_current_group($course, $groupmode, $groupid=-1) {
|
||||
* Otherwise returns the current group if there is one
|
||||
* Otherwise returns false if groups aren't relevant
|
||||
*
|
||||
* @param type description
|
||||
* @param type description
|
||||
*/
|
||||
function setup_and_print_groups($course, $groupmode, $urlroot) {
|
||||
|
||||
@@ -1999,6 +1999,42 @@ function delete_event($id) {
|
||||
}
|
||||
|
||||
|
||||
function hide_event($event) {
|
||||
/// call this function to hide an event in the calendar table
|
||||
/// the event will be identified by the id field of the $event object
|
||||
|
||||
global $CFG;
|
||||
|
||||
if (!empty($CFG->calendar)) { // call the update_event function of the selected calendar
|
||||
if (file_exists("$CFG->dirroot/calendar/$CFG->calendar/lib.php")) {
|
||||
include_once("$CFG->dirroot/calendar/$CFG->calendar/lib.php");
|
||||
$calendar_hide_event = $CFG->calendar.'_hide_event';
|
||||
if (function_exists($calendar_hide_event)) {
|
||||
$calendar_hide_event($event);
|
||||
}
|
||||
}
|
||||
}
|
||||
return set_field('event', 'visible', 0, 'id', $event->id);
|
||||
}
|
||||
|
||||
|
||||
function show_event($event) {
|
||||
/// call this function to unhide an event in the calendar table
|
||||
/// the event will be identified by the id field of the $event object
|
||||
|
||||
global $CFG;
|
||||
|
||||
if (!empty($CFG->calendar)) { // call the update_event function of the selected calendar
|
||||
if (file_exists("$CFG->dirroot/calendar/$CFG->calendar/lib.php")) {
|
||||
include_once("$CFG->dirroot/calendar/$CFG->calendar/lib.php");
|
||||
$calendar_show_event = $CFG->calendar.'_show_event';
|
||||
if (function_exists($calendar_show_event)) {
|
||||
$calendar_show_event($event);
|
||||
}
|
||||
}
|
||||
}
|
||||
return set_field('event', 'visible', 1, 'id', $event->id);
|
||||
}
|
||||
|
||||
|
||||
/// ENVIRONMENT CHECKING ////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -112,6 +112,7 @@ function assignment_refresh_events($courseid = 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$moduleid = get_field('modules', 'id', 'name', 'assignment');
|
||||
|
||||
foreach ($assignments as $assignment) {
|
||||
$event = NULL;
|
||||
@@ -130,9 +131,10 @@ function assignment_refresh_events($courseid = 0) {
|
||||
$event->instance = $assignment->id;
|
||||
$event->eventtype = 'due';
|
||||
$event->timeduration = 0;
|
||||
|
||||
$event->visible = get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $assignment->id);
|
||||
add_event($event);
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
+3
-1
@@ -235,6 +235,7 @@ function chat_refresh_events($courseid = 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$moduleid = get_field('modules', 'id', 'name', 'chat');
|
||||
|
||||
foreach ($chats as $chat) {
|
||||
$event = NULL;
|
||||
@@ -253,7 +254,8 @@ function chat_refresh_events($courseid = 0) {
|
||||
$event->instance = $chat->id;
|
||||
$event->eventtype = $chat->schedule;
|
||||
$event->timeduration = 0;
|
||||
|
||||
$event->visible = get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $chat->id);
|
||||
|
||||
add_event($event);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -305,7 +305,8 @@ function quiz_refresh_events($courseid = 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$moduleid = get_field('modules', 'id', 'name', 'quiz');
|
||||
|
||||
foreach ($quizzes as $quiz) {
|
||||
$event = NULL;
|
||||
$event->name = addslashes($quiz->name);
|
||||
@@ -326,6 +327,7 @@ function quiz_refresh_events($courseid = 0) {
|
||||
$event->modulename = 'quiz';
|
||||
$event->instance = $quiz->id;
|
||||
$event->eventtype = 'start';
|
||||
$event->visible = get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $quiz->id);
|
||||
|
||||
add_event($event);
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
// database to determine whether upgrades should
|
||||
// be performed (see lib/db/*.php)
|
||||
|
||||
$version = 2004050300; // The current version is a date (YYYYMMDDXX)
|
||||
$version = 2004050500; // The current version is a date (YYYYMMDDXX)
|
||||
|
||||
$release = "1.3 development"; // User-friendly version number
|
||||
|
||||
|
||||
Reference in New Issue
Block a user