From f26cef7c223e2ef3fdd01158c2bbc819e9ac3c56 Mon Sep 17 00:00:00 2001 From: michaelpenne Date: Wed, 15 Jun 2005 23:35:11 +0000 Subject: [PATCH] Minor changes to support the new media file feature. --- mod/lesson/backuplib.php | 1 + mod/lesson/db/mysql.php | 4 ++++ mod/lesson/db/mysql.sql | 1 + mod/lesson/db/postgres7.php | 4 ++++ mod/lesson/db/postgres7.sql | 1 + mod/lesson/mod.html | 15 +++++++++++++++ mod/lesson/restorelib.php | 1 + mod/lesson/version.php | 2 +- mod/lesson/view.php | 25 ++++++++++++++++++++++--- 9 files changed, 50 insertions(+), 4 deletions(-) diff --git a/mod/lesson/backuplib.php b/mod/lesson/backuplib.php index 317ad30f82c..5efe7620f3a 100644 --- a/mod/lesson/backuplib.php +++ b/mod/lesson/backuplib.php @@ -69,6 +69,7 @@ fwrite ($bf,full_tag("MAXTIME",4,false,$lesson->maxtime)); fwrite ($bf,full_tag("RETAKE",4,false,$lesson->retake)); fwrite ($bf,full_tag("TREE",4,false,$lesson->tree)); + fwrite ($bf,full_tag("MEDIAFILE",4,false,$lesson->mediafile)); fwrite ($bf,full_tag("SLIDESHOW",4,false,$lesson->slideshow)); fwrite ($bf,full_tag("WIDTH",4,false,$lesson->width)); fwrite ($bf,full_tag("HEIGHT",4,false,$lesson->height)); diff --git a/mod/lesson/db/mysql.php b/mod/lesson/db/mysql.php index adc25a43b53..dc24d3a4301 100644 --- a/mod/lesson/db/mysql.php +++ b/mod/lesson/db/mysql.php @@ -167,6 +167,10 @@ function lesson_upgrade($oldversion) { if ($oldversion < 2005060900) { table_column('lesson_grades', 'grade', 'grade', 'float', '', 'unsigned', '0', 'not null'); } + + if ($oldversion < 2005061500) { + table_column('lesson', '', 'mediafile', 'varchar', '255', '', '', 'not null', 'tree'); + } return true; } diff --git a/mod/lesson/db/mysql.sql b/mod/lesson/db/mysql.sql index bda22481425..c2013c67d44 100644 --- a/mod/lesson/db/mysql.sql +++ b/mod/lesson/db/mysql.sql @@ -26,6 +26,7 @@ CREATE TABLE `prefix_lesson` ( `maxtime` INT(10) UNSIGNED NOT NULL DEFAULT '0', `retake` int(3) unsigned NOT NULL default '1', `tree` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0', + `mediafile` varchar(255) NOT NULL default '', `slideshow` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0', `width` INT(10) UNSIGNED NOT NULL DEFAULT '640', `height` INT(10) UNSIGNED NOT NULL DEFAULT '480', diff --git a/mod/lesson/db/postgres7.php b/mod/lesson/db/postgres7.php index a3a17600542..c34a4aab42e 100644 --- a/mod/lesson/db/postgres7.php +++ b/mod/lesson/db/postgres7.php @@ -215,6 +215,10 @@ function lesson_upgrade($oldversion) { if ($oldversion < 2005060900) { table_column('lesson_grades', 'grade', 'grade', 'real', '', 'unsigned', '0', 'not null'); } + + if ($oldversion < 2005061500) { + table_column('lesson', '', 'mediafile', 'varchar', '255', '', '', 'not null', 'tree'); + } return true; } diff --git a/mod/lesson/db/postgres7.sql b/mod/lesson/db/postgres7.sql index e8c9bb86f6e..a7b7068e6f4 100644 --- a/mod/lesson/db/postgres7.sql +++ b/mod/lesson/db/postgres7.sql @@ -20,6 +20,7 @@ CREATE TABLE prefix_lesson ( maxtime INT8 NOT NULL DEFAULT '0', retake INT NOT NULL default '1', tree INT NOT NULL DEFAULT '0', + mediafile varchar(255) NOT NULL default '', slideshow INT NOT NULL DEFAULT '0', width INT8 NOT NULL DEFAULT '640', height INT8 NOT NULL DEFAULT '480', diff --git a/mod/lesson/mod.html b/mod/lesson/mod.html index 533dfef13d0..874710382c4 100644 --- a/mod/lesson/mod.html +++ b/mod/lesson/mod.html @@ -100,6 +100,9 @@ if ($form->mode == "add") { $form->modattempts = 0; } + if (!isset($form->mediafile)) { + $form->mediafile = ''; + } $form->deleteattempts = ""; @@ -437,6 +440,18 @@ if ($form->mode == "add") { + + : + + mediafile\" />
"; + button_to_popup_window ("/files/index.php?id=$course->id&choose=form.mediafile", "coursefiles", $strchooseafile, 500, 750, $strchooseafile); + helpbutton("mediafile", get_string("mediafile", "lesson"), "lesson"); + ?> + + + : diff --git a/mod/lesson/restorelib.php b/mod/lesson/restorelib.php index e407ecd4700..6298846df3a 100644 --- a/mod/lesson/restorelib.php +++ b/mod/lesson/restorelib.php @@ -72,6 +72,7 @@ $lesson->maxtime = backup_todb($info['MOD']['#']['MAXTIME']['0']['#']); $lesson->retake = backup_todb($info['MOD']['#']['RETAKE']['0']['#']); $lesson->tree = backup_todb($info['MOD']['#']['TREE']['0']['#']); + $lesson->mediafile = backup_todb($info['MOD']['#']['MEDIAFILE']['0']['#']); $lesson->slideshow = backup_todb($info['MOD']['#']['SLIDESHOW']['0']['#']); $lesson->width = backup_todb($info['MOD']['#']['WIDTH']['0']['#']); $lesson->height = backup_todb($info['MOD']['#']['HEIGHT']['0']['#']); diff --git a/mod/lesson/version.php b/mod/lesson/version.php index 46b1e85284d..2b1e738111d 100644 --- a/mod/lesson/version.php +++ b/mod/lesson/version.php @@ -5,7 +5,7 @@ /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2005060900; // The current module version (Date: YYYYMMDDXX) +$module->version = 2005061500; // The current module version (Date: YYYYMMDDXX) $module->requires = 2005021600; // Requires this Moodle version $module->cron = 0; // Period for cron to check this module (secs) diff --git a/mod/lesson/view.php b/mod/lesson/view.php index 65fdccd61f5..f5191a46d77 100644 --- a/mod/lesson/view.php +++ b/mod/lesson/view.php @@ -274,7 +274,7 @@ if (!$pageid = get_field('lesson_pages', 'id', 'lessonid', $lesson->id, 'prevpageid', 0)) { error('Navigation: first page not found'); } - /// CDC-FLAG /// -- This is the code for starting a timed test + /// This is the code for starting a timed test if(!isset($USER->startlesson[$lesson->id]) && !isteacher($course->id)) { $USER->startlesson[$lesson->id] = true; $startlesson = new stdClass; @@ -290,7 +290,18 @@ $timedflag = true; } } - /// CDC-FLAG /// + + if (!empty($lesson->mediafile)) { + // open our pop-up + $url = '/mod/lesson/mediafile.php?id='.$cm->id; + $name = $lesson->mediafile; + $options = 'menubar=0,location=0,left=5,top=5,scrollbars,resizable,width='. 650 .',height='. 100; + echo "\n'; + } } if ($pageid != LESSON_EOL) { @@ -387,7 +398,15 @@ // This is where several messages (usually warnings) are displayed // all of this is displayed above the actual page - + + if (!empty($lesson->mediafile)) { + $url = '/mod/lesson/mediafile.php?id='.$cm->id; + $options = 'menubar=0,location=0,left=5,top=5,scrollbars,resizable,width='. 650 .',height='. 100; + echo '
'; + link_to_popup_window ($url, $lesson->mediafile, get_string('mediafilepopup', 'lesson'), '', '', get_string('mediafilepopup', 'lesson'), $options); + helpbutton("mediafilestudent", get_string("mediafile", "lesson"), "lesson"); + echo '
'; + } // clock code // get time information for this user if(!isteacher($course->id)) {