]> git.mjollnir.org Git - moodle.git/commitdiff
Drift between CVS and git
authorFrancois Marier <francois@catalyst.net.nz>
Wed, 25 Jun 2008 17:31:23 +0000 (17:31 +0000)
committerFrancois Marier <francois@catalyst.net.nz>
Wed, 25 Jun 2008 17:31:23 +0000 (17:31 +0000)
- large deletions
- lucene updates
- error() => print_error()
- NO_MOODLE_COOKIES define
- various other things

384 files changed:
admin/auth.php
admin/cron.php
admin/enrol.php
admin/mnet/index.php
admin/module.php
auth/cas/cas_ldap_sync_users.php
auth/db/auth_db_sync_users.php
auth/ldap/auth.php
auth/ldap/auth_ldap_sync_users.php
auth/ldap/ntlmsso_magic.php
auth/shibboleth/index.php
auth/shibboleth/login.php
backup/db/mysql.php [deleted file]
backup/db/postgres7.php [deleted file]
blocks/activity_modules/db/mysql.php [deleted file]
blocks/activity_modules/db/postgres7.php [deleted file]
blocks/admin/db/mysql.php [deleted file]
blocks/admin/db/mysql.sql [deleted file]
blocks/admin/db/postgres7.php [deleted file]
blocks/admin/db/postgres7.sql [deleted file]
blocks/admin_bookmarks/create.php
blocks/admin_bookmarks/delete.php
blocks/calendar_month/db/mysql.php [deleted file]
blocks/calendar_month/db/postgres7.php [deleted file]
blocks/calendar_upcoming/db/mysql.php [deleted file]
blocks/calendar_upcoming/db/postgres7.php [deleted file]
blocks/course_list/db/mysql.php [deleted file]
blocks/course_list/db/postgres7.php [deleted file]
blocks/course_summary/db/mysql.php [deleted file]
blocks/course_summary/db/postgres7.php [deleted file]
blocks/db/mysql.php [deleted file]
blocks/db/postgres7.php [deleted file]
blocks/news_items/db/mysql.php [deleted file]
blocks/news_items/db/postgres7.php [deleted file]
blocks/online_users/db/mysql.php [deleted file]
blocks/online_users/db/postgres7.php [deleted file]
blocks/participants/db/mysql.php [deleted file]
blocks/participants/db/postgres7.php [deleted file]
blocks/recent_activity/db/mysql.php [deleted file]
blocks/recent_activity/db/postgres7.php [deleted file]
blocks/rss_client/db/mysql.php [deleted file]
blocks/rss_client/db/postgres7.php [deleted file]
blocks/search/block_search.php
blocks/search/db/install.xml
blocks/search_forums/db/mysql.php [deleted file]
blocks/search_forums/db/postgres7.php [deleted file]
blocks/section_links/db/mysql.php [deleted file]
blocks/section_links/db/postgres7.php [deleted file]
blocks/social_activities/db/mysql.php [deleted file]
blocks/social_activities/db/postgres7.php [deleted file]
course/format/topicscss/ajax.php [deleted file]
course/format/topicscss/format.php [deleted file]
course/format/weekscss/ajax.php [deleted file]
course/format/weekscss/format.php [deleted file]
doc/pix/cvstree.png [deleted file]
doc/pix/files.jpg [deleted file]
doc/pix/social.jpg [deleted file]
doc/pix/topics.jpg [deleted file]
doc/pix/weekly.jpg [deleted file]
enrol/authorize/authorizenetlib.php [deleted file]
enrol/authorize/const.php
enrol/authorize/db/mysql.php [deleted file]
enrol/authorize/db/postgres7.php [deleted file]
enrol/paypal/db/mysql.php [deleted file]
enrol/paypal/db/postgres7.php [deleted file]
filter/algebra/algebradebug.php
filter/algebra/pix.php
filter/tex/pix.php
filter/tex/texdebug.php
filter/tex/texed.php
grade/export/csv/db/access.php [deleted file]
grade/export/ods/dump.php
grade/export/txt/dump.php
grade/export/xls/dump.php
grade/export/xml/dump.php
grade/import/xml/fetch.php
index.php
install/lang/en_utf8/installer.php
lang/en_utf8/block_search.php
lib/adodb/adodb-time.zip [deleted file]
lib/adodb/adodb-xmlschema-0.0.1-snap20030511/docs/media/bg_left.png [deleted file]
lib/adodb/adodb-xmlschema.zip [deleted file]
lib/adodb/cute_icons_for_site/adodb.gif [deleted file]
lib/adodb/cute_icons_for_site/adodb.png [deleted file]
lib/adodb/cute_icons_for_site/adodb2.gif [deleted file]
lib/adodb/cute_icons_for_site/adodb2.png [deleted file]
lib/adodb/tests/tmssql.php [deleted file]
lib/componentlib.class.php
lib/cookieless.php [deleted file]
lib/db/mysql.php [deleted file]
lib/db/postgres7.php [deleted file]
lib/filelib.php
lib/form/modgroupmode.php [deleted file]
lib/form/selectallornone.php [deleted file]
lib/grade/lib_wrapper.php [deleted file]
lib/javascript-mod.php
lib/pear/System.php [deleted file]
lib/session-test.php
lib/setup.php
lib/simpletest/testdmllib.php [deleted file]
lib/timezones.txt [deleted file]
lib/yui/button/assets/background.png [deleted file]
lib/yui/button/assets/button.css [deleted file]
lib/yui/button/assets/menuarrow.gif [deleted file]
lib/yui/button/assets/splitarrow.gif [deleted file]
lib/yui/button/assets/splitarrow_active.gif [deleted file]
lib/yui/button/button-beta-debug.js [deleted file]
lib/yui/button/button-beta-min.js [deleted file]
lib/yui/button/button-beta.js [deleted file]
lib/yui/colorpicker/colorpicker-beta-debug.js [deleted file]
lib/yui/colorpicker/colorpicker-beta-min.js [deleted file]
lib/yui/colorpicker/colorpicker-beta.js [deleted file]
lib/yui/history/history-beta-debug.js [deleted file]
lib/yui/history/history-beta-min.js [deleted file]
lib/yui/history/history-beta.js [deleted file]
lib/yui/imageloader/imageloader-experimental-debug.js [deleted file]
lib/yui/imageloader/imageloader-experimental-min.js [deleted file]
lib/yui/imageloader/imageloader-experimental.js [deleted file]
lib/yui/menu/assets/map.gif [deleted file]
lib/yui/menu/assets/menuarodwn8_dim_1.gif [deleted file]
lib/yui/menu/assets/menuarodwn8_hov_1.gif [deleted file]
lib/yui/menu/assets/menuarodwn8_nrm_1.gif [deleted file]
lib/yui/menu/assets/menuarorght8_dim_1.gif [deleted file]
lib/yui/menu/assets/menuarorght8_hov_1.gif [deleted file]
lib/yui/menu/assets/menuarorght8_nrm_1.gif [deleted file]
lib/yui/menu/assets/menuchk8_dim_1.gif [deleted file]
lib/yui/menu/assets/menuchk8_hov_1.gif [deleted file]
lib/yui/menu/assets/menuchk8_nrm_1.gif [deleted file]
lib/yui/reset-fonts-grids/reset-fonts-grids-min.css [deleted file]
lib/yui/treeview/assets/lm.gif [deleted file]
lib/yui/treeview/assets/lmh.gif [deleted file]
lib/yui/treeview/assets/ln.gif [deleted file]
lib/yui/treeview/assets/loading.gif [deleted file]
lib/yui/treeview/assets/lp.gif [deleted file]
lib/yui/treeview/assets/lph.gif [deleted file]
lib/yui/treeview/assets/tm.gif [deleted file]
lib/yui/treeview/assets/tmh.gif [deleted file]
lib/yui/treeview/assets/tn.gif [deleted file]
lib/yui/treeview/assets/tp.gif [deleted file]
lib/yui/treeview/assets/tph.gif [deleted file]
lib/yui/treeview/assets/tree.css [deleted file]
lib/yui/treeview/assets/vline.gif [deleted file]
login/confirm.php
login/index.php
mnet/environment.php
mod/assignment/db/mysql.php [deleted file]
mod/assignment/db/postgres7.php [deleted file]
mod/assignment/type/online/db/mysql.php [deleted file]
mod/assignment/type/online/db/postgres7.php [deleted file]
mod/chat/chatd.php
mod/chat/db/mysql.php [deleted file]
mod/chat/db/postgres7.php [deleted file]
mod/chat/gui_header_js/jsupdated.php
mod/chat/gui_header_js/users.php
mod/chat/gui_sockets/chatinput.php
mod/choice/db/mysql.php [deleted file]
mod/choice/db/postgres7.php [deleted file]
mod/data/css.php
mod/data/db/mysql.php [deleted file]
mod/data/db/postgres7.php [deleted file]
mod/data/js.php
mod/exercise/assessments.php [deleted file]
mod/exercise/backuplib.php [deleted file]
mod/exercise/construction_icon.gif [deleted file]
mod/exercise/db/access.php [deleted file]
mod/exercise/db/install.xml [deleted file]
mod/exercise/db/mysql.php [deleted file]
mod/exercise/db/postgres7.php [deleted file]
mod/exercise/db/upgrade.php [deleted file]
mod/exercise/defaults.php [deleted file]
mod/exercise/icon.gif [deleted file]
mod/exercise/icon.png [deleted file]
mod/exercise/icon2.gif [deleted file]
mod/exercise/icon2.png [deleted file]
mod/exercise/index.php [deleted file]
mod/exercise/lib.php [deleted file]
mod/exercise/locallib.php [deleted file]
mod/exercise/mod_form.php [deleted file]
mod/exercise/restorelib.php [deleted file]
mod/exercise/submissions.php [deleted file]
mod/exercise/upload.php [deleted file]
mod/exercise/version.php [deleted file]
mod/exercise/view.php [deleted file]
mod/forum/db/mysql.php [deleted file]
mod/forum/db/postgres7.php [deleted file]
mod/glossary/db/mysql.php [deleted file]
mod/glossary/db/postgres7.php [deleted file]
mod/hotpot/db/mysql.php [deleted file]
mod/hotpot/db/postgres7.php [deleted file]
mod/hotpot/db/update_to_v2.php [deleted file]
mod/hotpot/mod.html [deleted file]
mod/journal/backuplib.php [deleted file]
mod/journal/db/install.xml [deleted file]
mod/journal/db/mysql.php [deleted file]
mod/journal/db/postgres7.php [deleted file]
mod/journal/db/upgrade.php [deleted file]
mod/journal/defaults.php [deleted file]
mod/journal/edit.html [deleted file]
mod/journal/edit.php [deleted file]
mod/journal/icon.gif [deleted file]
mod/journal/index.php [deleted file]
mod/journal/lib.php [deleted file]
mod/journal/mod_form.php [deleted file]
mod/journal/report.php [deleted file]
mod/journal/restorelib.php [deleted file]
mod/journal/version.php [deleted file]
mod/journal/view.php [deleted file]
mod/label/db/mysql.php [deleted file]
mod/label/db/postgres7.php [deleted file]
mod/lams/constants.php [deleted file]
mod/lams/db/access.php [deleted file]
mod/lams/db/install.xml [deleted file]
mod/lams/db/mysql.php [deleted file]
mod/lams/db/postgres7.php [deleted file]
mod/lams/db/upgrade.php [deleted file]
mod/lams/defaults.php [deleted file]
mod/lams/icon.gif [deleted file]
mod/lams/index.php [deleted file]
mod/lams/lib.php [deleted file]
mod/lams/list.php [deleted file]
mod/lams/mod.html [deleted file]
mod/lams/settings.php [deleted file]
mod/lams/userinfo.php [deleted file]
mod/lams/version.php [deleted file]
mod/lams/view.php [deleted file]
mod/lesson/db/mysql.php [deleted file]
mod/lesson/db/postgres7.php [deleted file]
mod/quiz/accessrules.php
mod/quiz/db/mysql.php [deleted file]
mod/quiz/db/postgres7.php [deleted file]
mod/quiz/jstimer.php [deleted file]
mod/quiz/protect_js.php [deleted file]
mod/resource/db/mysql.php [deleted file]
mod/resource/db/postgres7.php [deleted file]
mod/scorm/db/mysql.php [deleted file]
mod/scorm/db/postgres7.php [deleted file]
mod/survey/db/mysql.php [deleted file]
mod/survey/db/postgres7.php [deleted file]
mod/wiki/db/mysql.php [deleted file]
mod/wiki/db/postgres7.php [deleted file]
mod/workshop/assess.php [deleted file]
mod/workshop/assessment_grading_form.html [deleted file]
mod/workshop/assessments.php [deleted file]
mod/workshop/backuplib.php [deleted file]
mod/workshop/db/access.php [deleted file]
mod/workshop/db/install.xml [deleted file]
mod/workshop/db/mysql.php [deleted file]
mod/workshop/db/postgres7.php [deleted file]
mod/workshop/db/upgrade.php [deleted file]
mod/workshop/defaults.php [deleted file]
mod/workshop/icon.gif [deleted file]
mod/workshop/index.php [deleted file]
mod/workshop/lib.php [deleted file]
mod/workshop/locallib.php [deleted file]
mod/workshop/mod.html [deleted file]
mod/workshop/restorelib.php [deleted file]
mod/workshop/styles.php [deleted file]
mod/workshop/submissions.php [deleted file]
mod/workshop/upload.php [deleted file]
mod/workshop/version.php [deleted file]
mod/workshop/view.php [deleted file]
mod/workshop/viewassessment.php [deleted file]
pix/smartpix.php
question/type/calculated/db/mysql.php [deleted file]
question/type/calculated/db/postgres7.php [deleted file]
question/type/essay/db/mysql.php [deleted file]
question/type/essay/db/postgres7.php [deleted file]
question/type/match/db/mysql.php [deleted file]
question/type/match/db/postgres7.php [deleted file]
question/type/multianswer/db/mysql.php [deleted file]
question/type/multianswer/db/postgres7.php [deleted file]
question/type/multichoice/db/mysql.php [deleted file]
question/type/multichoice/db/postgres7.php [deleted file]
question/type/numerical/db/mysql.php [deleted file]
question/type/numerical/db/postgres7.php [deleted file]
question/type/randomsamatch/db/mysql.php [deleted file]
question/type/randomsamatch/db/postgres7.php [deleted file]
question/type/rqp/icon.gif [deleted file]
question/type/shortanswer/db/mysql.php [deleted file]
question/type/shortanswer/db/postgres7.php [deleted file]
question/type/truefalse/db/mysql.php [deleted file]
question/type/truefalse/db/postgres7.php [deleted file]
rss/file.php
search/LISEZMOI.txt
search/README.txt
search/READMETOO.txt [deleted file]
search/README_ARCHIVE.txt [new file with mode: 0644]
search/Zend/Search/Lucene/Analysis/Analyzer/Common.php
search/Zend/Search/Lucene/Analysis/Analyzer/Common/Text/CaseInsensitive.php
search/Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum.php
search/Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum/CaseInsensitive.php
search/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8/CaseInsensitive.php [new file with mode: 0644]
search/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num.php
search/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num/CaseInsensitive.php [new file with mode: 0644]
search/Zend/Search/Lucene/Analysis/Token.php
search/Zend/Search/Lucene/Analysis/TokenFilter.php
search/Zend/Search/Lucene/Analysis/TokenFilter/LowerCase.php
search/Zend/Search/Lucene/Analysis/TokenFilter/ShortWords.php
search/Zend/Search/Lucene/Analysis/TokenFilter/StopWords.php
search/Zend/Search/Lucene/Document/Html.php
search/Zend/Search/Lucene/EncodingConverter.php [deleted file]
search/Zend/Search/Lucene/FSM.php
search/Zend/Search/Lucene/FSMAction.php
search/Zend/Search/Lucene/Field.php
search/Zend/Search/Lucene/Index/DictionaryLoader.php
search/Zend/Search/Lucene/Index/FieldInfo.php
search/Zend/Search/Lucene/Index/SegmentInfo.php
search/Zend/Search/Lucene/Index/SegmentInfoPriorityQueue.php
search/Zend/Search/Lucene/Index/SegmentMerger.php
search/Zend/Search/Lucene/Index/SegmentWriter.php
search/Zend/Search/Lucene/Index/SegmentWriter/DocumentWriter.php
search/Zend/Search/Lucene/Index/SegmentWriter/StreamWriter.php
search/Zend/Search/Lucene/Index/Term.php
search/Zend/Search/Lucene/Index/TermInfo.php
search/Zend/Search/Lucene/Index/Writer.php
search/Zend/Search/Lucene/Interface.php
search/Zend/Search/Lucene/LockManager.php [new file with mode: 0644]
search/Zend/Search/Lucene/PriorityQueue.php
search/Zend/Search/Lucene/Proxy.php
search/Zend/Search/Lucene/Search/BooleanExpressionRecognizer.php
search/Zend/Search/Lucene/Search/Query.php
search/Zend/Search/Lucene/Search/Query/Boolean.php
search/Zend/Search/Lucene/Search/Query/Empty.php
search/Zend/Search/Lucene/Search/Query/Fuzzy.php [new file with mode: 0644]
search/Zend/Search/Lucene/Search/Query/Insignificant.php [new file with mode: 0644]
search/Zend/Search/Lucene/Search/Query/MultiTerm.php
search/Zend/Search/Lucene/Search/Query/Phrase.php
search/Zend/Search/Lucene/Search/Query/Range.php [new file with mode: 0644]
search/Zend/Search/Lucene/Search/Query/Wildcard.php [new file with mode: 0644]
search/Zend/Search/Lucene/Search/QueryEntry.php
search/Zend/Search/Lucene/Search/QueryEntry/Phrase.php
search/Zend/Search/Lucene/Search/QueryEntry/Subquery.php
search/Zend/Search/Lucene/Search/QueryEntry/Term.php
search/Zend/Search/Lucene/Search/QueryHit.php
search/Zend/Search/Lucene/Search/QueryLexer.php
search/Zend/Search/Lucene/Search/QueryParserContext.php
search/Zend/Search/Lucene/Search/QueryParserException.php
search/Zend/Search/Lucene/Search/QueryToken.php
search/Zend/Search/Lucene/Search/QueryTokenizer.php [deleted file]
search/Zend/Search/Lucene/Search/Similarity.php
search/Zend/Search/Lucene/Search/Similarity/Default.php
search/Zend/Search/Lucene/Search/Weight.php
search/Zend/Search/Lucene/Search/Weight/Boolean.php
search/Zend/Search/Lucene/Search/Weight/Empty.php
search/Zend/Search/Lucene/Search/Weight/MultiTerm.php
search/Zend/Search/Lucene/Search/Weight/Phrase.php
search/Zend/Search/Lucene/Search/Weight/Term.php
search/Zend/Search/Lucene/Storage/Directory.php
search/Zend/Search/Lucene/Storage/Directory/Filesystem.php
search/Zend/Search/Lucene/Storage/File.php
search/Zend/Search/Lucene/Storage/File/Filesystem.php
search/Zend/Search/Lucene/Storage/File/Memory.php
search/documents/physical_html.php
search/documents/techproject_document.php [deleted file]
search/lang/en_utf8/search.php [deleted file]
search/lang/fr_utf8/search.php [deleted file]
search/lang/nl_utf8/search.php [deleted file]
theme/chameleon/styles.php
theme/cornflower/docstyles.php
theme/cornflower/images/headerbg.jpg [deleted file]
theme/cornflower/images/logo2.jpg [deleted file]
theme/cornflower/styles.php
theme/custom_corners/js/jquery-latest.pack.js [deleted file]
theme/custom_corners/js/jquery.php [deleted file]
theme/custom_corners/styles.php
theme/formal_white/docstyles.php
theme/formal_white/styles.php
theme/metal/styles.php
theme/oceanblue/docstyles.php
theme/oceanblue/styles.php
theme/orangewhite/docstyles.php
theme/orangewhite/styles.php
theme/orangewhitepda/docstyles.php
theme/orangewhitepda/styles.php
theme/standard/docstyles.php
theme/standard/styles.php
theme/standardblue/styles.php
theme/standardgreen/styles.php
theme/standardlogo/styles.php
theme/standardred/styles.php
theme/standardwhite/styles.php
theme/wood/styles.php
user/pix.php
user/pixgroup.php

index 61afb67c19f4a82f1eff10dddd981627cd2838e6..41faab54ddc4362c59587fa40583389327e18ab3 100644 (file)
@@ -30,7 +30,7 @@ if (empty($CFG->auth)) {
 }
 
 if (!empty($auth) and !exists_auth_plugin($auth)) {
-    error(get_string('pluginnotinstalled', 'auth', $auth), $url);
+    print_error('pluginnotinstalled', 'auth', $url, $auth);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -67,7 +67,7 @@ switch ($action) {
         $key = array_search($auth, $authsenabled);
         // check auth plugin is valid
         if ($key === false) {
-            error(get_string('pluginnotenabled', 'auth', $auth), $url);
+            print_error('pluginnotenabled', 'auth', $url, $auth);
         }
         // move down the list
         if ($key < (count($authsenabled) - 1)) {
@@ -82,7 +82,7 @@ switch ($action) {
         $key = array_search($auth, $authsenabled);
         // check auth is valid
         if ($key === false) {
-            error(get_string('pluginnotenabled', 'auth', $auth), $url);
+            print_error('pluginnotenabled', 'auth', $url, $auth);
         }
         // move up the list
         if ($key >= 1) {
index f5f49bb664d418379c68b7e1f2f04fab2566b7af..3ace8d8f1833cabae8fe509534636ffad6dc99dc 100644 (file)
@@ -20,7 +20,7 @@
 
 
 /// Do not set moodle cookie because we do not need it here, it is better to emulate session
-    $nomoodlecookie = true;
+    define('NO_MOODLE_COOKIES', true);
 
 /// The current directory in PHP version 4.3.0 and above isn't necessarily the
 /// directory of the script when run from the command line. The require_once()
@@ -66,7 +66,6 @@
 
 
 /// emulate normal session
-    $SESSION = new object();
     $USER = get_admin();      /// Temporarily, to provide environment for this script
 
 /// ignore admins timezone, language and locale - use site deafult instead!
index 8e0cfdfd6bf42aa40695160403ea1a8e78e71793..14b75d6b10d09432857d55c10108c2e71560a0da 100644 (file)
@@ -18,7 +18,7 @@
 
     if ($frm = data_submitted()) {
         if (!confirm_sesskey()) {
-            error(get_string('confirmsesskeybad', 'error'));
+            print_error('confirmsesskeybad', 'error');
         }
         if (empty($frm->enable)) {
             $frm->enable = array();
 
     admin_externalpage_print_footer();
 
-?>
\ No newline at end of file
+?>
index a281f1cec0960f86d7548b6ea46d04782681567f..d03efaa566090b58d64f18a55ccc281ef71a38cb 100644 (file)
@@ -48,7 +48,7 @@
             }
         } elseif (!empty($form->submit) && $form->submit == get_string('delete')) {
             $MNET->get_private_key();
-            $_SESSION['mnet_confirm_delete_key'] = md5(sha1($MNET->keypair['keypair_PEM'])).':'.time();
+            $SESSION->mnet_confirm_delete_key = md5(sha1($MNET->keypair['keypair_PEM'])).':'.time();
             notice_yesno(get_string("deletekeycheck", "mnet"),
                                     "index.php?sesskey=$USER->sesskey&amp;confirm=".md5($MNET->public_key),
                                     "index.php",
             // We're deleting
             
             
-            if (!isset($_SESSION['mnet_confirm_delete_key'])) {
+            if (!isset($SESSION->mnet_confirm_delete_key)) {
                 // fail - you're being attacked?
             }
 
             $key = '';
             $time = '';
-            @list($key, $time) = explode(':',$_SESSION['mnet_confirm_delete_key']);
+            @list($key, $time) = explode(':',$SESSION->mnet_confirm_delete_key);
             $MNET->get_private_key();
 
             if($time < time() - 60) {
index 3b2c8cc99e9b6f762e58f71754043b17763224b5..e503b8292e0a5af675371a3c91672fe48953c445 100644 (file)
@@ -10,7 +10,7 @@
         $module = optional_param('module', '', PARAM_SAFEDIR);
 
         if (!confirm_sesskey()) {
-            error(get_string('confirmsesskeybad', 'error'));
+            print_error('confirmsesskeybad', 'error');
         }
 
         if ($module != '') {
index e1cc5acd4c20c53d84c03d8b9281bd95f814eb39..9abc5fc095866abdb2fec6b1666eebbe17ed7789 100644 (file)
@@ -27,7 +27,7 @@ if (isset($_SERVER['REMOTE_ADDR'])) {
     exit;
 }
 
-$nomoodlecookie = true; // cookie not needed
+define('NO_MOODLE_COOKIES', true);
 
 require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
 
index b4e22aa4b829e969db306f05d19922bedfbd8177..8ed5de05bc41720b5ae86ce3ea20961b76499fd8 100644 (file)
@@ -27,7 +27,7 @@ if (isset($_SERVER['REMOTE_ADDR'])) {
     exit;
 }
 
-$nomoodlecookie = true; // cookie not needed
+define('NO_MOODLE_COOKIES', true);
 
 require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
 
index 5ea3f315e8f69b14887a0eff27915ba99f7b5f82..8b8d1cf62baeb326a2aea7100072e5ba4a995b12 100644 (file)
@@ -1764,7 +1764,7 @@ class auth_plugin_ldap extends auth_plugin_base {
      *
      * NOTE that this code will execute under the OS user credentials, 
      * so we MUST avoid dealing with files -- such as session files.
-     * (The caller should set $nomoodlecookie before including config.php)
+     * (The caller should define('NO_MOODLE_COOKIES', true) before including config.php)
      *
      */
     function ntlmsso_magic($sesskey) {
index 8b764242c7562e58dd2365db3c9881cbce0e8326..528d3556d7534da15a1e92ad1fa4599d029f64b0 100755 (executable)
@@ -26,7 +26,7 @@ if (isset($_SERVER['REMOTE_ADDR'])) {
     exit;
 }
 
-$nomoodlecookie = true; // cookie not needed
+define('NO_MOODLE_COOKIES', true);
 
 require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
 
index 79077ef2b3f449da8ea3481c4b8b080c04886ea2..fc1120e05efcfc89b4383501bbe464405abe0a0a 100644 (file)
@@ -4,7 +4,7 @@
 // as we will be executing under the OS security
 // context of the user we are trying to login, rather than
 // of the webserver.
-$nomoodlecookie=true;
+define('NO_MOODLE_COOKIES', true);
 
 require_once(dirname(dirname(dirname(__FILE__)))."/config.php");
 
index 3cf39a78495c58e5fbd8b33b22aec6fdea9fd918..90ba89a7b941f6d473b18926934246ef52adcb8e 100644 (file)
@@ -43,7 +43,7 @@
             update_user_login_times();
             
             // Don't show username on login page
-            set_moodle_cookie('nobody');
+            $SESSION->set_moodle_cookie('nobody');
 
             set_login_session_preferences();
             
index ff6de2dbf563a43375cd964cac32fe9183bd3853..7f7c03212501e0e533e58ff963008d3f5139f469 100644 (file)
@@ -38,8 +38,8 @@ httpsrequired();
     $loginurl = (!empty($CFG->alternateloginurl)) ? $CFG->alternateloginurl : '';
 
 
-    if (get_moodle_cookie() == '') {   
-        set_moodle_cookie('nobody');   // To help search for cookies
+    if ($SESSION->get_moodle_cookie() == '') {   
+        $SESSION->set_moodle_cookie('nobody');   // To help search for cookies
     }
 
     if (!empty($CFG->registerauth) or is_enabled_auth('none') or !empty($CFG->auth_instructions)) {
diff --git a/backup/db/mysql.php b/backup/db/mysql.php
deleted file mode 100644 (file)
index af93afa..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-<?php  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to MySQL
-
-function backup_upgrade($oldversion=0) {
-
-    global $CFG;
-
-    $result = true;
-
-    if ($oldversion < 2003050300 and $result) {
-        $result = execute_sql("CREATE TABLE `{$CFG->prefix}backup_ids` (
-                        `backup_code` INT(12) UNSIGNED NOT NULL, 
-                        `table_name` VARCHAR(30) NOT NULL, 
-                        `old_id` INT(10) UNSIGNED NOT NULL, 
-                        `new_id` INT(10) UNSIGNED,
-                         PRIMARY KEY (`backup_code`, `table_name`, `old_id`)
-                     )
-                     COMMENT = 'To store and convert ids in backup/restore'");
-    }
-
-    if ($oldversion < 2003050301 and $result) {
-        $result = execute_sql("ALTER TABLE `{$CFG->prefix}backup_ids`
-                         ADD `info` VARCHAR(30)");
-    }
-
-    if ($oldversion < 2003050400 and $result) {
-        $result = execute_sql("ALTER TABLE `{$CFG->prefix}backup_ids`
-                         MODIFY `info` VARCHAR(255)");
-    } 
-
-    if ($oldversion < 2003050401 and $result) {
-        $result = execute_sql("CREATE  TABLE  `{$CFG->prefix}backup_files` (
-                                  `backup_code` INT( 10  ) UNSIGNED NOT  NULL ,
-                                  `file_type` VARCHAR( 10  )  NOT  NULL ,
-                                  `path` VARCHAR( 255  )  NOT  NULL ,
-                                  `old_id` INT( 10  ) UNSIGNED,
-                                  `new_id` INT( 10  ) UNSIGNED,
-                               PRIMARY  KEY (  `backup_code` ,  `file_type` ,  `path`  ) 
-                               ) COMMENT  =  'To store and recode ids to user & course files.'");
-    }
-
-    if ($oldversion < 2003052000 and $result) {
-        $result = execute_sql("ALTER TABLE `{$CFG->prefix}backup_ids`
-                         MODIFY `info` TEXT");
-    } 
-
-    if ($oldversion < 2003061100 and $result) {
-        $result = execute_sql("ALTER TABLE `{$CFG->prefix}backup_ids`
-                         MODIFY `info` MEDIUMTEXT");
-    } 
-
-    if ($oldversion < 2003082600 and $result) {
-        print_simple_box("This is the first non-alpha release of the Backup/Restore module.<p>Thanks for upgrading!","center", "50%", '', "20", "noticebox");
-    }
-
-    if ($oldversion < 2003112700 and $result) {
-        $result = execute_sql("CREATE TABLE `{$CFG->prefix}backup_config` (
-                      `id` int(10) unsigned NOT NULL auto_increment,
-                      `name` varchar(255) NOT NULL default '',
-                      `value` varchar(255) NOT NULL default '',
-                      PRIMARY KEY  (`id`),
-                      UNIQUE KEY `name` (`name`)
-                  ) TYPE=MyISAM COMMENT='To store backup configuration variables'");
-    }
-
-    if ($oldversion < 2003120800 and $result) {
-        $result = execute_sql("CREATE TABLE `{$CFG->prefix}backup_courses` (
-                      `id` int(10) unsigned NOT NULL auto_increment,
-                      `courseid` int(10) unsigned NOT NULL default '0',
-                      `laststarttime` int(10) unsigned NOT NULL default '0',
-                      `lastendtime` int(10) unsigned NOT NULL default '0',
-                      `laststatus` varchar(1) NOT NULL default '0',
-                      `nextstarttime` int(10) unsigned NOT NULL default '0',
-                      PRIMARY KEY  (`id`),
-                      UNIQUE KEY `courseid` (`courseid`)
-                  ) TYPE=MyISAM COMMENT='To store every course backup status'");
-
-        if ($result) {
-            $result = execute_sql("CREATE TABLE `{$CFG->prefix}backup_log` (    
-                          `id` int(10) unsigned NOT NULL auto_increment, 
-                          `courseid` int(10) unsigned NOT NULL default '0',
-                          `time` int(10) unsigned NOT NULL default '0',
-                          `laststarttime` int(10) unsigned NOT NULL default '0',
-                          `info` varchar(255) NOT NULL default '',
-                          PRIMARY KEY  (`id`)
-                      ) TYPE=MyISAM COMMENT='To store every course backup log info'");
-        }
-    }
-
-    if ($oldversion < 2006011600 and $result) {
-        $result = execute_sql("DROP TABLE {$CFG->prefix}backup_files");
-        if ($result) {
-            $result = execute_sql("CREATE TABLE `{$CFG->prefix}backup_files` (
-                          `id` int(10) unsigned NOT NULL auto_increment,
-                          `backup_code` int(10) unsigned NOT NULL default '0',
-                          `file_type` varchar(10) NOT NULL default '',
-                          `path` varchar(255) NOT NULL default '',
-                          `old_id` int(10) unsigned NOT NULL default '0',
-                          `new_id` int(10) unsigned NOT NULL default '0',
-                          PRIMARY KEY  (`id`),
-                          UNIQUE KEY `{$CFG->prefix}backup_files_uk` (`backup_code`,`file_type`,`path`)
-                      ) TYPE=MyISAM COMMENT='To store and recode ids to user and course files.'");
-        }
-        if ($result) {
-            $result = execute_sql("DROP TABLE {$CFG->prefix}backup_ids");
-        }
-        if ($result) {
-            $result = execute_sql("CREATE TABLE `{$CFG->prefix}backup_ids` (
-                          `id` int(10) unsigned NOT NULL auto_increment,
-                          `backup_code` int(12) unsigned NOT NULL default '0',
-                          `table_name` varchar(30) NOT NULL default '',
-                          `old_id` int(10) unsigned NOT NULL default '0',
-                          `new_id` int(10) unsigned NOT NULL default '0',
-                          `info` mediumtext,
-                          PRIMARY KEY  (`id`),
-                          UNIQUE KEY `{$CFG->prefix}backup_ids_uk` (`backup_code` ,`table_name`,`old_id`)
-                      ) TYPE=MyISAM COMMENT='To store and convert ids in backup/restore'");
-        }
-    }
-
-
-    // code to drop the prefix in tables
-    if ($oldversion < 2006042100) {
-        // see bug 5205, silent drops, so should not panic anyone
-        $result = execute_sql("ALTER TABLE {$CFG->prefix}backup_files DROP INDEX backup_files_uk", false);
-        $result = execute_sql("ALTER TABLE {$CFG->prefix}backup_files DROP INDEX {$CFG->prefix}backup_files_uk", false);
-        $result = execute_sql("ALTER TABLE {$CFG->prefix}backup_ids DROP INDEX backup_ids_uk", false);
-        $result = execute_sql("ALTER TABLE {$CFG->prefix}backup_ids DROP INDEX {$CFG->prefix}backup_ids_uk", false);
-        $result = execute_sql("ALTER TABLE {$CFG->prefix}backup_files ADD UNIQUE INDEX backup_files_uk(backup_code,file_type(10),path(255))");
-        $result = execute_sql("ALTER TABLE {$CFG->prefix}backup_ids ADD UNIQUE INDEX backup_ids_uk(backup_code,table_name(30),old_id)");
-    }
-
-    // chaing default nulls to not null default 0
-    
-    if ($oldversion < 2006042800) {
-
-        execute_sql("UPDATE {$CFG->prefix}backup_files SET old_id='0' WHERE old_id IS NULL");
-        table_column('backup_files','old_id','old_id','int','10','unsigned','0','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}backup_files SET new_id='0' WHERE new_id IS NULL");
-        table_column('backup_files','new_id','new_id','int','10','unsigned','0','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}backup_ids SET new_id='0' WHERE new_id IS NULL");
-        table_column('backup_ids','new_id','new_id','int','10','unsigned','0','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}backup_ids SET info='' WHERE info IS NULL");
-        table_column('backup_ids','info','info','mediumtext','','','','not null');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-
-}
-
-?>
diff --git a/backup/db/postgres7.php b/backup/db/postgres7.php
deleted file mode 100644 (file)
index 87fa622..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function backup_upgrade($oldversion=0) {
-
-    global $CFG;
-
-    $result = true;
-
-    if ($oldversion < 2006011600 and $result) {
-        $result = execute_sql("DROP TABLE {$CFG->prefix}backup_files");
-        if ($result) {
-            $result = execute_sql("CREATE TABLE {$CFG->prefix}backup_files (
-                          id SERIAL PRIMARY KEY,
-                          backup_code integer NOT NULL default '0',
-                          file_type varchar(10) NOT NULL default '',
-                          path varchar(255) NOT NULL default '',
-                          old_id integer default NULL,
-                          new_id integer default NULL,
-                          CONSTRAINT {$CFG->prefix}backup_files_uk UNIQUE (backup_code, file_type, path))");
-        }
-        if ($result) {
-            $result = execute_sql("DROP TABLE {$CFG->prefix}backup_ids");
-        }
-        if ($result) {
-            $result = execute_sql("CREATE TABLE {$CFG->prefix}backup_ids (
-                          id SERIAL PRIMARY KEY,
-                          backup_code integer NOT NULL default '0',
-                          table_name varchar(30) NOT NULL default '',
-                          old_id integer NOT NULL default '0',
-                          new_id integer default NULL,
-                          info text,
-                          CONSTRAINT {$CFG->prefix}backup_ids_uk UNIQUE (backup_code, table_name, old_id))");
-        }
-    }
-
-    if ($oldversion < 2006042801) {
-        table_column('backup_log', 'time', 'time', 'integer', '', '', '0');
-        table_column('backup_log', 'laststarttime', 'laststarttime', 'integer', '', '', '0');
-        table_column('backup_log', 'courseid', 'courseid', 'integer', '', '', '0');
-
-        table_column('backup_courses', 'lastendtime', 'lastendtime', 'integer', '', '', '0');
-        table_column('backup_courses', 'laststarttime', 'laststarttime', 'integer', '', '', '0');
-        table_column('backup_courses', 'courseid', 'courseid', 'integer', '', '', '0');
-        table_column('backup_courses', 'nextstarttime', 'nextstarttime', 'integer', '', '', '0');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-
-}
-
-?>
diff --git a/blocks/activity_modules/db/mysql.php b/blocks/activity_modules/db/mysql.php
deleted file mode 100644 (file)
index 1549db4..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?PHP  //$Id$
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to MySQL
-
-function activity_modules_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/activity_modules/db/postgres7.php b/blocks/activity_modules/db/postgres7.php
deleted file mode 100644 (file)
index 228bade..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to PostgreSQL
-
-function activity_modules_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/admin/db/mysql.php b/blocks/admin/db/mysql.php
deleted file mode 100644 (file)
index 845fbc9..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to MySQL
-
-function admin_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/admin/db/mysql.sql b/blocks/admin/db/mysql.sql
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/blocks/admin/db/postgres7.php b/blocks/admin/db/postgres7.php
deleted file mode 100644 (file)
index bf288a2..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to PostgreSQL
-
-function admin_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/admin/db/postgres7.sql b/blocks/admin/db/postgres7.sql
deleted file mode 100644 (file)
index e69de29..0000000
index a0e1969f2cf1c60458fc66af31a7b47aa9502b95..746c5cf37c4042472d23866360e35243e800aad0 100644 (file)
@@ -12,7 +12,7 @@ if ($section = optional_param('section', '', PARAM_SAFEDIR) and confirm_sesskey(
         $bookmarks = explode(',', get_user_preferences('admin_bookmarks'));
 
         if (in_array($section, $bookmarks)) {
-            error(get_string('bookmarkalreadyexists','admin'));
+            print_error('bookmarkalreadyexists','admin');
             die;
         }
 
@@ -28,7 +28,7 @@ if ($section = optional_param('section', '', PARAM_SAFEDIR) and confirm_sesskey(
         set_user_preference('admin_bookmarks', $bookmarks);
 
     } else {
-        error(get_string('invalidsection','admin'));
+        print_error('invalidsection','admin');
         die;
     }
 
@@ -40,7 +40,7 @@ if ($section = optional_param('section', '', PARAM_SAFEDIR) and confirm_sesskey(
     }
 
 } else {
-    error(get_string('invalidsection','admin'));
+    print_error('invalidsection','admin');
     die;
 }
 
index 1ad4f1519e334001927c362db02a01811f3bf5ff..cc06f0600d0ce96cec23f65839b4c94cafffdc18 100644 (file)
@@ -16,7 +16,7 @@ if ($section = optional_param('section', '', PARAM_SAFEDIR) and confirm_sesskey(
         $key = array_search($section, $bookmarks);
 
         if ($key === false) {
-            error(get_string('nonexistentbookmark','admin'));
+            print_error('nonexistentbookmark','admin');
             die;
         }
 
@@ -38,12 +38,12 @@ if ($section = optional_param('section', '', PARAM_SAFEDIR) and confirm_sesskey(
 
     }
 
-    error(get_string('nobookmarksforuser','admin'));
+    print_error('nobookmarksforuser','admin');
     die;
 
 } else {
-    error(get_string('invalidsection', 'admin'));
+    print_error('invalidsection', 'admin');
     die;
 }
 
-?>
\ No newline at end of file
+?>
diff --git a/blocks/calendar_month/db/mysql.php b/blocks/calendar_month/db/mysql.php
deleted file mode 100644 (file)
index 4e529be..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to MySQL
-
-function calendar_month_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/calendar_month/db/postgres7.php b/blocks/calendar_month/db/postgres7.php
deleted file mode 100644 (file)
index 9ba1754..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to PostgreSQL
-
-function calendar_month_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/calendar_upcoming/db/mysql.php b/blocks/calendar_upcoming/db/mysql.php
deleted file mode 100644 (file)
index 5ccd912..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to MySQL
-
-function calendar_upcoming_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/calendar_upcoming/db/postgres7.php b/blocks/calendar_upcoming/db/postgres7.php
deleted file mode 100644 (file)
index b5cbdee..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to PostgreSQL
-
-function calendar_upcoming_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/course_list/db/mysql.php b/blocks/course_list/db/mysql.php
deleted file mode 100644 (file)
index 1d006bb..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to MySQL
-
-function course_list_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/course_list/db/postgres7.php b/blocks/course_list/db/postgres7.php
deleted file mode 100644 (file)
index a58d050..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to PostgreSQL
-
-function course_list_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/course_summary/db/mysql.php b/blocks/course_summary/db/mysql.php
deleted file mode 100644 (file)
index 4dccae1..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to MySQL
-
-function course_summary_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/course_summary/db/postgres7.php b/blocks/course_summary/db/postgres7.php
deleted file mode 100644 (file)
index 972d417..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to PostgreSQL
-
-function course_summary_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/db/mysql.php b/blocks/db/mysql.php
deleted file mode 100644 (file)
index 2c58e40..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to MySQL
-
-function blocks_upgrade($oldversion=0) {
-
-global $CFG;
-    
-    $result = true;
-    
-    if ($oldversion < 2004041000 && $result) {
-        $result = execute_sql("CREATE TABLE `{$CFG->prefix}blocks` (
-                        `id` int(10) unsigned NOT NULL auto_increment,
-                        `name` varchar(40) NOT NULL default '',
-                        `version` int(10) NOT NULL default '0',
-                        `cron` int(10) unsigned NOT NULL default '0',
-                        `lastcron` int(10) unsigned NOT NULL default '0',
-                        `visible` tinyint(1) NOT NULL default '1',
-                        PRIMARY KEY (`id`)
-                     ) 
-                     COMMENT = 'To register and update all the available blocks'");
-    }
-
-    if ($oldversion < 2004101900 && $result) {
-        $result = execute_sql("CREATE TABLE `{$CFG->prefix}block` (
-                        `id` int(10) unsigned NOT NULL auto_increment,
-                        `name` varchar(40) NOT NULL default '',
-                        `version` int(10) NOT NULL default '0',
-                        `cron` int(10) unsigned NOT NULL default '0',
-                        `lastcron` int(10) unsigned NOT NULL default '0',
-                        `visible` tinyint(1) NOT NULL default '1',
-                        `multiple` tinyint(1) NOT NULL default '0',
-                        PRIMARY KEY (`id`)
-                     ) 
-                     COMMENT = 'To register and update all the available blocks'");
-
-        if(!$result) {
-            return false;
-        }
-
-        $records = get_records('blocks');
-        if(!empty($records)) {
-            foreach($records as $block) {
-                $block->multiple = 0;
-                insert_record('block', $block, false);
-            }
-        }
-
-        execute_sql("DROP TABLE `{$CFG->prefix}blocks`");
-
-        $result = execute_sql("CREATE TABLE `{$CFG->prefix}block_instance` (
-                        `id` int(10) not null auto_increment,
-                        `blockid` int(10) not null default '0',
-                        `pageid` int(10) not null default '0',
-                        `pagetype` varchar(12) not null default '',
-                        `position` enum('l', 'r') not null default 'l',
-                        `weight` tinyint(3) not null default '0',
-                        `visible` tinyint(1) not null default '0',
-                        `configdata` text not null default '',
-                        
-                        PRIMARY KEY(`id`),
-                        INDEX pageid(`pageid`)
-                    )");
-
-        if(!$result) {
-            return false;
-        }
-
-        $records = get_records('course', '','','', 'id, shortname, blockinfo');
-        if(!empty($records)) {
-            foreach($records as $thiscourse) {
-                // The @ suppresses a notice emitted if there is no : in the string
-                @list($left, $right) = split(':', $thiscourse->blockinfo);
-                if(!empty($left)) {
-                    $arr = explode(',', $left);
-                    foreach($arr as $weight => $blk) {
-                        $instance = new stdClass;
-                        $instance->blockid    = abs($blk);
-                        $instance->pageid     = $thiscourse->id;
-                        $instance->pagetype   = PAGE_COURSE_VIEW;
-                        $instance->position   = BLOCK_POS_LEFT;
-                        $instance->weight     = $weight;
-                        $instance->visible    = ($blk > 0) ? 1 : 0;
-                        $instance->configdata = '';
-                        insert_record('block_instance', $instance, false);
-                    }
-                }
-                if(!empty($right)) {
-                    $arr = explode(',', $right);
-                    foreach($arr as $weight => $blk) {
-                        $instance = new stdClass;
-                        $instance->blockid    = abs($blk);
-                        $instance->pageid     = $thiscourse->id;
-                        $instance->pagetype   = PAGE_COURSE_VIEW;
-                        $instance->position   = BLOCK_POS_RIGHT;
-                        $instance->weight     = $weight;
-                        $instance->visible    = ($blk > 0) ? 1 : 0;
-                        $instance->configdata = '';
-                        insert_record('block_instance', $instance, false);
-                    }
-                }
-            }
-        }
-
-        execute_sql("ALTER TABLE `{$CFG->prefix}course` DROP COLUMN blockinfo");
-    }
-
-    if ($oldversion < 2004112900 && $result) {
-        $result = $result && table_column('block_instance', 'pagetype', 'pagetype', 'varchar', '20', '');
-        $result = $result && table_column('block_instance', 'position', 'position', 'varchar', '10', '');
-    }
-
-    if ($oldversion < 2004112900 && $result) {
-        execute_sql('UPDATE '.$CFG->prefix.'block_instance SET pagetype = \''.PAGE_COURSE_VIEW.'\' WHERE pagetype = \'\'');
-    }
-
-    if ($oldversion < 2005043000 && $result) {
-        $records = get_records('block');
-        if(!empty($records)) {
-            foreach($records as $block) {
-                if(!block_is_compatible($block->name)) {
-                    $block->visible = 0;
-                    update_record('block', $block);
-                    notify('The '.$block->name.' block has been disabled because it is not compatible with Moodle 1.5 and needs to be updated by a programmer.');
-                }
-            }
-        }
-    }
-
-    if ($oldversion < 2005081600) {
-         $result = $result && modify_database('',"CREATE TABLE `prefix_block_pinned` (
-           `id` int(10) not null auto_increment,
-           `blockid` int(10) not null default '0',
-           `pagetype` varchar(20) not null default '',
-           `position` varchar(10) not null default '',
-           `weight` tinyint(3) not null default '0',
-           `visible` tinyint(1) not null default '0',
-           `configdata` text not null default '',
-           PRIMARY KEY(`id`)
-          ) TYPE=MyISAM;");
-    }
-    
-    if ($oldversion < 2005090200) {
-        execute_sql("ALTER TABLE {$CFG->prefix}block_instance ADD INDEX pagetype (pagetype);",false);  // do it silently, in case it's already there from 1.5
-        modify_database('','ALTER TABLE prefix_block_pinned ADD INDEX pagetype (pagetype);');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
-?>
diff --git a/blocks/db/postgres7.php b/blocks/db/postgres7.php
deleted file mode 100644 (file)
index 6122508..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to PostgreSQL
-
-function blocks_upgrade($oldversion=0) {
-
-global $CFG;
-    
-    $result = true;
-    
-    if ($oldversion < 2004041000 and $result) {
-        $result = execute_sql("
-                                CREATE TABLE {$CFG->prefix}blocks 
-                                (
-                                  id SERIAL8 PRIMARY KEY,
-                                  name varchar(40) NOT NULL default '',
-                                  version INT8 NOT NULL default '0',
-                                  cron INT8  NOT NULL default '0',
-                                  lastcron INT8  NOT NULL default '0',
-                                  visible int NOT NULL default '1'
-                                )
-        ") ;
-
-    }
-
-    if ($oldversion < 2004101900 && $result) {
-        $result = execute_sql("CREATE TABLE {$CFG->prefix}block (
-                        id SERIAL8 PRIMARY KEY,
-                        name varchar(40) NOT NULL default '',
-                        version INT8 NOT NULL default '0',
-                        cron INT8 NOT NULL default '0',
-                        lastcron INT8 NOT NULL default '0',
-                        visible int NOT NULL default '1',
-                        multiple int NOT NULL default '0'
-                     ) 
-                     ");
-
-        if(!$result) {
-            return false;
-        }
-
-        $records = get_records('blocks');
-        if(!empty($records)) {
-            foreach($records as $block) {
-                $block->multiple = 0;
-                insert_record('block', $block, false);
-            }
-            execute_sql("SELECT setval('{$CFG->prefix}block_id_seq', (SELECT MAX(id) FROM {$CFG->prefix}block), true)");
-        }
-
-        execute_sql("DROP TABLE {$CFG->prefix}blocks");
-        
-        $result = execute_sql("CREATE TABLE {$CFG->prefix}block_instance (
-                        id SERIAL8 PRIMARY KEY,
-                        blockid INT8 not null default '0',
-                        pageid INT8 not null default '0',
-                        pagetype varchar(12) not null default '',
-                        position char not null default 'l' check (position in ('l', 'r')) ,
-                        weight int not null default '0',
-                        visible int not null default '0',
-                        configdata text not null default ''
-                    )");
-
-        if(!$result) {
-            return false;
-        }
-        
-        $records = get_records('course', '','','', 'id, shortname, blockinfo');
-        if(!empty($records)) {
-            foreach($records as $thiscourse) {
-                // The @ suppresses a notice emitted if there is no : in the string
-                @list($left, $right) = split(':', $thiscourse->blockinfo);
-                if(!empty($left)) {
-                    $arr = explode(',', $left);
-                    foreach($arr as $weight => $blk) {
-                        $instance = new stdClass;
-                        $instance->blockid    = abs($blk);
-                        $instance->pageid     = $thiscourse->id;
-                        $instance->pagetype   = PAGE_COURSE_VIEW;
-                        $instance->position   = BLOCK_POS_LEFT;
-                        $instance->weight     = $weight;
-                        $instance->visible    = ($blk > 0) ? 1 : 0;
-                        $instance->configdata = '';
-                        insert_record('block_instance', $instance, false);
-                    }
-                }
-                if(!empty($right)) {
-                    $arr = explode(',', $right);
-                    foreach($arr as $weight => $blk) {
-                        $instance = new stdClass;
-                        $instance->blockid    = abs($blk);
-                        $instance->pageid     = $thiscourse->id;
-                        $instance->pagetype   = PAGE_COURSE_VIEW;
-                        $instance->position   = BLOCK_POS_RIGHT;
-                        $instance->weight     = $weight;
-                        $instance->visible    = ($blk > 0) ? 1 : 0;
-                        $instance->configdata = '';
-                        insert_record('block_instance', $instance, false);
-                    }
-                }
-            }
-        }
-
-        execute_sql("ALTER TABLE {$CFG->prefix}course DROP COLUMN blockinfo");
-    }
-
-    if ($oldversion < 2004112900 && $result) {
-        $result = $result && table_column('block_instance', 'pagetype', 'pagetype', 'varchar', '20', '');
-        $result = $result && table_column('block_instance', 'position', 'position', 'varchar', '10', '');
-    }
-
-    if ($oldversion < 2005043000 && $result) {
-        $records = get_records('block');
-        if(!empty($records)) {
-            foreach($records as $block) {
-                if(!block_is_compatible($block->name)) {
-                    $block->visible = 0;
-                    update_record('block', $block);
-                    notify('The '.$block->name.' block has been disabled because it is not compatible with Moodle 1.5 and needs to be updated by a programmer.');
-                }
-            }
-        }
-    }
-
-    if ($oldversion < 2005022401 && $result) { // Mass cleanup of bad upgrade scripts
-        execute_sql("CREATE INDEX {$CFG->prefix}block_instance_pageid_idx ON {$CFG->prefix}block_instance (pageid)",false); // this one should be quiet...
-        modify_database('','ALTER TABLE prefix_block_instance ALTER pagetype SET DEFAULT \'\'');
-        modify_database('','ALTER TABLE prefix_block_instance ALTER position SET DEFAULT \'\'');
-        modify_database('','ALTER TABLE prefix_block_instance ALTER pagetype SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_block_instance ALTER position SET NOT NULL');
-    }
-
-    if ($oldversion < 2005081600) {
-        modify_database('',"CREATE TABLE prefix_block_pinned ( 
-            id SERIAL8 PRIMARY KEY,
-            blockid INT8 NOT NULL default 0,
-            pagetype varchar(20) NOT NULL default '',
-            position varchar(10) NOT NULL default '',
-            weight INT NOT NULL default 0,
-            visible INT NOT NULL default 0,
-            configdata text NOT NULL default 0
-          );");
-     }
-
-    if ($oldversion < 2005090200) {
-        execute_sql("CREATE INDEX {$CFG->prefix}block_instance_pagetype_idx ON {$CFG->prefix}block_instance (pagetype);",false); // do it silently, in case it's already there from 1.5
-        modify_database('','CREATE INDEX prefix_block_pinned_pagetype_idx ON prefix_block_pinned (pagetype);');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
-?>
diff --git a/blocks/news_items/db/mysql.php b/blocks/news_items/db/mysql.php
deleted file mode 100644 (file)
index 2728665..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to MySQL
-
-function news_items_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/news_items/db/postgres7.php b/blocks/news_items/db/postgres7.php
deleted file mode 100644 (file)
index 650dc38..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to PostgreSQL
-
-function news_items_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/online_users/db/mysql.php b/blocks/online_users/db/mysql.php
deleted file mode 100644 (file)
index 4f05306..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to MySQL
-
-function online_users_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/online_users/db/postgres7.php b/blocks/online_users/db/postgres7.php
deleted file mode 100644 (file)
index 06b5209..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to PostgreSQL
-
-function online_users_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/participants/db/mysql.php b/blocks/participants/db/mysql.php
deleted file mode 100644 (file)
index 996ae7c..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to MySQL
-
-function participants_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/participants/db/postgres7.php b/blocks/participants/db/postgres7.php
deleted file mode 100644 (file)
index 7e297c7..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to PostgreSQL
-
-function participants_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/recent_activity/db/mysql.php b/blocks/recent_activity/db/mysql.php
deleted file mode 100644 (file)
index 4581389..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to MySQL
-
-function recent_activity_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/recent_activity/db/postgres7.php b/blocks/recent_activity/db/postgres7.php
deleted file mode 100644 (file)
index 23073ca..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to PostgreSQL
-
-function recent_activity_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/rss_client/db/mysql.php b/blocks/rss_client/db/mysql.php
deleted file mode 100644 (file)
index d708a30..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-<?php //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function rss_client_upgrade($oldversion) {
-/// This function does anything necessary to upgrade 
-/// older versions to match current functionality 
-
-    global $CFG;
-
-    if ($oldversion < 2003111500) {
-       # Do something ...
-    }
-
-    if ($oldversion < 2005111400) {
-        // title and description should be TEXT as we don't have control over their length.
-        table_column('block_rss_client','title','title','text',10,'unsigned','');
-        table_column('block_rss_client','description','description','text',10,'unsigned','');
-    }
-
-
-    if ($oldversion < 2006091100) {
-
-        // We need a new field to store whether an RSS feed is shared or private.
-        table_column('block_rss_client', '', 'shared', 'integer');
-
-        // Admin feeds used to be displayed to everybody (shared feeds).
-        $admins = get_admins();
-        if (!empty($admins)) {
-            $count = 0;
-            foreach($admins as $admin) {
-                if (!$count) {
-                    $adminsql = 'userid = '.$admin->id;
-                } else {
-                    $adminsql .= ' OR userid = '.$admin->id;
-                }
-                $count++;
-            }
-            if ($rssfeeds = get_records_select('block_rss_client', $adminsql)) {
-                foreach ($rssfeeds as $rssfeed) {
-                    if (!set_field('block_rss_client', 'shared', 1)) {
-                        notice('Could not set '.$rssfeed->title.' as a shared RSS feed.');
-                    }
-                }
-            }
-        }
-    }
-
-/// see MDL-6707 for more info about problem that was here
-
-    if ($oldversion < 2006100101) {
-
-        // Upgrade block to use the Roles System.
-        $block = get_record('block', 'name', 'rss_client');
-        
-        if ($blockinstances = get_records('block_instance', 'blockid', $block->id)) {
-            
-            if (!$adminroles = get_roles_with_capability('moodle/legacy:admin', CAP_ALLOW)) {
-                notice('Default student role was not found. Roles and permissions '.
-                       'for all your Remote RSS Feed blocks will have to be '.
-                       'manually set after this upgrade.');
-            }
-            if (!$teacherroles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW)) {
-                notice('Default teacher role was not found. Roles and permissions '.
-                       'for all your Remote RSS Feed blocks will have to be '.
-                       'manually set after this upgrade.');
-            }
-            if (!$studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) {
-                notice('Default student role was not found. Roles and permissions '.
-                       'for all your Remote RSS Feed blocks will have to be '.
-                       'manually set after this upgrade.');
-            }
-            
-            foreach ($blockinstances as $bi) {
-                $context = get_context_instance(CONTEXT_BLOCK, $bi->id);
-                
-                if ($bi->pagetype == 'course-view' && $bi->pageid == SITEID) {
-                    
-                    // Only the admin was allowed to manage the RSS feed block
-                    // on the site home page.
-                    
-                    // Since this is already the default behavior set in
-                    // blocks/rss_client/db/access.php, we don't need to
-                    // specifically assign the capabilities here.
-                    
-                } else {
-                    
-                    // Who can add shared feeds? This was defined in lib/rsslib.php
-                    // for config var block_rss_client_submitters.
-                    switch ($CFG->block_rss_client_submitters) {
-                        
-                        case 0:
-                            // SUBMITTERS_ALL_ACCOUNT_HOLDERS
-                            
-                            foreach ($adminroles as $adminrole) {
-                                assign_capability('block/rss_client:createsharedfeeds', CAP_ALLOW, $adminrole->id, $context->id);
-                            }
-                            foreach ($teacherroles as $teacherrole) {
-                                assign_capability('block/rss_client:createsharedfeeds', CAP_ALLOW, $teacherrole->id, $context->id);
-                            }
-                            foreach ($studentroles as $studentrole) {
-                                assign_capability('block/rss_client:createsharedfeeds', CAP_ALLOW, $studentrole->id, $context->id);
-                            }
-                            break;
-                        
-                        case 1:
-                            // SUBMITTERS_ADMIN_ONLY
-                            
-                            // Since this is already the default behavior set in
-                            // blocks/rss_client/db/access.php, we don't need to
-                            // specifically assign the capabilities here.
-                            break;
-                        
-                        case 2:
-                            // SUBMITTERS_ADMIN_AND_TEACHER
-                            
-                            foreach ($adminroles as $adminrole) {
-                                assign_capability('block/rss_client:createsharedfeeds', CAP_ALLOW, $adminrole->id, $context->id);
-                            }
-                            foreach ($teacherroles as $teacherrole) {
-                                assign_capability('block/rss_client:createsharedfeeds', CAP_ALLOW, $teacherrole->id, $context->id);
-                            }
-                            foreach ($studentroles as $studentrole) {
-                                assign_capability('block/rss_client:createsharedfeeds', CAP_PREVENT, $studentrole->id, $context->id);
-                            }
-                            break;
-
-                    } // End switch.
-                    
-                }
-            }   
-        }
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/blocks/rss_client/db/postgres7.php b/blocks/rss_client/db/postgres7.php
deleted file mode 100644 (file)
index 4204ed8..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-<?php //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function rss_client_upgrade($oldversion) {
-/// This function does anything necessary to upgrade 
-/// older versions to match current functionality 
-
-    global $CFG;
-
-    if ($oldversion < 2005111400) {
-        // title and description should be TEXT as we don't have control over their length.
-        table_column('block_rss_client','title','title','text');
-        table_column('block_rss_client','description','description','text');
-    }
-
-    if ($oldversion < 2005090201) {
-        modify_database('', 'ALTER TABLE prefix_block_rss_client
-            ALTER COLUMN title SET DEFAULT \'\',
-            ALTER COLUMN description SET DEFAULT \'\'');
-    }
-
-
-    if ($oldversion < 2006091100) {
-
-        // We need a new field to store whether an RSS feed is shared or private.
-        table_column('block_rss_client', '', 'shared', 'integer');
-
-        // Admin feeds used to be displayed to everybody (shared feeds).
-        $admins = get_admins();
-        if (!empty($admins)) {
-            $count = 0;
-            foreach($admins as $admin) {
-                if (!$count) {
-                    $adminsql = 'userid = '.$admin->id;
-                } else {
-                    $adminsql .= ' OR userid = '.$admin->id;
-                }
-                $count++;
-            }
-            if ($rssfeeds = get_records_select('block_rss_client', $adminsql)) {
-                foreach ($rssfeeds as $rssfeed) {
-                    if (!set_field('block_rss_client', 'shared', 1)) {
-                        notice('Could not set '.$rssfeed->title.' as a shared RSS feed.');
-                    }
-                }
-            }
-        }
-    }
-
-/// see MDL-6707 for more info about problem that was here
-
-    if ($oldversion < 2006100101) {
-        
-        // Upgrade block to use the Roles System.
-        $block = get_record('block', 'name', 'rss_client');
-        
-        if ($blockinstances = get_records('block_instance', 'blockid', $block->id)) {
-            
-            if (!$adminroles = get_roles_with_capability('moodle/legacy:admin', CAP_ALLOW)) {
-                notice('Default student role was not found. Roles and permissions '.
-                       'for all your Remote RSS Feed blocks will have to be '.
-                       'manually set after this upgrade.');
-            }
-            if (!$teacherroles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW)) {
-                notice('Default teacher role was not found. Roles and permissions '.
-                       'for all your Remote RSS Feed blocks will have to be '.
-                       'manually set after this upgrade.');
-            }
-            if (!$studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) {
-                notice('Default student role was not found. Roles and permissions '.
-                       'for all your Remote RSS Feed blocks will have to be '.
-                       'manually set after this upgrade.');
-            }
-            
-            foreach ($blockinstances as $bi) {
-                $context = get_context_instance(CONTEXT_BLOCK, $bi->id);
-                
-                if ($bi->pagetype == 'course-view' && $bi->pageid == SITEID) {
-                    
-                    // Only the admin was allowed to manage the RSS feed block
-                    // on the site home page.
-                    
-                    // Since this is already the default behavior set in
-                    // blocks/rss_client/db/access.php, we don't need to
-                    // specifically assign the capabilities here.
-                    
-                } else {
-                    
-                    // Who can add shared feeds? This was defined in lib/rsslib.php
-                    // for config var block_rss_client_submitters.
-                    switch ($CFG->block_rss_client_submitters) {
-                        
-                        case 0:
-                            // SUBMITTERS_ALL_ACCOUNT_HOLDERS
-                            
-                            foreach ($adminroles as $adminrole) {
-                                assign_capability('block/rss_client:createsharedfeeds', CAP_ALLOW, $adminrole->id, $context->id);
-                            }
-                            foreach ($teacherroles as $teacherrole) {
-                                assign_capability('block/rss_client:createsharedfeeds', CAP_ALLOW, $teacherrole->id, $context->id);
-                            }
-                            foreach ($studentroles as $studentrole) {
-                                assign_capability('block/rss_client:createsharedfeeds', CAP_ALLOW, $studentrole->id, $context->id);
-                            }
-                            break;
-                        
-                        case 1:
-                            // SUBMITTERS_ADMIN_ONLY
-                            
-                            // Since this is already the default behavior set in
-                            // blocks/rss_client/db/access.php, we don't need to
-                            // specifically assign the capabilities here.
-                            break;
-                        
-                        case 2:
-                            // SUBMITTERS_ADMIN_AND_TEACHER
-                            
-                            foreach ($adminroles as $adminrole) {
-                                assign_capability('block/rss_client:createsharedfeeds', CAP_ALLOW, $adminrole->id, $context->id);
-                            }
-                            foreach ($teacherroles as $teacherrole) {
-                                assign_capability('block/rss_client:createsharedfeeds', CAP_ALLOW, $teacherrole->id, $context->id);
-                            }
-                            foreach ($studentroles as $studentrole) {
-                                assign_capability('block/rss_client:createsharedfeeds', CAP_PREVENT, $studentrole->id, $context->id);
-                            }
-                            break;
-
-                    } // End switch.
-                    
-                }
-            }   
-        }
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
index e021f9924353c9373e7fe84d0f30c9add1fcda46..65fabe23c9f54b047f896e1019680526b98b1e34 100644 (file)
@@ -81,4 +81,4 @@
       
   } //block_search
 
-?>
\ No newline at end of file
+?>
index 234e77e1479863f48c74984fcb694fc382fd8a11..b118e4e1b2cedc7041917fda948b4f48ced0d86a 100644 (file)
@@ -12,8 +12,8 @@
         <FIELD NAME="itemtype" TYPE="char" LENGTH="32" NOTNULL="true" DEFAULT="standard" SEQUENCE="false" ENUM="false" PREVIOUS="doctype" NEXT="title"/>
         <FIELD NAME="title" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="itemtype" NEXT="url"/>
         <FIELD NAME="url" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="title" NEXT="docdate"/>
-        <FIELD NAME="docdate" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="url" NEXT="updated"/>
-        <FIELD NAME="updated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="docdate" NEXT="courseid"/>
+        <FIELD NAME="docdate" TYPE="datetime" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="url" NEXT="updated"/>
+        <FIELD NAME="updated" TYPE="datetime" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="docdate" NEXT="courseid"/>
         <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="updated" NEXT="groupid"/>
         <FIELD NAME="groupid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="courseid"/>
       </FIELDS>
diff --git a/blocks/search_forums/db/mysql.php b/blocks/search_forums/db/mysql.php
deleted file mode 100644 (file)
index 5161f4f..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to MySQL
-
-function search_forums_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/search_forums/db/postgres7.php b/blocks/search_forums/db/postgres7.php
deleted file mode 100644 (file)
index d213fbd..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to PostgreSQL
-
-function search_forums_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/section_links/db/mysql.php b/blocks/section_links/db/mysql.php
deleted file mode 100644 (file)
index d714536..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to MySQL
-
-function section_links_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004050500 and $result) {
-        $result = true; //Nothing to do
-    }
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/section_links/db/postgres7.php b/blocks/section_links/db/postgres7.php
deleted file mode 100644 (file)
index 2466998..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to PostgreSQL
-
-function section_links_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004050500 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/social_activities/db/mysql.php b/blocks/social_activities/db/mysql.php
deleted file mode 100644 (file)
index aaca971..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to MySQL
-
-function social_activities_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/social_activities/db/postgres7.php b/blocks/social_activities/db/postgres7.php
deleted file mode 100644 (file)
index 54aca77..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to PostgreSQL
-
-function social_activities_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2004041000 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/course/format/topicscss/ajax.php b/course/format/topicscss/ajax.php
deleted file mode 100644 (file)
index 2280edd..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-/**
- * This file is required if the course format is to support AJAX.
- */
-
-
-$CFG->ajaxcapable = true;
-$CFG->ajaxtestedbrowsers = array('MSIE' => 6.0, 'Gecko' => 20061111);
-
-?>
diff --git a/course/format/topicscss/format.php b/course/format/topicscss/format.php
deleted file mode 100644 (file)
index b4a62b7..0000000
+++ /dev/null
@@ -1,301 +0,0 @@
-<?php // $Id$
-      // Display the whole course as "topics" made of of modules
-      // Included from "view.php"
-/**
- * Evaluation topics format for course display - NO layout tables, for accessibility, etc.
- * 
- * A duplicate course format to enable the Moodle development team to evaluate 
- * CSS for the multi-column layout in place of layout tables. 
- * Less risk for the Moodle 1.6 beta release.
- *   1. Straight copy of topics/format.php
- *   2. Replace <table> and <td> with DIVs; inline styles.
- *   3. Reorder columns so that in linear view content is first then blocks;
- * styles to maintain original graphical (side by side) view.
- *
- * Target: 3-column graphical view using relative widths for pixel screen sizes 
- * 800x600, 1024x768... on IE6, Firefox. Below 800 columns will shift downwards.
- * 
- * http://www.maxdesign.com.au/presentation/em/ Ideal length for content.
- * http://www.svendtofte.com/code/max_width_in_ie/ Max width in IE.
- *
- * @copyright &copy; 2006 The Open University
- * @author N.D.Freear@open.ac.uk, and others.
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package  
- */
-//TODO (nfreear): Accessibility: evaluation, lang/en_utf8/moodle.php: $string['formattopicscss']
-
-    require_once($CFG->libdir.'/ajax/ajaxlib.php');
-
-    if (!empty($THEME->customcorners)) {
-        require_once($CFG->dirroot.'/lib/custom_corners_lib.php');
-    }
-
-    $topic = optional_param('topic', -1, PARAM_INT);
-
-    if ($topic != -1) {
-        $displaysection = course_set_display($course->id, $topic);
-    } else {
-        if (isset($USER->display[$course->id])) {
-            $displaysection = $USER->display[$course->id];
-        } else {
-            $displaysection = course_set_display($course->id, 0);
-        }
-    }
-
-    $context = get_context_instance(CONTEXT_COURSE, $course->id);
-
-    if (($marker >=0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) {
-       $course->marker = $marker;
-       if (! set_field("course", "marker", $marker, "id", $course->id)) {
-           error("Could not mark that topic for this course");
-       }
-    }
-
-    $streditsummary  = get_string('editsummary');
-    $stradd          = get_string('add');
-    $stractivities   = get_string('activities');
-    $strshowalltopics = get_string('showalltopics');
-    $strtopic         = get_string('topic');
-    $strgroups       = get_string('groups');
-    $strgroupmy      = get_string('groupmy');
-    $editing         = $PAGE->user_is_editing();
-
-    if ($editing) {
-        $strstudents = moodle_strtolower($course->students);
-        $strtopichide = get_string('topichide', '', $strstudents);
-        $strtopicshow = get_string('topicshow', '', $strstudents);
-       $strmarkthistopic = get_string('markthistopic');
-       $strmarkedthistopic = get_string('markedthistopic');
-        $strmoveup   = get_string('moveup');
-        $strmovedown = get_string('movedown');
-    }
-
-/* Internet Explorer min-width fix. (See theme/standard/styles_layout.css: min-width for Firefox.)
-   Window width: 800px, Firefox 763px, IE 752px. (Window width: 640px, Firefox 602px, IE 588px.)    
-*/
-?>
-
-<!--[if IE]>
-  <style type="text/css">
-  .topicscss-format { width: expression(document.body.clientWidth < 800 ? "752px" : "auto"); }
-  </style>
-<![endif]-->
-<?php
-/// Layout the whole page as three big columns (was, id="layout-table")
-    echo '<div class="topicscss-format">';
-
-/// The left column ...
-
-    if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
-        echo '<div id="left-column">';
-        blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
-        echo '</div>';
-    }
-    
-/// The right column, BEFORE the middle-column.
-    if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing) {
-        echo '<div id="right-column">';
-        blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
-        echo '</div>';
-    }
-
-/// Start main column
-    echo '<div id="middle-column">';
-
-    if (!empty($THEME->customcorners)) print_custom_corners_start();
-
-    echo skip_main_destination();
-
-    print_heading_block(get_string('topicoutline'), 'outline');
-
-    // Note, an ordered list would confuse - "1" could be the clipboard or summary.
-    echo "<ul class='topicscss'>\n";
-
-/// If currently moving a file then show the current clipboard
-    if (ismoving($course->id)) {
-        $stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname)));
-        $strcancel= get_string('cancel');
-        echo '<li class="clipboard">';
-        echo $stractivityclipboard.'&nbsp;&nbsp;(<a href="mod.php?cancelcopy=true&amp;sesskey='.$USER->sesskey.'">'.$strcancel.'</a>)';
-        echo "</li>\n";
-    }
-
-/// Print Section 0 with general activities
-
-    $section = 0;
-    $thissection = $sections[$section];
-
-    if ($thissection->summary or $thissection->sequence or isediting($course->id)) {
-
-        // Note, no need for a 'left side' cell or DIV.
-        // Note, 'right side' is BEFORE content.
-        echo '<li id="section-0" class="section main" >';
-       echo '<div class="left side">&nbsp;</div>';
-        echo '<div class="right side" >&nbsp;</div>';        
-        echo '<div class="content">';
-        echo '<div class="summary">';
-        $summaryformatoptions->noclean = true;
-        echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
-
-        if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
-            echo '<a title="'.$streditsummary.'" '.
-                 ' href="editsection.php?id='.$thissection->id.'"><img src="'.$CFG->pixpath.'/t/edit.gif" '.
-                 ' class="icon edit" alt="'.$streditsummary.'" /></a>';
-        }
-        echo '</div>';
-        
-        print_section($course, $thissection, $mods, $modnamesused);
-
-        if (isediting($course->id)) {
-            print_section_add_menus($course, $section, $modnames);
-        }
-
-        echo '</div>';
-        echo "</li>\n";
-    }
-
-
-/// Now all the normal modules by topic
-/// Everything below uses "section" terminology - each "section" is a topic.
-
-    $timenow = time();
-    $section = 1;
-    $sectionmenu = array();
-
-    while ($section <= $course->numsections) {
-
-        if (!empty($sections[$section])) {
-            $thissection = $sections[$section];
-
-        } else {
-            unset($thissection);
-            $thissection->course = $course->id;   // Create a new section structure
-            $thissection->section = $section;
-            $thissection->summary = '';
-            $thissection->visible = 1;
-            if (!$thissection->id = insert_record('course_sections', $thissection)) {
-                notify('Error inserting new topic!');
-            }
-        }
-
-        $showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible or !$course->hiddensections);
-
-        if (!empty($displaysection) and $displaysection != $section) {  // Check this topic is visible
-            if ($showsection) {
-               $strsummary = strip_tags(format_string($thissection->summary,true));
-               if (strlen($strsummary) < 57) {
-                   $strsummary = ' - '.$strsummary;
-               } else {
-                   $strsummary = ' - '.substr($strsummary, 0, 60).'...';
-               }
-                $sectionmenu['topic='.$section] = s($section.$strsummary);
-            }
-            $section++;
-            continue;
-        }
-
-        if ($showsection) {
-
-            $currenttopic = ($course->marker == $section);
-
-            $currenttext = '';
-            if (!$thissection->visible) {
-                $sectionstyle = ' hidden';
-            } else if ($currenttopic) {
-                $sectionstyle = ' current';
-                $currenttext = get_accesshide(get_string('currenttopic','access'));
-            } else {
-                $sectionstyle = '';
-            }
-
-            echo '<li id="section-'.$section.'" class="section main'.$sectionstyle.'" >'; //'<div class="left side">&nbsp;</div>';
-
-               echo '<div class="left side">'.$currenttext.$section.'</div>';
-            // Note, 'right side' is BEFORE content.
-            echo '<div class="right side">';
-            
-            if ($displaysection == $section) { // Show the zoom boxes
-                echo '<a href="view.php?id='.$course->id.'&amp;topic=0#section-'.$section.'" title="'.$strshowalltopics.'">'.
-                     '<img src="'.$CFG->pixpath.'/i/all.gif" class="icon" alt="'.$strshowalltopics.'" /></a><br />';
-            } else {
-                $strshowonlytopic = get_string("showonlytopic", "", $section);
-                echo '<a href="view.php?id='.$course->id.'&amp;topic='.$section.'" title="'.$strshowonlytopic.'">'.
-                     '<img src="'.$CFG->pixpath.'/i/one.gif" class="icon" alt="'.$strshowonlytopic.'" /></a><br />';
-            }
-
-            if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
-
-               if ($course->marker == $section) {  // Show the "light globe" on/off
-                           echo '<a href="view.php?id='.$course->id.'&amp;marker=0&amp;sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strmarkedthistopic.'">'.'<img src="'.$CFG->pixpath.'/i/marked.gif" alt="'.$strmarkedthistopic.'" /></a><br />';
-               } else {
-                    echo '<a href="view.php?id='.$course->id.'&amp;marker='.$section.'&amp;sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strmarkthistopic.'">'.'<img src="'.$CFG->pixpath.'/i/marker.gif" alt="'.$strmarkthistopic.'" /></a><br />';
-               }
-
-                if ($thissection->visible) {        // Show the hide/show eye
-                    echo '<a href="view.php?id='.$course->id.'&amp;hide='.$section.'&amp;sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strtopichide.'">'.
-                         '<img src="'.$CFG->pixpath.'/i/hide.gif" class="icon hide" alt="'.$strtopichide.'" /></a><br />';
-                } else {
-                    echo '<a href="view.php?id='.$course->id.'&amp;show='.$section.'&amp;sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strtopicshow.'">'.
-                         '<img src="'.$CFG->pixpath.'/i/show.gif" class="icon hide" alt="'.$strtopicshow.'" /></a><br />';
-                }
-                if ($section > 1) {                       // Add a arrow to move section up
-                    echo '<a href="view.php?id='.$course->id.'&amp;random='.rand(1,10000).'&amp;section='.$section.'&amp;move=-1&amp;sesskey='.$USER->sesskey.'#section-'.($section-1).'" title="'.$strmoveup.'">'.
-                         '<img src="'.$CFG->pixpath.'/t/up.gif" class="icon up" alt="'.$strmoveup.'" /></a><br />';
-                }
-
-                if ($section < $course->numsections) {    // Add a arrow to move section down
-                    echo '<a href="view.php?id='.$course->id.'&amp;random='.rand(1,10000).'&amp;section='.$section.'&amp;move=1&amp;sesskey='.$USER->sesskey.'#section-'.($section+1).'" title="'.$strmovedown.'">'.
-                         '<img src="'.$CFG->pixpath.'/t/down.gif" class="icon down" alt="'.$strmovedown.'" /></a><br />';
-                }
-            }
-            echo '</div>';
-
-            echo '<div class="content">';
-            if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible) {   // Hidden for students
-               echo get_string('notavailable').'</div>';
-           } else {
-                echo '<div class="summary">';
-                $summaryformatoptions->noclean = true;
-               if ($thissection->summary) {
-                   echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
-               } else {
-                  echo '&nbsp;';
-               }
-
-                if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
-                    echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id.'">'.
-                         '<img src="'.$CFG->pixpath.'/t/edit.gif" class="icon edit" alt="'.$streditsummary.'" /></a><br /><br />';
-                }
-                echo '</div>';
-
-                print_section($course, $thissection, $mods, $modnamesused);
-
-                if (isediting($course->id)) {
-                    print_section_add_menus($course, $section, $modnames);
-                }
-            }
-
-            echo '</div>';
-            echo "</li>\n";
-        }
-
-        $section++;
-    }
-    echo "</ul>\n";
-
-    if (!empty($sectionmenu)) {
-        echo '<div align="center" class="jumpmenu">';
-        echo popup_form($CFG->wwwroot.'/course/view.php?id='.$course->id.'&amp;', $sectionmenu,
-                   'sectionmenu', '', get_string('jumpto'), '', '', true);
-        echo '</div>';
-    }
-
-    if (!empty($THEME->customcorners)) print_custom_corners_end();
-
-    echo '</div>';
-
-    echo '</div>';
-    echo '<div class="clearer"></div>';
-
-?>
diff --git a/course/format/weekscss/ajax.php b/course/format/weekscss/ajax.php
deleted file mode 100644 (file)
index 2280edd..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-/**
- * This file is required if the course format is to support AJAX.
- */
-
-
-$CFG->ajaxcapable = true;
-$CFG->ajaxtestedbrowsers = array('MSIE' => 6.0, 'Gecko' => 20061111);
-
-?>
diff --git a/course/format/weekscss/format.php b/course/format/weekscss/format.php
deleted file mode 100644 (file)
index a120bfd..0000000
+++ /dev/null
@@ -1,276 +0,0 @@
-<?php // $Id$
-      // Display the whole course as "weeks" made of of modules
-      // Included from "view.php"
-/**
- * Evaluation weekly format for course display - NO layout tables, for accessibility, etc.
- * 
- * A duplicate course format to enable the Moodle development team to evaluate 
- * CSS for the multi-column layout in place of layout tables. 
- * Less risk for the Moodle 1.6 beta release.
- *   1. Straight copy of weeks/format.php
- *   2. Replace <table> and <td> with DIVs; inline styles.
- *   3. Reorder columns so that in linear view content is first then blocks;
- * styles to maintain original graphical (side by side) view.
- *
- * Target: 3-column graphical view using relative widths for pixel screen sizes 
- * 800x600, 1024x768... on IE6, Firefox. Below 800 columns will shift downwards.
- * 
- * http://www.maxdesign.com.au/presentation/em/ Ideal length for content.
- * http://www.svendtofte.com/code/max_width_in_ie/ Max width in IE.
- *
- * @copyright &copy; 2006 The Open University
- * @author N.D.Freear@open.ac.uk, and others.
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package  
- */
-//TODO (nfreear): Accessibility: evaluation, lang/en_utf8/moodle.php: $string['formatweekscss']
-
-    $week = optional_param('week', -1, PARAM_INT);
-
-    if ($week != -1) {
-        $displaysection = course_set_display($course->id, $week);
-    } else {
-        if (isset($USER->display[$course->id])) {
-            $displaysection = $USER->display[$course->id];
-        } else {
-            $displaysection = course_set_display($course->id, 0);
-        }
-    }
-
-    $streditsummary  = get_string('editsummary');
-    $stradd          = get_string('add');
-    $stractivities   = get_string('activities');
-    $strshowallweeks = get_string('showallweeks');
-    $strweek         = get_string('week');
-    $strgroups       = get_string('groups');
-    $strgroupmy      = get_string('groupmy');
-    $editing         = $PAGE->user_is_editing();
-
-    if ($editing) {
-        $strstudents = moodle_strtolower($course->students);
-        $strweekhide = get_string('weekhide', '', $strstudents);
-        $strweekshow = get_string('weekshow', '', $strstudents);
-        $strmoveup   = get_string('moveup');
-        $strmovedown = get_string('movedown');
-    }
-
-    $context = get_context_instance(CONTEXT_COURSE, $course->id);
-/* Internet Explorer min-width fix. (See theme/standard/styles_layout.css: min-width for Firefox.)
-   Window width: 800px, Firefox 763px, IE 752px. (Window width: 640px, Firefox 602px, IE 588px.)    
-*/
-?>
-
-<!--[if IE]>
-  <style type="text/css">
-  .weekscss-format { width: expression(document.body.clientWidth < 800 ? "752px" : "auto"); }
-  </style>
-<![endif]-->
-<?php
-/// Layout the whole page as three big columns (was, id="layout-table")
-    echo '<div class="weekscss-format">';
-
-/// The left column ...
-
-    if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
-        echo '<div id="left-column">';
-        blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
-        echo '</div>';
-    }
-    
-/// The right column, BEFORE the middle-column.
-    if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing) {
-        echo '<div id="right-column">';
-        blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
-        echo '</div>';
-    }
-
-/// Start main column
-    echo '<div id="middle-column">'. skip_main_destination();
-
-    print_heading_block(get_string('weeklyoutline'), 'outline');
-
-    // Note, an ordered list would confuse - "1" could be the clipboard or summary.
-    echo "<ul class='weekscss'>\n";
-
-/// If currently moving a file then show the current clipboard
-    if (ismoving($course->id)) {
-        $stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname)));
-        $strcancel= get_string('cancel');
-        echo '<li class="clipboard">';
-        echo $stractivityclipboard.'&nbsp;&nbsp;(<a href="mod.php?cancelcopy=true&amp;sesskey='.$USER->sesskey.'">'.$strcancel.'</a>)';
-        echo "</li>\n";
-    }
-
-/// Print Section 0 with general activities
-
-    $section = 0;
-    $thissection = $sections[$section];
-
-    if ($thissection->summary or $thissection->sequence or isediting($course->id)) {
-
-        // Note, no need for a 'left side' cell or DIV.
-        // Note, 'right side' is BEFORE content.
-        echo '<li id="section-0" class="section main" >';
-        echo '<div class="right side" >&nbsp;</div>';        
-        echo '<div class="content">';
-        
-        echo '<div class="summary">';
-        $summaryformatoptions->noclean = true;
-        echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
-
-        if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
-            echo '<p><a title="'.$streditsummary.'" '.
-                 ' href="editsection.php?id='.$thissection->id.'"><img src="'.$CFG->pixpath.'/t/edit.gif" '.
-                 ' class="icon edit" alt="'.$streditsummary.'" /></a></p>';
-        }
-        echo '</div>';
-        
-        print_section($course, $thissection, $mods, $modnamesused);
-
-        if (isediting($course->id)) {
-            print_section_add_menus($course, $section, $modnames);
-        }
-
-        echo '</div>';
-        echo "</li>\n";
-    }
-
-
-/// Now all the normal modules by week
-/// Everything below uses "section" terminology - each "section" is a week.
-
-    $timenow = time();
-    $weekdate = $course->startdate;    // this should be 0:00 Monday of that week
-    $weekdate += 7200;                 // Add two hours to avoid possible DST problems
-    $section = 1;
-    $sectionmenu = array();
-    $weekofseconds = 604800;
-    $course->enddate = $course->startdate + ($weekofseconds * $course->numsections);
-
-    $strftimedateshort = ' '.get_string('strftimedateshort');
-
-    while ($weekdate < $course->enddate) {
-
-        $nextweekdate = $weekdate + ($weekofseconds);
-        $weekday = userdate($weekdate, $strftimedateshort);
-        $endweekday = userdate($weekdate+518400, $strftimedateshort);
-
-        if (!empty($sections[$section])) {
-            $thissection = $sections[$section];
-
-        } else {
-            unset($thissection);
-            $thissection->course = $course->id;   // Create a new week structure
-            $thissection->section = $section;
-            $thissection->summary = '';
-            $thissection->visible = 1;
-            if (!$thissection->id = insert_record('course_sections', $thissection)) {
-                notify('Error inserting new week!');
-            }
-        }
-
-        $showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible or !$course->hiddensections);
-
-        if (!empty($displaysection) and $displaysection != $section) {  // Check this week is visible
-            if ($showsection) {
-                $sectionmenu['week='.$section] = s("$strweek $section |     $weekday - $endweekday");
-            }
-            $section++;
-            $weekdate = $nextweekdate;
-            continue;
-        }
-
-        if ($showsection) {
-
-            $currentweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate));
-
-            $currenttext = '';
-            if (!$thissection->visible) {
-                $sectionstyle = ' hidden';
-            } else if ($currentweek) {
-                $sectionstyle = ' current';
-                $currenttext = get_accesshide(get_string('currentweek','access'));
-            } else {
-                $sectionstyle = '';
-            }
-
-            echo '<li id="section-'.$section.'" class="section main'.$sectionstyle.'" >'; //'<div class="left side">&nbsp;</div>';
-
-            // Note, 'right side' is BEFORE content.
-            echo '<div class="right side">';
-            
-            if ($displaysection == $section) {
-                echo '<a href="view.php?id='.$course->id.'&amp;week=0#section-'.$section.'" title="'.$strshowallweeks.'">'.
-                     '<img src="'.$CFG->pixpath.'/i/all.gif" class="icon wkall" alt="'.$strshowallweeks.'" /></a><br />';
-            } else {
-                $strshowonlyweek = get_string("showonlyweek", "", $section);
-                echo '<a href="view.php?id='.$course->id.'&amp;week='.$section.'" title="'.$strshowonlyweek.'">'.
-                     '<img src="'.$CFG->pixpath.'/i/one.gif" class="icon wkone" alt="'.$strshowonlyweek.'" /></a><br />';
-            }
-
-            if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
-                if ($thissection->visible) {        // Show the hide/show eye
-                    echo '<a href="view.php?id='.$course->id.'&amp;hide='.$section.'&amp;sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strweekhide.'">'.
-                         '<img src="'.$CFG->pixpath.'/i/hide.gif" class="icon hide" alt="'.$strweekhide.'" /></a><br />';
-                } else {
-                    echo '<a href="view.php?id='.$course->id.'&amp;show='.$section.'&amp;sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strweekshow.'">'.
-                         '<img src="'.$CFG->pixpath.'/i/show.gif" class="icon hide" alt="'.$strweekshow.'" /></a><br />';
-                }
-                if ($section > 1) {                       // Add a arrow to move section up
-                    echo '<a href="view.php?id='.$course->id.'&amp;random='.rand(1,10000).'&amp;section='.$section.'&amp;move=-1&amp;sesskey='.$USER->sesskey.'#section-'.($section-1).'" title="'.$strmoveup.'">'.
-                         '<img src="'.$CFG->pixpath.'/t/up.gif" class="icon up" alt="'.$strmoveup.'" /></a><br />';
-                }
-
-                if ($section < $course->numsections) {    // Add a arrow to move section down
-                    echo '<a href="view.php?id='.$course->id.'&amp;random='.rand(1,10000).'&amp;section='.$section.'&amp;move=1&amp;sesskey='.$USER->sesskey.'#section-'.($section+1).'" title="'.$strmovedown.'">'.
-                         '<img src="'.$CFG->pixpath.'/t/down.gif" class="icon down" alt="'.$strmovedown.'" /></a><br />';
-                }
-            }
-            echo '</div>';
-
-            echo '<div class="content">';
-            if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible) {   // Hidden for students
-                echo '<div class="weekdates">'.$currenttext.$weekday.' - '.$endweekday.' ('.get_string('notavailable').')</div>';
-
-            } else {
-                echo '<div class="weekdates">'.$currenttext.$weekday.' - '.$endweekday.'</div>';
-
-                echo '<div class="summary">';
-                $summaryformatoptions->noclean = true;
-                echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
-
-                if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
-                    echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id.'">'.
-                         '<img src="'.$CFG->pixpath.'/t/edit.gif" class="icon edit" alt="'.$streditsummary.'" /></a><br /><br />';
-                }
-                echo '</div>';
-
-                print_section($course, $thissection, $mods, $modnamesused);
-
-                if (isediting($course->id)) {
-                    print_section_add_menus($course, $section, $modnames);
-                }
-            }
-
-            echo '</div>';
-            echo "</li>\n";
-        }
-
-        $section++;
-        $weekdate = $nextweekdate;
-    }
-    echo "</ul>\n";
-
-    if (!empty($sectionmenu)) {
-        echo '<div align="center" class="jumpmenu">';
-        echo popup_form($CFG->wwwroot.'/course/view.php?id='.$course->id.'&amp;', $sectionmenu,
-                   'sectionmenu', '', get_string('jumpto'), '', '', true);
-        echo '</div>';
-    }
-
-    echo '</div>';
-
-    echo '</div>';
-    echo '<div class="clearer"></div>';
-
-?>
diff --git a/doc/pix/cvstree.png b/doc/pix/cvstree.png
deleted file mode 100755 (executable)
index 803ad27..0000000
Binary files a/doc/pix/cvstree.png and /dev/null differ
diff --git a/doc/pix/files.jpg b/doc/pix/files.jpg
deleted file mode 100755 (executable)
index ff8f7d0..0000000
Binary files a/doc/pix/files.jpg and /dev/null differ
diff --git a/doc/pix/social.jpg b/doc/pix/social.jpg
deleted file mode 100755 (executable)
index 69596f9..0000000
Binary files a/doc/pix/social.jpg and /dev/null differ
diff --git a/doc/pix/topics.jpg b/doc/pix/topics.jpg
deleted file mode 100755 (executable)
index c8a099e..0000000
Binary files a/doc/pix/topics.jpg and /dev/null differ
diff --git a/doc/pix/weekly.jpg b/doc/pix/weekly.jpg
deleted file mode 100755 (executable)
index 1ffc82c..0000000
Binary files a/doc/pix/weekly.jpg and /dev/null differ
diff --git a/enrol/authorize/authorizenetlib.php b/enrol/authorize/authorizenetlib.php
deleted file mode 100644 (file)
index 0350105..0000000
+++ /dev/null
@@ -1,410 +0,0 @@
-<?php //  $Id$
-
-if (!defined('MOODLE_INTERNAL')) {
-    die('Direct access to this script is forbidden.');
-}
-
-define('AN_DELIM',    '|');
-define('AN_ENCAP',    '"');
-
-define('AN_REASON_NOCCTYPE',    17);
-define('AN_REASON_NOCCTYPE2',   28);
-define('AN_REASON_NOACH',       18);
-define('AN_REASON_ACHONLY',     56);
-define('AN_REASON_NOACHTYPE',  245);
-define('AN_REASON_NOACHTYPE2', 246);
-
-require_once($CFG->dirroot.'/enrol/authorize/const.php');
-require_once($CFG->dirroot.'/enrol/authorize/localfuncs.php');
-
-/**
- * Gets settlement date and time
- *
- * @param int $time Time processed, usually now.
- * @return int Settlement date and time
- */
-function authorize_getsettletime($time)
-{
-    global $CFG;
-
-    $cutoff = intval($CFG->an_cutoff);
-    $mins = $cutoff % 60;
-    $hrs = ($cutoff - $mins) / 60;
-    $cutofftime = strtotime("$hrs:$mins", $time);
-    if ($cutofftime < $time) {
-        $cutofftime = strtotime("$hrs:$mins", $time + (24 * 3600));
-    }
-    return $cutofftime;
-}
-
-/**
- * Is order settled? Status must be auth_captured or credited.
- *
- * @param object $order Order details
- * @return bool true, if settled, false otherwise.
- */
-function authorize_settled($order)
-{
-    return (($order->status == AN_STATUS_AUTHCAPTURE || $order->status == AN_STATUS_CREDIT) &&
-            ($order->settletime > 0) && ($order->settletime < time()));
-}
-
-/**
- * Is order expired? 'Authorized/Pending Capture' transactions are expired after 30 days.
- *
- * @param object &$order Order details.
- * @return bool true, transaction is expired, false otherwise.
- */
-function authorize_expired(&$order)
-{
-    static $timediff30;
-
-    if ($order->status == AN_STATUS_EXPIRE) {
-        return true;
-    }
-    elseif ($order->status != AN_STATUS_AUTH) {
-        return false;
-    }
-
-    if (empty($timediff30)) {
-        $timediff30 = authorize_getsettletime(time()) - (30 * 24 * 3600);
-    }
-
-    $isexpired = (authorize_getsettletime($order->timecreated) < $timediff30);
-    if ($isexpired) {
-        $order->status = AN_STATUS_EXPIRE;
-        update_record('enrol_authorize', $order);
-    }
-    return $isexpired;
-}
-
-/**
- * Performs an action on authorize.net and updates/inserts records. If record update fails,
- * sends email to admin.
- *
- * @param object &$order Which transaction data will be sent. See enrol_authorize table.
- * @param string &$message Information about error message.
- * @param object &$extra Extra data that used for refunding and credit card information.
- * @param int $action Which action will be performed. See AN_ACTION_*
- * @param string $cctype Used internally to configure credit types automatically.
- * @return int AN_APPROVED Transaction was successful, AN_RETURNZERO otherwise. Use $message for reason.
- * @author Ethem Evlice <ethem a.t evlice d.o.t com>
- * @uses $CFG
- */
-function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE, $cctype=NULL)
-{
-    global $CFG;
-    static $constpd;
-    require_once($CFG->libdir.'/filelib.php');
-
-    if (!isset($constpd)) {
-        $mconfig = get_config('enrol/authorize');
-        $constpd = array(
-             'x_version'         => '3.1',
-             'x_delim_data'      => 'True',
-             'x_delim_char'      => AN_DELIM,
-             'x_encap_char'      => AN_ENCAP,
-             'x_relay_response'  => 'FALSE',
-             'x_login'           => rc4decrypt($mconfig->an_login)
-        );
-
-        if (!empty($mconfig->an_tran_key)) {
-            $constpd['x_tran_key'] = rc4decrypt($mconfig->an_tran_key);
-        }
-        else {
-            $constpd['x_password'] = rc4decrypt($mconfig->an_password);
-        }
-    }
-
-    if (empty($order) or empty($order->id)) {
-        $message = "Check order->id!";
-        return AN_RETURNZERO;
-    }
-
-    $method = $order->paymentmethod;
-    if (empty($method)) {
-        $method = AN_METHOD_CC;
-    }
-    elseif ($method != AN_METHOD_CC && $method != AN_METHOD_ECHECK) {
-        $message = "Invalid method: $method";
-        return AN_RETURNZERO;
-    }
-
-    $action = intval($action);
-    if ($method == AN_METHOD_ECHECK) {
-        if ($action != AN_ACTION_AUTH_CAPTURE && $action != AN_ACTION_CREDIT) {
-            $message = "Please perform AUTH_CAPTURE or CREDIT for echecks";
-            return AN_RETURNZERO;
-        }
-    }
-
-    $pd = $constpd;
-    $pd['x_method'] = $method;
-    $test = !empty($CFG->an_test);
-    $pd['x_test_request'] = ($test ? 'TRUE' : 'FALSE');
-
-    switch ($action) {
-        case AN_ACTION_AUTH_ONLY:
-        case AN_ACTION_CAPTURE_ONLY:
-        case AN_ACTION_AUTH_CAPTURE:
-        {
-            if ($order->status != AN_STATUS_NONE) {
-                $message = "Order status must be AN_STATUS_NONE(0)!";
-                return AN_RETURNZERO;
-            }
-            elseif (empty($extra)) {
-                $message = "Need extra fields!";
-                return AN_RETURNZERO;
-            }
-            elseif (($action == AN_ACTION_CAPTURE_ONLY) and empty($extra->x_auth_code)) {
-                $message = "x_auth_code is required for capture only transactions!";
-                return AN_RETURNZERO;
-            }
-
-            $ext = (array)$extra;
-            $pd['x_type'] = (($action==AN_ACTION_AUTH_ONLY)
-                              ? 'AUTH_ONLY' :( ($action==AN_ACTION_CAPTURE_ONLY)
-                                                ? 'CAPTURE_ONLY' : 'AUTH_CAPTURE'));
-            foreach($ext as $k => $v) {
-                $pd[$k] = $v;
-            }
-            break;
-        }
-
-        case AN_ACTION_PRIOR_AUTH_CAPTURE:
-        {
-            if ($order->status != AN_STATUS_AUTH) {
-                $message = "Order status must be authorized!";
-                return AN_RETURNZERO;
-            }
-            if (authorize_expired($order)) {
-                $message = "Transaction must be captured within 30 days. EXPIRED!";
-                return AN_RETURNZERO;
-            }
-            $pd['x_type'] = 'PRIOR_AUTH_CAPTURE';
-            $pd['x_trans_id'] = $order->transid;
-            break;
-        }
-
-        case AN_ACTION_CREDIT:
-        {
-            if ($order->status != AN_STATUS_AUTHCAPTURE) {
-                $message = "Order status must be authorized/captured!";
-                return AN_RETURNZERO;
-            }
-            if (!authorize_settled($order)) {
-                $message = "Order must be settled. Try VOID, check Cut-Off time if it fails!";
-                return AN_RETURNZERO;
-            }
-            if (empty($extra->amount)) {
-                $message = "No valid amount!";
-                return AN_RETURNZERO;
-            }
-            $timenowsettle = authorize_getsettletime(time());
-            $timediff = $timenowsettle - (120 * 3600 * 24);
-            if ($order->settletime < $timediff) {
-                $message = "Order must be credited within 120 days!";
-                return AN_RETURNZERO;
-            }
-
-            $pd['x_type'] = 'CREDIT';
-            $pd['x_trans_id'] = $order->transid;
-            $pd['x_currency_code'] = $order->currency;
-            $pd['x_invoice_num'] = $extra->orderid;
-            $pd['x_amount'] = $extra->amount;
-            if ($method == AN_METHOD_CC) {
-                $pd['x_card_num'] = sprintf("%04d", intval($order->refundinfo));
-            }
-            elseif ($method == AN_METHOD_ECHECK && empty($order->refundinfo)) {
-                $message = "Business checkings can be refunded only.";
-                return AN_RETURNZERO;
-            }
-            break;
-        }
-
-        case AN_ACTION_VOID:
-        {
-            if (authorize_expired($order) || authorize_settled($order)) {
-                $message = "The transaction cannot be voided due to the fact that it is expired or settled.";
-                return AN_RETURNZERO;
-            }
-            $pd['x_type'] = 'VOID';
-            $pd['x_trans_id'] = $order->transid;
-            break;
-        }
-
-        default: {
-            $message = "Invalid action: $action";
-            return AN_RETURNZERO;
-        }
-    }
-
-    $headers = array('Connection' => 'close');
-    if (! (empty($CFG->an_referer) || $CFG->an_referer == "http://")) {
-        $headers['Referer'] = $CFG->an_referer;
-    }
-
-    @ignore_user_abort(true);
-    if (intval(ini_get('max_execution_time')) > 0) {
-        @set_time_limit(300);
-    }
-
-    $host = $test ? 'certification.authorize.net' : 'secure.authorize.net';
-    $data = download_file_content("https://$host:443/gateway/transact.dll", $headers, $pd, false, 60);
-    if (!$data) {
-        $message = "No connection to https://$host:443";
-        return AN_RETURNZERO;
-    }
-    $response = explode(AN_ENCAP.AN_DELIM.AN_ENCAP, $data);
-    if ($response === false) {
-        $message = "response error";
-        return AN_RETURNZERO;
-    }
-    $rcount = count($response) - 1;
-    if ($response[0]{0} == AN_ENCAP) {
-        $response[0] = substr($response[0], 1);
-    }
-    if (substr($response[$rcount], -1) == AN_ENCAP) {
-        $response[$rcount] = substr($response[$rcount], 0, -1);
-    }
-
-    $responsecode = intval($response[0]);
-    if ($responsecode == AN_APPROVED || $responsecode == AN_REVIEW)
-    {
-        $transid = intval($response[6]);
-        if ($test || $transid == 0) {
-            return $responsecode; // don't update original transaction in test mode.
-        }
-        switch ($action) {
-            case AN_ACTION_AUTH_ONLY:
-            case AN_ACTION_CAPTURE_ONLY:
-            case AN_ACTION_AUTH_CAPTURE:
-            case AN_ACTION_PRIOR_AUTH_CAPTURE:
-            {
-                $order->transid = $transid;
-
-                if ($method == AN_METHOD_CC) {
-                    if ($action == AN_ACTION_AUTH_ONLY || $responsecode == AN_REVIEW) {
-                        $order->status = AN_STATUS_AUTH;
-                    } else {
-                        $order->status = AN_STATUS_AUTHCAPTURE;
-                        $order->settletime = authorize_getsettletime(time());
-                    }
-                }
-                elseif ($method == AN_METHOD_ECHECK) {
-                    $order->status = AN_STATUS_UNDERREVIEW;
-                }
-
-                if (! update_record('enrol_authorize', $order)) {
-                    email_to_admin("Error while trying to update data " .
-                    "in table enrol_authorize. Please edit manually this record: ID=$order->id.", $order);
-                }
-                break;
-            }
-            case AN_ACTION_CREDIT:
-            {
-                // Credit generates new transaction id.
-                // So, $extra must be updated, not $order.
-                $extra->status = AN_STATUS_CREDIT;
-                $extra->transid = $transid;
-                $extra->settletime = authorize_getsettletime(time());
-                if (! $extra->id = insert_record('enrol_authorize_refunds', $extra)) {
-                    unset($extra->id);
-                    email_to_admin("Error while trying to insert data " .
-                    "into table enrol_authorize_refunds. Please add manually this record:", $extra);
-                }
-                break;
-            }
-            case AN_ACTION_VOID:
-            {
-                $tableupdate = 'enrol_authorize';
-                if ($order->status == AN_STATUS_CREDIT) {
-                    $tableupdate = 'enrol_authorize_refunds';
-                    unset($order->paymentmethod);
-                }
-                $order->status = AN_STATUS_VOID;
-                if (! update_record($tableupdate, $order)) {
-                    email_to_admin("Error while trying to update data " .
-                    "in table $tableupdate. Please edit manually this record: ID=$order->id.", $order);
-                }
-                break;
-            }
-        }
-    }
-    else
-    {
-        $reasonno = $response[2];
-        $reasonstr = "reason" . $reasonno;
-        $message = get_string($reasonstr, "enrol_authorize");
-        if ($message == '[[' . $reasonstr . ']]') {
-            $message = isset($response[3]) ? $response[3] : 'unknown error';
-        }
-        if ($method == AN_METHOD_CC && !empty($CFG->an_avs) && $response[5] != "P") {
-            $avs = "avs" . strtolower($response[5]);
-            $stravs = get_string($avs, "enrol_authorize");
-            $message .= "<br />" . get_string("avsresult", "enrol_authorize", $stravs);
-        }
-        if (!$test) { // Autoconfigure :)
-            switch($reasonno) {
-                // Credit card type isn't accepted
-                case AN_REASON_NOCCTYPE:
-                case AN_REASON_NOCCTYPE2:
-                {
-                    if (!empty($cctype)) {
-                        $ccaccepts = get_list_of_creditcards();
-                        unset($ccaccepts[$cctype]);
-                        set_config('an_acceptccs', implode(',', array_keys($ccaccepts)));
-                        email_to_admin("$message ($cctype)" .
-                        "This is new config(an_acceptccs):", $ccaccepts);
-                    }
-                    break;
-                }
-                // Echecks only
-                case AN_REASON_ACHONLY:
-                {
-                    set_config('an_acceptmethods', AN_METHOD_ECHECK);
-                    email_to_admin("$message " .
-                    "This is new config(an_acceptmethods):", array(AN_METHOD_ECHECK));
-                    break;
-                }
-                // Echecks aren't accepted
-                case AN_REASON_NOACH:
-                {
-                    set_config('an_acceptmethods', AN_METHOD_CC);
-                    email_to_admin("$message " .
-                    "This is new config(an_acceptmethods):", array(AN_METHOD_CC));
-                    break;
-                }
-                // This echeck type isn't accepted
-                case AN_REASON_NOACHTYPE:
-                case AN_REASON_NOACHTYPE2:
-                {
-                    if (!empty($extra->x_echeck_type)) {
-                        switch ($extra->x_echeck_type) {
-                            // CCD=BUSINESSCHECKING
-                            case 'CCD':
-                            {
-                                set_config('an_acceptechecktypes', 'CHECKING,SAVINGS');
-                                email_to_admin("$message " .
-                                "This is new config(an_acceptechecktypes):", array('CHECKING','SAVINGS'));
-                            }
-                            break;
-                            // WEB=CHECKING or SAVINGS
-                            case 'WEB':
-                            {
-                                set_config('an_acceptechecktypes', 'BUSINESSCHECKING');
-                                email_to_admin("$message " .
-                                "This is new config(an_acceptechecktypes):", array('BUSINESSCHECKING'));
-                            }
-                            break;
-                        }
-                    }
-                    break;
-                }
-            }
-        }
-    }
-    return $responsecode;
-}
-
-?>
index c66698625b61dfd2576f7d4c44ab60b011491aed..650dbbeb8c228dfd03de704d07b97e3121487d84 100644 (file)
@@ -20,7 +20,7 @@ define('AN_METHOD_ECHECK', 'echeck');
  * CREDIT: Refunded.
  * VOID: Cancelled.
  * EXPIRE: Expired. Orders be expired unless be accepted within 30 days.
- * 
+ *
  * These are valid only for ECHECK:
  * UNDERREVIEW: Hold for review.
  * APPROVEDREVIEW: Approved review.
@@ -41,7 +41,7 @@ define('AN_STATUS_TEST',            0xff); // dummy status
 /**#@-*/
 
 /**#@+
- * Actions used in authorize_action() function.
+ * Actions used in AuthorizeNet::process() method.
  *
  * NONE: No action. Function always returns false.
  * AUTH_ONLY: Used to authorize only, don't capture.
@@ -75,7 +75,7 @@ define('AN_ACTION_VOID',                6);
 /**#@-*/
 
 /**#@+
- * Return codes for authorize_action() function.
+ * Return codes for AuthorizeNet::process() method.
  *
  * AN_RETURNZERO: No connection was made on authorize.net.
  * AN_APPROVED: The transaction was accepted.
diff --git a/enrol/authorize/db/mysql.php b/enrol/authorize/db/mysql.php
deleted file mode 100755 (executable)
index 9dbf661..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-<?php //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-// MySQL commands for upgrading this enrolment module
-
-function enrol_authorize_upgrade($oldversion=0) {
-    global $CFG, $THEME, $db;
-    require_once("$CFG->dirroot/enrol/authorize/const.php");
-
-    $result = true;
-
-    if ($oldversion < 2005071600) {
-        // Be sure, only last 4 digit is inserted.
-        table_column('enrol_authorize', 'cclastfour', 'cclastfour', 'integer', '4', 'unsigned', '0', 'not null');
-        table_column('enrol_authorize', 'courseid', 'courseid', 'integer', '10', 'unsigned', '0', 'not null');
-        table_column('enrol_authorize', 'userid', 'userid', 'integer', '10', 'unsigned', '0', 'not null');
-        // Add some indexes for speed.
-        execute_sql("ALTER TABLE `{$CFG->prefix}enrol_authorize` ADD INDEX courseid(courseid)", false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}enrol_authorize` ADD INDEX userid(userid)", false);
-    }
-
-    if ($oldversion && $oldversion < 2005071602) {
-        notify("If you are using the authorize.net enrolment plugin for credit card
-                handling, please ensure that you have turned loginhttps ON in Admin >> Variables >> Security.");
-    }
-
-    if ($oldversion < 2005112100) {
-        table_column('enrol_authorize', '', 'authcode', 'varchar', '6', '', '', '', 'avscode'); // CAPTURE_ONLY
-        table_column('enrol_authorize', '', 'status', 'integer', '10', 'unsigned', '0', 'not null', 'transid');
-        table_column('enrol_authorize', '', 'timecreated', 'integer', '10', 'unsigned', '0', 'not null', 'status');
-        table_column('enrol_authorize', '', 'timeupdated', 'integer', '10', 'unsigned', '0', 'not null', 'timecreated');
-        // status index for speed.
-        execute_sql("ALTER TABLE `{$CFG->prefix}enrol_authorize` ADD INDEX status(status)");
-        // defaults.
-        $status = AN_STATUS_AUTH | AN_STATUS_CAPTURE;
-        execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET status='$status' WHERE transid<>'0'", false);
-        $timenow = time();
-        execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET timecreated='$timenow', timeupdated='$timenow'", false);
-    }
-
-    if ($oldversion < 2005121200) {
-        // new fields for refund and sales reports.
-        $defaultcurrency = empty($CFG->enrol_currency) ? 'USD' : $CFG->enrol_currency;
-        table_column('enrol_authorize', '', 'amount', 'varchar', '10', '', '0', 'not null', 'timeupdated');
-        table_column('enrol_authorize', '', 'currency', 'varchar', '3', '', $defaultcurrency, 'not null', 'amount');
-        modify_database("","CREATE TABLE prefix_enrol_authorize_refunds (
-          `id` int(10) unsigned NOT NULL auto_increment,
-          `orderid` int(10) unsigned NOT NULL default 0,
-          `refundtype` int(1) unsigned NOT NULL default 0,
-          `amount` varchar(10) NOT NULL default '',
-          `transid` int(10) unsigned NULL default 0,
-          PRIMARY KEY (`id`),
-          KEY `orderid` (`orderid`));");
-        // defaults.
-        if (($courses = get_records_select('course', '', '', 'id, cost, currency'))) {
-            foreach ($courses as $course) {
-                execute_sql("UPDATE {$CFG->prefix}enrol_authorize
-                             SET amount = '$course->cost', currency = '$course->currency'
-                             WHERE courseid = '$course->id'", false);
-            }
-        }
-    }
-
-    if ($oldversion < 2005122200) { // settletime
-        table_column('enrol_authorize_refunds', 'refundtype', 'status', 'integer', '1', 'unsigned', '0', 'not null');
-        table_column('enrol_authorize_refunds', '', 'settletime', 'integer', '10', 'unsigned', '0', 'not null', 'transid');
-        table_column('enrol_authorize', 'timeupdated', 'settletime', 'integer', '10', 'unsigned', '0', 'not null');
-        $status = AN_STATUS_AUTH | AN_STATUS_CAPTURE;
-        if (($settlements = get_records_select('enrol_authorize', "status='$status'", '', 'id, settletime'))) {
-            include_once("$CFG->dirroot/enrol/authorize/authorizenetlib.php");
-            foreach ($settlements as $settlement) {
-                execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET settletime = '" .
-                authorize_getsettletime($settlement->settletime) . "' WHERE id = '$settlement->id'", false);
-            }
-        }
-    }
-
-    if ($oldversion < 2005122800) { // no need anymore some fields.
-        execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP ccexp", false);
-        execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP cvv", false);
-        execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP avscode", false);
-        execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP authcode", false);
-    }
-
-    if ($oldversion < 2006010200) { // rename an_review_day
-        if (isset($CFG->an_review_day)) {
-            set_config('an_capture_day', $CFG->an_review_day);
-            delete_records('config', 'name', 'an_review_day');
-        }
-    }
-
-    if ($oldversion < 2006020100) { // rename an_cutoff_hour and an_cutoff_min to an_cutoff
-        if (isset($CFG->an_cutoff_hour) && isset($CFG->an_cutoff_min)) {
-            $an_cutoff_hour = intval($CFG->an_cutoff_hour);
-            $an_cutoff_min = intval($CFG->an_cutoff_min);
-            $an_cutoff = ($an_cutoff_hour * 60) + $an_cutoff_min;
-            if (set_config('an_cutoff', $an_cutoff)) {
-                delete_records('config', 'name', 'an_cutoff_hour');
-                delete_records('config', 'name', 'an_cutoff_min');
-            }
-        }
-    }
-
-    if ($oldversion < 2006021500) { // transid is int
-        table_column('enrol_authorize', 'transid', 'transid', 'integer', '10', 'unsigned', '0', 'not null');
-    }
-
-    if ($oldversion < 2006021501) { // delete an_nextmail record from config_plugins table
-        delete_records('config_plugins', 'name', 'an_nextmail');
-    }
-
-    if ($oldversion < 2006050400) { // Create transid indexes for backup & restore speed.
-        execute_sql("ALTER TABLE `{$CFG->prefix}enrol_authorize` ADD INDEX transid(transid)", false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}enrol_authorize_refunds` ADD INDEX transid(transid)", false);
-    }
-
-    if ($oldversion < 2006060500) { // delete an_nextmail record from config_plugins table
-        delete_records('config_plugins', 'name', 'an_nextmail'); // run twice.
-    }
-
-    if ($oldversion < 2006081401) { // no need an_teachermanagepay in 1.7
-        if (isset($CFG->an_teachermanagepay)) {
-            delete_records('config', 'name', 'an_teachermanagepay');
-        }
-    }
-
-    if ($oldversion < 2006083100) {
-        // enums are lower case
-        if (isset($CFG->an_acceptmethods)) {
-            set_config('an_acceptmethods', strtolower($CFG->an_acceptmethods));
-        }
-        // new ENUM field: paymentmethod(cc,echeck)
-        execute_sql("ALTER TABLE `{$CFG->prefix}enrol_authorize` ADD paymentmethod enum('cc', 'echeck') NOT NULL default 'cc' AFTER `id`", true);
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return $result;
-}
-
-?>
diff --git a/enrol/authorize/db/postgres7.php b/enrol/authorize/db/postgres7.php
deleted file mode 100644 (file)
index 62c1d87..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-<?php //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-// PostgreSQL commands for upgrading this enrolment module
-
-function enrol_authorize_upgrade($oldversion=0) {
-    global $CFG, $THEME, $db;
-    require_once("$CFG->dirroot/enrol/authorize/const.php");
-
-    $result = true;
-
-    if (!$tables = $db->MetaColumns($CFG->prefix . 'enrol_authorize')) {
-        $installfirst = true;
-    }
-
-    if ($oldversion == 0 || !empty($installfirst)) { // First time install
-        $result = modify_database("$CFG->dirroot/enrol/authorize/db/postgres7.sql");
-        return $result; // RETURN, sql file contains last upgrades.
-    }
-
-    // Authorize module was installed before. Upgrades must be applied to SQL file.
-
-    if ($oldversion && $oldversion < 2005071602) {
-        notify("If you are using the authorize.net enrolment plugin for credit card
-                handling, please ensure that you have turned loginhttps ON in Admin >> Variables >> Security.");
-    }
-
-    if ($oldversion < 2005080200) {
-        // Be sure, only last 4 digit is inserted.
-        table_column('enrol_authorize', 'cclastfour', 'cclastfour', 'integer', '4', 'unsigned', '0', 'not null');
-        table_column('enrol_authorize', 'courseid', 'courseid', 'integer', '10', 'unsigned', '0', 'not null');
-        table_column('enrol_authorize', 'userid', 'userid', 'integer', '10', 'unsigned', '0', 'not null');
-        // Add some indexes for speed.
-        execute_sql("CREATE INDEX {$CFG->prefix}enrol_authorize_courseid_idx ON {$CFG->prefix}enrol_authorize (courseid);", false);
-        execute_sql("CREATE INDEX {$CFG->prefix}enrol_authorize_userid_idx ON {$CFG->prefix}enrol_authorize (userid);", false);
-    }
-
-    if ($oldversion < 2005112100) {
-        table_column('enrol_authorize', '', 'authcode', 'varchar', '6', '', '', '', 'avscode'); // CAPTURE_ONLY
-        table_column('enrol_authorize', '', 'status', 'integer', '10', 'unsigned', '0', 'not null', 'transid');
-        table_column('enrol_authorize', '', 'timecreated', 'integer', '10', 'unsigned', '0', 'not null', 'status');
-        table_column('enrol_authorize', '', 'timeupdated', 'integer', '10', 'unsigned', '0', 'not null', 'timecreated');
-        // status index for speed.
-        modify_database('',"CREATE INDEX prefix_enrol_authorize_status_idx ON prefix_enrol_authorize (status);");
-        // defaults.
-        $status = AN_STATUS_AUTH | AN_STATUS_CAPTURE;
-        execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET status='$status' WHERE transid<>'0'", false);
-        $timenow = time();
-        execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET timecreated='$timenow', timeupdated='$timenow'", false);
-    }
-
-    if ($oldversion < 2005121200) {
-        // new fields for refund and sales reports.
-        $defaultcurrency = empty($CFG->enrol_currency) ? 'USD' : $CFG->enrol_currency;
-        table_column('enrol_authorize', '', 'amount', 'varchar', '10', '', '0', 'not null', 'timeupdated');
-        table_column('enrol_authorize', '', 'currency', 'varchar', '3', '', $defaultcurrency, 'not null', 'amount');
-        modify_database("","CREATE TABLE prefix_enrol_authorize_refunds (
-           id SERIAL PRIMARY KEY,
-           orderid INTEGER NOT NULL default 0,
-           refundtype INTEGER NOT NULL default 0,
-           amount varchar(10) NOT NULL default '',
-           transid INTEGER NULL default 0
-         );");
-        modify_database("","CREATE INDEX prefix_enrol_authorize_refunds_orderid_idx ON prefix_enrol_authorize_refunds (orderid);");
-        // defaults.
-        if (($courses = get_records_select('course', '', '', 'id, cost, currency'))) {
-            foreach ($courses as $course) {
-                execute_sql("UPDATE {$CFG->prefix}enrol_authorize
-                             SET amount = '$course->cost', currency = '$course->currency'
-                             WHERE courseid = '$course->id'", false);
-            }
-        }
-    }
-
-    if ($oldversion < 2005122200) { // settletime
-        table_column('enrol_authorize_refunds', 'refundtype', 'status', 'integer', '1', 'unsigned', '0', 'not null');
-        table_column('enrol_authorize_refunds', '', 'settletime', 'integer', '10', 'unsigned', '0', 'not null', 'transid');
-        table_column('enrol_authorize', 'timeupdated', 'settletime', 'integer', '10', 'unsigned', '0', 'not null');
-        $status = AN_STATUS_AUTH | AN_STATUS_CAPTURE;
-        if (($settlements = get_records_select('enrol_authorize', "status='$status'", '', 'id, settletime'))) {
-            include_once("$CFG->dirroot/enrol/authorize/authorizenetlib.php");
-            foreach ($settlements as $settlement) {
-                execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET settletime = '" .
-                authorize_getsettletime($settlement->settletime) . "' WHERE id = '$settlement->id'", false);
-            }
-        }
-    }
-
-    if ($oldversion < 2005122800) { // no need anymore some fields.
-        execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP ccexp", false);
-        execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP cvv", false);
-        execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP avscode", false);
-        execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP authcode", false);
-    }
-
-    if ($oldversion < 2006010200) { // rename an_review_day
-        if (isset($CFG->an_review_day)) {
-            set_config('an_capture_day', $CFG->an_review_day);
-            delete_records('config', 'name', 'an_review_day');
-        }
-    }
-
-    if ($oldversion < 2006020100) { // rename an_cutoff_hour and an_cutoff_min to an_cutoff
-        if (isset($CFG->an_cutoff_hour) && isset($CFG->an_cutoff_min)) {
-            $an_cutoff_hour = intval($CFG->an_cutoff_hour);
-            $an_cutoff_min = intval($CFG->an_cutoff_min);
-            $an_cutoff = ($an_cutoff_hour * 60) + $an_cutoff_min;
-            if (set_config('an_cutoff', $an_cutoff)) {
-                delete_records('config', 'name', 'an_cutoff_hour');
-                delete_records('config', 'name', 'an_cutoff_min');
-            }
-        }
-    }
-
-    if ($oldversion < 2006021500) { // transid is int
-        table_column('enrol_authorize', 'transid', 'transid', 'integer', '10', 'unsigned', '0', 'not null');
-    }
-
-    if ($oldversion < 2006021501) { // delete an_nextmail record from config_plugins table
-        delete_records('config_plugins', 'name', 'an_nextmail');
-    }
-
-    if ($oldversion < 2006050400) { // Create transid indexes for backup & restore speed.
-        execute_sql("CREATE INDEX {$CFG->prefix}enrol_authorize_transid_idx ON {$CFG->prefix}enrol_authorize(transid);", false);
-        execute_sql("CREATE INDEX {$CFG->prefix}enrol_authorize_refunds_transid_idx ON {$CFG->prefix}enrol_authorize_refunds(transid);", false);
-    }
-
-    if ($oldversion < 2006060500) { // delete an_nextmail record from config_plugins table
-        delete_records('config_plugins', 'name', 'an_nextmail'); // run twice.
-    }
-
-    if ($oldversion < 2006081401) { // no need an_teachermanagepay in 1.7
-        if (isset($CFG->an_teachermanagepay)) {
-            delete_records('config', 'name', 'an_teachermanagepay');
-        }
-    }
-
-    if ($oldversion < 2006083100) {
-        // enums are lower case
-        if (isset($CFG->an_acceptmethods)) {
-            set_config('an_acceptmethods', strtolower($CFG->an_acceptmethods));
-        }
-        // new ENUM field: paymentmethod(cc,echeck)
-        table_column('enrol_authorize', '', 'paymentmethod', 'varchar', '6', '', 'cc', 'not null');
-        execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize ADD CONSTRAINT enroauth_pay_ck CHECK (paymentmethod IN ('cc', 'echeck'))", true);
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return $result;
-}
-
-?>
diff --git a/enrol/paypal/db/mysql.php b/enrol/paypal/db/mysql.php
deleted file mode 100644 (file)
index 7a926a0..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-// MySQL commands for upgrading this enrolment module
-
-function enrol_paypal_upgrade($oldversion=0) {
-
-    global $CFG, $THEME, $db;
-
-    $result = true;
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return $result;
-
-}
-
-?>
diff --git a/enrol/paypal/db/postgres7.php b/enrol/paypal/db/postgres7.php
deleted file mode 100644 (file)
index 35768f7..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?PHP  //$Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-// PostgreSQL commands for upgrading this enrolment module
-
-function enrol_paypal_upgrade($oldversion=0) {
-
-    global $CFG, $THEME, $db;
-
-    $result = true;
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return $result;
-
-}
-
-?>
index 2000a060c9e9bc4f05193f2dbcf4c7c970044b1a..f86445441d27a07e4fdcaf26e34059389a093603 100644 (file)
@@ -3,7 +3,7 @@
       // If not, it obtains the corresponding TeX expression from the cache_tex db table
       // and uses mimeTeX to create the image file
 
-    $nomoodlecookie = true;     // Because it interferes with caching
+    define('NO_MOODLE_COOKIES', true); // Because it interferes with caching
 
     require_once("../../config.php");
 
index 3c14bd217f8143d796d3fd547b6f9889117ff5c8..fe93abc03e5fce85ba949cb5386bdd062575466a 100644 (file)
@@ -3,7 +3,7 @@
       // If not, it obtains the corresponding TeX expression from the cache_tex db table
       // and uses mimeTeX to create the image file
 
-    $nomoodlecookie = true;     // Because it interferes with caching
+    define('NO_MOODLE_COOKIES', true); // Because it interferes with caching
 
     require_once('../../config.php');
 
index 6ca5bb567143ab58e30b4dca774b3dafcdc7cec1..dd7e9696a8543a225a6bb672a95d3a140599d632 100644 (file)
@@ -3,7 +3,7 @@
       // If not, it obtains the corresponding TeX expression from the cache_tex db table
       // and uses mimeTeX to create the image file
 
-    $nomoodlecookie = true;     // Because it interferes with caching
+define('NO_MOODLE_COOKIES', true); // Because it interferes with caching
 
     require_once('../../config.php');
 
index 6a976f4da13f0ecb78e1b6f1c1bc8fcf623816d7..4cd5f9611623041e2fd664da7577c06e2dd15213 100644 (file)
@@ -3,7 +3,7 @@
       // If not, it obtains the corresponding TeX expression from the cache_tex db table
       // and uses mimeTeX to create the image file
 
-    $nomoodlecookie = true;     // Because it interferes with caching
+    define('NO_MOODLE_COOKIES', true); // Because it interferes with caching
 
     require_once("../../config.php");
 
index 5ff4c0bd42d580a5f87e7679020af521b9ecf6c3..3a40ba1cc8185bd5101f39f6d574e0be9b8b4bff 100644 (file)
@@ -3,7 +3,7 @@
       // If not, it obtains the corresponding TeX expression from the cache_tex db table
       // and uses mimeTeX to create the image file
 
-    $nomoodlecookie = true;     // Because it interferes with caching
+    define('NO_MOODLE_COOKIES', true); // Because it interferes with caching
 
     require_once("../../config.php");
     require_once($CFG->dirroot.'/filter/tex/lib.php');
diff --git a/grade/export/csv/db/access.php b/grade/export/csv/db/access.php
deleted file mode 100644 (file)
index b28b04f..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
index eff5cb65cc4ffd9cda18c57688e1c3e757c22a5a..f6c21a79646aff13fa9185d43a04bf484f20dbe9 100644 (file)
@@ -23,7 +23,7 @@
 //                                                                       //
 ///////////////////////////////////////////////////////////////////////////
 
-$nomoodlecookie = true; // session not used here
+define('NO_MOODLE_COOKIES', true); // session not used here
 require '../../../config.php';
 
 $id = required_param('id', PARAM_INT); // course id
index 91f1ebea632a47cd6a92f2c53c712b4b87dc50d7..bb9b45af85940ecd815d1b266a05b828f72d2372 100644 (file)
@@ -23,7 +23,7 @@
 //                                                                       //
 ///////////////////////////////////////////////////////////////////////////
 
-$nomoodlecookie = true; // session not used here
+define('NO_MOODLE_COOKIES', true); // session not used here
 require '../../../config.php';
 
 $id = required_param('id', PARAM_INT); // course id
index 11cdd27dcb079e270d3b3ee7882652f86af584b3..b3efcb770814f917510e406630a689a7708ffd7e 100644 (file)
@@ -23,7 +23,7 @@
 //                                                                       //
 ///////////////////////////////////////////////////////////////////////////
 
-$nomoodlecookie = true; // session not used here
+define('NO_MOODLE_COOKIES', true); // session not used here
 require '../../../config.php';
 
 $id = required_param('id', PARAM_INT); // course id
index 6362af0017f7a0509dbb5d59d61f7f6eb34be581..275cc229c878a195a19a51a27e06efe927f45807 100644 (file)
@@ -23,7 +23,7 @@
 //                                                                       //
 ///////////////////////////////////////////////////////////////////////////
 
-$nomoodlecookie = true; // session not used here
+define('NO_MOODLE_COOKIES', true); // session not used here
 require '../../../config.php';
 
 $id = required_param('id', PARAM_INT); // course id
index 48d9d3e60bb4224b9838f824215ccc3b6d7695d8..008c3947eace913d4a5bb75ea3cdcee7fa7c88b9 100644 (file)
@@ -23,7 +23,7 @@
 //                                                                       //
 ///////////////////////////////////////////////////////////////////////////
 
-$nomoodlecookie = true; // session not used here
+define('NO_MOODLE_COOKIES', true); // session not used here
 require '../../../config.php';
 
 $id = required_param('id', PARAM_INT); // course id
index dcf1356d1c583b9900fbfd090becb0301c410e09..0a7cb9d1ac06be3b5ce598d251543de45267cffd 100644 (file)
--- a/index.php
+++ b/index.php
@@ -85,8 +85,8 @@
     }
 
 
-    if (get_moodle_cookie() == '') {
-        set_moodle_cookie('nobody');   // To help search for cookies on login page
+    if ($SESSION->get_moodle_cookie() == '') {
+        $SESSION->set_moodle_cookie('nobody');   // To help search for cookies on login page
     }
 
     if (!empty($USER->id)) {
index 67d10fa0d8b962642b36a9a7806998a634a18fc4..26f74afa6efe6cafd68cfae08409a1ab383b9c7d 100644 (file)
@@ -36,14 +36,14 @@ $string['availabledbtypes']='Available db types';
 $string['availablelangs']='List of available languages';
 $string['bypassed'] = 'Bypassed';
 $string['cannotconnecttodb'] = 'Cannot connect to db';
-$string['cannotcreatelangdir'] = 'Cannot create lang dir.';
-$string['cannotcreatetempdir'] = 'Cannot create temp dir.';
-$string['cannotdownloadcomponents'] = 'Cannot download components.';
-$string['cannotdownloadzipfile'] = 'Cannot download ZIP file.';
-$string['cannotfindcomponent'] = 'Cannot find component.';
-$string['cannotsavemd5file'] = 'Cannot save md5 file.';
-$string['cannotsavezipfile'] = 'Cannot save ZIP file.';
-$string['cannotunzipfile'] = 'Cannot unzip file.';
+$string['cannotcreatelangdir'] = 'Cannot create lang directory';
+$string['cannotcreatetempdir'] = 'Cannot create temp directory';
+$string['cannotdownloadcomponents'] = 'Cannot download components';
+$string['cannotdownloadzipfile'] = 'Cannot download ZIP file';
+$string['cannotfindcomponent'] = 'Cannot find component';
+$string['cannotsavemd5file'] = 'Cannot save md5 file';
+$string['cannotsavezipfile'] = 'Cannot save ZIP file';
+$string['cannotunzipfile'] = 'Cannot unzip file';
 $string['caution'] = 'Caution';
 $string['check'] = 'Check';
 $string['checkingphpsettings']='Checking PHP Settings';
@@ -54,7 +54,7 @@ $string['closewindow'] = 'Close this window';
 $string['compatibilitysettings'] = 'Checking your PHP settings ...';
 $string['compatibilitysettingshead'] = 'Checking your PHP settings ...';
 $string['compatibilitysettingssub'] = 'Your server should pass all these tests to make Moodle run properly';
-$string['componentisuptodate'] = 'Component is up to date.';
+$string['componentisuptodate'] = 'Component is up-to-date';
 $string['configfilecreated'] = 'Configuration file successfully created';
 $string['configfiledoesnotexist'] = 'Configuration file does not exist !!!';
 $string['configfilenotwritten'] = 'The installer script was not able to automatically create a config.php file containing your chosen settings, probably because the Moodle directory is not writeable. You can manually copy the following code into a file named config.php within the root directory of Moodle.';
@@ -215,7 +215,7 @@ $string['dirroot'] = 'Moodle Directory';
 $string['dirrooterror'] = 'The \'Moodle Directory\' setting seems to be incorrect - we can\'t find a Moodle installation there. The value below has been reset.';
 $string['disagreelicense'] = 'Upgrade cannot proceed due to disagreement to GPL!';
 $string['download'] = 'Download';
-$string['downloadedfilecheckfailed'] = 'Downloaded file check failed.';
+$string['downloadedfilecheckfailed'] = 'Downloaded file check failed';
 $string['downloadlanguagebutton'] = 'Download the &quot;$a&quot; language pack';
 $string['downloadlanguagehead'] = 'Download language pack';
 $string['downloadlanguagenotneeded'] = 'You may continue the installation process using the default language pack, \"$a\".';
@@ -363,7 +363,7 @@ $string['phpversionhelp'] = '<p>Moodle requires a PHP version of at least 4.3.0
 <p>You must upgrade PHP or move to a host with a newer version of PHP!<br/>
 (In case of 5.0.x you could also downgrade to 4.4.x version)</p>';
 $string['postgres7'] = 'PostgreSQL (postgres7)';
-$string['prefixcannotbeempty'] = '<p>Error: database table prefix can not be empty ($a)</p>
+$string['prefixcannotbeempty'] = '<p>Error: database table prefix cannot be empty ($a)</p>
 <p>The site administrator must fix this problem.</p>';
 $string['prefixtoolong'] = '<p>Error: database table prefix is too long ($a->dbfamily)</p>
 <p>The site administrator must fix this problem. Maximum length for table prefixes in $a->dbfamily is $a->maxlength characters.</p>';
@@ -469,9 +469,9 @@ $string['welcomep60'] = 'The following pages will lead you through some easy to
 $string['welcomep70'] = 'Click the \"Next\" button below to continue with the set up of <strong>Moodle</strong>.';
 $string['welcometext']='---Welcome to moodle commandline installer---';
 $string['writetoconfigfilefaild'] = 'Error: Write to config file failed ';
-$string['wrongdestpath'] = 'Wrong destination path.';
-$string['wrongsourcebase'] = 'Wrong source URL base.';
-$string['wrongzipfilename'] = 'Wrong ZIP filename.';
+$string['wrongdestpath'] = 'Wrong destination path';
+$string['wrongsourcebase'] = 'Wrong source URL base';
+$string['wrongzipfilename'] = 'Wrong ZIP file name';
 $string['wwwroot'] = 'Web address';
 $string['wwwrooterror'] = 'The \'Web Address\' does not appear to be valid - this Moodle installation doesn\'t appear to be there. The value below has been reset.';
 $string['xmlrpcrecommended'] = 'Installing the optional xmlrpc extension is useful for Moodle Networking functionality.';
index 0dc84730148440bf4a39d64f709eeaf57dc5742d..060e4c0d46ca043b9bba1ce66ff8d0e5a284b366 100644 (file)
@@ -12,4 +12,14 @@ $string['go'] = 'Go!';
 $string['bytes'] = ' bytes (0 stands for no limits)';
 $string['searchmoodle'] = 'Search Moodle';
 $string['usemoodleroot'] = 'Use moodle root for external converters';
+$string['wordhandling'] = 'Microsoft Word handling';
+$string['pdfhandling'] = 'Acrobat PDF handling';
+$string['handlingfor'] = 'Extra handling for';
+$string['searchdiscovery'] = 'Searchable items discovery';
+$string['configtypetotxtcmd'] = 'Converter\'s command line';
+$string['configtypetotxtenv'] = 'Environment define for converter';
+$string['modulessearchswitches'] = 'Indexer activation for modules';
+$string['blockssearchswitches'] = 'Indexer activation for blocks';
+$string['nosearchablemodules'] = 'No searchable modules';
+$string['nosearchableblocks'] = 'No searchable blocks';
 ?>
\ No newline at end of file
diff --git a/lib/adodb/adodb-time.zip b/lib/adodb/adodb-time.zip
deleted file mode 100644 (file)
index d3239db..0000000
Binary files a/lib/adodb/adodb-time.zip and /dev/null differ
diff --git a/lib/adodb/adodb-xmlschema-0.0.1-snap20030511/docs/media/bg_left.png b/lib/adodb/adodb-xmlschema-0.0.1-snap20030511/docs/media/bg_left.png
deleted file mode 100644 (file)
index 19fdf05..0000000
Binary files a/lib/adodb/adodb-xmlschema-0.0.1-snap20030511/docs/media/bg_left.png and /dev/null differ
diff --git a/lib/adodb/adodb-xmlschema.zip b/lib/adodb/adodb-xmlschema.zip
deleted file mode 100644 (file)
index 14e6a8f..0000000
Binary files a/lib/adodb/adodb-xmlschema.zip and /dev/null differ
diff --git a/lib/adodb/cute_icons_for_site/adodb.gif b/lib/adodb/cute_icons_for_site/adodb.gif
deleted file mode 100644 (file)
index c5e8dfc..0000000
Binary files a/lib/adodb/cute_icons_for_site/adodb.gif and /dev/null differ
diff --git a/lib/adodb/cute_icons_for_site/adodb.png b/lib/adodb/cute_icons_for_site/adodb.png
deleted file mode 100644 (file)
index 339dd76..0000000
Binary files a/lib/adodb/cute_icons_for_site/adodb.png and /dev/null differ
diff --git a/lib/adodb/cute_icons_for_site/adodb2.gif b/lib/adodb/cute_icons_for_site/adodb2.gif
deleted file mode 100644 (file)
index f12ae20..0000000
Binary files a/lib/adodb/cute_icons_for_site/adodb2.gif and /dev/null differ
diff --git a/lib/adodb/cute_icons_for_site/adodb2.png b/lib/adodb/cute_icons_for_site/adodb2.png
deleted file mode 100644 (file)
index ab18515..0000000
Binary files a/lib/adodb/cute_icons_for_site/adodb2.png and /dev/null differ
diff --git a/lib/adodb/tests/tmssql.php b/lib/adodb/tests/tmssql.php
deleted file mode 100644 (file)
index 69bcb9e..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php\r
-\r
-require_once('../../../config.php');\r
-require_once('../../weblib.php');\r
-\r
-add_to_log(0, 'adodb', 'intrusion attempt', 'lib/adodb/tests/tmssql.php');\r
-trigger_error('SECURITY WARNING: intrusion attempt against lib/tests/tmssql.php from ' . getremoteaddr());\r
-error('SECURITY WARNING: logged intrusion attempt against lib/adodb/tests/tmssql.php');\r
-\r
-?>
\ No newline at end of file
index a394d7786c01d63ec0e86d2e213ad4946e4d0a9f..e44115f1edf1c77ddb311d7d494fdd9e88a8d9f6 100644 (file)
@@ -84,9 +84,9 @@
 //                     $a = new stdClass();
 //                     $a->url = 'http://download.moodle.org/lang16/es_utf8.zip';
 //                     $a->dest= $CFG->dataroot.'/lang';
-//                     error(get_string($cd->get_error(), 'error', $a));
+//                     print_error($cd->get_error(), 'error', '', $a);
 //                 } else {
-//                     error(get_string($cd->get_error(), 'error'));
+//                     print_error($cd->get_error(), 'error');
 //                 }
 //                 break;
 //             case COMPONENT_UPTODATE:
diff --git a/lib/cookieless.php b/lib/cookieless.php
deleted file mode 100644 (file)
index e7ca80b..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-<?php  // $Id$
-/**
-* Enable cookieless sessions by including $CFG->usesid=true;
-* in config.php.
-* Based on code from php manual by Richard at postamble.co.uk
-* Attempts to use cookies if cookies not present then uses session ids attached to all urls and forms to pass session id from page to page.
-* If site is open to google, google is given guest access as usual and there are no sessions. No session ids will be attached to urls for googlebot.
-* This doesn't require trans_sid to be turned on but this is recommended for better performance
-* you should put :
-* session.use_trans_sid = 1 
-* in your php.ini file and make sure that you don't have a line like this in your php.ini
-* session.use_only_cookies = 1
-* @author Richard at postamble.co.uk and Jamie Pratt
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-*/
-/**
-* You won't call this function directly. This function is used to process 
-* text buffered by php in an output buffer. All output is run through this function 
-* before it is ouput.
-* @param string $buffer is the output sent from php
-* @return string the output sent to the browser
-*/
-function sid_ob_rewrite($buffer){
-    $replacements = array(
-        '/(<\s*(a|link|script|frame|area)\s[^>]*(href|src)\s*=\s*")([^"]*)(")/i',
-        '/(<\s*(a|link|script|frame|area)\s[^>]*(href|src)\s*=\s*\')([^\']*)(\')/i');
-    $buffer = preg_replace_callback($replacements, "sid_rewrite_link_tag", $buffer);
-    $buffer = preg_replace('/<form\s[^>]*>/i',
-        '\0<input type="hidden" name="' . session_name() . '" value="' . session_id() . '"/>', $buffer);
-    
-      return $buffer;
-}
-/**
-* You won't call this function directly. This function is used to process 
-* text buffered by php in an output buffer. All output is run through this function 
-* before it is ouput.
-* This function only processes absolute urls, it is used when we decide that 
-* php is processing other urls itself but needs some help with internal absolute urls still.
-* @param string $buffer is the output sent from php
-* @return string the output sent to the browser
-*/
-function sid_ob_rewrite_absolute($buffer){
-    $replacements = array(
-        '/(<\s*(a|link|script|frame|area)\s[^>]*(href|src)\s*=\s*")((?:http|https)[^"]*)(")/i',
-        '/(<\s*(a|link|script|frame|area)\s[^>]*(href|src)\s*=\s*\')((?:http|https)[^\']*)(\')/i');
-    $buffer = preg_replace_callback($replacements, "sid_rewrite_link_tag", $buffer);
-    $buffer = preg_replace('/<form\s[^>]*>/i',
-        '\0<input type="hidden" name="' . session_name() . '" value="' . session_id() . '"/>', $buffer);
-    return $buffer;
-}
-/**
-* A function to process link, a and script tags found 
-* by preg_replace_callback in {@link sid_ob_rewrite($buffer)}.
-*/
-function sid_rewrite_link_tag($matches){
-    $url = $matches[4];
-    $url=sid_process_url($url);
-    return $matches[1]. $url.$matches[5];
-}
-/**
-* You can call this function directly. This function is used to process 
-* urls to add a moodle session id to the url for internal links.
-* @param string $url is a url
-* @return string the processed url
-*/
-function sid_process_url($url) {
-    global $CFG;
-    if ((preg_match('/^(http|https):/i', $url)) // absolute url
-        &&  ((stripos($url, $CFG->wwwroot)!==0) && stripos($url, $CFG->httpswwwroot)!==0)) { // and not local one
-        return $url; //don't attach sessid to non local urls
-    }
-    if ($url[0]=='#' || (stripos($url, 'javascript:')===0)) {
-        return $url; //don't attach sessid to anchors
-    }
-    if (strpos($url, session_name())!==FALSE)
-    {
-        return $url; //don't attach sessid to url that already has one sessid
-    }
-    if (strpos($url, "?")===FALSE){
-        $append="?".strip_tags(session_name() . '=' . session_id() );
-    }    else {
-        $append="&amp;".strip_tags(session_name() . '=' . session_id() );
-    }
-    //put sessid before any anchor
-    $p = strpos($url, "#");
-    if($p!==FALSE){
-        $anch = substr($url, $p);
-        $url = substr($url, 0, $p).$append.$anch ;
-    } else  {
-        $url .= $append ;
-    }
-    return $url;    
-}
-
-
-/**
-* Call this function before there has been any output to the browser to
-* buffer output and add session ids to all internal links.
-*/
-function sid_start_ob(){
-    global $CFG;
-    //don't attach sess id for bots
-
-    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
-        if (!empty($CFG->opentogoogle)) {
-            if (strpos($_SERVER['HTTP_USER_AGENT'], 'Googlebot') !== false ) {
-                @ini_set('session.use_trans_sid', '0'); // try and turn off trans_sid
-                $CFG->usesid=false;
-                return;
-            }
-            if (strpos($_SERVER['HTTP_USER_AGENT'], 'google.com') !== false ) {
-                @ini_set('session.use_trans_sid', '0'); // try and turn off trans_sid
-                $CFG->usesid=false;
-                return;
-            }
-        }
-        if (strpos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') !== false ) {
-            @ini_set('session.use_trans_sid', '0'); // try and turn off trans_sid
-            $CFG->usesid=false;
-            return;
-        }
-    }
-    @ini_set('session.use_trans_sid', '1'); // try and turn on trans_sid
-    if (ini_get('session.use_trans_sid')!=0 ){ 
-        // use trans sid as its available
-        ini_set('url_rewriter.tags', 'a=href,area=href,script=src,link=href,' 
-            . 'frame=src,form=fakeentry');
-        ob_start('sid_ob_rewrite_absolute');
-    }else{
-        //rewrite all links ourselves
-        ob_start('sid_ob_rewrite');
-    }
-}
-?>
diff --git a/lib/db/mysql.php b/lib/db/mysql.php
deleted file mode 100644 (file)
index 3e27b02..0000000
+++ /dev/null
@@ -1,2337 +0,0 @@
-<?PHP  //$Id$
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-//
-// This file is tailored to MySQL
-
-function main_upgrade($oldversion=0) {
-
-    global $CFG, $THEME, $db;
-
-    $result = true;
-
-    if ($oldversion == 0) {
-        execute_sql("
-          CREATE TABLE `config` (
-            `id` int(10) unsigned NOT NULL auto_increment,
-            `name` varchar(255) NOT NULL default '',
-            `value` varchar(255) NOT NULL default '',
-            PRIMARY KEY  (`id`),
-            UNIQUE KEY `name` (`name`)
-          ) COMMENT='Moodle configuration variables';");
-        notify("Created a new table 'config' to hold configuration data");
-    }
-    if ($oldversion < 2002073100) {
-        execute_sql(" DELETE FROM `modules` WHERE `name` = 'chat' ");
-    }
-    if ($oldversion < 2002080200) {
-        execute_sql(" ALTER TABLE `modules` DROP `fullname`  ");
-        execute_sql(" ALTER TABLE `modules` DROP `search`  ");
-    }
-    if ($oldversion < 2002080300) {
-        execute_sql(" ALTER TABLE `log_display` CHANGE `table` `mtable` VARCHAR( 20 ) NOT NULL ");
-        execute_sql(" ALTER TABLE `user_teachers` CHANGE `authority` `authority` TINYINT( 3 ) DEFAULT '3' NOT NULL ");
-    }
-    if ($oldversion < 2002082100) {
-        execute_sql(" ALTER TABLE `course` CHANGE `guest` `guest` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL ");
-    }
-    if ($oldversion < 2002082101) {
-        execute_sql(" ALTER TABLE `user` ADD `maildisplay` TINYINT(2) UNSIGNED DEFAULT '2' NOT NULL AFTER `mailformat` ");
-    }
-    if ($oldversion < 2002090100) {
-        execute_sql(" ALTER TABLE `course_sections` CHANGE `summary` `summary` TEXT NOT NULL ");
-    }
-    if ($oldversion < 2002090701) {
-        execute_sql(" ALTER TABLE `user_teachers` CHANGE `authority` `authority` TINYINT( 10 ) DEFAULT '3' NOT NULL ");
-        execute_sql(" ALTER TABLE `user_teachers` ADD `role` VARCHAR(40) NOT NULL AFTER `authority` ");
-    }
-    if ($oldversion < 2002090800) {
-        execute_sql(" ALTER TABLE `course` ADD `teachers` VARCHAR( 100 ) DEFAULT 'Teachers' NOT NULL AFTER `teacher` ");
-        execute_sql(" ALTER TABLE `course` ADD `students` VARCHAR( 100 ) DEFAULT 'Students' NOT NULL AFTER `student` ");
-    }
-    if ($oldversion < 2002091000) {
-        execute_sql(" ALTER TABLE `user` CHANGE `personality` `secret` VARCHAR( 15 ) NOT NULL DEFAULT ''  ");
-    }
-    if ($oldversion < 2002091400) {
-        execute_sql(" ALTER TABLE `user` ADD `lang` VARCHAR( 3 ) DEFAULT 'en' NOT NULL AFTER `country`  ");
-    }
-    if ($oldversion < 2002091900) {
-        notify("Most Moodle configuration variables have been moved to the database and can now be edited via the admin page.");
-        notify("Although it is not vital that you do so, you might want to edit <U>config.php</U> and remove all the unused settings (except the database, URL and directory definitions).  See <U>config-dist.php</U> for an example of how your new slim config.php should look.");
-    }
-    if ($oldversion < 2002092000) {
-        execute_sql(" ALTER TABLE `user` CHANGE `lang` `lang` VARCHAR(5) DEFAULT 'en' NOT NULL  ");
-    }
-    if ($oldversion < 2002092100) {
-        execute_sql(" ALTER TABLE `user` ADD `deleted` TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL AFTER `confirmed` ");
-    }
-    if ($oldversion < 2002101001) {
-        execute_sql(" ALTER TABLE `user` ADD `htmleditor` TINYINT(1) UNSIGNED DEFAULT '1' NOT NULL AFTER `maildisplay` ");
-    }
-    if ($oldversion < 2002101701) {
-        execute_sql(" ALTER TABLE `reading` RENAME `resource` ");  // Small line with big consequences!
-        execute_sql(" DELETE FROM `log_display` WHERE module = 'reading'");
-        execute_sql(" INSERT INTO log_display (module, action, mtable, field) VALUES ('resource', 'view', 'resource', 'name') ");
-        execute_sql(" UPDATE log SET module = 'resource' WHERE module = 'reading' ");
-        execute_sql(" UPDATE modules SET name = 'resource' WHERE name = 'reading' ");
-    }
-
-    if ($oldversion < 2002102503) {
-        execute_sql(" ALTER TABLE `course` ADD `modinfo` TEXT NOT NULL AFTER `format` ");
-        require_once("$CFG->dirroot/mod/forum/lib.php");
-        require_once("$CFG->dirroot/course/lib.php");
-
-        if (! $module = get_record("modules", "name", "forum")) {
-            notify("Could not find forum module!!");
-            return false;
-        }
-
-        // First upgrade the site forums
-        if ($site = get_site()) {
-            print_heading("Making News forums editable for main site (moving to section 1)...");
-            if ($news = forum_get_course_forum($site->id, "news")) {
-                $mod->course = $site->id;
-                $mod->module = $module->id;
-                $mod->instance = $news->id;
-                $mod->section = 1;
-                if (! $mod->coursemodule = add_course_module($mod) ) {
-                    notify("Could not add a new course module to the site");
-                    return false;
-                }
-                if (! $sectionid = add_mod_to_section($mod) ) {
-                    notify("Could not add the new course module to that section");
-                    return false;
-                }
-                if (! set_field("course_modules", "section", $sectionid, "id", $mod->coursemodule)) {
-                    notify("Could not update the course module with the correct section");
-                    return false;
-                }
-            }
-        }
-
-
-        // Now upgrade the courses.
-        if ($courses = get_records_sql("SELECT * FROM course WHERE category > 0")) {
-            print_heading("Making News and Social forums editable for each course (moving to section 0)...");
-            foreach ($courses as $course) {
-                if ($course->format == "social") {  // we won't touch them
-                    continue;
-                }
-                if ($news = forum_get_course_forum($course->id, "news")) {
-                    $mod->course = $course->id;
-                    $mod->module = $module->id;
-                    $mod->instance = $news->id;
-                    $mod->section = 0;
-                    if (! $mod->coursemodule = add_course_module($mod) ) {
-                        notify("Could not add a new course module to the course '" . format_string($course->fullname) . "'");
-                        return false;
-                    }
-                    if (! $sectionid = add_mod_to_section($mod) ) {
-                        notify("Could not add the new course module to that section");
-                        return false;
-                    }
-                    if (! set_field("course_modules", "section", $sectionid, "id", $mod->coursemodule)) {
-                        notify("Could not update the course module with the correct section");
-                        return false;
-                    }
-                }
-                if ($social = forum_get_course_forum($course->id, "social")) {
-                    $mod->course = $course->id;
-                    $mod->module = $module->id;
-                    $mod->instance = $social->id;
-                    $mod->section = 0;
-                    if (! $mod->coursemodule = add_course_module($mod) ) {
-                        notify("Could not add a new course module to the course '" . format_string($course->fullname) . "'");
-                        return false;
-                    }
-                    if (! $sectionid = add_mod_to_section($mod) ) {
-                        notify("Could not add the new course module to that section");
-                        return false;
-                    }
-                    if (! set_field("course_modules", "section", $sectionid, "id", $mod->coursemodule)) {
-                        notify("Could not update the course module with the correct section");
-                        return false;
-                    }
-                }
-            }
-        }
-    }
-
-    if ($oldversion < 2002111003) {
-        execute_sql(" ALTER TABLE `course` ADD `modinfo` TEXT NOT NULL AFTER `format` ");
-        if ($courses = get_records_sql("SELECT * FROM course")) {
-            require_once("$CFG->dirroot/course/lib.php");
-            foreach ($courses as $course) {
-
-                $modinfo = serialize(get_array_of_activities($course->id));
-
-                if (!set_field("course", "modinfo", $modinfo, "id", $course->id)) {
-                    notify("Could not cache module information for course '" . format_string($course->fullname) . "'!");
-                }
-            }
-        }
-    }
-
-    if ($oldversion < 2002111100) {
-        print_simple_box_start("CENTER", "", "#FFCCCC");
-        echo "<FONT SIZE=+1>";
-        echo "<P>Changes have been made to all built-in themes, to add the new popup navigation menu.";
-        echo "<P>If you have customised themes, you will need to edit theme/xxxx/header.html as follows:";
-        echo "<UL><LI>Change anywhere it says <B>$"."button</B> to say <B>$"."menu</B>";
-        echo "<LI>Add <B>$"."button</B> elsewhere (eg at the end of the navigation bar)</UL>";
-        echo "<P>See the standard themes for examples, eg: theme/standard/header.html";
-        print_simple_box_end();
-    }
-
-    if ($oldversion < 2002111200) {
-        execute_sql(" ALTER TABLE `course` ADD `showrecent` TINYINT(5) UNSIGNED DEFAULT '1' NOT NULL AFTER `numsections` ");
-    }
-
-    if ($oldversion < 2002111400) {
-    // Rebuild all course caches, because some may not be done in new installs (eg site page)
-        if ($courses = get_records_sql("SELECT * FROM course")) {
-            require_once("$CFG->dirroot/course/lib.php");
-            foreach ($courses as $course) {
-
-                $modinfo = serialize(get_array_of_activities($course->id));
-
-                if (!set_field("course", "modinfo", $modinfo, "id", $course->id)) {
-                    notify("Could not cache module information for course '" . format_string($course->fullname) . "'!");
-                }
-            }
-        }
-    }
-
-    if ($oldversion < 2002112000) {
-        set_config("guestloginbutton", 1);
-    }
-
-    if ($oldversion < 2002122300) {
-        execute_sql("ALTER TABLE `log` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
-        execute_sql("ALTER TABLE `user_admins` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
-        execute_sql("ALTER TABLE `user_students` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
-        execute_sql("ALTER TABLE `user_teachers` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
-        execute_sql("ALTER TABLE `user_students` CHANGE `start` `timestart` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
-        execute_sql("ALTER TABLE `user_students` CHANGE `end` `timeend` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
-    }
-
-    if ($oldversion < 2002122700) {
-        if (! record_exists("log_display", "module", "user", "action", "view")) {
-            execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('user', 'view', 'user', 'CONCAT(firstname,' ',lastname)') ");
-        }
-    }
-    if ($oldversion < 2003010101) {
-        delete_records("log_display", "module", "user");
-        $new->module = "user";
-        $new->action = "view";
-        $new->mtable = "user";
-        $new->field  = "CONCAT(firstname,\" \",lastname)";
-        insert_record("log_display", $new);
-
-        delete_records("log_display", "module", "course");
-        $new->module = "course";
-        $new->action = "view";
-        $new->mtable = "course";
-        $new->field  = "fullname";
-        insert_record("log_display", $new);
-        $new->action = "update";
-        insert_record("log_display", $new);
-        $new->action = "enrol";
-        insert_record("log_display", $new);
-    }
-
-    if ($oldversion < 2003012200) {
-        // execute_sql(" ALTER TABLE `log_display` CHANGE `module` `module` VARCHAR( 20 ) NOT NULL ");
-        // Commented out - see below where it's done properly
-    }
-
-    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) {
-        // 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
-        execute_sql(" ALTER TABLE `{$CFG->prefix}log` ADD INDEX(course) ");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}log` ADD INDEX(userid) ");
-    }
-
-    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 ($files = get_directory_list($CFG->dataroot)) {
-            echo "Attempting to update permissions for all files... ignore any errors.";
-            foreach ($files as $file) {
-                echo "$CFG->dataroot/$file<br />";
-                @chmod("$CFG->dataroot/$file", $CFG->directorypermissions);
-            }
-        }
-    }
-
-    if ($oldversion < 2003042400) {
-    // Rebuild all course caches, because of changes to do with visible variable
-        if ($courses = get_records_sql("SELECT * FROM {$CFG->prefix}course")) {
-            require_once("$CFG->dirroot/course/lib.php");
-            foreach ($courses as $course) {
-                $modinfo = serialize(get_array_of_activities($course->id));
-
-                if (!set_field("course", "modinfo", $modinfo, "id", $course->id)) {
-                    notify("Could not cache module information for course '" . format_string($course->fullname) . "'!");
-                }
-            }
-        }
-    }
-
-    if ($oldversion < 2003042500) {
-    //  Convert all usernames to lowercase.
-        $users = get_records_sql("SELECT id, username FROM {$CFG->prefix}user");
-        $cerrors = "";
-        $rarray = array();
-
-        foreach ($users as $user) {      // Check for possible conflicts
-            $lcname = trim(moodle_strtolower($user->username));
-            if (in_array($lcname, $rarray)) {
-                $cerrors .= $user->id."->".$lcname.'<br/>' ;
-            } else {
-                array_push($rarray,$lcname);
-            }
-        }
-
-        if ($cerrors != '') {
-            notify("Error: Cannot convert usernames to lowercase.
-                    Following usernames would overlap (id->username):<br/> $cerrors .
-                    Please resolve overlapping errors.");
-            $result = false;
-        }
-
-        $cerrors = "";
-        echo "Checking userdatabase:<br />";
-        foreach ($users as $user) {
-            $lcname = trim(moodle_strtolower($user->username));
-            if ($lcname != $user->username) {
-                $convert = set_field("user" , "username" , $lcname, "id", $user->id);
-                if (!$convert) {
-                    if ($cerrors){
-                       $cerrors .= ", ";
-                    }
-                    $cerrors .= $item;
-                } else {
-                    echo ".";
-                }
-            }
-        }
-        if ($cerrors != '') {
-            notify("There were errors when converting following usernames to lowercase.
-                   '$cerrors' . Sorry, but you will need to fix your database by hand.");
-            $result = false;
-        }
-    }
-
-    if ($oldversion < 2003042600) {
-        /// Some more indexes - we need all the help we can get on the logs
-        //execute_sql(" ALTER TABLE `{$CFG->prefix}log` ADD INDEX(module) ");
-        //execute_sql(" ALTER TABLE `{$CFG->prefix}log` ADD INDEX(action) ");
-    }
-
-    if ($oldversion < 2003042700) {
-        /// Changing to multiple indexes
-        execute_sql(" ALTER TABLE `{$CFG->prefix}log` DROP INDEX module ", false);
-        execute_sql(" ALTER TABLE `{$CFG->prefix}log` DROP INDEX action ", false);
-        execute_sql(" ALTER TABLE `{$CFG->prefix}log` DROP INDEX course ", false);
-        execute_sql(" ALTER TABLE `{$CFG->prefix}log` DROP INDEX userid ", false);
-        execute_sql(" ALTER TABLE `{$CFG->prefix}log` ADD INDEX coursemoduleaction (course,module,action) ");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}log` ADD INDEX courseuserid (course,userid) ");
-    }
-
-    if ($oldversion < 2003042801) {
-        execute_sql("CREATE TABLE `{$CFG->prefix}course_display` (
-                        `id` int(10) unsigned NOT NULL auto_increment,
-                        `course` int(10) unsigned NOT NULL default '0',
-                        `userid` int(10) unsigned NOT NULL default '0',
-                        `display` int(10) NOT NULL default '0',
-                        PRIMARY KEY  (`id`),
-                        UNIQUE KEY `id` (`id`),
-                        KEY `courseuserid` (course,userid)
-                     ) TYPE=MyISAM COMMENT='Stores info about how to display the course'");
-    }
-
-    if ($oldversion < 2003050400) {
-        table_column("course_sections", "", "visible", "integer", "1", "unsigned", "1", "", "");
-    }
-
-    if ($oldversion < 2003050900) {
-        table_column("modules", "", "visible", "integer", "1", "unsigned", "1", "", "");
-    }
-
-    if ($oldversion < 2003050902) {
-        if (get_records("modules", "name", "pgassignment")) {
-            print_simple_box("Note: the pgassignment module has been removed (it will be replaced later by the workshop module).  Go to the new 'Manage Modules' page and DELETE IT from your system", "center", "50%", "$THEME->cellheading", "20", "noticebox");
-        }
-    }
-
-    if ($oldversion < 2003051600) {
-        print_simple_box("Thanks for upgrading!<p>There are many changes since the last release.  Please read the release notes carefully.  If you are using CUSTOM themes you will need to edit them.  You will also need to check your site's config.php file.", "center", "50%", "$THEME->cellheading", "20", "noticebox");
-    }
-
-    if ($oldversion < 2003052300) {
-        table_column("user", "", "autosubscribe", "integer", "1", "unsigned", "1", "", "htmleditor");
-    }
-
-    if ($oldversion < 2003072100) {
-        table_column("course", "", "visible", "integer", "1", "unsigned", "1", "", "marker");
-    }
-
-    if ($oldversion < 2003072101) {
-        table_column("course_sections", "sequence", "sequence", "text", "", "", "", "", "");
-    }
-
-    if ($oldversion < 2003072800) {
-        print_simple_box("The following database index improves performance, but can be quite large - if you are upgrading and you have problems with a limited quota you may want to delete this index later from the '{$CFG->prefix}log' table in your database", "center", "50%", "$THEME->cellheading", "20", "noticebox");
-        flush();
-        execute_sql(" ALTER TABLE `{$CFG->prefix}log` ADD INDEX timecoursemoduleaction (time,course,module,action) ");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}user_students` ADD INDEX courseuserid (course,userid) ");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}user_teachers` ADD INDEX courseuserid (course,userid) ");
-    }
-
-    if ($oldversion < 2003072803) {
-        table_column("course_categories", "", "description", "text", "", "", "");
-        table_column("course_categories", "", "parent", "integer", "10", "unsigned");
-        table_column("course_categories", "", "sortorder", "integer", "10", "unsigned");
-        table_column("course_categories", "", "courseorder", "text", "", "", "");
-        table_column("course_categories", "", "visible", "integer", "1", "unsigned", "1");
-        table_column("course_categories", "", "timemodified", "integer", "10", "unsigned");
-    }
-
-    if ($oldversion < 2003080400) {
-        table_column("course_categories", "courseorder", "courseorder", "integer", "10", "unsigned");
-        table_column("course", "", "sortorder", "integer", "10", "unsigned", "0", "", "category");
-    }
-
-    if ($oldversion < 2003080700) {
-        notify("Cleaning up categories and course ordering...");
-        fix_course_sortorder();
-    }
-
-    if ($oldversion < 2003081001) {
-        table_column("course", "format", "format", "varchar", "10", "", "topics");
-    }
-
-    if ($oldversion < 2003081500) {
-//        print_simple_box("Some important changes have been made to how course creators work.  Formerly, they could create new courses and assign teachers, and teachers could edit courses.  Now, ordinary teachers can no longer edit courses - they <b>need to be a teacher of a course AND a course creator</b>.  A new site-wide configuration variable allows you to choose whether to allow course creators to create new courses as well (by default this is off).  <p>The following update will automatically convert all your existing teachers into course creators, to maintain backward compatibility.  Make sure you look at your upgraded site carefully and understand these new changes.", "center", "50%", "$THEME->cellheading", "20", "noticebox");
-
-//        $count = 0;
-//        $errorcount = 0;
-//        if ($teachers = get_records("user_teachers")) {
-//            foreach ($teachers as $teacher) {
-//                if (! record_exists("user_coursecreators", "userid", $teacher->userid)) {
-//                    $creator = NULL;
-//                    $creator->userid = $teacher->userid;
-//                    if (!insert_record("user_coursecreators", $creator)) {
-//                        $errorcount++;
-//                    } else {
-//                        $count++;
-//                    }
-//                }
-//            }
-//        }
-//        print_simple_box("$count teachers were upgraded to course creators (with $errorcount errors)", "center", "50%", "$THEME->cellheading", "20", "noticebox");
-
-    }
-
-    if ($oldversion < 2003081501) {
-        execute_sql(" CREATE TABLE `{$CFG->prefix}scale` (
-                         `id` int(10) unsigned NOT NULL auto_increment,
-                         `courseid` int(10) unsigned NOT NULL default '0',
-                         `userid` int(10) unsigned NOT NULL default '0',
-                         `name` varchar(255) NOT NULL default '',
-                         `scale` text NOT NULL,
-                         `description` text NOT NULL,
-                         `timemodified` int(10) unsigned NOT NULL default '0',
-                         PRIMARY KEY  (id)
-                       ) TYPE=MyISAM COMMENT='Defines grading scales'");
-
-    }
-
-    if ($oldversion < 2003081503) {
-        table_column("forum", "", "scale", "integer", "10", "unsigned", "0", "", "assessed");
-        get_scales_menu(0);    // Just to force the default scale to be created
-    }
-
-    if ($oldversion < 2003081600) {
-        table_column("user_teachers", "", "editall", "integer", "1", "unsigned", "1", "", "role");
-        table_column("user_teachers", "", "timemodified", "integer", "10", "unsigned", "0", "", "editall");
-    }
-
-    if ($oldversion < 2003081900) {
-        table_column("course_categories", "courseorder", "coursecount", "integer", "10", "unsigned", "0");
-    }
-
-    if ($oldversion < 2003082001) {
-        table_column("course", "", "showgrades", "integer", "2", "unsigned", "1", "", "format");
-    }
-
-    if ($oldversion < 2003082101) {
-        execute_sql(" ALTER TABLE `{$CFG->prefix}course` ADD INDEX category (category) ");
-    }
-    if ($oldversion < 2003082702) {
-        execute_sql(" INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('course', 'user report', 'user', 'CONCAT(firstname,\" \",lastname)') ");
-    }
-
-    if ($oldversion < 2003091400) {
-        table_column("course_modules", "", "indent", "integer", "5", "unsigned", "0", "", "score");
-    }
-
-    if ($oldversion < 2003092900) {
-        table_column("course", "", "maxbytes", "integer", "10", "unsigned", "0", "", "marker");
-    }
-
-    if ($oldversion < 2003102700) {
-        table_column("user_students", "", "timeaccess", "integer", "10", "unsigned", "0", "", "time");
-        table_column("user_teachers", "", "timeaccess", "integer", "10", "unsigned", "0", "", "timemodified");
-
-        $db->debug = false;
-        $CFG->debug = 0;
-        notify("Calculating access times.  Please wait - this may take a long time on big sites...", "green");
-        flush();
-
-        if ($courses = get_records_select("course", "category > 0")) {
-            foreach ($courses as $course) {
-                notify("Processing " . format_string($course->fullname) . " ...", "green");
-                flush();
-                if ($users = get_records_select("user_teachers", "course = '$course->id'",
-                                                "id", "id, userid, timeaccess")) {
-                    foreach ($users as $user) {
-                        $loginfo = get_record_sql("SELECT id, time FROM {$CFG->prefix}log                                                                                  WHERE course = '$course->id' and userid = '$user->userid'                                                               ORDER by time DESC");
-                        if (empty($loginfo->time)) {
-                            $loginfo->time = 0;
-                        }
-                        execute_sql("UPDATE {$CFG->prefix}user_teachers                                                                                      SET timeaccess = '$loginfo->time'
-                                     WHERE userid = '$user->userid' AND course = '$course->id'", false);
-
-                    }
-                }
-
-                if ($users = get_records_select("user_students", "course = '$course->id'",
-                                                "id", "id, userid, timeaccess")) {
-                    foreach ($users as $user) {
-                        $loginfo = get_record_sql("SELECT id, time FROM {$CFG->prefix}log
-                                                   WHERE course = '$course->id' and userid = '$user->userid'
-                                                   ORDER by time DESC");
-                        if (empty($loginfo->time)) {
-                            $loginfo->time = 0;
-                        }
-                        execute_sql("UPDATE {$CFG->prefix}user_students
-                                     SET timeaccess = '$loginfo->time'
-                                     WHERE userid = '$user->userid' AND course = '$course->id'", false);
-
-                    }
-                }
-            }
-        }
-        notify("All courses complete.", "green");
-        $db->debug = true;
-    }
-
-    if ($oldversion < 2003103100) {
-        table_column("course", "", "showreports", "integer", "4", "unsigned", "0", "", "maxbytes");
-    }
-
-    if ($oldversion < 2003121600) {
-        modify_database("", "CREATE TABLE `prefix_groups` (
-                                `id` int(10) unsigned NOT NULL auto_increment,
-                                `courseid` int(10) unsigned NOT NULL default '0',
-                                `name` varchar(254) NOT NULL default '',
-                                `description` text NOT NULL,
-                                `lang` varchar(10) NOT NULL default 'en',
-                                `picture` int(10) unsigned NOT NULL default '0',
-                                `timecreated` int(10) unsigned NOT NULL default '0',
-                                `timemodified` int(10) unsigned NOT NULL default '0',
-                                PRIMARY KEY  (`id`),
-                                KEY `courseid` (`courseid`)
-                              ) TYPE=MyISAM COMMENT='Each record is a group in a course.'; ");
-
-        modify_database("", "CREATE TABLE `prefix_groups_members` (
-                                `id` int(10) unsigned NOT NULL auto_increment,
-                                `groupid` int(10) unsigned NOT NULL default '0',
-                                `userid` int(10) unsigned NOT NULL default '0',
-                                `timeadded` int(10) unsigned NOT NULL default '0',
-                                PRIMARY KEY  (`id`),
-                                KEY `groupid` (`groupid`)
-                              ) TYPE=MyISAM COMMENT='Lists memberships of users in groups'; ");
-    }
-
-    if ($oldversion < 2003121800) {
-        table_column("course", "modinfo", "modinfo", "longtext", "", "", "");
-    }
-
-    if ($oldversion < 2003122600) {
-        table_column("course", "", "groupmode", "integer", "4", "unsigned", "0", "", "showreports");
-        table_column("course", "", "groupmodeforce", "integer", "4", "unsigned", "0", "", "groupmode");
-    }
-
-    if ($oldversion < 2004010900) {
-        table_column("course_modules", "", "groupmode", "integer", "4", "unsigned", "0", "", "visible");
-    }
-
-    if ($oldversion < 2004011700) {
-        modify_database("", "CREATE TABLE `prefix_event` (
-                              `id` int(10) unsigned NOT NULL auto_increment,
-                              `name` varchar(255) NOT NULL default '',
-                              `description` text NOT NULL,
-                              `courseid` int(10) unsigned NOT NULL default '0',
-                              `groupid` int(10) unsigned NOT NULL default '0',
-                              `userid` int(10) unsigned NOT NULL default '0',
-                              `modulename` varchar(20) NOT NULL default '',
-                              `instance` int(10) unsigned NOT NULL default '0',
-                              `eventtype` varchar(20) NOT NULL default '',
-                              `timestart` int(10) unsigned NOT NULL default '0',
-                              `timeduration` int(10) unsigned NOT NULL default '0',
-                              `timemodified` int(10) unsigned NOT NULL default '0',
-                              PRIMARY KEY  (`id`),
-                              UNIQUE KEY `id` (`id`),
-                              KEY `courseid` (`courseid`),
-                              KEY `userid` (`userid`)
-                            ) TYPE=MyISAM COMMENT='For everything with a time associated to it'; ");
-    }
-
-    if ($oldversion < 2004012800) {
-        modify_database("", "CREATE TABLE `prefix_user_preferences` (
-                              `id` int(10) unsigned NOT NULL auto_increment,
-                              `userid` int(10) unsigned NOT NULL default '0',
-                              `name` varchar(50) NOT NULL default '',
-                              `value` varchar(255) NOT NULL default '',
-                              PRIMARY KEY  (`id`),
-                              UNIQUE KEY `id` (`id`),
-                              KEY `useridname` (userid,name)
-                            ) TYPE=MyISAM COMMENT='Allows modules to store arbitrary user preferences'; ");
-    }
-
-    if ($oldversion < 2004012900) {
-        table_column("config", "value", "value", "text", "", "", "");
-    }
-
-    if ($oldversion < 2004013101) {
-        table_column("log", "", "cmid", "integer", "10", "unsigned", "0", "", "module");
-        set_config("upgrade", "logs");
-    }
-
-    if ($oldversion < 2004020900) {
-        table_column("course", "", "lang", "varchar", "5", "", "", "", "groupmodeforce");
-    }
-
-    if ($oldversion < 2004020903) {
-        modify_database("", "CREATE TABLE `prefix_cache_text` (
-                                `id` int(10) unsigned NOT NULL auto_increment,
-                                `md5key` varchar(32) NOT NULL default '',
-                                `formattedtext` longtext NOT NULL,
-                                `timemodified` int(10) unsigned NOT NULL default '0',
-                                PRIMARY KEY  (`id`),
-                                KEY `md5key` (`md5key`)
-                             ) TYPE=MyISAM COMMENT='For storing temporary copies of processed texts';");
-    }
-
-    if ($oldversion < 2004021000) {
-        $textfilters = array();
-        for ($i=1; $i<=10; $i++) {
-            $variable = "textfilter$i";
-            if (!empty($CFG->$variable)) {   /// No more filters
-                if (is_readable("$CFG->dirroot/".$CFG->$variable)) {
-                    $textfilters[] = $CFG->$variable;
-                }
-            }
-        }
-        $textfilters = implode(',', $textfilters);
-        if (empty($textfilters)) {
-            $textfilters = 'mod/glossary/dynalink.php';
-        }
-        set_config('textfilters', $textfilters);
-    }
-
-    if ($oldversion < 2004021201) {
-        modify_database("", "CREATE TABLE `prefix_cache_filters` (
-                                `id` int(10) unsigned NOT NULL auto_increment,
-                                `filter` varchar(32) NOT NULL default '',
-                                `version` int(10) unsigned NOT NULL default '0',
-                                `md5key` varchar(32) NOT NULL default '',
-                                `rawtext` text NOT NULL,
-                                `timemodified` int(10) unsigned NOT NULL default '0',
-                                PRIMARY KEY  (`id`),
-                                KEY `filtermd5key` (filter,md5key)
-                              ) TYPE=MyISAM COMMENT='For keeping information about cached data';");
-    }
-
-    if ($oldversion < 2004021500) {
-        table_column("groups", "", "hidepicture", "integer", "2", "unsigned", "0", "", "picture");
-    }
-
-    if ($oldversion < 2004021700) {
-        if (!empty($CFG->textfilters)) {
-            $CFG->textfilters = str_replace("tex_filter.php", "filter.php", $CFG->textfilters);
-            $CFG->textfilters = str_replace("multilang.php", "filter.php", $CFG->textfilters);
-            $CFG->textfilters = str_replace("censor.php", "filter.php", $CFG->textfilters);
-            $CFG->textfilters = str_replace("mediaplugin.php", "filter.php", $CFG->textfilters);
-            $CFG->textfilters = str_replace("algebra_filter.php", "filter.php", $CFG->textfilters);
-            $CFG->textfilters = str_replace("dynalink.php", "filter.php", $CFG->textfilters);
-            set_config("textfilters", $CFG->textfilters);
-        }
-    }
-
-    if ($oldversion < 2004022000) {
-        table_column("user", "", "emailstop", "integer", "1", "unsigned", "0", "not null", "email");
-    }
-
-    if ($oldversion < 2004022200) {     /// Final renaming I hope.  :-)
-        if (!empty($CFG->textfilters)) {
-            $CFG->textfilters = str_replace("/filter.php", "", $CFG->textfilters);
-            $CFG->textfilters = str_replace("mod/glossary/dynalink.php", "mod/glossary", $CFG->textfilters);
-            $textfilters = explode(',', $CFG->textfilters);
-            foreach ($textfilters as $key => $textfilter) {
-                $textfilters[$key] = trim($textfilter);
-            }
-            set_config("textfilters", implode(',',$textfilters));
-        }
-    }
-
-    if ($oldversion < 2004030702) {     /// Because of the renaming of Czech language pack
-        execute_sql("UPDATE {$CFG->prefix}user SET lang = 'cs' WHERE lang = 'cz'");
-        execute_sql("UPDATE {$CFG->prefix}course SET lang = 'cs' WHERE lang = 'cz'");
-    }
-
-    if ($oldversion < 2004041800) {     /// Integrate Block System from contrib
-        table_column("course", "", "blockinfo", "varchar", "255", "", "", "not null", "modinfo");
-    }
-
-    if ($oldversion < 2004042600) {     /// Rebuild course caches for resource icons
-        //include_once("$CFG->dirroot/course/lib.php");
-        //rebuild_course_cache();
-    }
-
-    if ($oldversion < 2004042700) {     /// Increase size of lang fields
-        table_column("user",   "lang", "lang", "varchar", "10", "", "en");
-        table_column("groups", "lang", "lang", "varchar", "10", "", "");
-        table_column("course", "lang", "lang", "varchar", "10", "", "");
-    }
-
-    if ($oldversion < 2004042701) {     /// Add hiddentopics field to control hidden topics behaviour
-        table_column("course", "", "hiddentopics", "integer", "1", "unsigned", "0", "not null", "visible");
-    }
-
-    if ($oldversion < 2004042702) {     /// add a format field for the description
-        table_column("event", "", "format", "integer", "4", "unsigned", "0", "not null", "description");
-    }
-
-    if ($oldversion < 2004042900) {
-        execute_sql(" ALTER TABLE `{$CFG->prefix}course` DROP `showrecent` ");
-    }
-
-    if ($oldversion < 2004043001) {     /// Change hiddentopics to hiddensections
-        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);
-                    }
-                }
-            }
-        }
-    }
-
-    if ($oldversion < 2004052800) {     /// First version tagged "1.4 development", version.php 1.227
-        set_config('siteblocksadded', true);   /// This will be used later by the block upgrade
-    }
-
-    if ($oldversion < 2004053000) {     /// set defaults for site course
-        $site = get_site();
-        set_field('course', 'numsections', 0, 'id', $site->id);
-        set_field('course', 'groupmodeforce', 1, 'id', $site->id);
-        set_field('course', 'teacher', get_string('administrator'), 'id', $site->id);
-        set_field('course', 'teachers', get_string('administrators'), 'id', $site->id);
-        set_field('course', 'student', get_string('user'), 'id', $site->id);
-        set_field('course', 'students', get_string('users'), 'id', $site->id);
-    }
-
-    if ($oldversion < 2004060100) {
-        set_config('digestmailtime', 0);
-        table_column('user', "", 'maildigest', 'tinyint', '1', '', '0', 'not null', 'mailformat');
-    }
-
-    if ($oldversion < 2004062400) {
-        table_column('user_teachers', "", 'timeend', 'int', '10', 'unsigned', '0', 'not null', 'editall');
-        table_column('user_teachers', "", 'timestart', 'int', '10', 'unsigned', '0', 'not null', 'editall');
-    }
-
-    if ($oldversion < 2004062401) {
-        table_column('course', '', 'idnumber', 'varchar', '100', '', '', 'not null', 'shortname');
-        execute_sql('UPDATE '.$CFG->prefix.'course SET idnumber = shortname');   // By default
-    }
-
-    if ($oldversion < 2004062600) {
-        table_column('course', '', 'cost', 'varchar', '10', '', '', 'not null', 'lang');
-    }
-
-    if ($oldversion < 2004072900) {
-        table_column('course', '', 'enrolperiod', 'int', '10', 'unsigned', '0', 'not null', 'startdate');
-    }
-
-    if ($oldversion < 2004072901) {  // Fixing error in schema
-        if ($record = get_record('log_display', 'module', 'course', 'action', 'update')) {
-            delete_records('log_display', 'module', 'course', 'action', 'update');
-            insert_record('log_display', $record, false);
-        }
-    }
-
-    if ($oldversion < 2004081200) {  // Fixing version errors in some blocks
-        set_field('blocks', 'version', 2004081200, 'name', 'admin');
-        set_field('blocks', 'version', 2004081200, 'name', 'calendar_month');
-        set_field('blocks', 'version', 2004081200, 'name', 'course_list');
-    }
-
-    if ($oldversion < 2004081500) {  // Adding new "auth" field to user table to allow more flexibility
-        table_column('user', '', 'auth', 'varchar', '20', '', 'manual', 'not null', 'id');
-
-        execute_sql("UPDATE {$CFG->prefix}user SET auth = 'manual'");  // Set everyone to 'manual' to be sure
-
-        if ($admins = get_admins()) {   // Set all the NON-admins to whatever the current auth module is
-            $adminlist = array();
-            foreach ($admins as $user) {
-                $adminlist[] = $user->id; 
-            }
-            $adminlist = implode(',', $adminlist);
-            execute_sql("UPDATE {$CFG->prefix}user SET auth = '$CFG->auth' WHERE id NOT IN ($adminlist)");
-        }
-    }
-    
-    if ($oldversion < 2004082200) { // Making admins teachers on site course
-        $site = get_site();
-        $admins = get_admins();
-        foreach ($admins as $admin) {
-            add_teacher($admin->id, $site->id);
-        }
-    }
-
-    if ($oldversion < 2004082600) {
-        //update auth-fields for external users
-        // following code would not work in 1.8
-/*        include_once ($CFG->dirroot."/auth/".$CFG->auth."/lib.php");
-        if (function_exists('auth_get_userlist')) {
-            $externalusers = auth_get_userlist();
-            if (!empty($externalusers)){
-                $externalusers = '\''. implode('\',\'',$externalusers).'\'';
-                execute_sql("UPDATE {$CFG->prefix}user SET auth = '$CFG->auth' WHERE username  IN ($externalusers)");
-            }
-        }*/
-    }
-
-    if ($oldversion < 2004082900) {  // Make sure guest is "manual" too.
-        set_field('user', 'auth', 'manual', 'username', 'guest');
-    }
-    
-    /* Commented out unused guid-field code
-    if ($oldversion < 2004090300) { // Add guid-field used in user syncronization
-        table_column('user', '', 'guid', 'varchar', '128', '', '', '', 'auth');
-        execute_sql("ALTER TABLE {$CFG->prefix}user ADD INDEX authguid (auth, guid)");
-    }
-    */
-
-    if ($oldversion < 2004091900) { // modify idnumber to hold longer values
-        table_column('user', 'idnumber', 'idnumber', 'varchar', '64', '', '', '', '');
-        execute_sql("ALTER TABLE {$CFG->prefix}user DROP INDEX user_idnumber",false); // added in case of conflicts with upgrade from 14stable
-        execute_sql("ALTER TABLE {$CFG->prefix}user DROP INDEX user_auth",false); // added in case of conflicts with upgrade from 14stable
-
-        execute_sql("ALTER TABLE {$CFG->prefix}user ADD INDEX idnumber (idnumber)");
-        execute_sql("ALTER TABLE {$CFG->prefix}user ADD INDEX auth (auth)");
-    }
-
-    if ($oldversion < 2004093001) { // add new table for sessions storage
-        execute_sql(" CREATE TABLE `{$CFG->prefix}sessions` (
-                          `sesskey` char(32) NOT null,
-                          `expiry` int(11) unsigned NOT null,
-                          `expireref` varchar(64),
-                          `data` text NOT null,
-                          PRIMARY KEY (`sesskey`), 
-                          KEY (`expiry`) 
-                      ) TYPE=MyISAM COMMENT='Optional database session storage, not used by default';");
-    }
-
-    if ($oldversion < 2004111500) {  // Update any users/courses using wrongly-named lang pack
-        execute_sql("UPDATE {$CFG->prefix}user SET lang = 'mi_nt' WHERE lang = 'ma_nt'");
-        execute_sql("UPDATE {$CFG->prefix}course SET lang = 'mi_nt' WHERE lang = 'ma_nt'");
-    }
-
-    if ($oldversion < 2004111700) { // add indexes. - drop them first silently to avoid conflicts when upgrading.
-        execute_sql(" ALTER TABLE `{$CFG->prefix}course` DROP INDEX idnumber;",false);
-        execute_sql(" ALTER TABLE `{$CFG->prefix}course` DROP INDEX shortname;",false);
-        execute_sql(" ALTER TABLE `{$CFG->prefix}user_students` DROP INDEX userid;",false);
-        execute_sql(" ALTER TABLE `{$CFG->prefix}user_teachers` DROP INDEX userid;",false);
-
-        execute_sql(" ALTER TABLE `{$CFG->prefix}course` ADD INDEX idnumber (idnumber);");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}course` ADD INDEX shortname (shortname);");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}user_students` ADD INDEX userid (userid);");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}user_teachers` ADD INDEX userid (userid);");
-    }
-
-    if ($oldversion < 2004111700) {// add an index to event for timestart and timeduration. - drop them first silently to avoid conflicts when upgrading.
-        execute_sql("ALTER TABLE {$CFG->prefix}event DROP INDEX timestart;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}event DROP INDEX timeduration;",false); 
-
-        modify_database('','ALTER TABLE prefix_event ADD INDEX timestart (timestart);');
-        modify_database('','ALTER TABLE prefix_event ADD INDEX timeduration (timeduration);');
-    }
-
-    if ($oldversion < 2004111700) { //add indexes on modules and course_modules. - drop them first silently to avoid conflicts when upgrading.
-        execute_sql("ALTER TABLE {$CFG->prefix}course_modules drop key visible;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}course_modules drop key course;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}course_modules drop key module;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}course_modules drop key instance;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}course_modules drop key deleted;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}modules drop key name;",false);
-
-        modify_database('','ALTER TABLE prefix_course_modules add key visible(visible);');
-        modify_database('','ALTER TABLE prefix_course_modules add key course(course);');
-        modify_database('','ALTER TABLE prefix_course_modules add key module(module);');
-        modify_database('','ALTER TABLE prefix_course_modules add key instance (instance);');
-        modify_database('','ALTER TABLE prefix_course_modules add key deleted (deleted);');
-        modify_database('','ALTER TABLE prefix_modules add key name(name);');
-    }
-
-    if ($oldversion < 2004111700) { // add an index on the groups_members table. - drop them first silently to avoid conflicts when upgrading.
-        execute_sql("ALTER TABLE {$CFG->prefix}groups_members DROP INDEX userid;",false);
-
-        modify_database('','ALTER TABLE prefix_groups_members ADD INDEX userid (userid);');
-    }
-
-    if ($oldversion < 2004111700) { // add an index on user students timeaccess (used for sorting)- drop them first silently to avoid conflicts when upgrading
-        execute_sql("ALTER TABLE {$CFG->prefix}user_students DROP INDEX timeaccess;",false);
-
-        modify_database('','ALTER TABLE prefix_user_students ADD INDEX timeaccess (timeaccess);');
-    }
-
-    if ($oldversion < 2004111700) {  // add indexes on faux-foreign keys. - drop them first silently to avoid conflicts when upgrading.
-        execute_sql("ALTER TABLE {$CFG->prefix}scale DROP INDEX courseid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}user_admins DROP INDEX userid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}user_coursecreators DROP INDEX userid;",false);
-
-        modify_database('','ALTER TABLE prefix_scale ADD INDEX courseid (courseid);');
-        modify_database('','ALTER TABLE prefix_user_admins ADD INDEX userid (userid);');
-        modify_database('','ALTER TABLE prefix_user_coursecreators ADD INDEX userid (userid);');
-    }
-
-    if ($oldversion < 2004111700) { // replace index on course
-        fix_course_sortorder(0,0,1);
-        execute_sql("ALTER TABLE `{$CFG->prefix}course` DROP KEY category",false);
-
-        execute_sql("ALTER TABLE `{$CFG->prefix}course` DROP KEY category_sortorder;",false);
-        modify_database('', "ALTER TABLE `prefix_course` ADD UNIQUE KEY category_sortorder(category,sortorder)"); 
-
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_deleted_idx;",false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_confirmed_idx;",false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_firstname_idx;",false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_lastname_idx;",false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_city_idx;",false); 
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_country_idx;",false); 
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_lastaccess_idx;",false);
-
-        modify_database("", "ALTER TABLE `prefix_user` ADD INDEX prefix_user_deleted_idx  (deleted)");
-        modify_database("", "ALTER TABLE `prefix_user` ADD INDEX prefix_user_confirmed_idx (confirmed)");
-        modify_database("", "ALTER TABLE `prefix_user` ADD INDEX prefix_user_firstname_idx (firstname)");
-        modify_database("", "ALTER TABLE `prefix_user` ADD INDEX prefix_user_lastname_idx (lastname)");
-        modify_database("", "ALTER TABLE `prefix_user` ADD INDEX prefix_user_city_idx (city)");
-        modify_database("", "ALTER TABLE `prefix_user` ADD INDEX prefix_user_country_idx (country)");
-        modify_database("", "ALTER TABLE `prefix_user` ADD INDEX prefix_user_lastaccess_idx (lastaccess)");
-     }
-    if ($oldversion < 2004111700) { // one more index for email (for sorting)
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_email_idx;",false);
-        modify_database('','ALTER TABLE `prefix_user` ADD INDEX prefix_user_email_idx (email);');
-    }
-
-    if ($oldversion < 2004112200) { // new 'enrol' field for enrolment tables
-        table_column('user_students', '', 'enrol', 'varchar', '20', '', '', 'not null');
-        table_column('user_teachers', '', 'enrol', 'varchar', '20', '', '', 'not null');
-        execute_sql("ALTER TABLE `{$CFG->prefix}user_students` ADD INDEX enrol (enrol);");
-        execute_sql("ALTER TABLE `{$CFG->prefix}user_teachers` ADD INDEX enrol (enrol);");
-    }
-    
-    if ($oldversion < 2004112400) {
-        /// Delete duplicate enrolments 
-        /// and then tell the database course,userid is a unique combination
-        if ($users = get_records_select("user_students", "userid > 0 GROUP BY course, userid ".
-                                        "HAVING count(*) > 1", "", "max(id) as id, userid, course ,count(*)")) {
-            foreach ($users as $user) {
-                delete_records_select("user_students", "userid = '$user->userid' ".
-                                     "AND course = '$user->course' AND id <> '$user->id'");
-            }
-        }
-        flush();
-        
-        modify_database('','ALTER TABLE prefix_user_students DROP INDEX courseuserid;');
-        modify_database('','ALTER TABLE prefix_user_students ADD UNIQUE INDEX courseuserid(course,userid);');        
-
-        /// Delete duplicate teacher enrolments 
-        /// and then tell the database course,userid is a unique combination
-        if ($users = get_records_select("user_teachers", "userid > 0 GROUP BY course, userid ".
-                                        "HAVING count(*) > 1", "", "max(id) as id, userid, course ,count(*)")) {
-            foreach ($users as $user) {
-                delete_records_select("user_teachers", "userid = '$user->userid' ".
-                                     "AND course = '$user->course' AND id <> '$user->id'");
-            }
-        }
-        flush();
-        modify_database('','ALTER TABLE prefix_user_teachers DROP INDEX courseuserid;');
-        modify_database('','ALTER TABLE prefix_user_teachers ADD UNIQUE INDEX courseuserid(course,userid);');        
-    } 
-
-    if ($oldversion < 2004112900) {
-        table_column('user', '', 'policyagreed', 'integer', '1', 'unsigned', '0', 'not null', 'confirmed');
-    }
-
-    if ($oldversion < 2004121400) {
-        table_column('groups', '', 'password', 'varchar', '50', '', '', 'not null', 'description');
-    }
-
-    if ($oldversion < 2004121500) {
-        modify_database('',"CREATE TABLE prefix_dst_preset (
-            id int(10) NOT NULL auto_increment,
-            name char(48) default '' NOT NULL,
-            
-            apply_offset tinyint(3) default '0' NOT NULL,
-            
-            activate_index tinyint(1) default '1' NOT NULL,
-            activate_day tinyint(1) default '1' NOT NULL,
-            activate_month tinyint(2) default '1' NOT NULL,
-            activate_time char(5) default '03:00' NOT NULL,
-            
-            deactivate_index tinyint(1) default '1' NOT NULL,
-            deactivate_day tinyint(1) default '1' NOT NULL,
-            deactivate_month tinyint(2) default '2' NOT NULL,
-            deactivate_time char(5) default '03:00' NOT NULL,
-            
-            last_change int(10) default '0' NOT NULL,
-            next_change int(10) default '0' NOT NULL,
-            current_offset tinyint(3) default '0' NOT NULL,
-            
-            PRIMARY KEY (id))");
-    }       
-
-    if ($oldversion < 2004122800) {
-        execute_sql("DROP TABLE {$CFG->prefix}message", false);
-        execute_sql("DROP TABLE {$CFG->prefix}message_read", false);
-        execute_sql("DROP TABLE {$CFG->prefix}message_contacts", false);
-
-        modify_database('',"CREATE TABLE `prefix_message` (
-                               `id` int(10) unsigned NOT NULL auto_increment,
-                               `useridfrom` int(10) NOT NULL default '0',
-                               `useridto` int(10) NOT NULL default '0',
-                               `message` text NOT NULL,
-                               `timecreated` int(10) NOT NULL default '0',
-                               `messagetype` varchar(50) NOT NULL default '',
-                               PRIMARY KEY  (`id`),
-                               KEY `useridfrom` (`useridfrom`),
-                               KEY `useridto` (`useridto`)
-                             ) TYPE=MyISAM COMMENT='Stores all unread messages';");
-
-        modify_database('',"CREATE TABLE `prefix_message_read` (
-                               `id` int(10) unsigned NOT NULL auto_increment,
-                               `useridfrom` int(10) NOT NULL default '0',
-                               `useridto` int(10) NOT NULL default '0',
-                               `message` text NOT NULL,
-                               `timecreated` int(10) NOT NULL default '0',
-                               `timeread` int(10) NOT NULL default '0',
-                               `messagetype` varchar(50) NOT NULL default '',
-                               `mailed` tinyint(1) NOT NULL default '0',
-                               PRIMARY KEY  (`id`),
-                               KEY `useridfrom` (`useridfrom`),
-                               KEY `useridto` (`useridto`)
-                             ) TYPE=MyISAM COMMENT='Stores all messages that have been read';");
-
-        modify_database('',"CREATE TABLE `prefix_message_contacts` (
-                               `id` int(10) unsigned NOT NULL auto_increment,
-                               `userid` int(10) unsigned NOT NULL default '0',
-                               `contactid` int(10) unsigned NOT NULL default '0',
-                               `blocked` tinyint(1) unsigned NOT NULL default '0',
-                               PRIMARY KEY  (`id`),
-                               UNIQUE KEY `usercontact` (`userid`,`contactid`)
-                             ) TYPE=MyISAM COMMENT='Maintains lists of relationships between users';");
-
-        modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'write', 'user', 'CONCAT(firstname,\" \",lastname)'); ");
-        modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'read', 'user', 'CONCAT(firstname,\" \",lastname)'); ");
-    }
-
-    if ($oldversion < 2004122801) {
-        table_column('message', '', 'format', 'integer', '4', 'unsigned', '0', 'not null', 'message');
-        table_column('message_read', '', 'format', 'integer', '4', 'unsigned', '0', 'not null', 'message');
-    }
-
-    if ($oldversion < 2005010100) {
-        modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'add contact', 'user', 'CONCAT(firstname,\" \",lastname)'); ");
-        modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'remove contact', 'user', 'CONCAT(firstname,\" \",lastname)'); ");
-        modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'block contact', 'user', 'CONCAT(firstname,\" \",lastname)'); ");
-        modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'unblock contact', 'user', 'CONCAT(firstname,\" \",lastname)'); ");
-    }
-
-    if ($oldversion < 2005011000) {     // Create a .htaccess file in dataroot, just in case
-        if (!file_exists($CFG->dataroot.'/.htaccess')) {
-            if ($handle = fopen($CFG->dataroot.'/.htaccess', 'w')) {   // For safety
-                @fwrite($handle, "deny from all\r\nAllowOverride None\r\n");
-                @fclose($handle); 
-                notify("Created a default .htaccess file in $CFG->dataroot");
-            }
-        }
-    }
-    
-
-    if ($oldversion < 2005012500) { 
-        /*
-        // add new table for meta courses.
-        modify_database("","CREATE TABLE `prefix_meta_course` (
-            `id` int(1) unsigned NOT NULL auto_increment,
-            `parent_course` int(10) NOT NULL default 0,
-            `child_course` int(10) NOT NULL default 0,
-            PRIMARY KEY (`id`),
-            KEY `parent_course` (parent_course),
-            KEY `child_course` (child_course)
-        );");
-        // add flag to course field
-        table_column('course','','meta_course','integer','1','','0','not null');
-        */ // taking this OUT for upgrade from 1.4 to 1.5 (those tracking head will have already seen it)
-    }
-
-    if ($oldversion < 2005012501) { 
-        execute_sql("DROP TABLE {$CFG->prefix}meta_course",false); // drop silently
-        execute_sql("ALTER TABLE {$CFG->prefix}course DROP COLUMN meta_course",false); // drop silently
-        
-        // add new table for meta courses.
-        modify_database("","CREATE TABLE `prefix_course_meta` (
-            `id` int(10) unsigned NOT NULL auto_increment,
-            `parent_course` int(10) NOT NULL default 0,
-            `child_course` int(10) NOT NULL default 0,
-            PRIMARY KEY (`id`),
-            KEY `parent_course` (parent_course),
-            KEY `child_course` (child_course)
-        );");
-        // add flag to course field
-        table_column('course','','metacourse','integer','1','','0','not null');
-    }
-
-    if ($oldversion < 2005012800) {
-        // fix a typo (int 1 becomes int 10) 
-        table_column('course_meta','id','id','integer','10','','0','not null');
-    }
-
-    if ($oldversion < 2005020100) {
-        fix_course_sortorder(0, 1, 1);
-    }   
-
-
-    if ($oldversion < 2005020101) {
-        // hopefully this is the LAST TIME we need to do this ;)
-        if ($rows = count_records("course_meta")) {
-            // we need to upgrade
-            modify_database("","CREATE TABLE `prefix_course_meta_tmp` (
-            `parent_course` int(10) NOT NULL default 0,
-            `child_course` int(10) NOT NULL default 0);");
-            
-            execute_sql("INSERT INTO {$CFG->prefix}course_meta_tmp (parent_course,child_course) 
-               SELECT {$CFG->prefix}course_meta.parent_course, {$CFG->prefix}course_meta.child_course
-               FROM {$CFG->prefix}course_meta");
-            $insertafter = true;
-        }
-
-        execute_sql("DROP TABLE {$CFG->prefix}course_meta");
-
-        modify_database("","CREATE TABLE `prefix_course_meta` (
-            `id` int(10) unsigned NOT NULL auto_increment,
-            `parent_course` int(10) unsigned NOT NULL default 0,
-            `child_course` int(10) unsigned NOT NULL default 0,
-            PRIMARY KEY (`id`),
-            KEY `parent_course` (parent_course),
-            KEY `child_course` (child_course));");
-
-        if (!empty($insertafter)) {
-            execute_sql("INSERT INTO {$CFG->prefix}course_meta (parent_course,child_course) 
-               SELECT {$CFG->prefix}course_meta_tmp.parent_course, {$CFG->prefix}course_meta_tmp.child_course
-               FROM {$CFG->prefix}course_meta_tmp");
-
-            execute_sql("DROP TABLE {$CFG->prefix}course_meta_tmp");
-        }
-    }
-
-    if ($oldversion < 2005020800) {     // Expand module column to max 20 chars
-        table_column('log','module','module','varchar','20','','','not null');
-    }
-
-    if ($oldversion < 2005021000) {     // New fields for theme choices
-        table_column('course', '', 'theme', 'varchar', '50', '', '', '', 'lang');
-        table_column('groups', '', 'theme', 'varchar', '50', '', '', '', 'lang');
-        table_column('user',   '', 'theme', 'varchar', '50', '', '', '', 'lang');
-
-        set_config('theme', 'standardwhite');         // Reset to a known good theme 
-    }
-    
-    if ($oldversion < 2005021600) {     // course.idnumber should be varchar(100)
-        table_column('course', 'idnumber', 'idnumber', 'varchar', '100', '', '', '', '');
-    }
-
-    if ($oldversion < 2005021700) {
-        table_column('user', '', 'dstpreset', 'int', '10', '', '0', 'not null', 'timezone');
-    }
-
-    if ($oldversion < 2005021800) {     // For database debugging, not for normal use
-        modify_database(""," CREATE TABLE `adodb_logsql` (
-                               `created` datetime NOT NULL,
-                               `sql0` varchar(250) NOT NULL,
-                               `sql1` text NOT NULL,
-                               `params` text NOT NULL,
-                               `tracer` text NOT NULL,
-                               `timer` decimal(16,6) NOT NULL
-                              );");
-    }
-
-    if ($oldversion < 2005022400) {
-        // Add more visible digits to the fields
-        table_column('dst_preset', 'activate_index', 'activate_index', 'tinyint', '2', '', '0', 'not null');
-        table_column('dst_preset', 'activate_day', 'activate_day', 'tinyint', '2', '', '0', 'not null');
-        // Add family and year fields
-        table_column('dst_preset', '', 'family', 'varchar', '100', '', '', 'not null', 'name');
-        table_column('dst_preset', '', 'year', 'int', '10', '', '0', 'not null', 'family');
-    }
-
-    if ($oldversion < 2005030501) {
-        table_column('user', '', 'msn', 'varchar', '50', '', '', '', 'icq');
-        table_column('user', '', 'aim', 'varchar', '50', '', '', '', 'icq');
-        table_column('user', '', 'yahoo', 'varchar', '50', '', '', '', 'icq');
-        table_column('user', '', 'skype', 'varchar', '50', '', '', '', 'icq');
-    }
-
-    if ($oldversion < 2005032300) {
-        table_column('user', 'dstpreset', 'timezonename', 'varchar', '100');
-        execute_sql('UPDATE `'.$CFG->prefix.'user` SET timezonename = \'\'');
-    }
-
-    if ($oldversion < 2005032600) {
-        execute_sql('DROP TABLE '.$CFG->prefix.'dst_preset', false);
-        modify_database('',"CREATE TABLE `prefix_timezone` (
-                              `id` int(10) NOT NULL auto_increment,
-                              `name` varchar(100) NOT NULL default '',
-                              `year` int(11) NOT NULL default '0',
-                              `rule` varchar(20) NOT NULL default '',
-                              `gmtoff` int(11) NOT NULL default '0',
-                              `dstoff` int(11) NOT NULL default '0',
-                              `dst_month` tinyint(2) NOT NULL default '0',
-                              `dst_startday` tinyint(3) NOT NULL default '0',
-                              `dst_weekday` tinyint(3) NOT NULL default '0',
-                              `dst_skipweeks` tinyint(3) NOT NULL default '0',
-                              `dst_time` varchar(5) NOT NULL default '00:00',
-                              `std_month` tinyint(2) NOT NULL default '0',
-                              `std_startday` tinyint(3) NOT NULL default '0',
-                              `std_weekday` tinyint(3) NOT NULL default '0',
-                              `std_skipweeks` tinyint(3) NOT NULL default '0',
-                              `std_time` varchar(5) NOT NULL default '00:00',
-                              PRIMARY KEY (`id`)
-                            ) TYPE=MyISAM COMMENT='Rules for calculating local wall clock time for users';");
-    }
-
-    if ($oldversion < 2005032800) {
-        execute_sql("CREATE TABLE `{$CFG->prefix}grade_category` (
-            `id` int(10) unsigned NOT NULL auto_increment,
-            `name` varchar(64) NOT NULL default '',
-            `courseid` int(10) unsigned NOT NULL default '0',
-            `drop_x_lowest` int(10) unsigned NOT NULL default '0',
-            `bonus_points` int(10) unsigned NOT NULL default '0',
-            `hidden` int(10) unsigned NOT NULL default '0',
-            `weight` decimal(4,2) NOT NULL default '0.00',
-            PRIMARY KEY  (`id`),
-            KEY `courseid` (`courseid`)
-          ) TYPE=MyISAM ;");
-
-        execute_sql("CREATE TABLE `{$CFG->prefix}grade_exceptions` (
-            `id` int(10) unsigned NOT NULL auto_increment,
-            `courseid` int(10) unsigned NOT NULL default '0',
-            `grade_itemid` int(10) unsigned NOT NULL default '0',
-            `userid` int(10) unsigned NOT NULL default '0',
-            PRIMARY KEY  (`id`),
-            KEY `courseid` (`courseid`)
-          ) TYPE=MyISAM ;");
-
-
-        execute_sql("CREATE TABLE `{$CFG->prefix}grade_item` (
-            `id` int(10) unsigned NOT NULL auto_increment,
-            `courseid` int(10) unsigned NOT NULL default '0',
-            `category` int(10) unsigned NOT NULL default '0',
-            `modid` int(10) unsigned NOT NULL default '0',
-            `cminstance` int(10) unsigned NOT NULL default '0',
-            `scale_grade` float(11,10) default '1.0000000000',
-            `extra_credit` int(10) unsigned NOT NULL default '0',
-            `sort_order` int(10) unsigned NOT NULL default '0',
-            PRIMARY KEY  (`id`),
-            KEY `courseid` (`courseid`)
-          ) TYPE=MyISAM ;");
-
-
-        execute_sql("CREATE TABLE `{$CFG->prefix}grade_letter` (
-            `id` int(10) unsigned NOT NULL auto_increment,
-            `courseid` int(10) unsigned NOT NULL default '0',
-            `letter` varchar(8) NOT NULL default 'NA',
-            `grade_high` decimal(4,2) NOT NULL default '100.00',
-            `grade_low` decimal(4,2) NOT NULL default '0.00',
-            PRIMARY KEY  (`id`),
-            KEY `courseid` (`courseid`)
-          ) TYPE=MyISAM ;");
-          
-
-        execute_sql("CREATE TABLE `{$CFG->prefix}grade_preferences` (
-            `id` int(10) unsigned NOT NULL auto_increment,
-            `courseid` int(10) unsigned NOT NULL default '0',
-            `preference` int(10) NOT NULL default '0',
-            `value` int(10) NOT NULL default '0',
-            PRIMARY KEY  (`id`),
-            UNIQUE KEY `courseidpreference` (`courseid`,`preference`)
-          ) TYPE=MyISAM ;");
-          
-    }
-
-    if ($oldversion < 2005033100) {   // Get rid of defunct field from course modules table
-         delete_records('course_modules', 'deleted', 1);  // Delete old records we don't need any more
-         execute_sql('ALTER TABLE `'.$CFG->prefix.'course_modules` DROP INDEX `deleted`');  // Old index
-         execute_sql('ALTER TABLE `'.$CFG->prefix.'course_modules` DROP `deleted`');    // Old field
-    }
-
-    if ($oldversion < 2005040800) {
-        table_column('user', 'timezone', 'timezone', 'varchar', '100', '', '99');
-        execute_sql(" ALTER TABLE `{$CFG->prefix}user` DROP `timezonename` ");
-    }
-    
-    if ($oldversion < 2005041101) {
-        require_once($CFG->libdir.'/filelib.php');
-        if (is_readable($CFG->dirroot.'/lib/timezones.txt')) {  // Distribution file
-            if ($timezones = get_records_csv($CFG->dirroot.'/lib/timezones.txt', 'timezone')) {
-                $db->debug = false;
-                update_timezone_records($timezones);
-                notify(count($timezones).' timezones installed');
-                $db->debug = true;
-            }
-        }
-    }
-
-    if ($oldversion < 2005041900) {  // Copy all Dialogue entries into Messages, and hide Dialogue module
-
-        if ($entries = get_records_sql('SELECT e.id, e.userid, c.recipientid, e.text, e.timecreated
-                                          FROM '.$CFG->prefix.'dialogue_conversations c,
-                                               '.$CFG->prefix.'dialogue_entries e
-                                         WHERE e.conversationid = c.id')) {
-            foreach ($entries as $entry) {
-                $message = new object;
-                $message->useridfrom    = $entry->userid;
-                $message->useridto      = $entry->recipientid;
-                $message->message       = addslashes($entry->text);
-                $message->format        = FORMAT_HTML;
-                $message->timecreated   = $entry->timecreated;
-                $message->messagetype   = 'direct';
-            
-                insert_record('message_read', $message);
-            }
-        }
-
-        set_field('modules', 'visible', 0, 'name', 'dialogue');
-
-        notify('The Dialogue module has been disabled, and all the old Messages from it copied into the new standard Message feature.  If you really want Dialogue back, you can enable it using the "eye" icon here:  Admin >> Modules >> Dialogue');
-
-    }
-
-    if ($oldversion < 2005042100) {
-        $result = table_column('event', '', 'repeatid', 'int', '10', 'unsigned', '0', 'not null', 'userid') && $result;
-    }
-
-    if ($oldversion < 2005042400) {  // Add user tracking prefs field.
-        table_column('user', '', 'trackforums', 'int', '4', 'unsigned', '0', 'not null', 'autosubscribe');
-    }
-
-    if ($oldversion < 2005053000 ) { // Add config_plugins table
-        
-        // this table was created on the MOODLE_15_STABLE branch
-        // so it may already exist.
-        $result = execute_sql("CREATE TABLE IF NOT EXISTS `{$CFG->prefix}config_plugins` (
-                                  `id`         int(10) unsigned NOT NULL auto_increment,
-                                  `plugin`     varchar(100) NOT NULL default 'core',
-                                  `name`       varchar(100) NOT NULL default '',
-                                  `value`      text NOT NULL default '',
-                                  PRIMARY KEY  (`id`),
-                                           UNIQUE KEY `plugin_name` (`plugin`, `name`)
-                                  ) TYPE=MyISAM 
-                                  COMMENT='Moodle modules and plugins configuration variables';");
-    }
-
-    if ($oldversion < 2005060200) {  // migrate some config items to config_plugins table
-
-        // NOTE: this block is in both postgres AND mysql upgrade
-        // files. If you edit either, update the otherone. 
-        $user_fields = array("firstname", "lastname", "email", 
-                             "phone1", "phone2", "department", 
-                             "address", "city", "country", 
-                             "description", "idnumber", "lang");
-        if (!empty($CFG->auth)) { // if we have no auth, just pass
-            foreach ($user_fields as $field) {
-                $suffixes = array('', '_editlock', '_updateremote', '_updatelocal');
-                foreach ($suffixes as $suffix) {
-                    $key = 'auth_user_' . $field . $suffix;
-                    if (isset($CFG->$key)) {
-                        
-                        // translate keys & values
-                        // to the new convention
-                        // this should support upgrading 
-                        // even 1.5dev installs
-                        $newkey = $key;
-                        $newval = $CFG->$key;
-                        if ($suffix === '') {
-                            $newkey = 'field_map_' . $field;
-                        } elseif ($suffix === '_editlock') {
-                            $newkey = 'field_lock_' . $field;
-                            $newval = ($newval==1) ? 'locked' : 'unlocked'; // translate 0/1 to locked/unlocked
-                        } elseif ($suffix === '_updateremote') {
-                            $newkey = 'field_updateremote_' . $field;                            
-                        } elseif ($suffix === '_updatelocal') {
-                            $newkey = 'field_updatelocal_' . $field;
-                            $newval = ($newval==1) ? 'onlogin' : 'oncreate'; // translate 0/1 to locked/unlocked
-                        }
-
-                        if (!(set_config($newkey, addslashes($newval), 'auth/'.$CFG->auth)
-                            && delete_records('config', 'name', $key))) {
-                            notify("Error updating Auth configuration $key to {$CFG->auth} $newkey .");
-                            $result = false;
-                        }
-                    } // end if isset key
-                } // end foreach suffix
-            } // end foreach field
-        }
-    }
-
-    if ($oldversion < 2005060201) {  // Close down the Attendance module, we are removing it from CVS.
-        if (!file_exists($CFG->dirroot.'/mod/attendance/lib.php')) {
-            if (count_records('attendance')) {   // We have some data, so should keep it
-
-                set_field('modules', 'visible', 0, 'name', 'attendance');
-                notify('The Attendance module has been discontinued.  If you really want to 
-                        continue using it, you should download it individually from 
-                        http://download.moodle.org/modules and install it, then 
-                        reactivate it from Admin >> Configuration >> Modules.  
-                        None of your existing data has been deleted, so all existing 
-                        Attendance activities should re-appear.');
-
-            } else {  // No data, so do a complete delete
-
-                execute_sql('DROP TABLE '.$CFG->prefix.'attendance', false);
-                delete_records('modules', 'name', 'attendance');
-                notify("The Attendance module has been discontinued and removed from your site.  
-                        You weren't using it anyway.  ;-)");
-            }
-        }
-    }
-
-    if ($oldversion < 2005071700) {  // Close down the Dialogue module, we are removing it from CVS.
-        if (!file_exists($CFG->dirroot.'/mod/dialogue/lib.php')) {
-            if (count_records('dialogue')) {   // We have some data, so should keep it
-
-                set_field('modules', 'visible', 0, 'name', 'dialogue');
-                notify('The Dialogue module has been discontinued.  If you really want to 
-                        continue using it, you should download it individually from 
-                        http://download.moodle.org/modules and install it, then 
-                        reactivate it from Admin >> Configuration >> Modules.  
-                        None of your existing data has been deleted, so all existing 
-                        Dialogue activities should re-appear.');
-
-            } else {  // No data, so do a complete delete
-
-                execute_sql('DROP TABLE '.$CFG->prefix.'dialogue', false);
-                delete_records('modules', 'name', 'dialogue');
-                notify("The Dialogue module has been discontinued and removed from your site.  
-                        You weren't using it anyway.  ;-)");
-            }
-        }
-    }
-
-    if ($oldversion < 2005072000) {  // Add a couple fields to mdl_event to work towards iCal import/export
-        table_column('event', '', 'uuid', 'char', '36', '', '', 'not null', 'visible');
-        table_column('event', '', 'sequence', 'integer', '10', 'unsigned', '1', 'not null', 'uuid');
-    }
-
-    if ($oldversion < 2005072100) { // run the online assignment cleanup code
-        include($CFG->dirroot.'/'.$CFG->admin.'/oacleanup.php');
-        if (function_exists('online_assignment_cleanup')) {
-            online_assignment_cleanup();
-        }
-    }
-
-    if ($oldversion < 2005072200) { // fix the mistakenly-added currency stuff from enrol/authorize
-        execute_sql("DROP TABLE {$CFG->prefix}currencies", false); // drop silently
-        execute_sql("ALTER TABLE {$CFG->prefix}course DROP currency", false);
-        $defaultcurrency = empty($CFG->enrol_currency) ? 'USD' : $CFG->enrol_currency;
-        table_column('course', '', 'currency', 'char', '3', '', $defaultcurrency, 'not null', 'cost');
-    }
-
-    if ($oldversion < 2005081600) { //set up the course requests table
-        modify_database('',"CREATE TABLE `prefix_course_request`  (
-          `id` int(10) unsigned NOT NULL auto_increment,
-          `fullname` varchar(254) NOT NULL default '',
-          `shortname` varchar(15) NOT NULL default '',
-          `summary` text NOT NULL,
-          `reason` text NOT NULL,
-          `requester` int(10) NOT NULL default 0,
-          PRIMARY KEY (`id`),
-          KEY `shortname` (`shortname`)
-        ) TYPE=MyISAM;");
-        
-        table_column('course','','requested');
-    }
-
-    if ($oldversion < 2005081601) {
-        modify_database('',"CREATE TABLE `prefix_course_allowed_modules` (
-         `id` int(10) unsigned NOT NULL auto_increment,
-         `course` int(10) unsigned NOT NULL default 0,
-         `module` int(10) unsigned NOT NULL default 0,
-         PRIMARY KEY (`id`),
-         KEY `course` (`course`),
-         KEY `module` (`module`)
-      ) TYPE=MyISAM;");
-        
-        table_column('course','','restrictmodules','int','1','','0','not null');
-    }
-
-    if ($oldversion < 2005081700) {
-        table_column('course_categories','','depth','integer');
-        table_column('course_categories','','path','varchar','255');
-    }
-
-    if ($oldversion < 2005090100) {
-        modify_database("","CREATE TABLE `prefix_stats_daily` (
-          `id` int(10) unsigned NOT NULL auto_increment,
-          `courseid` int(10) unsigned NOT NULL default 0,
-          `timeend` int(10) unsigned NOT NULL default 0,
-          `students` int(10) unsigned NOT NULL default 0,
-          `teachers` int(10) unsigned NOT NULL default 0,
-          `activestudents` int(10) unsigned NOT NULL default 0,
-          `activeteachers` int(10) unsigned NOT NULL default 0,
-          `studentreads` int(10) unsigned NOT NULL default 0,
-          `studentwrites` int(10) unsigned NOT NULL default 0,
-          `teacherreads` int(10) unsigned NOT NULL default 0,
-          `teacherwrites` int(10) unsigned NOT NULL default 0,
-          `logins` int(10) unsigned NOT NULL default 0,
-          `uniquelogins` int(10) unsigned NOT NULL default 0,
-          PRIMARY KEY (`id`),
-          KEY `courseid` (`courseid`),
-          KEY `timeend` (`timeend`)
-       );");
-
-        modify_database("","CREATE TABLE prefix_stats_weekly (
-          `id` int(10) unsigned NOT NULL auto_increment,
-          `courseid` int(10) unsigned NOT NULL default 0,
-          `timeend` int(10) unsigned NOT NULL default 0,
-          `students` int(10) unsigned NOT NULL default 0,
-          `teachers` int(10) unsigned NOT NULL default 0,
-          `activestudents` int(10) unsigned NOT NULL default 0,
-          `activeteachers` int(10) unsigned NOT NULL default 0,
-          `studentreads` int(10) unsigned NOT NULL default 0,
-          `studentwrites` int(10) unsigned NOT NULL default 0,
-          `teacherreads` int(10) unsigned NOT NULL default 0,
-          `teacherwrites` int(10) unsigned NOT NULL default 0,
-          `logins` int(10) unsigned NOT NULL default 0,
-          `uniquelogins` int(10) unsigned NOT NULL default 0,
-          PRIMARY KEY (`id`),
-          KEY `courseid` (`courseid`),
-          KEY `timeend` (`timeend`)
-       );");
-
-        modify_database("","CREATE TABLE prefix_stats_monthly (
-          `id` int(10) unsigned NOT NULL auto_increment,
-          `courseid` int(10) unsigned NOT NULL default 0,
-          `timeend` int(10) unsigned NOT NULL default 0,
-          `students` int(10) unsigned NOT NULL default 0,
-          `teachers` int(10) unsigned NOT NULL default 0,
-          `activestudents` int(10) unsigned NOT NULL default 0,
-          `activeteachers` int(10) unsigned NOT NULL default 0,
-          `studentreads` int(10) unsigned NOT NULL default 0,
-          `studentwrites` int(10) unsigned NOT NULL default 0,
-          `teacherreads` int(10) unsigned NOT NULL default 0,
-          `teacherwrites` int(10) unsigned NOT NULL default 0,
-          `logins` int(10) unsigned NOT NULL default 0,
-          `uniquelogins` int(10) unsigned NOT NULL default 0,
-          PRIMARY KEY (`id`),
-          KEY `courseid` (`courseid`),
-          KEY `timeend` (`timeend`)
-       );");
-
-        modify_database("","CREATE TABLE prefix_stats_user_daily (
-          `id` int(10) unsigned NOT NULL auto_increment,
-          `courseid` int(10) unsigned NOT NULL default 0,
-          `userid` int(10) unsigned NOT NULL default 0,
-          `roleid` int(10) unsigned NOT NULL default 0,
-          `timeend` int(10) unsigned NOT NULL default 0,
-          `statsreads` int(10) unsigned NOT NULL default 0,
-          `statswrites` int(10) unsigned NOT NULL default 0,
-          `stattype` varchar(30) NOT NULL default '',
-          PRIMARY KEY (`id`),
-          KEY `courseid` (`courseid`),
-          KEY `userid` (`userid`),
-          KEY `roleid` (`roleid`),
-          KEY `timeend` (`timeend`)
-       );");
-
-        modify_database("","CREATE TABLE prefix_stats_user_weekly (
-          `id` int(10) unsigned NOT NULL auto_increment,
-          `courseid` int(10) unsigned NOT NULL default 0,
-          `userid` int(10) unsigned NOT NULL default 0,
-          `roleid` int(10) unsigned NOT NULL default 0,
-          `timeend` int(10) unsigned NOT NULL default 0,
-          `statsreads` int(10) unsigned NOT NULL default 0,
-          `statswrites` int(10) unsigned NOT NULL default 0,
-          `stattype` varchar(30) NOT NULL default '',
-          PRIMARY KEY (`id`),
-          KEY `courseid` (`courseid`),
-          KEY `userid` (`userid`),
-          KEY `roleid` (`roleid`),
-          KEY `timeend` (`timeend`)
-       );");
-
-        modify_database("","CREATE TABLE prefix_stats_user_monthly (
-          `id` int(10) unsigned NOT NULL auto_increment,
-          `courseid` int(10) unsigned NOT NULL default 0,
-          `userid` int(10) unsigned NOT NULL default 0,
-          `roleid` int(10) unsigned NOT NULL default 0,
-          `timeend` int(10) unsigned NOT NULL default 0,
-          `statsreads` int(10) unsigned NOT NULL default 0,
-          `statswrites` int(10) unsigned NOT NULL default 0,
-          `stattype` varchar(30) NOT NULL default '',
-          PRIMARY KEY (`id`),
-          KEY `courseid` (`courseid`),
-          KEY `userid` (`userid`),
-          KEY `roleid` (`roleid`),
-          KEY `timeend` (`timeend`)
-       );");
-         
-    }
-
-    if ($oldversion < 2005100300) {
-        table_column('course','','expirynotify','tinyint','1');
-        table_column('course','','expirythreshold','int','10');
-        table_column('course','','notifystudents','tinyint','1');
-        $new = new stdClass();
-        $new->name = 'lastexpirynotify';
-        $new->value = 0;
-        insert_record('config', $new);
-    }
-
-    if ($oldversion < 2005100400) {
-        table_column('course','','enrollable','tinyint','1','unsigned','1');
-        table_column('course','','enrolstartdate','int');
-        table_column('course','','enrolenddate','int');
-    }
-
-    if ($oldversion < 2005101200) { // add enrolment key to course_request.
-        table_column('course_request','','password','varchar',50);
-    }
-
-    if ($oldversion < 2006030800) { # add extra indexes to log (see bug #4112)
-        modify_database('',"ALTER TABLE prefix_log ADD INDEX userid (userid);");
-        modify_database('',"ALTER TABLE prefix_log ADD INDEX info (info);");
-    }
-
-    if ($oldversion < 2006030900) {
-        table_column('course','','enrol','varchar','20','','');
-
-        if ($CFG->enrol == 'internal' || $CFG->enrol == 'manual') {
-            set_config('enrol_plugins_enabled', 'manual');
-            set_config('enrol', 'manual');
-        } else {
-            set_config('enrol_plugins_enabled', 'manual,'.$CFG->enrol);
-        }
-
-        require_once("$CFG->dirroot/enrol/enrol.class.php");
-        $defaultenrol = enrolment_factory::factory($CFG->enrol);
-        if (!method_exists($defaultenrol, 'print_entry')) { // switch enrollable to off for all courses in this case
-            modify_database('', 'UPDATE prefix_course SET enrollable = 0');
-        }
-
-        execute_sql("UPDATE {$CFG->prefix}user_students SET enrol='manual' WHERE enrol='' OR enrol='internal'");
-        execute_sql("UPDATE {$CFG->prefix}user_teachers SET enrol='manual' WHERE enrol=''");
-
-    }
-    
-    if ($oldversion < 2006031000) {
-
-        modify_database("","CREATE TABLE prefix_post (
-          `id` int(10) unsigned NOT NULL auto_increment,
-          `userid` int(10) unsigned NOT NULL default '0',
-          `courseid` int(10) unsigned NOT NULL default'0',
-          `groupid` int(10) unsigned NOT NULL default'0',
-          `moduleid` int(10) unsigned NOT NULL default'0',
-          `coursemoduleid` int(10) unsigned NOT NULL default'0',
-          `subject` varchar(128) NOT NULL default '',
-          `summary` longtext,
-          `content` longtext,
-          `uniquehash` varchar(128) NOT NULL default '',
-          `rating` int(10) unsigned NOT NULL default'0',
-          `format` int(10) unsigned NOT NULL default'0',
-          `publishstate` enum('draft','site','public') NOT NULL default 'draft',
-          `lastmodified` int(10) unsigned NOT NULL default '0',
-          `created` int(10) unsigned NOT NULL default '0',
-          PRIMARY KEY  (`id`),
-          UNIQUE KEY `id_user_idx` (`id`, `userid`),
-          KEY `post_lastmodified_idx` (`lastmodified`),
-          KEY `post_subject_idx` (`subject`)
-        ) TYPE=MyISAM  COMMENT='New moodle post table. Holds data posts such as forum entries or blog entries.';");
-
-        modify_database("","CREATE TABLE prefix_tags (
-          `id` int(10) unsigned NOT NULL auto_increment,
-          `type` varchar(255) NOT NULL default 'official',
-          `userid` int(10) unsigned NOT NULL default'0',
-          `text` varchar(255) NOT NULL default '',
-          PRIMARY KEY  (`id`)
-        ) TYPE=MyISAM COMMENT ='tags structure for moodle.';");
-
-        modify_database("","CREATE TABLE prefix_blog_tag_instance (
-          `id` int(10) unsigned NOT NULL auto_increment,
-          `entryid` int(10) unsigned NOT NULL default'0',
-          `tagid` int(10) unsigned NOT NULL default'0',
-          `groupid` int(10) unsigned NOT NULL default'0',
-          `courseid` int(10) unsigned NOT NULL default'0',
-          `userid` int(10) unsigned NOT NULL default'0',
-          PRIMARY KEY  (`id`)
-          ) TYPE=MyISAM COMMENT ='tag instance for blogs.';");
-    }
-
-    if ($oldversion < 2006031400) {
-        require_once("$CFG->dirroot/enrol/enrol.class.php");
-        $defaultenrol = enrolment_factory::factory($CFG->enrol);
-        if (!method_exists($defaultenrol, 'print_entry')) {
-            set_config('enrol', 'manual');
-        }
-    }
-    
-    if ($oldversion < 2006031600) {
-        execute_sql(" ALTER TABLE `{$CFG->prefix}grade_category` CHANGE `weight` `weight` decimal(5,2) default '0.00';");
-    }
-
-    if ($oldversion < 2006032000) {
-        table_column('post','','module','varchar','20','','','not null', 'id');
-        modify_database('',"ALTER TABLE prefix_post ADD INDEX post_module_idx (module);");
-        modify_database('',"UPDATE prefix_post SET module = 'blog';");
-    }
-
-    if ($oldversion < 2006032001) {
-        table_column('blog_tag_instance','','timemodified','integer','10','unsigned','0','not null', 'userid');
-        modify_database('',"ALTER TABLE prefix_blog_tag_instance ADD INDEX bti_entryid_idx (entryid);");
-        modify_database('',"ALTER TABLE prefix_blog_tag_instance ADD INDEX bti_tagid_idx (tagid);");
-        modify_database('',"UPDATE prefix_blog_tag_instance SET timemodified = '".time()."';");
-    }
-
-    if ($oldversion < 2006040500) { // Add an index to course_sections that was never upgraded (bug 5100)
-        execute_sql(" CREATE INDEX coursesection ON {$CFG->prefix}course_sections (course,section) ", false);
-    }
-
-    /// change all the int(11) to int(10) for blogs and tags
-
-    if ($oldversion < 2006041000) {
-        table_column('post','id','id','integer','10','unsigned','0','not null');
-        table_column('post','userid','userid','integer','10','unsigned','0','not null');
-        table_column('post','courseid','courseid','integer','10','unsigned','0','not null');
-        table_column('post','groupid','groupid','integer','10','unsigned','0','not null');
-        table_column('post','moduleid','moduleid','integer','10','unsigned','0','not null');
-        table_column('post','coursemoduleid','coursemoduleid','integer','10','unsigned','0','not null');
-        table_column('post','rating','rating','integer','10','unsigned','0','not null');
-        table_column('post','format','format','integer','10','unsigned','0','not null');
-        table_column('tags','id','id','integer','10','unsigned','0','not null');
-        table_column('tags','userid','userid','integer','10','unsigned','0','not null');
-        table_column('blog_tag_instance','id','id','integer','10','unsigned','0','not null');
-        table_column('blog_tag_instance','entryid','entryid','integer','10','unsigned','0','not null');
-        table_column('blog_tag_instance','tagid','tagid','integer','10','unsigned','0','not null');
-        table_column('blog_tag_instance','groupid','groupid','integer','10','unsigned','0','not null');
-        table_column('blog_tag_instance','courseid','courseid','integer','10','unsigned','0','not null');
-        table_column('blog_tag_instance','userid','userid','integer','10','unsigned','0','not null');
-    }
-
-    if ($oldversion < 2006041001) {
-        table_column('cache_text','formattedtext','formattedtext','longblob','','','','not null');
-    }
-    
-    if ($oldversion < 2006041100) {
-        table_column('course_modules','','visibleold','integer','1','unsigned','1','not null', 'visible');
-    }
-    
-    if ($oldversion < 2006041801) { // forgot auto_increments for ids
-        modify_database('',"ALTER TABLE prefix_post CHANGE id id INT UNSIGNED NOT NULL AUTO_INCREMENT");
-        modify_database('',"ALTER TABLE prefix_tags CHANGE id id INT UNSIGNED NOT NULL AUTO_INCREMENT");
-        modify_database('',"ALTER TABLE prefix_blog_tag_instance CHANGE id id INT UNSIGNED NOT NULL AUTO_INCREMENT");
-    }
-    
-    // changed user->firstname, user->lastname, course->shortname to varchar(100)
-    
-    if ($oldversion < 2006041900) {
-        table_column('course','shortname','shortname','varchar','100','','','not null');
-        table_column('user','firstname','firstname','varchar','100','','','not null');
-        table_column('user','lastname','lastname','varchar','100','','','not null');
-    }
-    
-    if ($oldversion < 2006042400) {
-        // Look through table log_display and get rid of duplicates.
-        $rs = get_recordset_sql('SELECT DISTINCT * FROM '.$CFG->prefix.'log_display');
-        
-        // Drop the log_display table and create it back with an id field.
-        execute_sql("DROP TABLE {$CFG->prefix}log_display", false);
-        
-        modify_database('', "CREATE TABLE prefix_log_display (
-                               `id` int(10) unsigned NOT NULL auto_increment,
-                               `module` varchar(30),
-                               `action` varchar(40),
-                               `mtable` varchar(30),
-                               `field` varchar(50),
-                               PRIMARY KEY (`id`)
-                               ) TYPE=MyISAM");
-        
-        // Add index to ensure that module and action combination is unique.
-        modify_database('', "ALTER TABLE prefix_log_display ADD UNIQUE `moduleaction`(`module` , `action`)");
-        
-        // Insert the records back in, sans duplicates.
-        if ($rs) {
-            while (!$rs->EOF) {
-                $sql = "INSERT INTO {$CFG->prefix}log_display ".
-                            "VALUES('', '".$rs->fields['module']."', ".
-                            "'".$rs->fields['action']."', ".
-                            "'".$rs->fields['mtable']."', ".
-                            "'".$rs->fields['field']."')";
-                
-                execute_sql($sql, false);
-                $rs->MoveNext();
-            }
-            rs_close($rs);
-        }
-    }
-    
-    // change tags->type to varchar(20), adding 2 indexes for tags table.
-    if ($oldversion < 2006042401) {
-        table_column('tags','type','type','varchar','20','','','not null');
-        modify_database('',"ALTER TABLE prefix_tags ADD INDEX tags_typeuserid_idx (type(20), userid)");
-        modify_database('',"ALTER TABLE prefix_tags ADD INDEX tags_text_idx(text(255))");
-    }
-    
-    /***************************************************
-     * The following is an effort to change all the    *
-     * default NULLs to NOT NULL defaut '' in all      *
-     * mysql tables, to prevent 5303 and be consistent *
-     ***************************************************/
-
-    if ($oldversion < 2006042800) {
-
-        execute_sql("UPDATE {$CFG->prefix}grade_category SET name='' WHERE name IS NULL");
-        table_column('grade_category','name','name','varchar','64','','','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}grade_category SET weight='0' WHERE weight IS NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}grade_category change weight weight decimal(5,2) NOT NULL default 0.00");
-        execute_sql("UPDATE {$CFG->prefix}grade_item SET courseid='0' WHERE courseid IS NULL");
-        table_column('grade_item','courseid','courseid','int','10','unsigned','0','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}grade_item SET category='0' WHERE category IS NULL");
-        table_column('grade_item','category','category','int','10','unsigned','0','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}grade_item SET modid='0' WHERE modid IS NULL");
-        table_column('grade_item','modid','modid','int','10','unsigned','0','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}grade_item SET cminstance='0' WHERE cminstance IS NULL");
-        table_column('grade_item','cminstance','cminstance','int','10','unsigned','0','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}grade_item SET scale_grade='0' WHERE scale_grade IS NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}grade_item change scale_grade scale_grade float(11,10) NOT NULL default 1.0000000000");
-        
-        execute_sql("UPDATE {$CFG->prefix}grade_preferences SET courseid='0' WHERE courseid IS NULL");
-        table_column('grade_preferences','courseid','courseid','int','10','unsigned','0','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}user SET idnumber='' WHERE idnumber IS NULL");
-        table_column('user','idnumber','idnumber','varchar','64','','','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}user SET icq='' WHERE icq IS NULL");
-        table_column('user','icq','icq','varchar','15','','','not null');
-        
-        execute_sql("UPDATE {$CFG->prefix}user SET skype='' WHERE skype IS NULL");
-        table_column('user','skype','skype','varchar','50','','','not null');
-        
-        execute_sql("UPDATE {$CFG->prefix}user SET yahoo='' WHERE yahoo IS NULL");
-        table_column('user','yahoo','yahoo','varchar','50','','','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}user SET aim='' WHERE aim IS NULL");
-        table_column('user','aim','aim','varchar','50','','','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}user SET msn='' WHERE msn IS NULL");
-        table_column('user','msn','msn','varchar','50','','','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}user SET phone1='' WHERE phone1 IS NULL");
-        table_column('user','phone1','phone1','varchar','20','','','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}user SET phone2='' WHERE phone2 IS NULL");
-        table_column('user','phone2','phone2','varchar','20','','','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}user SET institution='' WHERE institution IS NULL");
-        table_column('user','institution','institution','varchar','40','','','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}user SET department='' WHERE department IS NULL");
-        table_column('user','department','department','varchar','30','','','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}user SET address='' WHERE address IS NULL");
-        table_column('user','address','address','varchar','70','','','not null');
-        
-        execute_sql("UPDATE {$CFG->prefix}user SET city='' WHERE city IS NULL");
-        table_column('user','city','city','varchar','20','','','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}user SET country='' WHERE country IS NULL");
-        table_column('user','country','country','char','2','','','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}user SET lang='' WHERE lang IS NULL");
-        table_column('user','lang','lang','varchar','10','','en','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}user SET lastIP='' WHERE lastIP IS NULL");
-        table_column('user','lastIP','lastIP','varchar','15','','','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}user SET secret='' WHERE secret IS NULL");
-        table_column('user','secret','secret','varchar','15','','','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}user SET picture='0' WHERE picture IS NULL");
-        table_column('user','picture','picture','tinyint','1','','0','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}user SET url='' WHERE url IS NULL");
-        table_column('user','url','url','varchar','255','','','not null');
-    }
-    
-    if ($oldversion < 2006050400) {
-
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_deleted_idx;",false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_confirmed_idx;",false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_firstname_idx;",false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_lastname_idx;",false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_city_idx;",false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_country_idx;",false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_lastaccess_idx;",false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_email_idx;",false);
-
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` ADD INDEX user_deleted (deleted)",false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` ADD INDEX user_confirmed (confirmed)",false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` ADD INDEX user_firstname (firstname)",false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` ADD INDEX user_lastname (lastname)",false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` ADD INDEX user_city (city)",false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` ADD INDEX user_country (country)",false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` ADD INDEX user_lastaccess (lastaccess)",false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}user` ADD INDEX user_email (email)",false);
-    }
-    
-    if ($oldversion < 2006050500) {
-        table_column('log', 'action', 'action', 'varchar', '40', '', '', 'not null');
-    }
-
-    if ($oldversion < 2006050501) {
-        table_column('sessions', 'data', 'data', 'mediumtext', '', '', '', 'not null');
-    }
-    
-    // renaming of reads and writes for stats_user_xyz
-    if ($oldversion < 2006052400) { // change this later
-
-        // we are using this because we want silent updates
-
-        execute_sql("ALTER TABLE `{$CFG->prefix}stats_user_daily` CHANGE `reads` statsreads int(10) unsigned  NOT NULL default 0", false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}stats_user_daily` CHANGE `writes` statswrites int(10) unsigned  NOT NULL default 0", false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}stats_user_weekly` CHANGE `reads` statsreads int(10) unsigned  NOT NULL default 0", false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}stats_user_weekly` CHANGE `writes` statswrites int(10) unsigned  NOT NULL default 0", false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}stats_user_monthly` CHANGE `reads` statsreads int(10) unsigned  NOT NULL default 0", false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}stats_user_monthly` CHANGE `writes` statswrites int(10) unsigned  NOT NULL default 0", false);
-  
-    }
-
-    // Adding some missing log actions
-    if ($oldversion < 2006060400) {
-        // But only if they doesn't exist (because this was introduced after branch and we could be duplicating!)
-        if (!record_exists('log_display', 'module', 'course', 'action', 'report log')) {
-            execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('course', 'report log', 'course', 'fullname')");
-        }
-        if (!record_exists('log_display', 'module', 'course', 'action', 'report live')) {
-            execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('course', 'report live', 'course', 'fullname')");
-        }
-        if (!record_exists('log_display', 'module', 'course', 'action', 'report outline')) {
-            execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('course', 'report outline', 'course', 'fullname')");
-        }
-        if (!record_exists('log_display', 'module', 'course', 'action', 'report participation')) {
-            execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('course', 'report participation', 'course', 'fullname')");
-        }
-        if (!record_exists('log_display', 'module', 'course', 'action', 'report stats')) {
-            execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('course', 'report stats', 'course', 'fullname')");
-        }
-    }
-
-    //Renaming lastIP to lastip (all fields lowercase)
-    if ($oldversion < 2006060900) {
-        //Only if it exists
-        $fields = $db->MetaColumnNames($CFG->prefix.'user');
-        if (in_array('lastIP',$fields)) {
-            table_column("user", "lastIP", "lastip", "varchar", "15", "", "", "not null", "currentlogin");
-        }
-    }
-
-    // Change in MySQL 5.0.3 concerning how decimals are stored. Mimic from 16_STABLE
-    // this isn't dangerous because it's a simple type change, but be careful with
-    // versions and duplicate work in order to provide smooth upgrade paths.
-    if ($oldversion < 2006071800) {
-        table_column('grade_letter', 'grade_high', 'grade_high', 'decimal(5,2)', '', '', '100.00', 'not null', '');
-        table_column('grade_letter', 'grade_low', 'grade_low', 'decimal(5,2)', '', '', '0.00', 'not null', '');
-    }
-    
-    if ($oldversion < 2006080400) {
-        execute_sql("CREATE TABLE {$CFG->prefix}role (
-                              `id` int(10) unsigned NOT NULL auto_increment,
-                              `name` varchar(255) NOT NULL default '',
-                              `shortname` varchar(100) NOT NULL default '',
-                              `description` text NOT NULL default '',
-                              `sortorder` int(10) unsigned NOT NULL default '0',
-                              PRIMARY KEY  (`id`)
-                            )", true);
-
-        execute_sql("CREATE TABLE {$CFG->prefix}context (
-                              `id` int(10) unsigned NOT NULL auto_increment,
-                              `level` int(10) unsigned NOT NULL default '0',
-                              `instanceid` int(10) unsigned NOT NULL default '0',
-                              PRIMARY KEY  (`id`)
-                            )", true);
-
-        execute_sql("CREATE TABLE {$CFG->prefix}role_assignments (
-                              `id` int(10) unsigned NOT NULL auto_increment,
-                              `roleid` int(10) unsigned NOT NULL default '0',
-                              `contextid` int(10) unsigned NOT NULL default '0',
-                              `userid` int(10) unsigned NOT NULL default '0',
-                              `hidden` int(1) unsigned NOT NULL default '0',
-                              `timestart` int(10) unsigned NOT NULL default '0',
-                              `timeend` int(10) unsigned NOT NULL default '0',
-                              `timemodified` int(10) unsigned NOT NULL default '0',
-                              `modifierid` int(10) unsigned NOT NULL default '0',
-                              `enrol` varchar(20) NOT NULL default '',
-                              `sortorder` int(10) unsigned NOT NULL default '0',
-                              PRIMARY KEY  (`id`)
-                            )", true);
-
-        execute_sql("CREATE TABLE {$CFG->prefix}role_capabilities (
-                              `id` int(10) unsigned NOT NULL auto_increment,
-                              `contextid` int(10) unsigned NOT NULL default '0',
-                              `roleid` int(10) unsigned NOT NULL default '0',
-                              `capability` varchar(255) NOT NULL default '',
-                              `permission` int(10) unsigned NOT NULL default '0',
-                              `timemodified` int(10) unsigned NOT NULL default '0',
-                              `modifierid` int(10) unsigned NOT NULL default '0',
-                              PRIMARY KEY (`id`)
-                            )", true);
-                            
-        execute_sql("CREATE TABLE {$CFG->prefix}role_deny_grant (
-                              `id` int(10) unsigned NOT NULL auto_increment,
-                              `roleid` int(10) unsigned NOT NULL default '0',
-                              `unviewableroleid` int(10) unsigned NOT NULL default '0',
-                              PRIMARY KEY (`id`)
-                            )", true);
-                            
-        execute_sql("CREATE TABLE {$CFG->prefix}capabilities ( 
-                              `id` int(10) unsigned NOT NULL auto_increment, 
-                              `name` varchar(255) NOT NULL default '', 
-                              `captype` varchar(50) NOT NULL default '', 
-                              `contextlevel` int(10) unsigned NOT NULL default '0', 
-                              `component` varchar(100) NOT NULL default '', 
-                              PRIMARY KEY (`id`) 
-                            )", true);     
-                            
-        execute_sql("CREATE TABLE {$CFG->prefix}role_names ( 
-                              `id` int(10) unsigned NOT NULL auto_increment, 
-                              `roleid` int(10) unsigned NOT NULL default '0',
-                              `contextid` int(10) unsigned NOT NULL default '0', 
-                              `text` text NOT NULL default '',
-                              PRIMARY KEY (`id`) 
-                            )", true);                      
-                        
-    }
-    
-    if ($oldversion < 2006081000) {
-      
-        execute_sql("ALTER TABLE `{$CFG->prefix}role` ADD INDEX `sortorder` (`sortorder`)",true);
-        
-        execute_sql("ALTER TABLE `{$CFG->prefix}context` ADD INDEX `instanceid` (`instanceid`)",true);
-        execute_sql("ALTER TABLE `{$CFG->prefix}context` ADD UNIQUE INDEX `level-instanceid` (`level`, `instanceid`)",true);
-
-        execute_sql("ALTER TABLE `{$CFG->prefix}role_assignments` ADD INDEX `roleid` (`roleid`)",true);
-        execute_sql("ALTER TABLE `{$CFG->prefix}role_assignments` ADD INDEX `contextid` (`contextid`)",true);  
-        execute_sql("ALTER TABLE `{$CFG->prefix}role_assignments` ADD INDEX `userid` (`userid`)",true);
-        execute_sql("ALTER TABLE `{$CFG->prefix}role_assignments` ADD UNIQUE INDEX `contextid-roleid-userid` (`contextid`, `roleid`, `userid`)",true);
-        execute_sql("ALTER TABLE `{$CFG->prefix}role_assignments` ADD INDEX `sortorder` (`sortorder`)",true);
-
-        execute_sql("ALTER TABLE `{$CFG->prefix}role_capabilities` ADD INDEX `roleid` (`roleid`)",true);
-        execute_sql("ALTER TABLE `{$CFG->prefix}role_capabilities` ADD INDEX `contextid` (`contextid`)",true); 
-        execute_sql("ALTER TABLE `{$CFG->prefix}role_capabilities` ADD INDEX `modifierid` (`modifierid`)",true);                
-        // MDL-10640  adding missing index from upgrade
-        execute_sql("ALTER TABLE `{$CFG->prefix}role_capabilities` ADD INDEX `capability` (`capability`)",true);   
-        execute_sql("ALTER TABLE `{$CFG->prefix}role_capabilities` ADD UNIQUE INDEX `roleid-contextid-capability` (`roleid`, `contextid`, `capability`)",true);         
-                        
-        execute_sql("ALTER TABLE `{$CFG->prefix}role_deny_grant` ADD INDEX `roleid` (`roleid`)",true);
-        execute_sql("ALTER TABLE `{$CFG->prefix}role_deny_grant` ADD INDEX `unviewableroleid` (`unviewableroleid`)",true);    
-        execute_sql("ALTER TABLE `{$CFG->prefix}role_deny_grant` ADD UNIQUE INDEX `roleid-unviewableroleid` (`roleid`, `unviewableroleid`)",true);         
-       
-        execute_sql("ALTER TABLE `{$CFG->prefix}capabilities` ADD UNIQUE INDEX `name` (`name`)",true); 
-                             
-        execute_sql("ALTER TABLE `{$CFG->prefix}role_names` ADD INDEX `roleid` (`roleid`)",true);                         
-        execute_sql("ALTER TABLE `{$CFG->prefix}role_names` ADD INDEX `contextid` (`contextid`)",true); 
-        execute_sql("ALTER TABLE `{$CFG->prefix}role_names` ADD UNIQUE INDEX `roleid-contextid` (`roleid`, `contextid`)",true);                 
-    }
-    
-    if ($oldversion < 2006081600) {
-        execute_sql("ALTER TABLE `{$CFG->prefix}role_capabilities` CHANGE permission permission int(10) NOT NULL default '0'",true);   
-    }
-    
-    // drop role_deny_grant table, and create 2 new ones
-    if ($oldversion < 2006081700) {
-        execute_sql("DROP TABLE `{$CFG->prefix}role_deny_grant`", true);
-        
-        execute_sql("CREATE TABLE {$CFG->prefix}role_allow_assign (
-                    `id` int(10) unsigned NOT NULL auto_increment,
-                    `roleid` int(10) unsigned NOT NULL default '0',
-                    `allowassign` int(10) unsigned NOT NULL default '0',
-                    KEY `roleid` (`roleid`),
-                    KEY `allowassign` (`allowassign`),
-                    UNIQUE KEY `roleid-allowassign` (`roleid`, `allowassign`),
-                    PRIMARY KEY (`id`)
-                    )", true); 
-                            
-        execute_sql("CREATE TABLE {$CFG->prefix}role_allow_override (
-                    `id` int(10) unsigned NOT NULL auto_increment,
-                    `roleid` int(10) unsigned NOT NULL default '0',
-                    `allowoverride` int(10) unsigned NOT NULL default '0',
-                    KEY `roleid` (`roleid`),
-                    KEY `allowoverride` (`allowoverride`),
-                    UNIQUE KEY `roleid-allowoverride` (`roleid`, `allowoverride`),
-                    PRIMARY KEY (`id`)
-                    )", true); 
-        
-    }
-    
-    if ($oldversion < 2006082100) {
-        execute_sql("ALTER TABLE `{$CFG->prefix}context` DROP INDEX `level-instanceid`;",false);
-        table_column('context', 'level', 'aggregatelevel', 'int', '10', 'unsigned', '0', 'not null', '');
-        execute_sql("ALTER TABLE `{$CFG->prefix}context` ADD UNIQUE INDEX `aggregatelevel-instanceid` (`aggregatelevel`, `instanceid`)",false);
-    }
-    
-    if ($oldversion < 2006082200) {
-        table_column('timezone', 'rule', 'tzrule', 'varchar', '20', '', '', 'not null', '');
-    }
-
-    if ($oldversion < 2006082800) {
-        table_column('user', '', 'ajax', 'integer', '1', 'unsigned', '1', 'not null', 'htmleditor');
-    }
-
-    if ($oldversion < 2006082900) {
-        execute_sql("DROP TABLE {$CFG->prefix}sessions", true);
-        execute_sql("
-            CREATE TABLE {$CFG->prefix}sessions2 (
-                sesskey VARCHAR(64) NOT NULL default '',
-                expiry DATETIME NOT NULL,
-                expireref VARCHAR(250),
-                created DATETIME NOT NULL,
-                modified DATETIME NOT NULL,
-                sessdata TEXT,
-                CONSTRAINT  PRIMARY KEY (sesskey)
-            ) COMMENT='Optional database session storage in new format, not used by default';", true);
-
-        execute_sql("
-            CREATE INDEX {$CFG->prefix}sess_exp_ix ON {$CFG->prefix}sessions2 (expiry);", true);
-        execute_sql("
-            CREATE INDEX {$CFG->prefix}sess_exp2_ix ON {$CFG->prefix}sessions2 (expireref);", true);
-    }
-
-    if ($oldversion < 2006083001) {
-        table_column('sessions2', 'sessdata', 'sessdata', 'LONGTEXT', '', '', '', '', '');
-    }
-    
-    if ($oldversion < 2006083002) {
-        table_column('capabilities', '', 'riskbitmask', 'INTEGER', '10', 'unsigned', '0', 'not null', '');
-    }
-
-    if ($oldversion < 2006083100) {
-        execute_sql("ALTER TABLE {$CFG->prefix}course CHANGE modinfo modinfo longtext NULL AFTER showgrades");
-    }
-
-    if ($oldversion < 2006083101) {
-        execute_sql("ALTER TABLE {$CFG->prefix}course_categories CHANGE description description text NULL AFTER name");
-    }
-
-    if ($oldversion < 2006083102) {
-        execute_sql("ALTER TABLE {$CFG->prefix}user CHANGE description description text NULL AFTER url");
-    }
-
-    if ($oldversion < 2006090200) {
-        execute_sql("ALTER TABLE {$CFG->prefix}course_sections CHANGE summary summary text NULL AFTER section");
-        execute_sql("ALTER TABLE {$CFG->prefix}course_sections CHANGE sequence sequence text NULL AFTER section");
-    }
-
-
-    // table to keep track of course page access times, used in online participants block, and participants list
-    if ($oldversion < 2006091200) {
-        execute_sql("CREATE TABLE {$CFG->prefix}user_lastaccess ( 
-                    `id` int(10) unsigned NOT NULL auto_increment, 
-                    `userid` int(10) unsigned NOT NULL default '0',
-                    `courseid` int(10) unsigned NOT NULL default '0', 
-                    `timeaccess` int(10) unsigned NOT NULL default '0', 
-                    KEY `userid` (`userid`),
-                    KEY `courseid` (`courseid`),
-                    UNIQUE KEY `userid-courseid` (`userid`, `courseid`),
-                    PRIMARY KEY (`id`) 
-                    )TYPE=MYISAM COMMENT ='time user last accessed any page in a course';", true);
-    }
-
-    if (!empty($CFG->rolesactive) and $oldversion < 2006091212) {   // Reload the guest roles completely with new defaults
-        if ($guestroles = get_roles_with_capability('moodle/legacy:guest', CAP_ALLOW)) {
-            delete_records('capabilities');
-            $sitecontext = get_context_instance(CONTEXT_SYSTEM);
-            foreach ($guestroles as $guestrole) {
-                delete_records('role_capabilities', 'roleid', $guestrole->id);
-                assign_capability('moodle/legacy:guest', CAP_ALLOW, $guestrole->id, $sitecontext->id);
-            }
-        }
-    }
-
-    if ($oldversion < 2006091700) {
-        table_column('course','','defaultrole','integer','10', 'unsigned', '0', 'not null');
-    }
-
-    if ($oldversion < 2006091800) {
-        delete_records('config', 'name', 'showsiteparticipantslist');
-        delete_records('config', 'name', 'requestedteachername');
-        delete_records('config', 'name', 'requestedteachersname');
-        delete_records('config', 'name', 'requestedstudentname');
-        delete_records('config', 'name', 'requestedstudentsname');
-    }
-
-    if (!empty($CFG->rolesactive) and $oldversion < 2006091901) {
-        if ($roles = get_records('role')) {
-            $first = array_shift($roles);
-            if (!empty($first->shortname)) {
-                // shortnames already exist
-            } else {
-                table_column('role', '', 'shortname', 'varchar', '100', '', '', 'not null', 'name');
-                $legacy_names = array('admin', 'coursecreator', 'editingteacher', 'teacher', 'student', 'guest');
-                foreach ($legacy_names as $name) {
-                    if ($roles = get_roles_with_capability('moodle/legacy:'.$name, CAP_ALLOW)) {
-                        $i = '';
-                        foreach ($roles as $role) {
-                            if (empty($role->shortname)) {
-                                $updated = new object();
-                                $updated->id = $role->id;
-                                $updated->shortname = $name.$i;
-                                update_record('role', $updated);
-                                $i++;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    /// Tables for customisable user profile fields
-    if ($oldversion < 2006092000) {
-        execute_sql("CREATE TABLE {$CFG->prefix}user_info_field (
-                        id BIGINT(10) NOT NULL auto_increment,
-                        name VARCHAR(255) NOT NULL default '',
-                        datatype VARCHAR(255) NOT NULL default '',
-                        categoryid BIGINT(10) unsigned NOT NULL default 0,
-                        sortorder BIGINT(10) unsigned NOT NULL default 0,
-                        required TINYINT(2) unsigned NOT NULL default 0,
-                        locked TINYINT(2) unsigned NOT NULL default 0,
-                        visible SMALLINT(4) unsigned NOT NULL default 0,
-                        defaultdata LONGTEXT,
-                        CONSTRAINT  PRIMARY KEY (id));", true);
-
-        execute_sql("ALTER TABLE {$CFG->prefix}user_info_field COMMENT='Customisable user profile fields';", true);
-
-        execute_sql("CREATE TABLE {$CFG->prefix}user_info_category (
-                        id BIGINT(10) NOT NULL auto_increment,
-                        name VARCHAR(255) NOT NULL default '',
-                        sortorder BIGINT(10) unsigned NOT NULL default 0,
-                        CONSTRAINT  PRIMARY KEY (id));", true);
-
-        execute_sql("ALTER TABLE {$CFG->prefix}user_info_category COMMENT='Customisable fields categories';", true);
-
-        execute_sql("CREATE TABLE {$CFG->prefix}user_info_data (
-                        id BIGINT(10) NOT NULL auto_increment,
-                        userid BIGINT(10) unsigned NOT NULL default 0,
-                        fieldid BIGINT(10) unsigned NOT NULL default 0,
-                        data LONGTEXT NOT NULL,
-                        CONSTRAINT  PRIMARY KEY (id));", true);
-
-        execute_sql("ALTER TABLE {$CFG->prefix}user_info_data COMMENT='Data for the customisable user fields';", true);
-
-
-    }
-
-    if ($oldversion < 2006092200) {
-       table_column('context', 'aggregatelevel', 'contextlevel', 'int', '10', 'unsigned', '0', 'not null', '');
-/*        execute_sql("ALTER TABLE `{$CFG->prefix}context` DROP INDEX `aggregatelevel-instanceid`;",false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}context` ADD UNIQUE INDEX `contextlevel-instanceid` (`contextlevel`, `instanceid`)",false);   // see 2006092409 below  */
-    }
-
-    if ($oldversion < 2006092201) {
-        execute_sql('TRUNCATE TABLE '.$CFG->prefix.'cache_text', true);
-        table_column('cache_text','formattedtext','formattedtext','longtext','','','','not null');
-    }
-
-    if ($oldversion < 2006092302) {
-        // fix sortorder first if needed
-        if ($roles = get_all_roles()) {
-            $i = 0;
-            foreach ($roles as $rolex) {
-                if ($rolex->sortorder != $i) {
-                    $r = new object();
-                    $r->id = $rolex->id;
-                    $r->sortorder = $i;
-                    update_record('role', $r);
-                }
-                $i++;
-            }
-        }
-/*        execute_sql("ALTER TABLE {$CFG->prefix}role DROP INDEX {$CFG->prefix}role_sor_ix;", false);
-        execute_sql("ALTER TABLE {$CFG->prefix}role ADD UNIQUE INDEX {$CFG->prefix}role_sor_uix (sortorder)", false);*/
-    }
-
-    if ($oldversion < 2006092400) {
-        table_column('user', '', 'trustbitmask', 'INTEGER', '10', 'unsigned', '0', 'not null', '');
-    }
-
-    if ($oldversion < 2006092409) {
-        // ok, once more and now correctly!
-        execute_sql("DROP INDEX `aggregatelevel-instanceid` ON {$CFG->prefix}context ;", false);
-        execute_sql("DROP INDEX `contextlevel-instanceid` ON {$CFG->prefix}context ;", false);
-        execute_sql("CREATE UNIQUE INDEX {$CFG->prefix}cont_conins_uix ON {$CFG->prefix}context (contextlevel, instanceid);", false);
-
-        execute_sql("DROP INDEX {$CFG->prefix}role_sor_ix ON {$CFG->prefix}role ;", false);
-        execute_sql("DROP INDEX {$CFG->prefix}role_sor_uix ON {$CFG->prefix}role ;", false);
-        execute_sql("CREATE UNIQUE INDEX {$CFG->prefix}role_sor_uix ON {$CFG->prefix}role (sortorder);", false);
-    }
-
-    if ($oldversion < 2006092601) {
-        table_column('log_display', 'field', 'field', 'varchar', '200', '', '', 'not null', '');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return $result;
-}
-
-?>
diff --git a/lib/db/postgres7.php b/lib/db/postgres7.php
deleted file mode 100644 (file)
index 3decbc2..0000000
+++ /dev/null
@@ -1,1961 +0,0 @@
-<?PHP  //$Id$
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to PostgreSQL 7
-
-function main_upgrade($oldversion=0) {
-
-    global $CFG, $THEME, $db;
-
-    $result = true;
-
-
-    if ($oldversion < 2003010101) {
-        delete_records("log_display", "module", "user");
-        $new->module = "user";
-        $new->action = "view";
-        $new->mtable = "user";
-        $new->field  = "CONCAT(firstname,\" \",lastname)";
-        insert_record("log_display", $new);
-
-        delete_records("log_display", "module", "course");
-        $new->module = "course";
-        $new->action = "view";
-        $new->mtable = "course";
-        $new->field  = "fullname";
-        insert_record("log_display", $new);
-        $new->action = "update";
-        insert_record("log_display", $new);
-        $new->action = "enrol";
-        insert_record("log_display", $new);
-    }
-    
-    //support user based course creating
-    if ($oldversion < 2003032400) {
-        execute_sql("CREATE TABLE {$CFG->prefix}user_coursecreators (
-                                  id int8 SERIAL PRIMARY KEY,
-                                  userid int8  NOT NULL default '0'
-                                  )");
-    }
-
-    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 ($files = get_directory_list($CFG->dataroot)) {
-            echo "Attempting to update permissions for all files... ignore any errors.";
-            foreach ($files as $file) {
-                echo "$CFG->dataroot/$file<br />";
-                @chmod("$CFG->dataroot/$file", $CFG->directorypermissions);
-            }
-        }
-    }
-
-    if ($oldversion < 2003042400) {
-    // Rebuild all course caches, because of changes to do with visible variable
-        if ($courses = get_records_sql("SELECT * FROM {$CFG->prefix}course")) {
-            require_once("$CFG->dirroot/course/lib.php");
-            foreach ($courses as $course) {
-                $modinfo = serialize(get_array_of_activities($course->id));
-
-                if (!set_field("course", "modinfo", $modinfo, "id", $course->id)) {
-                    notify("Could not cache module information for course '" . format_string($course->fullname) . "'!");
-                }
-            }
-        }
-    }
-
-    if ($oldversion < 2003042500) {                 
-    //  Convert all usernames to lowercase.  
-        $users = get_records_sql("SELECT id, username FROM {$CFG->prefix}user"); 
-        $cerrors = "";
-        $rarray = array();
-
-        foreach ($users as $user) {      // Check for possible conflicts
-            $lcname = trim(moodle_strtolower($user->username));
-            if (in_array($lcname, $rarray)) {
-                $cerrors .= $user->id."->".$lcname.'<br/>' ; 
-            } else {
-                array_push($rarray,$lcname);
-            }
-        }
-
-        if ($cerrors != '') {
-            notify("Error: Cannot convert usernames to lowercase. 
-                    Following usernames would overlap (id->username):<br/> $cerrors . 
-                    Please resolve overlapping errors."); 
-            $result = false;
-        }
-
-        $cerrors = "";
-        echo "Checking userdatabase:<br />";
-        foreach ($users as $user) {
-            $lcname = trim(moodle_strtolower($user->username));
-            if ($lcname != $user->username) {
-                $convert = set_field("user" , "username" , $lcname, "id", $user->id);
-                if (!$convert) {
-                    if ($cerrors){
-                       $cerrors .= ", ";
-                    }   
-                    $cerrors .= $item;
-                } else {
-                    echo ".";
-                }   
-            }
-        }
-        if ($cerrors != '') {
-            notify("There were errors when converting following usernames to lowercase. 
-                   '$cerrors' . Sorry, but you will need to fix your database by hand.");
-            $result = false;
-        }
-    }
-
-    if ($oldversion < 2003042700) {
-        /// Changing to multiple indexes
-        execute_sql(" CREATE INDEX {$CFG->prefix}log_coursemoduleaction_idx ON {$CFG->prefix}log (course,module,action) ");
-        execute_sql(" CREATE INDEX {$CFG->prefix}log_courseuserid_idx ON {$CFG->prefix}log (course,userid) ");
-    }
-
-    if ($oldversion < 2003042801) {
-        execute_sql("CREATE TABLE {$CFG->prefix}course_display (
-                         id SERIAL PRIMARY KEY,
-                         course integer NOT NULL default '0',
-                         userid integer NOT NULL default '0',
-                         display integer NOT NULL default '0'
-                      )");
-
-        execute_sql("CREATE INDEX {$CFG->prefix}course_display_courseuserid_idx ON {$CFG->prefix}course_display (course,userid)");
-    }
-
-    if ($oldversion < 2003050400) {
-        table_column("course_sections", "", "visible", "integer", "1", "unsigned", "1", "", "");
-    }
-                                                            
-    if ($oldversion < 2003050401) {
-        table_column("user", "", "lang", "VARCHAR", "5", "", "$CFG->lang" ,"NOT NULL","");
-    }
-
-    if ($oldversion < 2003050900) {
-        table_column("modules", "", "visible", "integer", "1", "unsigned", "1", "", "");
-    }
-
-    if ($oldversion < 2003050902) {
-        if (get_records("modules", "name", "pgassignment")) {
-            print_simple_box("Note: the pgassignment module will soon be deleted from CVS!  Go to the new 'Manage Modules' page and DELETE IT from your system", "center", "50%", "$THEME->cellheading", "20", "noticebox");
-        }
-    }
-
-    if ($oldversion < 2003051600) {
-        print_simple_box("Thanks for upgrading!<p>There are many changes since the last release.  Please read the release notes carefully.  If you are using CUSTOM themes you will need to edit them.  You will also need to check your site's config.php file.", "center", "50%", "$THEME->cellheading", "20", "noticebox");
-    }
-
-    if ($oldversion < 2003052300) {
-        table_column("user", "", "autosubscribe", "integer", "1", "unsigned", "1", "", "htmleditor");
-    }
-
-    if ($oldversion < 2003072100) {
-        table_column("course", "", "visible", "integer", "1", "unsigned", "1", "", "marker");
-    }
-
-    if ($oldversion < 2003072101) {
-        table_column("course_sections", "sequence", "sequence", "text", "", "", "", "", "");
-    }
-
-    if ($oldversion < 2003072800) {
-        print_simple_box("The following database index improves performance, but can be quite large - if you are upgrading and you have problems with a limited quota you may want to delete this index later from the '{$CFG->prefix}log' table in your database", "center", "50%", "$THEME->cellheading", "20", "noticebox");
-        flush();
-        execute_sql(" CREATE INDEX {$CFG->prefix}log_timecoursemoduleaction_idx ON {$CFG->prefix}log (time,course,module,action) ");
-        execute_sql(" CREATE INDEX {$CFG->prefix}user_students_courseuserid_idx ON {$CFG->prefix}user_students (course,userid) ");
-        execute_sql(" CREATE INDEX {$CFG->prefix}user_teachers_courseuserid_idx ON {$CFG->prefix}user_teachers (course,userid) ");
-    }
-
-    if ($oldversion < 2003072802) {
-        table_column("course_categories", "", "description", "text", "", "", "");
-        table_column("course_categories", "", "parent", "integer", "10", "unsigned");
-        table_column("course_categories", "", "sortorder", "integer", "10", "unsigned");
-        table_column("course_categories", "", "courseorder", "text", "", "", "");
-        table_column("course_categories", "", "visible", "integer", "1", "unsigned", "1");
-        table_column("course_categories", "", "timemodified", "integer", "10", "unsigned");
-    }
-
-    if ($oldversion < 2003080400) {
-        notify("If the following command fails you may want to change the type manually, from TEXT to INTEGER.  Moodle should keep working even if you don't.");
-        table_column("course_categories", "courseorder", "courseorder", "integer", "10", "unsigned");
-        table_column("course", "", "sortorder", "integer", "10", "unsigned", "0", "", "category");
-    }
-
-    if ($oldversion < 2003081502) {
-        execute_sql(" CREATE TABLE {$CFG->prefix}scale (
-                         id SERIAL PRIMARY KEY,
-                         courseid integer NOT NULL default '0',
-                         userid integer NOT NULL default '0',
-                         name varchar(255) NOT NULL default '',
-                         scale text,
-                         description text,
-                         timemodified integer NOT NULL default '0'
-                      )");
-    }
-
-    if ($oldversion < 2003081503) {
-        table_column("forum", "", "scale", "integer", "10", "unsigned", "0", "", "assessed");
-        get_scales_menu(0);    // Just to force the default scale to be created
-    }
-
-    if ($oldversion < 2003081600) {
-        table_column("user_teachers", "", "editall", "integer", "1", "unsigned", "1", "", "role");
-        table_column("user_teachers", "", "timemodified", "integer", "10", "unsigned", "0", "", "editall");
-    }
-
-    if ($oldversion < 2003081900) {
-        table_column("course_categories", "courseorder", "coursecount", "integer", "10", "unsigned", "0");
-    }
-
-    if ($oldversion < 2003080700) {
-        notify("Cleaning up categories and course ordering...");
-        fix_course_sortorder();
-    }
-
-
-    if ($oldversion < 2003082001) {
-        table_column("course", "", "showgrades", "integer", "2", "unsigned", "1", "", "format");
-    }
-
-    if ($oldversion < 2003082101) {
-        execute_sql(" CREATE INDEX {$CFG->prefix}course_category_idx ON {$CFG->prefix}course (category) ");
-    }
-    if ($oldversion < 2003082702) {
-        execute_sql(" INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('course', 'user report', 'user', 'CONCAT(firstname,\" \",lastname)') ");
-    }
-
-    if ($oldversion < 2003091000) {
-        # Old field that was never added!
-        table_column("course", "", "showrecent", "integer", "10", "unsigned", "1", "", "numsections");
-    }
-
-    if ($oldversion < 2003091400) {
-        table_column("course_modules", "", "indent", "integer", "5", "unsigned", "0", "", "score");
-    }
-
-    if ($oldversion < 2003092900) {
-        table_column("course", "", "maxbytes", "integer", "10", "unsigned", "0", "", "marker");
-    }
-
-    if ($oldversion < 2003102700) {
-        table_column("user_students", "", "timeaccess", "integer", "10", "unsigned", "0", "", "time");
-        table_column("user_teachers", "", "timeaccess", "integer", "10", "unsigned", "0", "", "timemodified");
-
-        $db->debug = false;
-        $CFG->debug = 0;
-        notify("Calculating access times.  Please wait - this may take a long time on big sites...", "green");
-        flush();
-
-        if ($courses = get_records_select("course", "category > 0")) {
-            foreach ($courses as $course) {
-                notify("Processing " . format_string($course->fullname) . " ...", "green");
-                flush();
-                if ($users = get_records_select("user_teachers", "course = '$course->id'", 
-                                                "id", "id, userid, timeaccess")) {
-                    foreach ($users as $user) {
-                        $loginfo = get_record_sql("SELECT id, time FROM {$CFG->prefix}log                                                                                  WHERE course = '$course->id' and userid = '$user->userid'                                                               ORDER by time DESC");
-                        if (empty($loginfo->time)) {
-                            $loginfo->time = 0;
-                        }
-                        execute_sql("UPDATE {$CFG->prefix}user_teachers                                                                                      SET timeaccess = '$loginfo->time' 
-                                     WHERE userid = '$user->userid' AND course = '$course->id'", false);
-                        
-                    }
-                }
-
-                if ($users = get_records_select("user_students", "course = '$course->id'", 
-                                                "id", "id, userid, timeaccess")) {
-                    foreach ($users as $user) {
-                        $loginfo = get_record_sql("SELECT id, time FROM {$CFG->prefix}log 
-                                                   WHERE course = '$course->id' and userid = '$user->userid' 
-                                                   ORDER by time DESC");
-                        if (empty($loginfo->time)) {
-                            $loginfo->time = 0;
-                        }
-                        execute_sql("UPDATE {$CFG->prefix}user_students 
-                                     SET timeaccess = '$loginfo->time' 
-                                     WHERE userid = '$user->userid' AND course = '$course->id'", false);
-                        
-                    }
-                }
-            }
-        }
-        notify("All courses complete.", "green");
-        $db->debug = true;
-    }
-
-    if ($oldversion < 2003103100) {
-        table_column("course", "", "showreports", "integer", "4", "unsigned", "0", "", "maxbytes");
-    }
-
-
-    if ($oldversion < 2003121600) {
-        execute_sql("CREATE TABLE {$CFG->prefix}groups (
-                        id SERIAL PRIMARY KEY,
-                        courseid integer NOT NULL default '0',
-                        name varchar(255) NOT NULL default '',
-                        description text,
-                        lang varchar(10) NOT NULL default '',
-                        picture integer NOT NULL default '0',
-                        timecreated integer NOT NULL default '0',
-                        timemodified integer NOT NULL default '0'
-                     )");
-    
-        execute_sql("CREATE INDEX {$CFG->prefix}groups_idx ON {$CFG->prefix}groups (courseid) ");
-    
-        execute_sql("CREATE TABLE {$CFG->prefix}groups_members (
-                        id SERIAL PRIMARY KEY,
-                        groupid integer NOT NULL default '0',
-                        userid integer NOT NULL default '0',
-                        timeadded integer NOT NULL default '0'
-                     )");
-      
-        execute_sql("CREATE INDEX {$CFG->prefix}groups_members_idx ON {$CFG->prefix}groups_members (groupid) ");
-    }
-
-    if ($oldversion < 2003122600) {
-        table_column("course", "", "groupmode", "integer", "4", "unsigned", "0", "", "visible");
-        table_column("course", "", "groupmodeforce", "integer", "4", "unsigned", "0", "", "groupmode");
-    }
-
-    if ($oldversion < 2004010900) {
-        table_column("course_modules", "", "groupmode", "integer", "4", "unsigned", "0", "", "visible");
-    }
-
-    if ($oldversion < 2004011700) {
-        modify_database("", "CREATE TABLE prefix_event (
-                                id SERIAL PRIMARY KEY,
-                                name varchar(255) NOT NULL default '',
-                                description text,
-                                courseid integer NOT NULL default '0',
-                                groupid integer NOT NULL default '0',
-                                userid integer NOT NULL default '0',
-                                modulename varchar(20) NOT NULL default '',
-                                instance integer NOT NULL default '0',
-                                eventtype varchar(20) NOT NULL default '',
-                                timestart integer NOT NULL default '0',
-                                timeduration integer NOT NULL default '0',
-                                timemodified integer NOT NULL default '0'
-                             ); ");
-
-        modify_database("", "CREATE INDEX prefix_event_courseid_idx ON prefix_event (courseid);");
-        modify_database("", "CREATE INDEX prefix_event_userid_idx ON prefix_event (userid);");
-    }
-
-
-    if ($oldversion < 2004012800) {
-        modify_database("", "CREATE TABLE prefix_user_preferences (
-                                id SERIAL PRIMARY KEY,
-                                userid integer NOT NULL default '0',
-                                name varchar(50) NOT NULL default '',
-                                value varchar(255) NOT NULL default ''
-                             ); ");
-
-        modify_database("", "CREATE INDEX prefix_user_preferences_useridname_idx ON prefix_user_preferences (userid,name);");
-    }
-
-    if ($oldversion < 2004012900) {
-        table_column("config", "value", "value", "text", "", "", "");
-    }
-
-    if ($oldversion < 2004013101) {
-        table_column("log", "", "cmid", "integer", "10", "unsigned", "0", "", "module");
-        set_config("upgrade", "logs");
-    }
-
-    if ($oldversion < 2004020900) {
-        table_column("course", "", "lang", "varchar", "5", "", "", "", "groupmodeforce");
-    }
-
-    if ($oldversion < 2004020903) {
-        modify_database("", "CREATE TABLE prefix_cache_text (
-                                id SERIAL PRIMARY KEY,
-                                md5key varchar(32) NOT NULL default '',
-                                formattedtext text,
-                                timemodified integer NOT NULL default '0'
-                             );");
-    }
-
-    if ($oldversion < 2004021000) {
-        $textfilters = array();
-        for ($i=1; $i<=10; $i++) {
-            $variable = "textfilter$i";
-            if (!empty($CFG->$variable)) {   /// No more filters
-                if (is_readable("$CFG->dirroot/".$CFG->$variable)) {
-                    $textfilters[] = $CFG->$variable;
-                }
-            }
-        }
-        $textfilters = implode(',', $textfilters);
-        if (empty($textfilters)) {
-            $textfilters = 'mod/glossary/dynalink.php';
-        }
-        set_config('textfilters', $textfilters);
-    }
-
-    if ($oldversion < 2004021201) {
-        modify_database("", "CREATE TABLE prefix_cache_filters (
-                                id SERIAL PRIMARY KEY,
-                                filter varchar(32) NOT NULL default '',
-                                version integer NOT NULL default '0',
-                                md5key varchar(32) NOT NULL default '',
-                                rawtext text,
-                                timemodified integer NOT NULL default '0'
-                             );");
-
-        modify_database("", "CREATE INDEX prefix_cache_filters_filtermd5key_idx ON prefix_cache_filters (filter,md5key);");
-        modify_database("", "CREATE INDEX prefix_cache_text_md5key_idx ON prefix_cache_text (md5key);");
-    }
-
-    if ($oldversion < 2004021500) {
-        table_column("groups", "", "hidepicture", "integer", "2", "unsigned", "0", "", "picture");
-    }
-
-    if ($oldversion < 2004021700) {
-        if (!empty($CFG->textfilters)) {
-            $CFG->textfilters = str_replace("tex_filter.php", "filter.php", $CFG->textfilters);
-            $CFG->textfilters = str_replace("multilang.php", "filter.php", $CFG->textfilters);
-            $CFG->textfilters = str_replace("censor.php", "filter.php", $CFG->textfilters);
-            $CFG->textfilters = str_replace("mediaplugin.php", "filter.php", $CFG->textfilters);
-            $CFG->textfilters = str_replace("algebra_filter.php", "filter.php", $CFG->textfilters);
-            $CFG->textfilters = str_replace("dynalink.php", "filter.php", $CFG->textfilters);
-            set_config("textfilters", $CFG->textfilters);
-        }
-    }
-
-    if ($oldversion < 2004022000) {
-        table_column("user", "", "emailstop", "integer", "1", "unsigned", "0", "not null", "email");
-    }
-
-    if ($oldversion < 2004022200) {     /// Final renaming I hope.  :-)
-        if (!empty($CFG->textfilters)) {
-            $CFG->textfilters = str_replace("/filter.php", "", $CFG->textfilters);
-            $CFG->textfilters = str_replace("mod/glossary/dynalink.php", "mod/glossary", $CFG->textfilters);
-            $textfilters = explode(',', $CFG->textfilters);
-            foreach ($textfilters as $key => $textfilter) {
-                $textfilters[$key] = trim($textfilter);
-            }
-            set_config("textfilters", implode(',',$textfilters));
-        }
-    }
-
-    if ($oldversion < 2004030702) {     /// Because of the renaming of Czech language pack
-        execute_sql("UPDATE {$CFG->prefix}user SET lang = 'cs' WHERE lang = 'cz'");
-        execute_sql("UPDATE {$CFG->prefix}course SET lang = 'cs' WHERE lang = 'cz'");
-    }
-
-    if ($oldversion < 2004041800) {     /// Integrate Block System from contrib
-        table_column("course", "", "blockinfo", "varchar", "255", "", "", "not null", "modinfo");
-    }
-
-    if ($oldversion < 2004042600) {     /// Rebuild course caches for resource icons
-        //include_once("$CFG->dirroot/course/lib.php");
-        //rebuild_course_cache();
-    }
-
-    if ($oldversion < 2004042700) {     /// Increase size of lang fields
-        table_column("user",   "lang", "lang", "varchar", "10", "", "en");
-        table_column("groups", "lang", "lang", "varchar", "10", "", "");
-        table_column("course", "lang", "lang", "varchar", "10", "", "");
-    }
-
-    if ($oldversion < 2004042701) {     /// Add hiddentopics field to control hidden topics behaviour
-        #table_column("course", "", "hiddentopics", "integer", "1", "unsigned", "0", "not null", "visible");
-        #See 'hiddensections' further down
-    }
-
-    if ($oldversion < 2004042702) {     /// Add a format field for the description 
-        table_column("event", "", "format", "integer", "4", "unsigned", "0", "not null", "description");
-    }
-
-    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", "smallint", "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);
-                    }
-                }
-            }
-        }
-    }
-
-    if ($oldversion < 2004052800) {     /// First version tagged "1.4 development", version.php 1.227
-        set_config('siteblocksadded', true);   /// This will be used later by the block upgrade
-    }
-
-    if ($oldversion < 2004053000) {     /// set defaults for site course
-        $site = get_site();
-        set_field('course', 'numsections', 0, 'id', $site->id);
-        set_field('course', 'groupmodeforce', 1, 'id', $site->id);
-        set_field('course', 'teacher', get_string('administrator'), 'id', $site->id);
-        set_field('course', 'teachers', get_string('administrators'), 'id', $site->id);
-        set_field('course', 'student', get_string('user'), 'id', $site->id);
-        set_field('course', 'students', get_string('users'), 'id', $site->id);
-    }
-
-    if ($oldversion < 2004060100) {
-        set_config('digestmailtime', 0);
-        table_column('user', "", 'maildigest', 'smallint', '1', '', '0', 'not null', 'mailformat');
-    }
-
-    if ($oldversion < 2004062400) {
-        table_column('user_teachers', "", 'timeend', 'int', '10', 'unsigned', '0', 'not null', 'editall');
-        table_column('user_teachers', "", 'timestart', 'int', '10', 'unsigned', '0', 'not null', 'editall');
-    }
-
-    if ($oldversion < 2004062401) {
-        table_column('course', '', 'idnumber', 'varchar', '100', '', '', 'not null', 'shortname');
-        execute_sql('UPDATE '.$CFG->prefix.'course SET idnumber = shortname');   // By default
-    }
-
-    if ($oldversion < 2004062600) {
-        table_column('course', '', 'cost', 'varchar', '10', '', '', 'not null', 'lang');
-    }
-
-    if ($oldversion < 2004072900) {
-        table_column('course', '', 'enrolperiod', 'int', '10', 'unsigned', '0', 'not null', 'startdate');
-    }
-
-    if ($oldversion < 2004072901) {  // Fixing error in schema
-        if ($record = get_record('log_display', 'module', 'course', 'action', 'update')) {
-            delete_records('log_display', 'module', 'course', 'action', 'update');
-            insert_record('log_display', $record, false);
-        }
-    }
-
-    if ($oldversion < 2004081200) {  // Fixing version errors in some blocks
-        set_field('blocks', 'version', 2004081200, 'name', 'admin');
-        set_field('blocks', 'version', 2004081200, 'name', 'calendar_month');
-        set_field('blocks', 'version', 2004081200, 'name', 'course_list');
-    }
-
-    if ($oldversion < 2004081500) {  // Adding new "auth" field to user table to allow more flexibility
-        table_column('user', '', 'auth', 'varchar', '20', '', 'manual', 'not null', 'id');
-
-        execute_sql("UPDATE {$CFG->prefix}user SET auth = 'manual'");  // Set everyone to 'manual' to be sure
-
-        if ($admins = get_admins()) {   // Set all the NON-admins to whatever the current auth module is
-            $adminlist = array();
-            foreach ($admins as $user) {
-                $adminlist[] = $user->id; 
-            }
-            $adminlist = implode(',', $adminlist);
-            execute_sql("UPDATE {$CFG->prefix}user SET auth = '$CFG->auth' WHERE id NOT IN ($adminlist)");
-        }
-    }
-    
-    if ($oldversion < 2004082600) {
-        //update auth-fields for external users
-        // following code would not work in 1.8
-/*        include_once ($CFG->dirroot."/auth/".$CFG->auth."/lib.php");
-        if (function_exists('auth_get_userlist')) {
-            $externalusers = auth_get_userlist();
-            if (!empty($externalusers)){
-                $externalusers = '\''. implode('\',\'',$externalusers).'\'';
-                execute_sql("UPDATE {$CFG->prefix}user SET auth = '$CFG->auth' WHERE username  IN ($externalusers)");
-            }
-        }*/
-    }
-        
-    if ($oldversion < 2004082900) {  // Make sure guest is "manual" too.
-        set_field('user', 'auth', 'manual', 'username', 'guest');
-    }
-
-    /* Just commenteed unused fields out
-    if ($oldversion < 2004090300) { // Add guid-field used in user syncronization
-            table_column('user', '', 'guid', 'varchar', '128', '', '', '', 'auth');
-            execute_sql("CREATE INDEX {$CFG->prefix}user_auth_guid_idx ON {$CFG->prefix}user (auth, guid)"); 
-    }
-    */
-
-    if ($oldversion < 2004091900) {  //Modify idnumber to hold longer keys 
-        set_field('user', 'auth', 'manual', 'username', 'guest');
-        table_column('user', 'idnumber', 'idnumber', 'varchar', '64', '', '', '', '');
-        execute_sql("DROP INDEX {$CFG->prefix}user_idnumber_idx ;",false);// added in case of conflicts with upgrade from 14stable
-        execute_sql("DROP INDEX {$CFG->prefix}user_auth_idx ;",false);// added in case of conflicts with upgrade from 14stable
-        execute_sql("CREATE INDEX {$CFG->prefix}user_idnumber_idx ON {$CFG->prefix}user (idnumber)"); 
-        execute_sql("CREATE INDEX {$CFG->prefix}user_auth_idx ON {$CFG->prefix}user (auth)"); 
-    }
-
-    if ($oldversion < 2004092000) { //redoing this just to be sure that column type is text (postgres type changes didnt work when this was done first time)
-        table_column("config", "value", "value", "text", "", "", "");
-    }
-
-    if ($oldversion < 2004093001) { // add new table for sessions storage
-        execute_sql(" CREATE TABLE {$CFG->prefix}sessions (
-                          sesskey char(32) PRIMARY KEY,
-                          expiry integer NOT null,
-                          expireref varchar(64),
-                          data text NOT null
-                      );");
-
-        execute_sql(" CREATE INDEX {$CFG->prefix}sessions_expiry_idx ON {$CFG->prefix}sessions (expiry)");
-    }
-
-    if ($oldversion < 2004111500) {  // Update any users/courses using wrongly-named lang pack
-        execute_sql("UPDATE {$CFG->prefix}user SET lang = 'mi_nt' WHERE lang = 'ma_nt'");
-        execute_sql("UPDATE {$CFG->prefix}course SET lang = 'mi_nt' WHERE lang = 'ma_nt'");
-    }
-
-    if ($oldversion < 2004111700) { // add indexes- drop them first silently to avoid conflicts when upgrading.
-        execute_sql("DROP INDEX {$CFG->prefix}course_idnumber_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}course_shortname_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}user_students_userid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}user_teachers_userid_idx;",false);
-
-        modify_database("","CREATE INDEX {$CFG->prefix}course_idnumber_idx ON {$CFG->prefix}course (idnumber);" );
-        modify_database("","CREATE INDEX {$CFG->prefix}course_shortname_idx ON {$CFG->prefix}course (shortname);" );
-        modify_database("","CREATE INDEX {$CFG->prefix}user_students_userid_idx ON {$CFG->prefix}user_students (userid);");
-        modify_database("","CREATE INDEX {$CFG->prefix}user_teachers_userid_idx ON {$CFG->prefix}user_teachers (userid);");
-    }
-    if ($oldversion < 2004111700) { // add an index to event for timestart and timeduration- drop them first silently to avoid conflicts when upgrading.
-        execute_sql("DROP INDEX {$CFG->prefix}event_timestart_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}event_timeduration_idx;",false);
-
-        modify_database('','CREATE INDEX prefix_event_timestart_idx ON prefix_event (timestart);');
-        modify_database('','CREATE INDEX prefix_event_timeduration_idx ON prefix_event (timeduration);');
-    }
-
-    if ($oldversion < 2004117000) { // add an index on the groups_members table- drop them first silently to avoid conflicts when upgrading.
-        execute_sql("DROP INDEX {$CFG->prefix}groups_members_userid_idx;",false);
-
-        modify_database('','CREATE INDEX prefix_groups_members_userid_idx ON prefix_groups_members (userid);');
-    }
-    
-    if ($oldversion < 2004111700) { //add indexes on modules and course_modules- drop them first silently to avoid conflicts when upgrading.
-        execute_sql("DROP INDEX {$CFG->prefix}course_modules_visible_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}course_modules_course_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}course_modules_module_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}course_modules_instance_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}course_modules_deleted_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}modules_name_idx;",false);
-
-        modify_database('','CREATE INDEX prefix_course_modules_visible_idx ON prefix_course_modules (visible);');
-        modify_database('','CREATE INDEX prefix_course_modules_course_idx ON prefix_course_modules (course);');
-        modify_database('','CREATE INDEX prefix_course_modules_module_idx ON prefix_course_modules (module);');
-        modify_database('','CREATE INDEX prefix_course_modules_instance_idx ON prefix_course_modules (instance);');
-        modify_database('','CREATE INDEX prefix_course_modules_deleted_idx ON prefix_course_modules (deleted);');
-        modify_database('','CREATE INDEX prefix_modules_name_idx ON prefix_modules (name);');
-    }
-    
-    if ($oldversion < 2004111700) { // add an index on user students timeaccess (used for sorting)- drop them first silently to avoid conflicts when upgrading
-        execute_sql("DROP INDEX {$CFG->prefix}user_students_timeaccess_idx;",false);
-
-        modify_database('','CREATE INDEX prefix_user_students_timeaccess_idx ON prefix_user_students (timeaccess);');
-    }
-    
-    if ($oldversion < 2004111700) { //add indexes on faux foreign keys  - drop them first silently to avoid conflicts when upgrading.
-        execute_sql("DROP INDEX {$CFG->prefix}course_sections_coursesection_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}scale_courseid_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}user_admins_userid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}user_coursecreators_userid_idx;",false); 
-
-        modify_database('','CREATE INDEX prefix_course_sections_coursesection_idx ON prefix_course_sections (course,section);');
-        modify_database('','CREATE INDEX prefix_scale_courseid_idx ON prefix_scale (courseid);');
-        modify_database('','CREATE INDEX prefix_user_admins_userid_idx ON prefix_user_admins (userid);');
-        modify_database('','CREATE INDEX prefix_user_coursecreators_userid_idx ON prefix_user_coursecreators (userid);');
-    }
-   
-    if ($oldversion < 2004111700) { // make new indexes on user table.
-        fix_course_sortorder(0,0,1);
-
-        execute_sql("DROP INDEX {$CFG->prefix}course_category_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}course_category_sortorder_uk;",false);
-        modify_database('', "CREATE UNIQUE INDEX prefix_course_category_sortorder_uk ON prefix_course(category,sortorder)"); 
-
-        execute_sql("DROP INDEX {$CFG->prefix}user_deleted_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}user_confirmed_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}user_firstname_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}user_lastname_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}user_city_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}user_country_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}user_lastaccess_idx;",false);
-
-        modify_database("","CREATE INDEX prefix_user_deleted_idx ON prefix_user (deleted)");
-        modify_database("","CREATE INDEX prefix_user_confirmed_idx ON prefix_user (confirmed)");
-        modify_database("","CREATE INDEX prefix_user_firstname_idx ON prefix_user (firstname)");
-        modify_database("","CREATE INDEX prefix_user_lastname_idx ON prefix_user (lastname)");
-        modify_database("","CREATE INDEX prefix_user_city_idx ON prefix_user (city)");
-        modify_database("","CREATE INDEX prefix_user_country_idx ON prefix_user (country)");
-        modify_database("","CREATE INDEX prefix_user_lastaccess_idx ON prefix_user (lastaccess)");
-    }
-
-    if ($oldversion < 2004111700) { // one more index for email (for sorting)
-        execute_sql("DROP INDEX {$CFG->prefix}user_email_idx;",false);
-
-        modify_database('','CREATE INDEX prefix_user_email_idx ON prefix_user (email);');
-     }
-
-    if ($oldversion < 2004112200) { // new 'enrol' field for enrolment tables
-        table_column('user_students', '', 'enrol', 'varchar', '20', '', '', 'not null');
-        table_column('user_teachers', '', 'enrol', 'varchar', '20', '', '', 'not null');
-        modify_database("","CREATE INDEX {$CFG->prefix}user_students_enrol_idx ON {$CFG->prefix}user_students (enrol);");
-        modify_database("","CREATE INDEX {$CFG->prefix}user_teachers_enrol_idx ON {$CFG->prefix}user_teachers (enrol);");
-    } 
-
-    if ($oldversion < 2004112300) { // update log display to use correct postgres friendly sql
-        execute_sql("UPDATE {$CFG->prefix}log_display SET field='firstname||\' \'||lastname' WHERE module='user' AND action='view' AND mtable='user'");
-        execute_sql("UPDATE {$CFG->prefix}log_display SET field='firstname||\' \'||lastname' WHERE module='course' AND action='user report' AND mtable='user'");
-    }
-
-    if ($oldversion < 2004112400) {
-
-        /// Delete duplicate enrolments 
-        /// and then tell the database course,userid is a unique combination
-        if ($users = get_records_select("user_students", "userid > 0 GROUP BY course, userid ".
-                                        "HAVING count(*) > 1", "", "max(id) as id, userid, course ,count(*)")) {
-            foreach ($users as $user) {
-                delete_records_select("user_students", "userid = '$user->userid' ".
-                                     "AND course = '$user->course' AND id <> '$user->id'");
-            }
-        }
-        flush();
-
-        // drop some indexes quietly -- they may or may not exist depending on what version 
-        // the user upgrades from 
-        execute_sql("DROP INDEX {$CFG->prefix}user_students_courseuserid_idx ", false);
-        execute_sql("DROP INDEX {$CFG->prefix}user_students_courseuserid_uk  ", false);        
-        modify_database('','CREATE UNIQUE INDEX prefix_user_students_courseuserid_uk ON prefix_user_students (course,userid);');        
-
-        /// Delete duplicate teacher enrolments 
-        /// and then tell the database course,userid is a unique combination
-        if ($users = get_records_select("user_teachers", "userid > 0 GROUP BY course, userid ".
-                                        "HAVING count(*) > 1", "", "max(id) as id, userid, course ,count(*)")) {
-            foreach ($users as $user) {
-                delete_records_select("user_teachers", "userid = '$user->userid' ".
-                                     "AND course = '$user->course' AND id <> '$user->id'");
-            }
-        }
-        flush();
-
-        // drop some indexes quietly -- they may or may not exist depending on what version 
-        // the user upgrades from 
-        execute_sql("DROP INDEX {$CFG->prefix}user_teachers_courseuserid_idx ", false);
-        execute_sql("DROP INDEX {$CFG->prefix}user_teachers_courseuserid_uk  ", false);
-        modify_database('','CREATE UNIQUE INDEX prefix_user_teachers_courseuserid_uk ON prefix_user_teachers (course,userid);');        
-    } 
-    
-    if ($oldversion < 2004112401) {
-        // some postgres databases may have a non-unique index mislabeled unique.
-        fix_course_sortorder(0,0,1);
-        execute_sql("DROP INDEX {$CFG->prefix}course_category_sortorder_uk  ", false);
-        execute_sql("DROP INDEX {$CFG->prefix}course_category_idx  ", false);
-        modify_database('', "CREATE UNIQUE INDEX prefix_course_category_sortorder_uk ON prefix_course(category,sortorder);");
-        
-        // odd! username was missing its unique index!
-        // first silently drop it just in case...
-        execute_sql("ALTER TABLE {$CFG->prefix}user DROP CONSTRAINT {$CFG->prefix}user_username_uk;", false);   
-        execute_sql("DROP INDEX {$CFG->prefix}user_username_uk", false);
-        modify_database('', "CREATE UNIQUE INDEX prefix_user_username_uk ON prefix_user (username);");
-        
-    } 
-
-    if ($oldversion < 2004112900) {
-        table_column('user', '', 'policyagreed', 'integer', '1', 'unsigned', '0', 'not null', 'confirmed');
-    }
-
-    if ($oldversion < 2004121400) {
-        table_column('groups', '', 'password', 'varchar', '50', '', '', 'not null', 'description');
-    }
-
-    if ($oldversion < 2004121600) {
-        modify_database('',"CREATE TABLE prefix_dst_preset (
-                                id SERIAL PRIMARY KEY,
-                                name varchar(48) NOT NULL default '',
-                                apply_offset integer NOT NULL default '0',
-                                activate_index integer NOT NULL default '1',
-                                activate_day integer NOT NULL default '1',
-                                activate_month integer NOT NULL default '1',
-                                activate_time char(5) NOT NULL default '03:00',
-                                deactivate_index integer NOT NULL default '1',
-                                deactivate_day integer NOT NULL default '1',
-                                deactivate_month integer NOT NULL default '2',
-                                deactivate_time char(5) NOT NULL default '03:00',
-                                last_change integer NOT NULL default '0',
-                                next_change integer NOT NULL default '0',
-                                current_offset integer NOT NULL default '0'
-                             );");
-    }
-
-    if ($oldversion < 2004122800) {
-        execute_sql("DROP TABLE {$CFG->prefix}message", false);
-        execute_sql("DROP TABLE {$CFG->prefix}message_read", false);
-        execute_sql("DROP TABLE {$CFG->prefix}message_contacts", false);
-
-        execute_sql("DROP INDEX {$CFG->prefix}message_useridfrom_idx", false);
-        execute_sql("DROP INDEX {$CFG->prefix}message_useridto_idx", false);
-        execute_sql("DROP INDEX {$CFG->prefix}message_read_useridfrom_idx", false);
-        execute_sql("DROP INDEX {$CFG->prefix}message_read_useridto_idx", false);
-        execute_sql("DROP INDEX {$CFG->prefix}message_contacts_useridcontactid_idx", false);
-
-        modify_database('',"CREATE TABLE prefix_message (
-                               id SERIAL PRIMARY KEY,
-                               useridfrom integer NOT NULL default '0',
-                               useridto integer NOT NULL default '0',
-                               message text,
-                               timecreated integer NOT NULL default '0',
-                               messagetype varchar(50) NOT NULL default ''
-                            );
-
-                            CREATE INDEX prefix_message_useridfrom_idx ON prefix_message (useridfrom);
-                            CREATE INDEX prefix_message_useridto_idx ON prefix_message (useridto);
-
-                            CREATE TABLE prefix_message_read (
-                               id SERIAL PRIMARY KEY,
-                               useridfrom integer NOT NULL default '0',
-                               useridto integer NOT NULL default '0',
-                               message text,
-                               timecreated integer NOT NULL default '0',
-                               timeread integer NOT NULL default '0',
-                               messagetype varchar(50) NOT NULL default '',
-                               mailed integer NOT NULL default '0'
-                            );
-
-                            CREATE INDEX prefix_message_read_useridfrom_idx ON prefix_message_read (useridfrom);
-                            CREATE INDEX prefix_message_read_useridto_idx ON prefix_message_read (useridto);
-                            ");
-      
-        modify_database('',"CREATE TABLE prefix_message_contacts (
-                               id SERIAL PRIMARY KEY,
-                               userid integer NOT NULL default '0',
-                               contactid integer NOT NULL default '0',
-                               blocked integer NOT NULL default '0'
-                            );
-
-                            CREATE INDEX prefix_message_contacts_useridcontactid_idx ON prefix_message_contacts (userid,contactid);
-                            ");
-
-        modify_database('',"INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'write', 'user', 'firstname||\' \'||lastname');
-                            INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'read', 'user', 'firstname||\' \'||lastname');
-                            ");
-    }
-
-    if ($oldversion < 2004122801) {
-        table_column('message', '', 'format', 'integer', '4', 'unsigned', '0', 'not null', 'message');
-        table_column('message_read', '', 'format', 'integer', '4', 'unsigned', '0', 'not null', 'message');
-    }
-       
-                                
-    if ($oldversion < 2005010100) {
-        modify_database('',"INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'add contact', 'user', 'firstname||\' \'||lastname');
-                            INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'remove contact', 'user', 'firstname||\' \'||lastname');
-                            INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'block contact', 'user', 'firstname||\' \'||lastname');
-                            INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'unblock contact', 'user', 'firstname||\' \'||lastname');
-                            ");
-    }
-
-    if ($oldversion < 2005011000) {     // Create a .htaccess file in dataroot, just in case
-        if (!file_exists($CFG->dataroot.'/.htaccess')) {
-            if ($handle = fopen($CFG->dataroot.'/.htaccess', 'w')) {   // For safety
-                @fwrite($handle, "deny from all\r\nAllowOverride None\r\n");
-                @fclose($handle); 
-                notify("Created a default .htaccess file in $CFG->dataroot");
-            }
-        }
-    }
-
-    if ($oldversion < 2005012500) { // add new table for meta courses.
-        /*
-        modify_database("","CREATE TABLE prefix_meta_course (
-             id SERIAL primary key,
-             parent_course integer NOT NULL,
-             child_course integer NOT NULL
-             );");
-
-        modify_database("","CREATE INDEX prefix_meta_course_parent_idx ON prefix_meta_course (parent_course);");
-        modify_database("","CREATE INDEX prefix_meta_course_child_idx ON prefix_meta_course (child_course);");
-        table_column('course','','meta_course','integer','1','','0','not null');
-        */ // taking this OUT for upgrade from 1.4 to 1.5 (those tracking head will have already seen it)
-    }
-
-    if ($oldversion < 2005012501) { //fix table names for consistency
-        execute_sql("DROP TABLE {$CFG->prefix}meta_course",false); // drop silently
-        execute_sql("ALTER TABLE {$CFG->prefix}course DROP COLUMN meta_course",false); // drop silently
-        
-        modify_database("","CREATE TABLE prefix_course_meta (
-             id SERIAL primary key,
-             parent_course integer NOT NULL,
-             child_course integer NOT NULL
-             );");
-
-        modify_database("","CREATE INDEX prefix_course_meta_parent_idx ON prefix_course_meta (parent_course);");
-        modify_database("","CREATE INDEX prefix_course_meta_child_idx ON prefix_course_meta (child_course);");
-        table_column('course','','metacourse','integer','1','','0','not null');
-    }
-
-    if ($oldversion < 2005020100) {
-        fix_course_sortorder(0, 1, 1);
-    } 
-
-    if ($oldversion < 2005021000) {     // New fields for theme choices
-        table_column('course', '', 'theme', 'varchar', '50', '', '', '', 'lang');
-        table_column('groups', '', 'theme', 'varchar', '50', '', '', '', 'lang');
-        table_column('user',   '', 'theme', 'varchar', '50', '', '', '', 'lang');
-
-        set_config('theme', 'standardwhite');         // Reset to a known good theme 
-    }
-
-    if ($oldversion < 2005021700) {
-        table_column('user', '', 'dstpreset', 'int', '10', '', '0', 'not null', 'timezone');
-    }
-
-    if ($oldversion < 2005021800) {
-        modify_database("","CREATE TABLE adodb_logsql (
-                              created timestamp NOT NULL,
-                              sql0 varchar(250) NOT NULL,
-                              sql1 text NOT NULL,
-                              params text NOT NULL,
-                              tracer text NOT NULL,
-                              timer decimal(16,6) NOT NULL
-                           );");
-    }
-
-    if ($oldversion < 2005022400) {
-        table_column('dst_preset', '', 'family', 'varchar', '100', '', '', 'not null', 'name');
-        table_column('dst_preset', '', 'year', 'int', '10', '', '0', 'not null', 'family');
-    }
-
-    if ($oldversion < 2005030501) {
-        table_column('user', '', 'msn', 'varchar', '50', '', '', '', 'icq');
-        table_column('user', '', 'aim', 'varchar', '50', '', '', '', 'icq');
-        table_column('user', '', 'yahoo', 'varchar', '50', '', '', '', 'icq');
-        table_column('user', '', 'skype', 'varchar', '50', '', '', '', 'icq');
-    }
-
-    if ($oldversion < 2005032300) {
-        table_column('user', 'dstpreset', 'timezonename', 'varchar', '100');
-        execute_sql('UPDATE '.$CFG->prefix.'user SET timezonename = \'\'');
-    }
-
-
-    if ($oldversion < 2005032600) {
-        execute_sql('DROP TABLE '.$CFG->prefix.'dst_preset', false);
-        modify_database('',"CREATE TABLE prefix_timezone (
-                              id SERIAL PRIMARY KEY,
-                              name varchar(100) NOT NULL default '',
-                              year integer NOT NULL default '0',
-                              rule varchar(20) NOT NULL default '',
-                              gmtoff integer NOT NULL default '0',
-                              dstoff integer NOT NULL default '0',
-                              dst_month integer NOT NULL default '0',
-                              dst_startday integer NOT NULL default '0',
-                              dst_weekday integer NOT NULL default '0',
-                              dst_skipweeks integer NOT NULL default '0',
-                              dst_time varchar(5) NOT NULL default '00:00',
-                              std_month integer NOT NULL default '0',
-                              std_startday integer NOT NULL default '0',
-                              std_weekday integer NOT NULL default '0',
-                              std_skipweeks integer NOT NULL default '0',
-                              std_time varchar(5) NOT NULL default '00:00'
-                            );");
-    }
-
-    if ($oldversion < 2005032800) {
-        modify_database('',"CREATE TABLE prefix_grade_category (
-                              id SERIAL PRIMARY KEY,
-                              name varchar(64) default NULL,
-                              courseid integer NOT NULL default '0',
-                              drop_x_lowest integer NOT NULL default '0',
-                              bonus_points integer NOT NULL default '0',
-                              hidden integer NOT NULL default '0',
-                              weight decimal(4,2) default '0.00'
-                            );");
-        
-        modify_database('',"CREATE INDEX prefix_grade_category_courseid_idx ON prefix_grade_category (courseid);");
-        
-        modify_database('',"CREATE TABLE prefix_grade_exceptions (
-                              id SERIAL PRIMARY KEY,
-                              courseid integer  NOT NULL default '0',
-                              grade_itemid integer  NOT NULL default '0',
-                              userid integer  NOT NULL default '0'
-                            );");
-        
-        modify_database('',"CREATE INDEX prefix_grade_exceptions_courseid_idx ON prefix_grade_exceptions (courseid);");
-        
-        
-        modify_database('',"CREATE TABLE prefix_grade_item (
-                              id SERIAL PRIMARY KEY,
-                              courseid integer default NULL,
-                              category integer default NULL,
-                              modid integer default NULL,
-                              cminstance integer default NULL,
-                              scale_grade float(11) default '1.0000000000',
-                              extra_credit integer NOT NULL default '0',
-                              sort_order integer  NOT NULL default '0'
-                            );");
-        
-        modify_database('',"CREATE INDEX prefix_grade_item_courseid_idx ON prefix_grade_item (courseid);");
-        
-        modify_database('',"CREATE TABLE prefix_grade_letter (
-                              id SERIAL PRIMARY KEY,
-                              courseid integer NOT NULL default '0',
-                              letter varchar(8) NOT NULL default 'NA',
-                              grade_high decimal(6,2) NOT NULL default '100.00',
-                              grade_low decimal(6,2) NOT NULL default '0.00'
-                            );");
-
-        modify_database('',"CREATE INDEX prefix_grade_letter_courseid_idx ON prefix_grade_letter (courseid);");
-        
-        modify_database('',"CREATE TABLE prefix_grade_preferences (
-                              id SERIAL PRIMARY KEY,
-                              courseid integer default NULL,
-                              preference integer NOT NULL default '0',
-                              value integer NOT NULL default '0'
-                            );");
-        
-        modify_database('',"CREATE UNIQUE INDEX prefix_grade_prefs_courseidpref_uk ON prefix_grade_preferences (courseid,preference);");
-    }
-
-    if ($oldversion < 2005033100) {   // Get rid of defunct field from course modules table
-         delete_records('course_modules', 'deleted', 1);  // Delete old records we don't need any more
-         execute_sql('DROP INDEX '.$CFG->prefix.'course_modules_deleted_idx;');  // Old index
-         execute_sql('ALTER TABLE '.$CFG->prefix.'course_modules DROP deleted;');    // Old field
-    }
-
-    if ($oldversion < 2005040800) {
-        table_column('user', 'timezone', 'timezone', 'varchar', '100', '', '99');
-        execute_sql(" ALTER TABLE {$CFG->prefix}user DROP timezonename ");
-    }
-
-    if ($oldversion < 2005041101) {
-        require_once($CFG->libdir.'/filelib.php');
-        if (is_readable($CFG->dirroot.'/lib/timezones.txt')) {  // Distribution file
-            if ($timezones = get_records_csv($CFG->dirroot.'/lib/timezones.txt', 'timezone')) {
-                $db->debug = false;
-                update_timezone_records($timezones);
-                notify(count($timezones).' timezones installed');
-                $db->debug = true;
-            }
-        }
-    }
-
-    if ($oldversion < 2005041900) {  // Copy all Dialogue entries into Messages, and hide Dialogue module
-
-        if ($entries = get_records_sql('SELECT e.id, e.userid, c.recipientid, e.text, e.timecreated
-                                          FROM '.$CFG->prefix.'dialogue_conversations c,
-                                               '.$CFG->prefix.'dialogue_entries e
-                                         WHERE e.conversationid = c.id')) {
-            foreach ($entries as $entry) {
-                $message = NULL;
-                $message->useridfrom    = $entry->userid;
-                $message->useridto      = $entry->recipientid;
-                $message->message       = addslashes($entry->text);
-                $message->format        = FORMAT_HTML;
-                $message->timecreated   = $entry->timecreated;
-                $message->messagetype   = 'direct';
-            
-                insert_record('message_read', $message);
-            }
-        }
-
-        set_field('modules', 'visible', 0, 'name', 'dialogue');
-
-        notify('The Dialogue module has been disabled, and all the old Messages from it copied into the new standard Message feature.  If you really want Dialogue back, you can enable it using the "eye" icon here:  Admin >> Modules >> Dialogue');
-
-    }
-
-    if ($oldversion < 2005042100) {
-        $result = table_column('event', '', 'repeatid', 'int', '10', 'unsigned', '0', 'not null', 'userid') && $result;
-    }
-
-    if ($oldversion < 2005042400) {  // Add user tracking prefs field.
-        table_column('user', '', 'trackforums', 'int', '4', 'unsigned', '0', 'not null', 'autosubscribe');
-    }
-
-    if ($oldversion < 2005051500) {  // Add user tracking prefs field.
-        table_column('grade_category', 'weight', 'weight', 'numeric(5,2)', '', '', '0.00', '', '');
-    }
-
-    if ($oldversion < 2005053000 ) { // Add config_plugins table
-        
-        // this table was created on the MOODLE_15_STABLE branch
-        // so it may already exist. Therefore we hide potential errors
-        // (Postgres doesn't support CREATE TABLE IF NOT EXISTS)
-        execute_sql("CREATE TABLE {$CFG->prefix}config_plugins (
-                        id     SERIAL PRIMARY KEY,
-                        plugin varchar(100) NOT NULL default 'core',
-                        name   varchar(100) NOT NULL default '',
-                        value  text NOT NULL default '',
-                        CONSTRAINT {$CFG->prefix}config_plugins_plugin_name_uk UNIQUE (plugin, name)
-                     );", false);
-
-    }
-
-    if ($oldversion < 2005060200) {  // migrate some config items to config_plugins table
-
-        // NOTE: this block is in both postgres AND mysql upgrade
-        // files. If you edit either, update the otherone. 
-        $user_fields = array("firstname", "lastname", "email", 
-                             "phone1", "phone2", "department", 
-                             "address", "city", "country", 
-                             "description", "idnumber", "lang");
-        if (!empty($CFG->auth)) { // if we have no auth, just pass
-            foreach ($user_fields as $field) {
-                $suffixes = array('', '_editlock', '_updateremote', '_updatelocal');
-                foreach ($suffixes as $suffix) {
-                    $key = 'auth_user_' . $field . $suffix;
-                    if (isset($CFG->$key)) {
-                        
-                        // translate keys & values
-                        // to the new convention
-                        // this should support upgrading 
-                        // even 1.5dev installs
-                        $newkey = $key;
-                        $newval = $CFG->$key;
-                        if ($suffix === '') {
-                            $newkey = 'field_map_' . $field;
-                        } elseif ($suffix === '_editlock') {
-                            $newkey = 'field_lock_' . $field;
-                            $newval = ($newval==1) ? 'locked' : 'unlocked'; // translate 0/1 to locked/unlocked
-                        } elseif ($suffix === '_updateremote') {
-                            $newkey = 'field_updateremote_' . $field;                            
-                        } elseif ($suffix === '_updatelocal') {
-                            $newkey = 'field_updatelocal_' . $field;
-                            $newval = ($newval==1) ? 'onlogin' : 'oncreate'; // translate 0/1 to locked/unlocked
-                        }
-
-                        if (!(set_config($newkey, addslashes($newval), 'auth/'.$CFG->auth)
-                            && delete_records('config', 'name', $key))) {
-                            notify("Error updating Auth configuration $key to {$CFG->auth} $newkey .");
-                            $result = false;
-                        }
-                    } // end if isset key
-                } // end foreach suffix
-            } // end foreach field
-        }
-    }
-
-    if ($oldversion < 2005060201) {  // Close down the Attendance module, we are removing it from CVS.
-        if (!file_exists($CFG->dirroot.'/mod/attendance/lib.php')) {
-            if (count_records('attendance')) {   // We have some data, so should keep it
-
-                set_field('modules', 'visible', 0, 'name', 'attendance');
-                notify('The Attendance module has been discontinued.  If you really want to 
-                        continue using it, you should download it individually from 
-                        http://download.moodle.org/modules and install it, then 
-                        reactivate it from Admin >> Configuration >> Modules.  
-                        None of your existing data has been deleted, so all existing 
-                        Attendance activities should re-appear.');
-
-            } else {  // No data, so do a complete delete
-
-                execute_sql('DROP TABLE '.$CFG->prefix.'attendance', false);
-                delete_records('modules', 'name', 'attendance');
-                notify("The Attendance module has been discontinued and removed from your site.  
-                        You weren't using it anyway.  ;-)");
-            }
-        }
-    }
-
-    if ($oldversion < 2005060223) { // Mass cleanup of bad postgres upgrade scripts
-        execute_sql("DROP TABLE {$CFG->prefix}attendance_roll", false); // There are no attendance module anymore
-        modify_database('','ALTER TABLE prefix_config ALTER value SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_course ALTER metacourse SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_course ALTER theme SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_event ALTER repeatid SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_groups ALTER password SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_groups ALTER theme SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_message ALTER format SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_message_read ALTER format SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_groups ALTER theme SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_user ALTER aim DROP DEFAULT');
-        modify_database('','ALTER TABLE prefix_user ALTER idnumber DROP DEFAULT');
-        modify_database('','ALTER TABLE prefix_user ALTER msn DROP DEFAULT');
-        modify_database('','ALTER TABLE prefix_user ALTER policyagreed SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_user ALTER skype DROP DEFAULT');
-        modify_database('','ALTER TABLE prefix_user ALTER theme SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_user ALTER timezone SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_user ALTER trackforums SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_user ALTER yahoo DROP DEFAULT');
-        modify_database('','ALTER TABLE prefix_user_students ALTER enrol SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_user_teachers ALTER enrol SET NOT NULL');
-    }
-
-    if ($oldversion < 2005071700) {  // Close down the Dialogue module, we are removing it from CVS.
-        if (!file_exists($CFG->dirroot.'/mod/dialogue/lib.php')) {
-            if (count_records('dialogue')) {   // We have some data, so should keep it
-
-                set_field('modules', 'visible', 0, 'name', 'dialogue');
-                notify('The Dialogue module has been discontinued.  If you really want to 
-                        continue using it, you should download it individually from 
-                        http://download.moodle.org/modules and install it, then 
-                        reactivate it from Admin >> Configuration >> Modules.  
-                        None of your existing data has been deleted, so all existing 
-                        Dialogue activities should re-appear.');
-
-            } else {  // No data, so do a complete delete
-
-                execute_sql('DROP TABLE '.$CFG->prefix.'dialogue', false);
-                delete_records('modules', 'name', 'dialogue');
-                notify("The Dialogue module has been discontinued and removed from your site.  
-                        You weren't using it anyway.  ;-)");
-            }
-        }
-    }
-
-    if ($oldversion < 2005072000) {  // Add a couple fields to mdl_event to work towards iCal import/export
-        table_column('event', '', 'uuid', 'char', '36', '', '', 'not null', 'visible');
-        table_column('event', '', 'sequence', 'integer', '10', 'unsigned', '1', 'not null', 'uuid');
-    }
-    
-    if ($oldversion < 2005072100) { // run the online assignment cleanup code
-        include($CFG->dirroot.'/'.$CFG->admin.'/oacleanup.php');
-        if (function_exists('online_assignment_cleanup')) {
-            online_assignment_cleanup();
-        }
-    }
-
-    if ($oldversion < 2005072200) { // fix the mistakenly-added currency stuff from enrol/authorize
-        execute_sql("DROP TABLE {$CFG->prefix}currencies", false); // drop silently
-        execute_sql("ALTER TABLE {$CFG->prefix}course DROP currency", false);
-        $defaultcurrency = empty($CFG->enrol_currency) ? 'USD' : $CFG->enrol_currency;
-        table_column('course', '', 'currency', 'char', '3', '', $defaultcurrency, 'not null', 'cost');
-    }
-
-    if ($oldversion < 2005081600) { //set up the course requests table
-        modify_database('',"CREATE TABLE prefix_course_request (
-           id SERIAL PRIMARY KEY,
-           fullname varchar(254) NOT NULL default '',
-           shortname varchar(15) NOT NULL default '',
-           summary text NOT NULL default '',
-           reason text NOT NULL default '',
-           requester INTEGER NOT NULL default 0
-         );");
-        
-        modify_database('','CREATE INDEX prefix_course_request_shortname_idx ON prefix_course_request (shortname);');
-
-        table_column('course','','requested');
-    }
-
-    if ($oldversion < 2005081601) {
-        modify_database('','CREATE TABLE prefix_course_allowed_modules (
-            id SERIAL PRIMARY KEY,
-            course INTEGER NOT NULL default 0,
-            module INTEGER NOT NULL default 0
-         );');
-         
-        modify_database('','CREATE INDEX prefix_course_allowed_modules_course_idx ON prefix_course_allowed_modules (course);');
-        modify_database('','CREATE INDEX prefix_course_allowed_modules_module_idx ON prefix_course_allowed_modules (module);');
-        table_column('course','','restrictmodules','int','1','','0','not null');
-    }
-    
-    if ($oldversion < 2005081700) {
-        table_column('course_categories','','depth','integer');
-        table_column('course_categories','','path','varchar','255');
-    }
-
-    if  ($oldversion < 2005090100) { // stats!
-        modify_database('','CREATE TABLE prefix_stats_daily (
-           id SERIAL PRIMARY KEY,
-           courseid INTEGER NOT NULL default 0,
-           timeend INTEGER NOT NULL default 0,
-           students INTEGER NOT NULL default 0,
-           teachers INTEGER NOT NULL default 0,
-           activestudents INTEGER NOT NULL default 0,
-           activeteachers INTEGER NOT NULL default 0,
-           studentreads INTEGER NOT NULL default 0,
-           studentwrites INTEGER NOT NULL default 0,
-           teacherreads INTEGER NOT NULL default 0,
-           teacherwrites INTEGER NOT NULL default 0,
-           logins INTEGER NOT NULL default 0,
-           uniquelogins INTEGER NOT NULL default 0
-        );');
-
-        modify_database('','CREATE INDEX prefix_stats_daily_courseid_idx ON prefix_stats_daily (courseid);');
-        modify_database('','CREATE INDEX prefix_stats_daily_timeend_idx ON prefix_stats_daily (timeend);');
-        
-        modify_database('','CREATE TABLE prefix_stats_weekly (
-           id SERIAL PRIMARY KEY,
-           courseid INTEGER NOT NULL default 0,
-           timeend INTEGER NOT NULL default 0,
-           students INTEGER NOT NULL default 0,
-           teachers INTEGER NOT NULL default 0,
-           activestudents INTEGER NOT NULL default 0,
-           activeteachers INTEGER NOT NULL default 0,
-           studentreads INTEGER NOT NULL default 0,
-           studentwrites INTEGER NOT NULL default 0,
-           teacherreads INTEGER NOT NULL default 0,
-           teacherwrites INTEGER NOT NULL default 0,
-           logins INTEGER NOT NULL default 0,
-           uniquelogins INTEGER NOT NULL default 0
-        );');
-
-        modify_database('','CREATE INDEX prefix_stats_weekly_courseid_idx ON prefix_stats_weekly (courseid);');
-        modify_database('','CREATE INDEX prefix_stats_weekly_timeend_idx ON prefix_stats_weekly (timeend);');
-
-        modify_database('','CREATE TABLE prefix_stats_monthly (
-           id SERIAL PRIMARY KEY,
-           courseid INTEGER NOT NULL default 0,
-           timeend INTEGER NOT NULL default 0,
-           students INTEGER NOT NULL default 0,
-           teachers INTEGER NOT NULL default 0,
-           activestudents INTEGER NOT NULL default 0,
-           activeteachers INTEGER NOT NULL default 0,
-           studentreads INTEGER NOT NULL default 0,
-           studentwrites INTEGER NOT NULL default 0,
-           teacherreads INTEGER NOT NULL default 0,
-           teacherwrites INTEGER NOT NULL default 0,
-           logins INTEGER NOT NULL default 0,
-           uniquelogins INTEGER NOT NULL default 0
-        );');
-
-        modify_database('','CREATE INDEX prefix_stats_monthly_courseid_idx ON prefix_stats_monthly (courseid);');
-        modify_database('','CREATE INDEX prefix_stats_monthly_timeend_idx ON prefix_stats_monthly (timeend);');
-        
-        modify_database("","CREATE TABLE prefix_stats_user_daily (
-           id SERIAL PRIMARY KEY,
-           courseid INTEGER NOT NULL default 0,
-           userid INTEGER NOT NULL default 0,
-           roleid INTEGER NOT NULL default 0,
-           timeend INTEGER NOT NULL default 0,
-           statsreads INTEGER NOT NULL default 0,
-           statswrites INTEGER NOT NULL default 0,
-           stattype varchar(30) NOT NULL default ''
-         );");
-         
-         modify_database("","CREATE INDEX prefix_stats_user_daily_courseid_idx ON prefix_stats_user_daily (courseid);");
-         modify_database("","CREATE INDEX prefix_stats_user_daily_userid_idx ON prefix_stats_user_daily (userid);");
-         modify_database("","CREATE INDEX prefix_stats_user_daily_roleid_idx ON prefix_stats_user_daily (roleid);");
-         modify_database("","CREATE INDEX prefix_stats_user_daily_timeend_idx ON prefix_stats_user_daily (timeend);");
-
-         modify_database("","CREATE TABLE prefix_stats_user_weekly (
-           id SERIAL PRIMARY KEY,
-           courseid INTEGER NOT NULL default 0,
-           userid INTEGER NOT NULL default 0,
-           roleid INTEGER NOT NULL default 0,
-           timeend INTEGER NOT NULL default 0,
-           statsreads INTEGER NOT NULL default 0,
-           statswrites INTEGER NOT NULL default 0,
-           stattype varchar(30) NOT NULL default ''
-         );");
-         
-         modify_database("","CREATE INDEX prefix_stats_user_weekly_courseid_idx ON prefix_stats_user_weekly (courseid);");
-         modify_database("","CREATE INDEX prefix_stats_user_weekly_userid_idx ON prefix_stats_user_weekly (userid);");
-         modify_database("","CREATE INDEX prefix_stats_user_weekly_roleid_idx ON prefix_stats_user_weekly (roleid);");
-         modify_database("","CREATE INDEX prefix_stats_user_weekly_timeend_idx ON prefix_stats_user_weekly (timeend);");
-
-         modify_database("","CREATE TABLE prefix_stats_user_monthly (
-           id SERIAL PRIMARY KEY,
-           courseid INTEGER NOT NULL default 0,
-           userid INTEGER NOT NULL default 0,
-           roleid INTEGER NOT NULL default 0,
-           timeend INTEGER NOT NULL default 0,
-           statsreads INTEGER NOT NULL default 0,
-           statswrites INTEGER NOT NULL default 0,
-           stattype varchar(30) NOT NULL default ''
-         );");
-         
-         modify_database("","CREATE INDEX prefix_stats_user_monthly_courseid_idx ON prefix_stats_user_monthly (courseid);");
-         modify_database("","CREATE INDEX prefix_stats_user_monthly_userid_idx ON prefix_stats_user_monthly (userid);");
-         modify_database("","CREATE INDEX prefix_stats_user_monthly_roleid_idx ON prefix_stats_user_monthly (roleid);");
-         modify_database("","CREATE INDEX prefix_stats_user_monthly_timeend_idx ON prefix_stats_user_monthly (timeend);");
-    }
-    
-    if ($oldversion < 2005100300) {
-        table_column('course','','expirynotify','integer','1');
-        table_column('course','','expirythreshold','integer');
-        table_column('course','','notifystudents','integer','1');
-        $new = new stdClass();
-        $new->name = 'lastexpirynotify';
-        $new->value = 0;
-        insert_record('config', $new);
-    }
-
-    if ($oldversion < 2005100400) {
-        table_column('course','','enrollable','integer','1','unsigned','1');
-        table_column('course','','enrolstartdate','integer');
-        table_column('course','','enrolenddate','integer');
-    }
-
-
-    if ($oldversion < 2005101200) { // add enrolment key to course_request.
-        table_column('course_request','','password','text');
-    }
-
-    if ($oldversion < 2006030800) { # add extra indexes to log (see bug #4112)
-        modify_database('',"CREATE INDEX prefix_log_userid_idx ON prefix_log (userid);");
-        modify_database('',"CREATE INDEX prefix_log_info_idx ON prefix_log (info);");
-    }
-
-    if ($oldversion < 2006030900) {
-        table_column('course','','enrol','varchar','20','','');
-
-        if ($CFG->enrol == 'internal' || $CFG->enrol == 'manual') {
-            set_config('enrol_plugins_enabled', 'manual');
-            set_config('enrol', 'manual');
-        } else {
-            set_config('enrol_plugins_enabled', 'manual,'.$CFG->enrol);
-        }
-
-        require_once("$CFG->dirroot/enrol/enrol.class.php");
-        $defaultenrol = enrolment_factory::factory($CFG->enrol);
-        if (!method_exists($defaultenrol, 'print_entry')) { // switch enrollable to off for all courses in this case
-            modify_database('', 'UPDATE prefix_course SET enrollable = 0');
-        }
-
-        execute_sql("UPDATE {$CFG->prefix}user_students SET enrol='manual' WHERE enrol='' OR enrol='internal'");
-        execute_sql("UPDATE {$CFG->prefix}user_teachers SET enrol='manual' WHERE enrol=''");
-
-    }
-    
-    if ($oldversion < 2006031000) {
-
-        modify_database("","CREATE TABLE prefix_post (
-          id SERIAL PRIMARY KEY,
-          userid INTEGER NOT NULL default 0,
-          courseid INTEGER NOT NULL default 0,
-          groupid INTEGER NOT NULL default 0,
-          moduleid INTEGER NOT NULL default 0,
-          coursemoduleid INTEGER NOT NULL default 0,
-          subject varchar(128) NOT NULL default '',
-          summary text,
-          content text,
-          uniquehash varchar(128) NOT NULL default '',
-          rating INTEGER NOT NULL default 0,
-          format INTEGER NOT NULL default 0,
-          publishstate varchar(10) CHECK (publishstate IN ('draft','site','public')) NOT NULL default 'draft',
-          lastmodified INTEGER NOT NULL default '0',
-          created INTEGER NOT NULL default '0'
-        );");
-
-         modify_database("","CREATE INDEX id_user_idx ON prefix_post  (id, courseid);");
-         modify_database("","CREATE INDEX post_lastmodified_idx ON prefix_post (lastmodified);");
-         modify_database("","CREATE INDEX post_subject_idx ON prefix_post (subject);");
-
-         modify_database("","CREATE TABLE prefix_tags (
-          id SERIAL PRIMARY KEY,
-          type varchar(255) NOT NULL default 'official',
-          userid INTEGER NOT NULL default 0,
-          text varchar(255) NOT NULL default ''
-        );");
-
-         modify_database("","CREATE TABLE prefix_blog_tag_instance (
-          id SERIAL PRIMARY KEY,
-          entryid integer NOT NULL default 0,
-          tagid integer NOT NULL default 0,
-          groupid integer NOT NULL default 0,
-          courseid integer NOT NULL default 0,
-          userid integer NOT NULL default 0
-        );");
-    }
-
-    if ($oldversion < 2006031400) {
-        require_once("$CFG->dirroot/enrol/enrol.class.php");
-        $defaultenrol = enrolment_factory::factory($CFG->enrol);
-        if (!method_exists($defaultenrol, 'print_entry')) {
-            set_config('enrol', 'manual');
-        }
-    }
-
-    if ($oldversion < 2006032000) {
-        table_column('post','','module','varchar','20','','','not null', 'id');
-        modify_database('',"CREATE INDEX post_module_idx ON prefix_post (module);");
-        modify_database('',"UPDATE prefix_post SET module = 'blog';");
-    }
-
-    if ($oldversion < 2006032001) {
-        table_column('blog_tag_instance','','timemodified','integer','10','unsigned','0','not null', 'userid'); 
-        modify_database('',"CREATE INDEX bti_entryid_idx ON prefix_blog_tag_instance (entryid);");
-        modify_database('',"CREATE INDEX bti_tagid_idx ON prefix_blog_tag_instance (tagid);");
-        modify_database('',"UPDATE prefix_blog_tag_instance SET timemodified = '".time()."';");
-    }
-
-    if ($oldversion < 2006040500) { // Add an index to course_sections that was never upgraded (bug 5100)
-        execute_sql(" CREATE INDEX {$CFG->prefix}course_sections_coursesection_idx ON {$CFG->prefix}course_sections (course,section) ", false);
-    }
-
-    if ($oldversion < 2006041100) {
-        table_column('course_modules','','visibleold','integer','1','unsigned','1','not null', 'visible');
-    }
-
-    if ($oldversion < 2006042400) {
-        // Look through table log_display and get rid of duplicates.
-        $rs = get_recordset_sql('SELECT DISTINCT * FROM '.$CFG->prefix.'log_display');
-        
-        // Drop the log_display table and create it back with an id field.
-        execute_sql("DROP TABLE {$CFG->prefix}log_display", false);
-        
-        modify_database('', "CREATE TABLE prefix_log_display (
-                               id SERIAL PRIMARY KEY,
-                               module varchar(30) NOT NULL default '',
-                               action varchar(40) NOT NULL default '',
-                               mtable varchar(30) NOT NULL default '',
-                               field varchar(50) NOT NULL default '')");
-        
-        // Add index to ensure that module and action combination is unique.
-        modify_database('', 'CREATE INDEX prefix_log_display_moduleaction ON prefix_log_display (module,action)');
-        
-        // Insert the records back in, sans duplicates.
-        if ($rs) {
-            while (!$rs->EOF) {
-                $sql = "INSERT INTO {$CFG->prefix}log_display ".
-                            "VALUES('', '".$rs->fields['module']."', ".
-                            "'".$rs->fields['action']."', ".
-                            "'".$rs->fields['mtable']."', ".
-                            "'".$rs->fields['field']."')";
-                
-                execute_sql($sql, false);
-                $rs->MoveNext();
-            }
-            rs_close($rs);
-        }
-    }
-    
-    // add 2 indexes to tags table
-    if ($oldversion < 2006042401) {
-        modify_database('',"CREATE INDEX tags_typeuserid_idx ON prefix_tags (type, userid);");
-        modify_database('',"CREATE INDEX tags_text_idx ON prefix_tags (text);");
-    }
-    
-    if ($oldversion < 2006050500) {
-        table_column('log', 'action', 'action', 'varchar', '40', '', '', 'not null');
-    }
-
-    if ($oldversion < 2006050502) {  // Close down the Dialogue module, we are removing it from CVS.
-        if (!file_exists($CFG->dirroot.'/mod/dialogue/lib.php')) {
-            if (!count_records('dialogue_conversations')) {   // no data, drop the extra tables
-                execute_sql('DROP TABLE '.$CFG->prefix.'dialogue_conversations', false);
-                execute_sql('DROP TABLE '.$CFG->prefix.'dialogue_entries', false);
-                notify("The Dialogue module has been discontinued and removed from your site.  
-                        You weren't using it anyway.  ;-)");
-            }
-        }
-
-        table_column('course_request', 'password', 'password', 'varchar', '50', '', '');
-
-        table_column('course', 'currency', 'currency', 'varchar', '3');
-
-        modify_database('', 'ALTER TABLE prefix_course_categories
-            ALTER COLUMN path SET DEFAULT \'\'');
-
-        table_column('log_display', 'module', 'module', 'varchar', '20');
-
-        modify_database("","DROP INDEX id_user_idx");
-        modify_database("","DROP INDEX post_lastmodified_idx");
-        modify_database("","DROP INDEX post_subject_idx");
-        modify_database('',"DROP INDEX bti_entryid_idx");
-        modify_database('',"DROP INDEX bti_tagid_idx");
-        modify_database('',"DROP INDEX post_module_idx");
-        modify_database('',"DROP INDEX tags_typeuserid_idx");
-        modify_database('',"DROP INDEX tags_text_idx");
-
-        modify_database("","CREATE INDEX {$CFG->prefix}id_user_idx           ON prefix_post (id, courseid);");
-        modify_database("","CREATE INDEX {$CFG->prefix}post_lastmodified_idx ON prefix_post (lastmodified);");
-        modify_database("","CREATE INDEX {$CFG->prefix}post_subject_idx      ON prefix_post (subject);");
-        modify_database('',"CREATE INDEX {$CFG->prefix}bti_entryid_idx       ON prefix_blog_tag_instance (entryid);");
-        modify_database('',"CREATE INDEX {$CFG->prefix}bti_tagid_idx         ON prefix_blog_tag_instance (tagid);");
-        modify_database('',"CREATE INDEX {$CFG->prefix}post_module_idx       ON prefix_post (moduleid);");
-        modify_database('',"CREATE INDEX {$CFG->prefix}tags_typeuserid_idx   ON prefix_tags (type, userid);");
-        modify_database('',"CREATE INDEX {$CFG->prefix}tags_text_idx         ON prefix_tags (text);");
-
-    }
-
-    // renaming of reads and writes for stats_user_xyz
-    if ($oldversion < 2006052400) { // change this later
-
-        // we are using this because we want silent updates
-
-        execute_sql("ALTER TABLE {$CFG->prefix}stats_user_daily RENAME COLUMN reads TO statsreads", false);
-        execute_sql("ALTER TABLE {$CFG->prefix}stats_user_daily RENAME COLUMN writes TO statswrites", false);
-        execute_sql("ALTER TABLE {$CFG->prefix}stats_user_weekly RENAME COLUMN reads TO statsreads", false);
-        execute_sql("ALTER TABLE {$CFG->prefix}stats_user_weekly RENAME COLUMN writes TO statswrites", false);
-        execute_sql("ALTER TABLE {$CFG->prefix}stats_user_monthly RENAME COLUMN reads TO statsreads", false);
-        execute_sql("ALTER TABLE {$CFG->prefix}stats_user_monthly RENAME COLUMN writes TO statswrites", false);
-
-    }
-
-    // Adding some missing log actions
-    if ($oldversion < 2006060400) {
-        // But only if they doesn't exist (because this was introduced after branch and we could be duplicating!)
-        if (!record_exists('log_display', 'module', 'course', 'action', 'report log')) {
-            execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('course', 'report log', 'course', 'fullname')");
-        }
-        if (!record_exists('log_display', 'module', 'course', 'action', 'report live')) {
-            execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('course', 'report live', 'course', 'fullname')");
-        }
-        if (!record_exists('log_display', 'module', 'course', 'action', 'report outline')) {
-            execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('course', 'report outline', 'course', 'fullname')");
-        }
-        if (!record_exists('log_display', 'module', 'course', 'action', 'report participation')) {
-            execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('course', 'report participation', 'course', 'fullname')");
-        }
-        if (!record_exists('log_display', 'module', 'course', 'action', 'report stats')) {
-            execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('course', 'report stats', 'course', 'fullname')");
-        }
-    }
-
-    //Renaming lastIP to lastip (all fields lowercase)
-    if ($oldversion < 2006060900) {
-        //Not needed unded PG because it stores fieldnames lowecase by default
-        //Only if it exists (because MOODLE_16_STABLE could have done this work before. Bug 5763)
-        //$fields = $db->MetaColumnNames($CFG->prefix.'user');
-        //if (in_array('lastIP',$fields)) {
-        //    table_column("user", "lastIP", "lastip", "varchar", "15", "", "", "", "currentlogin");
-        //}
-    }
-
-    
-    if ($oldversion < 2006080400) {
-         modify_database('', "CREATE TABLE prefix_role (
-                                  id SERIAL PRIMARY KEY,
-                                  name varchar(255) NOT NULL default '',
-                                  shortname varchar(100) NOT NULL default '',     
-                                  description text NOT NULL default '',
-                                  sortorder integer NOT NULL default '0'
-                                );");
-
-         modify_database('', "CREATE TABLE prefix_context (
-                                  id SERIAL PRIMARY KEY,
-                                  level integer NOT NULL default 0,
-                                  instanceid integer NOT NULL default 0
-                                );");
-
-
-         modify_database('', "CREATE TABLE prefix_role_assignments (
-                                  id SERIAL PRIMARY KEY,
-                                  roleid integer NOT NULL default 0,
-                                  contextid integer NOT NULL default 0,
-                                  userid integer NOT NULL default 0,
-                                  hidden integer NOT NULL default 0,
-                                  timestart integer NOT NULL default 0,
-                                  timeend integer NOT NULL default 0,
-                                  timemodified integer NOT NULL default 0,
-                                  modifierid integer NOT NULL default 0,
-                                  enrol varchar(20) NOT NULL default '',
-                                  sortorder integer NOT NULL default '0'
-                                );");
-
-        modify_database('', "CREATE TABLE prefix_role_capabilities (
-                                  id SERIAL PRIMARY KEY,
-                                  contextid integer NOT NULL default 0,
-                                  roleid integer NOT NULL default 0,
-                                  capability varchar(255) NOT NULL default '',
-                                  permission integer NOT NULL default 0,
-                                  timemodified integer NOT NULL default 0,
-                                  modifierid integer NOT NULL default 0
-                                );");
-
-        modify_database('', "CREATE TABLE prefix_role_deny_grant (
-                                  id SERIAL PRIMARY KEY,
-                                  roleid integer NOT NULL default '0',
-                                  unviewableroleid integer NOT NULL default '0'
-                                );");
-                                
-        modify_database('', "CREATE TABLE prefix_capabilities ( 
-                              id SERIAL PRIMARY KEY,
-                              name varchar(255) NOT NULL default '', 
-                              captype varchar(50) NOT NULL default '', 
-                              contextlevel integer NOT NULL default 0, 
-                              component varchar(100) NOT NULL default ''
-                                );"); 
-                                
-        modify_database('', "CREATE TABLE prefix_role_names ( 
-                              id SERIAL PRIMARY KEY,
-                              roleid integer NOT NULL default 0,
-                              contextid integer NOT NULL default 0, 
-                              text text NOT NULL default ''
-                                );");                                
-                                                                                     
-    }
-    
-    if ($oldversion < 2006081000) {
-        modify_database('',"CREATE INDEX prefix_role_sortorder_idx ON prefix_role (sortorder);");
-        modify_database('',"CREATE INDEX prefix_context_instanceid_idx ON prefix_context (instanceid);");
-        modify_database('',"CREATE UNIQUE INDEX prefix_context_levelinstanceid_idx ON prefix_context (level, instanceid);"); 
-        modify_database('',"CREATE INDEX prefix_role_assignments_roleid_idx ON prefix_role_assignments (roleid);");
-        modify_database('',"CREATE INDEX prefix_role_assignments_contextidid_idx ON prefix_role_assignments (contextid);");
-        modify_database('',"CREATE INDEX prefix_role_assignments_userid_idx ON prefix_role_assignments (userid);");
-        modify_database('',"CREATE UNIQUE INDEX prefix_role_assignments_contextidroleiduserid_idx ON prefix_role_assignments (contextid, roleid, userid);");
-        modify_database('',"CREATE INDEX prefix_role_assignments_sortorder_idx ON prefix_role_assignments (sortorder);");
-        modify_database('',"CREATE INDEX prefix_role_capabilities_roleid_idx ON prefix_role_capabilities (roleid);");
-        modify_database('',"CREATE INDEX prefix_role_capabilities_contextid_idx ON prefix_role_capabilities (contextid);");
-        modify_database('',"CREATE INDEX prefix_role_capabilities_modifierid_idx ON prefix_role_capabilities (modifierid);");
-        // MDL-10640  adding missing index from upgrade
-        modify_database('',"CREATE INDEX prefix_role_capabilities_capability_idx ON prefix_role_capabilities (capability);");
-        modify_database('',"CREATE UNIQUE INDEX prefix_role_capabilities_roleidcontextidcapability_idx ON prefix_role_capabilities (roleid, contextid, capability);"); 
-        modify_database('',"CREATE INDEX prefix_role_deny_grant_roleid_idx ON prefix_role_deny_grant (roleid);");
-        modify_database('',"CREATE INDEX prefix_role_deny_grant_unviewableroleid_idx ON prefix_role_deny_grant (unviewableroleid);");
-        modify_database('',"CREATE UNIQUE INDEX prefix_role_deny_grant_roleidunviewableroleid_idx ON prefix_role_deny_grant (roleid, unviewableroleid);");
-        modify_database('',"CREATE UNIQUE INDEX prefix_capabilities_name_idx ON prefix_capabilities (name);");
-        modify_database('',"CREATE INDEX prefix_role_names_roleid_idx ON prefix_role_names (roleid);");
-        modify_database('',"CREATE INDEX prefix_role_names_contextid_idx ON prefix_role_names (contextid);");
-        modify_database('',"CREATE UNIQUE INDEX prefix_role_names_roleidcontextid_idx ON prefix_role_names (roleid, contextid);");    
-    }
-        
-    if ($oldversion < 2006081700) { 
-        modify_database('',"DROP TABLE prefix_role_deny_grant");
-        
-        modify_database('',"CREATE TABLE prefix_role_allow_assign (    
-            id SERIAL PRIMARY KEY,     
-            roleid integer NOT NULL default '0',   
-            allowassign integer NOT NULL default '0'      
-        );");
-
-        modify_database('',"CREATE INDEX prefix_role_allow_assign_roleid_idx ON prefix_role_allow_assign (roleid);");
-        modify_database('',"CREATE INDEX prefix_role_allow_assign_allowassign_idx ON prefix_role_allow_assign (allowassign);");
-        modify_database('',"CREATE UNIQUE INDEX prefix_role_allow_assign_roleidallowassign_idx ON prefix_role_allow_assign (roleid, allowassign);");
-
-        modify_database('',"CREATE TABLE prefix_role_allow_override (    
-            id SERIAL PRIMARY KEY,     
-            roleid integer NOT NULL default '0',   
-            allowoverride integer NOT NULL default '0'      
-        );");
-        
-        modify_database('',"CREATE INDEX prefix_role_allow_override_roleid_idx ON prefix_role_allow_override (roleid);");
-        modify_database('',"CREATE INDEX prefix_role_allow_override_allowoverride_idx ON prefix_role_allow_override (allowoverride);");
-        modify_database('',"CREATE UNIQUE INDEX prefix_role_allow_override_roleidallowoverride_idx ON prefix_role_allow_override (roleid, allowoverride);");
-               
-    }
-    
-    if ($oldversion < 2006082100) {
-        execute_sql("DROP INDEX {$CFG->prefix}context_levelinstanceid_idx;",false);
-        table_column('context', 'level', 'aggregatelevel', 'integer', '10', 'unsigned', '0', 'not null', '');
-        modify_database('',"CREATE UNIQUE INDEX prefix_context_aggregatelevelinstanceid_idx ON prefix_context (aggregatelevel, instanceid);"); 
-    }
-
-    if ($oldversion < 2006082200) {
-        table_column('timezone', 'rule', 'tzrule', 'varchar', '20', '', '', 'not null', '');
-    }
-
-    if ($oldversion < 2006082800) {
-        table_column('user', '', 'ajax', 'integer', '1', 'unsigned', '1', 'not null', 'htmleditor');
-    }
-
-    if ($oldversion < 2006082900) {
-        execute_sql("DROP TABLE {$CFG->prefix}sessions", true);
-        execute_sql("
-            CREATE TABLE {$CFG->prefix}sessions2 (
-                sesskey VARCHAR(255) NOT NULL default '',
-                expiry TIMESTAMP NOT NULL,
-                expireref VARCHAR(255),
-                created TIMESTAMP NOT NULL,
-                modified TIMESTAMP NOT NULL,
-                sessdata TEXT,
-                CONSTRAINT {$CFG->prefix}sess_ses_pk PRIMARY KEY (sesskey)
-            );", true);
-
-        execute_sql("
-            CREATE INDEX {$CFG->prefix}sess_exp_ix ON {$CFG->prefix}sessions2 (expiry);", true);
-        execute_sql("
-            CREATE INDEX {$CFG->prefix}sess_exp2_ix ON {$CFG->prefix}sessions2 (expireref);", true);
-    }
-    
-    if ($oldversion < 2006083002) {
-        table_column('capabilities', '', 'riskbitmask', 'INTEGER', '10', 'unsigned', '0', 'not null', '');
-    }
-
-    if ($oldversion < 2006083100) {
-        execute_sql("ALTER TABLE {$CFG->prefix}course ALTER COLUMN modinfo DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}course ALTER COLUMN modinfo DROP DEFAULT");
-    }
-
-    if ($oldversion < 2006083101) {
-        execute_sql("ALTER TABLE {$CFG->prefix}course_categories ALTER COLUMN description DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}course_categories ALTER COLUMN description DROP DEFAULT");
-    }
-
-    if ($oldversion < 2006083102) {
-        execute_sql("ALTER TABLE {$CFG->prefix}user ALTER COLUMN description DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}user ALTER COLUMN description DROP DEFAULT");
-    }
-
-    if ($oldversion < 2006090200) {
-        execute_sql("ALTER TABLE {$CFG->prefix}course_sections ALTER COLUMN summary DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}course_sections ALTER COLUMN summary DROP DEFAULT");
-        execute_sql("ALTER TABLE {$CFG->prefix}course_sections ALTER COLUMN sequence DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}course_sections ALTER COLUMN sequence DROP DEFAULT");
-    }
-
-    // table to keep track of course page access times, used in online participants block, and participants list
-    if ($oldversion < 2006091200) {
-        execute_sql("CREATE TABLE {$CFG->prefix}user_lastaccess ( 
-                    id SERIAL PRIMARY KEY,     
-                    userid integer NOT NULL default 0,
-                    courseid integer NOT NULL default 0, 
-                    timeaccess integer NOT NULL default 0
-                    );", true);
-
-        execute_sql("CREATE INDEX {$CFG->prefix}user_lastaccess_userid_idx ON {$CFG->prefix}user_lastaccess (userid);", true);
-        execute_sql("CREATE INDEX {$CFG->prefix}user_lastaccess_courseid_idx ON {$CFG->prefix}user_lastaccess (courseid);", true);
-        execute_sql("CREATE UNIQUE INDEX {$CFG->prefix}user_lastaccess_useridcourseid_idx ON {$CFG->prefix}user_lastaccess (userid, courseid);", true);
-    
-    }
-
-    if (!empty($CFG->rolesactive) and $oldversion < 2006091212) {   // Reload the guest roles completely with new defaults
-        if ($guestroles = get_roles_with_capability('moodle/legacy:guest', CAP_ALLOW)) {
-            delete_records('capabilities');
-            $sitecontext = get_context_instance(CONTEXT_SYSTEM);
-            foreach ($guestroles as $guestrole) {
-                delete_records('role_capabilities', 'roleid', $guestrole->id);
-                assign_capability('moodle/legacy:guest', CAP_ALLOW, $guestrole->id, $sitecontext->id);
-            }
-        }
-    }
-
-    if ($oldversion < 2006091700) {
-        table_column('course','','defaultrole','integer','10', 'unsigned', '0', 'not null');
-    }
-
-    if ($oldversion < 2006091800) {
-        delete_records('config', 'name', 'showsiteparticipantslist');
-        delete_records('config', 'name', 'requestedteachername');
-        delete_records('config', 'name', 'requestedteachersname');
-        delete_records('config', 'name', 'requestedstudentname');
-        delete_records('config', 'name', 'requestedstudentsname');
-    }
-
-    if (!empty($CFG->rolesactive) and $oldversion < 2006091901) {
-        if ($roles = get_records('role')) {
-            $first = array_shift($roles);
-            if (!empty($first->shortname)) {
-                // shortnames already exist
-            } else {
-                table_column('role', '', 'shortname', 'varchar', '100', '', '', 'not null', 'name');
-                $legacy_names = array('admin', 'coursecreator', 'editingteacher', 'teacher', 'student', 'guest');
-                foreach ($legacy_names as $name) {
-                    if ($roles = get_roles_with_capability('moodle/legacy:'.$name, CAP_ALLOW)) {
-                        $i = '';
-                        foreach ($roles as $role) {
-                            if (empty($role->shortname)) {
-                                $updated = new object();
-                                $updated->id = $role->id;
-                                $updated->shortname = $name.$i;
-                                update_record('role', $updated);
-                                $i++;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    /// Tables for customisable user profile fields
-    if ($oldversion < 2006092000) {
-        execute_sql("CREATE TABLE {$CFG->prefix}user_info_field (
-                        id BIGSERIAL,
-                        name VARCHAR(255) NOT NULL default '',
-                        datatype VARCHAR(255) NOT NULL default '',
-                        categoryid BIGINT NOT NULL default 0,
-                        sortorder BIGINT NOT NULL default 0,
-                        required SMALLINT NOT NULL default 0,
-                        locked SMALLINT NOT NULL default 0,
-                        visible SMALLINT NOT NULL default 0,
-                        defaultdata TEXT,
-                        CONSTRAINT {$CFG->prefix}userinfofiel_id_pk PRIMARY KEY (id));", true);
-
-        execute_sql("COMMENT ON TABLE {$CFG->prefix}user_info_field IS 'Customisable user profile fields';", true);
-
-        execute_sql("CREATE TABLE {$CFG->prefix}user_info_category (
-                        id BIGSERIAL,
-                        name VARCHAR(255) NOT NULL default '',
-                        sortorder BIGINT NOT NULL default 0,
-                        CONSTRAINT {$CFG->prefix}userinfocate_id_pk PRIMARY KEY (id));", true);
-
-        execute_sql("COMMENT ON TABLE {$CFG->prefix}user_info_category IS 'Customisable fields categories';", true);
-
-        execute_sql("CREATE TABLE {$CFG->prefix}user_info_data (
-                        id BIGSERIAL,
-                        userid BIGINT NOT NULL default 0,
-                        fieldid BIGINT NOT NULL default 0,
-                        data TEXT NOT NULL,
-                        CONSTRAINT {$CFG->prefix}userinfodata_id_pk PRIMARY KEY (id));", true);
-
-        execute_sql("COMMENT ON TABLE {$CFG->prefix}user_info_data IS 'Data for the customisable user fields';", true);
-
-    }
-
-    if ($oldversion < 2006092200) {
-        table_column('context', 'aggregatelevel', 'contextlevel', 'int', '10', 'unsigned', '0', 'not null', '');
-/*      execute_sql("ALTER TABLE `{$CFG->prefix}context` DROP INDEX `aggregatelevel-instanceid`;",false);
-        execute_sql("ALTER TABLE `{$CFG->prefix}context` ADD UNIQUE INDEX `contextlevel-instanceid` (`contextlevel`, `instanceid`)",false);  // see 2006092409 below */   
-    }
-
-    if ($oldversion < 2006092302) {
-        // fix sortorder first if needed
-        if ($roles = get_all_roles()) {
-            $i = 0;
-            foreach ($roles as $rolex) {
-                if ($rolex->sortorder != $i) {
-                    $r = new object();
-                    $r->id = $rolex->id;
-                    $r->sortorder = $i;
-                    update_record('role', $r);
-                }
-                $i++;
-            }
-        }
-/*        execute_sql("ALTER TABLE {$CFG->prefix}role DROP INDEX {$CFG->prefix}role_sor_ix;");
-        execute_sql("ALTER TABLE {$CFG->prefix}role ADD UNIQUE INDEX {$CFG->prefix}role_sor_uix (sortorder)");*/
-    }
-
-    if ($oldversion < 2006092400) {
-        table_column('user', '', 'trustbitmask', 'INTEGER', '10', 'unsigned', '0', 'not null', '');
-    }
-
-    if ($oldversion < 2006092409) {
-        // ok, once more and now correctly!
-        execute_sql("DROP INDEX \"aggregatelevel-instanceid\";", false);
-        execute_sql("DROP INDEX \"contextlevel-instanceid\";", false);
-        execute_sql("CREATE UNIQUE INDEX {$CFG->prefix}cont_conins_uix ON {$CFG->prefix}context (contextlevel, instanceid);", false);
-
-        execute_sql("DROP INDEX {$CFG->prefix}role_sor_ix;", false);
-        execute_sql("DROP INDEX {$CFG->prefix}role_sor_uix;", false);
-        execute_sql("CREATE UNIQUE INDEX {$CFG->prefix}role_sor_uix ON {$CFG->prefix}role (sortorder);", false);
-    }
-
-    if ($oldversion < 2006092410) {
-        /// Convert all the PG unique keys into their corresponding unique indexes
-        /// we don't want such keys inside Moodle 1.7 and above
-        /// Look for all the UNIQUE CONSTRAINSTS existing in DB
-        $uniquecons = get_records_sql ("SELECT conname, relname, conkey, clas.oid AS tableoid
-                                          FROM pg_constraint cons,
-                                               pg_class clas
-                                         WHERE cons.contype='u'
-                                           AND cons.conrelid = clas.oid");
-        /// Iterate over every unique constraint, calculating its fields
-        if ($uniquecons) {
-            foreach ($uniquecons as $uniquecon) {
-                $conscols = trim(trim($uniquecon->conkey, '}'), '{');
-                $conscols = explode(',', $conscols);
-            /// Iterate over each column to fetch its name
-                $indexcols = array();
-                foreach ($conscols as $conscol) {
-                    $column = get_record_sql ("SELECT attname, attname
-                                                 FROM pg_attribute
-                                                WHERE attrelid = $uniquecon->tableoid
-                                                  AND attnum   = $conscol");
-                    $indexcols[] = $column->attname;
-                }
-            /// Drop the old UNIQUE CONSTRAINT
-                execute_sql ("ALTER TABLE $uniquecon->relname DROP CONSTRAINT $uniquecon->conname", false);
-            /// Create the new UNIQUE INDEX
-                execute_sql ("CREATE UNIQUE INDEX {$uniquecon->relname}_".implode('_', $indexcols)."_uix ON $uniquecon->relname (".implode(', ', $indexcols).')', false);
-            }
-        }
-    }
-
-    if ($oldversion < 2006092601) {
-            table_column('log_display', 'field', 'field', 'varchar', '200', '', '', 'not null', '');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return $result;
-}
-
-?>
index cf7df182c54fc9e2818f510ca8808d031d1b6732..4dcd092b2a8083c74b0fd2246912ac66be43394f 100644 (file)
@@ -555,7 +555,7 @@ function get_mimetype_description($mimetype,$capitalise=false) {
  * @param string $mimetype Include to specify the MIME type; leave blank to have it guess the type from $filename
  */
 function send_file($path, $filename, $lifetime=86400 , $filter=0, $pathisstring=false, $forcedownload=false, $mimetype='') {
-    global $CFG, $COURSE;
+    global $CFG, $COURSE, $SESSION;
 
     // Use given MIME type if specified, otherwise guess it using mimeinfo.
     // IE, Konqueror and Opera open html file directly in browser from web even when directed to save it to disk :-O
@@ -670,7 +670,7 @@ function send_file($path, $filename, $lifetime=86400 , $filter=0, $pathisstring=
             //cookieless mode - rewrite links
             @header('Content-Type: text/html');
             $path = $pathisstring ? $path : implode('', file($path));
-            $path = sid_ob_rewrite($path);
+            $path = $SESSION->sid_ob_rewrite($path);
             $filesize = strlen($path);
             $pathisstring = true;
         } else if ($mimetype == 'text/plain') {
@@ -696,7 +696,7 @@ function send_file($path, $filename, $lifetime=86400 , $filter=0, $pathisstring=
             $output = format_text($text, FORMAT_HTML, $options, $COURSE->id);
             if (!empty($CFG->usesid) && empty($_COOKIE['MoodleSession'.$CFG->sessioncookie])) {
                 //cookieless mode - rewrite links
-                $output = sid_ob_rewrite($output);
+                $output = $SESSION->sid_ob_rewrite($output);
             }
 
             @header('Content-Length: '.strlen($output));
@@ -712,7 +712,7 @@ function send_file($path, $filename, $lifetime=86400 , $filter=0, $pathisstring=
             $output = '<pre>'. format_text($text, FORMAT_MOODLE, $options, $COURSE->id) .'</pre>';
             if (!empty($CFG->usesid) && empty($_COOKIE['MoodleSession'.$CFG->sessioncookie])) {
                 //cookieless mode - rewrite links
-                $output = sid_ob_rewrite($output);
+                $output = $SESSION->sid_ob_rewrite($output);
             }
 
             @header('Content-Length: '.strlen($output));
diff --git a/lib/form/modgroupmode.php b/lib/form/modgroupmode.php
deleted file mode 100644 (file)
index 6651e0f..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-global $CFG;
-require_once "$CFG->libdir/form/select.php";
-
-/**
- * HTML class for a drop down element to select groupmode in an activity mod update form
- *
- * @author       Jamie Pratt
- * @access       public
- */
-class MoodleQuickForm_modgroupmode extends MoodleQuickForm_select{
-    /**
-     * Class constructor
-     *
-     * @param     string    Select name attribute
-     * @param     mixed     Label(s) for the select
-     * @param     mixed     Either a typical HTML attribute string or an associative array
-     * @param     mixed     $options ignored
-     * @access    public
-     * @return    void
-     */
-    function MoodleQuickForm_modgroupmode($elementName=null, $elementLabel=null, $attributes=null, $options=null)
-    {
-        HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes, null);
-        $this->_type = 'modgroupmode';
-
-
-    } //end constructor
-
-    /**
-     * Called by HTML_QuickForm whenever form event is made on this element
-     *
-     * @param     string    $event  Name of event
-     * @param     mixed     $arg    event arguments
-     * @param     object    $caller calling object
-     * @since     1.0
-     * @access    public
-     * @return    mixed
-     */
-    function onQuickFormEvent($event, $arg, &$caller)
-    {
-        switch ($event) {
-            case 'createElement':
-                $choices = array();
-                
-                $choices[NOGROUPS] = get_string('groupsnone');
-                $choices[SEPARATEGROUPS] = get_string('groupsseparate');
-                $choices[VISIBLEGROUPS] = get_string('groupsvisible');
-                
-                $this->setHelpButton(array('groupmode', get_string('groupmode')));
-                $this->load($choices);
-                break;
-        }
-        return parent::onQuickFormEvent($event, $arg, $caller);
-    }
-
-}
-?>
diff --git a/lib/form/selectallornone.php b/lib/form/selectallornone.php
deleted file mode 100644 (file)
index 32e099d..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-<?php // $Id$
-
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards Martin Dougiamas  http://dougiamas.com     //
-//                                                                       //
-// This program is free software; you can redistribute it and/or modify  //
-// it under the terms of the GNU General Public License as published by  //
-// the Free Software Foundation; either version 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program is distributed in the hope that it will be useful,       //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
-// GNU General Public License for more details:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-require_once("HTML/QuickForm/link.php");
-
-/**
- * HTML class for a multiple checkboxes state controller
- *
- * @author       Nicolas Connault <nicolasconnault@gmail.com>
- * @version      1.0
- * @since        PHP4.04pl1
- * @access       public
- */
-class MoodleQuickForm_selectallornone extends HTML_QuickForm_link {
-    /**
-     * The original state of the checkboxes controlled by this element. This determines whether the first click of this element will switch them all to
-     * checked or to unchecked. It doesn't change the checked state of the original elements (there could be a mixed of checked/unchecked there), but
-     * there has to be a decision as to which action will be taken by clicking "select all/select none" the first time.
-     * @var int $originalValue
-     */
-    var $_originalValue = 0;
-
-    /**
-     * Constructor
-     * @param string $elementName The name of the group of advcheckboxes this element controls
-     * @param string $text The text of the link. Defaults to "select all/none"
-     * @param array  $attributes associative array of HTML attributes
-     * @param int    $originalValue The original general state of the checkboxes before the user first clicks this element
-     */
-    function MoodleQuickForm_selectallornone($elementName=null, $text=null, $attributes=null, $originalValue=0) {
-        if (is_null($originalValue)) {
-            $originalValue = 0;
-        }
-
-        global $FULLME;
-        $this->_originalValue = $originalValue;
-
-        if (is_null($elementName)) {
-            return;
-        }
-        $elementLabel = '&nbsp;';
-        $strselectallornone = get_string('selectallornone', 'form');
-        $attributes['onmouseover'] = "window.status='" . $strselectallornone . "';";
-        $attributes['onmouseout'] = "window.status='';";
-        $attributes['onclick'] = "html_quickform_toggle_checkboxes($elementName); return false;";
-        $select_value = optional_param('select'. $elementName, $originalValue, PARAM_INT);
-
-        if ($select_value == 0) {
-            $new_select_value = 1;
-        } else {
-            $new_select_value = 0;
-        }
-
-        $old_selectstr = "&select$elementName=$select_value";
-        $new_selectstr = "&select$elementName=$new_select_value";
-        $new_fullme = str_replace($old_selectstr, '', $FULLME);
-
-        $href = "$new_fullme$new_selectstr";
-        
-        if (empty($text)) {
-            $text = $strselectallornone;
-        }
-        $this->HTML_QuickForm_link($elementName, $elementLabel, $href, $text, $attributes);
-    } 
-
-    function toHtml() {
-        if (is_null($this->_originalValue)) {
-            return false;
-        }
-
-        $group = $this->_attributes['name'];
-        if ($this->_flagFrozen) {
-            $js = '';
-        } else {
-            $js = "<script type=\"text/javascript\">\n//<![CDATA[\n";
-            if (!defined('HTML_QUICKFORM_SELECTALLORNONE_EXISTS')) {
-                $js .= <<<EOS
-function html_quickform_toggle_checkboxes(group) {
-    var checkboxes = getElementsByClassName(document, 'input', 'checkboxgroup' + group);
-    var newvalue = false;
-    var global = eval('html_quickform_checkboxgroup' + group + ';');
-    if (global == 1) {
-        eval('html_quickform_checkboxgroup' + group + ' = 0;'); 
-        newvalue = '';
-    } else {
-        eval('html_quickform_checkboxgroup' + group + ' = 1;'); 
-        newvalue = 'checked';
-    }
-
-    for (i = 0; i < checkboxes.length; i++) {
-        checkboxes[i].checked = newvalue; 
-    }
-}
-EOS;
-                define('HTML_QUICKFORM_SELECTALLORNONE_EXISTS', true);
-            }
-            $js .= "var html_quickform_checkboxgroup$group=$this->_originalValue;";
-            
-            $js .= "//]]>\n</script>";
-        }
-        return $js . parent::toHtml(); 
-    }
-}
-?> 
diff --git a/lib/grade/lib_wrapper.php b/lib/grade/lib_wrapper.php
deleted file mode 100644 (file)
index d566388..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-<?php // $Id$
-
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards Martin Dougiamas  http://dougiamas.com     //
-//                                                                       //
-// This program is free software; you can redistribute it and/or modify  //
-// it under the terms of the GNU General Public License as published by  //
-// the Free Software Foundation; either version 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program is distributed in the hope that it will be useful,       //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
-// GNU General Public License for more details:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-class grade_lib_wrapper {
-/*
-    function get_records_sql($sql, $limitfrom='', $limitnum='') {
-        return get_records_sql($sql, $limitfrom, $limitnum);
-    }
-    
-    function get_records_select($table, $select='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
-        return get_records_select($table, $select, $sort, $fields, $limitfrom, $limitnum);
-    }
-
-    function get_recordset($table, $field='', $value='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
-        return get_recordset($table, $field, $value, $sort, $fields, $limitfrom, $limitnum); 
-    }
-
-    function get_recordset_select($table, $select='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
-        return get_recordset_select($table, $select, $sort, $fields, $limitfrom, $limitnum);
-    }
-
-    function get_recordset_sql($sql, $limitfrom=null, $limitnum=null) {
-        return get_recordset_sql($sql, $limitfrom, $limitnum);
-    }
-    
-    function get_record($table, $field1, $value1, $field2='', $value2='', $field3='', $value3='', $fields='*') {
-        return get_record($table, $field1, $value1, $field2, $value2, $field3, $value3, $fields);
-    }
-
-    function get_records($table, $field='', $value='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
-        return get_records($table, $field, $value, $sort, $fields, $limitfrom, $limitnum);
-    }
-
-    function get_records_list($table, $field='', $values='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
-        return get_records_list($table, $field, $values, $sort, $fields, $limitfrom, $limitnum);
-    }
-
-    function get_field($table, $return, $field1, $value1, $field2='', $value2='', $field3='', $value3='') {
-        return get_field($table, $return, $field1, $value1, $field2, $value2, $field3, $value3);
-    }
-
-    function get_field_sql($sql) {
-        return get_field_sql($sql);
-    }
-
-    function get_field_select($table, $return, $select) {
-        return get_field_select($table, $return, $select);
-    }
-
-    function set_field($table, $newfield, $newvalue, $field1, $value1, $field2='', $value2='', $field3='', $value3='') {
-        return set_field($table, $newfield, $newvalue, $field1, $value1, $field2, $value2, $field3, $value3);
-    }
-
-    function set_field_select($table, $newfield, $newvalue, $select, $localcall = false) {
-        return set_field_select($table, $newfield, $newvalue, $select, $localcall);
-    }
-
-    function rs_fetch_next_record(&$rs) {
-        return rs_fetch_next_record($rs);
-    }
-
-    function execute_sql($command, $feedback=true) {
-        return execute_sql($command, $feedback);
-    }
-    
-    function update_record($table, $dataobject) {
-        return update_record($table, $dataobject);
-    }
-    
-    function insert_record($table, $dataobject, $returnid=true, $primarykey='id') {
-        return insert_record($table, $dataobject, $returnid, $primarykey);
-    }
-    
-    function delete_records($table, $field1='', $value1='', $field2='', $value2='', $field3='', $value3='') {
-        return delete_records($table, $field1, $value1, $field2, $value2, $field3, $value3);
-    }
-    
-    function count_records($table, $field1='', $value1='', $field2='', $value2='', $field3='', $value3='') {
-        return count_records($table, $field1, $value1, $field2, $value2, $field3, $value3);
-    }
-    
-    function count_records_sql($sql) {
-        return count_records_sql($sql);
-    }
-
-    function rs_close(&$rs) {
-        return;
-    }
-*/    
-    function get_coursemodule_from_instance($modulename, $instance, $courseid=0) {
-        return get_coursemodule_from_instance($modulename, $instance, $courseid);
-    }
-
-    function course_scale_used($courseid, $scaleid) {
-        return course_scale_used($courseid, $scaleid);
-    }
-    
-    function site_scale_used($scaleid,&$courses) {
-        return site_scale_used($scaleid, $courses);
-    }
-}
-
-?>
index 35e59eff067f6b43bdb01a71ddcf17fd199a7bc2..22dc0cb4b39a580a6b93ef189f3a4c3edbcf87ba 100644 (file)
@@ -3,7 +3,7 @@
        /// Searches modules, filters and blocks for any Javascript files
        /// that should be called on every page
 
-    $nomoodlecookie = true;
+    define('NO_MOODLE_COOKIES', true);
 
     include('../config.php');
 
diff --git a/lib/pear/System.php b/lib/pear/System.php
deleted file mode 100644 (file)
index 7289016..0000000
+++ /dev/null
@@ -1,540 +0,0 @@
-<?php
-//
-// +----------------------------------------------------------------------+
-// | PHP Version 5                                                        |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group                                |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.0 of the PHP license,       |
-// | that is bundled with this package in the file LICENSE, and is        |
-// | available through the world-wide-web at the following url:           |
-// | http://www.php.net/license/3_0.txt.                                  |
-// | If you did not receive a copy of the PHP license and are unable to   |
-// | obtain it through the world-wide-web, please send a note to          |
-// | license@php.net so we can mail you a copy immediately.               |
-// +----------------------------------------------------------------------+
-// | Authors: Tomas V.V.Cox <cox@idecnet.com>                             |
-// +----------------------------------------------------------------------+
-//
-// $Id$
-//
-
-require_once 'PEAR.php';
-require_once 'Console/Getopt.php';
-
-$GLOBALS['_System_temp_files'] = array();
-
-/**
-* System offers cross plattform compatible system functions
-*
-* Static functions for different operations. Should work under
-* Unix and Windows. The names and usage has been taken from its respectively
-* GNU commands. The functions will return (bool) false on error and will
-* trigger the error with the PHP trigger_error() function (you can silence
-* the error by prefixing a '@' sign after the function call).
-*
-* Documentation on this class you can find in:
-* http://pear.php.net/manual/
-*
-* Example usage:
-* if (!@System::rm('-r file1 dir1')) {
-*    print "could not delete file1 or dir1";
-* }
-*
-* In case you need to to pass file names with spaces,
-* pass the params as an array:
-*
-* System::rm(array('-r', $file1, $dir1));
-*
-* @package  System
-* @author   Tomas V.V.Cox <cox@idecnet.com>
-* @version  $Revision$
-* @access   public
-* @see      http://pear.php.net/manual/
-*/
-class System
-{
-    /**
-    * returns the commandline arguments of a function
-    *
-    * @param    string  $argv           the commandline
-    * @param    string  $short_options  the allowed option short-tags
-    * @param    string  $long_options   the allowed option long-tags
-    * @return   array   the given options and there values
-    * @access private
-    */
-    function _parseArgs($argv, $short_options, $long_options = null)
-    {
-        if (!is_array($argv) && $argv !== null) {
-            $argv = preg_split('/\s+/', $argv);
-        }
-        return Console_Getopt::getopt2($argv, $short_options);
-    }
-
-    /**
-    * Output errors with PHP trigger_error(). You can silence the errors
-    * with prefixing a "@" sign to the function call: @System::mkdir(..);
-    *
-    * @param mixed $error a PEAR error or a string with the error message
-    * @return bool false
-    * @access private
-    */
-    function raiseError($error)
-    {
-        if (PEAR::isError($error)) {
-            $error = $error->getMessage();
-        }
-        trigger_error($error, E_USER_WARNING);
-        return false;
-    }
-
-    /**
-    * Creates a nested array representing the structure of a directory
-    *
-    * System::_dirToStruct('dir1', 0) =>
-    *   Array
-    *    (
-    *    [dirs] => Array
-    *        (
-    *            [0] => dir1
-    *        )
-    *
-    *    [files] => Array
-    *        (
-    *            [0] => dir1/file2
-    *            [1] => dir1/file3
-    *        )
-    *    )
-    * @param    string  $sPath      Name of the directory
-    * @param    integer $maxinst    max. deep of the lookup
-    * @param    integer $aktinst    starting deep of the lookup
-    * @return   array   the structure of the dir
-    * @access   private
-    */
-
-    function _dirToStruct($sPath, $maxinst, $aktinst = 0)
-    {
-        $struct = array('dirs' => array(), 'files' => array());
-        if (($dir = @opendir($sPath)) === false) {
-            System::raiseError("Could not open dir $sPath");
-            return $struct; // XXX could not open error
-        }
-        $struct['dirs'][] = $sPath; // XXX don't add if '.' or '..' ?
-        $list = array();
-        while ($file = readdir($dir)) {
-            if ($file != '.' && $file != '..') {
-                $list[] = $file;
-            }
-        }
-        closedir($dir);
-        sort($list);
-        if ($aktinst < $maxinst || $maxinst == 0) {
-            foreach($list as $val) {
-                $path = $sPath . DIRECTORY_SEPARATOR . $val;
-                if (is_dir($path)) {
-                    $tmp = System::_dirToStruct($path, $maxinst, $aktinst+1);
-                    $struct = array_merge_recursive($tmp, $struct);
-                } else {
-                    $struct['files'][] = $path;
-                }
-            }
-        }
-        return $struct;
-    }
-
-    /**
-    * Creates a nested array representing the structure of a directory and files
-    *
-    * @param    array $files Array listing files and dirs
-    * @return   array
-    * @see System::_dirToStruct()
-    */
-    function _multipleToStruct($files)
-    {
-        $struct = array('dirs' => array(), 'files' => array());
-        settype($files, 'array');
-        foreach ($files as $file) {
-            if (is_dir($file)) {
-                $tmp = System::_dirToStruct($file, 0);
-                $struct = array_merge_recursive($tmp, $struct);
-            } else {
-                $struct['files'][] = $file;
-            }
-        }
-        return $struct;
-    }
-
-    /**
-    * The rm command for removing files.
-    * Supports multiple files and dirs and also recursive deletes
-    *
-    * @param    string  $args   the arguments for rm
-    * @return   mixed   PEAR_Error or true for success
-    * @access   public
-    */
-    function rm($args)
-    {
-        $opts = System::_parseArgs($args, 'rf'); // "f" do nothing but like it :-)
-        if (PEAR::isError($opts)) {
-            return System::raiseError($opts);
-        }
-        foreach($opts[0] as $opt) {
-            if ($opt[0] == 'r') {
-                $do_recursive = true;
-            }
-        }
-        $ret = true;
-        if (isset($do_recursive)) {
-            $struct = System::_multipleToStruct($opts[1]);
-            foreach($struct['files'] as $file) {
-                if (!@unlink($file)) {
-                    $ret = false;
-                }
-            }
-            foreach($struct['dirs'] as $dir) {
-                if (!@rmdir($dir)) {
-                    $ret = false;
-                }
-            }
-        } else {
-            foreach ($opts[1] as $file) {
-                $delete = (is_dir($file)) ? 'rmdir' : 'unlink';
-                if (!@$delete($file)) {
-                    $ret = false;
-                }
-            }
-        }
-        return $ret;
-    }
-
-    /**
-    * Make directories. Note that we use call_user_func('mkdir') to avoid
-    * a problem with ZE2 calling System::mkDir instead of the native PHP func.
-    *
-    * @param    string  $args    the name of the director(y|ies) to create
-    * @return   bool    True for success
-    * @access   public
-    */
-    function mkDir($args)
-    {
-        $opts = System::_parseArgs($args, 'pm:');
-        if (PEAR::isError($opts)) {
-            return System::raiseError($opts);
-        }
-        $mode = 0777; // default mode
-        foreach($opts[0] as $opt) {
-            if ($opt[0] == 'p') {
-                $create_parents = true;
-            } elseif($opt[0] == 'm') {
-                // if the mode is clearly an octal number (starts with 0)
-                // convert it to decimal
-                if (strlen($opt[1]) && $opt[1]{0} == '0') {
-                    $opt[1] = octdec($opt[1]);
-                } else {
-                    // convert to int
-                    $opt[1] += 0;
-                }
-                $mode = $opt[1];
-            }
-        }
-        $ret = true;
-        if (isset($create_parents)) {
-            foreach($opts[1] as $dir) {
-                $dirstack = array();
-                while (!@is_dir($dir) && $dir != DIRECTORY_SEPARATOR) {
-                    array_unshift($dirstack, $dir);
-                    $dir = dirname($dir);
-                }
-                while ($newdir = array_shift($dirstack)) {
-                    if (!call_user_func('mkdir', $newdir, $mode)) {
-                        $ret = false;
-                    }
-                }
-            }
-        } else {
-            foreach($opts[1] as $dir) {
-                if (!@is_dir($dir) && !call_user_func('mkdir', $dir, $mode)) {
-                    $ret = false;
-                }
-            }
-        }
-        return $ret;
-    }
-
-    /**
-    * Concatenate files
-    *
-    * Usage:
-    * 1) $var = System::cat('sample.txt test.txt');
-    * 2) System::cat('sample.txt test.txt > final.txt');
-    * 3) System::cat('sample.txt test.txt >> final.txt');
-    *
-    * Note: as the class use fopen, urls should work also (test that)
-    *
-    * @param    string  $args   the arguments
-    * @return   boolean true on success
-    * @access   public
-    */
-    function &cat($args)
-    {
-        $ret = null;
-        $files = array();
-        if (!is_array($args)) {
-            $args = preg_split('/\s+/', $args);
-        }
-        for($i=0; $i < count($args); $i++) {
-            if ($args[$i] == '>') {
-                $mode = 'wb';
-                $outputfile = $args[$i+1];
-                break;
-            } elseif ($args[$i] == '>>') {
-                $mode = 'ab+';
-                $outputfile = $args[$i+1];
-                break;
-            } else {
-                $files[] = $args[$i];
-            }
-        }
-        if (isset($mode)) {
-            if (!$outputfd = fopen($outputfile, $mode)) {
-                $err = System::raiseError("Could not open $outputfile");
-                return $err;
-            }
-            $ret = true;
-        }
-        foreach ($files as $file) {
-            if (!$fd = fopen($file, 'r')) {
-                System::raiseError("Could not open $file");
-                continue;
-            }
-            while ($cont = fread($fd, 2048)) {
-                if (isset($outputfd)) {
-                    fwrite($outputfd, $cont);
-                } else {
-                    $ret .= $cont;
-                }
-            }
-            fclose($fd);
-        }
-        if (@is_resource($outputfd)) {
-            fclose($outputfd);
-        }
-        return $ret;
-    }
-
-    /**
-    * Creates temporary files or directories. This function will remove
-    * the created files when the scripts finish its execution.
-    *
-    * Usage:
-    *   1) $tempfile = System::mktemp("prefix");
-    *   2) $tempdir  = System::mktemp("-d prefix");
-    *   3) $tempfile = System::mktemp();
-    *   4) $tempfile = System::mktemp("-t /var/tmp prefix");
-    *
-    * prefix -> The string that will be prepended to the temp name
-    *           (defaults to "tmp").
-    * -d     -> A temporary dir will be created instead of a file.
-    * -t     -> The target dir where the temporary (file|dir) will be created. If
-    *           this param is missing by default the env vars TMP on Windows or
-    *           TMPDIR in Unix will be used. If these vars are also missing
-    *           c:\windows\temp or /tmp will be used.
-    *
-    * @param   string  $args  The arguments
-    * @return  mixed   the full path of the created (file|dir) or false
-    * @see System::tmpdir()
-    * @access  public
-    */
-    function mktemp($args = null)
-    {
-        static $first_time = true;
-        $opts = System::_parseArgs($args, 't:d');
-        if (PEAR::isError($opts)) {
-            return System::raiseError($opts);
-        }
-        foreach($opts[0] as $opt) {
-            if($opt[0] == 'd') {
-                $tmp_is_dir = true;
-            } elseif($opt[0] == 't') {
-                $tmpdir = $opt[1];
-            }
-        }
-        $prefix = (isset($opts[1][0])) ? $opts[1][0] : 'tmp';
-        if (!isset($tmpdir)) {
-            $tmpdir = System::tmpdir();
-        }
-        if (!System::mkDir("-p $tmpdir")) {
-            return false;
-        }
-        $tmp = tempnam($tmpdir, $prefix);
-        if (isset($tmp_is_dir)) {
-            unlink($tmp); // be careful possible race condition here
-            if (!call_user_func('mkdir', $tmp, 0700)) {
-                return System::raiseError("Unable to create temporary directory $tmpdir");
-            }
-        }
-        $GLOBALS['_System_temp_files'][] = $tmp;
-        if ($first_time) {
-            PEAR::registerShutdownFunc(array('System', '_removeTmpFiles'));
-            $first_time = false;
-        }
-        return $tmp;
-    }
-
-    /**
-    * Remove temporary files created my mkTemp. This function is executed
-    * at script shutdown time
-    *
-    * @access private
-    */
-    function _removeTmpFiles()
-    {
-        if (count($GLOBALS['_System_temp_files'])) {
-            $delete = $GLOBALS['_System_temp_files'];
-            array_unshift($delete, '-r');
-            System::rm($delete);
-        }
-    }
-
-    /**
-    * Get the path of the temporal directory set in the system
-    * by looking in its environments variables.
-    * Note: php.ini-recommended removes the "E" from the variables_order setting,
-    * making unavaible the $_ENV array, that s why we do tests with _ENV
-    *
-    * @return string The temporal directory on the system
-    */
-    function tmpdir()
-    {
-        if (OS_WINDOWS) {
-            if ($var = isset($_ENV['TEMP']) ? $_ENV['TEMP'] : getenv('TEMP')) {
-                return $var;
-            }
-            if ($var = isset($_ENV['TMP']) ? $_ENV['TMP'] : getenv('TMP')) {
-                return $var;
-            }
-            if ($var = isset($_ENV['windir']) ? $_ENV['windir'] : getenv('windir')) {
-                return $var;
-            }
-            return getenv('SystemRoot') . '\temp';
-        }
-        if ($var = isset($_ENV['TMPDIR']) ? $_ENV['TMPDIR'] : getenv('TMPDIR')) {
-            return $var;
-        }
-        return '/tmp';
-    }
-
-    /**
-    * The "which" command (show the full path of a command)
-    *
-    * @param string $program The command to search for
-    * @return mixed A string with the full path or false if not found
-    * @author Stig Bakken <ssb@php.net>
-    */
-    function which($program, $fallback = false)
-    {
-        // is_executable() is not available on windows
-        if (OS_WINDOWS) {
-            $pear_is_executable = 'is_file';
-        } else {
-            $pear_is_executable = 'is_executable';
-        }
-
-        // full path given
-        if (basename($program) != $program) {
-            return (@$pear_is_executable($program)) ? $program : $fallback;
-        }
-
-        // XXX FIXME honor safe mode
-        $path_delim = OS_WINDOWS ? ';' : ':';
-        $exe_suffixes = OS_WINDOWS ? array('.exe','.bat','.cmd','.com') : array('');
-        $path_elements = explode($path_delim, getenv('PATH'));
-        foreach ($exe_suffixes as $suff) {
-            foreach ($path_elements as $dir) {
-                $file = $dir . DIRECTORY_SEPARATOR . $program . $suff;
-                if (@is_file($file) && @$pear_is_executable($file)) {
-                    return $file;
-                }
-            }
-        }
-        return $fallback;
-    }
-
-    /**
-    * The "find" command
-    *
-    * Usage:
-    *
-    * System::find($dir);
-    * System::find("$dir -type d");
-    * System::find("$dir -type f");
-    * System::find("$dir -name *.php");
-    * System::find("$dir -name *.php -name *.htm*");
-    * System::find("$dir -maxdepth 1");
-    *
-    * Params implmented:
-    * $dir            -> Start the search at this directory
-    * -type d         -> return only directories
-    * -type f         -> return only files
-    * -maxdepth <n>   -> max depth of recursion
-    * -name <pattern> -> search pattern (bash style). Multiple -name param allowed
-    *
-    * @param  mixed Either array or string with the command line
-    * @return array Array of found files
-    *
-    */
-    function find($args)
-    {
-        if (!is_array($args)) {
-            $args = preg_split('/\s+/', $args, -1, PREG_SPLIT_NO_EMPTY);
-        }
-        $dir = array_shift($args);
-        $patterns = array();
-        $depth = 0;
-        $do_files = $do_dirs = true;
-        for ($i = 0; $i < count($args); $i++) {
-            switch ($args[$i]) {
-                case '-type':
-                    if (in_array($args[$i+1], array('d', 'f'))) {
-                        if ($args[$i+1] == 'd') {
-                             $do_files = false;
-                        } else {
-                            $do_dirs = false;
-                        }
-                    }
-                    $i++;
-                    break;
-                case '-name':
-                    $patterns[] = "(" . preg_replace(array('/\./', '/\*/'),
-                                                     array('\.', '.*'),
-                                                     $args[$i+1])
-                                      . ")";
-                    $i++;
-                    break;
-                case '-maxdepth':
-                    $depth = $args[$i+1];
-                    break;
-            }
-        }
-        $path = System::_dirToStruct($dir, $depth);
-        if ($do_files && $do_dirs) {
-            $files = array_merge($path['files'], $path['dirs']);
-        } elseif ($do_dirs) {
-            $files = $path['dirs'];
-        } else {
-            $files = $path['files'];
-        }
-        if (count($patterns)) {
-            $patterns = implode('|', $patterns);
-            $ret = array();
-            for ($i = 0; $i < count($files); $i++) {
-                if (preg_match("#^$patterns\$#", $files[$i])) {
-                    $ret[] = $files[$i];
-                }
-            }
-            return $ret;
-        }
-        return $files;
-    }
-}
-?>
index 32aa7b91de4cb4f4d0668df3edee3eb1cfdc1a59..f73da062eae8ba0cb272de2dc216a38509444bb3 100644 (file)
@@ -6,17 +6,10 @@
 /// set a new variable, and after that it will try to find it again.
 /// The random number is just to prevent browser caching.
 
-session_start();
+require '../config.php';
 
-if (!isset($_SESSION["test"])) {   // First time you call it.
-    echo "<p>No session found - starting a session now.";
-    $_SESSION["test"] = "welcome back!";
+error('session test not reimplemented yet');
 
-} else {                           // Subsequent times you call it
-    echo "<p>Session found - ".$_SESSION["test"];
-    echo "</p><p>Sessions are working correctly</p>";
-}
-
-echo "<p><a href=\"session-test.php?random=".rand(1,10000)."\">Reload this page</a></p>";
+//TODO: add code that actually tests moodle sessions, the old one only tested PHP sessions used from installer, not the real moodle sessions 
 
 ?>
index c5ba97153c48acfd72e62d7a3016345ef97f4f6e..87a2f6cbc76124648c7f542e3d928db8a41f3dd6 100644 (file)
@@ -44,7 +44,7 @@ global $CFG;
  * @global object(session) $SESSION
  */
 global $SESSION;
-/** 
+/**
  * Definition of shared memory cache
  */
 global $MCACHE;
@@ -70,8 +70,8 @@ global $DB;
 global $THEME;
 
 /**
- * HTTPSPAGEREQUIRED is a global to define if the page being displayed must run under HTTPS. 
- * 
+ * HTTPSPAGEREQUIRED is a global to define if the page being displayed must run under HTTPS.
+ *
  * It's primary goal is to allow 100% HTTPS pages when $CFG->loginhttps is enabled. Default to false.
  * It's enabled only by the httpsrequired() function and used in some pages to update some URLs
 */
@@ -100,9 +100,9 @@ global $HTTPSPAGEREQUIRED;
 
     require_once($CFG->libdir .'/setuplib.php');        // Functions that MUST be loaded first
 
-/// Time to start counting    
-    init_performance_info();        
-    
+/// Time to start counting
+    init_performance_info();
+
 
 /// If there are any errors in the standard libraries we want to know!
     error_reporting(E_ALL);
@@ -110,7 +110,7 @@ global $HTTPSPAGEREQUIRED;
 /// Just say no to link prefetching (Moz prefetching, Google Web Accelerator, others)
 /// http://www.google.com/webmasters/faq.html#prefetchblock
     if (!empty($_SERVER['HTTP_X_moz']) && $_SERVER['HTTP_X_moz'] === 'prefetch'){
-        header($_SERVER['SERVER_PROTOCOL'] . ' 404 Prefetch Forbidden');        
+        header($_SERVER['SERVER_PROTOCOL'] . ' 404 Prefetch Forbidden');
         trigger_error('Prefetch request forbidden.');
         exit;
     }
@@ -133,6 +133,7 @@ global $HTTPSPAGEREQUIRED;
     require_once($CFG->libdir .'/moodlelib.php');       // Other general-purpose functions
     require_once($CFG->libdir .'/eventslib.php');       // Events functions
     require_once($CFG->libdir .'/grouplib.php');        // Groups functions
+    require_once($CFG->libdir .'/sessionlib.php');      // All session and cookie related stuff
 
     //point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
     //the problem is that we need specific version of quickforms and hacked excel files :-(
@@ -207,7 +208,7 @@ global $HTTPSPAGEREQUIRED;
         $CFG->debug = $originaldatabasedebug;
     }
     if ($originalconfigdebug !== -1) {
-        $CFG->debug = $originalconfigdebug; 
+        $CFG->debug = $originalconfigdebug;
     }
     unset($originalconfigdebug);
     unset($originaldatabasedebug);
@@ -265,7 +266,7 @@ global $HTTPSPAGEREQUIRED;
             if (!init_eaccelerator()) {
                 debugging("Error initialising eaccelerator cache");
                 $CFG->cachetype = '';
-                $CFG->rcache = false;                
+                $CFG->rcache = false;
             }
         }
 
@@ -309,69 +310,13 @@ global $HTTPSPAGEREQUIRED;
         make_upload_directory('cache');
     }
 
-/// Set up smarty template system
-    //require_once($CFG->libdir .'/smarty/Smarty.class.php');
-    //$smarty = new Smarty;
-    //$smarty->template_dir = $CFG->dirroot .'/templates/'. $CFG->template;
-    //if (!file_exists($CFG->dataroot .'/cache/smarty')) {
-    //    make_upload_directory('cache/smarty');
-    //}
-    //$smarty->compile_dir = $CFG->dataroot .'/cache/smarty';
-
-/// Set up session handling
-    if(empty($CFG->respectsessionsettings)) {
-        if (empty($CFG->dbsessions)) {   /// File-based sessions
-
-            // Some distros disable GC by setting probability to 0
-            // overriding the PHP default of 1
-            // (gc_probability is divided by gc_divisor, which defaults to 1000)
-            if (ini_get('session.gc_probability') == 0) {
-                ini_set('session.gc_probability', 1);
-            }
-
-            if (!empty($CFG->sessiontimeout)) {
-                ini_set('session.gc_maxlifetime', $CFG->sessiontimeout);
-            }
-
-            if (!file_exists($CFG->dataroot .'/sessions')) {
-                make_upload_directory('sessions');
-            }
-            ini_set('session.save_path', $CFG->dataroot .'/sessions');
-
-        } else {                         /// Database sessions
-            ini_set('session.save_handler', 'user');
-
-            $ADODB_SESSION_DRIVER  = $CFG->dbtype;
-            $ADODB_SESSION_CONNECT = $CFG->dbhost;
-            $ADODB_SESSION_USER    = $CFG->dbuser;
-            $ADODB_SESSION_PWD     = $CFG->dbpass;
-            $ADODB_SESSION_DB      = $CFG->dbname;
-            $ADODB_SESSION_TBL     = $CFG->prefix.'sessions2';
-            if (!empty($CFG->sessiontimeout)) {
-                $ADODB_SESS_LIFE   = $CFG->sessiontimeout;
-            }
-
-            require_once($CFG->libdir. '/adodb/session/adodb-session2.php');
-        }
-    }
-/// Set sessioncookie and sessioncookiepath variable if it isn't already
-    if (!isset($CFG->sessioncookie)) {
-        $CFG->sessioncookie = '';
-    }
-    if (!isset($CFG->sessioncookiepath)) {
-        $CFG->sessioncookiepath = '/';
-    }
-
 /// Configure ampersands in URLs
-
     @ini_set('arg_separator.output', '&amp;');
 
 /// Work around for a PHP bug   see MDL-11237
-  
-    @ini_set('pcre.backtrack_limit', 20971520);  // 20 MB 
+    @ini_set('pcre.backtrack_limit', 20971520);  // 20 MB
 
 /// Location of standard files
-
     $CFG->wordlist    = $CFG->libdir .'/wordlist.txt';
     $CFG->javascript  = $CFG->libdir .'/javascript.php';
     $CFG->moddata     = 'moddata';
@@ -415,60 +360,13 @@ global $HTTPSPAGEREQUIRED;
         }
     }
 
-/// Load up global environment variables
-
-    if (!isset($CFG->cookiesecure) or strpos($CFG->wwwroot, 'https://') !== 0) {
-        $CFG->cookiesecure = false;
-    }
+/// start session and prepare global $SESSION
+    $SESSION = new moodle_session();
 
-    if (!isset($CFG->cookiehttponly)) {
-        $CFG->cookiehttponly = false;
-    }
-
-    //discard session ID from POST, GET and globals to tighten security,
-    //this session fixation prevention can not be used in cookieless mode
-    if (empty($CFG->usesid) && !defined('MOODLE_SANE_INPUT')) {
-        unset(${'MoodleSession'.$CFG->sessioncookie});
-        unset($_GET['MoodleSession'.$CFG->sessioncookie]);
-        unset($_POST['MoodleSession'.$CFG->sessioncookie]);
-    }
-    //compatibility hack for Moodle Cron, cookies not deleted, but set to "deleted" - should not be needed with $nomoodlecookie in cron.php now 
-    if (!empty($_COOKIE['MoodleSession'.$CFG->sessioncookie]) && $_COOKIE['MoodleSession'.$CFG->sessioncookie] == "deleted") {
-        unset($_COOKIE['MoodleSession'.$CFG->sessioncookie]);
-    }
-    if (!empty($_COOKIE['MoodleSessionTest'.$CFG->sessioncookie]) && $_COOKIE['MoodleSessionTest'.$CFG->sessioncookie] == "deleted") {
-        unset($_COOKIE['MoodleSessionTest'.$CFG->sessioncookie]);
-    }
-    if (!empty($CFG->usesid) && empty($_COOKIE['MoodleSession'.$CFG->sessioncookie])) {
-        require_once("$CFG->dirroot/lib/cookieless.php");
-        sid_start_ob();
-    }
-
-    if (empty($nomoodlecookie)) {
-        session_name('MoodleSession'.$CFG->sessioncookie);
-        session_set_cookie_params(0, $CFG->sessioncookiepath, '', $CFG->cookiesecure, $CFG->cookiehttponly);
-        @session_start();
-        if (! isset($_SESSION['SESSION'])) {
-            $_SESSION['SESSION'] = new object;
-            $_SESSION['SESSION']->session_test = random_string(10);
-            if (!empty($_COOKIE['MoodleSessionTest'.$CFG->sessioncookie])) {
-                $_SESSION['SESSION']->has_timed_out = true;
-            }
-            setcookie('MoodleSessionTest'.$CFG->sessioncookie, $_SESSION['SESSION']->session_test, 0, $CFG->sessioncookiepath, '', $CFG->cookiesecure, $CFG->cookiehttponly);
-            $_COOKIE['MoodleSessionTest'.$CFG->sessioncookie] = $_SESSION['SESSION']->session_test;
-        }
-        if (! isset($_SESSION['USER']))    {
-            $_SESSION['USER']    = new object;
-        }
-
-        $SESSION = &$_SESSION['SESSION'];   // Makes them easier to reference
-        $USER    = &$_SESSION['USER'];
-        if (!isset($USER->id)) {
-            $USER->id = 0; // to enable proper function of $CFG->notloggedinroleid hack
-        }
-    }
-    else {
-        $SESSION  = NULL;
+/// set up global $USER
+    if (!NO_MOODLE_COOKIES) {
+        $USER = &$_SESSION['USER'];
+    } else {
         $USER     = new object();
         $USER->id = 0; // user not logged in when session disabled
         if (isset($CFG->mnet_localhost_id)) {
@@ -490,7 +388,7 @@ global $HTTPSPAGEREQUIRED;
         $CFG->themedir = $CFG->dirroot.'/theme';
         $CFG->themewww = $CFG->wwwroot.'/theme';
     }
-    $CFG->httpsthemewww = $CFG->themewww; 
+    $CFG->httpsthemewww = $CFG->themewww;
 
     if (isset($_GET['theme'])) {
         if ($CFG->allowthemechangeonurl || confirm_sesskey()) {
@@ -507,27 +405,17 @@ global $HTTPSPAGEREQUIRED;
     }
 
 /// now do a session test to prevent random user switching - observed on some PHP/Apache combinations,
-/// disable checks when working in cookieless mode
-    if (empty($CFG->usesid) || !empty($_COOKIE['MoodleSession'.$CFG->sessioncookie])) {
-        if ($SESSION != NULL) {
-            if (empty($_COOKIE['MoodleSessionTest'.$CFG->sessioncookie])) {
-                report_session_error();
-            } else if (isset($SESSION->session_test) && $_COOKIE['MoodleSessionTest'.$CFG->sessioncookie] != $SESSION->session_test) {
-                report_session_error();
-            }
-        }
-    }
-
+    $SESSION->session_verify();
 
 /// Set language/locale of printed times.  If user has chosen a language that
 /// that is different from the site language, then use the locale specified
 /// in the language file.  Otherwise, if the admin hasn't specified a locale
 /// then use the one from the default language.  Otherwise (and this is the
 /// majority of cases), use the stored locale specified by admin.
-    if ($SESSION !== NULL && isset($_GET['lang']) && ($lang = clean_param($_GET['lang'], PARAM_SAFEDIR))) {
+    if (isset($_GET['lang']) && ($lang = clean_param($_GET['lang'], PARAM_SAFEDIR))) {
         if (file_exists($CFG->dataroot .'/lang/'. $lang) or file_exists($CFG->dirroot .'/lang/'. $lang)) {
             $SESSION->lang = $lang;
-        } else if (file_exists($CFG->dataroot.'/lang/'.$lang.'_utf8') or 
+        } else if (file_exists($CFG->dataroot.'/lang/'.$lang.'_utf8') or
                    file_exists($CFG->dirroot .'/lang/'.$lang.'_utf8')) {
             $SESSION->lang = $lang.'_utf8';
         }
@@ -544,12 +432,12 @@ global $HTTPSPAGEREQUIRED;
             $CFG->lang = $SESSION->lang;
         }
     }
-    
+
     // set default locale and themes - might be changed again later from require_login()
     course_setup();
 
     if (!empty($CFG->opentogoogle)) {
-        if (empty($USER->id)) {  // Ignore anyone logged in
+        if (!NO_MOODLE_COOKIES and empty($USER->id)) {  // Ignore anyone logged in, or scripts without cookies
             if (!empty($_SERVER['HTTP_USER_AGENT'])) {
                 if (strpos($_SERVER['HTTP_USER_AGENT'], 'Googlebot') !== false ) {
                     $USER = guest_user();
@@ -570,14 +458,14 @@ global $HTTPSPAGEREQUIRED;
                     $USER = guest_user();
                 }
             }
-            if (!empty($USER)) {
+            if (!empty($USER->id)) {
                 load_all_capabilities();
             }
         }
     }
 
     if ($CFG->theme == 'standard' or $CFG->theme == 'standardwhite') {    // Temporary measure to help with XHTML validation
-        if (isset($_SERVER['HTTP_USER_AGENT']) and empty($_SESSION['USER']->id)) {      // Allow W3CValidator in as user called w3cvalidator (or guest)
+        if (isset($_SERVER['HTTP_USER_AGENT']) and empty($USER->id)) {      // Allow W3CValidator in as user called w3cvalidator (or guest)
             if ((strpos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') !== false) or
                 (strpos($_SERVER['HTTP_USER_AGENT'], 'Cynthia') !== false )) {
                 if ($USER = get_complete_user_data("username", "w3cvalidator")) {
diff --git a/lib/simpletest/testdmllib.php b/lib/simpletest/testdmllib.php
deleted file mode 100644 (file)
index 6767e22..0000000
+++ /dev/null
@@ -1,345 +0,0 @@
-<?php
-/**
- * Unit tests for (some of) ../datalib.php.
- *
- * @copyright &copy; 2006 The Open University
- * @author T.J.Hunt@open.ac.uk
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package moodlecore
- */
-
-if (!defined('MOODLE_INTERNAL')) {
-    die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
-}
-
-require_once($CFG->libdir . '/simpletestlib/web_tester.php');
-require_once($CFG->libdir . '/dmllib.php');
-
-class datalib_test extends prefix_changing_test_case {
-    var $table = 'table';
-    var $data = array(
-            array('id',   'textfield', 'numberfield'),
-            array(  1,    'frog',     101),
-            array(  2,    'toad',     102),
-            array(  3, 'tadpole',     103),
-            array(  4, 'tadpole',     104),
-            array(  5, 'nothing',     NULL),
-        );
-    var $objects = array();
-
-    function setUp() {
-        global $CFG, $db;
-        parent::setUp();
-        load_test_table($CFG->prefix . $this->table, $this->data, $db);
-        $keys = reset($this->data);
-        foreach ($this->data as $row=>$datum) {
-            if ($row == 0) {
-                continue;
-            }
-            $this->objects[$datum[0]] = (object) array_combine($keys, $datum);
-        }
-    }
-
-    function tearDown() {
-        global $CFG, $db;
-        remove_test_table($CFG->prefix . $this->table, $db);
-        parent::tearDown();
-    }
-
-    function test_where_clause() {
-        $this->assertEqual(where_clause('f1', 'v1'), "WHERE f1 = 'v1'");
-        $this->assertEqual(where_clause('f1', 'v1', 'f2', 2), "WHERE f1 = 'v1' AND f2 = '2'");
-        $this->assertEqual(where_clause('f1', 'v1', 'f2', 1.75, 'f3', 'v3'), "WHERE f1 = 'v1' AND f2 = '1.75' AND f3 = 'v3'");
-        $this->assertEqual(where_clause('f1', NULL), "WHERE f1 IS NULL");
-    }
-
-    function test_record_exists() {
-        $this->assertTrue(record_exists($this->table, 'numberfield', 101, 'id', 1));
-        $this->assertFalse(record_exists($this->table, 'numberfield', 102, 'id', 1));
-        $this->assertTrue(record_exists($this->table, 'numberfield', NULL));
-    }
-
-    function test_record_exists_select() {
-        $this->assertTrue(record_exists_select($this->table, 'numberfield = 101 AND id = 1'));
-        $this->assertFalse(record_exists_select($this->table, 'numberfield = 102 AND id = 1'));
-        $this->assertTrue(record_exists_select($this->table, 'numberfield IS NULL'));
-    }
-
-    function test_record_exists_sql() {
-        global $CFG;
-        $this->assertTrue(record_exists_sql("SELECT * FROM {$CFG->prefix}$this->table WHERE numberfield = 101 AND id = 1"));
-        $this->assertFalse(record_exists_sql("SELECT * FROM {$CFG->prefix}$this->table WHERE numberfield = 102 AND id = 1"));
-        $this->assertTrue(record_exists_sql("SELECT * FROM {$CFG->prefix}$this->table WHERE numberfield IS NULL"));
-    }
-
-
-    function test_get_record() {
-        // Get particular records.
-        $this->assert(new CheckSpecifiedFieldsExpectation($this->objects[1]), get_record($this->table, 'id', 1));
-        $this->assert(new CheckSpecifiedFieldsExpectation($this->objects[3]), get_record($this->table, 'textfield', 'tadpole', 'numberfield', 103));
-        $this->assert(new CheckSpecifiedFieldsExpectation($this->objects[5]), get_record($this->table, 'numberfield', null));
-
-        // Abiguous get attempt, should return one, and print a warning in debug mode.
-        global $CFG;
-        $old_debug = $CFG->debug;
-        $CFG->debug = 0;
-
-        ob_start();
-        $record = get_record($this->table, 'textfield', 'tadpole');
-        $result = ob_get_contents();
-        ob_end_clean();
-        $this->assertEqual('', $result, '%s (No error ouside debug mode).');
-
-        $CFG->debug = DEBUG_DEVELOPER;
-        ob_start();
-        $record = get_record($this->table, 'textfield', 'tadpole');
-        $result = ob_get_contents();
-        ob_end_clean();
-        $this->assert(new TextExpectation('Error:'), $result, 'Error in debug mode.');
-
-        $CFG->debug = $old_debug;
-
-        // Return only specified fields
-        $expected = new stdClass;
-        $expected->id = 3;
-        $expected->textfield = 'tadpole';
-        $result = get_record($this->table, 'id', '3', '', '', '', '', 'id,textfield');
-        $this->assert(new CheckSpecifiedFieldsExpectation($expected), $result);
-        $this->assertFalse(isset($result->numberfield));
-        $expected = new stdClass;
-        $expected->textfield = 'tadpole';
-        $expected->numberfield = 103;
-        $result = get_record($this->table, 'id', '3', '', '', '', '', 'textfield,numberfield');
-        $this->assert(new CheckSpecifiedFieldsExpectation($expected), $result);
-        $this->assertFalse(isset($result->id));
-
-        // Attempting to get a non-existant records should return false.
-        $this->assertFalse(get_record($this->table, 'textfield', 'not there'), 'attempt to get non-existant record');
-    }
-
-    function test_get_record_sql() {
-        global $CFG;
-        // Get particular records.
-        $this->assert(new CheckSpecifiedFieldsExpectation($this->objects[1]), get_record_sql("SELECT * FROM {$CFG->prefix}" . $this->table . " WHERE id = '1'", 'id = 1'));
-
-        // Abiguous get attempt, should return one, and print a warning in debug mode, unless $expectmultiple is used.
-        $old_debug = $CFG->debug;
-        $CFG->debug = 0;
-
-        ob_start();
-        $record = get_record_sql("SELECT * FROM {$CFG->prefix}" . $this->table . " WHERE textfield = 'tadpole'");
-        $result = ob_get_contents();
-        ob_end_clean();
-        $this->assertEqual('', $result, '%s (No error ouside debug mode).');
-
-        $CFG->debug = DEBUG_DEVELOPER;
-        ob_start();
-        $record = get_record_sql("SELECT * FROM {$CFG->prefix}" . $this->table . " WHERE textfield = 'tadpole'");
-        $result = ob_get_contents();
-        ob_end_clean();
-        $this->assert(new TextExpectation('Error:'), $result, 'Error in debug mode.');
-
-        ob_start();
-        $record = get_record_sql("SELECT * FROM {$CFG->prefix}" . $this->table . " WHERE textfield = 'tadpole'", true);
-        $result = ob_get_contents();
-        ob_end_clean();
-        $this->assertEqual('', $result, '%s (No error ouside debug mode).');
-
-        $CFG->debug = $old_debug;
-
-        // Attempting to get a non-existant records should return false.
-        $this->assertFalse(get_record_sql("SELECT * FROM {$CFG->prefix}" . $this->table . " WHERE textfield = 'not there'"), 'attempt to get non-existant record');
-    }
-
-    function test_get_record_select() {
-        // Get particular records.
-        $this->assert(new CheckSpecifiedFieldsExpectation($this->objects[2]), get_record_select($this->table, 'id > 1 AND id < 3'), 'id > 1 AND id < 3');
-
-        // Abiguous get attempt, should return one, and print a warning in debug mode.
-        global $CFG;
-        $old_debug = $CFG->debug;
-        $CFG->debug = 0;
-
-        ob_start();
-        $record = get_record_select($this->table, "textfield = 'tadpole'");
-        $result = ob_get_contents();
-        ob_end_clean();
-        $this->assertEqual('', $result, '%s (No error ouside debug mode).');
-
-        $CFG->debug = DEBUG_DEVELOPER;
-        ob_start();
-        $record = get_record_select($this->table, "textfield = 'tadpole'");
-        $result = ob_get_contents();
-        ob_end_clean();
-        $this->assert(new TextExpectation('Error:'), $result, 'Error in debug mode.');
-
-        $CFG->debug = $old_debug;
-
-        // Return only specified fields
-        $expected = new stdClass;
-        $expected->id = 1;
-        $expected->textfield = 'frog';
-        $result = get_record_select($this->table, "textfield = 'frog'", 'id,textfield');
-        $this->assert(new CheckSpecifiedFieldsExpectation($expected), $result);
-        $this->assertFalse(isset($result->numberfield));
-
-        // Attempting to get a non-existant records should return false.
-        $this->assertFalse(get_record_select($this->table, 'id > 666'), 'attempt to get non-existant record');
-    }
-
-    function test_get_field() {
-        $this->assertEqual(get_field($this->table, 'numberfield', 'id', 1), 101);
-        $this->assertEqual(get_field($this->table, 'textfield', 'numberfield', 102), 'toad');
-        $this->assertEqual(get_field($this->table, 'numberfield', 'textfield', 'tadpole', 'id', 4), 104);
-        $this->assertEqual(get_field($this->table, 'numberfield + id', 'textfield', 'tadpole', 'id', 4), 108);
-        $this->assertNull(get_field($this->table, 'numberfield', 'id', 5));
-    }
-
-    function test_get_field_select() {
-        $this->assertEqual(get_field_select($this->table, 'numberfield',  'id = 1'), 101);
-    }
-
-    function test_get_field_sql() {
-        global $CFG;
-        $this->assertEqual(get_field_sql("SELECT numberfield FROM {$CFG->prefix}$this->table WHERE id = 1"), 101);
-    }
-
-    function test_set_field() {
-        set_field($this->table, 'numberfield', 12345, 'id', 1);
-        $this->assertEqual(get_field($this->table, 'numberfield', 'id', 1), 12345);
-
-        set_field($this->table, 'textfield', 'newvalue', 'numberfield', 102);
-        $this->assertEqual(get_field($this->table, 'textfield', 'numberfield', 102), 'newvalue');
-
-        set_field($this->table, 'numberfield', -1, 'textfield', 'tadpole', 'id', 4);
-        $this->assertEqual(get_field($this->table, 'numberfield', 'textfield', 'tadpole', 'id', 4), -1);
-
-        set_field($this->table, 'textfield', null, 'id', 5);
-        $this->assertNull(get_field($this->table, 'textfield', 'id', 5));
-    }
-
-    function test_delete_records() {
-        delete_records($this->table, 'id', 666);
-        $this->assertEqual(count_records($this->table), 5);
-        delete_records($this->table, 'id', 1);
-        $this->assertEqual(count_records($this->table), 4);
-        delete_records($this->table, 'textfield', 'tadpole');
-        $this->assertEqual(count_records($this->table), 2);
-        delete_records($this->table, 'numberfield', NULL);
-        $this->assertEqual(count_records($this->table), 1);
-    }
-
-    function test_delete_records2() {
-        delete_records($this->table, 'textfield', 'tadpole', 'id', 4);
-        $this->assertEqual(count_records($this->table), 4);
-        delete_records($this->table);
-        $this->assertEqual(count_records($this->table), 0);
-    }
-
-    function test_delete_records_select() {
-        delete_records_select($this->table, "textfield LIKE 't%'");
-        $this->assertEqual(count_records($this->table), 2);
-        delete_records_select($this->table, "'1' = '1'");
-        $this->assertEqual(count_records($this->table), 0);
-    }
-
-    function test_update_record() {
-        global $CFG;
-
-        // Simple update
-        $obj = new stdClass;
-        $obj->id = 1;
-        $obj->textfield = 'changed entry';
-        $obj->numberfield = 123;
-        $this->assertTrue(update_record($this->table, $obj));
-        $this->assert(new CheckSpecifiedFieldsExpectation($obj, 'Simple update (%s)'), get_record($this->table, 'id', $obj->id));
-
-        // Simple incomplete update
-        $obj = new stdClass;
-        $obj->id = 2;
-        $obj->numberfield = 123;
-        $this->assertTrue(update_record($this->table, $obj));
-        $obj->textfield = 'toad';
-        $this->assert(new CheckSpecifiedFieldsExpectation($obj, 'Simple update (%s)'), get_record($this->table, 'id', $obj->id));
-
-        // Simple incomplete update
-        $obj = new stdClass;
-        $obj->id = 3;
-        $obj->numberfield = 123;
-        $obj->textfield = null;
-        $this->assertTrue(update_record($this->table, $obj));
-        $this->assert(new CheckSpecifiedFieldsExpectation($obj, 'Simple update (%s)'), get_record($this->table, 'id', $obj->id));
-
-    }
-
-//function insert_record($table, $dataobject, $returnid=true, $primarykey='id', $feedback=true) {
-    function test_insert_record() {
-        global $CFG;
-
-        // Simple insert with $returnid
-        $obj = new stdClass;
-        $obj->textfield = 'new entry';
-        $obj->numberfield = 123;
-        $this->assertEqual(insert_record($this->table, $obj), 6);
-        $obj->id = 6;
-        $this->assert(new CheckSpecifiedFieldsExpectation($obj, 'Simple insert with returnid (%s)'), get_record($this->table, 'id', $obj->id));
-
-        // Simple insert without $returnid
-        $obj = new stdClass;
-        $obj->textfield = 'newer entry';
-        $obj->numberfield = 321;
-        $this->assertEqual(insert_record($this->table, $obj, false), true);
-        $obj->id = 7;
-        $this->assert(new CheckSpecifiedFieldsExpectation($obj, 'Simple insert without returnid (%s)'), get_record($this->table, 'id', $obj->id));
-
-        // Insert with missing columns - should get defaults.
-        $obj = new stdClass;
-        $obj->textfield = 'partial entry';
-        $this->assertEqual(insert_record($this->table, $obj), 8);
-        $obj->id = 8;
-        $obj->numberfield = 0xDefa;
-        $got = get_record($this->table, 'id', 8);
-        $this->assert(new CheckSpecifiedFieldsExpectation($obj, 'Insert with missing columns - should get defaults (%s)'), get_record($this->table, 'id', $obj->id));
-
-        // Insert with extra columns - should be ingnored.
-        $obj = new stdClass;
-        $obj->textfield = 'entry with extra';
-        $obj->numberfield = 747;
-        $obj->unused = 666;
-        $this->assertEqual(insert_record($this->table, $obj), 9);
-        $obj->id = 9;
-        unset($obj->unused);
-        $this->assert(new CheckSpecifiedFieldsExpectation($obj, 'Insert with extra columns - should be ingnored (%s)'), get_record($this->table, 'id', $obj->id));
-
-        // Simple insert with $returnid and NULL values
-        $obj = new stdClass;
-        $obj->textfield = null;
-        $obj->numberfield = null;
-        $this->assertEqual(insert_record($this->table, $obj), 10);
-        $obj->id = 10;
-        $new = get_record($this->table, 'id', $obj->id);
-        $this->assert(new CheckSpecifiedFieldsExpectation($obj, 'Simple insert with returnid (%s)'), $new);
-        $this->assertNull($new->textfield);
-        $this->assertNull($new->numberfield);
-
-        // Insert into nonexistant table - should fail.
-        $obj = new stdClass;
-        $obj->textfield = 'new entry';
-        $obj->numberfield = 123;
-        $this->assertFalse(insert_record('nonexistant_table', $obj), 'Insert into nonexistant table');
-
-        // Insert bad data - error should be printed - mysql not tested
-        if ($CFG->dbfamily != 'mysql') {
-            $obj = new stdClass;
-            $obj->textfield = 'new entry';
-            $obj->numberfield = 'not a number';
-            ob_start();
-            $this->assertFalse(insert_record($this->table, $obj), 'Insert bad data - should fail.');
-            $result = ob_get_contents();
-            ob_end_clean();
-            $this->assert(new TextExpectation('ERROR:'), $result, 'Insert bad data - error should have been printed. This is known not to work on MySQL.');
-        }
-    }
-}
-
-?>
diff --git a/lib/timezones.txt b/lib/timezones.txt
deleted file mode 100644 (file)
index 4afca0e..0000000
+++ /dev/null
@@ -1,1940 +0,0 @@
-id,name,year,tzrule,gmtoff,dstoff,dst_month,dst_startday,dst_weekday,dst_skipweeks,dst_time,std_month,std_startday,std_weekday,std_skipweeks,std_time
-1,Africa/Algiers,1970,Algeria,0,60,4,1,1,0,02:00,9,16,-1,0,00:00
-2,Africa/Algiers,1971,Algeria,0,60,4,25,-1,0,23:00,9,26,-1,0,23:00
-3,Africa/Algiers,1977,Algeria,60,60,5,6,-1,0,01:00,10,21,-1,0,00:00
-4,Africa/Algiers,1978,Algeria,60,60,3,24,-1,0,02:00,9,22,-1,0,03:00
-5,Africa/Algiers,1979,Algeria,0,60,3,24,-1,0,01:00,9,22,-1,0,02:00
-6,Africa/Algiers,1980,Algeria,0,60,4,25,-1,0,00:00,10,31,-1,0,01:00
-7,Africa/Algiers,1981,,60,0,0,0,0,0,,0,0,0,0,
-8,Africa/Luanda,1970,,60,0,0,0,0,0,,0,0,0,0,
-9,Africa/Porto-Novo,1970,,60,0,0,0,0,0,,0,0,0,0,
-10,Africa/Gaborone,1970,,120,0,0,0,0,0,,0,0,0,0,
-11,Africa/Ouagadougou,1970,,0,0,0,0,0,0,,0,0,0,0,
-12,Africa/Bujumbura,1970,,120,0,0,0,0,0,,0,0,0,0,
-13,Africa/Douala,1970,,60,0,0,0,0,0,,0,0,0,0,
-14,Atlantic/Cape_Verde,1970,,-120,0,0,0,0,0,,0,0,0,0,
-15,Atlantic/Cape_Verde,1975,,-60,0,0,0,0,0,,0,0,0,0,
-16,Africa/Bangui,1970,,60,0,0,0,0,0,,0,0,0,0,
-17,Africa/Ndjamena,1970,,60,0,0,0,0,0,,0,0,0,0,
-18,Africa/Ndjamena,1979,,60,0,0,0,0,0,,0,0,0,0,
-19,Indian/Comoro,1970,,180,0,0,0,0,0,,0,0,0,0,
-20,Africa/Kinshasa,1970,,60,0,0,0,0,0,,0,0,0,0,
-21,Africa/Lubumbashi,1970,,120,0,0,0,0,0,,0,0,0,0,
-22,Africa/Brazzaville,1970,,60,0,0,0,0,0,,0,0,0,0,
-23,Africa/Abidjan,1970,,0,0,0,0,0,0,,0,0,0,0,
-24,Africa/Djibouti,1970,,180,0,0,0,0,0,,0,0,0,0,
-25,Africa/Cairo,1970,Egypt,120,60,5,1,-1,0,03:00,10,1,-1,0,04:00
-26,Africa/Cairo,1982,Egypt,120,60,7,25,-1,0,03:00,10,1,-1,0,04:00
-27,Africa/Cairo,1983,Egypt,120,60,7,12,-1,0,03:00,10,1,-1,0,04:00
-28,Africa/Cairo,1984,Egypt,120,60,5,1,-1,0,03:00,10,1,-1,0,04:00
-29,Africa/Cairo,1989,Egypt,120,60,5,6,-1,0,03:00,10,1,-1,0,04:00
-30,Africa/Cairo,1990,Egypt,120,60,5,1,-1,0,03:00,10,1,-1,0,04:00
-31,Africa/Cairo,1995,Egypt,120,60,4,-1,5,0,02:00,9,-1,4,0,25:00
-32,Africa/Cairo,2006,Egypt,120,60,4,-1,5,0,02:00,9,21,-1,0,25:00
-33,Africa/Cairo,2007,Egypt,120,60,4,-1,5,0,02:00,9,-1,4,0,25:00
-34,Africa/Malabo,1970,,60,0,0,0,0,0,,0,0,0,0,
-35,Africa/Asmara,1970,,180,0,0,0,0,0,,0,0,0,0,
-36,Africa/Addis_Ababa,1970,,180,0,0,0,0,0,,0,0,0,0,
-37,Africa/Libreville,1970,,60,0,0,0,0,0,,0,0,0,0,
-38,Africa/Banjul,1970,,0,0,0,0,0,0,,0,0,0,0,
-39,Africa/Accra,1970,Ghana,0,0,9,1,-1,0,00:00,12,31,-1,0,-1:00
-40,Africa/Conakry,1970,,0,0,0,0,0,0,,0,0,0,0,
-41,Africa/Bissau,1970,,-60,0,0,0,0,0,,0,0,0,0,
-42,Africa/Bissau,1975,,0,0,0,0,0,0,,0,0,0,0,
-43,Africa/Nairobi,1970,,180,0,0,0,0,0,,0,0,0,0,
-44,Africa/Maseru,1970,,120,0,0,0,0,0,,0,0,0,0,
-45,Africa/Monrovia,1970,,-44,0,0,0,0,0,,0,0,0,0,
-46,Africa/Monrovia,1972,,0,0,0,0,0,0,,0,0,0,0,
-47,Africa/Tripoli,1970,,120,0,0,0,0,0,,0,0,0,0,
-48,Africa/Tripoli,1982,Libya,60,60,4,1,-1,0,01:00,10,1,-1,0,00:00
-49,Africa/Tripoli,1985,Libya,60,60,4,6,-1,0,01:00,10,1,-1,0,00:00
-50,Africa/Tripoli,1986,Libya,60,60,4,4,-1,0,01:00,10,3,-1,0,00:00
-51,Africa/Tripoli,1987,Libya,60,60,4,1,-1,0,01:00,10,1,-1,0,00:00
-52,Africa/Tripoli,1989,Libya,60,0,4,1,-1,0,01:00,10,1,-1,0,00:00
-53,Africa/Tripoli,1990,,120,0,0,0,0,0,,0,0,0,0,
-54,Africa/Tripoli,1996,,60,0,0,0,0,0,,0,0,0,0,
-55,Africa/Tripoli,1997,,120,0,0,0,0,0,,0,0,0,0,
-56,Indian/Antananarivo,1970,,180,0,0,0,0,0,,0,0,0,0,
-57,Africa/Blantyre,1970,,120,0,0,0,0,0,,0,0,0,0,
-58,Africa/Bamako,1970,,0,0,0,0,0,0,,0,0,0,0,
-59,Africa/Nouakchott,1970,,0,0,0,0,0,0,,0,0,0,0,
-60,Indian/Mauritius,1970,,240,0,0,0,0,0,,0,0,0,0,
-61,Indian/Mayotte,1970,,180,0,0,0,0,0,,0,0,0,0,
-62,Africa/Casablanca,1970,Morocco,0,60,6,3,-1,0,12:00,10,1,-1,0,-1:00
-63,Africa/Casablanca,1974,Morocco,0,60,6,24,-1,0,00:00,9,1,-1,0,-1:00
-64,Africa/Casablanca,1976,Morocco,0,60,5,1,-1,0,00:00,8,1,-1,0,-1:00
-65,Africa/Casablanca,1977,Morocco,0,60,5,1,-1,0,00:00,9,28,-1,0,-1:00
-66,Africa/Casablanca,1978,Morocco,0,60,6,1,-1,0,00:00,8,4,-1,0,-1:00
-67,Africa/Casablanca,1979,Morocco,0,0,6,1,-1,0,00:00,8,4,-1,0,-1:00
-68,Africa/Casablanca,1984,,60,0,0,0,0,0,,0,0,0,0,
-69,Africa/Casablanca,1986,,0,0,0,0,0,0,,0,0,0,0,
-70,Africa/El_Aaiun,1970,,-60,0,0,0,0,0,,0,0,0,0,
-71,Africa/El_Aaiun,1976,,0,0,0,0,0,0,,0,0,0,0,
-72,Africa/Maputo,1970,,120,0,0,0,0,0,,0,0,0,0,
-73,Africa/Windhoek,1970,,120,0,0,0,0,0,,0,0,0,0,
-74,Africa/Windhoek,1990,,120,0,0,0,0,0,,0,0,0,0,
-75,Africa/Windhoek,1994,Namibia,60,60,9,1,0,0,03:00,1,1,-1,0,12:00
-76,Africa/Windhoek,1995,Namibia,60,60,9,1,0,0,03:00,4,1,0,0,02:00
-77,Africa/Niamey,1970,,60,0,0,0,0,0,,0,0,0,0,
-78,Africa/Lagos,1970,,60,0,0,0,0,0,,0,0,0,0,
-79,Indian/Reunion,1970,,240,0,0,0,0,0,,0,0,0,0,
-80,Africa/Kigali,1970,,120,0,0,0,0,0,,0,0,0,0,
-81,Atlantic/St_Helena,1970,,0,0,0,0,0,0,,0,0,0,0,
-82,Africa/Sao_Tome,1970,,0,0,0,0,0,0,,0,0,0,0,
-83,Africa/Dakar,1970,,0,0,0,0,0,0,,0,0,0,0,
-84,Indian/Mahe,1970,,240,0,0,0,0,0,,0,0,0,0,
-85,Africa/Freetown,1970,SL,0,0,6,1,-1,0,00:00,9,1,-1,0,-1:00
-86,Africa/Mogadishu,1970,,180,0,0,0,0,0,,0,0,0,0,
-87,Africa/Johannesburg,1970,SA,120,0,12,31,-1,0,14:00,3,15,0,0,03:00
-88,Africa/Khartoum,1970,Sudan,120,60,5,1,-1,0,02:00,10,15,-1,0,01:00
-89,Africa/Khartoum,1971,Sudan,120,60,4,30,-1,0,02:00,10,15,-1,0,01:00
-90,Africa/Khartoum,1972,Sudan,120,60,4,-1,0,0,02:00,10,15,-1,0,01:00
-91,Africa/Khartoum,1985,Sudan,120,0,4,-1,0,0,02:00,10,15,-1,0,01:00
-92,Africa/Khartoum,2000,,180,0,0,0,0,0,,0,0,0,0,
-93,Africa/Mbabane,1970,,120,0,0,0,0,0,,0,0,0,0,
-94,Africa/Dar_es_Salaam,1970,,180,0,0,0,0,0,,0,0,0,0,
-95,Africa/Lome,1970,,0,0,0,0,0,0,,0,0,0,0,
-96,Africa/Tunis,1970,Tunisia,60,60,4,1,1,0,03:00,9,16,-1,0,00:00
-97,Africa/Tunis,1977,Tunisia,60,60,4,30,-1,0,01:00,9,24,-1,0,01:00
-98,Africa/Tunis,1978,Tunisia,60,60,5,1,-1,0,01:00,10,1,-1,0,01:00
-99,Africa/Tunis,1988,Tunisia,60,60,6,1,-1,0,01:00,9,-1,0,0,01:00
-100,Africa/Tunis,1989,Tunisia,60,60,3,26,-1,0,01:00,9,-1,0,0,01:00
-101,Africa/Tunis,1990,Tunisia,60,60,5,1,-1,0,01:00,9,-1,0,0,01:00
-102,Africa/Tunis,2005,Tunisia,60,60,5,1,-1,0,01:00,9,30,-1,0,02:00
-103,Africa/Tunis,2006,Tunisia,60,60,3,-1,0,0,03:00,10,-1,0,0,03:00
-104,Africa/Kampala,1970,,180,0,0,0,0,0,,0,0,0,0,
-105,Africa/Lusaka,1970,,120,0,0,0,0,0,,0,0,0,0,
-106,Africa/Harare,1970,,120,0,0,0,0,0,,0,0,0,0,
-107,Antarctica/Casey,1970,,480,0,0,0,0,0,,0,0,0,0,
-108,Antarctica/Davis,1970,,420,0,0,0,0,0,,0,0,0,0,
-109,Antarctica/Mawson,1970,,360,0,0,0,0,0,,0,0,0,0,
-110,Indian/Kerguelen,1970,,300,0,0,0,0,0,,0,0,0,0,
-111,Antarctica/DumontDUrville,1970,,600,0,0,0,0,0,,0,0,0,0,
-112,Antarctica/Syowa,1970,,180,0,0,0,0,0,,0,0,0,0,
-113,Antarctica/Vostok,1970,,360,0,0,0,0,0,,0,0,0,0,
-114,Antarctica/Rothera,1970,,0,0,0,0,0,0,,0,0,0,0,
-115,Antarctica/Rothera,1976,,-180,0,0,0,0,0,,0,0,0,0,
-116,Antarctica/Palmer,1970,ArgAQ,-180,0,12,31,-1,0,09:00,4,1,0,0,-4:00
-117,Antarctica/Palmer,1974,ArgAQ,-180,60,1,23,-1,0,-3:00,5,1,-1,0,-4:00
-118,Antarctica/Palmer,1975,ArgAQ,-180,0,1,23,-1,0,-3:00,5,1,-1,0,-4:00
-119,Antarctica/Palmer,1982,ChileAQ,-240,60,10,9,0,0,4:00,3,9,0,0,3:00
-120,Antarctica/Palmer,1987,ChileAQ,-240,60,10,9,0,0,4:00,4,12,-1,0,3:00
-121,Antarctica/Palmer,1988,ChileAQ,-240,60,10,1,0,0,4:00,3,9,0,0,3:00
-122,Antarctica/Palmer,1989,ChileAQ,-240,60,10,9,0,0,4:00,3,9,0,0,3:00
-123,Antarctica/Palmer,1990,ChileAQ,-240,60,9,16,-1,0,4:00,3,18,-1,0,3:00
-124,Antarctica/Palmer,1991,ChileAQ,-240,60,10,9,0,0,4:00,3,9,0,0,3:00
-125,Antarctica/Palmer,1997,ChileAQ,-240,60,10,9,0,0,4:00,3,30,-1,0,3:00
-126,Antarctica/Palmer,1998,ChileAQ,-240,60,9,27,-1,0,4:00,3,9,0,0,3:00
-127,Antarctica/Palmer,1999,ChileAQ,-240,60,10,9,0,0,4:00,4,4,-1,0,3:00
-128,Antarctica/Palmer,2000,ChileAQ,-240,60,10,9,0,0,4:00,3,9,0,0,3:00
-129,Antarctica/McMurdo,1970,NZAQ,720,0,0,0,0,0,,0,0,0,0,
-130,Antarctica/McMurdo,1974,NZAQ,720,60,11,3,-1,0,14:00,1,1,-1,0,23:00
-131,Antarctica/McMurdo,1975,NZAQ,720,60,10,-1,0,0,14:00,2,23,-1,0,14:00
-132,Antarctica/McMurdo,1976,NZAQ,720,60,10,-1,0,0,14:00,3,1,0,0,14:00
-133,Antarctica/McMurdo,1989,NZAQ,720,60,10,8,-1,0,14:00,3,1,0,0,14:00
-134,Antarctica/McMurdo,1990,NZAQ,720,60,10,1,0,0,14:00,3,15,0,0,14:00
-135,Asia/Kabul,1970,,270,0,0,0,0,0,,0,0,0,0,
-136,Asia/Yerevan,1970,RussiaAsia,240,0,0,0,0,0,,0,0,0,0,
-137,Asia/Yerevan,1981,RussiaAsia,240,60,4,1,-1,0,04:00,10,1,-1,0,03:00
-138,Asia/Yerevan,1984,RussiaAsia,240,60,4,1,-1,0,04:00,9,-1,0,0,06:00
-139,Asia/Yerevan,1985,RussiaAsia,240,60,3,-1,0,0,06:00,9,-1,0,0,06:00
-140,Asia/Yerevan,1991,RussiaAsia,180,60,3,-1,0,0,05:00,9,-1,0,0,05:00
-141,Asia/Yerevan,1992,RussiaAsia,180,60,3,-1,6,0,26:00,9,-1,6,0,25:00
-142,Asia/Yerevan,1993,RussiaAsia,180,60,3,-1,0,0,05:00,9,-1,0,0,05:00
-143,Asia/Yerevan,1995,,240,0,0,0,0,0,,0,0,0,0,
-144,Asia/Yerevan,1997,RussiaAsia,240,60,3,-1,0,0,06:00,10,-1,0,0,06:00
-145,Asia/Baku,1970,RussiaAsia,240,0,0,0,0,0,,0,0,0,0,
-146,Asia/Baku,1981,RussiaAsia,240,60,4,1,-1,0,04:00,10,1,-1,0,03:00
-147,Asia/Baku,1984,RussiaAsia,240,60,4,1,-1,0,04:00,9,-1,0,0,06:00
-148,Asia/Baku,1985,RussiaAsia,240,60,3,-1,0,0,06:00,9,-1,0,0,06:00
-149,Asia/Baku,1991,RussiaAsia,180,60,3,-1,0,0,05:00,9,-1,0,0,05:00
-150,Asia/Baku,1992,,240,0,0,0,0,0,,0,0,0,0,
-151,Asia/Baku,1996,EUAsia,240,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-152,Asia/Baku,1997,Azer,240,60,3,-1,0,0,08:00,10,-1,0,0,08:00
-153,Asia/Bahrain,1970,,240,0,0,0,0,0,,0,0,0,0,
-154,Asia/Bahrain,1972,,180,0,0,0,0,0,,0,0,0,0,
-155,Asia/Dhaka,1970,,360,0,0,0,0,0,,0,0,0,0,
-156,Asia/Dhaka,1971,,360,0,0,0,0,0,,0,0,0,0,
-157,Asia/Thimphu,1970,,330,0,0,0,0,0,,0,0,0,0,
-158,Asia/Thimphu,1987,,360,0,0,0,0,0,,0,0,0,0,
-159,Indian/Chagos,1970,,300,0,0,0,0,0,,0,0,0,0,
-160,Indian/Chagos,1996,,360,0,0,0,0,0,,0,0,0,0,
-161,Asia/Brunei,1970,,480,0,0,0,0,0,,0,0,0,0,
-162,Asia/Rangoon,1970,,390,0,0,0,0,0,,0,0,0,0,
-163,Asia/Phnom_Penh,1970,,420,0,0,0,0,0,,0,0,0,0,
-164,Asia/Harbin,1970,,510,0,0,0,0,0,,0,0,0,0,
-165,Asia/Harbin,1980,PRC,480,0,0,0,0,0,,0,0,0,0,
-166,Asia/Harbin,1986,PRC,480,60,5,4,-1,0,08:00,9,11,0,0,07:00
-167,Asia/Harbin,1987,PRC,480,60,4,10,0,0,08:00,9,11,0,0,07:00
-168,Asia/Harbin,1991,PRC,480,0,4,10,0,0,08:00,9,11,0,0,07:00
-169,Asia/Shanghai,1970,PRC,480,0,0,0,0,0,,0,0,0,0,
-170,Asia/Shanghai,1986,PRC,480,60,5,4,-1,0,08:00,9,11,0,0,07:00
-171,Asia/Shanghai,1987,PRC,480,60,4,10,0,0,08:00,9,11,0,0,07:00
-172,Asia/Shanghai,1991,PRC,480,0,4,10,0,0,08:00,9,11,0,0,07:00
-173,Asia/Chongqing,1970,,420,0,0,0,0,0,,0,0,0,0,
-174,Asia/Chongqing,1980,PRC,480,0,0,0,0,0,,0,0,0,0,
-175,Asia/Chongqing,1986,PRC,480,60,5,4,-1,0,08:00,9,11,0,0,07:00
-176,Asia/Chongqing,1987,PRC,480,60,4,10,0,0,08:00,9,11,0,0,07:00
-177,Asia/Chongqing,1991,PRC,480,0,4,10,0,0,08:00,9,11,0,0,07:00
-178,Asia/Urumqi,1970,,360,0,0,0,0,0,,0,0,0,0,
-179,Asia/Urumqi,1980,PRC,480,0,0,0,0,0,,0,0,0,0,
-180,Asia/Urumqi,1986,PRC,480,60,5,4,-1,0,08:00,9,11,0,0,07:00
-181,Asia/Urumqi,1987,PRC,480,60,4,10,0,0,08:00,9,11,0,0,07:00
-182,Asia/Urumqi,1991,PRC,480,0,4,10,0,0,08:00,9,11,0,0,07:00
-183,Asia/Kashgar,1970,,300,0,0,0,0,0,,0,0,0,0,
-184,Asia/Kashgar,1980,PRC,480,0,0,0,0,0,,0,0,0,0,
-185,Asia/Kashgar,1986,PRC,480,60,5,4,-1,0,08:00,9,11,0,0,07:00
-186,Asia/Kashgar,1987,PRC,480,60,4,10,0,0,08:00,9,11,0,0,07:00
-187,Asia/Kashgar,1991,PRC,480,0,4,10,0,0,08:00,9,11,0,0,07:00
-188,Asia/Hong_Kong,1970,HK,480,60,4,16,0,0,11:30,10,16,0,0,10:30
-189,Asia/Hong_Kong,1979,HK,480,60,5,8,0,0,11:30,10,16,0,0,10:30
-190,Asia/Hong_Kong,1980,HK,480,0,5,8,0,0,11:30,10,16,0,0,10:30
-191,Asia/Taipei,1970,Taiwan,480,60,6,1,-1,0,08:00,10,1,-1,0,07:00
-192,Asia/Taipei,1974,Taiwan,480,60,4,1,-1,0,08:00,10,1,-1,0,07:00
-193,Asia/Taipei,1980,Taiwan,480,60,6,30,-1,0,08:00,9,30,-1,0,07:00
-194,Asia/Taipei,1981,Taiwan,480,0,6,30,-1,0,08:00,9,30,-1,0,07:00
-195,Asia/Macau,1970,Macau,480,60,4,16,0,0,11:30,10,16,0,0,10:30
-196,Asia/Macau,1972,Macau,480,60,4,15,0,0,08:00,10,15,0,0,07:00
-197,Asia/Macau,1974,Macau,480,60,4,15,0,0,08:00,10,15,0,0,10:30
-198,Asia/Macau,1975,Macau,480,60,4,15,0,0,11:30,10,15,0,0,10:30
-199,Asia/Macau,1978,Macau,480,60,4,15,0,0,08:00,10,15,0,0,07:00
-200,Asia/Macau,1980,Macau,480,0,4,15,0,0,08:00,10,15,0,0,07:00
-201,Asia/Macau,1999,PRC,480,0,4,15,0,0,08:00,10,15,0,0,07:00
-202,Asia/Nicosia,1970,Cyprus,120,0,0,0,0,0,,0,0,0,0,
-203,Asia/Nicosia,1975,Cyprus,120,60,4,13,-1,0,02:00,10,12,-1,0,01:00
-204,Asia/Nicosia,1976,Cyprus,120,60,5,15,-1,0,02:00,10,11,-1,0,01:00
-205,Asia/Nicosia,1977,Cyprus,120,60,4,1,0,0,02:00,9,25,-1,0,01:00
-206,Asia/Nicosia,1978,Cyprus,120,60,4,1,0,0,02:00,10,2,-1,0,01:00
-207,Asia/Nicosia,1979,Cyprus,120,60,4,1,0,0,02:00,9,-1,0,0,01:00
-208,Asia/Nicosia,1981,Cyprus,120,60,3,-1,0,0,02:00,9,-1,0,0,01:00
-209,Asia/Nicosia,1998,EUAsia,120,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-210,Asia/Tbilisi,1970,RussiaAsia,240,0,0,0,0,0,,0,0,0,0,
-211,Asia/Tbilisi,1981,RussiaAsia,240,60,4,1,-1,0,04:00,10,1,-1,0,03:00
-212,Asia/Tbilisi,1984,RussiaAsia,240,60,4,1,-1,0,04:00,9,-1,0,0,06:00
-213,Asia/Tbilisi,1985,RussiaAsia,240,60,3,-1,0,0,06:00,9,-1,0,0,06:00
-214,Asia/Tbilisi,1991,RussiaAsia,180,60,3,-1,0,0,05:00,9,-1,0,0,05:00
-215,Asia/Tbilisi,1992,E-EurAsia,180,60,3,-1,0,0,03:00,9,-1,0,0,02:00
-216,Asia/Tbilisi,1994,E-EurAsia,240,60,3,-1,0,0,04:00,9,-1,0,0,03:00
-217,Asia/Tbilisi,1995,E-EurAsia,240,0,12,31,-1,0,16:00,9,-1,0,0,03:00
-218,Asia/Tbilisi,1996,,240,0,0,0,0,0,,0,0,0,0,
-219,Asia/Tbilisi,1997,E-EurAsia,240,60,3,-1,0,0,04:00,10,-1,0,0,03:00
-220,Asia/Tbilisi,2004,RussiaAsia,180,60,3,-1,0,0,05:00,10,-1,0,0,05:00
-221,Asia/Tbilisi,2005,,240,0,0,0,0,0,,0,0,0,0,
-222,Asia/Dili,1970,,540,0,0,0,0,0,,0,0,0,0,
-223,Asia/Dili,1976,,480,0,0,0,0,0,,0,0,0,0,
-224,Asia/Dili,2000,,540,0,0,0,0,0,,0,0,0,0,
-225,Asia/Calcutta,1970,,330,0,0,0,0,0,,0,0,0,0,
-226,Asia/Jakarta,1970,,420,0,0,0,0,0,,0,0,0,0,
-227,Asia/Pontianak,1970,,480,0,0,0,0,0,,0,0,0,0,
-228,Asia/Pontianak,1988,,420,0,0,0,0,0,,0,0,0,0,
-229,Asia/Makassar,1970,,480,0,0,0,0,0,,0,0,0,0,
-230,Asia/Jayapura,1970,,540,0,0,0,0,0,,0,0,0,0,
-231,Asia/Tehran,1970,,210,0,0,0,0,0,,0,0,0,0,
-232,Asia/Tehran,1977,Iran,240,0,0,0,0,0,,0,0,0,0,
-233,Asia/Tehran,1978,Iran,240,60,3,21,-1,0,04:00,10,21,-1,0,03:00
-234,Asia/Tehran,1979,Iran,210,60,3,21,-1,0,03:30,9,19,-1,0,02:30
-235,Asia/Tehran,1980,Iran,210,60,3,21,-1,0,03:30,9,23,-1,0,02:30
-236,Asia/Tehran,1991,Iran,210,60,5,3,-1,0,03:30,9,22,-1,0,02:30
-237,Asia/Tehran,1992,Iran,210,60,3,22,-1,0,03:30,9,22,-1,0,02:30
-238,Asia/Tehran,1996,Iran,210,60,3,21,-1,0,03:30,9,21,-1,0,02:30
-239,Asia/Tehran,1997,Iran,210,60,3,22,-1,0,03:30,9,22,-1,0,02:30
-240,Asia/Tehran,2000,Iran,210,60,3,21,-1,0,03:30,9,21,-1,0,02:30
-241,Asia/Tehran,2001,Iran,210,60,3,22,-1,0,03:30,9,22,-1,0,02:30
-242,Asia/Tehran,2004,Iran,210,60,3,21,-1,0,03:30,9,21,-1,0,02:30
-243,Asia/Tehran,2005,Iran,210,60,3,22,-1,0,03:30,9,22,-1,0,02:30
-244,Asia/Tehran,2006,Iran,210,0,3,22,-1,0,03:30,9,22,-1,0,02:30
-245,Asia/Baghdad,1970,,180,0,0,0,0,0,,0,0,0,0,
-246,Asia/Baghdad,1982,Iraq,180,60,5,1,-1,0,03:00,10,1,-1,0,02:00
-247,Asia/Baghdad,1983,Iraq,180,60,3,31,-1,0,03:00,10,1,-1,0,02:00
-248,Asia/Baghdad,1984,Iraq,180,60,4,1,-1,0,03:00,10,1,-1,0,02:00
-249,Asia/Baghdad,1985,Iraq,180,60,4,1,-1,0,03:00,9,-1,0,0,04:00
-250,Asia/Baghdad,1986,Iraq,180,60,3,-1,0,0,04:00,9,-1,0,0,04:00
-251,Asia/Baghdad,1991,Iraq,180,60,4,1,-1,0,06:00,10,1,-1,0,06:00
-252,Asia/Jerusalem,1970,Zion,120,60,4,29,-1,0,04:00,9,22,-1,0,01:00
-253,Asia/Jerusalem,1974,Zion,120,60,7,7,-1,0,02:00,10,13,-1,0,01:00
-254,Asia/Jerusalem,1975,Zion,120,60,4,20,-1,0,02:00,8,31,-1,0,01:00
-255,Asia/Jerusalem,1985,Zion,120,60,4,14,-1,0,02:00,9,15,-1,0,01:00
-256,Asia/Jerusalem,1986,Zion,120,60,5,18,-1,0,02:00,9,7,-1,0,01:00
-257,Asia/Jerusalem,1987,Zion,120,60,4,15,-1,0,02:00,9,13,-1,0,01:00
-258,Asia/Jerusalem,1988,Zion,120,60,4,9,-1,0,02:00,9,3,-1,0,01:00
-259,Asia/Jerusalem,1989,Zion,120,60,4,30,-1,0,02:00,9,3,-1,0,01:00
-260,Asia/Jerusalem,1990,Zion,120,60,3,25,-1,0,02:00,8,26,-1,0,01:00
-261,Asia/Jerusalem,1991,Zion,120,60,3,24,-1,0,02:00,9,1,-1,0,01:00
-262,Asia/Jerusalem,1992,Zion,120,60,3,29,-1,0,02:00,9,6,-1,0,01:00
-263,Asia/Jerusalem,1993,Zion,120,60,4,2,-1,0,02:00,9,5,-1,0,01:00
-264,Asia/Jerusalem,1994,Zion,120,60,4,1,-1,0,02:00,8,28,-1,0,01:00
-265,Asia/Jerusalem,1995,Zion,120,60,3,31,-1,0,02:00,9,3,-1,0,01:00
-266,Asia/Jerusalem,1996,Zion,120,60,3,15,-1,0,02:00,9,16,-1,0,01:00
-267,Asia/Jerusalem,1997,Zion,120,60,3,21,-1,0,02:00,9,14,-1,0,01:00
-268,Asia/Jerusalem,1998,Zion,120,60,3,20,-1,0,02:00,9,6,-1,0,01:00
-269,Asia/Jerusalem,1999,Zion,120,60,4,2,-1,0,04:00,9,3,-1,0,03:00
-270,Asia/Jerusalem,2000,Zion,120,60,4,14,-1,0,04:00,10,6,-1,0,02:00
-271,Asia/Jerusalem,2001,Zion,120,60,4,9,-1,0,03:00,9,24,-1,0,02:00
-272,Asia/Jerusalem,2002,Zion,120,60,3,29,-1,0,03:00,10,7,-1,0,02:00
-273,Asia/Jerusalem,2003,Zion,120,60,3,28,-1,0,03:00,10,3,-1,0,02:00
-274,Asia/Jerusalem,2004,Zion,120,60,4,7,-1,0,03:00,9,22,-1,0,02:00
-275,Asia/Jerusalem,2005,Zion,120,60,4,1,-1,0,04:00,10,9,-1,0,03:00
-276,Asia/Jerusalem,2006,Zion,120,60,3,26,5,0,04:00,10,1,-1,0,03:00
-277,Asia/Jerusalem,2007,Zion,120,60,3,26,5,0,04:00,9,16,-1,0,03:00
-278,Asia/Jerusalem,2008,Zion,120,60,3,26,5,0,04:00,10,5,-1,0,03:00
-279,Asia/Jerusalem,2009,Zion,120,60,3,26,5,0,04:00,9,27,-1,0,03:00
-280,Asia/Jerusalem,2010,Zion,120,60,3,26,5,0,04:00,9,12,-1,0,03:00
-281,Asia/Jerusalem,2011,Zion,120,60,4,1,-1,0,04:00,10,2,-1,0,03:00
-282,Asia/Jerusalem,2012,Zion,120,60,3,26,5,0,04:00,9,23,-1,0,03:00
-283,Asia/Jerusalem,2013,Zion,120,60,3,26,5,0,04:00,9,8,-1,0,03:00
-284,Asia/Jerusalem,2014,Zion,120,60,3,26,5,0,04:00,9,28,-1,0,03:00
-285,Asia/Jerusalem,2015,Zion,120,60,3,26,5,0,04:00,9,20,-1,0,03:00
-286,Asia/Jerusalem,2016,Zion,120,60,4,1,-1,0,04:00,10,9,-1,0,03:00
-287,Asia/Tokyo,1970,Japan,540,0,5,1,0,0,11:00,9,8,6,0,10:00
-288,Asia/Amman,1970,Jordan,120,0,0,0,0,0,,0,0,0,0,
-289,Asia/Amman,1973,Jordan,120,60,6,6,-1,0,02:00,10,1,-1,0,01:00
-290,Asia/Amman,1974,Jordan,120,60,5,1,-1,0,02:00,10,1,-1,0,01:00
-291,Asia/Amman,1976,Jordan,120,60,5,1,-1,0,02:00,11,1,-1,0,01:00
-292,Asia/Amman,1977,Jordan,120,60,5,1,-1,0,02:00,10,1,-1,0,01:00
-293,Asia/Amman,1978,Jordan,120,60,4,30,-1,0,02:00,9,30,-1,0,01:00
-294,Asia/Amman,1985,Jordan,120,60,4,1,-1,0,02:00,10,1,-1,0,01:00
-295,Asia/Amman,1986,Jordan,120,60,4,1,5,0,02:00,10,1,5,0,01:00
-296,Asia/Amman,1989,Jordan,120,60,5,8,-1,0,02:00,10,1,5,0,01:00
-297,Asia/Amman,1990,Jordan,120,60,4,27,-1,0,02:00,10,1,5,0,01:00
-298,Asia/Amman,1991,Jordan,120,60,4,17,-1,0,02:00,9,27,-1,0,01:00
-299,Asia/Amman,1992,Jordan,120,60,4,10,-1,0,02:00,10,1,5,0,01:00
-300,Asia/Amman,1993,Jordan,120,60,4,1,5,0,02:00,10,1,5,0,01:00
-301,Asia/Amman,1994,Jordan,120,60,4,1,5,0,02:00,9,15,5,0,01:00
-302,Asia/Amman,1995,Jordan,120,60,4,1,5,0,02:00,9,15,5,0,02:00
-303,Asia/Amman,1999,Jordan,120,60,7,1,-1,0,02:00,9,-1,4,0,02:00
-304,Asia/Amman,2000,Jordan,120,60,3,-1,4,0,02:00,9,-1,4,0,02:00
-305,Asia/Amman,2003,Jordan,120,60,3,-1,4,0,02:00,10,24,-1,0,02:00
-306,Asia/Amman,2004,Jordan,120,60,3,-1,4,0,02:00,10,15,-1,0,02:00
-307,Asia/Amman,2005,Jordan,120,60,3,-1,4,0,02:00,9,-1,5,0,02:00
-308,Asia/Amman,2006,Jordan,120,60,3,-1,4,0,02:00,10,-1,5,0,02:00
-309,Asia/Almaty,1970,RussiaAsia,360,0,0,0,0,0,,0,0,0,0,
-310,Asia/Almaty,1981,RussiaAsia,360,60,4,1,-1,0,06:00,10,1,-1,0,05:00
-311,Asia/Almaty,1984,RussiaAsia,360,60,4,1,-1,0,06:00,9,-1,0,0,08:00
-312,Asia/Almaty,1985,RussiaAsia,360,60,3,-1,0,0,08:00,9,-1,0,0,08:00
-313,Asia/Almaty,1991,,360,0,0,0,0,0,,0,0,0,0,
-314,Asia/Almaty,1992,RussiaAsia,360,60,3,-1,6,0,29:00,9,-1,6,0,28:00
-315,Asia/Almaty,1993,RussiaAsia,360,60,3,-1,0,0,08:00,9,-1,0,0,08:00
-316,Asia/Almaty,1996,RussiaAsia,360,60,3,-1,0,0,08:00,10,-1,0,0,08:00
-317,Asia/Almaty,2005,,360,0,0,0,0,0,,0,0,0,0,
-318,Asia/Qyzylorda,1970,,300,0,0,0,0,0,,0,0,0,0,
-319,Asia/Qyzylorda,1981,,360,0,0,0,0,0,,0,0,0,0,
-320,Asia/Qyzylorda,1982,RussiaAsia,300,60,4,1,-1,0,05:00,10,1,-1,0,04:00
-321,Asia/Qyzylorda,1984,RussiaAsia,300,60,4,1,-1,0,05:00,9,-1,0,0,07:00
-322,Asia/Qyzylorda,1985,RussiaAsia,300,60,3,-1,0,0,07:00,9,-1,0,0,07:00
-323,Asia/Qyzylorda,1991,,300,0,0,0,0,0,,0,0,0,0,
-324,Asia/Qyzylorda,1992,RussiaAsia,360,60,3,-1,6,0,29:00,9,-1,6,0,28:00
-325,Asia/Qyzylorda,1993,RussiaAsia,360,60,3,-1,0,0,08:00,9,-1,0,0,08:00
-326,Asia/Qyzylorda,1996,RussiaAsia,360,60,3,-1,0,0,08:00,10,-1,0,0,08:00
-327,Asia/Qyzylorda,2005,,360,0,0,0,0,0,,0,0,0,0,
-328,Asia/Aqtobe,1970,,300,0,0,0,0,0,,0,0,0,0,
-329,Asia/Aqtobe,1981,,360,0,0,0,0,0,,0,0,0,0,
-330,Asia/Aqtobe,1982,RussiaAsia,300,60,4,1,-1,0,05:00,10,1,-1,0,04:00
-331,Asia/Aqtobe,1984,RussiaAsia,300,60,4,1,-1,0,05:00,9,-1,0,0,07:00
-332,Asia/Aqtobe,1985,RussiaAsia,300,60,3,-1,0,0,07:00,9,-1,0,0,07:00
-333,Asia/Aqtobe,1992,RussiaAsia,300,60,3,-1,6,0,28:00,9,-1,6,0,27:00
-334,Asia/Aqtobe,1993,RussiaAsia,300,60,3,-1,0,0,07:00,9,-1,0,0,07:00
-335,Asia/Aqtobe,1996,RussiaAsia,300,60,3,-1,0,0,07:00,10,-1,0,0,07:00
-336,Asia/Aqtobe,2005,,300,0,0,0,0,0,,0,0,0,0,
-337,Asia/Aqtau,1970,,300,0,0,0,0,0,,0,0,0,0,
-338,Asia/Aqtau,1981,,360,0,0,0,0,0,,0,0,0,0,
-339,Asia/Aqtau,1982,RussiaAsia,300,60,4,1,-1,0,05:00,10,1,-1,0,04:00
-340,Asia/Aqtau,1984,RussiaAsia,300,60,4,1,-1,0,05:00,9,-1,0,0,07:00
-341,Asia/Aqtau,1985,RussiaAsia,300,60,3,-1,0,0,07:00,9,-1,0,0,07:00
-342,Asia/Aqtau,1992,RussiaAsia,300,60,3,-1,6,0,28:00,9,-1,6,0,27:00
-343,Asia/Aqtau,1993,RussiaAsia,300,60,3,-1,0,0,07:00,9,-1,0,0,07:00
-344,Asia/Aqtau,1995,RussiaAsia,240,60,3,-1,0,0,06:00,9,-1,0,0,06:00
-345,Asia/Aqtau,1996,RussiaAsia,240,60,3,-1,0,0,06:00,10,-1,0,0,06:00
-346,Asia/Aqtau,2005,,300,0,0,0,0,0,,0,0,0,0,
-347,Asia/Oral,1970,,300,0,0,0,0,0,,0,0,0,0,
-348,Asia/Oral,1981,,360,0,0,0,0,0,,0,0,0,0,
-349,Asia/Oral,1982,RussiaAsia,300,60,4,1,-1,0,05:00,10,1,-1,0,04:00
-350,Asia/Oral,1984,RussiaAsia,300,60,4,1,-1,0,05:00,9,-1,0,0,07:00
-351,Asia/Oral,1985,RussiaAsia,300,60,3,-1,0,0,07:00,9,-1,0,0,07:00
-352,Asia/Oral,1989,RussiaAsia,240,60,3,-1,0,0,06:00,9,-1,0,0,06:00
-353,Asia/Oral,1992,RussiaAsia,240,60,3,-1,6,0,27:00,9,-1,6,0,26:00
-354,Asia/Oral,1993,RussiaAsia,240,60,3,-1,0,0,06:00,9,-1,0,0,06:00
-355,Asia/Oral,1996,RussiaAsia,240,60,3,-1,0,0,06:00,10,-1,0,0,06:00
-356,Asia/Oral,2005,,300,0,0,0,0,0,,0,0,0,0,
-357,Asia/Bishkek,1970,RussiaAsia,360,0,0,0,0,0,,0,0,0,0,
-358,Asia/Bishkek,1981,RussiaAsia,360,60,4,1,-1,0,06:00,10,1,-1,0,05:00
-359,Asia/Bishkek,1984,RussiaAsia,360,60,4,1,-1,0,06:00,9,-1,0,0,08:00
-360,Asia/Bishkek,1985,RussiaAsia,360,60,3,-1,0,0,08:00,9,-1,0,0,08:00
-361,Asia/Bishkek,1991,Kyrgyz,300,60,3,-1,0,0,07:00,9,-1,0,0,07:00
-362,Asia/Bishkek,1992,Kyrgyz,300,60,4,7,0,0,05:00,9,-1,0,0,04:00
-363,Asia/Bishkek,1997,Kyrgyz,300,60,3,-1,0,0,07:30,10,-1,0,0,06:30
-364,Asia/Bishkek,2005,,360,0,0,0,0,0,,0,0,0,0,
-365,Asia/Seoul,1970,ROK,540,60,5,15,-1,0,09:00,9,13,-1,0,08:00
-366,Asia/Seoul,1987,ROK,540,60,5,8,0,0,09:00,10,8,0,0,08:00
-367,Asia/Seoul,1988,ROK,540,0,5,8,0,0,09:00,10,8,0,0,08:00
-368,Asia/Pyongyang,1970,,540,0,0,0,0,0,,0,0,0,0,
-369,Asia/Kuwait,1970,,180,0,0,0,0,0,,0,0,0,0,
-370,Asia/Vientiane,1970,,420,0,0,0,0,0,,0,0,0,0,
-371,Asia/Beirut,1970,Lebanon,120,60,5,1,-1,0,02:00,10,1,-1,0,01:00
-372,Asia/Beirut,1972,Lebanon,120,60,6,22,-1,0,02:00,10,1,-1,0,01:00
-373,Asia/Beirut,1973,Lebanon,120,60,5,1,-1,0,02:00,10,1,-1,0,01:00
-374,Asia/Beirut,1978,Lebanon,120,60,4,30,-1,0,02:00,9,30,-1,0,01:00
-375,Asia/Beirut,1984,Lebanon,120,60,5,1,-1,0,02:00,10,16,-1,0,01:00
-376,Asia/Beirut,1988,Lebanon,120,60,6,1,-1,0,02:00,10,16,-1,0,01:00
-377,Asia/Beirut,1989,Lebanon,120,60,5,10,-1,0,02:00,10,16,-1,0,01:00
-378,Asia/Beirut,1990,Lebanon,120,60,5,1,-1,0,02:00,10,16,-1,0,01:00
-379,Asia/Beirut,1992,Lebanon,120,60,5,1,-1,0,02:00,10,4,-1,0,01:00
-380,Asia/Beirut,1993,Lebanon,120,60,3,-1,0,0,02:00,9,-1,0,0,01:00
-381,Asia/Beirut,1999,Lebanon,120,60,3,-1,0,0,02:00,10,-1,0,0,01:00
-382,Asia/Kuala_Lumpur,1970,,450,0,0,0,0,0,,0,0,0,0,
-383,Asia/Kuala_Lumpur,1982,,480,0,0,0,0,0,,0,0,0,0,
-384,Asia/Kuching,1970,,480,0,0,0,0,0,,0,0,0,0,
-385,Asia/Kuching,1982,,480,0,0,0,0,0,,0,0,0,0,
-386,Indian/Maldives,1970,,300,0,0,0,0,0,,0,0,0,0,
-387,Asia/Hovd,1970,,360,0,0,0,0,0,,0,0,0,0,
-388,Asia/Hovd,1978,Mongol,420,0,0,0,0,0,,0,0,0,0,
-389,Asia/Hovd,1983,Mongol,420,60,4,1,-1,0,07:00,10,1,-1,0,06:00
-390,Asia/Hovd,1984,Mongol,420,60,4,1,-1,0,07:00,9,-1,0,0,06:00
-391,Asia/Hovd,1985,Mongol,420,60,3,-1,0,0,07:00,9,-1,0,0,06:00
-392,Asia/Hovd,2001,Mongol,420,60,4,-1,6,0,09:00,9,-1,6,0,08:00
-393,Asia/Hovd,2002,Mongol,420,60,3,-1,6,0,09:00,9,-1,6,0,08:00
-394,Asia/Ulaanbaatar,1970,,420,0,0,0,0,0,,0,0,0,0,
-395,Asia/Ulaanbaatar,1978,Mongol,480,0,0,0,0,0,,0,0,0,0,
-396,Asia/Ulaanbaatar,1983,Mongol,480,60,4,1,-1,0,08:00,10,1,-1,0,07:00
-397,Asia/Ulaanbaatar,1984,Mongol,480,60,4,1,-1,0,08:00,9,-1,0,0,07:00
-398,Asia/Ulaanbaatar,1985,Mongol,480,60,3,-1,0,0,08:00,9,-1,0,0,07:00
-399,Asia/Ulaanbaatar,2001,Mongol,480,60,4,-1,6,0,10:00,9,-1,6,0,09:00
-400,Asia/Ulaanbaatar,2002,Mongol,480,60,3,-1,6,0,10:00,9,-1,6,0,09:00
-401,Asia/Choibalsan,1970,,420,0,0,0,0,0,,0,0,0,0,
-402,Asia/Choibalsan,1978,,480,0,0,0,0,0,,0,0,0,0,
-403,Asia/Choibalsan,1983,Mongol,540,60,4,1,-1,0,09:00,10,1,-1,0,08:00
-404,Asia/Choibalsan,1984,Mongol,540,60,4,1,-1,0,09:00,9,-1,0,0,08:00
-405,Asia/Choibalsan,1985,Mongol,540,60,3,-1,0,0,09:00,9,-1,0,0,08:00
-406,Asia/Choibalsan,2001,Mongol,540,60,4,-1,6,0,11:00,9,-1,6,0,10:00
-407,Asia/Choibalsan,2002,Mongol,540,60,3,-1,6,0,11:00,9,-1,6,0,10:00
-408,Asia/Katmandu,1970,,330,0,0,0,0,0,,0,0,0,0,
-409,Asia/Katmandu,1986,,345,0,0,0,0,0,,0,0,0,0,
-410,Asia/Muscat,1970,,240,0,0,0,0,0,,0,0,0,0,
-411,Asia/Karachi,1970,,300,0,0,0,0,0,,0,0,0,0,
-412,Asia/Karachi,1971,Pakistan,300,0,0,0,0,0,,0,0,0,0,
-413,Asia/Karachi,2002,Pakistan,300,60,4,2,0,0,05:01,10,2,0,0,04:01
-414,Asia/Karachi,2003,Pakistan,300,0,4,2,0,0,05:01,10,2,0,0,04:01
-415,Asia/Gaza,1970,Zion,120,60,4,29,-1,0,04:00,9,22,-1,0,01:00
-416,Asia/Gaza,1974,Zion,120,60,7,7,-1,0,02:00,10,13,-1,0,01:00
-417,Asia/Gaza,1975,Zion,120,60,4,20,-1,0,02:00,8,31,-1,0,01:00
-418,Asia/Gaza,1985,Zion,120,60,4,14,-1,0,02:00,9,15,-1,0,01:00
-419,Asia/Gaza,1986,Zion,120,60,5,18,-1,0,02:00,9,7,-1,0,01:00
-420,Asia/Gaza,1987,Zion,120,60,4,15,-1,0,02:00,9,13,-1,0,01:00
-421,Asia/Gaza,1988,Zion,120,60,4,9,-1,0,02:00,9,3,-1,0,01:00
-422,Asia/Gaza,1989,Zion,120,60,4,30,-1,0,02:00,9,3,-1,0,01:00
-423,Asia/Gaza,1990,Zion,120,60,3,25,-1,0,02:00,8,26,-1,0,01:00
-424,Asia/Gaza,1991,Zion,120,60,3,24,-1,0,02:00,9,1,-1,0,01:00
-425,Asia/Gaza,1992,Zion,120,60,3,29,-1,0,02:00,9,6,-1,0,01:00
-426,Asia/Gaza,1993,Zion,120,60,4,2,-1,0,02:00,9,5,-1,0,01:00
-427,Asia/Gaza,1994,Zion,120,60,4,1,-1,0,02:00,8,28,-1,0,01:00
-428,Asia/Gaza,1995,Zion,120,60,3,31,-1,0,02:00,9,3,-1,0,01:00
-429,Asia/Gaza,1996,Jordan,120,60,4,1,5,0,02:00,9,15,5,0,02:00
-430,Asia/Gaza,1999,Palestine,120,60,4,15,5,0,02:00,10,15,5,0,01:00
-431,Asia/Gaza,2004,Palestine,120,60,4,15,5,0,02:00,10,1,-1,0,02:00
-432,Asia/Gaza,2005,Palestine,120,60,4,15,5,0,02:00,10,4,-1,0,03:00
-433,Asia/Gaza,2006,Palestine,120,60,4,1,-1,0,02:00,9,22,-1,0,01:00
-434,Asia/Gaza,2007,Palestine,120,60,4,1,-1,0,02:00,10,15,5,0,01:00
-435,Asia/Manila,1970,Phil,480,60,4,12,-1,0,08:00,7,1,-1,0,07:00
-436,Asia/Manila,1978,Phil,480,60,3,22,-1,0,08:00,9,21,-1,0,07:00
-437,Asia/Manila,1979,Phil,480,0,3,22,-1,0,08:00,9,21,-1,0,07:00
-438,Asia/Qatar,1970,,240,0,0,0,0,0,,0,0,0,0,
-439,Asia/Qatar,1972,,180,0,0,0,0,0,,0,0,0,0,
-440,Asia/Riyadh,1970,,180,0,0,0,0,0,,0,0,0,0,
-441,Asia/Singapore,1970,,450,0,0,0,0,0,,0,0,0,0,
-442,Asia/Singapore,1982,,480,0,0,0,0,0,,0,0,0,0,
-443,Asia/Colombo,1970,,330,0,0,0,0,0,,0,0,0,0,
-444,Asia/Colombo,1996,,360,0,0,0,0,0,,0,0,0,0,
-445,Asia/Colombo,2006,,330,0,0,0,0,0,,0,0,0,0,
-446,Asia/Damascus,1970,Syria,120,60,5,1,-1,0,04:00,10,1,-1,0,03:00
-447,Asia/Damascus,1977,Syria,120,60,5,1,-1,0,04:00,9,1,-1,0,03:00
-448,Asia/Damascus,1983,Syria,120,60,4,9,-1,0,04:00,10,1,-1,0,03:00
-449,Asia/Damascus,1986,Syria,120,60,2,16,-1,0,04:00,10,9,-1,0,03:00
-450,Asia/Damascus,1987,Syria,120,60,3,1,-1,0,04:00,10,31,-1,0,03:00
-451,Asia/Damascus,1988,Syria,120,60,3,15,-1,0,04:00,10,31,-1,0,03:00
-452,Asia/Damascus,1989,Syria,120,60,3,31,-1,0,04:00,10,1,-1,0,03:00
-453,Asia/Damascus,1990,Syria,120,60,4,1,-1,0,04:00,9,30,-1,0,03:00
-454,Asia/Damascus,1991,Syria,120,60,4,1,-1,0,02:00,10,1,-1,0,01:00
-455,Asia/Damascus,1992,Syria,120,60,4,8,-1,0,02:00,10,1,-1,0,01:00
-456,Asia/Damascus,1993,Syria,120,60,3,26,-1,0,02:00,9,25,-1,0,01:00
-457,Asia/Damascus,1994,Syria,120,60,4,1,-1,0,02:00,10,1,-1,0,01:00
-458,Asia/Damascus,1997,Syria,120,60,3,-1,1,0,02:00,10,1,-1,0,01:00
-459,Asia/Damascus,1999,Syria,120,60,4,1,-1,0,02:00,10,1,-1,0,01:00
-460,Asia/Damascus,2006,Syria,120,60,4,1,-1,0,02:00,9,22,-1,0,01:00
-461,Asia/Damascus,2007,Syria,120,60,4,1,-1,0,02:00,10,1,-1,0,01:00
-462,Asia/Dushanbe,1970,RussiaAsia,360,0,0,0,0,0,,0,0,0,0,
-463,Asia/Dushanbe,1981,RussiaAsia,360,60,4,1,-1,0,06:00,10,1,-1,0,05:00
-464,Asia/Dushanbe,1984,RussiaAsia,360,60,4,1,-1,0,06:00,9,-1,0,0,08:00
-465,Asia/Dushanbe,1985,RussiaAsia,360,60,3,-1,0,0,08:00,9,-1,0,0,08:00
-466,Asia/Dushanbe,1991,,300,0,0,0,0,0,,0,0,0,0,
-467,Asia/Bangkok,1970,,420,0,0,0,0,0,,0,0,0,0,
-468,Asia/Ashgabat,1970,RussiaAsia,300,0,0,0,0,0,,0,0,0,0,
-469,Asia/Ashgabat,1981,RussiaAsia,300,60,4,1,-1,0,05:00,10,1,-1,0,04:00
-470,Asia/Ashgabat,1984,RussiaAsia,300,60,4,1,-1,0,05:00,9,-1,0,0,07:00
-471,Asia/Ashgabat,1985,RussiaAsia,300,60,3,-1,0,0,07:00,9,-1,0,0,07:00
-472,Asia/Ashgabat,1991,RussiaAsia,240,60,3,-1,0,0,06:00,9,-1,0,0,06:00
-473,Asia/Ashgabat,1992,,300,0,0,0,0,0,,0,0,0,0,
-474,Asia/Dubai,1970,,240,0,0,0,0,0,,0,0,0,0,
-475,Asia/Samarkand,1970,,300,0,0,0,0,0,,0,0,0,0,
-476,Asia/Samarkand,1981,,360,0,0,0,0,0,,0,0,0,0,
-477,Asia/Samarkand,1982,RussiaAsia,300,60,4,1,-1,0,05:00,10,1,-1,0,04:00
-478,Asia/Samarkand,1984,RussiaAsia,300,60,4,1,-1,0,05:00,9,-1,0,0,07:00
-479,Asia/Samarkand,1985,RussiaAsia,300,60,3,-1,0,0,07:00,9,-1,0,0,07:00
-480,Asia/Samarkand,1992,,300,0,0,0,0,0,,0,0,0,0,
-481,Asia/Tashkent,1970,RussiaAsia,360,0,0,0,0,0,,0,0,0,0,
-482,Asia/Tashkent,1981,RussiaAsia,360,60,4,1,-1,0,06:00,10,1,-1,0,05:00
-483,Asia/Tashkent,1984,RussiaAsia,360,60,4,1,-1,0,06:00,9,-1,0,0,08:00
-484,Asia/Tashkent,1985,RussiaAsia,360,60,3,-1,0,0,08:00,9,-1,0,0,08:00
-485,Asia/Tashkent,1991,RussiaAsia,300,60,3,-1,0,0,07:00,9,-1,0,0,07:00
-486,Asia/Tashkent,1992,,300,0,0,0,0,0,,0,0,0,0,
-487,Asia/Saigon,1970,,420,0,0,0,0,0,,0,0,0,0,
-488,Asia/Aden,1970,,180,0,0,0,0,0,,0,0,0,0,
-489,Australia/Darwin,1970,Aus,570,0,12,31,-1,0,21:30,3,-1,0,0,10:30
-490,Australia/Perth,1970,AW,480,0,0,0,0,0,,0,0,0,0,
-491,Australia/Perth,1974,AW,480,60,10,-1,0,0,10:00,1,1,-1,0,19:00
-492,Australia/Perth,1975,AW,480,0,12,31,-1,0,20:00,3,1,0,0,10:00
-493,Australia/Perth,1983,AW,480,60,10,-1,0,0,10:00,1,1,-1,0,19:00
-494,Australia/Perth,1984,AW,480,0,12,31,-1,0,20:00,3,1,0,0,10:00
-495,Australia/Perth,1991,AW,480,60,11,17,-1,0,10:00,1,1,-1,0,19:00
-496,Australia/Perth,1992,AW,480,0,12,31,-1,0,20:00,3,1,0,0,10:00
-497,Australia/Perth,2006,AW,480,60,12,3,-1,0,10:00,1,1,-1,0,19:00
-498,Australia/Perth,2007,AW,480,60,10,-1,0,0,10:00,3,-1,0,0,10:00
-499,Australia/Perth,2009,AW,480,0,12,31,-1,0,20:00,3,-1,0,0,10:00
-500,Australia/Eucla,1970,AW,525,0,0,0,0,0,,0,0,0,0,
-501,Australia/Eucla,1974,AW,525,60,10,-1,0,0,10:45,1,1,-1,0,19:45
-502,Australia/Eucla,1975,AW,525,0,12,31,-1,0,20:45,3,1,0,0,10:45
-503,Australia/Eucla,1983,AW,525,60,10,-1,0,0,10:45,1,1,-1,0,19:45
-504,Australia/Eucla,1984,AW,525,0,12,31,-1,0,20:45,3,1,0,0,10:45
-505,Australia/Eucla,1991,AW,525,60,11,17,-1,0,10:45,1,1,-1,0,19:45
-506,Australia/Eucla,1992,AW,525,0,12,31,-1,0,20:45,3,1,0,0,10:45
-507,Australia/Eucla,2006,AW,525,60,12,3,-1,0,10:45,1,1,-1,0,19:45
-508,Australia/Eucla,2007,AW,525,60,10,-1,0,0,10:45,3,-1,0,0,10:45
-509,Australia/Eucla,2009,AW,525,0,12,31,-1,0,20:45,3,-1,0,0,10:45
-510,Australia/Brisbane,1970,Aus,600,0,12,31,-1,0,22:00,3,-1,0,0,11:00
-511,Australia/Brisbane,1971,AQ,600,60,10,-1,0,0,12:00,1,1,-1,0,21:00
-512,Australia/Brisbane,1972,AQ,600,0,12,31,-1,0,22:00,2,-1,0,0,12:00
-513,Australia/Brisbane,1989,AQ,600,60,10,-1,0,0,12:00,1,1,-1,0,21:00
-514,Australia/Brisbane,1990,AQ,600,60,10,-1,0,0,12:00,3,1,0,0,12:00
-515,Australia/Brisbane,1992,AQ,600,0,12,31,-1,0,22:00,3,1,0,0,12:00
-516,Australia/Lindeman,1970,Aus,600,0,12,31,-1,0,22:00,3,-1,0,0,11:00
-517,Australia/Lindeman,1971,AQ,600,60,10,-1,0,0,12:00,1,1,-1,0,21:00
-518,Australia/Lindeman,1972,AQ,600,0,12,31,-1,0,22:00,2,-1,0,0,12:00
-519,Australia/Lindeman,1989,AQ,600,60,10,-1,0,0,12:00,1,1,-1,0,21:00
-520,Australia/Lindeman,1990,AQ,600,60,10,-1,0,0,12:00,3,1,0,0,12:00
-521,Australia/Lindeman,1992,Holiday,600,60,10,-1,0,0,12:00,1,1,-1,0,21:00
-522,Australia/Lindeman,1993,Holiday,600,60,10,-1,0,0,12:00,3,1,0,0,12:00
-523,Australia/Lindeman,1994,Holiday,600,0,12,31,-1,0,22:00,3,1,0,0,12:00
-524,Australia/Adelaide,1970,Aus,570,0,12,31,-1,0,21:30,3,-1,0,0,10:30
-525,Australia/Adelaide,1971,AS,570,60,10,-1,0,0,11:30,1,1,-1,0,20:30
-526,Australia/Adelaide,1972,AS,570,60,10,-1,0,0,11:30,2,27,-1,0,11:30
-527,Australia/Adelaide,1973,AS,570,60,10,-1,0,0,11:30,3,1,0,0,11:30
-528,Australia/Adelaide,1986,AS,570,60,10,19,-1,0,11:30,3,15,0,0,11:30
-529,Australia/Adelaide,1987,AS,570,60,10,-1,0,0,11:30,3,15,0,0,11:30
-530,Australia/Adelaide,1990,AS,570,60,10,-1,0,0,11:30,3,18,0,0,11:30
-531,Australia/Adelaide,1991,AS,570,60,10,-1,0,0,11:30,3,1,0,0,11:30
-532,Australia/Adelaide,1992,AS,570,60,10,-1,0,0,11:30,3,18,0,0,11:30
-533,Australia/Adelaide,1993,AS,570,60,10,-1,0,0,11:30,3,1,0,0,11:30
-534,Australia/Adelaide,1994,AS,570,60,10,-1,0,0,11:30,3,18,0,0,11:30
-535,Australia/Adelaide,1995,AS,570,60,10,-1,0,0,11:30,3,-1,0,0,11:30
-536,Australia/Adelaide,2006,AS,570,60,10,-1,0,0,11:30,4,1,0,0,11:30
-537,Australia/Adelaide,2007,AS,570,60,10,-1,0,0,11:30,3,-1,0,0,11:30
-538,Australia/Hobart,1970,AT,600,60,10,-1,0,0,12:00,3,8,0,0,12:00
-539,Australia/Hobart,1972,AT,600,60,10,-1,0,0,12:00,2,-1,0,0,12:00
-540,Australia/Hobart,1973,AT,600,60,10,-1,0,0,12:00,3,1,0,0,12:00
-541,Australia/Hobart,1982,AT,600,60,10,-1,0,0,12:00,3,-1,0,0,12:00
-542,Australia/Hobart,1984,AT,600,60,10,-1,0,0,12:00,3,1,0,0,12:00
-543,Australia/Hobart,1986,AT,600,60,10,15,0,0,12:00,3,1,0,0,12:00
-544,Australia/Hobart,1987,AT,600,60,10,22,0,0,12:00,3,15,0,0,12:00
-545,Australia/Hobart,1988,AT,600,60,10,-1,0,0,12:00,3,15,0,0,12:00
-546,Australia/Hobart,1991,AT,600,60,10,1,0,0,12:00,3,-1,0,0,12:00
-547,Australia/Hobart,2000,AT,600,60,8,-1,0,0,12:00,3,-1,0,0,12:00
-548,Australia/Hobart,2001,AT,600,60,10,1,0,0,12:00,3,-1,0,0,12:00
-549,Australia/Hobart,2006,AT,600,60,10,1,0,0,12:00,4,1,0,0,12:00
-550,Australia/Hobart,2007,AT,600,60,10,1,0,0,12:00,3,-1,0,0,12:00
-551,Australia/Currie,1970,Aus,600,0,12,31,-1,0,22:00,3,-1,0,0,11:00
-552,Australia/Currie,1971,AT,600,60,10,-1,0,0,12:00,3,8,0,0,12:00
-553,Australia/Currie,1972,AT,600,60,10,-1,0,0,12:00,2,-1,0,0,12:00
-554,Australia/Currie,1973,AT,600,60,10,-1,0,0,12:00,3,1,0,0,12:00
-555,Australia/Currie,1982,AT,600,60,10,-1,0,0,12:00,3,-1,0,0,12:00
-556,Australia/Currie,1984,AT,600,60,10,-1,0,0,12:00,3,1,0,0,12:00
-557,Australia/Currie,1986,AT,600,60,10,15,0,0,12:00,3,1,0,0,12:00
-558,Australia/Currie,1987,AT,600,60,10,22,0,0,12:00,3,15,0,0,12:00
-559,Australia/Currie,1988,AT,600,60,10,-1,0,0,12:00,3,15,0,0,12:00
-560,Australia/Currie,1991,AT,600,60,10,1,0,0,12:00,3,-1,0,0,12:00
-561,Australia/Currie,2000,AT,600,60,8,-1,0,0,12:00,3,-1,0,0,12:00
-562,Australia/Currie,2001,AT,600,60,10,1,0,0,12:00,3,-1,0,0,12:00
-563,Australia/Currie,2006,AT,600,60,10,1,0,0,12:00,4,1,0,0,12:00
-564,Australia/Currie,2007,AT,600,60,10,1,0,0,12:00,3,-1,0,0,12:00
-565,Australia/Melbourne,1970,Aus,600,0,12,31,-1,0,22:00,3,-1,0,0,11:00
-566,Australia/Melbourne,1971,AV,600,60,10,-1,0,0,12:00,1,1,-1,0,21:00
-567,Australia/Melbourne,1972,AV,600,60,10,-1,0,0,12:00,2,-1,0,0,12:00
-568,Australia/Melbourne,1973,AV,600,60,10,-1,0,0,12:00,3,1,0,0,12:00
-569,Australia/Melbourne,1986,AV,600,60,10,15,0,0,12:00,3,15,0,0,12:00
-570,Australia/Melbourne,1988,AV,600,60,10,-1,0,0,12:00,3,15,0,0,12:00
-571,Australia/Melbourne,1991,AV,600,60,10,-1,0,0,12:00,3,1,0,0,12:00
-572,Australia/Melbourne,1995,AV,600,60,10,-1,0,0,12:00,3,-1,0,0,12:00
-573,Australia/Melbourne,2000,AV,600,60,8,-1,0,0,12:00,3,-1,0,0,12:00
-574,Australia/Melbourne,2001,AV,600,60,10,-1,0,0,12:00,3,-1,0,0,12:00
-575,Australia/Melbourne,2006,AV,600,60,10,-1,0,0,12:00,4,1,0,0,12:00
-576,Australia/Melbourne,2007,AV,600,60,10,-1,0,0,12:00,3,-1,0,0,12:00
-577,Australia/Sydney,1970,Aus,600,0,12,31,-1,0,22:00,3,-1,0,0,11:00
-578,Australia/Sydney,1971,AN,600,60,10,-1,0,0,12:00,1,1,-1,0,21:00
-579,Australia/Sydney,1972,AN,600,60,10,-1,0,0,12:00,2,27,-1,0,12:00
-580,Australia/Sydney,1973,AN,600,60,10,-1,0,0,12:00,3,1,0,0,12:00
-581,Australia/Sydney,1982,AN,600,60,10,-1,0,0,12:00,4,1,0,0,12:00
-582,Australia/Sydney,1983,AN,600,60,10,-1,0,0,12:00,3,1,0,0,12:00
-583,Australia/Sydney,1986,AN,600,60,10,19,-1,0,12:00,3,15,0,0,12:00
-584,Australia/Sydney,1987,AN,600,60,10,-1,0,0,12:00,3,15,0,0,12:00
-585,Australia/Sydney,1990,AN,600,60,10,-1,0,0,12:00,3,1,0,0,12:00
-586,Australia/Sydney,1996,AN,600,60,10,-1,0,0,12:00,3,-1,0,0,12:00
-587,Australia/Sydney,2000,AN,600,60,8,-1,0,0,12:00,3,-1,0,0,12:00
-588,Australia/Sydney,2001,AN,600,60,10,-1,0,0,12:00,3,-1,0,0,12:00
-589,Australia/Sydney,2006,AN,600,60,10,-1,0,0,12:00,4,1,0,0,12:00
-590,Australia/Sydney,2007,AN,600,60,10,-1,0,0,12:00,3,-1,0,0,12:00
-591,Australia/Broken_Hill,1970,Aus,570,0,12,31,-1,0,21:30,3,-1,0,0,10:30
-592,Australia/Broken_Hill,1971,AN,570,60,10,-1,0,0,11:30,1,1,-1,0,20:30
-593,Australia/Broken_Hill,1972,AN,570,60,10,-1,0,0,11:30,2,27,-1,0,11:30
-594,Australia/Broken_Hill,1973,AN,570,60,10,-1,0,0,11:30,3,1,0,0,11:30
-595,Australia/Broken_Hill,1982,AN,570,60,10,-1,0,0,11:30,4,1,0,0,11:30
-596,Australia/Broken_Hill,1983,AN,570,60,10,-1,0,0,11:30,3,1,0,0,11:30
-597,Australia/Broken_Hill,1986,AN,570,60,10,19,-1,0,11:30,3,15,0,0,11:30
-598,Australia/Broken_Hill,1987,AN,570,60,10,-1,0,0,11:30,3,15,0,0,11:30
-599,Australia/Broken_Hill,1990,AN,570,60,10,-1,0,0,11:30,3,1,0,0,11:30
-600,Australia/Broken_Hill,1996,AN,570,60,10,-1,0,0,11:30,3,-1,0,0,11:30
-601,Australia/Broken_Hill,2000,AS,570,60,10,-1,0,0,11:30,3,-1,0,0,11:30
-602,Australia/Broken_Hill,2006,AS,570,60,10,-1,0,0,11:30,4,1,0,0,11:30
-603,Australia/Broken_Hill,2007,AS,570,60,10,-1,0,0,11:30,3,-1,0,0,11:30
-604,Australia/Lord_Howe,1970,,600,0,0,0,0,0,,0,0,0,0,
-605,Australia/Lord_Howe,1981,LH,630,60,10,-1,0,0,12:30,1,1,-1,0,21:30
-606,Australia/Lord_Howe,1982,LH,630,60,10,-1,0,0,12:30,3,1,0,0,11:30
-607,Australia/Lord_Howe,1985,LH,630,30,10,-1,0,0,12:30,3,1,0,0,11:30
-608,Australia/Lord_Howe,1986,LH,630,30,10,19,-1,0,12:30,3,15,0,0,11:30
-609,Australia/Lord_Howe,1987,LH,630,30,10,-1,0,0,12:30,3,15,0,0,11:30
-610,Australia/Lord_Howe,1990,LH,630,30,10,-1,0,0,12:30,3,1,0,0,11:30
-611,Australia/Lord_Howe,1996,LH,630,30,10,-1,0,0,12:30,3,-1,0,0,11:30
-612,Australia/Lord_Howe,2000,LH,630,30,8,-1,0,0,12:30,3,-1,0,0,11:30
-613,Australia/Lord_Howe,2001,LH,630,30,10,-1,0,0,12:30,3,-1,0,0,11:30
-614,Australia/Lord_Howe,2006,LH,630,30,10,-1,0,0,12:30,4,1,0,0,11:30
-615,Australia/Lord_Howe,2007,LH,630,30,10,-1,0,0,12:30,3,-1,0,0,11:30
-616,Indian/Christmas,1970,,420,0,0,0,0,0,,0,0,0,0,
-617,Pacific/Rarotonga,1970,,-630,0,0,0,0,0,,0,0,0,0,
-618,Pacific/Rarotonga,1978,Cook,-600,30,11,12,-1,0,-10:0,1,1,-1,0,01:00
-619,Pacific/Rarotonga,1979,Cook,-600,30,10,-1,0,0,-10:0,3,1,0,0,-11:0
-620,Pacific/Rarotonga,1991,Cook,-600,0,12,31,-1,0,02:00,3,1,0,0,-11:0
-621,Indian/Cocos,1970,,390,0,0,0,0,0,,0,0,0,0,
-622,Pacific/Fiji,1970,Fiji,720,0,0,0,0,0,,0,0,0,0,
-623,Pacific/Fiji,1998,Fiji,720,60,11,1,0,0,14:00,1,1,-1,0,23:00
-624,Pacific/Fiji,1999,Fiji,720,60,11,1,0,0,14:00,2,-1,0,0,14:00
-625,Pacific/Fiji,2000,Fiji,720,0,12,31,-1,0,24:00,2,-1,0,0,14:00
-626,Pacific/Gambier,1970,,-540,0,0,0,0,0,,0,0,0,0,
-627,Pacific/Marquesas,1970,,-570,0,0,0,0,0,,0,0,0,0,
-628,Pacific/Tahiti,1970,,-600,0,0,0,0,0,,0,0,0,0,
-629,Pacific/Guam,1970,,600,0,0,0,0,0,,0,0,0,0,
-630,Pacific/Guam,2000,,600,0,0,0,0,0,,0,0,0,0,
-631,Pacific/Tarawa,1970,,720,0,0,0,0,0,,0,0,0,0,
-632,Pacific/Enderbury,1970,,-720,0,0,0,0,0,,0,0,0,0,
-633,Pacific/Enderbury,1979,,-660,0,0,0,0,0,,0,0,0,0,
-634,Pacific/Enderbury,1995,,780,0,0,0,0,0,,0,0,0,0,
-635,Pacific/Kiritimati,1970,,-640,0,0,0,0,0,,0,0,0,0,
-636,Pacific/Kiritimati,1979,,-600,0,0,0,0,0,,0,0,0,0,
-637,Pacific/Kiritimati,1995,,840,0,0,0,0,0,,0,0,0,0,
-638,Pacific/Saipan,1970,,600,0,0,0,0,0,,0,0,0,0,
-639,Pacific/Saipan,2000,,600,0,0,0,0,0,,0,0,0,0,
-640,Pacific/Majuro,1970,,720,0,0,0,0,0,,0,0,0,0,
-641,Pacific/Kwajalein,1970,,-720,0,0,0,0,0,,0,0,0,0,
-642,Pacific/Kwajalein,1993,,720,0,0,0,0,0,,0,0,0,0,
-643,Pacific/Truk,1970,,600,0,0,0,0,0,,0,0,0,0,
-644,Pacific/Ponape,1970,,660,0,0,0,0,0,,0,0,0,0,
-645,Pacific/Kosrae,1970,,720,0,0,0,0,0,,0,0,0,0,
-646,Pacific/Kosrae,1999,,660,0,0,0,0,0,,0,0,0,0,
-647,Pacific/Nauru,1970,,690,0,0,0,0,0,,0,0,0,0,
-648,Pacific/Nauru,1979,,720,0,0,0,0,0,,0,0,0,0,
-649,Pacific/Noumea,1970,NC,660,0,0,0,0,0,,0,0,0,0,
-650,Pacific/Noumea,1977,NC,660,60,12,1,0,0,11:00,1,1,-1,0,22:00
-651,Pacific/Noumea,1978,NC,660,60,12,1,0,0,11:00,2,27,-1,0,10:00
-652,Pacific/Noumea,1979,NC,660,0,12,31,-1,0,23:00,2,27,-1,0,10:00
-653,Pacific/Noumea,1996,NC,660,60,12,1,-1,0,13:00,1,1,-1,0,22:00
-654,Pacific/Noumea,1997,NC,660,0,12,31,-1,0,23:00,3,2,-1,0,13:00
-655,Pacific/Auckland,1970,NZ,720,0,12,31,-1,0,24:00,1,1,-1,0,11:00
-656,Pacific/Auckland,1974,NZ,720,60,11,1,0,0,14:00,1,1,-1,0,23:00
-657,Pacific/Auckland,1975,NZ,720,60,10,-1,0,0,14:00,2,-1,0,0,14:00
-658,Pacific/Auckland,1976,NZ,720,60,10,-1,0,0,14:00,3,1,0,0,14:00
-659,Pacific/Auckland,1989,NZ,720,60,10,8,0,0,14:00,3,1,0,0,14:00
-660,Pacific/Auckland,1990,NZ,720,60,10,1,0,0,14:00,3,15,0,0,14:00
-661,Pacific/Chatham,1970,Chatham,765,0,0,0,0,0,,0,0,0,0,
-662,Pacific/Chatham,1974,Chatham,765,60,11,1,0,0,15:30,1,1,-1,0,23:45
-663,Pacific/Chatham,1975,Chatham,765,60,10,-1,0,0,15:30,2,-1,0,0,15:30
-664,Pacific/Chatham,1976,Chatham,765,60,10,-1,0,0,15:30,3,1,0,0,15:30
-665,Pacific/Chatham,1989,Chatham,765,60,10,8,0,0,15:30,3,1,0,0,15:30
-666,Pacific/Chatham,1990,Chatham,765,60,10,1,0,0,15:30,3,15,0,0,15:30
-667,Pacific/Niue,1970,,-690,0,0,0,0,0,,0,0,0,0,
-668,Pacific/Niue,1978,,-660,0,0,0,0,0,,0,0,0,0,
-669,Pacific/Norfolk,1970,,690,0,0,0,0,0,,0,0,0,0,
-670,Pacific/Palau,1970,,540,0,0,0,0,0,,0,0,0,0,
-671,Pacific/Port_Moresby,1970,,600,0,0,0,0,0,,0,0,0,0,
-672,Pacific/Pitcairn,1970,,-510,0,0,0,0,0,,0,0,0,0,
-673,Pacific/Pitcairn,1998,,-480,0,0,0,0,0,,0,0,0,0,
-674,Pacific/Pago_Pago,1970,,-660,0,0,0,0,0,,0,0,0,0,
-675,Pacific/Pago_Pago,1983,,-660,0,0,0,0,0,,0,0,0,0,
-676,Pacific/Apia,1970,,-660,0,0,0,0,0,,0,0,0,0,
-677,Pacific/Guadalcanal,1970,,660,0,0,0,0,0,,0,0,0,0,
-678,Pacific/Fakaofo,1970,,-600,0,0,0,0,0,,0,0,0,0,
-679,Pacific/Tongatapu,1970,,780,0,0,0,0,0,,0,0,0,0,
-680,Pacific/Tongatapu,1999,Tonga,780,60,10,7,-1,0,15:00,1,1,-1,0,24:00
-681,Pacific/Tongatapu,2000,Tonga,780,60,11,1,0,0,15:00,3,19,-1,0,15:00
-682,Pacific/Tongatapu,2001,Tonga,780,60,11,1,0,0,15:00,1,-1,0,0,14:00
-683,Pacific/Tongatapu,2002,Tonga,780,0,12,31,-1,0,25:00,1,-1,0,0,14:00
-684,Pacific/Funafuti,1970,,720,0,0,0,0,0,,0,0,0,0,
-685,Pacific/Johnston,1970,,-600,0,0,0,0,0,,0,0,0,0,
-686,Pacific/Midway,1970,,-660,0,0,0,0,0,,0,0,0,0,
-687,Pacific/Midway,1983,,-660,0,0,0,0,0,,0,0,0,0,
-688,Pacific/Wake,1970,,720,0,0,0,0,0,,0,0,0,0,
-689,Pacific/Efate,1970,Vanuatu,660,0,0,0,0,0,,0,0,0,0,
-690,Pacific/Efate,1983,Vanuatu,660,60,9,25,-1,0,11:00,1,1,-1,0,22:00
-691,Pacific/Efate,1984,Vanuatu,660,60,10,23,-1,0,11:00,3,23,0,0,10:00
-692,Pacific/Efate,1985,Vanuatu,660,60,9,23,0,0,11:00,3,23,0,0,10:00
-693,Pacific/Efate,1992,Vanuatu,660,60,10,23,0,0,11:00,1,23,0,0,10:00
-694,Pacific/Efate,1993,Vanuatu,660,0,12,31,-1,0,23:00,1,23,0,0,10:00
-695,Pacific/Wallis,1970,,720,0,0,0,0,0,,0,0,0,0,
-696,Europe/London,1970,,60,0,0,0,0,0,,0,0,0,0,
-697,Europe/London,1971,GB-Eire,0,0,0,0,0,0,,0,0,0,0,
-698,Europe/London,1972,GB-Eire,0,60,3,16,0,0,02:00,10,23,0,0,02:00
-699,Europe/London,1981,GB-Eire,0,60,3,-1,0,0,1:00,10,23,0,0,1:00
-700,Europe/London,1990,GB-Eire,0,60,3,-1,0,0,1:00,10,22,0,0,1:00
-701,Europe/London,1995,GB-Eire,0,0,3,-1,0,0,1:00,10,22,0,0,1:00
-702,Europe/London,1996,EU,0,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-703,Europe/Dublin,1970,,60,0,0,0,0,0,,0,0,0,0,
-704,Europe/Dublin,1971,GB-Eire,0,0,0,0,0,0,,0,0,0,0,
-705,Europe/Dublin,1972,GB-Eire,0,60,3,16,0,0,02:00,10,23,0,0,02:00
-706,Europe/Dublin,1981,GB-Eire,0,60,3,-1,0,0,1:00,10,23,0,0,1:00
-707,Europe/Dublin,1990,GB-Eire,0,60,3,-1,0,0,1:00,10,22,0,0,1:00
-708,Europe/Dublin,1995,GB-Eire,0,0,3,-1,0,0,1:00,10,22,0,0,1:00
-709,Europe/Dublin,1996,EU,0,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-710,WET,1970,EU,0,0,0,0,0,0,,0,0,0,0,
-711,WET,1977,EU,0,60,4,1,0,0,1:00,9,-1,0,0,1:00
-712,WET,1978,EU,0,60,4,1,0,0,1:00,10,1,-1,0,1:00
-713,WET,1979,EU,0,60,4,1,0,0,1:00,9,-1,0,0,1:00
-714,WET,1981,EU,0,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-715,WET,1996,EU,0,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-716,CET,1970,C-Eur,60,60,4,3,-1,0,03:00,10,2,-1,0,03:00
-717,CET,1977,C-Eur,60,60,4,1,0,0,03:00,9,-1,0,0,03:00
-718,CET,1978,C-Eur,60,60,4,1,0,0,03:00,10,1,-1,0,03:00
-719,CET,1979,C-Eur,60,60,4,1,0,0,03:00,9,-1,0,0,03:00
-720,CET,1981,C-Eur,60,60,3,-1,0,0,03:00,9,-1,0,0,03:00
-721,CET,1996,C-Eur,60,60,3,-1,0,0,03:00,10,-1,0,0,03:00
-722,MET,1970,C-Eur,60,60,4,3,-1,0,03:00,10,2,-1,0,03:00
-723,MET,1977,C-Eur,60,60,4,1,0,0,03:00,9,-1,0,0,03:00
-724,MET,1978,C-Eur,60,60,4,1,0,0,03:00,10,1,-1,0,03:00
-725,MET,1979,C-Eur,60,60,4,1,0,0,03:00,9,-1,0,0,03:00
-726,MET,1981,C-Eur,60,60,3,-1,0,0,03:00,9,-1,0,0,03:00
-727,MET,1996,C-Eur,60,60,3,-1,0,0,03:00,10,-1,0,0,03:00
-728,EET,1970,EU,120,0,0,0,0,0,,0,0,0,0,
-729,EET,1977,EU,120,60,4,1,0,0,1:00,9,-1,0,0,1:00
-730,EET,1978,EU,120,60,4,1,0,0,1:00,10,1,-1,0,1:00
-731,EET,1979,EU,120,60,4,1,0,0,1:00,9,-1,0,0,1:00
-732,EET,1981,EU,120,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-733,EET,1996,EU,120,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-734,Europe/Tirane,1970,Albania,60,60,3,29,-1,0,03:00,4,10,-1,0,03:00
-735,Europe/Tirane,1974,Albania,60,60,5,4,-1,0,01:00,10,2,-1,0,00:00
-736,Europe/Tirane,1975,Albania,60,60,5,1,-1,0,01:00,10,2,-1,0,00:00
-737,Europe/Tirane,1976,Albania,60,60,5,2,-1,0,01:00,10,3,-1,0,00:00
-738,Europe/Tirane,1977,Albania,60,60,5,8,-1,0,01:00,10,2,-1,0,00:00
-739,Europe/Tirane,1978,Albania,60,60,5,6,-1,0,01:00,10,1,-1,0,00:00
-740,Europe/Tirane,1979,Albania,60,60,5,5,-1,0,01:00,9,30,-1,0,00:00
-741,Europe/Tirane,1980,Albania,60,60,5,3,-1,0,01:00,10,4,-1,0,00:00
-742,Europe/Tirane,1981,Albania,60,60,4,26,-1,0,01:00,9,27,-1,0,00:00
-743,Europe/Tirane,1982,Albania,60,60,5,2,-1,0,01:00,10,3,-1,0,00:00
-744,Europe/Tirane,1983,Albania,60,60,4,18,-1,0,01:00,10,1,-1,0,00:00
-745,Europe/Tirane,1984,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-746,Europe/Tirane,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-747,Europe/Andorra,1970,,60,0,0,0,0,0,,0,0,0,0,
-748,Europe/Andorra,1985,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-749,Europe/Andorra,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-750,Europe/Vienna,1970,Austria,60,60,4,18,-1,0,03:00,10,1,0,0,03:00
-751,Europe/Vienna,1980,Austria,60,60,4,6,-1,0,01:00,9,28,-1,0,00:00
-752,Europe/Vienna,1981,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-753,Europe/Vienna,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-754,Europe/Minsk,1970,Russia,180,60,9,1,-1,0,03:00,10,1,-1,0,02:00
-755,Europe/Minsk,1981,Russia,180,60,4,1,-1,0,03:00,10,1,-1,0,02:00
-756,Europe/Minsk,1984,Russia,180,60,4,1,-1,0,03:00,9,-1,0,0,05:00
-757,Europe/Minsk,1985,Russia,180,60,3,-1,0,0,05:00,9,-1,0,0,05:00
-758,Europe/Minsk,1990,,180,0,0,0,0,0,,0,0,0,0,
-759,Europe/Minsk,1991,,120,0,0,0,0,0,,0,0,0,0,
-760,Europe/Minsk,1992,Russia,120,60,3,-1,6,0,25:00,9,-1,6,0,24:00
-761,Europe/Minsk,1993,Russia,120,60,3,-1,0,0,04:00,9,-1,0,0,04:00
-762,Europe/Minsk,1996,Russia,120,60,3,-1,0,0,04:00,10,-1,0,0,04:00
-763,Europe/Brussels,1970,Belgium,60,0,5,19,-1,0,03:00,10,7,-1,0,03:00
-764,Europe/Brussels,1977,EU,60,60,4,1,0,0,1:00,9,-1,0,0,1:00
-765,Europe/Brussels,1978,EU,60,60,4,1,0,0,1:00,10,1,-1,0,1:00
-766,Europe/Brussels,1979,EU,60,60,4,1,0,0,1:00,9,-1,0,0,1:00
-767,Europe/Brussels,1981,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-768,Europe/Brussels,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-769,Europe/Sofia,1970,,120,0,0,0,0,0,,0,0,0,0,
-770,Europe/Sofia,1979,Bulg,120,60,3,31,-1,0,25:00,10,1,-1,0,02:00
-771,Europe/Sofia,1980,Bulg,120,60,4,1,6,0,25:00,9,29,-1,0,02:00
-772,Europe/Sofia,1981,Bulg,120,60,4,1,6,0,25:00,9,27,-1,0,03:00
-773,Europe/Sofia,1982,C-Eur,120,60,3,-1,0,0,04:00,9,-1,0,0,04:00
-774,Europe/Sofia,1991,E-Eur,120,60,3,-1,0,0,02:00,9,-1,0,0,01:00
-775,Europe/Sofia,1996,E-Eur,120,60,3,-1,0,0,02:00,10,-1,0,0,01:00
-776,Europe/Sofia,1997,EU,120,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-777,Europe/Prague,1970,Czech,60,0,4,9,-1,0,03:00,10,1,0,0,03:00
-778,Europe/Prague,1979,EU,60,60,4,1,0,0,1:00,9,-1,0,0,1:00
-779,Europe/Prague,1981,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-780,Europe/Prague,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-781,Europe/Copenhagen,1970,Denmark,60,0,5,9,-1,0,03:00,8,8,-1,0,03:00
-782,Europe/Copenhagen,1980,EU,60,60,4,1,0,0,1:00,9,-1,0,0,1:00
-783,Europe/Copenhagen,1981,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-784,Europe/Copenhagen,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-785,Atlantic/Faroe,1970,,0,0,0,0,0,0,,0,0,0,0,
-786,Atlantic/Faroe,1981,EU,0,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-787,Atlantic/Faroe,1996,EU,0,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-788,America/Danmarkshavn,1970,,-180,0,0,0,0,0,,0,0,0,0,
-789,America/Danmarkshavn,1980,EU,-180,60,4,1,0,0,1:00,9,-1,0,0,1:00
-790,America/Danmarkshavn,1981,EU,-180,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-791,America/Danmarkshavn,1996,,0,0,0,0,0,0,,0,0,0,0,
-792,America/Scoresbysund,1970,,-120,0,0,0,0,0,,0,0,0,0,
-793,America/Scoresbysund,1980,C-Eur,-120,60,4,1,0,0,00:00,9,-1,0,0,00:00
-794,America/Scoresbysund,1981,EU,-60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-795,America/Scoresbysund,1996,EU,-60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-796,America/Godthab,1970,,-180,0,0,0,0,0,,0,0,0,0,
-797,America/Godthab,1980,EU,-180,60,4,1,0,0,1:00,9,-1,0,0,1:00
-798,America/Godthab,1981,EU,-180,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-799,America/Godthab,1996,EU,-180,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-800,America/Thule,1970,Thule,-240,0,0,0,0,0,,0,0,0,0,
-801,America/Thule,1991,Thule,-240,60,3,-1,0,0,-2:00,9,-1,0,0,-3:00
-802,America/Thule,1993,Thule,-240,60,4,1,0,0,-2:00,10,-1,0,0,-3:00
-803,America/Thule,2007,Thule,-240,60,3,8,0,0,-2:00,11,1,0,0,-3:00
-804,Europe/Tallinn,1970,Russia,180,60,9,1,-1,0,03:00,10,1,-1,0,02:00
-805,Europe/Tallinn,1981,Russia,180,60,4,1,-1,0,03:00,10,1,-1,0,02:00
-806,Europe/Tallinn,1984,Russia,180,60,4,1,-1,0,03:00,9,-1,0,0,05:00
-807,Europe/Tallinn,1985,Russia,180,60,3,-1,0,0,05:00,9,-1,0,0,05:00
-808,Europe/Tallinn,1989,C-Eur,120,60,3,-1,0,0,04:00,9,-1,0,0,04:00
-809,Europe/Tallinn,1996,C-Eur,120,60,3,-1,0,0,04:00,10,-1,0,0,04:00
-810,Europe/Tallinn,1998,EU,120,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-811,Europe/Tallinn,1999,,120,0,0,0,0,0,,0,0,0,0,
-812,Europe/Tallinn,2002,EU,120,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-813,Europe/Helsinki,1970,Finland,120,0,4,3,-1,0,02:00,10,3,-1,0,01:00
-814,Europe/Helsinki,1981,EU,120,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-815,Europe/Helsinki,1996,EU,120,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-816,Europe/Paris,1970,France,60,120,4,2,-1,0,03:00,9,16,-1,0,03:00
-817,Europe/Paris,1976,France,60,60,3,28,-1,0,02:00,9,26,-1,0,01:00
-818,Europe/Paris,1977,EU,60,60,4,1,0,0,1:00,9,-1,0,0,1:00
-819,Europe/Paris,1978,EU,60,60,4,1,0,0,1:00,10,1,-1,0,1:00
-820,Europe/Paris,1979,EU,60,60,4,1,0,0,1:00,9,-1,0,0,1:00
-821,Europe/Paris,1981,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-822,Europe/Paris,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-823,Europe/Berlin,1970,Germany,60,0,4,10,-1,0,03:00,10,1,0,0,03:00
-824,Europe/Berlin,1980,EU,60,60,4,1,0,0,1:00,9,-1,0,0,1:00
-825,Europe/Berlin,1981,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-826,Europe/Berlin,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-827,Europe/Gibraltar,1970,,60,0,0,0,0,0,,0,0,0,0,
-828,Europe/Gibraltar,1982,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-829,Europe/Gibraltar,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-830,Europe/Athens,1970,Greece,120,60,7,1,-1,0,02:00,11,2,-1,0,01:00
-831,Europe/Athens,1975,Greece,120,60,4,12,-1,0,02:00,11,26,-1,0,02:00
-832,Europe/Athens,1976,Greece,120,60,4,11,-1,0,04:00,10,10,-1,0,04:00
-833,Europe/Athens,1977,Greece,120,60,4,1,0,0,04:00,9,26,-1,0,04:00
-834,Europe/Athens,1978,Greece,120,60,4,1,0,0,04:00,9,24,-1,0,05:00
-835,Europe/Athens,1979,Greece,120,60,4,1,-1,0,11:00,9,29,-1,0,03:00
-836,Europe/Athens,1980,Greece,120,60,4,1,-1,0,02:00,9,28,-1,0,01:00
-837,Europe/Athens,1981,EU,120,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-838,Europe/Athens,1996,EU,120,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-839,Europe/Budapest,1970,Hungary,60,60,6,1,0,0,02:00,9,-1,0,0,03:00
-840,Europe/Budapest,1980,EU,60,60,4,1,0,0,1:00,9,-1,0,0,1:00
-841,Europe/Budapest,1981,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-842,Europe/Budapest,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-843,Atlantic/Reykjavik,1970,,0,0,0,0,0,0,,0,0,0,0,
-844,Europe/Rome,1970,Italy,60,60,5,31,-1,0,01:00,9,-1,0,0,00:00
-845,Europe/Rome,1971,Italy,60,60,5,22,0,0,01:00,9,-1,0,0,01:00
-846,Europe/Rome,1972,Italy,60,60,5,22,0,0,01:00,10,1,-1,0,00:00
-847,Europe/Rome,1973,Italy,60,60,6,3,-1,0,01:00,9,-1,0,0,00:00
-848,Europe/Rome,1974,Italy,60,60,5,26,-1,0,01:00,9,-1,0,0,00:00
-849,Europe/Rome,1975,Italy,60,60,6,1,-1,0,01:00,9,-1,0,0,01:00
-850,Europe/Rome,1976,Italy,60,60,5,30,-1,0,01:00,9,-1,0,0,01:00
-851,Europe/Rome,1977,Italy,60,60,5,22,0,0,01:00,9,-1,0,0,01:00
-852,Europe/Rome,1978,Italy,60,60,5,22,0,0,01:00,10,1,-1,0,01:00
-853,Europe/Rome,1979,Italy,60,60,5,22,0,0,01:00,9,30,-1,0,01:00
-854,Europe/Rome,1980,EU,60,60,4,1,0,0,1:00,9,-1,0,0,1:00
-855,Europe/Rome,1981,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-856,Europe/Rome,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-857,Europe/Riga,1970,Russia,180,60,9,1,-1,0,03:00,10,1,-1,0,02:00
-858,Europe/Riga,1981,Russia,180,60,4,1,-1,0,03:00,10,1,-1,0,02:00
-859,Europe/Riga,1984,Russia,180,60,4,1,-1,0,03:00,9,-1,0,0,05:00
-860,Europe/Riga,1985,Russia,180,60,3,-1,0,0,05:00,9,-1,0,0,05:00
-861,Europe/Riga,1989,Latvia,120,60,3,-1,0,0,04:00,9,-1,0,0,04:00
-862,Europe/Riga,1996,Latvia,120,0,3,-1,0,0,04:00,9,-1,0,0,04:00
-863,Europe/Riga,1997,EU,120,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-864,Europe/Riga,2000,,120,0,0,0,0,0,,0,0,0,0,
-865,Europe/Riga,2001,EU,120,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-866,Europe/Vaduz,1970,,60,0,0,0,0,0,,0,0,0,0,
-867,Europe/Vaduz,1981,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-868,Europe/Vaduz,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-869,Europe/Vilnius,1970,Russia,180,60,9,1,-1,0,03:00,10,1,-1,0,02:00
-870,Europe/Vilnius,1981,Russia,180,60,4,1,-1,0,03:00,10,1,-1,0,02:00
-871,Europe/Vilnius,1984,Russia,180,60,4,1,-1,0,03:00,9,-1,0,0,05:00
-872,Europe/Vilnius,1985,Russia,180,60,3,-1,0,0,05:00,9,-1,0,0,05:00
-873,Europe/Vilnius,1991,C-Eur,120,60,3,-1,0,0,04:00,9,-1,0,0,04:00
-874,Europe/Vilnius,1996,C-Eur,120,60,3,-1,0,0,04:00,10,-1,0,0,04:00
-875,Europe/Vilnius,1998,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-876,Europe/Vilnius,1999,,120,0,0,0,0,0,,0,0,0,0,
-877,Europe/Vilnius,2003,EU,120,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-878,Europe/Luxembourg,1970,Belgium,60,0,5,19,-1,0,03:00,10,7,-1,0,03:00
-879,Europe/Luxembourg,1977,EU,60,60,4,1,0,0,1:00,9,-1,0,0,1:00
-880,Europe/Luxembourg,1978,EU,60,60,4,1,0,0,1:00,10,1,-1,0,1:00
-881,Europe/Luxembourg,1979,EU,60,60,4,1,0,0,1:00,9,-1,0,0,1:00
-882,Europe/Luxembourg,1981,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-883,Europe/Luxembourg,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-884,Europe/Malta,1970,Italy,60,60,5,31,-1,0,01:00,9,-1,0,0,00:00
-885,Europe/Malta,1971,Italy,60,60,5,22,0,0,01:00,9,-1,0,0,01:00
-886,Europe/Malta,1972,Italy,60,60,5,22,0,0,01:00,10,1,-1,0,00:00
-887,Europe/Malta,1973,Malta,60,60,3,31,-1,0,01:00,9,29,-1,0,01:00
-888,Europe/Malta,1974,Malta,60,60,4,21,-1,0,01:00,9,16,-1,0,01:00
-889,Europe/Malta,1975,Malta,60,60,4,15,0,0,03:00,9,15,0,0,02:00
-890,Europe/Malta,1980,Malta,60,0,3,31,-1,0,03:00,9,15,0,0,02:00
-891,Europe/Malta,1981,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-892,Europe/Malta,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-893,Europe/Chisinau,1970,Russia,180,60,9,1,-1,0,03:00,10,1,-1,0,02:00
-894,Europe/Chisinau,1981,Russia,180,60,4,1,-1,0,03:00,10,1,-1,0,02:00
-895,Europe/Chisinau,1984,Russia,180,60,4,1,-1,0,03:00,9,-1,0,0,05:00
-896,Europe/Chisinau,1985,Russia,180,60,3,-1,0,0,05:00,9,-1,0,0,05:00
-897,Europe/Chisinau,1990,,120,0,0,0,0,0,,0,0,0,0,
-898,Europe/Chisinau,1991,Russia,120,60,3,-1,0,0,04:00,9,-1,0,0,04:00
-899,Europe/Chisinau,1992,E-Eur,120,60,3,-1,0,0,02:00,9,-1,0,0,01:00
-900,Europe/Chisinau,1996,E-Eur,120,60,3,-1,0,0,02:00,10,-1,0,0,01:00
-901,Europe/Chisinau,1997,EU,120,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-902,Europe/Monaco,1970,France,60,120,4,2,-1,0,03:00,9,16,-1,0,03:00
-903,Europe/Monaco,1976,France,60,60,3,28,-1,0,02:00,9,26,-1,0,01:00
-904,Europe/Monaco,1977,EU,60,60,4,1,0,0,1:00,9,-1,0,0,1:00
-905,Europe/Monaco,1978,EU,60,60,4,1,0,0,1:00,10,1,-1,0,1:00
-906,Europe/Monaco,1979,EU,60,60,4,1,0,0,1:00,9,-1,0,0,1:00
-907,Europe/Monaco,1981,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-908,Europe/Monaco,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-909,Europe/Amsterdam,1970,Neth,60,0,4,2,-1,0,03:00,9,16,-1,0,03:00
-910,Europe/Amsterdam,1977,EU,60,60,4,1,0,0,1:00,9,-1,0,0,1:00
-911,Europe/Amsterdam,1978,EU,60,60,4,1,0,0,1:00,10,1,-1,0,1:00
-912,Europe/Amsterdam,1979,EU,60,60,4,1,0,0,1:00,9,-1,0,0,1:00
-913,Europe/Amsterdam,1981,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-914,Europe/Amsterdam,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-915,Europe/Oslo,1970,Norway,60,0,4,25,-1,0,03:00,9,15,0,0,03:00
-916,Europe/Oslo,1980,EU,60,60,4,1,0,0,1:00,9,-1,0,0,1:00
-917,Europe/Oslo,1981,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-918,Europe/Oslo,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-919,Europe/Warsaw,1970,Poland,60,0,5,-1,0,0,02:00,9,-1,0,0,02:00
-920,Europe/Warsaw,1977,W-Eur,60,60,4,1,0,0,02:00,9,-1,0,0,02:00
-921,Europe/Warsaw,1978,W-Eur,60,60,4,1,0,0,02:00,10,1,-1,0,02:00
-922,Europe/Warsaw,1979,W-Eur,60,60,4,1,0,0,02:00,9,-1,0,0,02:00
-923,Europe/Warsaw,1981,W-Eur,60,60,3,-1,0,0,02:00,9,-1,0,0,02:00
-924,Europe/Warsaw,1988,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-925,Europe/Warsaw,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-926,Europe/Lisbon,1970,,60,0,0,0,0,0,,0,0,0,0,
-927,Europe/Lisbon,1976,Port,0,0,0,0,0,0,,0,0,0,0,
-928,Europe/Lisbon,1977,Port,0,60,3,27,-1,0,00:00,9,25,-1,0,00:00
-929,Europe/Lisbon,1978,Port,0,60,4,1,0,0,00:00,10,1,-1,0,00:00
-930,Europe/Lisbon,1979,Port,0,60,4,1,0,0,00:00,9,-1,0,0,01:00
-931,Europe/Lisbon,1980,Port,0,60,3,-1,0,0,00:00,9,-1,0,0,01:00
-932,Europe/Lisbon,1981,Port,0,60,3,-1,0,0,01:00,9,-1,0,0,01:00
-933,Europe/Lisbon,1983,W-Eur,0,60,3,-1,0,0,01:00,9,-1,0,0,01:00
-934,Europe/Lisbon,1992,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-935,Europe/Lisbon,1996,EU,0,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-936,Atlantic/Azores,1970,Port,-60,60,4,1,0,0,01:00,10,1,0,0,01:00
-937,Atlantic/Azores,1977,Port,-60,60,3,27,-1,0,-1:00,9,25,-1,0,-1:00
-938,Atlantic/Azores,1978,Port,-60,60,4,1,0,0,-1:00,10,1,-1,0,-1:00
-939,Atlantic/Azores,1979,Port,-60,60,4,1,0,0,-1:00,9,-1,0,0,00:00
-940,Atlantic/Azores,1980,Port,-60,60,3,-1,0,0,-1:00,9,-1,0,0,00:00
-941,Atlantic/Azores,1981,Port,-60,60,3,-1,0,0,00:00,9,-1,0,0,00:00
-942,Atlantic/Azores,1983,W-Eur,-60,60,3,-1,0,0,00:00,9,-1,0,0,00:00
-943,Atlantic/Azores,1992,EU,0,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-944,Atlantic/Azores,1993,EU,-60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-945,Atlantic/Azores,1996,EU,-60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-946,Atlantic/Madeira,1970,Port,0,60,4,1,0,0,02:00,10,1,0,0,02:00
-947,Atlantic/Madeira,1977,Port,0,60,3,27,-1,0,00:00,9,25,-1,0,00:00
-948,Atlantic/Madeira,1978,Port,0,60,4,1,0,0,00:00,10,1,-1,0,00:00
-949,Atlantic/Madeira,1979,Port,0,60,4,1,0,0,00:00,9,-1,0,0,01:00
-950,Atlantic/Madeira,1980,Port,0,60,3,-1,0,0,00:00,9,-1,0,0,01:00
-951,Atlantic/Madeira,1981,Port,0,60,3,-1,0,0,01:00,9,-1,0,0,01:00
-952,Atlantic/Madeira,1983,EU,0,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-953,Atlantic/Madeira,1996,EU,0,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-954,Europe/Bucharest,1970,Romania,120,60,4,2,0,0,02:00,10,1,0,0,02:00
-955,Europe/Bucharest,1979,Romania,120,60,5,27,-1,0,02:00,9,-1,0,0,01:00
-956,Europe/Bucharest,1980,Romania,120,60,4,5,-1,0,25:00,9,-1,0,0,02:00
-957,Europe/Bucharest,1981,C-Eur,120,60,3,-1,0,0,04:00,9,-1,0,0,04:00
-958,Europe/Bucharest,1991,Romania,120,60,3,-1,0,0,02:00,9,-1,0,0,02:00
-959,Europe/Bucharest,1993,Romania,120,0,3,-1,0,0,02:00,9,-1,0,0,02:00
-960,Europe/Bucharest,1994,E-Eur,120,60,3,-1,0,0,02:00,9,-1,0,0,01:00
-961,Europe/Bucharest,1996,E-Eur,120,60,3,-1,0,0,02:00,10,-1,0,0,01:00
-962,Europe/Bucharest,1997,EU,120,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-963,Europe/Kaliningrad,1970,Russia,180,60,9,1,-1,0,03:00,10,1,-1,0,02:00
-964,Europe/Kaliningrad,1981,Russia,180,60,4,1,-1,0,03:00,10,1,-1,0,02:00
-965,Europe/Kaliningrad,1984,Russia,180,60,4,1,-1,0,03:00,9,-1,0,0,05:00
-966,Europe/Kaliningrad,1985,Russia,180,60,3,-1,0,0,05:00,9,-1,0,0,05:00
-967,Europe/Kaliningrad,1991,Russia,120,60,3,-1,0,0,04:00,9,-1,0,0,04:00
-968,Europe/Kaliningrad,1992,Russia,120,60,3,-1,6,0,25:00,9,-1,6,0,24:00
-969,Europe/Kaliningrad,1993,Russia,120,60,3,-1,0,0,04:00,9,-1,0,0,04:00
-970,Europe/Kaliningrad,1996,Russia,120,60,3,-1,0,0,04:00,10,-1,0,0,04:00
-971,Europe/Moscow,1970,Russia,180,60,9,1,-1,0,03:00,10,1,-1,0,02:00
-972,Europe/Moscow,1981,Russia,180,60,4,1,-1,0,03:00,10,1,-1,0,02:00
-973,Europe/Moscow,1984,Russia,180,60,4,1,-1,0,03:00,9,-1,0,0,05:00
-974,Europe/Moscow,1985,Russia,180,60,3,-1,0,0,05:00,9,-1,0,0,05:00
-975,Europe/Moscow,1991,Russia,120,60,3,-1,0,0,04:00,9,-1,0,0,04:00
-976,Europe/Moscow,1992,Russia,180,60,3,-1,6,0,26:00,9,-1,6,0,25:00
-977,Europe/Moscow,1993,Russia,180,60,3,-1,0,0,05:00,9,-1,0,0,05:00
-978,Europe/Moscow,1996,Russia,180,60,3,-1,0,0,05:00,10,-1,0,0,05:00
-979,Europe/Volgograd,1970,Russia,240,60,9,1,-1,0,04:00,10,1,-1,0,03:00
-980,Europe/Volgograd,1981,Russia,240,60,4,1,-1,0,04:00,10,1,-1,0,03:00
-981,Europe/Volgograd,1984,Russia,240,60,4,1,-1,0,04:00,9,-1,0,0,06:00
-982,Europe/Volgograd,1985,Russia,240,60,3,-1,0,0,06:00,9,-1,0,0,06:00
-983,Europe/Volgograd,1989,Russia,180,60,3,-1,0,0,05:00,9,-1,0,0,05:00
-984,Europe/Volgograd,1991,,240,0,0,0,0,0,,0,0,0,0,
-985,Europe/Volgograd,1992,Russia,180,60,3,-1,6,0,26:00,9,-1,6,0,25:00
-986,Europe/Volgograd,1993,Russia,180,60,3,-1,0,0,05:00,9,-1,0,0,05:00
-987,Europe/Volgograd,1996,Russia,180,60,3,-1,0,0,05:00,10,-1,0,0,05:00
-988,Europe/Samara,1970,Russia,240,60,9,1,-1,0,04:00,10,1,-1,0,03:00
-989,Europe/Samara,1981,Russia,240,60,4,1,-1,0,04:00,10,1,-1,0,03:00
-990,Europe/Samara,1984,Russia,240,60,4,1,-1,0,04:00,9,-1,0,0,06:00
-991,Europe/Samara,1985,Russia,240,60,3,-1,0,0,06:00,9,-1,0,0,06:00
-992,Europe/Samara,1989,Russia,180,60,3,-1,0,0,05:00,9,-1,0,0,05:00
-993,Europe/Samara,1991,Russia,240,60,3,-1,0,0,06:00,9,-1,0,0,06:00
-994,Europe/Samara,1992,Russia,240,60,3,-1,6,0,27:00,9,-1,6,0,26:00
-995,Europe/Samara,1993,Russia,240,60,3,-1,0,0,06:00,9,-1,0,0,06:00
-996,Europe/Samara,1996,Russia,240,60,3,-1,0,0,06:00,10,-1,0,0,06:00
-997,Asia/Yekaterinburg,1970,Russia,300,60,9,1,-1,0,05:00,10,1,-1,0,04:00
-998,Asia/Yekaterinburg,1981,Russia,300,60,4,1,-1,0,05:00,10,1,-1,0,04:00
-999,Asia/Yekaterinburg,1984,Russia,300,60,4,1,-1,0,05:00,9,-1,0,0,07:00
-1000,Asia/Yekaterinburg,1985,Russia,300,60,3,-1,0,0,07:00,9,-1,0,0,07:00
-1001,Asia/Yekaterinburg,1991,Russia,240,60,3,-1,0,0,06:00,9,-1,0,0,06:00
-1002,Asia/Yekaterinburg,1992,Russia,300,60,3,-1,6,0,28:00,9,-1,6,0,27:00
-1003,Asia/Yekaterinburg,1993,Russia,300,60,3,-1,0,0,07:00,9,-1,0,0,07:00
-1004,Asia/Yekaterinburg,1996,Russia,300,60,3,-1,0,0,07:00,10,-1,0,0,07:00
-1005,Asia/Omsk,1970,Russia,360,60,9,1,-1,0,06:00,10,1,-1,0,05:00
-1006,Asia/Omsk,1981,Russia,360,60,4,1,-1,0,06:00,10,1,-1,0,05:00
-1007,Asia/Omsk,1984,Russia,360,60,4,1,-1,0,06:00,9,-1,0,0,08:00
-1008,Asia/Omsk,1985,Russia,360,60,3,-1,0,0,08:00,9,-1,0,0,08:00
-1009,Asia/Omsk,1991,Russia,300,60,3,-1,0,0,07:00,9,-1,0,0,07:00
-1010,Asia/Omsk,1992,Russia,360,60,3,-1,6,0,29:00,9,-1,6,0,28:00
-1011,Asia/Omsk,1993,Russia,360,60,3,-1,0,0,08:00,9,-1,0,0,08:00
-1012,Asia/Omsk,1996,Russia,360,60,3,-1,0,0,08:00,10,-1,0,0,08:00
-1013,Asia/Novosibirsk,1970,Russia,420,60,9,1,-1,0,07:00,10,1,-1,0,06:00
-1014,Asia/Novosibirsk,1981,Russia,420,60,4,1,-1,0,07:00,10,1,-1,0,06:00
-1015,Asia/Novosibirsk,1984,Russia,420,60,4,1,-1,0,07:00,9,-1,0,0,09:00
-1016,Asia/Novosibirsk,1985,Russia,420,60,3,-1,0,0,09:00,9,-1,0,0,09:00
-1017,Asia/Novosibirsk,1991,Russia,360,60,3,-1,0,0,08:00,9,-1,0,0,08:00
-1018,Asia/Novosibirsk,1992,Russia,420,60,3,-1,6,0,30:00,9,-1,6,0,29:00
-1019,Asia/Novosibirsk,1993,Russia,360,60,3,-1,0,0,08:00,9,-1,0,0,08:00
-1020,Asia/Novosibirsk,1996,Russia,360,60,3,-1,0,0,08:00,10,-1,0,0,08:00
-1021,Asia/Krasnoyarsk,1970,Russia,420,60,9,1,-1,0,07:00,10,1,-1,0,06:00
-1022,Asia/Krasnoyarsk,1981,Russia,420,60,4,1,-1,0,07:00,10,1,-1,0,06:00
-1023,Asia/Krasnoyarsk,1984,Russia,420,60,4,1,-1,0,07:00,9,-1,0,0,09:00
-1024,Asia/Krasnoyarsk,1985,Russia,420,60,3,-1,0,0,09:00,9,-1,0,0,09:00
-1025,Asia/Krasnoyarsk,1991,Russia,360,60,3,-1,0,0,08:00,9,-1,0,0,08:00
-1026,Asia/Krasnoyarsk,1992,Russia,420,60,3,-1,6,0,30:00,9,-1,6,0,29:00
-1027,Asia/Krasnoyarsk,1993,Russia,420,60,3,-1,0,0,09:00,9,-1,0,0,09:00
-1028,Asia/Krasnoyarsk,1996,Russia,420,60,3,-1,0,0,09:00,10,-1,0,0,09:00
-1029,Asia/Irkutsk,1970,Russia,480,60,9,1,-1,0,08:00,10,1,-1,0,07:00
-1030,Asia/Irkutsk,1981,Russia,480,60,4,1,-1,0,08:00,10,1,-1,0,07:00
-1031,Asia/Irkutsk,1984,Russia,480,60,4,1,-1,0,08:00,9,-1,0,0,10:00
-1032,Asia/Irkutsk,1985,Russia,480,60,3,-1,0,0,10:00,9,-1,0,0,10:00
-1033,Asia/Irkutsk,1991,Russia,420,60,3,-1,0,0,09:00,9,-1,0,0,09:00
-1034,Asia/Irkutsk,1992,Russia,480,60,3,-1,6,0,31:00,9,-1,6,0,30:00
-1035,Asia/Irkutsk,1993,Russia,480,60,3,-1,0,0,10:00,9,-1,0,0,10:00
-1036,Asia/Irkutsk,1996,Russia,480,60,3,-1,0,0,10:00,10,-1,0,0,10:00
-1037,Asia/Yakutsk,1970,Russia,540,60,9,1,-1,0,09:00,10,1,-1,0,08:00
-1038,Asia/Yakutsk,1981,Russia,540,60,4,1,-1,0,09:00,10,1,-1,0,08:00
-1039,Asia/Yakutsk,1984,Russia,540,60,4,1,-1,0,09:00,9,-1,0,0,11:00
-1040,Asia/Yakutsk,1985,Russia,540,60,3,-1,0,0,11:00,9,-1,0,0,11:00
-1041,Asia/Yakutsk,1991,Russia,480,60,3,-1,0,0,10:00,9,-1,0,0,10:00
-1042,Asia/Yakutsk,1992,Russia,540,60,3,-1,6,0,32:00,9,-1,6,0,31:00
-1043,Asia/Yakutsk,1993,Russia,540,60,3,-1,0,0,11:00,9,-1,0,0,11:00
-1044,Asia/Yakutsk,1996,Russia,540,60,3,-1,0,0,11:00,10,-1,0,0,11:00
-1045,Asia/Vladivostok,1970,Russia,600,60,9,1,-1,0,10:00,10,1,-1,0,09:00
-1046,Asia/Vladivostok,1981,Russia,600,60,4,1,-1,0,10:00,10,1,-1,0,09:00
-1047,Asia/Vladivostok,1984,Russia,600,60,4,1,-1,0,10:00,9,-1,0,0,12:00
-1048,Asia/Vladivostok,1985,Russia,600,60,3,-1,0,0,12:00,9,-1,0,0,12:00
-1049,Asia/Vladivostok,1991,Russia,540,60,3,-1,0,0,11:00,9,-1,0,0,11:00
-1050,Asia/Vladivostok,1992,Russia,600,60,3,-1,6,0,33:00,9,-1,6,0,32:00
-1051,Asia/Vladivostok,1993,Russia,600,60,3,-1,0,0,12:00,9,-1,0,0,12:00
-1052,Asia/Vladivostok,1996,Russia,600,60,3,-1,0,0,12:00,10,-1,0,0,12:00
-1053,Asia/Sakhalin,1970,Russia,660,60,9,1,-1,0,11:00,10,1,-1,0,10:00
-1054,Asia/Sakhalin,1981,Russia,660,60,4,1,-1,0,11:00,10,1,-1,0,10:00
-1055,Asia/Sakhalin,1984,Russia,660,60,4,1,-1,0,11:00,9,-1,0,0,13:00
-1056,Asia/Sakhalin,1985,Russia,660,60,3,-1,0,0,13:00,9,-1,0,0,13:00
-1057,Asia/Sakhalin,1991,Russia,600,60,3,-1,0,0,12:00,9,-1,0,0,12:00
-1058,Asia/Sakhalin,1992,Russia,660,60,3,-1,6,0,34:00,9,-1,6,0,33:00
-1059,Asia/Sakhalin,1993,Russia,660,60,3,-1,0,0,13:00,9,-1,0,0,13:00
-1060,Asia/Sakhalin,1996,Russia,660,60,3,-1,0,0,13:00,10,-1,0,0,13:00
-1061,Asia/Sakhalin,1997,Russia,600,60,3,-1,0,0,12:00,10,-1,0,0,12:00
-1062,Asia/Magadan,1970,Russia,660,60,9,1,-1,0,11:00,10,1,-1,0,10:00
-1063,Asia/Magadan,1981,Russia,660,60,4,1,-1,0,11:00,10,1,-1,0,10:00
-1064,Asia/Magadan,1984,Russia,660,60,4,1,-1,0,11:00,9,-1,0,0,13:00
-1065,Asia/Magadan,1985,Russia,660,60,3,-1,0,0,13:00,9,-1,0,0,13:00
-1066,Asia/Magadan,1991,Russia,600,60,3,-1,0,0,12:00,9,-1,0,0,12:00
-1067,Asia/Magadan,1992,Russia,660,60,3,-1,6,0,34:00,9,-1,6,0,33:00
-1068,Asia/Magadan,1993,Russia,660,60,3,-1,0,0,13:00,9,-1,0,0,13:00
-1069,Asia/Magadan,1996,Russia,660,60,3,-1,0,0,13:00,10,-1,0,0,13:00
-1070,Asia/Kamchatka,1970,Russia,720,60,9,1,-1,0,12:00,10,1,-1,0,11:00
-1071,Asia/Kamchatka,1981,Russia,720,60,4,1,-1,0,12:00,10,1,-1,0,11:00
-1072,Asia/Kamchatka,1984,Russia,720,60,4,1,-1,0,12:00,9,-1,0,0,14:00
-1073,Asia/Kamchatka,1985,Russia,720,60,3,-1,0,0,14:00,9,-1,0,0,14:00
-1074,Asia/Kamchatka,1991,Russia,660,60,3,-1,0,0,13:00,9,-1,0,0,13:00
-1075,Asia/Kamchatka,1992,Russia,720,60,3,-1,6,0,35:00,9,-1,6,0,34:00
-1076,Asia/Kamchatka,1993,Russia,720,60,3,-1,0,0,14:00,9,-1,0,0,14:00
-1077,Asia/Kamchatka,1996,Russia,720,60,3,-1,0,0,14:00,10,-1,0,0,14:00
-1078,Asia/Anadyr,1970,Russia,780,60,9,1,-1,0,13:00,10,1,-1,0,12:00
-1079,Asia/Anadyr,1981,Russia,780,60,4,1,-1,0,13:00,10,1,-1,0,12:00
-1080,Asia/Anadyr,1982,Russia,720,60,4,1,-1,0,12:00,10,1,-1,0,11:00
-1081,Asia/Anadyr,1984,Russia,720,60,4,1,-1,0,12:00,9,-1,0,0,14:00
-1082,Asia/Anadyr,1985,Russia,720,60,3,-1,0,0,14:00,9,-1,0,0,14:00
-1083,Asia/Anadyr,1991,Russia,660,60,3,-1,0,0,13:00,9,-1,0,0,13:00
-1084,Asia/Anadyr,1992,Russia,720,60,3,-1,6,0,35:00,9,-1,6,0,34:00
-1085,Asia/Anadyr,1993,Russia,720,60,3,-1,0,0,14:00,9,-1,0,0,14:00
-1086,Asia/Anadyr,1996,Russia,720,60,3,-1,0,0,14:00,10,-1,0,0,14:00
-1087,Europe/Belgrade,1970,,60,0,0,0,0,0,,0,0,0,0,
-1088,Europe/Belgrade,1982,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-1089,Europe/Belgrade,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-1090,Europe/Madrid,1970,Spain,60,60,4,30,-1,0,24:00,9,30,-1,0,01:00
-1091,Europe/Madrid,1974,Spain,60,60,4,13,6,0,24:00,10,1,0,0,01:00
-1092,Europe/Madrid,1976,Spain,60,60,3,27,-1,0,24:00,9,-1,0,0,01:00
-1093,Europe/Madrid,1977,Spain,60,60,4,2,-1,0,24:00,9,-1,0,0,01:00
-1094,Europe/Madrid,1978,Spain,60,60,4,2,-1,0,24:00,10,1,-1,0,01:00
-1095,Europe/Madrid,1979,EU,60,60,4,1,0,0,1:00,9,-1,0,0,1:00
-1096,Europe/Madrid,1981,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-1097,Europe/Madrid,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-1098,Africa/Ceuta,1970,SpainAfrica,0,60,6,3,-1,0,12:00,10,1,-1,0,-1:00
-1099,Africa/Ceuta,1974,SpainAfrica,0,60,6,24,-1,0,00:00,9,1,-1,0,-1:00
-1100,Africa/Ceuta,1976,SpainAfrica,0,60,5,1,-1,0,00:00,8,1,-1,0,-1:00
-1101,Africa/Ceuta,1977,SpainAfrica,0,60,5,1,-1,0,00:00,9,28,-1,0,-1:00
-1102,Africa/Ceuta,1978,SpainAfrica,0,60,6,1,-1,0,00:00,8,4,-1,0,-1:00
-1103,Africa/Ceuta,1979,SpainAfrica,0,0,6,1,-1,0,00:00,8,4,-1,0,-1:00
-1104,Africa/Ceuta,1984,,60,0,0,0,0,0,,0,0,0,0,
-1105,Africa/Ceuta,1986,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-1106,Africa/Ceuta,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-1107,Atlantic/Canary,1970,,0,0,0,0,0,0,,0,0,0,0,
-1108,Atlantic/Canary,1980,EU,0,60,4,1,0,0,1:00,9,-1,0,0,1:00
-1109,Atlantic/Canary,1981,EU,0,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-1110,Atlantic/Canary,1996,EU,0,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-1111,Europe/Stockholm,1970,,60,0,0,0,0,0,,0,0,0,0,
-1112,Europe/Stockholm,1980,EU,60,60,4,1,0,0,1:00,9,-1,0,0,1:00
-1113,Europe/Stockholm,1981,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-1114,Europe/Stockholm,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-1115,Europe/Zurich,1970,Swiss,60,0,5,1,0,0,03:00,10,1,0,0,00:00
-1116,Europe/Zurich,1981,EU,60,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-1117,Europe/Zurich,1996,EU,60,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-1118,Europe/Istanbul,1970,Turkey,120,60,5,2,0,0,02:00,10,2,0,0,01:00
-1119,Europe/Istanbul,1973,Turkey,120,60,6,3,-1,0,03:00,11,4,-1,0,04:00
-1120,Europe/Istanbul,1974,Turkey,120,60,3,31,-1,0,04:00,11,3,-1,0,06:00
-1121,Europe/Istanbul,1975,Turkey,120,60,3,30,-1,0,02:00,10,-1,0,0,01:00
-1122,Europe/Istanbul,1976,Turkey,120,60,6,1,-1,0,02:00,10,-1,0,0,01:00
-1123,Europe/Istanbul,1977,Turkey,120,60,4,1,0,0,02:00,10,16,-1,0,01:00
-1124,Europe/Istanbul,1978,Turkey,180,60,4,1,0,0,03:00,1,1,-1,0,14:00
-1125,Europe/Istanbul,1979,Turkey,180,60,4,1,0,0,06:00,10,11,1,0,02:00
-1126,Europe/Istanbul,1981,Turkey,180,60,3,-1,0,0,06:00,10,11,1,0,02:00
-1127,Europe/Istanbul,1983,Turkey,180,60,7,31,-1,0,03:00,10,2,-1,0,02:00
-1128,Europe/Istanbul,1985,Turkey,120,60,4,20,-1,0,02:00,9,28,-1,0,01:00
-1129,Europe/Istanbul,1986,Turkey,120,60,3,-1,0,0,04:00,9,-1,0,0,04:00
-1130,Europe/Istanbul,1991,Turkey,120,60,3,-1,0,0,03:00,9,-1,0,0,03:00
-1131,Europe/Istanbul,1996,Turkey,120,60,3,-1,0,0,03:00,10,-1,0,0,03:00
-1132,Europe/Kiev,1970,Russia,180,60,9,1,-1,0,03:00,10,1,-1,0,02:00
-1133,Europe/Kiev,1981,Russia,180,60,4,1,-1,0,03:00,10,1,-1,0,02:00
-1134,Europe/Kiev,1984,Russia,180,60,4,1,-1,0,03:00,9,-1,0,0,05:00
-1135,Europe/Kiev,1985,Russia,180,60,3,-1,0,0,05:00,9,-1,0,0,05:00
-1136,Europe/Kiev,1990,,120,0,0,0,0,0,,0,0,0,0,
-1137,Europe/Kiev,1992,E-Eur,120,60,3,-1,0,0,02:00,9,-1,0,0,01:00
-1138,Europe/Kiev,1995,EU,120,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-1139,Europe/Kiev,1996,EU,120,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-1140,Europe/Uzhgorod,1970,Russia,180,60,9,1,-1,0,03:00,10,1,-1,0,02:00
-1141,Europe/Uzhgorod,1981,Russia,180,60,4,1,-1,0,03:00,10,1,-1,0,02:00
-1142,Europe/Uzhgorod,1984,Russia,180,60,4,1,-1,0,03:00,9,-1,0,0,05:00
-1143,Europe/Uzhgorod,1985,Russia,180,60,3,-1,0,0,05:00,9,-1,0,0,05:00
-1144,Europe/Uzhgorod,1990,,60,0,0,0,0,0,,0,0,0,0,
-1145,Europe/Uzhgorod,1991,,120,0,0,0,0,0,,0,0,0,0,
-1146,Europe/Uzhgorod,1992,E-Eur,120,60,3,-1,0,0,02:00,9,-1,0,0,01:00
-1147,Europe/Uzhgorod,1995,EU,120,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-1148,Europe/Uzhgorod,1996,EU,120,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-1149,Europe/Zaporozhye,1970,Russia,180,60,9,1,-1,0,03:00,10,1,-1,0,02:00
-1150,Europe/Zaporozhye,1981,Russia,180,60,4,1,-1,0,03:00,10,1,-1,0,02:00
-1151,Europe/Zaporozhye,1984,Russia,180,60,4,1,-1,0,03:00,9,-1,0,0,05:00
-1152,Europe/Zaporozhye,1985,Russia,180,60,3,-1,0,0,05:00,9,-1,0,0,05:00
-1153,Europe/Zaporozhye,1991,E-Eur,120,60,3,-1,0,0,02:00,9,-1,0,0,01:00
-1154,Europe/Zaporozhye,1995,EU,120,60,3,-1,0,0,1:00,9,-1,0,0,1:00
-1155,Europe/Zaporozhye,1996,EU,120,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-1156,Europe/Simferopol,1970,Russia,180,60,9,1,-1,0,03:00,10,1,-1,0,02:00
-1157,Europe/Simferopol,1981,Russia,180,60,4,1,-1,0,03:00,10,1,-1,0,02:00
-1158,Europe/Simferopol,1984,Russia,180,60,4,1,-1,0,03:00,9,-1,0,0,05:00
-1159,Europe/Simferopol,1985,Russia,180,60,3,-1,0,0,05:00,9,-1,0,0,05:00
-1160,Europe/Simferopol,1990,,120,0,0,0,0,0,,0,0,0,0,
-1161,Europe/Simferopol,1992,E-Eur,120,60,3,-1,0,0,02:00,9,-1,0,0,01:00
-1162,Europe/Simferopol,1994,E-Eur,180,60,3,-1,0,0,03:00,9,-1,0,0,02:00
-1163,Europe/Simferopol,1996,Russia,180,60,3,-1,0,0,05:00,10,-1,0,0,05:00
-1164,Europe/Simferopol,1997,EU,120,60,3,-1,0,0,1:00,10,-1,0,0,1:00
-1165,EST,1970,,-300,0,0,0,0,0,,0,0,0,0,
-1166,MST,1970,,-420,0,0,0,0,0,,0,0,0,0,
-1167,HST,1970,,-600,0,0,0,0,0,,0,0,0,0,
-1168,EST5EDT,1970,US,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1169,EST5EDT,1974,US,-300,60,1,6,-1,0,-3:00,10,-1,0,0,-4:00
-1170,EST5EDT,1975,US,-300,60,2,23,-1,0,-3:00,10,-1,0,0,-4:00
-1171,EST5EDT,1976,US,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1172,EST5EDT,1987,US,-300,60,4,1,0,0,-3:00,10,-1,0,0,-4:00
-1173,EST5EDT,2007,US,-300,60,3,8,0,0,-3:00,11,1,0,0,-4:00
-1174,CST6CDT,1970,US,-360,60,4,-1,0,0,-4:00,10,-1,0,0,-5:00
-1175,CST6CDT,1974,US,-360,60,1,6,-1,0,-4:00,10,-1,0,0,-5:00
-1176,CST6CDT,1975,US,-360,60,2,23,-1,0,-4:00,10,-1,0,0,-5:00
-1177,CST6CDT,1976,US,-360,60,4,-1,0,0,-4:00,10,-1,0,0,-5:00
-1178,CST6CDT,1987,US,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1179,CST6CDT,2007,US,-360,60,3,8,0,0,-4:00,11,1,0,0,-5:00
-1180,MST7MDT,1970,US,-420,60,4,-1,0,0,-5:00,10,-1,0,0,-6:00
-1181,MST7MDT,1974,US,-420,60,1,6,-1,0,-5:00,10,-1,0,0,-6:00
-1182,MST7MDT,1975,US,-420,60,2,23,-1,0,-5:00,10,-1,0,0,-6:00
-1183,MST7MDT,1976,US,-420,60,4,-1,0,0,-5:00,10,-1,0,0,-6:00
-1184,MST7MDT,1987,US,-420,60,4,1,0,0,-5:00,10,-1,0,0,-6:00
-1185,MST7MDT,2007,US,-420,60,3,8,0,0,-5:00,11,1,0,0,-6:00
-1186,PST8PDT,1970,US,-480,60,4,-1,0,0,-6:00,10,-1,0,0,-7:00
-1187,PST8PDT,1974,US,-480,60,1,6,-1,0,-6:00,10,-1,0,0,-7:00
-1188,PST8PDT,1975,US,-480,60,2,23,-1,0,-6:00,10,-1,0,0,-7:00
-1189,PST8PDT,1976,US,-480,60,4,-1,0,0,-6:00,10,-1,0,0,-7:00
-1190,PST8PDT,1987,US,-480,60,4,1,0,0,-6:00,10,-1,0,0,-7:00
-1191,PST8PDT,2007,US,-480,60,3,8,0,0,-6:00,11,1,0,0,-7:00
-1192,America/New_York,1970,US,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1193,America/New_York,1974,US,-300,60,1,6,-1,0,-3:00,10,-1,0,0,-4:00
-1194,America/New_York,1975,US,-300,60,2,23,-1,0,-3:00,10,-1,0,0,-4:00
-1195,America/New_York,1976,US,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1196,America/New_York,1987,US,-300,60,4,1,0,0,-3:00,10,-1,0,0,-4:00
-1197,America/New_York,2007,US,-300,60,3,8,0,0,-3:00,11,1,0,0,-4:00
-1198,America/Chicago,1970,US,-360,60,4,-1,0,0,-4:00,10,-1,0,0,-5:00
-1199,America/Chicago,1974,US,-360,60,1,6,-1,0,-4:00,10,-1,0,0,-5:00
-1200,America/Chicago,1975,US,-360,60,2,23,-1,0,-4:00,10,-1,0,0,-5:00
-1201,America/Chicago,1976,US,-360,60,4,-1,0,0,-4:00,10,-1,0,0,-5:00
-1202,America/Chicago,1987,US,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1203,America/Chicago,2007,US,-360,60,3,8,0,0,-4:00,11,1,0,0,-5:00
-1204,America/North_Dakota/Center,1970,US,-420,60,4,-1,0,0,-5:00,10,-1,0,0,-6:00
-1205,America/North_Dakota/Center,1974,US,-420,60,1,6,-1,0,-5:00,10,-1,0,0,-6:00
-1206,America/North_Dakota/Center,1975,US,-420,60,2,23,-1,0,-5:00,10,-1,0,0,-6:00
-1207,America/North_Dakota/Center,1976,US,-420,60,4,-1,0,0,-5:00,10,-1,0,0,-6:00
-1208,America/North_Dakota/Center,1987,US,-420,60,4,1,0,0,-5:00,10,-1,0,0,-6:00
-1209,America/North_Dakota/Center,1992,US,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1210,America/North_Dakota/Center,2007,US,-360,60,3,8,0,0,-4:00,11,1,0,0,-5:00
-1211,America/North_Dakota/New_Salem,1970,US,-420,60,4,-1,0,0,-5:00,10,-1,0,0,-6:00
-1212,America/North_Dakota/New_Salem,1974,US,-420,60,1,6,-1,0,-5:00,10,-1,0,0,-6:00
-1213,America/North_Dakota/New_Salem,1975,US,-420,60,2,23,-1,0,-5:00,10,-1,0,0,-6:00
-1214,America/North_Dakota/New_Salem,1976,US,-420,60,4,-1,0,0,-5:00,10,-1,0,0,-6:00
-1215,America/North_Dakota/New_Salem,1987,US,-420,60,4,1,0,0,-5:00,10,-1,0,0,-6:00
-1216,America/North_Dakota/New_Salem,2003,US,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1217,America/North_Dakota/New_Salem,2007,US,-360,60,3,8,0,0,-4:00,11,1,0,0,-5:00
-1218,America/Denver,1970,US,-420,60,4,-1,0,0,-5:00,10,-1,0,0,-6:00
-1219,America/Denver,1974,US,-420,60,1,6,-1,0,-5:00,10,-1,0,0,-6:00
-1220,America/Denver,1975,US,-420,60,2,23,-1,0,-5:00,10,-1,0,0,-6:00
-1221,America/Denver,1976,US,-420,60,4,-1,0,0,-5:00,10,-1,0,0,-6:00
-1222,America/Denver,1987,US,-420,60,4,1,0,0,-5:00,10,-1,0,0,-6:00
-1223,America/Denver,2007,US,-420,60,3,8,0,0,-5:00,11,1,0,0,-6:00
-1224,America/Los_Angeles,1970,US,-480,60,4,-1,0,0,-6:00,10,-1,0,0,-7:00
-1225,America/Los_Angeles,1974,US,-480,60,1,6,-1,0,-6:00,10,-1,0,0,-7:00
-1226,America/Los_Angeles,1975,US,-480,60,2,23,-1,0,-6:00,10,-1,0,0,-7:00
-1227,America/Los_Angeles,1976,US,-480,60,4,-1,0,0,-6:00,10,-1,0,0,-7:00
-1228,America/Los_Angeles,1987,US,-480,60,4,1,0,0,-6:00,10,-1,0,0,-7:00
-1229,America/Los_Angeles,2007,US,-480,60,3,8,0,0,-6:00,11,1,0,0,-7:00
-1230,America/Juneau,1970,US,-480,60,4,-1,0,0,-6:00,10,-1,0,0,-7:00
-1231,America/Juneau,1974,US,-480,60,1,6,-1,0,-6:00,10,-1,0,0,-7:00
-1232,America/Juneau,1975,US,-480,60,2,23,-1,0,-6:00,10,-1,0,0,-7:00
-1233,America/Juneau,1976,US,-480,60,4,-1,0,0,-6:00,10,-1,0,0,-7:00
-1234,America/Juneau,1983,US,-540,60,4,-1,0,0,-7:00,10,-1,0,0,-8:00
-1235,America/Juneau,1987,US,-540,60,4,1,0,0,-7:00,10,-1,0,0,-8:00
-1236,America/Juneau,2007,US,-540,60,3,8,0,0,-7:00,11,1,0,0,-8:00
-1237,America/Yakutat,1970,US,-540,60,4,-1,0,0,-7:00,10,-1,0,0,-8:00
-1238,America/Yakutat,1974,US,-540,60,1,6,-1,0,-7:00,10,-1,0,0,-8:00
-1239,America/Yakutat,1975,US,-540,60,2,23,-1,0,-7:00,10,-1,0,0,-8:00
-1240,America/Yakutat,1976,US,-540,60,4,-1,0,0,-7:00,10,-1,0,0,-8:00
-1241,America/Yakutat,1987,US,-540,60,4,1,0,0,-7:00,10,-1,0,0,-8:00
-1242,America/Yakutat,2007,US,-540,60,3,8,0,0,-7:00,11,1,0,0,-8:00
-1243,America/Anchorage,1970,US,-600,60,4,-1,0,0,-8:00,10,-1,0,0,-9:00
-1244,America/Anchorage,1974,US,-600,60,1,6,-1,0,-8:00,10,-1,0,0,-9:00
-1245,America/Anchorage,1975,US,-600,60,2,23,-1,0,-8:00,10,-1,0,0,-9:00
-1246,America/Anchorage,1976,US,-600,60,4,-1,0,0,-8:00,10,-1,0,0,-9:00
-1247,America/Anchorage,1983,US,-540,60,4,-1,0,0,-7:00,10,-1,0,0,-8:00
-1248,America/Anchorage,1987,US,-540,60,4,1,0,0,-7:00,10,-1,0,0,-8:00
-1249,America/Anchorage,2007,US,-540,60,3,8,0,0,-7:00,11,1,0,0,-8:00
-1250,America/Nome,1970,US,-660,60,4,-1,0,0,-9:00,10,-1,0,0,-10:0
-1251,America/Nome,1974,US,-660,60,1,6,-1,0,-9:00,10,-1,0,0,-10:0
-1252,America/Nome,1975,US,-660,60,2,23,-1,0,-9:00,10,-1,0,0,-10:0
-1253,America/Nome,1976,US,-660,60,4,-1,0,0,-9:00,10,-1,0,0,-10:0
-1254,America/Nome,1983,US,-540,60,4,-1,0,0,-7:00,10,-1,0,0,-8:00
-1255,America/Nome,1987,US,-540,60,4,1,0,0,-7:00,10,-1,0,0,-8:00
-1256,America/Nome,2007,US,-540,60,3,8,0,0,-7:00,11,1,0,0,-8:00
-1257,America/Adak,1970,US,-660,60,4,-1,0,0,-9:00,10,-1,0,0,-10:0
-1258,America/Adak,1974,US,-660,60,1,6,-1,0,-9:00,10,-1,0,0,-10:0
-1259,America/Adak,1975,US,-660,60,2,23,-1,0,-9:00,10,-1,0,0,-10:0
-1260,America/Adak,1976,US,-660,60,4,-1,0,0,-9:00,10,-1,0,0,-10:0
-1261,America/Adak,1983,US,-600,60,4,-1,0,0,-8:00,10,-1,0,0,-9:00
-1262,America/Adak,1987,US,-600,60,4,1,0,0,-8:00,10,-1,0,0,-9:00
-1263,America/Adak,2007,US,-600,60,3,8,0,0,-8:00,11,1,0,0,-9:00
-1264,Pacific/Honolulu,1970,,-600,0,0,0,0,0,,0,0,0,0,
-1265,America/Phoenix,1970,,-420,0,0,0,0,0,,0,0,0,0,
-1266,America/Boise,1970,US,-420,60,4,-1,0,0,-5:00,10,-1,0,0,-6:00
-1267,America/Boise,1974,US,-420,60,1,6,-1,0,-5:00,10,-1,0,0,-6:00
-1268,America/Boise,1975,US,-420,60,2,23,-1,0,-5:00,10,-1,0,0,-6:00
-1269,America/Boise,1976,US,-420,60,4,-1,0,0,-5:00,10,-1,0,0,-6:00
-1270,America/Boise,1987,US,-420,60,4,1,0,0,-5:00,10,-1,0,0,-6:00
-1271,America/Boise,2007,US,-420,60,3,8,0,0,-5:00,11,1,0,0,-6:00
-1272,America/Indiana/Indianapolis,1970,US,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1273,America/Indiana/Indianapolis,1971,,-300,0,0,0,0,0,,0,0,0,0,
-1274,America/Indiana/Indianapolis,2006,US,-300,60,4,1,0,0,-3:00,10,-1,0,0,-4:00
-1275,America/Indiana/Indianapolis,2007,US,-300,60,3,8,0,0,-3:00,11,1,0,0,-4:00
-1276,America/Indiana/Marengo,1970,US,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1277,America/Indiana/Marengo,1974,US,-300,60,1,6,-1,0,-3:00,10,-1,0,0,-4:00
-1278,America/Indiana/Marengo,1975,US,-300,60,2,23,-1,0,-3:00,10,-1,0,0,-4:00
-1279,America/Indiana/Marengo,1976,,-300,0,0,0,0,0,,0,0,0,0,
-1280,America/Indiana/Marengo,2006,US,-300,60,4,1,0,0,-3:00,10,-1,0,0,-4:00
-1281,America/Indiana/Marengo,2007,US,-300,60,3,8,0,0,-3:00,11,1,0,0,-4:00
-1282,America/Indiana/Vincennes,1970,US,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1283,America/Indiana/Vincennes,1971,,-300,0,0,0,0,0,,0,0,0,0,
-1284,America/Indiana/Vincennes,2006,US,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1285,America/Indiana/Vincennes,2007,US,-360,60,3,8,0,0,-4:00,11,1,0,0,-5:00
-1286,America/Indiana/Petersburg,1970,US,-360,60,4,-1,0,0,-4:00,10,-1,0,0,-5:00
-1287,America/Indiana/Petersburg,1974,US,-360,60,1,6,-1,0,-4:00,10,-1,0,0,-5:00
-1288,America/Indiana/Petersburg,1975,US,-360,60,2,23,-1,0,-4:00,10,-1,0,0,-5:00
-1289,America/Indiana/Petersburg,1976,US,-360,60,4,-1,0,0,-4:00,10,-1,0,0,-5:00
-1290,America/Indiana/Petersburg,1977,,-300,0,0,0,0,0,,0,0,0,0,
-1291,America/Indiana/Petersburg,2006,US,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1292,America/Indiana/Petersburg,2007,US,-360,60,3,8,0,0,-4:00,11,1,0,0,-5:00
-1293,America/Indiana/Knox,1970,US,-360,60,4,-1,0,0,-4:00,10,-1,0,0,-5:00
-1294,America/Indiana/Knox,1974,US,-360,60,1,6,-1,0,-4:00,10,-1,0,0,-5:00
-1295,America/Indiana/Knox,1975,US,-360,60,2,23,-1,0,-4:00,10,-1,0,0,-5:00
-1296,America/Indiana/Knox,1976,US,-360,60,4,-1,0,0,-4:00,10,-1,0,0,-5:00
-1297,America/Indiana/Knox,1987,US,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1298,America/Indiana/Knox,1991,,-300,0,0,0,0,0,,0,0,0,0,
-1299,America/Indiana/Knox,2006,US,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1300,America/Indiana/Knox,2007,US,-360,60,3,8,0,0,-4:00,11,1,0,0,-5:00
-1301,America/Indiana/Winamac,1970,US,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1302,America/Indiana/Winamac,1971,,-300,0,0,0,0,0,,0,0,0,0,
-1303,America/Indiana/Winamac,2006,US,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1304,America/Indiana/Winamac,2007,US,-300,60,3,8,0,0,-3:00,11,1,0,0,-4:00
-1305,America/Indiana/Vevay,1970,US,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1306,America/Indiana/Vevay,1973,,-300,0,0,0,0,0,,0,0,0,0,
-1307,America/Indiana/Vevay,2006,US,-300,60,4,1,0,0,-3:00,10,-1,0,0,-4:00
-1308,America/Indiana/Vevay,2007,US,-300,60,3,8,0,0,-3:00,11,1,0,0,-4:00
-1309,America/Kentucky/Louisville,1970,US,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1310,America/Kentucky/Louisville,1974,US,-300,60,1,6,-1,0,-3:00,10,-1,0,0,-4:00
-1311,America/Kentucky/Louisville,1975,US,-300,60,2,23,-1,0,-3:00,10,-1,0,0,-4:00
-1312,America/Kentucky/Louisville,1976,US,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1313,America/Kentucky/Louisville,1987,US,-300,60,4,1,0,0,-3:00,10,-1,0,0,-4:00
-1314,America/Kentucky/Louisville,2007,US,-300,60,3,8,0,0,-3:00,11,1,0,0,-4:00
-1315,America/Kentucky/Monticello,1970,US,-360,60,4,-1,0,0,-4:00,10,-1,0,0,-5:00
-1316,America/Kentucky/Monticello,1974,US,-360,60,1,6,-1,0,-4:00,10,-1,0,0,-5:00
-1317,America/Kentucky/Monticello,1975,US,-360,60,2,23,-1,0,-4:00,10,-1,0,0,-5:00
-1318,America/Kentucky/Monticello,1976,US,-360,60,4,-1,0,0,-4:00,10,-1,0,0,-5:00
-1319,America/Kentucky/Monticello,1987,US,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1320,America/Kentucky/Monticello,2000,US,-300,60,4,1,0,0,-3:00,10,-1,0,0,-4:00
-1321,America/Kentucky/Monticello,2007,US,-300,60,3,8,0,0,-3:00,11,1,0,0,-4:00
-1322,America/Detroit,1970,Detroit,-300,0,6,14,-1,0,-3:00,10,-1,0,0,-4:00
-1323,America/Detroit,1973,US,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1324,America/Detroit,1974,US,-300,60,1,6,-1,0,-3:00,10,-1,0,0,-4:00
-1325,America/Detroit,1975,US,-300,60,2,23,-1,0,-3:00,10,-1,0,0,-4:00
-1326,America/Detroit,1976,US,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1327,America/Detroit,1987,US,-300,60,4,1,0,0,-3:00,10,-1,0,0,-4:00
-1328,America/Detroit,2007,US,-300,60,3,8,0,0,-3:00,11,1,0,0,-4:00
-1329,America/Menominee,1970,,-300,0,0,0,0,0,,0,0,0,0,
-1330,America/Menominee,1973,US,-360,60,4,-1,0,0,-4:00,10,-1,0,0,-5:00
-1331,America/Menominee,1974,US,-360,60,1,6,-1,0,-4:00,10,-1,0,0,-5:00
-1332,America/Menominee,1975,US,-360,60,2,23,-1,0,-4:00,10,-1,0,0,-5:00
-1333,America/Menominee,1976,US,-360,60,4,-1,0,0,-4:00,10,-1,0,0,-5:00
-1334,America/Menominee,1987,US,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1335,America/Menominee,2007,US,-360,60,3,8,0,0,-4:00,11,1,0,0,-5:00
-1336,America/St_Johns,1970,StJohns,-210,60,4,-1,0,0,-1:30,10,-1,0,0,-2:30
-1337,America/St_Johns,1987,StJohns,-210,60,4,1,0,0,-3:29,10,-1,0,0,-4:29
-1338,America/St_Johns,1988,StJohns,-210,120,4,1,0,0,-3:29,10,-1,0,0,-4:29
-1339,America/St_Johns,1989,StJohns,-210,60,4,1,0,0,-3:29,10,-1,0,0,-4:29
-1340,America/St_Johns,2007,StJohns,-210,60,3,8,0,0,-3:29,11,1,0,0,-4:29
-1341,America/Goose_Bay,1970,StJohns,-240,60,4,-1,0,0,-2:00,10,-1,0,0,-3:00
-1342,America/Goose_Bay,1987,StJohns,-240,60,4,1,0,0,-3:59,10,-1,0,0,-4:59
-1343,America/Goose_Bay,1988,StJohns,-240,120,4,1,0,0,-3:59,10,-1,0,0,-4:59
-1344,America/Goose_Bay,1989,StJohns,-240,60,4,1,0,0,-3:59,10,-1,0,0,-4:59
-1345,America/Goose_Bay,2007,StJohns,-240,60,3,8,0,0,-3:59,11,1,0,0,-4:59
-1346,America/Halifax,1970,Halifax,-240,60,4,-1,0,0,-2:00,10,-1,0,0,-3:00
-1347,America/Halifax,1973,Halifax,-240,0,4,-1,0,0,-2:00,10,-1,0,0,-3:00
-1348,America/Halifax,1974,Canada,-240,60,4,-1,0,0,-2:00,10,-1,0,0,-3:00
-1349,America/Halifax,1987,Canada,-240,60,4,1,0,0,-2:00,10,-1,0,0,-3:00
-1350,America/Halifax,2007,Canada,-240,60,3,8,0,0,-2:00,11,1,0,0,-3:00
-1351,America/Glace_Bay,1970,,-240,0,0,0,0,0,,0,0,0,0,
-1352,America/Glace_Bay,1972,Halifax,-240,60,4,-1,0,0,-2:00,10,-1,0,0,-3:00
-1353,America/Glace_Bay,1973,Halifax,-240,0,4,-1,0,0,-2:00,10,-1,0,0,-3:00
-1354,America/Glace_Bay,1974,Canada,-240,60,4,-1,0,0,-2:00,10,-1,0,0,-3:00
-1355,America/Glace_Bay,1987,Canada,-240,60,4,1,0,0,-2:00,10,-1,0,0,-3:00
-1356,America/Glace_Bay,2007,Canada,-240,60,3,8,0,0,-2:00,11,1,0,0,-3:00
-1357,America/Moncton,1970,Moncton,-240,60,4,-1,0,0,-2:00,10,-1,0,0,-3:00
-1358,America/Moncton,1973,Canada,-240,60,4,-1,0,0,-2:00,10,-1,0,0,-3:00
-1359,America/Moncton,1987,Canada,-240,60,4,1,0,0,-2:00,10,-1,0,0,-3:00
-1360,America/Moncton,1993,Moncton,-240,60,4,1,0,0,-3:59,10,-1,0,0,-4:59
-1361,America/Moncton,2006,Moncton,-240,0,4,1,0,0,-3:59,10,-1,0,0,-4:59
-1362,America/Moncton,2007,Canada,-240,60,3,8,0,0,-2:00,11,1,0,0,-3:00
-1363,America/Blanc-Sablon,1970,,-240,0,0,0,0,0,,0,0,0,0,
-1364,America/Montreal,1970,Mont,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1365,America/Montreal,1974,Canada,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1366,America/Montreal,1987,Canada,-300,60,4,1,0,0,-3:00,10,-1,0,0,-4:00
-1367,America/Montreal,2007,Canada,-300,60,3,8,0,0,-3:00,11,1,0,0,-4:00
-1368,America/Toronto,1970,Toronto,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1369,America/Toronto,1973,Toronto,-300,0,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1370,America/Toronto,1974,Canada,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1371,America/Toronto,1987,Canada,-300,60,4,1,0,0,-3:00,10,-1,0,0,-4:00
-1372,America/Toronto,2007,Canada,-300,60,3,8,0,0,-3:00,11,1,0,0,-4:00
-1373,America/Thunder_Bay,1970,Mont,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1374,America/Thunder_Bay,1973,,-300,0,0,0,0,0,,0,0,0,0,
-1375,America/Thunder_Bay,1974,Canada,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1376,America/Thunder_Bay,1987,Canada,-300,60,4,1,0,0,-3:00,10,-1,0,0,-4:00
-1377,America/Thunder_Bay,2007,Canada,-300,60,3,8,0,0,-3:00,11,1,0,0,-4:00
-1378,America/Nipigon,1970,Canada,-300,60,8,14,-1,0,23:00,9,30,-1,0,-4:00
-1379,America/Nipigon,1974,Canada,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1380,America/Nipigon,1987,Canada,-300,60,4,1,0,0,-3:00,10,-1,0,0,-4:00
-1381,America/Nipigon,2007,Canada,-300,60,3,8,0,0,-3:00,11,1,0,0,-4:00
-1382,America/Rainy_River,1970,Canada,-360,60,8,14,-1,0,23:00,9,30,-1,0,-5:00
-1383,America/Rainy_River,1974,Canada,-360,60,4,-1,0,0,-4:00,10,-1,0,0,-5:00
-1384,America/Rainy_River,1987,Canada,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1385,America/Rainy_River,2007,Canada,-360,60,3,8,0,0,-4:00,11,1,0,0,-5:00
-1386,America/Atikokan,1970,,-300,0,0,0,0,0,,0,0,0,0,
-1387,America/Winnipeg,1970,Winn,-360,60,4,-1,0,0,-4:00,10,-1,0,0,-4:00
-1388,America/Winnipeg,1987,Winn,-360,60,4,1,0,0,-4:00,10,-1,0,0,-4:00
-1389,America/Winnipeg,2005,Winn,-360,0,4,1,0,0,-4:00,10,-1,0,0,-4:00
-1390,America/Winnipeg,2006,Canada,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1391,America/Winnipeg,2007,Canada,-360,60,3,8,0,0,-4:00,11,1,0,0,-5:00
-1392,America/Regina,1970,,-360,0,0,0,0,0,,0,0,0,0,
-1393,America/Swift_Current,1970,Swift,-420,0,4,-1,0,0,-5:00,9,-1,0,0,-6:00
-1394,America/Swift_Current,1972,,-360,0,0,0,0,0,,0,0,0,0,
-1395,America/Edmonton,1970,Edm,-420,60,4,-1,0,0,-5:00,10,-1,0,0,-6:00
-1396,America/Edmonton,1987,Canada,-420,60,4,1,0,0,-5:00,10,-1,0,0,-6:00
-1397,America/Edmonton,2007,Canada,-420,60,3,8,0,0,-5:00,11,1,0,0,-6:00
-1398,America/Vancouver,1970,Vanc,-480,60,4,-1,0,0,-6:00,10,-1,0,0,-7:00
-1399,America/Vancouver,1987,Canada,-480,60,4,1,0,0,-6:00,10,-1,0,0,-7:00
-1400,America/Vancouver,2007,Canada,-480,60,3,8,0,0,-6:00,11,1,0,0,-7:00
-1401,America/Dawson_Creek,1970,Vanc,-480,60,4,-1,0,0,-6:00,10,-1,0,0,-7:00
-1402,America/Dawson_Creek,1972,,-420,0,0,0,0,0,,0,0,0,0,
-1403,America/Pangnirtung,1970,NT_YK,-240,120,4,-1,0,0,-4:00,10,-1,0,0,-3:00
-1404,America/Pangnirtung,1980,NT_YK,-240,60,4,-1,0,0,-2:00,10,-1,0,0,-3:00
-1405,America/Pangnirtung,1987,NT_YK,-240,60,4,1,0,0,-2:00,10,-1,0,0,-3:00
-1406,America/Pangnirtung,1995,Canada,-300,60,4,1,0,0,-3:00,10,-1,0,0,-4:00
-1407,America/Pangnirtung,1999,Canada,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1408,America/Pangnirtung,2000,Canada,-300,60,4,1,0,0,-3:00,10,-1,0,0,-4:00
-1409,America/Pangnirtung,2007,Canada,-300,60,3,8,0,0,-3:00,11,1,0,0,-4:00
-1410,America/Iqaluit,1970,NT_YK,-300,120,4,-1,0,0,-5:00,10,-1,0,0,-4:00
-1411,America/Iqaluit,1980,NT_YK,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1412,America/Iqaluit,1987,NT_YK,-300,60,4,1,0,0,-3:00,10,-1,0,0,-4:00
-1413,America/Iqaluit,1999,Canada,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1414,America/Iqaluit,2000,Canada,-300,60,4,1,0,0,-3:00,10,-1,0,0,-4:00
-1415,America/Iqaluit,2007,Canada,-300,60,3,8,0,0,-3:00,11,1,0,0,-4:00
-1416,America/Rankin_Inlet,1970,NT_YK,-360,120,4,-1,0,0,-6:00,10,-1,0,0,-5:00
-1417,America/Rankin_Inlet,1980,NT_YK,-360,60,4,-1,0,0,-4:00,10,-1,0,0,-5:00
-1418,America/Rankin_Inlet,1987,NT_YK,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1419,America/Rankin_Inlet,2000,,-300,0,0,0,0,0,,0,0,0,0,
-1420,America/Rankin_Inlet,2001,Canada,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1421,America/Rankin_Inlet,2007,Canada,-360,60,3,8,0,0,-4:00,11,1,0,0,-5:00
-1422,America/Cambridge_Bay,1970,NT_YK,-420,120,4,-1,0,0,-7:00,10,-1,0,0,-6:00
-1423,America/Cambridge_Bay,1980,NT_YK,-420,60,4,-1,0,0,-5:00,10,-1,0,0,-6:00
-1424,America/Cambridge_Bay,1987,NT_YK,-420,60,4,1,0,0,-5:00,10,-1,0,0,-6:00
-1425,America/Cambridge_Bay,1999,Canada,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1426,America/Cambridge_Bay,2000,,-360,0,0,0,0,0,,0,0,0,0,
-1427,America/Cambridge_Bay,2001,Canada,-420,60,4,1,0,0,-5:00,10,-1,0,0,-6:00
-1428,America/Cambridge_Bay,2007,Canada,-420,60,3,8,0,0,-5:00,11,1,0,0,-6:00
-1429,America/Yellowknife,1970,NT_YK,-420,120,4,-1,0,0,-7:00,10,-1,0,0,-6:00
-1430,America/Yellowknife,1980,Canada,-420,60,4,-1,0,0,-5:00,10,-1,0,0,-6:00
-1431,America/Yellowknife,1987,Canada,-420,60,4,1,0,0,-5:00,10,-1,0,0,-6:00
-1432,America/Yellowknife,2007,Canada,-420,60,3,8,0,0,-5:00,11,1,0,0,-6:00
-1433,America/Inuvik,1970,NT_YK,-480,120,4,-1,0,0,-8:00,10,-1,0,0,-7:00
-1434,America/Inuvik,1979,NT_YK,-420,120,4,-1,0,0,-7:00,10,-1,0,0,-6:00
-1435,America/Inuvik,1980,Canada,-420,60,4,-1,0,0,-5:00,10,-1,0,0,-6:00
-1436,America/Inuvik,1987,Canada,-420,60,4,1,0,0,-5:00,10,-1,0,0,-6:00
-1437,America/Inuvik,2007,Canada,-420,60,3,8,0,0,-5:00,11,1,0,0,-6:00
-1438,America/Whitehorse,1970,NT_YK,-480,120,4,-1,0,0,-8:00,10,-1,0,0,-7:00
-1439,America/Whitehorse,1980,Canada,-480,60,4,-1,0,0,-6:00,10,-1,0,0,-7:00
-1440,America/Whitehorse,1987,Canada,-480,60,4,1,0,0,-6:00,10,-1,0,0,-7:00
-1441,America/Whitehorse,2007,Canada,-480,60,3,8,0,0,-6:00,11,1,0,0,-7:00
-1442,America/Dawson,1970,NT_YK,-540,120,4,-1,0,0,-9:00,10,-1,0,0,-8:00
-1443,America/Dawson,1973,NT_YK,-480,120,4,-1,0,0,-8:00,10,-1,0,0,-7:00
-1444,America/Dawson,1980,Canada,-480,60,4,-1,0,0,-6:00,10,-1,0,0,-7:00
-1445,America/Dawson,1987,Canada,-480,60,4,1,0,0,-6:00,10,-1,0,0,-7:00
-1446,America/Dawson,2007,Canada,-480,60,3,8,0,0,-6:00,11,1,0,0,-7:00
-1447,America/Cancun,1970,,-360,0,0,0,0,0,,0,0,0,0,
-1448,America/Cancun,1981,Mexico,-300,0,0,0,0,0,,0,0,0,0,
-1449,America/Cancun,1996,Mexico,-300,60,4,1,0,0,-3:00,10,-1,0,0,-4:00
-1450,America/Cancun,1998,Mexico,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1451,America/Cancun,2001,Mexico,-360,60,5,1,0,0,-4:00,9,-1,0,0,-5:00
-1452,America/Cancun,2002,Mexico,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1453,America/Merida,1970,,-360,0,0,0,0,0,,0,0,0,0,
-1454,America/Merida,1981,,-300,0,0,0,0,0,,0,0,0,0,
-1455,America/Merida,1982,Mexico,-360,0,0,0,0,0,,0,0,0,0,
-1456,America/Merida,1996,Mexico,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1457,America/Merida,2001,Mexico,-360,60,5,1,0,0,-4:00,9,-1,0,0,-5:00
-1458,America/Merida,2002,Mexico,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1459,America/Monterrey,1970,,-360,0,0,0,0,0,,0,0,0,0,
-1460,America/Monterrey,1988,US,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1461,America/Monterrey,1989,Mexico,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1462,America/Monterrey,2001,Mexico,-360,60,5,1,0,0,-4:00,9,-1,0,0,-5:00
-1463,America/Monterrey,2002,Mexico,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1464,America/Mexico_City,1970,Mexico,-360,60,2,12,-1,0,-6:00,7,30,-1,0,-7:00
-1465,America/Mexico_City,1996,Mexico,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1466,America/Mexico_City,2001,,-360,0,0,0,0,0,,0,0,0,0,
-1467,America/Mexico_City,2002,Mexico,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1468,America/Chihuahua,1970,,-360,0,0,0,0,0,,0,0,0,0,
-1469,America/Chihuahua,1996,Mexico,-360,60,4,1,0,0,-4:00,10,-1,0,0,-5:00
-1470,America/Chihuahua,1998,Mexico,-420,60,4,1,0,0,-5:00,10,-1,0,0,-6:00
-1471,America/Chihuahua,2001,Mexico,-420,60,5,1,0,0,-5:00,9,-1,0,0,-6:00
-1472,America/Chihuahua,2002,Mexico,-420,60,4,1,0,0,-5:00,10,-1,0,0,-6:00
-1473,America/Hermosillo,1970,Mexico,-420,60,2,12,-1,0,-7:00,7,30,-1,0,-8:00
-1474,America/Hermosillo,1996,Mexico,-420,60,4,1,0,0,-5:00,10,-1,0,0,-6:00
-1475,America/Hermosillo,1999,,-420,0,0,0,0,0,,0,0,0,0,
-1476,America/Mazatlan,1970,Mexico,-420,60,2,12,-1,0,-7:00,7,30,-1,0,-8:00
-1477,America/Mazatlan,1996,Mexico,-420,60,4,1,0,0,-5:00,10,-1,0,0,-6:00
-1478,America/Mazatlan,2001,Mexico,-420,60,5,1,0,0,-5:00,9,-1,0,0,-6:00
-1479,America/Mazatlan,2002,Mexico,-420,60,4,1,0,0,-5:00,10,-1,0,0,-6:00
-1480,America/Tijuana,1970,,-480,0,0,0,0,0,,0,0,0,0,
-1481,America/Tijuana,1976,US,-480,60,4,-1,0,0,-6:00,10,-1,0,0,-7:00
-1482,America/Tijuana,1987,US,-480,60,4,1,0,0,-6:00,10,-1,0,0,-7:00
-1483,America/Tijuana,1996,Mexico,-480,60,4,1,0,0,-6:00,10,-1,0,0,-7:00
-1484,America/Tijuana,2001,US,-480,60,4,1,0,0,-6:00,10,-1,0,0,-7:00
-1485,America/Tijuana,2002,Mexico,-480,60,4,1,0,0,-6:00,10,-1,0,0,-7:00
-1486,America/Anguilla,1970,,-240,0,0,0,0,0,,0,0,0,0,
-1487,America/Antigua,1970,,-240,0,0,0,0,0,,0,0,0,0,
-1488,America/Nassau,1970,Bahamas,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1489,America/Nassau,1976,US,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1490,America/Nassau,1987,US,-300,60,4,1,0,0,-3:00,10,-1,0,0,-4:00
-1491,America/Nassau,2007,US,-300,60,3,8,0,0,-3:00,11,1,0,0,-4:00
-1492,America/Barbados,1970,Barb,-240,0,0,0,0,0,,0,0,0,0,
-1493,America/Barbados,1977,Barb,-240,60,6,12,-1,0,-2:00,10,1,0,0,-3:00
-1494,America/Barbados,1978,Barb,-240,60,4,15,0,0,-2:00,10,1,0,0,-3:00
-1495,America/Barbados,1979,Barb,-240,60,4,15,0,0,-2:00,9,30,-1,0,-3:00
-1496,America/Barbados,1980,Barb,-240,60,4,15,0,0,-2:00,9,25,-1,0,-3:00
-1497,America/Barbados,1981,Barb,-240,0,4,15,0,0,-2:00,9,25,-1,0,-3:00
-1498,America/Belize,1970,Belize,-360,0,12,31,-1,0,06:00,2,9,0,0,-7:00
-1499,America/Belize,1973,Belize,-360,60,12,5,-1,0,-6:00,1,1,-1,0,05:00
-1500,America/Belize,1974,Belize,-360,0,12,31,-1,0,06:00,2,9,-1,0,-7:00
-1501,America/Belize,1982,Belize,-360,60,12,18,-1,0,-6:00,1,1,-1,0,05:00
-1502,America/Belize,1983,Belize,-360,0,12,31,-1,0,06:00,2,12,-1,0,-7:00
-1503,Atlantic/Bermuda,1970,,-240,0,0,0,0,0,,0,0,0,0,
-1504,Atlantic/Bermuda,1974,Bahamas,-240,60,4,-1,0,0,-2:00,10,-1,0,0,-3:00
-1505,Atlantic/Bermuda,1976,US,-240,60,4,-1,0,0,-2:00,10,-1,0,0,-3:00
-1506,Atlantic/Bermuda,1987,US,-240,60,4,1,0,0,-2:00,10,-1,0,0,-3:00
-1507,Atlantic/Bermuda,2007,US,-240,60,3,8,0,0,-2:00,11,1,0,0,-3:00
-1508,America/Cayman,1970,,-300,0,0,0,0,0,,0,0,0,0,
-1509,America/Costa_Rica,1970,CR,-360,0,0,0,0,0,,0,0,0,0,
-1510,America/Costa_Rica,1979,CR,-360,60,2,-1,0,0,-6:00,6,1,0,0,-7:00
-1511,America/Costa_Rica,1991,CR,-360,60,1,15,6,0,-6:00,7,1,-1,0,-7:00
-1512,America/Costa_Rica,1992,CR,-360,60,1,15,6,0,-6:00,3,15,-1,0,-7:00
-1513,America/Costa_Rica,1993,CR,-360,0,1,15,6,0,-6:00,3,15,-1,0,-7:00
-1514,America/Havana,1970,Cuba,-300,60,4,-1,0,0,-5:00,10,-1,0,0,-6:00
-1515,America/Havana,1972,Cuba,-300,60,4,-1,0,0,-5:00,10,8,-1,0,-6:00
-1516,America/Havana,1975,Cuba,-300,60,4,-1,0,0,-5:00,10,-1,0,0,-6:00
-1517,America/Havana,1978,Cuba,-300,60,5,7,-1,0,-5:00,10,8,0,0,-6:00
-1518,America/Havana,1979,Cuba,-300,60,3,15,0,0,-5:00,10,8,0,0,-6:00
-1519,America/Havana,1981,Cuba,-300,60,5,5,0,0,-5:00,10,8,0,0,-6:00
-1520,America/Havana,1986,Cuba,-300,60,3,14,0,0,-5:00,10,8,0,0,-6:00
-1521,America/Havana,1990,Cuba,-300,60,4,1,0,0,-5:00,10,8,0,0,-6:00
-1522,America/Havana,1991,Cuba,-300,60,4,1,0,0,-5:00,10,8,0,0,-5:00
-1523,America/Havana,1996,Cuba,-300,60,4,1,0,0,-5:00,10,6,-1,0,-5:00
-1524,America/Havana,1997,Cuba,-300,60,4,1,0,0,-5:00,10,12,-1,0,-5:00
-1525,America/Havana,1998,Cuba,-300,60,3,-1,0,0,-5:00,10,-1,0,0,-5:00
-1526,America/Havana,2000,Cuba,-300,60,4,1,0,0,-5:00,10,-1,0,0,-5:00
-1527,America/Havana,2004,Cuba,-300,60,4,1,0,0,-5:00,1,1,-1,0,06:00
-1528,America/Havana,2006,Cuba,-300,60,4,1,0,0,-5:00,10,-1,0,0,-5:00
-1529,America/Dominica,1970,,-240,0,0,0,0,0,,0,0,0,0,
-1530,America/Santo_Domingo,1970,DR,-300,30,10,-1,0,0,-5:00,2,21,-1,0,-6:00
-1531,America/Santo_Domingo,1971,DR,-300,30,10,-1,0,0,-5:00,1,20,-1,0,-6:00
-1532,America/Santo_Domingo,1972,DR,-300,30,10,-1,0,0,-5:00,1,21,-1,0,-6:00
-1533,America/Santo_Domingo,1974,,-240,0,0,0,0,0,,0,0,0,0,
-1534,America/El_Salvador,1970,Salv,-360,0,0,0,0,0,,0,0,0,0,
-1535,America/El_Salvador,1987,Salv,-360,60,5,1,0,0,-6:00,9,-1,0,0,-7:00
-1536,America/El_Salvador,1988,Salv,-360,0,5,1,0,0,-6:00,9,-1,0,0,-7:00
-1537,America/Grenada,1970,,-240,0,0,0,0,0,,0,0,0,0,
-1538,America/Guadeloupe,1970,,-240,0,0,0,0,0,,0,0,0,0,
-1539,America/Guatemala,1970,Guat,-360,0,0,0,0,0,,0,0,0,0,
-1540,America/Guatemala,1973,Guat,-360,60,11,25,-1,0,-6:00,1,1,-1,0,05:00
-1541,America/Guatemala,1974,Guat,-360,0,12,31,-1,0,06:00,2,24,-1,0,-7:00
-1542,America/Guatemala,1983,Guat,-360,60,5,21,-1,0,-6:00,9,22,-1,0,-7:00
-1543,America/Guatemala,1991,Guat,-360,60,3,23,-1,0,-6:00,9,7,-1,0,-7:00
-1544,America/Guatemala,2006,Guat,-360,60,4,30,-1,0,-6:00,10,1,-1,0,-7:00
-1545,America/Guatemala,2007,Guat,-360,0,4,30,-1,0,-6:00,10,1,-1,0,-7:00
-1546,America/Port-au-Prince,1970,Haiti,-300,0,0,0,0,0,,0,0,0,0,
-1547,America/Port-au-Prince,1983,Haiti,-300,60,5,8,-1,0,-5:00,10,-1,0,0,-6:00
-1548,America/Port-au-Prince,1984,Haiti,-300,60,4,-1,0,0,-5:00,10,-1,0,0,-6:00
-1549,America/Port-au-Prince,1988,Haiti,-300,60,4,1,0,0,-4:00,10,-1,0,0,-4:00
-1550,America/Port-au-Prince,2005,Haiti,-300,60,4,1,0,0,-5:00,10,-1,0,0,-6:00
-1551,America/Tegucigalpa,1970,Hond,-360,0,0,0,0,0,,0,0,0,0,
-1552,America/Tegucigalpa,1987,Hond,-360,60,5,1,0,0,-6:00,9,-1,0,0,-7:00
-1553,America/Tegucigalpa,2006,Hond,-360,60,5,1,0,0,-6:00,8,1,1,0,-7:00
-1554,America/Tegucigalpa,2009,Hond,-360,0,5,1,0,0,-6:00,8,1,1,0,-7:00
-1555,America/Jamaica,1970,,-300,0,0,0,0,0,,0,0,0,0,
-1556,America/Jamaica,1974,US,-300,60,1,6,-1,0,-3:00,10,-1,0,0,-4:00
-1557,America/Jamaica,1975,US,-300,60,2,23,-1,0,-3:00,10,-1,0,0,-4:00
-1558,America/Jamaica,1976,US,-300,60,4,-1,0,0,-3:00,10,-1,0,0,-4:00
-1559,America/Jamaica,1984,,-300,0,0,0,0,0,,0,0,0,0,
-1560,America/Martinique,1970,,-240,0,0,0,0,0,,0,0,0,0,
-1561,America/Martinique,1980,,-240,0,0,0,0,0,,0,0,0,0,
-1562,America/Montserrat,1970,,-240,0,0,0,0,0,,0,0,0,0,
-1563,America/Managua,1970,,-360,0,0,0,0,0,,0,0,0,0,
-1564,America/Managua,1973,,-300,0,0,0,0,0,,0,0,0,0,
-1565,America/Managua,1975,Nic,-360,0,0,0,0,0,,0,0,0,0,
-1566,America/Managua,1979,Nic,-360,60,3,16,0,0,-6:00,6,23,1,0,-7:00
-1567,America/Managua,1992,,-360,0,0,0,0,0,,0,0,0,0,
-1568,America/Managua,1993,,-300,0,0,0,0,0,,0,0,0,0,
-1569,America/Managua,1997,Nic,-360,0,0,0,0,0,,0,0,0,0,
-1570,America/Managua,2005,Nic,-360,60,4,10,-1,0,-6:00,10,1,0,0,-7:00
-1571,America/Managua,2006,Nic,-360,60,4,30,-1,0,-4:00,10,1,0,0,-6:00
-1572,America/Managua,2007,Nic,-360,0,4,30,-1,0,-4:00,10,1,0,0,-6:00
-1573,America/Panama,1970,,-300,0,0,0,0,0,,0,0,0,0,
-1574,America/Puerto_Rico,1970,,-240,0,0,0,0,0,,0,0,0,0,
-1575,America/St_Kitts,1970,,-240,0,0,0,0,0,,0,0,0,0,
-1576,America/St_Lucia,1970,,-240,0,0,0,0,0,,0,0,0,0,
-1577,America/Miquelon,1970,,-240,0,0,0,0,0,,0,0,0,0,
-1578,America/Miquelon,1980,,-180,0,0,0,0,0,,0,0,0,0,
-1579,America/Miquelon,1987,Canada,-180,60,4,1,0,0,-1:00,10,-1,0,0,-2:00
-1580,America/Miquelon,2007,Canada,-180,60,3,8,0,0,-1:00,11,1,0,0,-2:00
-1581,America/St_Vincent,1970,,-240,0,0,0,0,0,,0,0,0,0,
-1582,America/Grand_Turk,1970,TC,-300,0,0,0,0,0,,0,0,0,0,
-1583,America/Grand_Turk,1979,TC,-300,60,4,-1,0,0,-5:00,10,-1,0,0,-6:00
-1584,America/Grand_Turk,1987,TC,-300,60,4,1,0,0,-5:00,10,-1,0,0,-6:00
-1585,America/Tortola,1970,,-240,0,0,0,0,0,,0,0,0,0,
-1586,America/St_Thomas,1970,,-240,0,0,0,0,0,,0,0,0,0,
-1587,America/Argentina/Buenos_Aires,1970,Arg,-180,0,12,31,-1,0,09:00,4,1,0,0,-4:00
-1588,America/Argentina/Buenos_Aires,1974,Arg,-180,60,1,23,-1,0,-3:00,5,1,-1,0,-4:00
-1589,America/Argentina/Buenos_Aires,1988,Arg,-180,60,12,1,-1,0,-3:00,1,1,-1,0,08:00
-1590,America/Argentina/Buenos_Aires,1989,Arg,-180,60,10,15,0,0,-3:00,3,1,0,0,-4:00
-1591,America/Argentina/Buenos_Aires,1993,Arg,-180,0,12,31,-1,0,09:00,3,1,0,0,-4:00
-1592,America/Argentina/Buenos_Aires,1999,Arg,-240,60,10,1,0,0,-4:00,1,1,-1,0,07:00
-1593,America/Argentina/Buenos_Aires,2000,,-180,0,0,0,0,0,,0,0,0,0,
-1594,America/Argentina/Cordoba,1970,Arg,-180,0,12,31,-1,0,09:00,4,1,0,0,-4:00
-1595,America/Argentina/Cordoba,1974,Arg,-180,60,1,23,-1,0,-3:00,5,1,-1,0,-4:00
-1596,America/Argentina/Cordoba,1988,Arg,-180,60,12,1,-1,0,-3:00,1,1,-1,0,08:00
-1597,America/Argentina/Cordoba,1989,Arg,-180,60,10,15,0,0,-3:00,3,1,0,0,-4:00
-1598,America/Argentina/Cordoba,1993,Arg,-180,0,12,31,-1,0,09:00,3,1,0,0,-4:00
-1599,America/Argentina/Cordoba,1999,Arg,-240,60,10,1,0,0,-4:00,1,1,-1,0,07:00
-1600,America/Argentina/Cordoba,2000,,-180,0,0,0,0,0,,0,0,0,0,
-1601,America/Argentina/Tucuman,1970,Arg,-180,0,12,31,-1,0,09:00,4,1,0,0,-4:00
-1602,America/Argentina/Tucuman,1974,Arg,-180,60,1,23,-1,0,-3:00,5,1,-1,0,-4:00
-1603,America/Argentina/Tucuman,1988,Arg,-180,60,12,1,-1,0,-3:00,1,1,-1,0,08:00
-1604,America/Argentina/Tucuman,1989,Arg,-180,60,10,15,0,0,-3:00,3,1,0,0,-4:00
-1605,America/Argentina/Tucuman,1993,Arg,-180,0,12,31,-1,0,09:00,3,1,0,0,-4:00
-1606,America/Argentina/Tucuman,1999,Arg,-240,60,10,1,0,0,-4:00,1,1,-1,0,07:00
-1607,America/Argentina/Tucuman,2000,,-180,0,0,0,0,0,,0,0,0,0,
-1608,America/Argentina/La_Rioja,1970,Arg,-180,0,12,31,-1,0,09:00,4,1,0,0,-4:00
-1609,America/Argentina/La_Rioja,1974,Arg,-180,60,1,23,-1,0,-3:00,5,1,-1,0,-4:00
-1610,America/Argentina/La_Rioja,1988,Arg,-180,60,12,1,-1,0,-3:00,1,1,-1,0,08:00
-1611,America/Argentina/La_Rioja,1989,Arg,-180,60,10,15,0,0,-3:00,3,1,0,0,-4:00
-1612,America/Argentina/La_Rioja,1993,Arg,-180,0,12,31,-1,0,09:00,3,1,0,0,-4:00
-1613,America/Argentina/La_Rioja,1999,Arg,-240,60,10,1,0,0,-4:00,1,1,-1,0,07:00
-1614,America/Argentina/La_Rioja,2000,,-180,0,0,0,0,0,,0,0,0,0,
-1615,America/Argentina/San_Juan,1970,Arg,-180,0,12,31,-1,0,09:00,4,1,0,0,-4:00
-1616,America/Argentina/San_Juan,1974,Arg,-180,60,1,23,-1,0,-3:00,5,1,-1,0,-4:00
-1617,America/Argentina/San_Juan,1988,Arg,-180,60,12,1,-1,0,-3:00,1,1,-1,0,08:00
-1618,America/Argentina/San_Juan,1989,Arg,-180,60,10,15,0,0,-3:00,3,1,0,0,-4:00
-1619,America/Argentina/San_Juan,1993,Arg,-180,0,12,31,-1,0,09:00,3,1,0,0,-4:00
-1620,America/Argentina/San_Juan,1999,Arg,-240,60,10,1,0,0,-4:00,1,1,-1,0,07:00
-1621,America/Argentina/San_Juan,2000,,-180,0,0,0,0,0,,0,0,0,0,
-1622,America/Argentina/Jujuy,1970,Arg,-180,0,12,31,-1,0,09:00,4,1,0,0,-4:00
-1623,America/Argentina/Jujuy,1974,Arg,-180,60,1,23,-1,0,-3:00,5,1,-1,0,-4:00
-1624,America/Argentina/Jujuy,1988,Arg,-180,60,12,1,-1,0,-3:00,1,1,-1,0,08:00
-1625,America/Argentina/Jujuy,1989,Arg,-180,60,10,15,0,0,-3:00,3,1,0,0,-4:00
-1626,America/Argentina/Jujuy,1990,,-240,0,0,0,0,0,,0,0,0,0,
-1627,America/Argentina/Jujuy,1991,,-180,0,0,0,0,0,,0,0,0,0,
-1628,America/Argentina/Jujuy,1992,Arg,-180,60,10,15,0,0,-3:00,3,1,0,0,-4:00
-1629,America/Argentina/Jujuy,1993,Arg,-180,0,12,31,-1,0,09:00,3,1,0,0,-4:00
-1630,America/Argentina/Jujuy,1999,Arg,-240,60,10,1,0,0,-4:00,1,1,-1,0,07:00
-1631,America/Argentina/Jujuy,2000,,-180,0,0,0,0,0,,0,0,0,0,
-1632,America/Argentina/Catamarca,1970,Arg,-180,0,12,31,-1,0,09:00,4,1,0,0,-4:00
-1633,America/Argentina/Catamarca,1974,Arg,-180,60,1,23,-1,0,-3:00,5,1,-1,0,-4:00
-1634,America/Argentina/Catamarca,1988,Arg,-180,60,12,1,-1,0,-3:00,1,1,-1,0,08:00
-1635,America/Argentina/Catamarca,1989,Arg,-180,60,10,15,0,0,-3:00,3,1,0,0,-4:00
-1636,America/Argentina/Catamarca,1993,Arg,-180,0,12,31,-1,0,09:00,3,1,0,0,-4:00
-1637,America/Argentina/Catamarca,1999,Arg,-240,60,10,1,0,0,-4:00,1,1,-1,0,07:00
-1638,America/Argentina/Catamarca,2000,,-180,0,0,0,0,0,,0,0,0,0,
-1639,America/Argentina/Mendoza,1970,Arg,-180,0,12,31,-1,0,09:00,4,1,0,0,-4:00
-1640,America/Argentina/Mendoza,1974,Arg,-180,60,1,23,-1,0,-3:00,5,1,-1,0,-4:00
-1641,America/Argentina/Mendoza,1988,Arg,-180,60,12,1,-1,0,-3:00,1,1,-1,0,08:00
-1642,America/Argentina/Mendoza,1989,Arg,-180,60,10,15,0,0,-3:00,3,1,0,0,-4:00
-1643,America/Argentina/Mendoza,1990,,-240,0,0,0,0,0,,0,0,0,0,
-1644,America/Argentina/Mendoza,1992,Arg,-180,60,10,15,0,0,-3:00,3,1,0,0,-4:00
-1645,America/Argentina/Mendoza,1993,Arg,-180,0,12,31,-1,0,09:00,3,1,0,0,-4:00
-1646,America/Argentina/Mendoza,1999,Arg,-240,60,10,1,0,0,-4:00,1,1,-1,0,07:00
-1647,America/Argentina/Mendoza,2000,,-180,0,0,0,0,0,,0,0,0,0,
-1648,America/Argentina/Rio_Gallegos,1970,Arg,-180,0,12,31,-1,0,09:00,4,1,0,0,-4:00
-1649,America/Argentina/Rio_Gallegos,1974,Arg,-180,60,1,23,-1,0,-3:00,5,1,-1,0,-4:00
-1650,America/Argentina/Rio_Gallegos,1988,Arg,-180,60,12,1,-1,0,-3:00,1,1,-1,0,08:00
-1651,America/Argentina/Rio_Gallegos,1989,Arg,-180,60,10,15,0,0,-3:00,3,1,0,0,-4:00
-1652,America/Argentina/Rio_Gallegos,1993,Arg,-180,0,12,31,-1,0,09:00,3,1,0,0,-4:00
-1653,America/Argentina/Rio_Gallegos,1999,Arg,-240,60,10,1,0,0,-4:00,1,1,-1,0,07:00
-1654,America/Argentina/Rio_Gallegos,2000,,-180,0,0,0,0,0,,0,0,0,0,
-1655,America/Argentina/Ushuaia,1970,Arg,-180,0,12,31,-1,0,09:00,4,1,0,0,-4:00
-1656,America/Argentina/Ushuaia,1974,Arg,-180,60,1,23,-1,0,-3:00,5,1,-1,0,-4:00
-1657,America/Argentina/Ushuaia,1988,Arg,-180,60,12,1,-1,0,-3:00,1,1,-1,0,08:00
-1658,America/Argentina/Ushuaia,1989,Arg,-180,60,10,15,0,0,-3:00,3,1,0,0,-4:00
-1659,America/Argentina/Ushuaia,1993,Arg,-180,0,12,31,-1,0,09:00,3,1,0,0,-4:00
-1660,America/Argentina/Ushuaia,1999,Arg,-240,60,10,1,0,0,-4:00,1,1,-1,0,07:00
-1661,America/Argentina/Ushuaia,2000,,-180,0,0,0,0,0,,0,0,0,0,
-1662,America/Aruba,1970,,-240,0,0,0,0,0,,0,0,0,0,
-1663,America/La_Paz,1970,,-240,0,0,0,0,0,,0,0,0,0,
-1664,America/Noronha,1970,Brazil,-120,0,12,31,-1,0,10:00,3,1,-1,0,-3:00
-1665,America/Noronha,1985,Brazil,-120,60,11,2,-1,0,-2:00,1,1,-1,0,09:00
-1666,America/Noronha,1986,Brazil,-120,60,10,25,-1,0,-2:00,3,15,-1,0,-3:00
-1667,America/Noronha,1987,Brazil,-120,60,10,25,-1,0,-2:00,2,14,-1,0,-3:00
-1668,America/Noronha,1988,Brazil,-120,60,10,16,-1,0,-2:00,2,7,-1,0,-3:00
-1669,America/Noronha,1989,Brazil,-120,60,10,15,-1,0,-2:00,1,29,-1,0,-3:00
-1670,America/Noronha,1990,,-120,0,0,0,0,0,,0,0,0,0,
-1671,America/Noronha,1999,Brazil,-120,60,10,3,-1,0,-2:00,2,21,-1,0,-3:00
-1672,America/Noronha,2000,,-120,0,0,0,0,0,,0,0,0,0,
-1673,America/Noronha,2001,Brazil,-120,60,10,8,0,0,-2:00,2,15,0,0,-3:00
-1674,America/Noronha,2002,,-120,0,0,0,0,0,,0,0,0,0,
-1675,America/Belem,1970,Brazil,-180,0,12,31,-1,0,09:00,3,1,-1,0,-4:00
-1676,America/Belem,1985,Brazil,-180,60,11,2,-1,0,-3:00,1,1,-1,0,08:00
-1677,America/Belem,1986,Brazil,-180,60,10,25,-1,0,-3:00,3,15,-1,0,-4:00
-1678,America/Belem,1987,Brazil,-180,60,10,25,-1,0,-3:00,2,14,-1,0,-4:00
-1679,America/Belem,1988,,-180,0,0,0,0,0,,0,0,0,0,
-1680,America/Fortaleza,1970,Brazil,-180,0,12,31,-1,0,09:00,3,1,-1,0,-4:00
-1681,America/Fortaleza,1985,Brazil,-180,60,11,2,-1,0,-3:00,1,1,-1,0,08:00
-1682,America/Fortaleza,1986,Brazil,-180,60,10,25,-1,0,-3:00,3,15,-1,0,-4:00
-1683,America/Fortaleza,1987,Brazil,-180,60,10,25,-1,0,-3:00,2,14,-1,0,-4:00
-1684,America/Fortaleza,1988,Brazil,-180,60,10,16,-1,0,-3:00,2,7,-1,0,-4:00
-1685,America/Fortaleza,1989,Brazil,-180,60,10,15,-1,0,-3:00,1,29,-1,0,-4:00
-1686,America/Fortaleza,1990,,-180,0,0,0,0,0,,0,0,0,0,
-1687,America/Fortaleza,1999,Brazil,-180,60,10,3,-1,0,-3:00,2,21,-1,0,-4:00
-1688,America/Fortaleza,2000,,-180,0,0,0,0,0,,0,0,0,0,
-1689,America/Fortaleza,2001,Brazil,-180,60,10,8,0,0,-3:00,2,15,0,0,-4:00
-1690,America/Fortaleza,2002,,-180,0,0,0,0,0,,0,0,0,0,
-1691,America/Recife,1970,Brazil,-180,0,12,31,-1,0,09:00,3,1,-1,0,-4:00
-1692,America/Recife,1985,Brazil,-180,60,11,2,-1,0,-3:00,1,1,-1,0,08:00
-1693,America/Recife,1986,Brazil,-180,60,10,25,-1,0,-3:00,3,15,-1,0,-4:00
-1694,America/Recife,1987,Brazil,-180,60,10,25,-1,0,-3:00,2,14,-1,0,-4:00
-1695,America/Recife,1988,Brazil,-180,60,10,16,-1,0,-3:00,2,7,-1,0,-4:00
-1696,America/Recife,1989,Brazil,-180,60,10,15,-1,0,-3:00,1,29,-1,0,-4:00
-1697,America/Recife,1990,,-180,0,0,0,0,0,,0,0,0,0,
-1698,America/Recife,1999,Brazil,-180,60,10,3,-1,0,-3:00,2,21,-1,0,-4:00
-1699,America/Recife,2000,,-180,0,0,0,0,0,,0,0,0,0,
-1700,America/Recife,2001,Brazil,-180,60,10,8,0,0,-3:00,2,15,0,0,-4:00
-1701,America/Recife,2002,,-180,0,0,0,0,0,,0,0,0,0,
-1702,America/Araguaina,1970,Brazil,-180,0,12,31,-1,0,09:00,3,1,-1,0,-4:00
-1703,America/Araguaina,1985,Brazil,-180,60,11,2,-1,0,-3:00,1,1,-1,0,08:00
-1704,America/Araguaina,1986,Brazil,-180,60,10,25,-1,0,-3:00,3,15,-1,0,-4:00
-1705,America/Araguaina,1987,Brazil,-180,60,10,25,-1,0,-3:00,2,14,-1,0,-4:00
-1706,America/Araguaina,1988,Brazil,-180,60,10,16,-1,0,-3:00,2,7,-1,0,-4:00
-1707,America/Araguaina,1989,Brazil,-180,60,10,15,-1,0,-3:00,1,29,-1,0,-4:00
-1708,America/Araguaina,1990,,-180,0,0,0,0,0,,0,0,0,0,
-1709,America/Araguaina,1995,Brazil,-180,60,10,11,0,0,-3:00,2,15,0,0,-4:00
-1710,America/Araguaina,1996,Brazil,-180,60,10,6,-1,0,-3:00,2,11,-1,0,-4:00
-1711,America/Araguaina,1997,Brazil,-180,60,10,6,-1,0,-3:00,2,16,-1,0,-4:00
-1712,America/Araguaina,1998,Brazil,-180,60,10,11,-1,0,-3:00,3,1,-1,0,-4:00
-1713,America/Araguaina,1999,Brazil,-180,60,10,3,-1,0,-3:00,2,21,-1,0,-4:00
-1714,America/Araguaina,2000,Brazil,-180,60,10,8,0,0,-3:00,2,27,-1,0,-4:00
-1715,America/Araguaina,2001,Brazil,-180,60,10,8,0,0,-3:00,2,15,0,0,-4:00
-1716,America/Araguaina,2002,Brazil,-180,60,11,3,-1,0,-3:00,2,15,0,0,-4:00
-1717,America/Araguaina,2003,,-180,0,0,0,0,0,,0,0,0,0,
-1718,America/Maceio,1970,Brazil,-180,0,12,31,-1,0,09:00,3,1,-1,0,-4:00
-1719,America/Maceio,1985,Brazil,-180,60,11,2,-1,0,-3:00,1,1,-1,0,08:00
-1720,America/Maceio,1986,Brazil,-180,60,10,25,-1,0,-3:00,3,15,-1,0,-4:00
-1721,America/Maceio,1987,Brazil,-180,60,10,25,-1,0,-3:00,2,14,-1,0,-4:00
-1722,America/Maceio,1988,Brazil,-180,60,10,16,-1,0,-3:00,2,7,-1,0,-4:00
-1723,America/Maceio,1989,Brazil,-180,60,10,15,-1,0,-3:00,1,29,-1,0,-4:00
-1724,America/Maceio,1990,,-180,0,0,0,0,0,,0,0,0,0,
-1725,America/Maceio,1995,Brazil,-180,60,10,11,0,0,-3:00,2,15,0,0,-4:00
-1726,America/Maceio,1996,,-180,0,0,0,0,0,,0,0,0,0,
-1727,America/Maceio,1999,Brazil,-180,60,10,3,-1,0,-3:00,2,21,-1,0,-4:00
-1728,America/Maceio,2000,,-180,0,0,0,0,0,,0,0,0,0,
-1729,America/Maceio,2001,Brazil,-180,60,10,8,0,0,-3:00,2,15,0,0,-4:00
-1730,America/Maceio,2002,,-180,0,0,0,0,0,,0,0,0,0,
-1731,America/Bahia,1970,Brazil,-180,0,12,31,-1,0,09:00,3,1,-1,0,-4:00
-1732,America/Bahia,1985,Brazil,-180,60,11,2,-1,0,-3:00,1,1,-1,0,08:00
-1733,America/Bahia,1986,Brazil,-180,60,10,25,-1,0,-3:00,3,15,-1,0,-4:00
-1734,America/Bahia,1987,Brazil,-180,60,10,25,-1,0,-3:00,2,14,-1,0,-4:00
-1735,America/Bahia,1988,Brazil,-180,60,10,16,-1,0,-3:00,2,7,-1,0,-4:00
-1736,America/Bahia,1989,Brazil,-180,60,10,15,-1,0,-3:00,1,29,-1,0,-4:00
-1737,America/Bahia,1990,Brazil,-180,60,10,21,-1,0,-3:00,2,11,-1,0,-4:00
-1738,America/Bahia,1991,Brazil,-180,60,10,20,-1,0,-3:00,2,17,-1,0,-4:00
-1739,America/Bahia,1992,Brazil,-180,60,10,25,-1,0,-3:00,2,9,-1,0,-4:00
-1740,America/Bahia,1993,Brazil,-180,60,10,11,0,0,-3:00,1,31,-1,0,-4:00
-1741,America/Bahia,1994,Brazil,-180,60,10,11,0,0,-3:00,2,15,0,0,-4:00
-1742,America/Bahia,1996,Brazil,-180,60,10,6,-1,0,-3:00,2,11,-1,0,-4:00
-1743,America/Bahia,1997,Brazil,-180,60,10,6,-1,0,-3:00,2,16,-1,0,-4:00
-1744,America/Bahia,1998,Brazil,-180,60,10,11,-1,0,-3:00,3,1,-1,0,-4:00
-1745,America/Bahia,1999,Brazil,-180,60,10,3,-1,0,-3:00,2,21,-1,0,-4:00
-1746,America/Bahia,2000,Brazil,-180,60,10,8,0,0,-3:00,2,27,-1,0,-4:00
-1747,America/Bahia,2001,Brazil,-180,60,10,8,0,0,-3:00,2,15,0,0,-4:00
-1748,America/Bahia,2002,Brazil,-180,60,11,3,-1,0,-3:00,2,15,0,0,-4:00
-1749,America/Bahia,2003,,-180,0,0,0,0,0,,0,0,0,0,
-1750,America/Sao_Paulo,1970,Brazil,-180,0,12,31,-1,0,09:00,3,1,-1,0,-4:00
-1751,America/Sao_Paulo,1985,Brazil,-180,60,11,2,-1,0,-3:00,1,1,-1,0,08:00
-1752,America/Sao_Paulo,1986,Brazil,-180,60,10,25,-1,0,-3:00,3,15,-1,0,-4:00
-1753,America/Sao_Paulo,1987,Brazil,-180,60,10,25,-1,0,-3:00,2,14,-1,0,-4:00
-1754,America/Sao_Paulo,1988,Brazil,-180,60,10,16,-1,0,-3:00,2,7,-1,0,-4:00
-1755,America/Sao_Paulo,1989,Brazil,-180,60,10,15,-1,0,-3:00,1,29,-1,0,-4:00
-1756,America/Sao_Paulo,1990,Brazil,-180,60,10,21,-1,0,-3:00,2,11,-1,0,-4:00
-1757,America/Sao_Paulo,1991,Brazil,-180,60,10,20,-1,0,-3:00,2,17,-1,0,-4:00
-1758,America/Sao_Paulo,1992,Brazil,-180,60,10,25,-1,0,-3:00,2,9,-1,0,-4:00
-1759,America/Sao_Paulo,1993,Brazil,-180,60,10,11,0,0,-3:00,1,31,-1,0,-4:00
-1760,America/Sao_Paulo,1994,Brazil,-180,60,10,11,0,0,-3:00,2,15,0,0,-4:00
-1761,America/Sao_Paulo,1996,Brazil,-180,60,10,6,-1,0,-3:00,2,11,-1,0,-4:00
-1762,America/Sao_Paulo,1997,Brazil,-180,60,10,6,-1,0,-3:00,2,16,-1,0,-4:00
-1763,America/Sao_Paulo,1998,Brazil,-180,60,10,11,-1,0,-3:00,3,1,-1,0,-4:00
-1764,America/Sao_Paulo,1999,Brazil,-180,60,10,3,-1,0,-3:00,2,21,-1,0,-4:00
-1765,America/Sao_Paulo,2000,Brazil,-180,60,10,8,0,0,-3:00,2,27,-1,0,-4:00
-1766,America/Sao_Paulo,2001,Brazil,-180,60,10,8,0,0,-3:00,2,15,0,0,-4:00
-1767,America/Sao_Paulo,2002,Brazil,-180,60,11,3,-1,0,-3:00,2,15,0,0,-4:00
-1768,America/Sao_Paulo,2003,Brazil,-180,60,10,19,-1,0,-3:00,2,15,0,0,-4:00
-1769,America/Sao_Paulo,2004,Brazil,-180,60,11,2,-1,0,-3:00,2,15,0,0,-4:00
-1770,America/Sao_Paulo,2005,Brazil,-180,60,10,16,-1,0,-3:00,2,15,0,0,-4:00
-1771,America/Sao_Paulo,2006,Brazil,-180,60,11,1,0,0,-3:00,2,15,0,0,-4:00
-1772,America/Sao_Paulo,2007,Brazil,-180,60,11,1,0,0,-3:00,2,-1,0,0,-4:00
-1773,America/Campo_Grande,1970,Brazil,-240,0,12,31,-1,0,08:00,3,1,-1,0,-5:00
-1774,America/Campo_Grande,1985,Brazil,-240,60,11,2,-1,0,-4:00,1,1,-1,0,07:00
-1775,America/Campo_Grande,1986,Brazil,-240,60,10,25,-1,0,-4:00,3,15,-1,0,-5:00
-1776,America/Campo_Grande,1987,Brazil,-240,60,10,25,-1,0,-4:00,2,14,-1,0,-5:00
-1777,America/Campo_Grande,1988,Brazil,-240,60,10,16,-1,0,-4:00,2,7,-1,0,-5:00
-1778,America/Campo_Grande,1989,Brazil,-240,60,10,15,-1,0,-4:00,1,29,-1,0,-5:00
-1779,America/Campo_Grande,1990,Brazil,-240,60,10,21,-1,0,-4:00,2,11,-1,0,-5:00
-1780,America/Campo_Grande,1991,Brazil,-240,60,10,20,-1,0,-4:00,2,17,-1,0,-5:00
-1781,America/Campo_Grande,1992,Brazil,-240,60,10,25,-1,0,-4:00,2,9,-1,0,-5:00
-1782,America/Campo_Grande,1993,Brazil,-240,60,10,11,0,0,-4:00,1,31,-1,0,-5:00
-1783,America/Campo_Grande,1994,Brazil,-240,60,10,11,0,0,-4:00,2,15,0,0,-5:00
-1784,America/Campo_Grande,1996,Brazil,-240,60,10,6,-1,0,-4:00,2,11,-1,0,-5:00
-1785,America/Campo_Grande,1997,Brazil,-240,60,10,6,-1,0,-4:00,2,16,-1,0,-5:00
-1786,America/Campo_Grande,1998,Brazil,-240,60,10,11,-1,0,-4:00,3,1,-1,0,-5:00
-1787,America/Campo_Grande,1999,Brazil,-240,60,10,3,-1,0,-4:00,2,21,-1,0,-5:00
-1788,America/Campo_Grande,2000,Brazil,-240,60,10,8,0,0,-4:00,2,27,-1,0,-5:00
-1789,America/Campo_Grande,2001,Brazil,-240,60,10,8,0,0,-4:00,2,15,0,0,-5:00
-1790,America/Campo_Grande,2002,Brazil,-240,60,11,3,-1,0,-4:00,2,15,0,0,-5:00
-1791,America/Campo_Grande,2003,Brazil,-240,60,10,19,-1,0,-4:00,2,15,0,0,-5:00
-1792,America/Campo_Grande,2004,Brazil,-240,60,11,2,-1,0,-4:00,2,15,0,0,-5:00
-1793,America/Campo_Grande,2005,Brazil,-240,60,10,16,-1,0,-4:00,2,15,0,0,-5:00
-1794,America/Campo_Grande,2006,Brazil,-240,60,11,1,0,0,-4:00,2,15,0,0,-5:00
-1795,America/Campo_Grande,2007,Brazil,-240,60,11,1,0,0,-4:00,2,-1,0,0,-5:00
-1796,America/Cuiaba,1970,Brazil,-240,0,12,31,-1,0,08:00,3,1,-1,0,-5:00
-1797,America/Cuiaba,1985,Brazil,-240,60,11,2,-1,0,-4:00,1,1,-1,0,07:00
-1798,America/Cuiaba,1986,Brazil,-240,60,10,25,-1,0,-4:00,3,15,-1,0,-5:00
-1799,America/Cuiaba,1987,Brazil,-240,60,10,25,-1,0,-4:00,2,14,-1,0,-5:00
-1800,America/Cuiaba,1988,Brazil,-240,60,10,16,-1,0,-4:00,2,7,-1,0,-5:00
-1801,America/Cuiaba,1989,Brazil,-240,60,10,15,-1,0,-4:00,1,29,-1,0,-5:00
-1802,America/Cuiaba,1990,Brazil,-240,60,10,21,-1,0,-4:00,2,11,-1,0,-5:00
-1803,America/Cuiaba,1991,Brazil,-240,60,10,20,-1,0,-4:00,2,17,-1,0,-5:00
-1804,America/Cuiaba,1992,Brazil,-240,60,10,25,-1,0,-4:00,2,9,-1,0,-5:00
-1805,America/Cuiaba,1993,Brazil,-240,60,10,11,0,0,-4:00,1,31,-1,0,-5:00
-1806,America/Cuiaba,1994,Brazil,-240,60,10,11,0,0,-4:00,2,15,0,0,-5:00
-1807,America/Cuiaba,1996,Brazil,-240,60,10,6,-1,0,-4:00,2,11,-1,0,-5:00
-1808,America/Cuiaba,1997,Brazil,-240,60,10,6,-1,0,-4:00,2,16,-1,0,-5:00
-1809,America/Cuiaba,1998,Brazil,-240,60,10,11,-1,0,-4:00,3,1,-1,0,-5:00
-1810,America/Cuiaba,1999,Brazil,-240,60,10,3,-1,0,-4:00,2,21,-1,0,-5:00
-1811,America/Cuiaba,2000,Brazil,-240,60,10,8,0,0,-4:00,2,27,-1,0,-5:00
-1812,America/Cuiaba,2001,Brazil,-240,60,10,8,0,0,-4:00,2,15,0,0,-5:00
-1813,America/Cuiaba,2002,Brazil,-240,60,11,3,-1,0,-4:00,2,15,0,0,-5:00
-1814,America/Cuiaba,2003,,-240,0,0,0,0,0,,0,0,0,0,
-1815,America/Cuiaba,2004,Brazil,-240,60,11,2,-1,0,-4:00,2,15,0,0,-5:00
-1816,America/Cuiaba,2005,Brazil,-240,60,10,16,-1,0,-4:00,2,15,0,0,-5:00
-1817,America/Cuiaba,2006,Brazil,-240,60,11,1,0,0,-4:00,2,15,0,0,-5:00
-1818,America/Cuiaba,2007,Brazil,-240,60,11,1,0,0,-4:00,2,-1,0,0,-5:00
-1819,America/Porto_Velho,1970,Brazil,-240,0,12,31,-1,0,08:00,3,1,-1,0,-5:00
-1820,America/Porto_Velho,1985,Brazil,-240,60,11,2,-1,0,-4:00,1,1,-1,0,07:00
-1821,America/Porto_Velho,1986,Brazil,-240,60,10,25,-1,0,-4:00,3,15,-1,0,-5:00
-1822,America/Porto_Velho,1987,Brazil,-240,60,10,25,-1,0,-4:00,2,14,-1,0,-5:00
-1823,America/Porto_Velho,1988,,-240,0,0,0,0,0,,0,0,0,0,
-1824,America/Boa_Vista,1970,Brazil,-240,0,12,31,-1,0,08:00,3,1,-1,0,-5:00
-1825,America/Boa_Vista,1985,Brazil,-240,60,11,2,-1,0,-4:00,1,1,-1,0,07:00
-1826,America/Boa_Vista,1986,Brazil,-240,60,10,25,-1,0,-4:00,3,15,-1,0,-5:00
-1827,America/Boa_Vista,1987,Brazil,-240,60,10,25,-1,0,-4:00,2,14,-1,0,-5:00
-1828,America/Boa_Vista,1988,,-240,0,0,0,0,0,,0,0,0,0,
-1829,America/Boa_Vista,1999,Brazil,-240,60,10,3,-1,0,-4:00,2,21,-1,0,-5:00
-1830,America/Boa_Vista,2000,,-240,0,0,0,0,0,,0,0,0,0,
-1831,America/Manaus,1970,Brazil,-240,0,12,31,-1,0,08:00,3,1,-1,0,-5:00
-1832,America/Manaus,1985,Brazil,-240,60,11,2,-1,0,-4:00,1,1,-1,0,07:00
-1833,America/Manaus,1986,Brazil,-240,60,10,25,-1,0,-4:00,3,15,-1,0,-5:00
-1834,America/Manaus,1987,Brazil,-240,60,10,25,-1,0,-4:00,2,14,-1,0,-5:00
-1835,America/Manaus,1988,,-240,0,0,0,0,0,,0,0,0,0,
-1836,America/Manaus,1993,Brazil,-240,60,10,11,0,0,-4:00,1,31,-1,0,-5:00
-1837,America/Manaus,1994,,-240,0,0,0,0,0,,0,0,0,0,
-1838,America/Eirunepe,1970,Brazil,-300,0,12,31,-1,0,07:00,3,1,-1,0,-6:00
-1839,America/Eirunepe,1985,Brazil,-300,60,11,2,-1,0,-5:00,1,1,-1,0,06:00
-1840,America/Eirunepe,1986,Brazil,-300,60,10,25,-1,0,-5:00,3,15,-1,0,-6:00
-1841,America/Eirunepe,1987,Brazil,-300,60,10,25,-1,0,-5:00,2,14,-1,0,-6:00
-1842,America/Eirunepe,1988,,-300,0,0,0,0,0,,0,0,0,0,
-1843,America/Eirunepe,1993,Brazil,-300,60,10,11,0,0,-5:00,1,31,-1,0,-6:00
-1844,America/Eirunepe,1994,,-300,0,0,0,0,0,,0,0,0,0,
-1845,America/Rio_Branco,1970,Brazil,-300,0,12,31,-1,0,07:00,3,1,-1,0,-6:00
-1846,America/Rio_Branco,1985,Brazil,-300,60,11,2,-1,0,-5:00,1,1,-1,0,06:00
-1847,America/Rio_Branco,1986,Brazil,-300,60,10,25,-1,0,-5:00,3,15,-1,0,-6:00
-1848,America/Rio_Branco,1987,Brazil,-300,60,10,25,-1,0,-5:00,2,14,-1,0,-6:00
-1849,America/Rio_Branco,1988,,-300,0,0,0,0,0,,0,0,0,0,
-1850,America/Santiago,1970,Chile,-240,60,10,9,0,0,4:00,3,29,-1,0,3:00
-1851,America/Santiago,1971,Chile,-240,60,10,9,0,0,4:00,3,14,-1,0,3:00
-1852,America/Santiago,1972,Chile,-240,60,10,9,0,0,4:00,3,9,0,0,3:00
-1853,America/Santiago,1973,Chile,-240,60,9,30,-1,0,4:00,3,9,0,0,3:00
-1854,America/Santiago,1974,Chile,-240,60,10,9,0,0,4:00,3,9,0,0,3:00
-1855,America/Santiago,1987,Chile,-240,60,10,9,0,0,4:00,4,12,-1,0,3:00
-1856,America/Santiago,1988,Chile,-240,60,10,1,0,0,4:00,3,9,0,0,3:00
-1857,America/Santiago,1989,Chile,-240,60,10,9,0,0,4:00,3,9,0,0,3:00
-1858,America/Santiago,1990,Chile,-240,60,9,16,-1,0,4:00,3,18,-1,0,3:00
-1859,America/Santiago,1991,Chile,-240,60,10,9,0,0,4:00,3,9,0,0,3:00
-1860,America/Santiago,1997,Chile,-240,60,10,9,0,0,4:00,3,30,-1,0,3:00
-1861,America/Santiago,1998,Chile,-240,60,9,27,-1,0,4:00,3,9,0,0,3:00
-1862,America/Santiago,1999,Chile,-240,60,10,9,0,0,4:00,4,4,-1,0,3:00
-1863,America/Santiago,2000,Chile,-240,60,10,9,0,0,4:00,3,9,0,0,3:00
-1864,Pacific/Easter,1970,Chile,-420,60,10,9,0,0,4:00,3,29,-1,0,3:00
-1865,Pacific/Easter,1971,Chile,-420,60,10,9,0,0,4:00,3,14,-1,0,3:00
-1866,Pacific/Easter,1972,Chile,-420,60,10,9,0,0,4:00,3,9,0,0,3:00
-1867,Pacific/Easter,1973,Chile,-420,60,9,30,-1,0,4:00,3,9,0,0,3:00
-1868,Pacific/Easter,1974,Chile,-420,60,10,9,0,0,4:00,3,9,0,0,3:00
-1869,Pacific/Easter,1982,Chile,-360,60,10,9,0,0,4:00,3,9,0,0,3:00
-1870,Pacific/Easter,1987,Chile,-360,60,10,9,0,0,4:00,4,12,-1,0,3:00
-1871,Pacific/Easter,1988,Chile,-360,60,10,1,0,0,4:00,3,9,0,0,3:00
-1872,Pacific/Easter,1989,Chile,-360,60,10,9,0,0,4:00,3,9,0,0,3:00
-1873,Pacific/Easter,1990,Chile,-360,60,9,16,-1,0,4:00,3,18,-1,0,3:00
-1874,Pacific/Easter,1991,Chile,-360,60,10,9,0,0,4:00,3,9,0,0,3:00
-1875,Pacific/Easter,1997,Chile,-360,60,10,9,0,0,4:00,3,30,-1,0,3:00
-1876,Pacific/Easter,1998,Chile,-360,60,9,27,-1,0,4:00,3,9,0,0,3:00
-1877,Pacific/Easter,1999,Chile,-360,60,10,9,0,0,4:00,4,4,-1,0,3:00
-1878,Pacific/Easter,2000,Chile,-360,60,10,9,0,0,4:00,3,9,0,0,3:00
-1879,America/Bogota,1970,CO,-300,0,0,0,0,0,,0,0,0,0,
-1880,America/Bogota,1992,CO,-300,60,5,3,-1,0,-5:00,1,1,-1,0,06:00
-1881,America/Bogota,1993,CO,-300,0,12,31,-1,0,07:00,4,4,-1,0,-6:00
-1882,America/Curacao,1970,,-240,0,0,0,0,0,,0,0,0,0,
-1883,America/Guayaquil,1970,,-300,0,0,0,0,0,,0,0,0,0,
-1884,Pacific/Galapagos,1970,,-300,0,0,0,0,0,,0,0,0,0,
-1885,Pacific/Galapagos,1986,,-360,0,0,0,0,0,,0,0,0,0,
-1886,Atlantic/Stanley,1970,Falk,-240,0,12,31,-1,0,08:00,1,1,-1,0,-5:00
-1887,Atlantic/Stanley,1983,Falk,-180,60,9,-1,0,0,-3:00,1,1,-1,0,08:00
-1888,Atlantic/Stanley,1984,Falk,-180,60,9,16,-1,0,-3:00,4,-1,0,0,-4:00
-1889,Atlantic/Stanley,1985,Falk,-240,60,9,9,0,0,-4:00,4,-1,0,0,-5:00
-1890,Atlantic/Stanley,1986,Falk,-240,60,9,9,0,0,-4:00,4,16,0,0,-5:00
-1891,Atlantic/Stanley,2001,Falk,-240,60,9,1,0,0,-2:00,4,15,0,0,-3:00
-1892,America/Cayenne,1970,,-180,0,0,0,0,0,,0,0,0,0,
-1893,America/Guyana,1970,,-225,0,0,0,0,0,,0,0,0,0,
-1894,America/Guyana,1975,,-180,0,0,0,0,0,,0,0,0,0,
-1895,America/Guyana,1991,,-240,0,0,0,0,0,,0,0,0,0,
-1896,America/Asuncion,1970,,-240,0,0,0,0,0,,0,0,0,0,
-1897,America/Asuncion,1972,,-180,0,0,0,0,0,,0,0,0,0,
-1898,America/Asuncion,1974,Para,-240,0,0,0,0,0,,0,0,0,0,
-1899,America/Asuncion,1975,Para,-240,60,10,1,-1,0,-4:00,3,1,-1,0,-5:00
-1900,America/Asuncion,1979,Para,-240,60,10,1,-1,0,-4:00,4,1,-1,0,-5:00
-1901,America/Asuncion,1989,Para,-240,60,10,22,-1,0,-4:00,4,1,-1,0,-5:00
-1902,America/Asuncion,1990,Para,-240,60,10,1,-1,0,-4:00,4,1,-1,0,-5:00
-1903,America/Asuncion,1991,Para,-240,60,10,6,-1,0,-4:00,4,1,-1,0,-5:00
-1904,America/Asuncion,1992,Para,-240,60,10,5,-1,0,-4:00,3,1,-1,0,-5:00
-1905,America/Asuncion,1993,Para,-240,60,10,1,-1,0,-4:00,3,31,-1,0,-5:00
-1906,America/Asuncion,1994,Para,-240,60,10,1,-1,0,-4:00,2,-1,0,0,-5:00
-1907,America/Asuncion,1996,Para,-240,60,10,1,0,0,-4:00,3,1,-1,0,-5:00
-1908,America/Asuncion,1997,Para,-240,60,10,1,0,0,-4:00,2,-1,0,0,-5:00
-1909,America/Asuncion,1998,Para,-240,60,10,1,0,0,-4:00,3,1,0,0,-5:00
-1910,America/Asuncion,2002,Para,-240,60,9,1,0,0,-4:00,4,1,0,0,-5:00
-1911,America/Asuncion,2004,Para,-240,60,10,15,0,0,-4:00,4,1,0,0,-5:00
-1912,America/Asuncion,2005,Para,-240,60,10,15,0,0,-4:00,3,8,0,0,-5:00
-1913,America/Lima,1970,Peru,-300,0,12,31,-1,0,07:00,3,24,0,0,-6:00
-1914,America/Lima,1986,Peru,-300,60,1,1,-1,0,-5:00,4,1,-1,0,-6:00
-1915,America/Lima,1995,Peru,-300,0,1,1,-1,0,-5:00,4,1,-1,0,-6:00
-1916,Atlantic/South_Georgia,1970,,-120,0,0,0,0,0,,0,0,0,0,
-1917,America/Paramaribo,1970,,-210,0,0,0,0,0,,0,0,0,0,
-1918,America/Paramaribo,1975,,-210,0,0,0,0,0,,0,0,0,0,
-1919,America/Paramaribo,1984,,-180,0,0,0,0,0,,0,0,0,0,
-1920,America/Port_of_Spain,1970,,-240,0,0,0,0,0,,0,0,0,0,
-1921,America/Montevideo,1970,Uruguay,-180,30,5,27,-1,0,-3:00,12,2,-1,0,-4:00
-1922,America/Montevideo,1972,Uruguay,-180,60,4,24,-1,0,-3:00,8,15,-1,0,-4:00
-1923,America/Montevideo,1974,Uruguay,-180,60,12,22,-1,0,-3:00,1,1,-1,0,08:00
-1924,America/Montevideo,1976,Uruguay,-180,0,12,31,-1,0,09:00,10,1,-1,0,-4:00
-1925,America/Montevideo,1977,Uruguay,-180,60,12,4,-1,0,-3:00,1,1,-1,0,08:00
-1926,America/Montevideo,1978,Uruguay,-180,0,12,31,-1,0,09:00,4,1,-1,0,-4:00
-1927,America/Montevideo,1979,Uruguay,-180,60,10,1,-1,0,-3:00,1,1,-1,0,08:00
-1928,America/Montevideo,1980,Uruguay,-180,0,12,31,-1,0,09:00,5,1,-1,0,-4:00
-1929,America/Montevideo,1987,Uruguay,-180,60,12,14,-1,0,-3:00,1,1,-1,0,08:00
-1930,America/Montevideo,1988,Uruguay,-180,60,12,11,-1,0,-3:00,3,14,-1,0,-4:00
-1931,America/Montevideo,1989,Uruguay,-180,60,10,29,-1,0,-3:00,3,12,-1,0,-4:00
-1932,America/Montevideo,1990,Uruguay,-180,60,10,21,0,0,-3:00,3,1,0,0,-4:00
-1933,America/Montevideo,1992,Uruguay,-180,60,10,18,-1,0,-3:00,3,1,0,0,-4:00
-1934,America/Montevideo,1993,Uruguay,-180,0,12,31,-1,0,09:00,2,28,-1,0,-4:00
-1935,America/Montevideo,2004,Uruguay,-180,60,9,19,-1,0,-3:00,1,1,-1,0,08:00
-1936,America/Montevideo,2005,Uruguay,-180,60,10,9,-1,0,-1:00,3,27,-1,0,-2:00
-1937,America/Montevideo,2006,Uruguay,-180,60,10,1,0,0,-1:00,3,12,-1,0,-2:00
-1938,America/Montevideo,2007,Uruguay,-180,60,10,1,0,0,-1:00,3,8,0,0,-2:00
-1939,America/Caracas,1970,,-240,0,0,0,0,0,,0,0,0,0,
diff --git a/lib/yui/button/assets/background.png b/lib/yui/button/assets/background.png
deleted file mode 100755 (executable)
index 32a72e4..0000000
Binary files a/lib/yui/button/assets/background.png and /dev/null differ
diff --git a/lib/yui/button/assets/button.css b/lib/yui/button/assets/button.css
deleted file mode 100755 (executable)
index fcdcfa2..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
-Copyright (c) 2007, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 2.3.0
-*/
-.yui-button  {
-
-    display:-moz-inline-box; /* Gecko */
-    display:inline-block; /* IE, Opera and Safari */
-    border-width:1px 0;
-    border-style:solid;
-    border-color:#999;
-    background:#ecece3 url(background.png) left center;
-    margin:auto .25em;
-    
-}
-
-.yui-button.ie6 {
-
-    /* Give the transparent background image to IE 6 */
-    background-image:none;
-    filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../build/button/assets/background.png', sizingMethod = 'scale');
-
-}
-
-.yui-button .first-child {
-
-    display:block;
-    *display:inline-block; /* IE */
-    border-width:0 1px;
-    border-style:solid;
-    border-color:#999;
-    margin:0 -1px;
-    *position:relative;
-    *left:-1px;
-
-}
-
-.yui-button button,
-.yui-button a {
-
-    display:block;
-    *display:inline-block; /* IE */
-    padding:.25em .5em;
-    border:1px solid #ccc;
-
-}
-
-.yui-button button {
-
-    *overflow:visible; /* Remove superfluous padding for IE */
-    font-size:100%; /* Makes form controls resizable in IE */
-    background-color:transparent;
-    cursor:pointer;
-    cursor:hand;
-
-}
-
-.yui-button a {
-
-    text-decoration:none;
-    color:#000;           
-
-}
-
-.yui-split-button button,
-.yui-menu-button button {
-
-    padding-right:20px;
-    background-position:right center;
-    background-repeat:no-repeat;
-    
-}
-
-.yui-menu-button button {
-
-    background-image:url(menuarrow.gif);
-
-}
-
-.yui-split-button button {
-
-    background-image:url(splitarrow.gif);
-
-}
-
-
-/* Focus state */
-
-.yui-button-focus {
-
-    border-color:#5e5c95;
-
-}
-
-.yui-button-focus .first-child {
-
-    border-color:#5e5c95;
-
-}
-
-.yui-button-focus button, 
-.yui-button-focus a {
-
-    border-color:#cec1fc;
-
-}
-
-
-/* Hover state */
-
-.yui-button-hover {
-
-    border-color:#406fac;
-    background-color:#98d5fc;
-
-}
-
-.yui-button-hover .first-child {
-
-    border-color:#406fac;
-
-}
-
-.yui-button-hover button, 
-.yui-button-hover a {
-
-    border-color:#7099ce;
-
-}
-
-
-/* Active state */
-
-.yui-button-active {
-    
-    border-color:#7a8180;
-    background-color:#333;
-    
-}
-
-.yui-button-active .first-child {
-
-    border-color:#7a8180;
-
-}
-
-.yui-button-active button, 
-.yui-button-active a {
-
-    border-color:#98a09f;
-
-}
-
-.yui-split-button-activeoption button {
-
-    background-color:transparent;
-    background-image:url(splitarrow_active.gif);
-    
-}
-
-
-
-/* Checked state */
-
-.yui-radio-button-checked,
-.yui-checkbox-button-checked {
-    
-    border-color:#7a8180;
-    background-color:#333;
-    
-}
-
-.yui-radio-button-checked .first-child,
-.yui-checkbox-button-checked .first-child {
-
-    border-color:#7a8180;
-
-}
-
-.yui-radio-button-checked button,
-.yui-checkbox-button-checked button { 
-
-    border-color:#98a09f;
-
-}
-
-
-
-/* Disabled state */
-
-.yui-button-disabled {
-    
-    border-color:#cbcdc5;
-    background:#ecece3;
-
-    filter:none;
-    
-}
-
-.yui-button-disabled .first-child {
-
-    border-color:#cbcdc5;
-
-}
-
-.yui-button-disabled button, 
-.yui-button-disabled a {
-
-    border-color:transparent;
-    color:#b9b9b9;
-    cursor:default;
-
-}
\ No newline at end of file
diff --git a/lib/yui/button/assets/menuarrow.gif b/lib/yui/button/assets/menuarrow.gif
deleted file mode 100755 (executable)
index ffa2ba9..0000000
Binary files a/lib/yui/button/assets/menuarrow.gif and /dev/null differ
diff --git a/lib/yui/button/assets/splitarrow.gif b/lib/yui/button/assets/splitarrow.gif
deleted file mode 100755 (executable)
index 6d1ce65..0000000
Binary files a/lib/yui/button/assets/splitarrow.gif and /dev/null differ
diff --git a/lib/yui/button/assets/splitarrow_active.gif b/lib/yui/button/assets/splitarrow_active.gif
deleted file mode 100755 (executable)
index 25c0884..0000000
Binary files a/lib/yui/button/assets/splitarrow_active.gif and /dev/null differ
diff --git a/lib/yui/button/button-beta-debug.js b/lib/yui/button/button-beta-debug.js
deleted file mode 100755 (executable)
index c9dfa28..0000000
+++ /dev/null
@@ -1,4554 +0,0 @@
-/*
-Copyright (c) 2007, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 2.3.0
-*/
-/**
-* @module button
-* @description <p>The Button Control enables the creation of rich, graphical 
-* buttons that function like traditional HTML form buttons.  <em>Unlike</em> 
-* tradition HTML form buttons, buttons created with the Button Control can have 
-* a label that is different from its value.  With the inclusion of the optional 
-* <a href="module_menu.html">Menu Control</a>, the Button Control can also be
-* used to create menu buttons and split buttons, controls that are not 
-* available natively in HTML.  The Button Control can also be thought of as a 
-* way to create more visually engaging implementations of the browser's 
-* default radio-button and check-box controls.</p>
-* <p>The Button Control supports the following types:</p>
-* <dl>
-* <dt>push</dt>
-* <dd>Basic push button that can execute a user-specified command when 
-* pressed.</dd>
-* <dt>link</dt>
-* <dd>Navigates to a specified url when pressed.</dd>
-* <dt>submit</dt>
-* <dd>Submits the parent form when pressed.</dd>
-* <dt>reset</dt>
-* <dd>Resets the parent form when pressed.</dd>
-* <dt>checkbox</dt>
-* <dd>Maintains a "checked" state that can be toggled on and off.</dd>
-* <dt>radio</dt>
-* <dd>Maintains a "checked" state that can be toggled on and off.  Use with 
-* the ButtonGroup class to create a set of controls that are mutually 
-* exclusive; checking one button in the set will uncheck all others in 
-* the group.</dd>
-* <dt>menu</dt>
-* <dd>When pressed will show/hide a menu.</dd>
-* <dt>split</dt>
-* <dd>Can execute a user-specified command or display a menu when pressed.</dd>
-* </dl>
-* @title Button
-* @namespace YAHOO.widget
-* @requires yahoo, dom, element, event
-* @optional container, menu
-* @beta
-*/
-
-
-(function () {
-
-
-    /**
-    * The Button class creates a rich, graphical button.
-    * @param {String} p_oElement String specifying the id attribute of the 
-    * <code>&#60;input&#62;</code>, <code>&#60;button&#62;</code>,
-    * <code>&#60;a&#62;</code>, or <code>&#60;span&#62;</code> element to 
-    * be used to create the button.
-    * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-
-    * one-html.html#ID-6043025">HTMLInputElement</a>|<a href="http://www.w3.org
-    * /TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-34812697">
-    * HTMLButtonElement</a>|<a href="
-    * http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#
-    * ID-33759296">HTMLElement</a>} p_oElement Object reference for the 
-    * <code>&#60;input&#62;</code>, <code>&#60;button&#62;</code>, 
-    * <code>&#60;a&#62;</code>, or <code>&#60;span&#62;</code> element to be 
-    * used to create the button.
-    * @param {Object} p_oElement Object literal specifying a set of   
-    * configuration attributes used to create the button.
-    * @param {Object} p_oAttributes Optional. Object literal specifying a set  
-    * of configuration attributes used to create the button.
-    * @namespace YAHOO.widget
-    * @class Button
-    * @constructor
-    * @extends YAHOO.util.Element
-    */
-
-
-
-    // Shorthard for utilities
-
-    var Dom = YAHOO.util.Dom,
-        Event = YAHOO.util.Event,
-        Lang = YAHOO.lang,
-        Overlay = YAHOO.widget.Overlay,
-        Menu = YAHOO.widget.Menu,
-    
-    
-        // Private member variables
-    
-        m_oButtons = {},    // Collection of all Button instances
-        m_oOverlayManager = null,   // YAHOO.widget.OverlayManager instance
-        m_oSubmitTrigger = null,    // The button that submitted the form 
-        m_oFocusedButton = null;    // The button that has focus
-
-
-
-    // Private methods
-
-    
-    
-    /**
-    * @method createInputElement
-    * @description Creates an <code>&#60;input&#62;</code> element of the 
-    * specified type.
-    * @private
-    * @param {String} p_sType String specifying the type of 
-    * <code>&#60;input&#62;</code> element to create.
-    * @param {String} p_sName String specifying the name of 
-    * <code>&#60;input&#62;</code> element to create.
-    * @param {String} p_sValue String specifying the value of 
-    * <code>&#60;input&#62;</code> element to create.
-    * @param {String} p_bChecked Boolean specifying if the  
-    * <code>&#60;input&#62;</code> element is to be checked.
-    * @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-
-    * one-html.html#ID-6043025">HTMLInputElement</a>}
-    */
-    function createInputElement(p_sType, p_sName, p_sValue, p_bChecked) {
-    
-        var oInput,
-            sInput;
-    
-        if (Lang.isString(p_sType) && Lang.isString(p_sName)) {
-        
-            if (YAHOO.env.ua.ie) {
-        
-                /*
-                    For IE it is necessary to create the element with the 
-                    "type," "name," "value," and "checked" properties set all 
-                    at once.
-                */
-            
-                sInput = "<input type=\"" + p_sType + "\" name=\"" + 
-                    p_sName + "\"";
-        
-                if (p_bChecked) {
-        
-                    sInput += " checked";
-                
-                }
-                
-                sInput += ">";
-        
-                oInput = document.createElement(sInput);
-        
-            }
-            else {
-            
-                oInput = document.createElement("input");
-                oInput.name = p_sName;
-                oInput.type = p_sType;
-        
-                if (p_bChecked) {
-        
-                    oInput.checked = true;
-                
-                }
-        
-            }
-        
-            oInput.value = p_sValue;
-            
-            return oInput;
-        
-        }
-    
-    }
-    
-    
-    /**
-    * @method setAttributesFromSrcElement
-    * @description Gets the values for all the attributes of the source element 
-    * (either <code>&#60;input&#62;</code> or <code>&#60;a&#62;</code>) that 
-    * map to Button configuration attributes and sets them into a collection 
-    * that is passed to the Button constructor.
-    * @private
-    * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-
-    * one-html.html#ID-6043025">HTMLInputElement</a>|<a href="http://www.w3.org/
-    * TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-
-    * 48250443">HTMLAnchorElement</a>} p_oElement Object reference to the HTML 
-    * element (either <code>&#60;input&#62;</code> or <code>&#60;span&#62;
-    * </code>) used to create the button.
-    * @param {Object} p_oAttributes Object reference for the collection of 
-    * configuration attributes used to create the button.
-    */
-    function setAttributesFromSrcElement(p_oElement, p_oAttributes) {
-    
-        var sSrcElementNodeName = p_oElement.nodeName.toUpperCase(),
-            me = this,
-            oAttribute,
-            oRootNode,
-            sText;
-            
-    
-        /**
-        * @method setAttributeFromDOMAttribute
-        * @description Gets the value of the specified DOM attribute and sets it 
-        * into the collection of configuration attributes used to configure 
-        * the button.
-        * @private
-        * @param {String} p_sAttribute String representing the name of the 
-        * attribute to retrieve from the DOM element.
-        */
-        function setAttributeFromDOMAttribute(p_sAttribute) {
-    
-            if ( !(p_sAttribute in p_oAttributes) ) {
-    
-                /*
-                    Need to use "getAttributeNode" instead of "getAttribute" 
-                    because using "getAttribute," IE will return the innerText 
-                    of a <code>&#60;button&#62;</code> for the value attribute  
-                    rather than the value of the "value" attribute.
-                */
-        
-                oAttribute = p_oElement.getAttributeNode(p_sAttribute);
-        
-    
-                if (oAttribute && ("value" in oAttribute)) {
-    
-                    me.logger.log("Setting attribute \"" + p_sAttribute + 
-                        "\" using source element's attribute value of \"" + 
-                        oAttribute.value + "\"");
-    
-                    p_oAttributes[p_sAttribute] = oAttribute.value;
-    
-                }
-    
-            }
-        
-        }
-    
-    
-        /**
-        * @method setFormElementProperties
-        * @description Gets the value of the attributes from the form element  
-        * and sets them into the collection of configuration attributes used to 
-        * configure the button.
-        * @private
-        */
-        function setFormElementProperties() {
-    
-            setAttributeFromDOMAttribute("type");
-    
-            if (p_oAttributes.type == "button") {
-            
-                p_oAttributes.type = "push";
-            
-            }
-    
-            if ( !("disabled" in p_oAttributes) ) {
-    
-                p_oAttributes.disabled = p_oElement.disabled;
-    
-            }
-    
-            setAttributeFromDOMAttribute("name");
-            setAttributeFromDOMAttribute("value");
-            setAttributeFromDOMAttribute("title");
-    
-        }
-
-    
-        switch (sSrcElementNodeName) {
-        
-        case "A":
-            
-            p_oAttributes.type = "link";
-            
-            setAttributeFromDOMAttribute("href");
-            setAttributeFromDOMAttribute("target");
-        
-            break;
-    
-        case "INPUT":
-
-            setFormElementProperties();
-
-            if ( !("checked" in p_oAttributes) ) {
-    
-                p_oAttributes.checked = p_oElement.checked;
-    
-            }
-
-            break;
-
-        case "BUTTON":
-
-            setFormElementProperties();
-
-            oRootNode = p_oElement.parentNode.parentNode;
-
-            if (Dom.hasClass(oRootNode, this.CSS_CLASS_NAME + "-checked")) {
-            
-                p_oAttributes.checked = true;
-            
-            }
-
-            if (Dom.hasClass(oRootNode, this.CSS_CLASS_NAME + "-disabled")) {
-
-                p_oAttributes.disabled = true;
-            
-            }
-
-            p_oElement.removeAttribute("value");
-
-            p_oElement.setAttribute("type", "button");
-
-            break;
-        
-        }
-
-        p_oElement.removeAttribute("id");
-        p_oElement.removeAttribute("name");
-        
-        if ( !("tabindex" in p_oAttributes) ) {
-
-            p_oAttributes.tabindex = p_oElement.tabIndex;
-
-        }
-    
-        if ( !("label" in p_oAttributes) ) {
-    
-            // Set the "label" property
-        
-            sText = sSrcElementNodeName == "INPUT" ? 
-                            p_oElement.value : p_oElement.innerHTML;
-        
-    
-            if (sText && sText.length > 0) {
-                
-                p_oAttributes.label = sText;
-                
-            } 
-    
-        }
-    
-    }
-    
-    
-    /**
-    * @method initConfig
-    * @description Initializes the set of configuration attributes that are 
-    * used to instantiate the button.
-    * @private
-    * @param {Object} Object representing the button's set of 
-    * configuration attributes.
-    */
-    function initConfig(p_oConfig) {
-    
-        var oAttributes = p_oConfig.attributes,
-            oSrcElement = oAttributes.srcelement,
-            sSrcElementNodeName = oSrcElement.nodeName.toUpperCase(),
-            me = this;
-    
-    
-        if (sSrcElementNodeName == this.NODE_NAME) {
-    
-            p_oConfig.element = oSrcElement;
-            p_oConfig.id = oSrcElement.id;
-
-            Dom.getElementsBy(function (p_oElement) {
-            
-                switch (p_oElement.nodeName.toUpperCase()) {
-                
-                case "BUTTON":
-                case "A":
-                case "INPUT":
-
-                    setAttributesFromSrcElement.call(me, p_oElement, 
-                        oAttributes);
-
-                    break;                        
-                
-                }
-            
-            }, "*", oSrcElement);
-        
-        }
-        else {
-    
-            switch (sSrcElementNodeName) {
-
-            case "BUTTON":
-            case "A":
-            case "INPUT":
-
-                setAttributesFromSrcElement.call(this, oSrcElement, 
-                    oAttributes);
-
-                break;
-
-            }
-        
-        }
-    
-    }
-
-
-
-    //  Constructor
-
-    YAHOO.widget.Button = function (p_oElement, p_oAttributes) {
-    
-        var fnSuperClass = YAHOO.widget.Button.superclass.constructor,
-            oConfig,
-            oElement;
-    
-        if (arguments.length == 1 && !Lang.isString(p_oElement) && 
-            !p_oElement.nodeName) {
-    
-            if (!p_oElement.id) {
-    
-                p_oElement.id = Dom.generateId();
-    
-                YAHOO.log("No value specified for the button's \"id\" " + 
-                    "attribute. Setting button id to \"" + p_oElement.id + 
-                    "\".", "warn");
-    
-            }
-    
-            this.logger = new YAHOO.widget.LogWriter("Button " + p_oElement.id);
-    
-            this.logger.log("No source HTML element.  Building the button " +
-                    "using the set of configuration attributes.");
-    
-            fnSuperClass.call(this, 
-                (this.createButtonElement(p_oElement.type)),
-                p_oElement);
-    
-        }
-        else {
-    
-            oConfig = { element: null, attributes: (p_oAttributes || {}) };
-    
-    
-            if (Lang.isString(p_oElement)) {
-    
-                oElement = Dom.get(p_oElement);
-    
-                if (oElement) {
-
-                    if (!oConfig.attributes.id) {
-                    
-                        oConfig.attributes.id = p_oElement;
-                    
-                    }
-    
-                    this.logger = new YAHOO.widget.LogWriter(
-                                        "Button " + oConfig.attributes.id);
-                
-                    this.logger.log("Building the button using an existing " + 
-                            "HTML element as a source element.");
-                
-                
-                    oConfig.attributes.srcelement = oElement;
-                
-                    initConfig.call(this, oConfig);
-                
-                
-                    if (!oConfig.element) {
-                
-                        this.logger.log("Source element could not be used " +
-                                "as is.  Creating a new HTML element for " + 
-                                "the button.");
-                
-                        oConfig.element = 
-                            this.createButtonElement(oConfig.attributes.type);
-                
-                    }
-                
-                    fnSuperClass.call(this, oConfig.element, 
-                        oConfig.attributes);
-    
-                }
-    
-            }
-            else if (p_oElement.nodeName) {
-    
-                if (!oConfig.attributes.id) {
-    
-                    if (p_oElement.id) {
-        
-                        oConfig.attributes.id = p_oElement.id;
-                    
-                    }
-                    else {
-        
-                        oConfig.attributes.id = Dom.generateId();
-        
-                        YAHOO.log("No value specified for the button's " +
-                            "\"id\" attribute. Setting button id to \"" + 
-                            oConfig.attributes.id + "\".", "warn");
-        
-                    }
-    
-                }
-    
-    
-                this.logger = new YAHOO.widget.LogWriter(
-                    "Button " + oConfig.attributes.id);
-    
-                this.logger.log("Building the button using an existing HTML " + 
-                    "element as a source element.");
-    
-    
-                oConfig.attributes.srcelement = p_oElement;
-        
-                initConfig.call(this, oConfig);
-        
-        
-                if (!oConfig.element) {
-    
-                    this.logger.log("Source element could not be used as is." +
-                            "  Creating a new HTML element for the button.");
-            
-                    oConfig.element = 
-                        this.createButtonElement(oConfig.attributes.type);
-            
-                }
-            
-                fnSuperClass.call(this, oConfig.element, oConfig.attributes);
-            
-            }
-    
-        }
-    
-    };
-
-
-
-    YAHOO.extend(YAHOO.widget.Button, YAHOO.util.Element, {
-    
-    
-        // Protected properties
-        
-        
-        /** 
-        * @property _button
-        * @description Object reference to the button's internal 
-        * <code>&#60;a&#62;</code> or <code>&#60;button&#62;</code> element.
-        * @default null
-        * @protected
-        * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-        * level-one-html.html#ID-48250443">HTMLAnchorElement</a>|<a href="
-        * http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html
-        * #ID-34812697">HTMLButtonElement</a>
-        */
-        _button: null,
-        
-        
-        /** 
-        * @property _menu
-        * @description Object reference to the button's menu.
-        * @default null
-        * @protected
-        * @type {<a href="YAHOO.widget.Overlay.html">YAHOO.widget.Overlay</a>|
-        * <a href="YAHOO.widget.Menu.html">YAHOO.widget.Menu</a>}
-        */
-        _menu: null,
-        
-        
-        /** 
-        * @property _hiddenFields
-        * @description Object reference to the <code>&#60;input&#62;</code>  
-        * element, or array of HTML form elements used to represent the button
-        *  when its parent form is submitted.
-        * @default null
-        * @protected
-        * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-        * level-one-html.html#ID-6043025">HTMLInputElement</a>|Array
-        */
-        _hiddenFields: null,
-        
-        
-        /** 
-        * @property _onclickAttributeValue
-        * @description Object reference to the button's current value for the 
-        * "onclick" configuration attribute.
-        * @default null
-        * @protected
-        * @type Object
-        */
-        _onclickAttributeValue: null,
-        
-        
-        /** 
-        * @property _activationKeyPressed
-        * @description Boolean indicating if the key(s) that toggle the button's 
-        * "active" state have been pressed.
-        * @default false
-        * @protected
-        * @type Boolean
-        */
-        _activationKeyPressed: false,
-        
-        
-        /** 
-        * @property _activationButtonPressed
-        * @description Boolean indicating if the mouse button that toggles 
-        * the button's "active" state has been pressed.
-        * @default false
-        * @protected
-        * @type Boolean
-        */
-        _activationButtonPressed: false,
-        
-        
-        /** 
-        * @property _hasKeyEventHandlers
-        * @description Boolean indicating if the button's "blur", "keydown" and 
-        * "keyup" event handlers are assigned
-        * @default false
-        * @protected
-        * @type Boolean
-        */
-        _hasKeyEventHandlers: false,
-        
-        
-        /** 
-        * @property _hasMouseEventHandlers
-        * @description Boolean indicating if the button's "mouseout," 
-        * "mousedown," and "mouseup" event handlers are assigned
-        * @default false
-        * @protected
-        * @type Boolean
-        */
-        _hasMouseEventHandlers: false,
-        
-        
-        
-        // Constants
-        
-        
-        /**
-        * @property NODE_NAME
-        * @description The name of the node to be used for the button's 
-        * root element.
-        * @default "SPAN"
-        * @final
-        * @type String
-        */
-        NODE_NAME: "SPAN",
-        
-        
-        /**
-        * @property CHECK_ACTIVATION_KEYS
-        * @description Array of numbers representing keys that (when pressed) 
-        * toggle the button's "checked" attribute.
-        * @default [32]
-        * @final
-        * @type Array
-        */
-        CHECK_ACTIVATION_KEYS: [32],
-        
-        
-        /**
-        * @property ACTIVATION_KEYS
-        * @description Array of numbers representing keys that (when presed) 
-        * toggle the button's "active" state.
-        * @default [13, 32]
-        * @final
-        * @type Array
-        */
-        ACTIVATION_KEYS: [13, 32],
-        
-        
-        /**
-        * @property OPTION_AREA_WIDTH
-        * @description Width (in pixels) of the area of a split button that  
-        * when pressed will display a menu.
-        * @default 20
-        * @final
-        * @type Number
-        */
-        OPTION_AREA_WIDTH: 20,
-        
-        
-        /**
-        * @property CSS_CLASS_NAME
-        * @description String representing the CSS class(es) to be applied to  
-        * the button's root element.
-        * @default "yui-button"
-        * @final
-        * @type String
-        */
-        CSS_CLASS_NAME: "yui-button",
-        
-        
-        /**
-        * @property RADIO_DEFAULT_TITLE
-        * @description String representing the default title applied to buttons 
-        * of type "radio." 
-        * @default "Unchecked.  Click to check."
-        * @final
-        * @type String
-        */
-        RADIO_DEFAULT_TITLE: "Unchecked.  Click to check.",
-        
-        
-        /**
-        * @property RADIO_CHECKED_TITLE
-        * @description String representing the title applied to buttons of 
-        * type "radio" when checked.
-        * @default "Checked.  Click to uncheck."
-        * @final
-        * @type String
-        */
-        RADIO_CHECKED_TITLE: "Checked.  Click to uncheck.",
-        
-        
-        /**
-        * @property CHECKBOX_DEFAULT_TITLE
-        * @description String representing the default title applied to 
-        * buttons of type "checkbox." 
-        * @default "Unchecked.  Click to check."
-        * @final
-        * @type String
-        */
-        CHECKBOX_DEFAULT_TITLE: "Unchecked.  Click to check.",
-        
-        
-        /**
-        * @property CHECKBOX_CHECKED_TITLE
-        * @description String representing the title applied to buttons of type 
-        * "checkbox" when checked.
-        * @default "Checked.  Click to uncheck."
-        * @final
-        * @type String
-        */
-        CHECKBOX_CHECKED_TITLE: "Checked.  Click to uncheck.",
-        
-        
-        /**
-        * @property MENUBUTTON_DEFAULT_TITLE
-        * @description String representing the default title applied to 
-        * buttons of type "menu." 
-        * @default "Menu collapsed.  Click to expand."
-        * @final
-        * @type String
-        */
-        MENUBUTTON_DEFAULT_TITLE: "Menu collapsed.  Click to expand.",
-        
-        
-        /**
-        * @property MENUBUTTON_MENU_VISIBLE_TITLE
-        * @description String representing the title applied to buttons of type 
-        * "menu" when the button's menu is visible. 
-        * @default "Menu expanded.  Click or press Esc to collapse."
-        * @final
-        * @type String
-        */
-        MENUBUTTON_MENU_VISIBLE_TITLE: 
-            "Menu expanded.  Click or press Esc to collapse.",
-        
-        
-        /**
-        * @property SPLITBUTTON_DEFAULT_TITLE
-        * @description  String representing the default title applied to 
-        * buttons of type "split." 
-        * @default "Menu collapsed.  Click inside option region or press 
-        * Ctrl + Shift + M to show the menu."
-        * @final
-        * @type String
-        */
-        SPLITBUTTON_DEFAULT_TITLE: ("Menu collapsed.  Click inside option " + 
-            "region or press Ctrl + Shift + M to show the menu."),
-        
-        
-        /**
-        * @property SPLITBUTTON_OPTION_VISIBLE_TITLE
-        * @description String representing the title applied to buttons of type 
-        * "split" when the button's menu is visible. 
-        * @default "Menu expanded.  Press Esc or Ctrl + Shift + M to hide 
-        * the menu."
-        * @final
-        * @type String
-        */
-        SPLITBUTTON_OPTION_VISIBLE_TITLE: 
-            "Menu expanded.  Press Esc or Ctrl + Shift + M to hide the menu.",
-        
-        
-        /**
-        * @property SUBMIT_TITLE
-        * @description String representing the title applied to buttons of 
-        * type "submit." 
-        * @default "Click to submit form."
-        * @final
-        * @type String
-        */
-        SUBMIT_TITLE: "Click to submit form.",
-        
-        
-        
-        // Protected attribute setter methods
-        
-        
-        /**
-        * @method _setType
-        * @description Sets the value of the button's "type" attribute.
-        * @protected
-        * @param {String} p_sType String indicating the value for the button's 
-        * "type" attribute.
-        */
-        _setType: function (p_sType) {
-        
-            if (p_sType == "split") {
-        
-                this.on("option", this._onOption);
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method _setLabel
-        * @description Sets the value of the button's "label" attribute.
-        * @protected
-        * @param {String} p_sLabel String indicating the value for the button's 
-        * "label" attribute.
-        */
-        _setLabel: function (p_sLabel) {
-
-            this._button.innerHTML = p_sLabel;             
-        
-        },
-        
-        
-        /**
-        * @method _setTabIndex
-        * @description Sets the value of the button's "tabindex" attribute.
-        * @protected
-        * @param {Number} p_nTabIndex Number indicating the value for the 
-        * button's "tabindex" attribute.
-        */
-        _setTabIndex: function (p_nTabIndex) {
-        
-            this._button.tabIndex = p_nTabIndex;
-        
-        },
-        
-        
-        /**
-        * @method _setTitle
-        * @description Sets the value of the button's "title" attribute.
-        * @protected
-        * @param {String} p_nTabIndex Number indicating the value for 
-        * the button's "title" attribute.
-        */
-        _setTitle: function (p_sTitle) {
-        
-            var sTitle = p_sTitle;
-        
-            if (this.get("type") != "link") {
-        
-                if (!sTitle) {
-        
-                    switch (this.get("type")) {
-        
-                    case "radio":
-    
-                        sTitle = this.RADIO_DEFAULT_TITLE;
-    
-                        break;
-    
-                    case "checkbox":
-    
-                        sTitle = this.CHECKBOX_DEFAULT_TITLE;
-    
-                        break;
-                    
-                    case "menu":
-    
-                        sTitle = this.MENUBUTTON_DEFAULT_TITLE;
-    
-                        break;
-    
-                    case "split":
-    
-                        sTitle = this.SPLITBUTTON_DEFAULT_TITLE;
-    
-                        break;
-    
-                    case "submit":
-    
-                        sTitle = this.SUBMIT_TITLE;
-    
-                        break;
-        
-                    }
-        
-                }
-        
-                this._button.title = sTitle;
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method _setDisabled
-        * @description Sets the value of the button's "disabled" attribute.
-        * @protected
-        * @param {Boolean} p_bDisabled Boolean indicating the value for 
-        * the button's "disabled" attribute.
-        */
-        _setDisabled: function (p_bDisabled) {
-        
-            if (this.get("type") != "link") {
-        
-                if (p_bDisabled) {
-        
-                    if (this._menu) {
-        
-                        this._menu.hide();
-        
-                    }
-        
-                    if (this.hasFocus()) {
-                    
-                        this.blur();
-                    
-                    }
-        
-                    this._button.setAttribute("disabled", "disabled");
-        
-                    this.addStateCSSClasses("disabled");
-        
-                }
-                else {
-        
-                    this._button.removeAttribute("disabled");
-        
-                    this.removeStateCSSClasses("disabled");
-                
-                }
-        
-            }
-        
-        },
-
-        
-        /**
-        * @method _setHref
-        * @description Sets the value of the button's "href" attribute.
-        * @protected
-        * @param {String} p_sHref String indicating the value for the button's 
-        * "href" attribute.
-        */
-        _setHref: function (p_sHref) {
-        
-            if (this.get("type") == "link") {
-        
-                this._button.href = p_sHref;
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method _setTarget
-        * @description Sets the value of the button's "target" attribute.
-        * @protected
-        * @param {String} p_sTarget String indicating the value for the button's 
-        * "target" attribute.
-        */
-        _setTarget: function (p_sTarget) {
-        
-            if (this.get("type") == "link") {
-        
-                this._button.setAttribute("target", p_sTarget);
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method _setChecked
-        * @description Sets the value of the button's "target" attribute.
-        * @protected
-        * @param {Boolean} p_bChecked Boolean indicating the value for  
-        * the button's "checked" attribute.
-        */
-        _setChecked: function (p_bChecked) {
-        
-            var sType = this.get("type"),
-                sTitle;
-        
-            if (sType == "checkbox" || sType == "radio") {
-        
-                if (p_bChecked) {
-        
-                    this.addStateCSSClasses("checked");
-                    
-                    sTitle = (sType == "radio") ? 
-                                this.RADIO_CHECKED_TITLE : 
-                                this.CHECKBOX_CHECKED_TITLE;
-                
-                }
-                else {
-
-                    this.removeStateCSSClasses("checked");
-        
-                    sTitle = (sType == "radio") ? 
-                                this.RADIO_DEFAULT_TITLE : 
-                                this.CHECKBOX_DEFAULT_TITLE;
-                
-                }
-        
-                this.set("title", sTitle);
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method _setMenu
-        * @description Sets the value of the button's "menu" attribute.
-        * @protected
-        * @param {Object} p_oMenu Object indicating the value for the button's 
-        * "menu" attribute.
-        */
-        _setMenu: function (p_oMenu) {
-
-            var bLazyLoad = this.get("lazyloadmenu"),
-                oButtonElement = this.get("element"),
-        
-                /*
-                    Boolean indicating if the value of p_oMenu is an instance 
-                    of YAHOO.widget.Menu or YAHOO.widget.Overlay.
-                */
-        
-                bInstance = false,
-        
-
-                oMenu,
-                oMenuElement,
-                oSrcElement,
-                aItems,
-                nItems,
-                oItem,
-                i;
-        
-        
-            if (!Overlay) {
-        
-                this.logger.log("YAHOO.widget.Overlay dependency not met.", 
-                    "error");
-        
-                return false;
-            
-            }
-        
-        
-            if (!Menu) {
-        
-                this.logger.log("YAHOO.widget.Menu dependency not met.", 
-                    "error");
-        
-                return false;
-            
-            }
-        
-        
-            function onAppendTo() {
-
-                oMenu.render(oButtonElement.parentNode);
-                
-                this.removeListener("appendTo", onAppendTo);
-            
-            }
-        
-        
-            function initMenu() {
-        
-                if (oMenu) {
-
-                    Dom.addClass(oMenu.element, this.get("menuclassname"));
-                    Dom.addClass(oMenu.element, 
-                            "yui-" + this.get("type") + "-button-menu");
-
-                    oMenu.showEvent.subscribe(this._onMenuShow, null, this);
-                    oMenu.hideEvent.subscribe(this._onMenuHide, null, this);
-                    oMenu.renderEvent.subscribe(this._onMenuRender, null, this);
-        
-        
-                    if (oMenu instanceof Menu) {
-        
-                        oMenu.keyDownEvent.subscribe(this._onMenuKeyDown, 
-                            this, true);
-
-                        oMenu.clickEvent.subscribe(this._onMenuClick, 
-                            this, true);
-
-                        oMenu.itemAddedEvent.subscribe(this._onMenuItemAdded, 
-                            this, true);
-        
-                        oSrcElement = oMenu.srcElement;
-        
-                        if (oSrcElement && 
-                            oSrcElement.nodeName.toUpperCase() == "SELECT") {
-                
-                            oSrcElement.style.display = "none";
-                            oSrcElement.parentNode.removeChild(oSrcElement);
-        
-                        }
-        
-                    }
-                    else if (oMenu instanceof Overlay) {
-        
-                        if (!m_oOverlayManager) {
-        
-                            m_oOverlayManager = 
-                                new YAHOO.widget.OverlayManager();
-                        
-                        }
-                        
-                        m_oOverlayManager.register(oMenu);
-                        
-                    }
-        
-        
-                    this._menu = oMenu;
-
-        
-                    if (!bInstance) {
-        
-                        if (bLazyLoad && !(oMenu instanceof Menu)) {
-        
-                            /*
-                                Mimic Menu's "lazyload" functionality by adding  
-                                a "beforeshow" event listener that renders the 
-                                Overlay instance before it is made visible by  
-                                the button.
-                            */
-        
-                            oMenu.beforeShowEvent.subscribe(
-                                this._onOverlayBeforeShow, null, this);
-            
-                        }
-                        else if (!bLazyLoad) {
-        
-                            if (Dom.inDocument(oButtonElement)) {
-        
-                                oMenu.render(oButtonElement.parentNode);
-                            
-                            }
-                            else {
-            
-                                this.on("appendTo", onAppendTo);
-                            
-                            }
-                        
-                        }
-                    
-                    }
-        
-                }
-        
-            }
-        
-        
-            if (p_oMenu && (p_oMenu instanceof Menu)) {
-        
-                oMenu = p_oMenu;
-                aItems = oMenu.getItems();
-                nItems = aItems.length;
-                bInstance = true;
-        
-        
-                if (nItems > 0) {
-        
-                    i = nItems - 1;
-        
-                    do {
-        
-                        oItem = aItems[i];
-        
-                        if (oItem) {
-        
-                            oItem.cfg.subscribeToConfigEvent("selected", 
-                                this._onMenuItemSelected, 
-                                oItem, 
-                                this);
-        
-                        }
-        
-                    }
-                    while (i--);
-        
-                }
-        
-                initMenu.call(this);
-        
-            }
-            else if (p_oMenu && (p_oMenu instanceof Overlay)) {
-        
-                oMenu = p_oMenu;
-                bInstance = true;
-        
-                oMenu.cfg.setProperty("visible", false);
-                oMenu.cfg.setProperty("context", [oButtonElement, "tl", "bl"]);
-        
-                initMenu.call(this);
-        
-            }
-            else if (Lang.isArray(p_oMenu)) {
-        
-                this.on("appendTo", function () {
-        
-                    oMenu = new Menu(Dom.generateId(), { lazyload: bLazyLoad, 
-                        itemdata: p_oMenu });
-        
-                    initMenu.call(this);
-        
-                });
-        
-            }
-            else if (Lang.isString(p_oMenu)) {
-        
-                oMenuElement = Dom.get(p_oMenu);
-        
-                if (oMenuElement) {
-        
-                    if (Dom.hasClass(oMenuElement, 
-                        Menu.prototype.CSS_CLASS_NAME) || 
-                        oMenuElement.nodeName == "SELECT") {
-            
-                        oMenu = new Menu(p_oMenu, { lazyload: bLazyLoad });
-            
-                        initMenu.call(this);
-            
-                    }
-                    else {
-        
-                        oMenu = new Overlay(p_oMenu, { visible: false, 
-                            context: [oButtonElement, "tl", "bl"] });
-            
-                        initMenu.call(this);
-            
-                    }
-        
-                }
-        
-            }
-            else if (p_oMenu && p_oMenu.nodeName) {
-        
-                if (Dom.hasClass(p_oMenu, Menu.prototype.CSS_CLASS_NAME) || 
-                        p_oMenu.nodeName == "SELECT") {
-        
-                    oMenu = new Menu(p_oMenu, { lazyload: bLazyLoad });
-                
-                    initMenu.call(this);
-        
-                }
-                else {
-        
-                    if (!p_oMenu.id) {
-                    
-                        Dom.generateId(p_oMenu);
-                    
-                    }
-        
-                    oMenu = new Overlay(p_oMenu, { visible: false, 
-                                    context: [oButtonElement, "tl", "bl"] });
-        
-                    initMenu.call(this);
-                
-                }
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method _setOnClick
-        * @description Sets the value of the button's "onclick" attribute.
-        * @protected
-        * @param {Object} p_oObject Object indicating the value for the button's 
-        * "onclick" attribute.
-        */
-        _setOnClick: function (p_oObject) {
-        
-            /*
-                Remove any existing listeners if a "click" event handler 
-                has already been specified.
-            */
-        
-            if (this._onclickAttributeValue && 
-                (this._onclickAttributeValue != p_oObject)) {
-        
-                this.removeListener("click", this._onclickAttributeValue.fn);
-        
-                this._onclickAttributeValue = null;
-        
-            }
-        
-        
-            if (!this._onclickAttributeValue && 
-                Lang.isObject(p_oObject) && 
-                Lang.isFunction(p_oObject.fn)) {
-        
-                this.on("click", p_oObject.fn, p_oObject.obj, p_oObject.scope);
-        
-                this._onclickAttributeValue = p_oObject;
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method _setSelectedMenuItem
-        * @description Sets the value of the button's 
-        * "selectedMenuItem" attribute.
-        * @protected
-        * @param {Number} p_nIndex Number representing the index of the item 
-        * in the button's menu that is currently selected.
-        */
-        _setSelectedMenuItem: function (p_nIndex) {
-
-            var oMenu = this._menu,
-                oMenuItem;
-
-
-            if (oMenu && oMenu instanceof Menu) {
-
-                oMenuItem = oMenu.getItem(p_nIndex);
-                
-
-                if (oMenuItem && !oMenuItem.cfg.getProperty("selected")) {
-                
-                    oMenuItem.cfg.setProperty("selected", true);
-                
-                }
-            
-            }
-
-        },
-        
-        
-        // Protected methods
-
-        
-        
-        /**
-        * @method _isActivationKey
-        * @description Determines if the specified keycode is one that toggles  
-        * the button's "active" state.
-        * @protected
-        * @param {Number} p_nKeyCode Number representing the keycode to 
-        * be evaluated.
-        * @return {Boolean}
-        */
-        _isActivationKey: function (p_nKeyCode) {
-        
-            var sType = this.get("type"),
-                aKeyCodes = (sType == "checkbox" || sType == "radio") ? 
-                    this.CHECK_ACTIVATION_KEYS : this.ACTIVATION_KEYS,
-        
-                nKeyCodes = aKeyCodes.length,
-                i;
-        
-            if (nKeyCodes > 0) {
-        
-                i = nKeyCodes - 1;
-        
-                do {
-        
-                    if (p_nKeyCode == aKeyCodes[i]) {
-        
-                        return true;
-        
-                    }
-        
-                }
-                while (i--);
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method _isSplitButtonOptionKey
-        * @description Determines if the specified keycode is one that toggles  
-        * the display of the split button's menu.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        * @return {Boolean}
-        */
-        _isSplitButtonOptionKey: function (p_oEvent) {
-        
-            return (p_oEvent.ctrlKey && p_oEvent.shiftKey && 
-                Event.getCharCode(p_oEvent) == 77);
-        
-        },
-        
-        
-        /**
-        * @method _addListenersToForm
-        * @description Adds event handlers to the button's form.
-        * @protected
-        */
-        _addListenersToForm: function () {
-        
-            var oForm = this.getForm(),
-                oSrcElement,
-                aListeners,
-                nListeners,
-                i,
-                bHasKeyPressListener;
-        
-        
-            if (oForm) {
-        
-                Event.on(oForm, "reset", this._onFormReset, null, this);
-                Event.on(oForm, "submit", this.createHiddenFields, null, this);
-        
-                oSrcElement = this.get("srcelement");
-        
-        
-                if (this.get("type") == "submit" || 
-                    (oSrcElement && oSrcElement.type == "submit")) 
-                {
-                
-                    aListeners = Event.getListeners(oForm, "keypress");
-                    bHasKeyPressListener = false;
-            
-                    if (aListeners) {
-            
-                        nListeners = aListeners.length;
-        
-                        if (nListeners > 0) {
-            
-                            i = nListeners - 1;
-                            
-                            do {
-               
-                                if (aListeners[i].fn == 
-                                    YAHOO.widget.Button.onFormKeyPress) 
-                                {
-                
-                                    bHasKeyPressListener = true;
-                                    break;
-                                
-                                }
-                
-                            }
-                            while (i--);
-                        
-                        }
-                    
-                    }
-            
-            
-                    if (!bHasKeyPressListener) {
-        
-                        Event.on(oForm, "keypress", 
-                            YAHOO.widget.Button.onFormKeyPress);
-            
-                    }
-        
-                }
-            
-            }
-        
-        },
-        
-        
-        _originalMaxHeight: -1,
-        
-        
-        /**
-        * @method _showMenu
-        * @description Shows the button's menu.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object 
-        * passed back by the event utility (YAHOO.util.Event) that triggered 
-        * the display of the menu.
-        */
-        _showMenu: function (p_oEvent) {
-        
-            YAHOO.widget.MenuManager.hideVisible();
-        
-            if (m_oOverlayManager) {
-        
-                m_oOverlayManager.hideAll();
-            
-            }
-        
-        
-            var oMenu = this._menu,
-                nViewportHeight = Dom.getViewportHeight(),
-                nMenuHeight,
-                nScrollTop,
-                nY;
-        
-        
-            if (oMenu && (oMenu instanceof Menu)) {
-        
-                oMenu.cfg.applyConfig({ context: [this.get("id"), "tl", "bl"],
-                    constraintoviewport: false,
-                    clicktohide: false,
-                    visible: true });
-                    
-                oMenu.cfg.fireQueue();
-            
-                oMenu.align("tl", "bl");
-        
-                /*
-                    Stop the propagation of the event so that the MenuManager 
-                    doesn't blur the menu after it gets focus.
-                */
-        
-                if (p_oEvent.type == "mousedown") {
-        
-                    Event.stopPropagation(p_oEvent);
-        
-                }
-
-
-                if (this.get("focusmenu")) {
-        
-                    this._menu.focus();
-                
-                }
-        
-                nMenuHeight = oMenu.element.offsetHeight;
-        
-        
-                if ((oMenu.cfg.getProperty("y") + nMenuHeight) > 
-                    nViewportHeight) {
-        
-                    this.logger.log("Current menu position will place a " + 
-                        "portion, or the entire menu outside the boundary of " +
-                        "the viewport.  Repositioning the menu to stay " +
-                        "inside the viewport.");
-        
-                    oMenu.align("bl", "tl");
-        
-                    nY = oMenu.cfg.getProperty("y");
-        
-                    nScrollTop = Dom.getDocumentScrollTop();
-        
-        
-                    if (nScrollTop >= nY) {
-        
-                        if (this._originalMaxHeight == -1) {
-        
-                            this._originalMaxHeight = 
-                                    oMenu.cfg.getProperty("maxheight");
-        
-                        }
-        
-                        oMenu.cfg.setProperty("maxheight", 
-                                    (nMenuHeight - ((nScrollTop - nY) + 20)));
-        
-                        oMenu.align("bl", "tl");
-        
-                    }
-        
-                }
-        
-            }
-            else if (oMenu && (oMenu instanceof Overlay)) {
-        
-                oMenu.show();
-                oMenu.align("tl", "bl");
-
-                nMenuHeight = oMenu.element.offsetHeight;
-        
-        
-                if ((oMenu.cfg.getProperty("y") + nMenuHeight) > 
-                    nViewportHeight) {
-        
-                    this.logger.log("Current menu position will place a " +
-                        "portion, or the entire menu outside the boundary of " + 
-                        "the viewport.  Repositioning the menu to stay inside" + 
-                        " the viewport.");
-        
-                    oMenu.align("bl", "tl");
-                    
-                }
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method _hideMenu
-        * @description Hides the button's menu.
-        * @protected
-        */
-        _hideMenu: function () {
-        
-            var oMenu = this._menu;
-        
-            if (oMenu) {
-        
-                oMenu.hide();
-        
-            }
-        
-        },
-        
-        
-        
-        
-        // Protected event handlers
-        
-        
-        /**
-        * @method _onMouseOver
-        * @description "mouseover" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onMouseOver: function (p_oEvent) {
-        
-            if (!this._hasMouseEventHandlers) {
-        
-                this.on("mouseout", this._onMouseOut);
-                this.on("mousedown", this._onMouseDown);
-                this.on("mouseup", this._onMouseUp);
-        
-                this._hasMouseEventHandlers = true;
-        
-            }
-        
-            this.addStateCSSClasses("hover");
-        
-            if (this._activationButtonPressed) {
-        
-                this.addStateCSSClasses("active");
-        
-            }
-        
-        
-            if (this._bOptionPressed) {
-        
-                this.addStateCSSClasses("activeoption");
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onMouseOut
-        * @description "mouseout" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onMouseOut: function (p_oEvent) {
-        
-            this.removeStateCSSClasses("hover");
-        
-            if (this.get("type") != "menu") {
-        
-                this.removeStateCSSClasses("active");
-        
-            }
-        
-            if (this._activationButtonPressed || this._bOptionPressed) {
-        
-                Event.on(document, "mouseup", this._onDocumentMouseUp, 
-                    null, this);
-        
-            }
-            
-        },
-        
-        
-        /**
-        * @method _onDocumentMouseUp
-        * @description "mouseup" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onDocumentMouseUp: function (p_oEvent) {
-        
-            this._activationButtonPressed = false;
-            this._bOptionPressed = false;
-        
-            var sType = this.get("type");
-        
-            if (sType == "menu" || sType == "split") {
-        
-                this.removeStateCSSClasses(
-                    (sType == "menu" ? "active" : "activeoption"));
-        
-                this._hideMenu();
-        
-            }
-        
-            Event.removeListener(document, "mouseup", this._onDocumentMouseUp);
-        
-        },
-        
-        
-        /**
-        * @method _onMouseDown
-        * @description "mousedown" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onMouseDown: function (p_oEvent) {
-        
-            var sType,
-                oElement,
-                nX,
-                me;
-        
-        
-            function onMouseUp() {
-            
-                this._hideMenu();
-                this.removeListener("mouseup", onMouseUp);
-            
-            }
-        
-        
-            if ((p_oEvent.which || p_oEvent.button) == 1) {
-        
-        
-                if (!this.hasFocus()) {
-                
-                    this.focus();
-                
-                }
-        
-        
-                sType = this.get("type");
-        
-        
-                if (sType == "split") {
-                
-                    oElement = this.get("element");
-                    nX = Event.getPageX(p_oEvent) - Dom.getX(oElement);
-        
-                    if ((oElement.offsetWidth - this.OPTION_AREA_WIDTH) < nX) {
-                        
-                        this.fireEvent("option", p_oEvent);
-        
-                    }
-                    else {
-        
-                        this.addStateCSSClasses("active");
-        
-                        this._activationButtonPressed = true;
-        
-                    }
-        
-                }
-                else if (sType == "menu") {
-        
-                    if (this.isActive()) {
-        
-                        this._hideMenu();
-        
-                        this._activationButtonPressed = false;
-        
-                    }
-                    else {
-        
-                        this._showMenu(p_oEvent);
-        
-                        this._activationButtonPressed = true;
-                    
-                    }
-        
-                }
-                else {
-        
-                    this.addStateCSSClasses("active");
-        
-                    this._activationButtonPressed = true;
-                
-                }
-        
-        
-        
-                if (sType == "split" || sType == "menu") {
-
-                    me = this;
-        
-                    this._hideMenuTimerId = window.setTimeout(function () {
-                    
-                        me.on("mouseup", onMouseUp);
-                    
-                    }, 250);
-        
-                }
-        
-            }
-            
-        },
-        
-        
-        /**
-        * @method _onMouseUp
-        * @description "mouseup" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onMouseUp: function (p_oEvent) {
-        
-            var sType = this.get("type");
-        
-        
-            if (this._hideMenuTimerId) {
-        
-                window.clearTimeout(this._hideMenuTimerId);
-        
-            }
-        
-        
-            if (sType == "checkbox" || sType == "radio") {
-        
-                this.set("checked", !(this.get("checked")));
-            
-            }
-        
-        
-            this._activationButtonPressed = false;
-            
-        
-            if (this.get("type") != "menu") {
-        
-                this.removeStateCSSClasses("active");
-            
-            }
-            
-        },
-        
-        
-        /**
-        * @method _onFocus
-        * @description "focus" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onFocus: function (p_oEvent) {
-        
-            var oElement;
-        
-            this.addStateCSSClasses("focus");
-        
-            if (this._activationKeyPressed) {
-        
-                this.addStateCSSClasses("active");
-           
-            }
-        
-            m_oFocusedButton = this;
-        
-        
-            if (!this._hasKeyEventHandlers) {
-        
-                oElement = this._button;
-        
-                Event.on(oElement, "blur", this._onBlur, null, this);
-                Event.on(oElement, "keydown", this._onKeyDown, null, this);
-                Event.on(oElement, "keyup", this._onKeyUp, null, this);
-        
-                this._hasKeyEventHandlers = true;
-        
-            }
-        
-        
-            this.fireEvent("focus", p_oEvent);
-        
-        },
-        
-        
-        /**
-        * @method _onBlur
-        * @description "blur" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onBlur: function (p_oEvent) {
-        
-            this.removeStateCSSClasses("focus");
-        
-            if (this.get("type") != "menu") {
-        
-                this.removeStateCSSClasses("active");
-        
-            }    
-        
-            if (this._activationKeyPressed) {
-        
-                Event.on(document, "keyup", this._onDocumentKeyUp, null, this);
-        
-            }
-        
-        
-            m_oFocusedButton = null;
-        
-            this.fireEvent("blur", p_oEvent);
-           
-        },
-        
-        
-        /**
-        * @method _onDocumentKeyUp
-        * @description "keyup" event handler for the document.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onDocumentKeyUp: function (p_oEvent) {
-        
-            if (this._isActivationKey(Event.getCharCode(p_oEvent))) {
-        
-                this._activationKeyPressed = false;
-                
-                Event.removeListener(document, "keyup", this._onDocumentKeyUp);
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onKeyDown
-        * @description "keydown" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onKeyDown: function (p_oEvent) {
-        
-            var oMenu = this._menu;
-        
-        
-            if (this.get("type") == "split" && 
-                this._isSplitButtonOptionKey(p_oEvent)) {
-        
-                this.fireEvent("option", p_oEvent);
-        
-            }
-            else if (this._isActivationKey(Event.getCharCode(p_oEvent))) {
-        
-                if (this.get("type") == "menu") {
-        
-                    this._showMenu(p_oEvent);
-        
-                }
-                else {
-        
-                    this._activationKeyPressed = true;
-                    
-                    this.addStateCSSClasses("active");
-                
-                }
-            
-            }
-        
-        
-            if (oMenu && oMenu.cfg.getProperty("visible") && 
-                Event.getCharCode(p_oEvent) == 27) {
-            
-                oMenu.hide();
-                this.focus();
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onKeyUp
-        * @description "keyup" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onKeyUp: function (p_oEvent) {
-        
-            var sType;
-        
-            if (this._isActivationKey(Event.getCharCode(p_oEvent))) {
-        
-                sType = this.get("type");
-        
-                if (sType == "checkbox" || sType == "radio") {
-        
-                    this.set("checked", !(this.get("checked")));
-                
-                }
-        
-                this._activationKeyPressed = false;
-        
-                if (this.get("type") != "menu") {
-        
-                    this.removeStateCSSClasses("active");
-        
-                }
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onClick
-        * @description "click" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onClick: function (p_oEvent) {
-        
-            var sType = this.get("type"),
-                sTitle,
-                oForm,
-                oSrcElement,
-                oElement,
-                nX;
-        
-        
-            switch (sType) {
-        
-            case "radio":
-            case "checkbox":
-    
-                if (this.get("checked")) {
-                    
-                    sTitle = (sType == "radio") ? 
-                                this.RADIO_CHECKED_TITLE : 
-                                this.CHECKBOX_CHECKED_TITLE;
-                
-                }
-                else {
-                
-                    sTitle = (sType == "radio") ? 
-                                this.RADIO_DEFAULT_TITLE : 
-                                this.CHECKBOX_DEFAULT_TITLE;
-                
-                }
-                
-                this.set("title", sTitle);
-    
-                break;
-    
-            case "submit":
-    
-                this.submitForm();
-            
-                break;
-    
-            case "reset":
-    
-                oForm = this.getForm();
-    
-                if (oForm) {
-    
-                    oForm.reset();
-                
-                }
-    
-                break;
-    
-            case "menu":
-    
-                sTitle = this._menu.cfg.getProperty("visible") ? 
-                                this.MENUBUTTON_MENU_VISIBLE_TITLE : 
-                                this.MENUBUTTON_DEFAULT_TITLE;
-    
-                this.set("title", sTitle);
-    
-                break;
-    
-            case "split":
-    
-                oElement = this.get("element");
-                nX = Event.getPageX(p_oEvent) - Dom.getX(oElement);
-    
-                if ((oElement.offsetWidth - this.OPTION_AREA_WIDTH) < nX) {
-    
-                    return false;
-                
-                }
-                else {
-    
-                    this._hideMenu();
-        
-                    oSrcElement = this.get("srcelement");
-        
-                    if (oSrcElement && oSrcElement.type == "submit") {
-    
-                        this.submitForm();
-                    
-                    }
-                
-                }
-    
-                sTitle = this._menu.cfg.getProperty("visible") ? 
-                                this.SPLITBUTTON_OPTION_VISIBLE_TITLE : 
-                                this.SPLITBUTTON_DEFAULT_TITLE;
-    
-                this.set("title", sTitle);
-    
-                break;
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onAppendTo
-        * @description "appendTo" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onAppendTo: function (p_oEvent) {
-        
-            /*
-                It is necessary to call "getForm" using "setTimeout" to make 
-                sure that the button's "form" property returns a node 
-                reference.  Sometimes, if you try to get the reference 
-                immediately after appending the field, it is null.
-            */
-        
-            var me = this;
-        
-            window.setTimeout(function () {
-        
-                me._addListenersToForm();
-        
-            }, 0);
-        
-        },
-        
-        
-        /**
-        * @method _onFormReset
-        * @description "reset" event handler for the button's form.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event 
-        * object passed back by the event utility (YAHOO.util.Event).
-        */
-        _onFormReset: function (p_oEvent) {
-        
-            var sType = this.get("type"),
-                oMenu = this._menu;
-        
-            if (sType == "checkbox" || sType == "radio") {
-        
-                this.resetValue("checked");
-        
-            }
-        
-        
-            if (oMenu && (oMenu instanceof Menu)) {
-        
-                this.resetValue("selectedMenuItem");
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onDocumentMouseDown
-        * @description "mousedown" event handler for the document.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onDocumentMouseDown: function (p_oEvent) {
-        
-            var oTarget = Event.getTarget(p_oEvent),
-                oButtonElement = this.get("element"),
-                oMenuElement = this._menu.element;
-        
-            if (oTarget != oButtonElement && 
-                !Dom.isAncestor(oButtonElement, oTarget) && 
-                oTarget != oMenuElement && 
-                !Dom.isAncestor(oMenuElement, oTarget)) {
-        
-                this._hideMenu();
-        
-                Event.removeListener(document, "mousedown", 
-                    this._onDocumentMouseDown);    
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onOption
-        * @description "option" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onOption: function (p_oEvent) {
-        
-            if (this.hasClass("yui-split-button-activeoption")) {
-        
-                this._hideMenu();
-        
-                this._bOptionPressed = false;
-        
-            }
-            else {
-        
-                this._showMenu(p_oEvent);    
-        
-                this._bOptionPressed = true;
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onOverlayBeforeShow
-        * @description "beforeshow" event handler for the 
-        * <a href="YAHOO.widget.Overlay.html">YAHOO.widget.Overlay</a> instance 
-        * serving as the button's menu.
-        * @private
-        * @param {String} p_sType String representing the name of the event  
-        * that was fired.
-        */
-        _onOverlayBeforeShow: function (p_sType) {
-        
-            var oMenu = this._menu;
-        
-            oMenu.render(this.get("element").parentNode);
-            
-            oMenu.beforeShowEvent.unsubscribe(this._onOverlayBeforeShow);
-        
-        },
-        
-        
-        /**
-        * @method _onMenuShow
-        * @description "show" event handler for the button's menu.
-        * @private
-        * @param {String} p_sType String representing the name of the event  
-        * that was fired.
-        */
-        _onMenuShow: function (p_sType) {
-        
-            Event.on(document, "mousedown", this._onDocumentMouseDown, 
-                null, this);
-        
-            var sTitle,
-                sState;
-            
-            if (this.get("type") == "split") {
-        
-                sTitle = this.SPLITBUTTON_OPTION_VISIBLE_TITLE;
-                sState = "activeoption";
-            
-            }
-            else {
-        
-                sTitle = this.MENUBUTTON_MENU_VISIBLE_TITLE;        
-                sState = "active";
-        
-            }
-        
-            this.addStateCSSClasses(sState);
-            this.set("title", sTitle);
-        
-        },
-        
-        
-        /**
-        * @method _onMenuHide
-        * @description "hide" event handler for the button's menu.
-        * @private
-        * @param {String} p_sType String representing the name of the event  
-        * that was fired.
-        */
-        _onMenuHide: function (p_sType) {
-            
-            var oMenu = this._menu,
-                sTitle,
-                sState;
-        
-            if (oMenu && (oMenu instanceof Menu) && 
-                this._originalMaxHeight != -1) {
-            
-                this._menu.cfg.setProperty("maxheight", 
-                    this._originalMaxHeight);
-        
-            }
-        
-            
-            if (this.get("type") == "split") {
-        
-                sTitle = this.SPLITBUTTON_DEFAULT_TITLE;
-                sState = "activeoption";
-        
-            }
-            else {
-        
-                sTitle = this.MENUBUTTON_DEFAULT_TITLE;        
-                sState = "active";
-            }
-        
-        
-            this.removeStateCSSClasses(sState);
-            this.set("title", sTitle);
-        
-        
-            if (this.get("type") == "split") {
-        
-                this._bOptionPressed = false;
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onMenuKeyDown
-        * @description "keydown" event handler for the button's menu.
-        * @private
-        * @param {String} p_sType String representing the name of the event  
-        * that was fired.
-        * @param {Array} p_aArgs Array of arguments sent when the event 
-        * was fired.
-        */
-        _onMenuKeyDown: function (p_sType, p_aArgs) {
-        
-            var oEvent = p_aArgs[0];
-        
-            if (Event.getCharCode(oEvent) == 27) {
-        
-                this.focus();
-        
-                if (this.get("type") == "split") {
-                
-                    this._bOptionPressed = false;
-                
-                }
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onMenuRender
-        * @description "render" event handler for the button's menu.
-        * @private
-        * @param {String} p_sType String representing the name of the  
-        * event thatwas fired.
-        */
-        _onMenuRender: function (p_sType) {
-        
-            var oButtonElement = this.get("element"),
-                oButtonParent = oButtonElement.parentNode,
-                oMenuElement = this._menu.element;
-        
-        
-            if (oButtonParent != oMenuElement.parentNode) {
-        
-                oButtonParent.appendChild(oMenuElement);
-            
-            }
-
-            this.set("selectedMenuItem", this.get("selectedMenuItem"));
-
-        },
-        
-        
-        /**
-        * @method _onMenuItemSelected
-        * @description "selectedchange" event handler for each item in the 
-        * button's menu.
-        * @private
-        * @param {String} p_sType String representing the name of the event  
-        * that was fired.
-        * @param {Array} p_aArgs Array of arguments sent when the event 
-        * was fired.
-        * @param {Number} p_nItem Number representing the index of the menu
-        * item that subscribed to the event.
-        */
-        _onMenuItemSelected: function (p_sType, p_aArgs, p_nItem) {
-
-            var bSelected = p_aArgs[0];
-
-            if (bSelected) {
-            
-                this.set("selectedMenuItem", p_nItem);
-
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onMenuItemAdded
-        * @description "itemadded" event handler for the button's menu.
-        * @private
-        * @param {String} p_sType String representing the name of the event  
-        * that was fired.
-        * @param {Array} p_aArgs Array of arguments sent when the event
-        * was fired.
-        * @param {<a href="YAHOO.widget.MenuItem.html">
-        * YAHOO.widget.MenuItem</a>} p_oItem Object representing the menu 
-        * item that subscribed to the event.
-        */
-        _onMenuItemAdded: function (p_sType, p_aArgs, p_oItem) {
-            
-            var oItem = p_aArgs[0];
-        
-            oItem.cfg.subscribeToConfigEvent("selected", 
-                this._onMenuItemSelected, 
-                oItem.index, 
-                this);
-        
-        },
-        
-        
-        /**
-        * @method _onMenuClick
-        * @description "click" event handler for the button's menu.
-        * @private
-        * @param {String} p_sType String representing the name of the event  
-        * that was fired.
-        * @param {Array} p_aArgs Array of arguments sent when the event 
-        * was fired.
-        */
-        _onMenuClick: function (p_sType, p_aArgs) {
-        
-            var oItem = p_aArgs[1],
-                oSrcElement;
-        
-            if (oItem) {
-        
-                oSrcElement = this.get("srcelement");
-            
-                if (oSrcElement && oSrcElement.type == "submit") {
-        
-                    this.submitForm();
-            
-                }
-            
-                this._hideMenu();
-            
-            }
-        
-        },
-        
-        
-        
-        // Public methods
-        
-        
-        /**
-        * @method createButtonElement
-        * @description Creates the button's HTML elements.
-        * @param {String} p_sType String indicating the type of element 
-        * to create.
-        * @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-        * level-one-html.html#ID-58190037">HTMLElement</a>}
-        */
-        createButtonElement: function (p_sType) {
-        
-            var sNodeName = this.NODE_NAME,
-                oElement = document.createElement(sNodeName);
-        
-            oElement.innerHTML =  "<" + sNodeName + " class=\"first-child\">" + 
-                (p_sType == "link" ? "<a></a>" : 
-                "<button type=\"button\"></button>") + "</" + sNodeName + ">";
-        
-            return oElement;
-        
-        },
-
-        
-        /**
-        * @method addStateCSSClasses
-        * @description Appends state-specific CSS classes to the button's root 
-        * DOM element.
-        */
-        addStateCSSClasses: function (p_sState) {
-        
-            var sType = this.get("type");
-        
-            if (Lang.isString(p_sState)) {
-        
-                if (p_sState != "activeoption") {
-        
-                    this.addClass(this.CSS_CLASS_NAME + ("-" + p_sState));
-        
-                }
-        
-                this.addClass("yui-" + sType + ("-button-" + p_sState));
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method removeStateCSSClasses
-        * @description Removes state-specific CSS classes to the button's root 
-        * DOM element.
-        */
-        removeStateCSSClasses: function (p_sState) {
-        
-            var sType = this.get("type");
-        
-            if (Lang.isString(p_sState)) {
-        
-                this.removeClass(this.CSS_CLASS_NAME + ("-" + p_sState));
-                this.removeClass("yui-" + sType + ("-button-" + p_sState));
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method createHiddenFields
-        * @description Creates the button's hidden form field and appends it 
-        * to its parent form.
-        * @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-        * level-one-html.html#ID-6043025">HTMLInputElement</a>|Array}
-        */
-        createHiddenFields: function () {
-        
-            this.removeHiddenFields();
-        
-            var oForm = this.getForm(),
-                oButtonField,
-                sType,     
-                bCheckable,
-                oMenu,
-                oMenuItem,
-                sName,
-                oValue,
-                oMenuField;
-        
-        
-            if (oForm && !this.get("disabled")) {
-        
-                sType = this.get("type");
-                bCheckable = (sType == "checkbox" || sType == "radio");
-        
-        
-                if (bCheckable || (m_oSubmitTrigger == this)) {
-                
-                    this.logger.log("Creating hidden field.");
-        
-                    oButtonField = createInputElement(
-                                    (bCheckable ? sType : "hidden"),
-                                    this.get("name"),
-                                    this.get("value"),
-                                    this.get("checked"));
-            
-            
-                    if (oButtonField) {
-            
-                        if (bCheckable) {
-            
-                            oButtonField.style.display = "none";
-            
-                        }
-            
-                        oForm.appendChild(oButtonField);
-            
-                    }
-        
-                }
-                    
-        
-                oMenu = this._menu;
-            
-            
-                if (oMenu && (oMenu instanceof Menu)) {
-        
-                    this.logger.log("Creating hidden field for menu.");
-        
-                    oMenuField = oMenu.srcElement;
-                    oMenuItem = oMenu.getItem(this.get("selectedMenuItem"));
-        
-                    if (oMenuField && 
-                        oMenuField.nodeName.toUpperCase() == "SELECT") {
-        
-                        oForm.appendChild(oMenuField);
-                        oMenuField.selectedIndex = oMenuItem.index;
-        
-                    }
-                    else {
-        
-                        oValue = (oMenuItem.value === null || 
-                                    oMenuItem.value === "") ? 
-                                    oMenuItem.cfg.getProperty("text") : 
-                                    oMenuItem.value;
-        
-                        sName = this.get("name");
-        
-                        if (oValue && sName) {
-        
-                            oMenuField = createInputElement("hidden", 
-                                                (sName + "_options"),
-                                                oValue);
-        
-                            oForm.appendChild(oMenuField);
-        
-                        }
-        
-                    }  
-        
-                }
-            
-            
-                if (oButtonField && oMenuField) {
-        
-                    this._hiddenFields = [oButtonField, oMenuField];
-        
-                }
-                else if (!oButtonField && oMenuField) {
-        
-                    this._hiddenFields = oMenuField;
-                
-                }
-                else if (oButtonField && !oMenuField) {
-        
-                    this._hiddenFields = oButtonField;
-                
-                }
-        
-        
-                return this._hiddenFields;
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method removeHiddenFields
-        * @description Removes the button's hidden form field(s) from its 
-        * parent form.
-        */
-        removeHiddenFields: function () {
-        
-            var oField = this._hiddenFields,
-                nFields,
-                i;
-        
-            function removeChild(p_oElement) {
-        
-                if (Dom.inDocument(p_oElement)) {
-        
-                    p_oElement.parentNode.removeChild(p_oElement);
-                
-                }
-                
-            }
-            
-        
-            if (oField) {
-        
-                if (Lang.isArray(oField)) {
-        
-                    nFields = oField.length;
-                    
-                    if (nFields > 0) {
-                    
-                        i = nFields - 1;
-                        
-                        do {
-        
-                            removeChild(oField[i]);
-        
-                        }
-                        while (i--);
-                    
-                    }
-                
-                }
-                else {
-        
-                    removeChild(oField);
-        
-                }
-        
-                this._hiddenFields = null;
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method submitForm
-        * @description Submits the form to which the button belongs.  Returns  
-        * true if the form was submitted successfully, false if the submission 
-        * was cancelled.
-        * @protected
-        * @return {Boolean}
-        */
-        submitForm: function () {
-        
-            var oForm = this.getForm(),
-        
-                oSrcElement = this.get("srcelement"),
-        
-                /*
-                    Boolean indicating if the event fired successfully 
-                    (was not cancelled by any handlers)
-                */
-        
-                bSubmitForm = false,
-                
-                oEvent;
-        
-        
-            if (oForm) {
-        
-                if (this.get("type") == "submit" || 
-                    (oSrcElement && oSrcElement.type == "submit")) 
-                {
-        
-                    m_oSubmitTrigger = this;
-                    
-                }
-        
-        
-                if (YAHOO.env.ua.ie) {
-        
-                    bSubmitForm = oForm.fireEvent("onsubmit");
-        
-                }
-                else {  // Gecko, Opera, and Safari
-        
-                    oEvent = document.createEvent("HTMLEvents");
-                    oEvent.initEvent("submit", true, true);
-        
-                    bSubmitForm = oForm.dispatchEvent(oEvent);
-        
-                }
-        
-        
-                /*
-                    In IE and Safari, dispatching a "submit" event to a form 
-                    WILL cause the form's "submit" event to fire, but WILL NOT 
-                    submit the form.  Therefore, we need to call the "submit" 
-                    method as well.
-                */
-              
-                if ((YAHOO.env.ua.ie || YAHOO.env.ua.webkit) && bSubmitForm) {
-        
-                    oForm.submit();
-                
-                }
-            
-            }
-        
-            return bSubmitForm;
-            
-        },
-        
-        
-        /**
-        * @method init
-        * @description The Button class's initialization method.
-        * @param {String} p_oElement String specifying the id attribute of the 
-        * <code>&#60;input&#62;</code>, <code>&#60;button&#62;</code>,
-        * <code>&#60;a&#62;</code>, or <code>&#60;span&#62;</code> element to 
-        * be used to create the button.
-        * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-        * level-one-html.html#ID-6043025">HTMLInputElement</a>|<a href="http://
-        * www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html
-        * #ID-34812697">HTMLButtonElement</a>|<a href="http://www.w3.org/TR
-        * /2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-33759296">
-        * HTMLElement</a>} p_oElement Object reference for the 
-        * <code>&#60;input&#62;</code>, <code>&#60;button&#62;</code>, 
-        * <code>&#60;a&#62;</code>, or <code>&#60;span&#62;</code> element to be 
-        * used to create the button.
-        * @param {Object} p_oElement Object literal specifying a set of 
-        * configuration attributes used to create the button.
-        * @param {Object} p_oAttributes Optional. Object literal specifying a 
-        * set of configuration attributes used to create the button.
-        */
-        init: function (p_oElement, p_oAttributes) {
-        
-            var sNodeName = p_oAttributes.type == "link" ? "A" : "BUTTON",
-                oSrcElement = p_oAttributes.srcelement,
-                oButton = p_oElement.getElementsByTagName(sNodeName)[0],
-                oInput;
-        
-
-            if (!oButton) {
-
-                oInput = p_oElement.getElementsByTagName("INPUT")[0];
-
-
-                if (oInput) {
-
-                    oButton = document.createElement("BUTTON");
-                    oButton.setAttribute("type", "button");
-
-                    oInput.parentNode.replaceChild(oButton, oInput);
-                
-                }
-
-            }
-
-            this._button = oButton;
-        
-
-            YAHOO.widget.Button.superclass.init.call(this, p_oElement, 
-                p_oAttributes);
-        
-        
-            m_oButtons[this.get("id")] = this;
-        
-        
-            this.addClass(this.CSS_CLASS_NAME);
-            
-            this.addClass("yui-" + this.get("type") + "-button");
-        
-            Event.on(this._button, "focus", this._onFocus, null, this);
-            this.on("mouseover", this._onMouseOver);
-            this.on("click", this._onClick);
-            this.on("appendTo", this._onAppendTo);
-            
-        
-            var oContainer = this.get("container"),
-                oElement = this.get("element"),
-                bElInDoc = Dom.inDocument(oElement),
-                oParentNode;
-
-
-            if (oContainer) {
-        
-                if (oSrcElement && oSrcElement != oElement) {
-                
-                    oParentNode = oSrcElement.parentNode;
-
-                    if (oParentNode) {
-                    
-                        oParentNode.removeChild(oSrcElement);
-                    
-                    }
-
-                }
-        
-                if (Lang.isString(oContainer)) {
-        
-                    Event.onContentReady(oContainer, function () {
-        
-                        this.appendTo(oContainer);
-                    
-                    }, null, this);
-        
-                }
-                else {
-        
-                    this.appendTo(oContainer);
-        
-                }
-        
-            }
-            else if (!bElInDoc && oSrcElement && oSrcElement != oElement) {
-
-                oParentNode = oSrcElement.parentNode;
-        
-                if (oParentNode) {
-        
-                    this.fireEvent("beforeAppendTo", {
-                        type: "beforeAppendTo",
-                        target: oParentNode
-                    });
-            
-                    oParentNode.replaceChild(oElement, oSrcElement);
-            
-                    this.fireEvent("appendTo", {
-                        type: "appendTo",
-                        target: oParentNode
-                    });
-                
-                }
-        
-            }
-            else if (this.get("type") != "link" && bElInDoc && oSrcElement && 
-                oSrcElement == oElement) {
-        
-                this._addListenersToForm();
-        
-            }
-        
-            this.logger.log("Initialization completed.");
-        
-        },
-        
-        
-        /**
-        * @method initAttributes
-        * @description Initializes all of the configuration attributes used to  
-        * create the button.
-        * @param {Object} p_oAttributes Object literal specifying a set of 
-        * configuration attributes used to create the button.
-        */
-        initAttributes: function (p_oAttributes) {
-        
-            var oAttributes = p_oAttributes || {};
-        
-            YAHOO.widget.Button.superclass.initAttributes.call(this, 
-                oAttributes);
-        
-        
-            /**
-            * @config type
-            * @description String specifying the button's type.  Possible 
-            * values are: "push," "link," "submit," "reset," "checkbox," 
-            * "radio," "menu," and "split."
-            * @default "push"
-            * @type String
-            */
-            this.setAttributeConfig("type", {
-        
-                value: (oAttributes.type || "push"),
-                validator: Lang.isString,
-                writeOnce: true,
-                method: this._setType
-        
-            });
-        
-        
-            /**
-            * @config label
-            * @description String specifying the button's text label 
-            * or innerHTML.
-            * @default null
-            * @type String
-            */
-            this.setAttributeConfig("label", {
-        
-                value: oAttributes.label,
-                validator: Lang.isString,
-                method: this._setLabel
-        
-            });
-        
-        
-            /**
-            * @config value
-            * @description Object specifying the value for the button.
-            * @default null
-            * @type Object
-            */
-            this.setAttributeConfig("value", {
-        
-                value: oAttributes.value
-        
-            });
-        
-        
-            /**
-            * @config name
-            * @description String specifying the name for the button.
-            * @default null
-            * @type String
-            */
-            this.setAttributeConfig("name", {
-        
-                value: oAttributes.name,
-                validator: Lang.isString
-        
-            });
-        
-        
-            /**
-            * @config tabindex
-            * @description Number specifying the tabindex for the button.
-            * @default null
-            * @type Number
-            */
-            this.setAttributeConfig("tabindex", {
-        
-                value: oAttributes.tabindex,
-                validator: Lang.isNumber,
-                method: this._setTabIndex
-        
-            });
-        
-        
-            /**
-            * @config title
-            * @description String specifying the title for the button.
-            * @default null
-            * @type String
-            */
-            this.configureAttribute("title", {
-        
-                value: oAttributes.title,
-                validator: Lang.isString,
-                method: this._setTitle
-        
-            });
-        
-        
-            /**
-            * @config disabled
-            * @description Boolean indicating if the button should be disabled.  
-            * (Disabled buttons are dimmed and will not respond to user input 
-            * or fire events.  Does not apply to button's of type "link.")
-            * @default false
-            * @type Boolean
-            */
-            this.setAttributeConfig("disabled", {
-        
-                value: (oAttributes.disabled || false),
-                validator: Lang.isBoolean,
-                method: this._setDisabled
-        
-            });
-        
-        
-            /**
-            * @config href
-            * @description String specifying the href for the button.  Applies
-            * only to buttons of type "link."
-            * @type String
-            */
-            this.setAttributeConfig("href", {
-        
-                value: oAttributes.href,
-                validator: Lang.isString,
-                method: this._setHref
-        
-            });
-        
-        
-            /**
-            * @config target
-            * @description String specifying the target for the button.  
-            * Applies only to buttons of type "link."
-            * @type String
-            */
-            this.setAttributeConfig("target", {
-        
-                value: oAttributes.target,
-                validator: Lang.isString,
-                method: this._setTarget
-        
-            });
-        
-        
-            /**
-            * @config checked
-            * @description Boolean indicating if the button is checked. 
-            * Applies only to buttons of type "radio" and "checkbox."
-            * @default false
-            * @type Boolean
-            */
-            this.setAttributeConfig("checked", {
-        
-                value: (oAttributes.checked || false),
-                validator: Lang.isBoolean,
-                method: this._setChecked
-        
-            });
-        
-        
-            /**
-            * @config container
-            * @description HTML element reference or string specifying the id 
-            * attribute of the HTML element that the button's markup should be 
-            * rendered into.
-            * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-            * level-one-html.html#ID-58190037">HTMLElement</a>|String
-            * @default null
-            */
-            this.setAttributeConfig("container", {
-        
-                value: oAttributes.container,
-                writeOnce: true
-        
-            });
-        
-        
-            /**
-            * @config srcelement
-            * @description Object reference to the HTML element (either 
-            * <code>&#60;input&#62;</code> or <code>&#60;span&#62;</code>) 
-            * used to create the button.
-            * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-            * level-one-html.html#ID-58190037">HTMLElement</a>|String
-            * @default null
-            */
-            this.setAttributeConfig("srcelement", {
-        
-                value: oAttributes.srcelement,
-                writeOnce: true
-        
-            });
-        
-        
-            /**
-            * @config menu
-            * @description Object specifying the menu for the button.  
-            * The value can be one of the following:
-            * <ul>
-            * <li>Object specifying a <a href="YAHOO.widget.Menu.html">
-            * YAHOO.widget.Menu</a> instance.</li>
-            * <li>Object specifying a <a href="YAHOO.widget.Overlay.html">
-            * YAHOO.widget.Overlay</a> instance.</li>
-            * <li>String specifying the id attribute of the <code>&#60;div&#62;
-            * </code> element used to create the menu.  By default the menu 
-            * will be created as an instance of 
-            * <a href="YAHOO.widget.Overlay.html">YAHOO.widget.Overlay</a>.  
-            * If the <a href="YAHOO.widget.Menu.html#CSS_CLASS_NAME">
-            * default CSS class name for YAHOO.widget.Menu</a> is applied to 
-            * the <code>&#60;div&#62;</code> element, it will be created as an
-            * instance of <a href="YAHOO.widget.Menu.html">YAHOO.widget.Menu
-            * </a>.</li><li>String specifying the id attribute of the 
-            * <code>&#60;select&#62;</code> element used to create the menu.
-            * </li><li>Object specifying the <code>&#60;div&#62;</code> element
-            * used to create the menu.</li>
-            * <li>Object specifying the <code>&#60;select&#62;</code> element
-            * used to create the menu.</li>
-            * <li>Array of object literals, each representing a set of 
-            * <a href="YAHOO.widget.MenuItem.html">YAHOO.widget.MenuItem</a> 
-            * configuration attributes.</li>
-            * <li>Array of strings representing the text labels for each menu 
-            * item in the menu.</li>
-            * </ul>
-            * @type <a href="YAHOO.widget.Menu.html">YAHOO.widget.Menu</a>|<a 
-            * href="YAHOO.widget.Overlay.html">YAHOO.widget.Overlay</a>|<a 
-            * href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-
-            * one-html.html#ID-58190037">HTMLElement</a>|String|Array
-            * @default null
-            */
-            this.setAttributeConfig("menu", {
-        
-                value: null,
-                method: this._setMenu,
-                writeOnce: true
-            
-            });
-        
-        
-            /**
-            * @config lazyloadmenu
-            * @description Boolean indicating the value to set for the 
-            * <a href="YAHOO.widget.Menu.html#lazyLoad">"lazyload"</a>
-            * configuration property of the button's menu.  Setting 
-            * "lazyloadmenu" to <code>true </code> will defer rendering of 
-            * the button's menu until the first time it is made visible.  
-            * If "lazyloadmenu" is set to <code>false</code>, the button's 
-            * menu will be rendered immediately if the button is in the 
-            * document, or in response to the button's "appendTo" event if 
-            * the button is not yet in the document.  In either case, the 
-            * menu is rendered into the button's parent HTML element.  
-            * <em>This attribute does not apply if a 
-            * <a href="YAHOO.widget.Menu.html">YAHOO.widget.Menu</a> or 
-            * <a href="YAHOO.widget.Overlay.html">YAHOO.widget.Overlay</a> 
-            * instance is passed as the value of the button's "menu" 
-            * configuration attribute. <a href="YAHOO.widget.Menu.html">
-            * YAHOO.widget.Menu</a> or <a href="YAHOO.widget.Overlay.html">
-            * YAHOO.widget.Overlay</a> instances should be rendered before 
-            * being set as the value for the "menu" configuration 
-            * attribute.</em>
-            * @default true
-            * @type Boolean
-            */
-            this.setAttributeConfig("lazyloadmenu", {
-        
-                value: (oAttributes.lazyloadmenu === false ? false : true),
-                validator: Lang.isBoolean,
-                writeOnce: true
-        
-            });
-
-
-            /**
-            * @config menuclassname
-            * @description String representing the CSS class name to be 
-            * applied to the root element of the button's menu.
-            * @type String
-            * @default "yui-button-menu"
-            */
-            this.setAttributeConfig("menuclassname", {
-        
-                value: (oAttributes.menuclassname || "yui-button-menu"),
-                validator: Lang.isString,
-                method: this._setMenuClassName,
-                writeOnce: true
-        
-            });        
-
-
-            /**
-            * @config selectedMenuItem
-            * @description Number representing the index of the item in the 
-            * button's menu that is currently selected.
-            * @type Number
-            * @default null
-            */
-            this.setAttributeConfig("selectedMenuItem", {
-        
-                value: 0,
-                validator: Lang.isNumber,
-                method: this._setSelectedMenuItem
-        
-            });
-        
-        
-            /**
-            * @config onclick
-            * @description Object literal representing the code to be executed  
-            * when the button is clicked.  Format:<br> <code> {<br> 
-            * <strong>fn:</strong> Function,   &#47;&#47; The handler to call 
-            * when the event fires.<br> <strong>obj:</strong> Object, 
-            * &#47;&#47; An object to pass back to the handler.<br> 
-            * <strong>scope:</strong> Object &#47;&#47;  The object to use 
-            * for the scope of the handler.<br> } </code>
-            * @type Object
-            * @default null
-            */
-            this.setAttributeConfig("onclick", {
-        
-                value: oAttributes.onclick,
-                method: this._setOnClick
-            
-            });
-
-
-            /**
-            * @config focusmenu
-            * @description Boolean indicating whether or not the button's menu 
-            * should be focused when it is made visible.
-            * @type Boolean
-            * @default true
-            */
-            this.setAttributeConfig("focusmenu", {
-        
-                value: (oAttributes.focusmenu === false ? false : true),
-                validator: Lang.isBoolean
-        
-            });
-
-        },
-        
-        
-        /**
-        * @method focus
-        * @description Causes the button to receive the focus and fires the 
-        * button's "focus" event.
-        */
-        focus: function () {
-        
-            if (!this.get("disabled")) {
-        
-                this._button.focus();
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method blur
-        * @description Causes the button to lose focus and fires the button's
-        * "blur" event.
-        */
-        blur: function () {
-        
-            if (!this.get("disabled")) {
-        
-                this._button.blur();
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method hasFocus
-        * @description Returns a boolean indicating whether or not the button 
-        * has focus.
-        * @return {Boolean}
-        */
-        hasFocus: function () {
-        
-            return (m_oFocusedButton == this);
-        
-        },
-        
-        
-        /**
-        * @method isActive
-        * @description Returns a boolean indicating whether or not the button 
-        * is active.
-        * @return {Boolean}
-        */
-        isActive: function () {
-        
-            return this.hasClass(this.CSS_CLASS_NAME + "-active");
-        
-        },
-        
-        
-        /**
-        * @method getMenu
-        * @description Returns a reference to the button's menu.
-        * @return {<a href="YAHOO.widget.Overlay.html">
-        * YAHOO.widget.Overlay</a>|<a 
-        * href="YAHOO.widget.Menu.html">YAHOO.widget.Menu</a>}
-        */
-        getMenu: function () {
-        
-            return this._menu;
-        
-        },
-        
-        
-        /**
-        * @method getForm
-        * @description Returns a reference to the button's parent form.
-        * @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-
-        * 20000929/level-one-html.html#ID-40002357">HTMLFormElement</a>}
-        */
-        getForm: function () {
-        
-            return this._button.form;
-        
-        },
-        
-        
-        /** 
-        * @method getHiddenFields
-        * @description Returns an <code>&#60;input&#62;</code> element or 
-        * array of form elements used to represent the button when its parent 
-        * form is submitted.  
-        * @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-        * level-one-html.html#ID-6043025">HTMLInputElement</a>|Array}
-        */
-        getHiddenFields: function () {
-        
-            return this._hiddenFields;
-        
-        },
-        
-        
-        /**
-        * @method destroy
-        * @description Removes the button's element from its parent element and 
-        * removes all event handlers.
-        */
-        destroy: function () {
-        
-            this.logger.log("Destroying ...");
-        
-            var oElement = this.get("element"),
-                oParentNode = oElement.parentNode,
-                oMenu = this._menu;
-        
-            if (oMenu) {
-        
-                this.logger.log("Destroying menu.");
-        
-                oMenu.destroy();
-        
-            }
-        
-            this.logger.log("Removing DOM event handlers.");
-        
-            Event.purgeElement(oElement);
-            Event.purgeElement(this._button);
-            Event.removeListener(document, "mouseup", this._onDocumentMouseUp);
-            Event.removeListener(document, "keyup", this._onDocumentKeyUp);
-            Event.removeListener(document, "mousedown", 
-                this._onDocumentMouseDown);
-        
-        
-            var oForm = this.getForm();
-            
-            if (oForm) {
-        
-                Event.removeListener(oForm, "reset", this._onFormReset);
-                Event.removeListener(oForm, "submit", this.createHiddenFields);
-        
-            }
-        
-        
-            oParentNode.removeChild(oElement);
-        
-            this.logger.log("Removing from document.");
-        
-            delete m_oButtons[this.get("id")];
-        
-            this.logger.log("Destroyed.");
-        
-        },
-        
-        
-        fireEvent: function (p_sType , p_aArgs) {
-        
-            //  Disabled buttons should not respond to DOM events
-        
-            if (this.DOM_EVENTS[p_sType] && this.get("disabled")) {
-        
-                return;
-        
-            }
-        
-            YAHOO.widget.Button.superclass.fireEvent.call(this, p_sType, 
-                p_aArgs);
-        
-        },
-        
-        
-        /**
-        * @method toString
-        * @description Returns a string representing the button.
-        * @return {String}
-        */
-        toString: function () {
-        
-            return ("Button " + this.get("id"));
-        
-        }
-    
-    });
-    
-    
-    /**
-    * @method YAHOO.widget.Button.onFormKeyPress
-    * @description "keypress" event handler for the button's form.
-    * @param {Event} p_oEvent Object representing the DOM event object passed 
-    * back by the event utility (YAHOO.util.Event).
-    */
-    YAHOO.widget.Button.onFormKeyPress = function (p_oEvent) {
-    
-        var oTarget = Event.getTarget(p_oEvent),
-            nCharCode = Event.getCharCode(p_oEvent),
-            sNodeName = oTarget.nodeName && oTarget.nodeName.toUpperCase(),
-            sType = oTarget.type,
-    
-            /*
-                Boolean indicating if the form contains any enabled or 
-                disabled YUI submit buttons
-            */
-    
-            bFormContainsYUIButtons = false,
-    
-            oButton,
-    
-            oYUISubmitButton,   // The form's first, enabled YUI submit button
-    
-            /*
-                 The form's first, enabled HTML submit button that precedes any 
-                 YUI submit button
-            */
-    
-            oPrecedingSubmitButton,
-            
-    
-            /*
-                 The form's first, enabled HTML submit button that follows a 
-                 YUI button
-            */
-            
-            oFollowingSubmitButton; 
-    
-    
-        function isSubmitButton(p_oElement) {
-    
-            var sId,
-                oSrcElement;
-    
-            switch (p_oElement.nodeName.toUpperCase()) {
-    
-            case "INPUT":
-            case "BUTTON":
-            
-                if (p_oElement.type == "submit" && !p_oElement.disabled) {
-                    
-                    if (!bFormContainsYUIButtons && 
-                        !oPrecedingSubmitButton) {
-
-                        oPrecedingSubmitButton = p_oElement;
-
-                    }
-                    
-                    if (oYUISubmitButton && !oFollowingSubmitButton) {
-                    
-                        oFollowingSubmitButton = p_oElement;
-                    
-                    }
-                
-                }
-
-                break;
-            
-
-            default:
-            
-                sId = p_oElement.id;
-    
-                if (sId) {
-    
-                    oButton = m_oButtons[sId];
-        
-                    if (oButton) {
-
-                        bFormContainsYUIButtons = true;
-        
-                        if (!oButton.get("disabled")) {
-
-                            oSrcElement = oButton.get("srcelement");
-    
-                            if (!oYUISubmitButton &&
-                                (oButton.get("type") == "submit" || 
-                                (oSrcElement && oSrcElement.type == "submit"))) 
-                            {
-
-                                oYUISubmitButton = oButton;
-                            
-                            }
-                        
-                        }
-                        
-                    }
-                
-                }
-
-                break;
-    
-            }
-    
-        }
-    
-    
-        if (nCharCode == 13 && ((sNodeName == "INPUT" && (sType == "text" || 
-            sType == "password" || sType == "checkbox" || sType == "radio" || 
-            sType == "file") ) || sNodeName == "SELECT"))
-        {
-    
-            Dom.getElementsBy(isSubmitButton, "*", this);
-    
-    
-            if (oPrecedingSubmitButton) {
-    
-                /*
-                     Need to set focus to the first enabled submit button
-                     to make sure that IE includes its name and value 
-                     in the form's data set.
-                */
-    
-                oPrecedingSubmitButton.focus();
-            
-            }
-            else if (!oPrecedingSubmitButton && oYUISubmitButton) {
-    
-                if (oFollowingSubmitButton) {
-    
-                    /*
-                        Need to call "preventDefault" to ensure that 
-                        the name and value of the regular submit button 
-                        following the YUI button doesn't get added to the 
-                        form's data set when it is submitted.
-                    */
-    
-                    Event.preventDefault(p_oEvent);
-                
-                }
-    
-                oYUISubmitButton.submitForm();
-    
-            }
-            
-        }
-    
-    };
-    
-    
-    /**
-    * @method addHiddenFieldsToForm
-    * @description Searches the specified form and adds hidden fields for  
-    * instances of YAHOO.widget.Button that are of type "radio," "checkbox," 
-    * "menu," and "split."
-    * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-
-    * one-html.html#ID-40002357">HTMLFormElement</a>} p_oForm Object reference 
-    * for the form to search.
-    */
-    YAHOO.widget.Button.addHiddenFieldsToForm = function (p_oForm) {
-    
-        var aButtons = Dom.getElementsByClassName(
-                            YAHOO.widget.Button.prototype.CSS_CLASS_NAME, 
-                            "*", 
-                            p_oForm),
-    
-            nButtons = aButtons.length,
-            oButton,
-            sId,
-            i;
-    
-        if (nButtons > 0) {
-    
-            YAHOO.log("Form contains " + nButtons + " YUI buttons.");
-    
-            for (i = 0; i < nButtons; i++) {
-    
-                sId = aButtons[i].id;
-    
-                if (sId) {
-    
-                    oButton = m_oButtons[sId];
-        
-                    if (oButton) {
-           
-                        oButton.createHiddenFields();
-                        
-                    }
-                
-                }
-            
-            }
-    
-        }
-    
-    };
-    
-    
-    
-    // Events
-    
-    
-    /**
-    * @event focus
-    * @description Fires when the menu item receives focus.  Passes back a  
-    * single object representing the original DOM event object passed back by 
-    * the event utility (YAHOO.util.Event) when the event was fired.  See 
-    * <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> 
-    * for more information on listening for this event.
-    * @type YAHOO.util.CustomEvent
-    */
-    
-    
-    /**
-    * @event blur
-    * @description Fires when the menu item loses the input focus.  Passes back  
-    * a single object representing the original DOM event object passed back by 
-    * the event utility (YAHOO.util.Event) when the event was fired.  See 
-    * <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for  
-    * more information on listening for this event.
-    * @type YAHOO.util.CustomEvent
-    */
-    
-    
-    /**
-    * @event option
-    * @description Fires when the user invokes the button's option.  Passes 
-    * back a single object representing the original DOM event (either 
-    * "mousedown" or "keydown") that caused the "option" event to fire.  See 
-    * <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> 
-    * for more information on listening for this event.
-    * @type YAHOO.util.CustomEvent
-    */
-
-})();
-(function () {
-
-    // Shorthard for utilities
-    
-    var Dom = YAHOO.util.Dom,
-        Event = YAHOO.util.Event,
-        Lang = YAHOO.lang,
-        Button = YAHOO.widget.Button,  
-    
-        // Private collection of radio buttons
-    
-        m_oButtons = {};
-
-
-
-    /**
-    * The ButtonGroup class creates a set of buttons that are mutually 
-    * exclusive; checking one button in the set will uncheck all others in the 
-    * button group.
-    * @param {String} p_oElement String specifying the id attribute of the 
-    * <code>&#60;div&#62;</code> element of the button group.
-    * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-    * level-one-html.html#ID-22445964">HTMLDivElement</a>} p_oElement Object 
-    * specifying the <code>&#60;div&#62;</code> element of the button group.
-    * @param {Object} p_oElement Object literal specifying a set of 
-    * configuration attributes used to create the button group.
-    * @param {Object} p_oAttributes Optional. Object literal specifying a set 
-    * of configuration attributes used to create the button group.
-    * @namespace YAHOO.widget
-    * @class ButtonGroup
-    * @constructor
-    * @extends YAHOO.util.Element
-    */
-    YAHOO.widget.ButtonGroup = function (p_oElement, p_oAttributes) {
-    
-        var fnSuperClass = YAHOO.widget.ButtonGroup.superclass.constructor,
-            sNodeName,
-            oElement,
-            sId;
-    
-        if (arguments.length == 1 && !Lang.isString(p_oElement) && 
-            !p_oElement.nodeName) {
-    
-            if (!p_oElement.id) {
-    
-                sId = Dom.generateId();
-    
-                p_oElement.id = sId;
-    
-                YAHOO.log("No value specified for the button group's \"id\"" +
-                    " attribute. Setting button group id to \"" + sId + "\".",
-                    "warn");
-    
-            }
-    
-            this.logger = new YAHOO.widget.LogWriter("ButtonGroup " + sId);
-    
-            this.logger.log("No source HTML element.  Building the button " +
-                    "group using the set of configuration attributes.");
-    
-            fnSuperClass.call(this, (this._createGroupElement()), p_oElement);
-    
-        }
-        else if (Lang.isString(p_oElement)) {
-    
-            oElement = Dom.get(p_oElement);
-    
-            if (oElement) {
-            
-                if (oElement.nodeName.toUpperCase() == this.NODE_NAME) {
-    
-                    this.logger = 
-                        new YAHOO.widget.LogWriter("ButtonGroup " + p_oElement);
-            
-                    fnSuperClass.call(this, oElement, p_oAttributes);
-    
-                }
-    
-            }
-        
-        }
-        else {
-    
-            sNodeName = p_oElement.nodeName;
-    
-            if (sNodeName && sNodeName == this.NODE_NAME) {
-        
-                if (!p_oElement.id) {
-        
-                    p_oElement.id = Dom.generateId();
-        
-                    YAHOO.log("No value specified for the button group's" +
-                        " \"id\" attribute. Setting button group id " +
-                        "to \"" + p_oElement.id + "\".", "warn");
-        
-                }
-        
-                this.logger = 
-                    new YAHOO.widget.LogWriter("ButtonGroup " + p_oElement.id);
-        
-                fnSuperClass.call(this, p_oElement, p_oAttributes);
-    
-            }
-    
-        }
-    
-    };
-    
-    
-    YAHOO.extend(YAHOO.widget.ButtonGroup, YAHOO.util.Element, {
-    
-    
-        // Protected properties
-        
-        
-        /** 
-        * @property _buttons
-        * @description Array of buttons in the button group.
-        * @default null
-        * @protected
-        * @type Array
-        */
-        _buttons: null,
-        
-        
-        
-        // Constants
-        
-        
-        /**
-        * @property NODE_NAME
-        * @description The name of the tag to be used for the button 
-        * group's element. 
-        * @default "DIV"
-        * @final
-        * @type String
-        */
-        NODE_NAME: "DIV",
-        
-        
-        /**
-        * @property CSS_CLASS_NAME
-        * @description String representing the CSS class(es) to be applied  
-        * to the button group's element.
-        * @default "yui-buttongroup"
-        * @final
-        * @type String
-        */
-        CSS_CLASS_NAME: "yui-buttongroup",
-    
-    
-    
-        // Protected methods
-        
-        
-        /**
-        * @method _createGroupElement
-        * @description Creates the button group's element.
-        * @protected
-        * @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-        * level-one-html.html#ID-22445964">HTMLDivElement</a>}
-        */
-        _createGroupElement: function () {
-        
-            var oElement = document.createElement(this.NODE_NAME);
-        
-            return oElement;
-        
-        },
-        
-        
-        
-        // Protected attribute setter methods
-        
-        
-        /**
-        * @method _setDisabled
-        * @description Sets the value of the button groups's 
-        * "disabled" attribute.
-        * @protected
-        * @param {Boolean} p_bDisabled Boolean indicating the value for
-        * the button group's "disabled" attribute.
-        */
-        _setDisabled: function (p_bDisabled) {
-        
-            var nButtons = this.getCount(),
-                i;
-        
-            if (nButtons > 0) {
-        
-                i = nButtons - 1;
-                
-                do {
-        
-                    this._buttons[i].set("disabled", p_bDisabled);
-                
-                }
-                while (i--);
-        
-            }
-        
-        },
-        
-        
-        
-        // Protected event handlers
-        
-        
-        /**
-        * @method _onKeyDown
-        * @description "keydown" event handler for the button group.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onKeyDown: function (p_oEvent) {
-        
-            var oTarget = Event.getTarget(p_oEvent),
-                nCharCode = Event.getCharCode(p_oEvent),
-                sId = oTarget.parentNode.parentNode.id,
-                oButton = m_oButtons[sId],
-                nIndex = -1;
-        
-        
-            if (nCharCode == 37 || nCharCode == 38) {
-        
-                nIndex = (oButton.index === 0) ? 
-                            (this._buttons.length - 1) : (oButton.index - 1);
-            
-            }
-            else if (nCharCode == 39 || nCharCode == 40) {
-        
-                nIndex = (oButton.index === (this._buttons.length - 1)) ? 
-                            0 : (oButton.index + 1);
-        
-            }
-        
-        
-            if (nIndex > -1) {
-        
-                this.check(nIndex);
-                this.getButton(nIndex).focus();
-            
-            }        
-        
-        },
-        
-        
-        /**
-        * @method _onAppendTo
-        * @description "appendTo" event handler for the button group.
-        * @protected
-        * @param {Event} p_oEvent Object representing the event that was fired.
-        */
-        _onAppendTo: function (p_oEvent) {
-        
-            var aButtons = this._buttons,
-                nButtons = aButtons.length,
-                i;
-        
-            for (i = 0; i < nButtons; i++) {
-        
-                aButtons[i].appendTo(this.get("element"));
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onButtonCheckedChange
-        * @description "checkedChange" event handler for each button in the 
-        * button group.
-        * @protected
-        * @param {Event} p_oEvent Object representing the event that was fired.
-        * @param {<a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a>}  
-        * p_oButton Object representing the button that fired the event.
-        */
-        _onButtonCheckedChange: function (p_oEvent, p_oButton) {
-        
-            var bChecked = p_oEvent.newValue,
-                oCheckedButton = this.get("checkedButton");
-        
-            if (bChecked && oCheckedButton != p_oButton) {
-        
-                if (oCheckedButton) {
-        
-                    oCheckedButton.set("checked", false, true);
-        
-                }
-        
-                this.set("checkedButton", p_oButton);
-                this.set("value", p_oButton.get("value"));
-        
-            }
-            else if (oCheckedButton && !oCheckedButton.set("checked")) {
-        
-                oCheckedButton.set("checked", true, true);
-        
-            }
-           
-        },
-        
-        
-        
-        // Public methods
-        
-        
-        /**
-        * @method init
-        * @description The ButtonGroup class's initialization method.
-        * @param {String} p_oElement String specifying the id attribute of the 
-        * <code>&#60;div&#62;</code> element of the button group.
-        * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-        * level-one-html.html#ID-22445964">HTMLDivElement</a>} p_oElement Object 
-        * specifying the <code>&#60;div&#62;</code> element of the button group.
-        * @param {Object} p_oElement Object literal specifying a set of  
-        * configuration attributes used to create the button group.
-        * @param {Object} p_oAttributes Optional. Object literal specifying a
-        * set of configuration attributes used to create the button group.
-        */
-        init: function (p_oElement, p_oAttributes) {
-        
-            this._buttons = [];
-        
-            YAHOO.widget.ButtonGroup.superclass.init.call(this, p_oElement, 
-                    p_oAttributes);
-        
-            this.addClass(this.CSS_CLASS_NAME);
-        
-            this.logger.log("Searching for child nodes with the class name " +
-                "\"yui-radio-button\" to add to the button group.");
-        
-            var aButtons = this.getElementsByClassName("yui-radio-button");
-        
-        
-            if (aButtons.length > 0) {
-        
-                this.logger.log("Found " + aButtons.length + 
-                    " child nodes with the class name \"yui-radio-button.\"" + 
-                    "  Attempting to add to button group.");
-        
-                this.addButtons(aButtons);
-        
-            }
-        
-        
-            this.logger.log("Searching for child nodes with the type of " +
-                " \"radio\" to add to the button group.");
-        
-            function isRadioButton(p_oElement) {
-        
-                return (p_oElement.type == "radio");
-        
-            }
-        
-            aButtons = 
-                Dom.getElementsBy(isRadioButton, "input", this.get("element"));
-        
-        
-            if (aButtons.length > 0) {
-        
-                this.logger.log("Found " + aButtons.length + " child nodes" +
-                    " with the type of \"radio.\"  Attempting to add to" +
-                    " button group.");
-        
-                this.addButtons(aButtons);
-        
-            }
-        
-            this.on("keydown", this._onKeyDown);
-            this.on("appendTo", this._onAppendTo);
-        
-
-            var oContainer = this.get("container");
-
-            if (oContainer) {
-        
-                if (Lang.isString(oContainer)) {
-        
-                    Event.onContentReady(oContainer, function () {
-        
-                        this.appendTo(oContainer);            
-                    
-                    }, null, this);
-        
-                }
-                else {
-        
-                    this.appendTo(oContainer);
-        
-                }
-        
-            }
-        
-        
-            this.logger.log("Initialization completed.");
-        
-        },
-        
-        
-        /**
-        * @method initAttributes
-        * @description Initializes all of the configuration attributes used to  
-        * create the button group.
-        * @param {Object} p_oAttributes Object literal specifying a set of 
-        * configuration attributes used to create the button group.
-        */
-        initAttributes: function (p_oAttributes) {
-        
-            var oAttributes = p_oAttributes || {};
-        
-            YAHOO.widget.ButtonGroup.superclass.initAttributes.call(
-                this, oAttributes);
-        
-        
-            /**
-            * @config name
-            * @description String specifying the name for the button group.  
-            * This name will be applied to each button in the button group.
-            * @default null
-            * @type String
-            */
-            this.setAttributeConfig("name", {
-        
-                value: oAttributes.name,
-                validator: Lang.isString
-        
-            });
-        
-        
-            /**
-            * @config disabled
-            * @description Boolean indicating if the button group should be 
-            * disabled.  Disabling the button group will disable each button 
-            * in the button group.  Disabled buttons are dimmed and will not 
-            * respond to user input or fire events.
-            * @default false
-            * @type Boolean
-            */
-            this.setAttributeConfig("disabled", {
-        
-                value: (oAttributes.disabled || false),
-                validator: Lang.isBoolean,
-                method: this._setDisabled
-        
-            });
-        
-        
-            /**
-            * @config value
-            * @description Object specifying the value for the button group.
-            * @default null
-            * @type Object
-            */
-            this.setAttributeConfig("value", {
-        
-                value: oAttributes.value
-        
-            });
-        
-        
-            /**
-            * @config container
-            * @description HTML element reference or string specifying the id 
-            * attribute of the HTML element that the button group's markup
-            * should be rendered into.
-            * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-            * level-one-html.html#ID-58190037">HTMLElement</a>|String
-            * @default null
-            */
-            this.setAttributeConfig("container", {
-        
-                value: oAttributes.container,
-                writeOnce: true
-        
-            });
-        
-        
-            /**
-            * @config checkedButton
-            * @description Reference for the button in the button group that 
-            * is checked.
-            * @type {<a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a>}
-            * @default null
-            */
-            this.setAttributeConfig("checkedButton", {
-        
-                value: null
-        
-            });
-        
-        },
-        
-        
-        /**
-        * @method addButton
-        * @description Adds the button to the button group.
-        * @param {<a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a>}  
-        * p_oButton Object reference for the <a href="YAHOO.widget.Button.html">
-        * YAHOO.widget.Button</a> instance to be added to the button group.
-        * @param {String} p_oButton String specifying the id attribute of the 
-        * <code>&#60;input&#62;</code> or <code>&#60;span&#62;</code> element 
-        * to be used to create the button to be added to the button group.
-        * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-        * level-one-html.html#ID-6043025">HTMLInputElement</a>|<a href="
-        * http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#
-        * ID-33759296">HTMLElement</a>} p_oButton Object reference for the 
-        * <code>&#60;input&#62;</code> or <code>&#60;span&#62;</code> element 
-        * to be used to create the button to be added to the button group.
-        * @param {Object} p_oButton Object literal specifying a set of 
-        * <a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a> 
-        * configuration attributes used to configure the button to be added to 
-        * the button group.
-        * @return {<a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a>} 
-        */
-        addButton: function (p_oButton) {
-        
-            var oButton,
-                oButtonElement,
-                oGroupElement,
-                nIndex,
-                sButtonName,
-                sGroupName;
-        
-        
-            if (p_oButton instanceof Button && 
-                p_oButton.get("type") == "radio") {
-        
-                oButton = p_oButton;
-        
-            }
-            else if (!Lang.isString(p_oButton) && !p_oButton.nodeName) {
-        
-                p_oButton.type = "radio";
-        
-                oButton = new Button(p_oButton);
-
-            }
-            else {
-        
-                oButton = new Button(p_oButton, { type: "radio" });
-        
-            }
-        
-        
-            if (oButton) {
-        
-                nIndex = this._buttons.length;
-                sButtonName = oButton.get("name");
-                sGroupName = this.get("name");
-        
-                oButton.index = nIndex;
-        
-                this._buttons[nIndex] = oButton;
-                m_oButtons[oButton.get("id")] = oButton;
-        
-        
-                if (sButtonName != sGroupName) {
-        
-                    oButton.set("name", sGroupName);
-                
-                }
-        
-        
-                if (this.get("disabled")) {
-        
-                    oButton.set("disabled", true);
-        
-                }
-        
-        
-                if (oButton.get("checked")) {
-        
-                    this.set("checkedButton", oButton);
-        
-                }
-
-                
-                oButtonElement = oButton.get("element");
-                oGroupElement = this.get("element");
-                
-                if (oButtonElement.parentNode != oGroupElement) {
-                
-                    oGroupElement.appendChild(oButtonElement);
-                
-                }
-        
-                
-                oButton.on("checkedChange", 
-                    this._onButtonCheckedChange, oButton, this);
-        
-                this.logger.log("Button " + oButton.get("id") + " added.");
-        
-                return oButton;
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method addButtons
-        * @description Adds the array of buttons to the button group.
-        * @param {Array} p_aButtons Array of <a href="YAHOO.widget.Button.html">
-        * YAHOO.widget.Button</a> instances to be added 
-        * to the button group.
-        * @param {Array} p_aButtons Array of strings specifying the id 
-        * attribute of the <code>&#60;input&#62;</code> or <code>&#60;span&#62;
-        * </code> elements to be used to create the buttons to be added to the 
-        * button group.
-        * @param {Array} p_aButtons Array of object references for the 
-        * <code>&#60;input&#62;</code> or <code>&#60;span&#62;</code> elements 
-        * to be used to create the buttons to be added to the button group.
-        * @param {Array} p_aButtons Array of object literals, each containing
-        * a set of <a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a>  
-        * configuration attributes used to configure each button to be added 
-        * to the button group.
-        * @return {Array}
-        */
-        addButtons: function (p_aButtons) {
-    
-            var nButtons,
-                oButton,
-                aButtons,
-                i;
-        
-            if (Lang.isArray(p_aButtons)) {
-            
-                nButtons = p_aButtons.length;
-                aButtons = [];
-        
-                if (nButtons > 0) {
-        
-                    for (i = 0; i < nButtons; i++) {
-        
-                        oButton = this.addButton(p_aButtons[i]);
-                        
-                        if (oButton) {
-        
-                            aButtons[aButtons.length] = oButton;
-        
-                        }
-                    
-                    }
-        
-                    if (aButtons.length > 0) {
-        
-                        this.logger.log(aButtons.length + " buttons added.");
-        
-                        return aButtons;
-        
-                    }
-                
-                }
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method removeButton
-        * @description Removes the button at the specified index from the 
-        * button group.
-        * @param {Number} p_nIndex Number specifying the index of the button 
-        * to be removed from the button group.
-        */
-        removeButton: function (p_nIndex) {
-        
-            var oButton = this.getButton(p_nIndex),
-                nButtons,
-                i;
-            
-            if (oButton) {
-        
-                this.logger.log("Removing button " + oButton.get("id") + ".");
-        
-                this._buttons.splice(p_nIndex, 1);
-                delete m_oButtons[oButton.get("id")];
-        
-                oButton.removeListener("checkedChange", 
-                    this._onButtonCheckedChange);
-
-                oButton.destroy();
-        
-        
-                nButtons = this._buttons.length;
-                
-                if (nButtons > 0) {
-        
-                    i = this._buttons.length - 1;
-                    
-                    do {
-        
-                        this._buttons[i].index = i;
-        
-                    }
-                    while (i--);
-                
-                }
-        
-                this.logger.log("Button " + oButton.get("id") + " removed.");
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method getButton
-        * @description Returns the button at the specified index.
-        * @param {Number} p_nIndex The index of the button to retrieve from the 
-        * button group.
-        * @return {<a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a>}
-        */
-        getButton: function (p_nIndex) {
-        
-            if (Lang.isNumber(p_nIndex)) {
-        
-                return this._buttons[p_nIndex];
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method getButtons
-        * @description Returns an array of the buttons in the button group.
-        * @return {Array}
-        */
-        getButtons: function () {
-        
-            return this._buttons;
-        
-        },
-        
-        
-        /**
-        * @method getCount
-        * @description Returns the number of buttons in the button group.
-        * @return {Number}
-        */
-        getCount: function () {
-        
-            return this._buttons.length;
-        
-        },
-        
-        
-        /**
-        * @method focus
-        * @description Sets focus to the button at the specified index.
-        * @param {Number} p_nIndex Number indicating the index of the button 
-        * to focus. 
-        */
-        focus: function (p_nIndex) {
-        
-            var oButton,
-                nButtons,
-                i;
-        
-            if (Lang.isNumber(p_nIndex)) {
-        
-                oButton = this._buttons[p_nIndex];
-                
-                if (oButton) {
-        
-                    oButton.focus();
-        
-                }
-            
-            }
-            else {
-        
-                nButtons = this.getCount();
-        
-                for (i = 0; i < nButtons; i++) {
-        
-                    oButton = this._buttons[i];
-        
-                    if (!oButton.get("disabled")) {
-        
-                        oButton.focus();
-                        break;
-        
-                    }
-        
-                }
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method check
-        * @description Checks the button at the specified index.
-        * @param {Number} p_nIndex Number indicating the index of the button 
-        * to check. 
-        */
-        check: function (p_nIndex) {
-        
-            var oButton = this.getButton(p_nIndex);
-            
-            if (oButton) {
-        
-                oButton.set("checked", true);
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method destroy
-        * @description Removes the button group's element from its parent 
-        * element and removes all event handlers.
-        */
-        destroy: function () {
-        
-            this.logger.log("Destroying...");
-        
-            var nButtons = this._buttons.length,
-                oElement = this.get("element"),
-                oParentNode = oElement.parentNode,
-                i;
-            
-            if (nButtons > 0) {
-        
-                i = this._buttons.length - 1;
-        
-                do {
-        
-                    this._buttons[i].destroy();
-        
-                }
-                while (i--);
-            
-            }
-        
-            this.logger.log("Removing DOM event handlers.");
-        
-            Event.purgeElement(oElement);
-            
-            this.logger.log("Removing from document.");
-        
-            oParentNode.removeChild(oElement);
-        
-        },
-        
-        
-        /**
-        * @method toString
-        * @description Returns a string representing the button group.
-        * @return {String}
-        */
-        toString: function () {
-        
-            return ("ButtonGroup " + this.get("id"));
-        
-        }
-    
-    });
-
-})();
-YAHOO.register("button", YAHOO.widget.Button, {version: "2.3.0", build: "442"});
diff --git a/lib/yui/button/button-beta-min.js b/lib/yui/button/button-beta-min.js
deleted file mode 100755 (executable)
index be19b02..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
-Copyright (c) 2007, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 2.3.0
-*/
-
-(function(){var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Lang=YAHOO.lang,Overlay=YAHOO.widget.Overlay,Menu=YAHOO.widget.Menu,m_oButtons={},m_oOverlayManager=null,m_oSubmitTrigger=null,m_oFocusedButton=null;function createInputElement(p_sType,p_sName,p_sValue,p_bChecked){var oInput,sInput;if(Lang.isString(p_sType)&&Lang.isString(p_sName)){if(YAHOO.env.ua.ie){sInput="<input type=\""+p_sType+"\" name=\""+
-p_sName+"\"";if(p_bChecked){sInput+=" checked";}
-sInput+=">";oInput=document.createElement(sInput);}
-else{oInput=document.createElement("input");oInput.name=p_sName;oInput.type=p_sType;if(p_bChecked){oInput.checked=true;}}
-oInput.value=p_sValue;return oInput;}}
-function setAttributesFromSrcElement(p_oElement,p_oAttributes){var sSrcElementNodeName=p_oElement.nodeName.toUpperCase(),me=this,oAttribute,oRootNode,sText;function setAttributeFromDOMAttribute(p_sAttribute){if(!(p_sAttribute in p_oAttributes)){oAttribute=p_oElement.getAttributeNode(p_sAttribute);if(oAttribute&&("value"in oAttribute)){p_oAttributes[p_sAttribute]=oAttribute.value;}}}
-function setFormElementProperties(){setAttributeFromDOMAttribute("type");if(p_oAttributes.type=="button"){p_oAttributes.type="push";}
-if(!("disabled"in p_oAttributes)){p_oAttributes.disabled=p_oElement.disabled;}
-setAttributeFromDOMAttribute("name");setAttributeFromDOMAttribute("value");setAttributeFromDOMAttribute("title");}
-switch(sSrcElementNodeName){case"A":p_oAttributes.type="link";setAttributeFromDOMAttribute("href");setAttributeFromDOMAttribute("target");break;case"INPUT":setFormElementProperties();if(!("checked"in p_oAttributes)){p_oAttributes.checked=p_oElement.checked;}
-break;case"BUTTON":setFormElementProperties();oRootNode=p_oElement.parentNode.parentNode;if(Dom.hasClass(oRootNode,this.CSS_CLASS_NAME+"-checked")){p_oAttributes.checked=true;}
-if(Dom.hasClass(oRootNode,this.CSS_CLASS_NAME+"-disabled")){p_oAttributes.disabled=true;}
-p_oElement.removeAttribute("value");p_oElement.setAttribute("type","button");break;}
-p_oElement.removeAttribute("id");p_oElement.removeAttribute("name");if(!("tabindex"in p_oAttributes)){p_oAttributes.tabindex=p_oElement.tabIndex;}
-if(!("label"in p_oAttributes)){sText=sSrcElementNodeName=="INPUT"?p_oElement.value:p_oElement.innerHTML;if(sText&&sText.length>0){p_oAttributes.label=sText;}}}
-function initConfig(p_oConfig){var oAttributes=p_oConfig.attributes,oSrcElement=oAttributes.srcelement,sSrcElementNodeName=oSrcElement.nodeName.toUpperCase(),me=this;if(sSrcElementNodeName==this.NODE_NAME){p_oConfig.element=oSrcElement;p_oConfig.id=oSrcElement.id;Dom.getElementsBy(function(p_oElement){switch(p_oElement.nodeName.toUpperCase()){case"BUTTON":case"A":case"INPUT":setAttributesFromSrcElement.call(me,p_oElement,oAttributes);break;}},"*",oSrcElement);}
-else{switch(sSrcElementNodeName){case"BUTTON":case"A":case"INPUT":setAttributesFromSrcElement.call(this,oSrcElement,oAttributes);break;}}}
-YAHOO.widget.Button=function(p_oElement,p_oAttributes){var fnSuperClass=YAHOO.widget.Button.superclass.constructor,oConfig,oElement;if(arguments.length==1&&!Lang.isString(p_oElement)&&!p_oElement.nodeName){if(!p_oElement.id){p_oElement.id=Dom.generateId();}
-fnSuperClass.call(this,(this.createButtonElement(p_oElement.type)),p_oElement);}
-else{oConfig={element:null,attributes:(p_oAttributes||{})};if(Lang.isString(p_oElement)){oElement=Dom.get(p_oElement);if(oElement){if(!oConfig.attributes.id){oConfig.attributes.id=p_oElement;}
-oConfig.attributes.srcelement=oElement;initConfig.call(this,oConfig);if(!oConfig.element){oConfig.element=this.createButtonElement(oConfig.attributes.type);}
-fnSuperClass.call(this,oConfig.element,oConfig.attributes);}}
-else if(p_oElement.nodeName){if(!oConfig.attributes.id){if(p_oElement.id){oConfig.attributes.id=p_oElement.id;}
-else{oConfig.attributes.id=Dom.generateId();}}
-oConfig.attributes.srcelement=p_oElement;initConfig.call(this,oConfig);if(!oConfig.element){oConfig.element=this.createButtonElement(oConfig.attributes.type);}
-fnSuperClass.call(this,oConfig.element,oConfig.attributes);}}};YAHOO.extend(YAHOO.widget.Button,YAHOO.util.Element,{_button:null,_menu:null,_hiddenFields:null,_onclickAttributeValue:null,_activationKeyPressed:false,_activationButtonPressed:false,_hasKeyEventHandlers:false,_hasMouseEventHandlers:false,NODE_NAME:"SPAN",CHECK_ACTIVATION_KEYS:[32],ACTIVATION_KEYS:[13,32],OPTION_AREA_WIDTH:20,CSS_CLASS_NAME:"yui-button",RADIO_DEFAULT_TITLE:"Unchecked.  Click to check.",RADIO_CHECKED_TITLE:"Checked.  Click to uncheck.",CHECKBOX_DEFAULT_TITLE:"Unchecked.  Click to check.",CHECKBOX_CHECKED_TITLE:"Checked.  Click to uncheck.",MENUBUTTON_DEFAULT_TITLE:"Menu collapsed.  Click to expand.",MENUBUTTON_MENU_VISIBLE_TITLE:"Menu expanded.  Click or press Esc to collapse.",SPLITBUTTON_DEFAULT_TITLE:("Menu collapsed.  Click inside option "+"region or press Ctrl + Shift + M to show the menu."),SPLITBUTTON_OPTION_VISIBLE_TITLE:"Menu expanded.  Press Esc or Ctrl + Shift + M to hide the menu.",SUBMIT_TITLE:"Click to submit form.",_setType:function(p_sType){if(p_sType=="split"){this.on("option",this._onOption);}},_setLabel:function(p_sLabel){this._button.innerHTML=p_sLabel;},_setTabIndex:function(p_nTabIndex){this._button.tabIndex=p_nTabIndex;},_setTitle:function(p_sTitle){var sTitle=p_sTitle;if(this.get("type")!="link"){if(!sTitle){switch(this.get("type")){case"radio":sTitle=this.RADIO_DEFAULT_TITLE;break;case"checkbox":sTitle=this.CHECKBOX_DEFAULT_TITLE;break;case"menu":sTitle=this.MENUBUTTON_DEFAULT_TITLE;break;case"split":sTitle=this.SPLITBUTTON_DEFAULT_TITLE;break;case"submit":sTitle=this.SUBMIT_TITLE;break;}}
-this._button.title=sTitle;}},_setDisabled:function(p_bDisabled){if(this.get("type")!="link"){if(p_bDisabled){if(this._menu){this._menu.hide();}
-if(this.hasFocus()){this.blur();}
-this._button.setAttribute("disabled","disabled");this.addStateCSSClasses("disabled");}
-else{this._button.removeAttribute("disabled");this.removeStateCSSClasses("disabled");}}},_setHref:function(p_sHref){if(this.get("type")=="link"){this._button.href=p_sHref;}},_setTarget:function(p_sTarget){if(this.get("type")=="link"){this._button.setAttribute("target",p_sTarget);}},_setChecked:function(p_bChecked){var sType=this.get("type"),sTitle;if(sType=="checkbox"||sType=="radio"){if(p_bChecked){this.addStateCSSClasses("checked");sTitle=(sType=="radio")?this.RADIO_CHECKED_TITLE:this.CHECKBOX_CHECKED_TITLE;}
-else{this.removeStateCSSClasses("checked");sTitle=(sType=="radio")?this.RADIO_DEFAULT_TITLE:this.CHECKBOX_DEFAULT_TITLE;}
-this.set("title",sTitle);}},_setMenu:function(p_oMenu){var bLazyLoad=this.get("lazyloadmenu"),oButtonElement=this.get("element"),bInstance=false,oMenu,oMenuElement,oSrcElement,aItems,nItems,oItem,i;if(!Overlay){return false;}
-if(!Menu){return false;}
-function onAppendTo(){oMenu.render(oButtonElement.parentNode);this.removeListener("appendTo",onAppendTo);}
-function initMenu(){if(oMenu){Dom.addClass(oMenu.element,this.get("menuclassname"));Dom.addClass(oMenu.element,"yui-"+this.get("type")+"-button-menu");oMenu.showEvent.subscribe(this._onMenuShow,null,this);oMenu.hideEvent.subscribe(this._onMenuHide,null,this);oMenu.renderEvent.subscribe(this._onMenuRender,null,this);if(oMenu instanceof Menu){oMenu.keyDownEvent.subscribe(this._onMenuKeyDown,this,true);oMenu.clickEvent.subscribe(this._onMenuClick,this,true);oMenu.itemAddedEvent.subscribe(this._onMenuItemAdded,this,true);oSrcElement=oMenu.srcElement;if(oSrcElement&&oSrcElement.nodeName.toUpperCase()=="SELECT"){oSrcElement.style.display="none";oSrcElement.parentNode.removeChild(oSrcElement);}}
-else if(oMenu instanceof Overlay){if(!m_oOverlayManager){m_oOverlayManager=new YAHOO.widget.OverlayManager();}
-m_oOverlayManager.register(oMenu);}
-this._menu=oMenu;if(!bInstance){if(bLazyLoad&&!(oMenu instanceof Menu)){oMenu.beforeShowEvent.subscribe(this._onOverlayBeforeShow,null,this);}
-else if(!bLazyLoad){if(Dom.inDocument(oButtonElement)){oMenu.render(oButtonElement.parentNode);}
-else{this.on("appendTo",onAppendTo);}}}}}
-if(p_oMenu&&(p_oMenu instanceof Menu)){oMenu=p_oMenu;aItems=oMenu.getItems();nItems=aItems.length;bInstance=true;if(nItems>0){i=nItems-1;do{oItem=aItems[i];if(oItem){oItem.cfg.subscribeToConfigEvent("selected",this._onMenuItemSelected,oItem,this);}}
-while(i--);}
-initMenu.call(this);}
-else if(p_oMenu&&(p_oMenu instanceof Overlay)){oMenu=p_oMenu;bInstance=true;oMenu.cfg.setProperty("visible",false);oMenu.cfg.setProperty("context",[oButtonElement,"tl","bl"]);initMenu.call(this);}
-else if(Lang.isArray(p_oMenu)){this.on("appendTo",function(){oMenu=new Menu(Dom.generateId(),{lazyload:bLazyLoad,itemdata:p_oMenu});initMenu.call(this);});}
-else if(Lang.isString(p_oMenu)){oMenuElement=Dom.get(p_oMenu);if(oMenuElement){if(Dom.hasClass(oMenuElement,Menu.prototype.CSS_CLASS_NAME)||oMenuElement.nodeName=="SELECT"){oMenu=new Menu(p_oMenu,{lazyload:bLazyLoad});initMenu.call(this);}
-else{oMenu=new Overlay(p_oMenu,{visible:false,context:[oButtonElement,"tl","bl"]});initMenu.call(this);}}}
-else if(p_oMenu&&p_oMenu.nodeName){if(Dom.hasClass(p_oMenu,Menu.prototype.CSS_CLASS_NAME)||p_oMenu.nodeName=="SELECT"){oMenu=new Menu(p_oMenu,{lazyload:bLazyLoad});initMenu.call(this);}
-else{if(!p_oMenu.id){Dom.generateId(p_oMenu);}
-oMenu=new Overlay(p_oMenu,{visible:false,context:[oButtonElement,"tl","bl"]});initMenu.call(this);}}},_setOnClick:function(p_oObject){if(this._onclickAttributeValue&&(this._onclickAttributeValue!=p_oObject)){this.removeListener("click",this._onclickAttributeValue.fn);this._onclickAttributeValue=null;}
-if(!this._onclickAttributeValue&&Lang.isObject(p_oObject)&&Lang.isFunction(p_oObject.fn)){this.on("click",p_oObject.fn,p_oObject.obj,p_oObject.scope);this._onclickAttributeValue=p_oObject;}},_setSelectedMenuItem:function(p_nIndex){var oMenu=this._menu,oMenuItem;if(oMenu&&oMenu instanceof Menu){oMenuItem=oMenu.getItem(p_nIndex);if(oMenuItem&&!oMenuItem.cfg.getProperty("selected")){oMenuItem.cfg.setProperty("selected",true);}}},_isActivationKey:function(p_nKeyCode){var sType=this.get("type"),aKeyCodes=(sType=="checkbox"||sType=="radio")?this.CHECK_ACTIVATION_KEYS:this.ACTIVATION_KEYS,nKeyCodes=aKeyCodes.length,i;if(nKeyCodes>0){i=nKeyCodes-1;do{if(p_nKeyCode==aKeyCodes[i]){return true;}}
-while(i--);}},_isSplitButtonOptionKey:function(p_oEvent){return(p_oEvent.ctrlKey&&p_oEvent.shiftKey&&Event.getCharCode(p_oEvent)==77);},_addListenersToForm:function(){var oForm=this.getForm(),oSrcElement,aListeners,nListeners,i,bHasKeyPressListener;if(oForm){Event.on(oForm,"reset",this._onFormReset,null,this);Event.on(oForm,"submit",this.createHiddenFields,null,this);oSrcElement=this.get("srcelement");if(this.get("type")=="submit"||(oSrcElement&&oSrcElement.type=="submit"))
-{aListeners=Event.getListeners(oForm,"keypress");bHasKeyPressListener=false;if(aListeners){nListeners=aListeners.length;if(nListeners>0){i=nListeners-1;do{if(aListeners[i].fn==YAHOO.widget.Button.onFormKeyPress)
-{bHasKeyPressListener=true;break;}}
-while(i--);}}
-if(!bHasKeyPressListener){Event.on(oForm,"keypress",YAHOO.widget.Button.onFormKeyPress);}}}},_originalMaxHeight:-1,_showMenu:function(p_oEvent){YAHOO.widget.MenuManager.hideVisible();if(m_oOverlayManager){m_oOverlayManager.hideAll();}
-var oMenu=this._menu,nViewportHeight=Dom.getViewportHeight(),nMenuHeight,nScrollTop,nY;if(oMenu&&(oMenu instanceof Menu)){oMenu.cfg.applyConfig({context:[this.get("id"),"tl","bl"],constraintoviewport:false,clicktohide:false,visible:true});oMenu.cfg.fireQueue();oMenu.align("tl","bl");if(p_oEvent.type=="mousedown"){Event.stopPropagation(p_oEvent);}
-if(this.get("focusmenu")){this._menu.focus();}
-nMenuHeight=oMenu.element.offsetHeight;if((oMenu.cfg.getProperty("y")+nMenuHeight)>nViewportHeight){oMenu.align("bl","tl");nY=oMenu.cfg.getProperty("y");nScrollTop=Dom.getDocumentScrollTop();if(nScrollTop>=nY){if(this._originalMaxHeight==-1){this._originalMaxHeight=oMenu.cfg.getProperty("maxheight");}
-oMenu.cfg.setProperty("maxheight",(nMenuHeight-((nScrollTop-nY)+20)));oMenu.align("bl","tl");}}}
-else if(oMenu&&(oMenu instanceof Overlay)){oMenu.show();oMenu.align("tl","bl");nMenuHeight=oMenu.element.offsetHeight;if((oMenu.cfg.getProperty("y")+nMenuHeight)>nViewportHeight){oMenu.align("bl","tl");}}},_hideMenu:function(){var oMenu=this._menu;if(oMenu){oMenu.hide();}},_onMouseOver:function(p_oEvent){if(!this._hasMouseEventHandlers){this.on("mouseout",this._onMouseOut);this.on("mousedown",this._onMouseDown);this.on("mouseup",this._onMouseUp);this._hasMouseEventHandlers=true;}
-this.addStateCSSClasses("hover");if(this._activationButtonPressed){this.addStateCSSClasses("active");}
-if(this._bOptionPressed){this.addStateCSSClasses("activeoption");}},_onMouseOut:function(p_oEvent){this.removeStateCSSClasses("hover");if(this.get("type")!="menu"){this.removeStateCSSClasses("active");}
-if(this._activationButtonPressed||this._bOptionPressed){Event.on(document,"mouseup",this._onDocumentMouseUp,null,this);}},_onDocumentMouseUp:function(p_oEvent){this._activationButtonPressed=false;this._bOptionPressed=false;var sType=this.get("type");if(sType=="menu"||sType=="split"){this.removeStateCSSClasses((sType=="menu"?"active":"activeoption"));this._hideMenu();}
-Event.removeListener(document,"mouseup",this._onDocumentMouseUp);},_onMouseDown:function(p_oEvent){var sType,oElement,nX,me;function onMouseUp(){this._hideMenu();this.removeListener("mouseup",onMouseUp);}
-if((p_oEvent.which||p_oEvent.button)==1){if(!this.hasFocus()){this.focus();}
-sType=this.get("type");if(sType=="split"){oElement=this.get("element");nX=Event.getPageX(p_oEvent)-Dom.getX(oElement);if((oElement.offsetWidth-this.OPTION_AREA_WIDTH)<nX){this.fireEvent("option",p_oEvent);}
-else{this.addStateCSSClasses("active");this._activationButtonPressed=true;}}
-else if(sType=="menu"){if(this.isActive()){this._hideMenu();this._activationButtonPressed=false;}
-else{this._showMenu(p_oEvent);this._activationButtonPressed=true;}}
-else{this.addStateCSSClasses("active");this._activationButtonPressed=true;}
-if(sType=="split"||sType=="menu"){me=this;this._hideMenuTimerId=window.setTimeout(function(){me.on("mouseup",onMouseUp);},250);}}},_onMouseUp:function(p_oEvent){var sType=this.get("type");if(this._hideMenuTimerId){window.clearTimeout(this._hideMenuTimerId);}
-if(sType=="checkbox"||sType=="radio"){this.set("checked",!(this.get("checked")));}
-this._activationButtonPressed=false;if(this.get("type")!="menu"){this.removeStateCSSClasses("active");}},_onFocus:function(p_oEvent){var oElement;this.addStateCSSClasses("focus");if(this._activationKeyPressed){this.addStateCSSClasses("active");}
-m_oFocusedButton=this;if(!this._hasKeyEventHandlers){oElement=this._button;Event.on(oElement,"blur",this._onBlur,null,this);Event.on(oElement,"keydown",this._onKeyDown,null,this);Event.on(oElement,"keyup",this._onKeyUp,null,this);this._hasKeyEventHandlers=true;}
-this.fireEvent("focus",p_oEvent);},_onBlur:function(p_oEvent){this.removeStateCSSClasses("focus");if(this.get("type")!="menu"){this.removeStateCSSClasses("active");}
-if(this._activationKeyPressed){Event.on(document,"keyup",this._onDocumentKeyUp,null,this);}
-m_oFocusedButton=null;this.fireEvent("blur",p_oEvent);},_onDocumentKeyUp:function(p_oEvent){if(this._isActivationKey(Event.getCharCode(p_oEvent))){this._activationKeyPressed=false;Event.removeListener(document,"keyup",this._onDocumentKeyUp);}},_onKeyDown:function(p_oEvent){var oMenu=this._menu;if(this.get("type")=="split"&&this._isSplitButtonOptionKey(p_oEvent)){this.fireEvent("option",p_oEvent);}
-else if(this._isActivationKey(Event.getCharCode(p_oEvent))){if(this.get("type")=="menu"){this._showMenu(p_oEvent);}
-else{this._activationKeyPressed=true;this.addStateCSSClasses("active");}}
-if(oMenu&&oMenu.cfg.getProperty("visible")&&Event.getCharCode(p_oEvent)==27){oMenu.hide();this.focus();}},_onKeyUp:function(p_oEvent){var sType;if(this._isActivationKey(Event.getCharCode(p_oEvent))){sType=this.get("type");if(sType=="checkbox"||sType=="radio"){this.set("checked",!(this.get("checked")));}
-this._activationKeyPressed=false;if(this.get("type")!="menu"){this.removeStateCSSClasses("active");}}},_onClick:function(p_oEvent){var sType=this.get("type"),sTitle,oForm,oSrcElement,oElement,nX;switch(sType){case"radio":case"checkbox":if(this.get("checked")){sTitle=(sType=="radio")?this.RADIO_CHECKED_TITLE:this.CHECKBOX_CHECKED_TITLE;}
-else{sTitle=(sType=="radio")?this.RADIO_DEFAULT_TITLE:this.CHECKBOX_DEFAULT_TITLE;}
-this.set("title",sTitle);break;case"submit":this.submitForm();break;case"reset":oForm=this.getForm();if(oForm){oForm.reset();}
-break;case"menu":sTitle=this._menu.cfg.getProperty("visible")?this.MENUBUTTON_MENU_VISIBLE_TITLE:this.MENUBUTTON_DEFAULT_TITLE;this.set("title",sTitle);break;case"split":oElement=this.get("element");nX=Event.getPageX(p_oEvent)-Dom.getX(oElement);if((oElement.offsetWidth-this.OPTION_AREA_WIDTH)<nX){return false;}
-else{this._hideMenu();oSrcElement=this.get("srcelement");if(oSrcElement&&oSrcElement.type=="submit"){this.submitForm();}}
-sTitle=this._menu.cfg.getProperty("visible")?this.SPLITBUTTON_OPTION_VISIBLE_TITLE:this.SPLITBUTTON_DEFAULT_TITLE;this.set("title",sTitle);break;}},_onAppendTo:function(p_oEvent){var me=this;window.setTimeout(function(){me._addListenersToForm();},0);},_onFormReset:function(p_oEvent){var sType=this.get("type"),oMenu=this._menu;if(sType=="checkbox"||sType=="radio"){this.resetValue("checked");}
-if(oMenu&&(oMenu instanceof Menu)){this.resetValue("selectedMenuItem");}},_onDocumentMouseDown:function(p_oEvent){var oTarget=Event.getTarget(p_oEvent),oButtonElement=this.get("element"),oMenuElement=this._menu.element;if(oTarget!=oButtonElement&&!Dom.isAncestor(oButtonElement,oTarget)&&oTarget!=oMenuElement&&!Dom.isAncestor(oMenuElement,oTarget)){this._hideMenu();Event.removeListener(document,"mousedown",this._onDocumentMouseDown);}},_onOption:function(p_oEvent){if(this.hasClass("yui-split-button-activeoption")){this._hideMenu();this._bOptionPressed=false;}
-else{this._showMenu(p_oEvent);this._bOptionPressed=true;}},_onOverlayBeforeShow:function(p_sType){var oMenu=this._menu;oMenu.render(this.get("element").parentNode);oMenu.beforeShowEvent.unsubscribe(this._onOverlayBeforeShow);},_onMenuShow:function(p_sType){Event.on(document,"mousedown",this._onDocumentMouseDown,null,this);var sTitle,sState;if(this.get("type")=="split"){sTitle=this.SPLITBUTTON_OPTION_VISIBLE_TITLE;sState="activeoption";}
-else{sTitle=this.MENUBUTTON_MENU_VISIBLE_TITLE;sState="active";}
-this.addStateCSSClasses(sState);this.set("title",sTitle);},_onMenuHide:function(p_sType){var oMenu=this._menu,sTitle,sState;if(oMenu&&(oMenu instanceof Menu)&&this._originalMaxHeight!=-1){this._menu.cfg.setProperty("maxheight",this._originalMaxHeight);}
-if(this.get("type")=="split"){sTitle=this.SPLITBUTTON_DEFAULT_TITLE;sState="activeoption";}
-else{sTitle=this.MENUBUTTON_DEFAULT_TITLE;sState="active";}
-this.removeStateCSSClasses(sState);this.set("title",sTitle);if(this.get("type")=="split"){this._bOptionPressed=false;}},_onMenuKeyDown:function(p_sType,p_aArgs){var oEvent=p_aArgs[0];if(Event.getCharCode(oEvent)==27){this.focus();if(this.get("type")=="split"){this._bOptionPressed=false;}}},_onMenuRender:function(p_sType){var oButtonElement=this.get("element"),oButtonParent=oButtonElement.parentNode,oMenuElement=this._menu.element;if(oButtonParent!=oMenuElement.parentNode){oButtonParent.appendChild(oMenuElement);}
-this.set("selectedMenuItem",this.get("selectedMenuItem"));},_onMenuItemSelected:function(p_sType,p_aArgs,p_nItem){var bSelected=p_aArgs[0];if(bSelected){this.set("selectedMenuItem",p_nItem);}},_onMenuItemAdded:function(p_sType,p_aArgs,p_oItem){var oItem=p_aArgs[0];oItem.cfg.subscribeToConfigEvent("selected",this._onMenuItemSelected,oItem.index,this);},_onMenuClick:function(p_sType,p_aArgs){var oItem=p_aArgs[1],oSrcElement;if(oItem){oSrcElement=this.get("srcelement");if(oSrcElement&&oSrcElement.type=="submit"){this.submitForm();}
-this._hideMenu();}},createButtonElement:function(p_sType){var sNodeName=this.NODE_NAME,oElement=document.createElement(sNodeName);oElement.innerHTML="<"+sNodeName+" class=\"first-child\">"+
-(p_sType=="link"?"<a></a>":"<button type=\"button\"></button>")+"</"+sNodeName+">";return oElement;},addStateCSSClasses:function(p_sState){var sType=this.get("type");if(Lang.isString(p_sState)){if(p_sState!="activeoption"){this.addClass(this.CSS_CLASS_NAME+("-"+p_sState));}
-this.addClass("yui-"+sType+("-button-"+p_sState));}},removeStateCSSClasses:function(p_sState){var sType=this.get("type");if(Lang.isString(p_sState)){this.removeClass(this.CSS_CLASS_NAME+("-"+p_sState));this.removeClass("yui-"+sType+("-button-"+p_sState));}},createHiddenFields:function(){this.removeHiddenFields();var oForm=this.getForm(),oButtonField,sType,bCheckable,oMenu,oMenuItem,sName,oValue,oMenuField;if(oForm&&!this.get("disabled")){sType=this.get("type");bCheckable=(sType=="checkbox"||sType=="radio");if(bCheckable||(m_oSubmitTrigger==this)){oButtonField=createInputElement((bCheckable?sType:"hidden"),this.get("name"),this.get("value"),this.get("checked"));if(oButtonField){if(bCheckable){oButtonField.style.display="none";}
-oForm.appendChild(oButtonField);}}
-oMenu=this._menu;if(oMenu&&(oMenu instanceof Menu)){oMenuField=oMenu.srcElement;oMenuItem=oMenu.getItem(this.get("selectedMenuItem"));if(oMenuField&&oMenuField.nodeName.toUpperCase()=="SELECT"){oForm.appendChild(oMenuField);oMenuField.selectedIndex=oMenuItem.index;}
-else{oValue=(oMenuItem.value===null||oMenuItem.value==="")?oMenuItem.cfg.getProperty("text"):oMenuItem.value;sName=this.get("name");if(oValue&&sName){oMenuField=createInputElement("hidden",(sName+"_options"),oValue);oForm.appendChild(oMenuField);}}}
-if(oButtonField&&oMenuField){this._hiddenFields=[oButtonField,oMenuField];}
-else if(!oButtonField&&oMenuField){this._hiddenFields=oMenuField;}
-else if(oButtonField&&!oMenuField){this._hiddenFields=oButtonField;}
-return this._hiddenFields;}},removeHiddenFields:function(){var oField=this._hiddenFields,nFields,i;function removeChild(p_oElement){if(Dom.inDocument(p_oElement)){p_oElement.parentNode.removeChild(p_oElement);}}
-if(oField){if(Lang.isArray(oField)){nFields=oField.length;if(nFields>0){i=nFields-1;do{removeChild(oField[i]);}
-while(i--);}}
-else{removeChild(oField);}
-this._hiddenFields=null;}},submitForm:function(){var oForm=this.getForm(),oSrcElement=this.get("srcelement"),bSubmitForm=false,oEvent;if(oForm){if(this.get("type")=="submit"||(oSrcElement&&oSrcElement.type=="submit"))
-{m_oSubmitTrigger=this;}
-if(YAHOO.env.ua.ie){bSubmitForm=oForm.fireEvent("onsubmit");}
-else{oEvent=document.createEvent("HTMLEvents");oEvent.initEvent("submit",true,true);bSubmitForm=oForm.dispatchEvent(oEvent);}
-if((YAHOO.env.ua.ie||YAHOO.env.ua.webkit)&&bSubmitForm){oForm.submit();}}
-return bSubmitForm;},init:function(p_oElement,p_oAttributes){var sNodeName=p_oAttributes.type=="link"?"A":"BUTTON",oSrcElement=p_oAttributes.srcelement,oButton=p_oElement.getElementsByTagName(sNodeName)[0],oInput;if(!oButton){oInput=p_oElement.getElementsByTagName("INPUT")[0];if(oInput){oButton=document.createElement("BUTTON");oButton.setAttribute("type","button");oInput.parentNode.replaceChild(oButton,oInput);}}
-this._button=oButton;YAHOO.widget.Button.superclass.init.call(this,p_oElement,p_oAttributes);m_oButtons[this.get("id")]=this;this.addClass(this.CSS_CLASS_NAME);this.addClass("yui-"+this.get("type")+"-button");Event.on(this._button,"focus",this._onFocus,null,this);this.on("mouseover",this._onMouseOver);this.on("click",this._onClick);this.on("appendTo",this._onAppendTo);var oContainer=this.get("container"),oElement=this.get("element"),bElInDoc=Dom.inDocument(oElement),oParentNode;if(oContainer){if(oSrcElement&&oSrcElement!=oElement){oParentNode=oSrcElement.parentNode;if(oParentNode){oParentNode.removeChild(oSrcElement);}}
-if(Lang.isString(oContainer)){Event.onContentReady(oContainer,function(){this.appendTo(oContainer);},null,this);}
-else{this.appendTo(oContainer);}}
-else if(!bElInDoc&&oSrcElement&&oSrcElement!=oElement){oParentNode=oSrcElement.parentNode;if(oParentNode){this.fireEvent("beforeAppendTo",{type:"beforeAppendTo",target:oParentNode});oParentNode.replaceChild(oElement,oSrcElement);this.fireEvent("appendTo",{type:"appendTo",target:oParentNode});}}
-else if(this.get("type")!="link"&&bElInDoc&&oSrcElement&&oSrcElement==oElement){this._addListenersToForm();}},initAttributes:function(p_oAttributes){var oAttributes=p_oAttributes||{};YAHOO.widget.Button.superclass.initAttributes.call(this,oAttributes);this.setAttributeConfig("type",{value:(oAttributes.type||"push"),validator:Lang.isString,writeOnce:true,method:this._setType});this.setAttributeConfig("label",{value:oAttributes.label,validator:Lang.isString,method:this._setLabel});this.setAttributeConfig("value",{value:oAttributes.value});this.setAttributeConfig("name",{value:oAttributes.name,validator:Lang.isString});this.setAttributeConfig("tabindex",{value:oAttributes.tabindex,validator:Lang.isNumber,method:this._setTabIndex});this.configureAttribute("title",{value:oAttributes.title,validator:Lang.isString,method:this._setTitle});this.setAttributeConfig("disabled",{value:(oAttributes.disabled||false),validator:Lang.isBoolean,method:this._setDisabled});this.setAttributeConfig("href",{value:oAttributes.href,validator:Lang.isString,method:this._setHref});this.setAttributeConfig("target",{value:oAttributes.target,validator:Lang.isString,method:this._setTarget});this.setAttributeConfig("checked",{value:(oAttributes.checked||false),validator:Lang.isBoolean,method:this._setChecked});this.setAttributeConfig("container",{value:oAttributes.container,writeOnce:true});this.setAttributeConfig("srcelement",{value:oAttributes.srcelement,writeOnce:true});this.setAttributeConfig("menu",{value:null,method:this._setMenu,writeOnce:true});this.setAttributeConfig("lazyloadmenu",{value:(oAttributes.lazyloadmenu===false?false:true),validator:Lang.isBoolean,writeOnce:true});this.setAttributeConfig("menuclassname",{value:(oAttributes.menuclassname||"yui-button-menu"),validator:Lang.isString,method:this._setMenuClassName,writeOnce:true});this.setAttributeConfig("selectedMenuItem",{value:0,validator:Lang.isNumber,method:this._setSelectedMenuItem});this.setAttributeConfig("onclick",{value:oAttributes.onclick,method:this._setOnClick});this.setAttributeConfig("focusmenu",{value:(oAttributes.focusmenu===false?false:true),validator:Lang.isBoolean});},focus:function(){if(!this.get("disabled")){this._button.focus();}},blur:function(){if(!this.get("disabled")){this._button.blur();}},hasFocus:function(){return(m_oFocusedButton==this);},isActive:function(){return this.hasClass(this.CSS_CLASS_NAME+"-active");},getMenu:function(){return this._menu;},getForm:function(){return this._button.form;},getHiddenFields:function(){return this._hiddenFields;},destroy:function(){var oElement=this.get("element"),oParentNode=oElement.parentNode,oMenu=this._menu;if(oMenu){oMenu.destroy();}
-Event.purgeElement(oElement);Event.purgeElement(this._button);Event.removeListener(document,"mouseup",this._onDocumentMouseUp);Event.removeListener(document,"keyup",this._onDocumentKeyUp);Event.removeListener(document,"mousedown",this._onDocumentMouseDown);var oForm=this.getForm();if(oForm){Event.removeListener(oForm,"reset",this._onFormReset);Event.removeListener(oForm,"submit",this.createHiddenFields);}
-oParentNode.removeChild(oElement);delete m_oButtons[this.get("id")];},fireEvent:function(p_sType,p_aArgs){if(this.DOM_EVENTS[p_sType]&&this.get("disabled")){return;}
-YAHOO.widget.Button.superclass.fireEvent.call(this,p_sType,p_aArgs);},toString:function(){return("Button "+this.get("id"));}});YAHOO.widget.Button.onFormKeyPress=function(p_oEvent){var oTarget=Event.getTarget(p_oEvent),nCharCode=Event.getCharCode(p_oEvent),sNodeName=oTarget.nodeName&&oTarget.nodeName.toUpperCase(),sType=oTarget.type,bFormContainsYUIButtons=false,oButton,oYUISubmitButton,oPrecedingSubmitButton,oFollowingSubmitButton;function isSubmitButton(p_oElement){var sId,oSrcElement;switch(p_oElement.nodeName.toUpperCase()){case"INPUT":case"BUTTON":if(p_oElement.type=="submit"&&!p_oElement.disabled){if(!bFormContainsYUIButtons&&!oPrecedingSubmitButton){oPrecedingSubmitButton=p_oElement;}
-if(oYUISubmitButton&&!oFollowingSubmitButton){oFollowingSubmitButton=p_oElement;}}
-break;default:sId=p_oElement.id;if(sId){oButton=m_oButtons[sId];if(oButton){bFormContainsYUIButtons=true;if(!oButton.get("disabled")){oSrcElement=oButton.get("srcelement");if(!oYUISubmitButton&&(oButton.get("type")=="submit"||(oSrcElement&&oSrcElement.type=="submit")))
-{oYUISubmitButton=oButton;}}}}
-break;}}
-if(nCharCode==13&&((sNodeName=="INPUT"&&(sType=="text"||sType=="password"||sType=="checkbox"||sType=="radio"||sType=="file"))||sNodeName=="SELECT"))
-{Dom.getElementsBy(isSubmitButton,"*",this);if(oPrecedingSubmitButton){oPrecedingSubmitButton.focus();}
-else if(!oPrecedingSubmitButton&&oYUISubmitButton){if(oFollowingSubmitButton){Event.preventDefault(p_oEvent);}
-oYUISubmitButton.submitForm();}}};YAHOO.widget.Button.addHiddenFieldsToForm=function(p_oForm){var aButtons=Dom.getElementsByClassName(YAHOO.widget.Button.prototype.CSS_CLASS_NAME,"*",p_oForm),nButtons=aButtons.length,oButton,sId,i;if(nButtons>0){for(i=0;i<nButtons;i++){sId=aButtons[i].id;if(sId){oButton=m_oButtons[sId];if(oButton){oButton.createHiddenFields();}}}}};})();(function(){var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Lang=YAHOO.lang,Button=YAHOO.widget.Button,m_oButtons={};YAHOO.widget.ButtonGroup=function(p_oElement,p_oAttributes){var fnSuperClass=YAHOO.widget.ButtonGroup.superclass.constructor,sNodeName,oElement,sId;if(arguments.length==1&&!Lang.isString(p_oElement)&&!p_oElement.nodeName){if(!p_oElement.id){sId=Dom.generateId();p_oElement.id=sId;}
-fnSuperClass.call(this,(this._createGroupElement()),p_oElement);}
-else if(Lang.isString(p_oElement)){oElement=Dom.get(p_oElement);if(oElement){if(oElement.nodeName.toUpperCase()==this.NODE_NAME){fnSuperClass.call(this,oElement,p_oAttributes);}}}
-else{sNodeName=p_oElement.nodeName;if(sNodeName&&sNodeName==this.NODE_NAME){if(!p_oElement.id){p_oElement.id=Dom.generateId();}
-fnSuperClass.call(this,p_oElement,p_oAttributes);}}};YAHOO.extend(YAHOO.widget.ButtonGroup,YAHOO.util.Element,{_buttons:null,NODE_NAME:"DIV",CSS_CLASS_NAME:"yui-buttongroup",_createGroupElement:function(){var oElement=document.createElement(this.NODE_NAME);return oElement;},_setDisabled:function(p_bDisabled){var nButtons=this.getCount(),i;if(nButtons>0){i=nButtons-1;do{this._buttons[i].set("disabled",p_bDisabled);}
-while(i--);}},_onKeyDown:function(p_oEvent){var oTarget=Event.getTarget(p_oEvent),nCharCode=Event.getCharCode(p_oEvent),sId=oTarget.parentNode.parentNode.id,oButton=m_oButtons[sId],nIndex=-1;if(nCharCode==37||nCharCode==38){nIndex=(oButton.index===0)?(this._buttons.length-1):(oButton.index-1);}
-else if(nCharCode==39||nCharCode==40){nIndex=(oButton.index===(this._buttons.length-1))?0:(oButton.index+1);}
-if(nIndex>-1){this.check(nIndex);this.getButton(nIndex).focus();}},_onAppendTo:function(p_oEvent){var aButtons=this._buttons,nButtons=aButtons.length,i;for(i=0;i<nButtons;i++){aButtons[i].appendTo(this.get("element"));}},_onButtonCheckedChange:function(p_oEvent,p_oButton){var bChecked=p_oEvent.newValue,oCheckedButton=this.get("checkedButton");if(bChecked&&oCheckedButton!=p_oButton){if(oCheckedButton){oCheckedButton.set("checked",false,true);}
-this.set("checkedButton",p_oButton);this.set("value",p_oButton.get("value"));}
-else if(oCheckedButton&&!oCheckedButton.set("checked")){oCheckedButton.set("checked",true,true);}},init:function(p_oElement,p_oAttributes){this._buttons=[];YAHOO.widget.ButtonGroup.superclass.init.call(this,p_oElement,p_oAttributes);this.addClass(this.CSS_CLASS_NAME);var aButtons=this.getElementsByClassName("yui-radio-button");if(aButtons.length>0){this.addButtons(aButtons);}
-function isRadioButton(p_oElement){return(p_oElement.type=="radio");}
-aButtons=Dom.getElementsBy(isRadioButton,"input",this.get("element"));if(aButtons.length>0){this.addButtons(aButtons);}
-this.on("keydown",this._onKeyDown);this.on("appendTo",this._onAppendTo);var oContainer=this.get("container");if(oContainer){if(Lang.isString(oContainer)){Event.onContentReady(oContainer,function(){this.appendTo(oContainer);},null,this);}
-else{this.appendTo(oContainer);}}},initAttributes:function(p_oAttributes){var oAttributes=p_oAttributes||{};YAHOO.widget.ButtonGroup.superclass.initAttributes.call(this,oAttributes);this.setAttributeConfig("name",{value:oAttributes.name,validator:Lang.isString});this.setAttributeConfig("disabled",{value:(oAttributes.disabled||false),validator:Lang.isBoolean,method:this._setDisabled});this.setAttributeConfig("value",{value:oAttributes.value});this.setAttributeConfig("container",{value:oAttributes.container,writeOnce:true});this.setAttributeConfig("checkedButton",{value:null});},addButton:function(p_oButton){var oButton,oButtonElement,oGroupElement,nIndex,sButtonName,sGroupName;if(p_oButton instanceof Button&&p_oButton.get("type")=="radio"){oButton=p_oButton;}
-else if(!Lang.isString(p_oButton)&&!p_oButton.nodeName){p_oButton.type="radio";oButton=new Button(p_oButton);}
-else{oButton=new Button(p_oButton,{type:"radio"});}
-if(oButton){nIndex=this._buttons.length;sButtonName=oButton.get("name");sGroupName=this.get("name");oButton.index=nIndex;this._buttons[nIndex]=oButton;m_oButtons[oButton.get("id")]=oButton;if(sButtonName!=sGroupName){oButton.set("name",sGroupName);}
-if(this.get("disabled")){oButton.set("disabled",true);}
-if(oButton.get("checked")){this.set("checkedButton",oButton);}
-oButtonElement=oButton.get("element");oGroupElement=this.get("element");if(oButtonElement.parentNode!=oGroupElement){oGroupElement.appendChild(oButtonElement);}
-oButton.on("checkedChange",this._onButtonCheckedChange,oButton,this);return oButton;}},addButtons:function(p_aButtons){var nButtons,oButton,aButtons,i;if(Lang.isArray(p_aButtons)){nButtons=p_aButtons.length;aButtons=[];if(nButtons>0){for(i=0;i<nButtons;i++){oButton=this.addButton(p_aButtons[i]);if(oButton){aButtons[aButtons.length]=oButton;}}
-if(aButtons.length>0){return aButtons;}}}},removeButton:function(p_nIndex){var oButton=this.getButton(p_nIndex),nButtons,i;if(oButton){this._buttons.splice(p_nIndex,1);delete m_oButtons[oButton.get("id")];oButton.removeListener("checkedChange",this._onButtonCheckedChange);oButton.destroy();nButtons=this._buttons.length;if(nButtons>0){i=this._buttons.length-1;do{this._buttons[i].index=i;}
-while(i--);}}},getButton:function(p_nIndex){if(Lang.isNumber(p_nIndex)){return this._buttons[p_nIndex];}},getButtons:function(){return this._buttons;},getCount:function(){return this._buttons.length;},focus:function(p_nIndex){var oButton,nButtons,i;if(Lang.isNumber(p_nIndex)){oButton=this._buttons[p_nIndex];if(oButton){oButton.focus();}}
-else{nButtons=this.getCount();for(i=0;i<nButtons;i++){oButton=this._buttons[i];if(!oButton.get("disabled")){oButton.focus();break;}}}},check:function(p_nIndex){var oButton=this.getButton(p_nIndex);if(oButton){oButton.set("checked",true);}},destroy:function(){var nButtons=this._buttons.length,oElement=this.get("element"),oParentNode=oElement.parentNode,i;if(nButtons>0){i=this._buttons.length-1;do{this._buttons[i].destroy();}
-while(i--);}
-Event.purgeElement(oElement);oParentNode.removeChild(oElement);},toString:function(){return("ButtonGroup "+this.get("id"));}});})();YAHOO.register("button",YAHOO.widget.Button,{version:"2.3.0",build:"442"});
\ No newline at end of file
diff --git a/lib/yui/button/button-beta.js b/lib/yui/button/button-beta.js
deleted file mode 100755 (executable)
index 83195b8..0000000
+++ /dev/null
@@ -1,4477 +0,0 @@
-/*
-Copyright (c) 2007, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 2.3.0
-*/
-/**
-* @module button
-* @description <p>The Button Control enables the creation of rich, graphical 
-* buttons that function like traditional HTML form buttons.  <em>Unlike</em> 
-* tradition HTML form buttons, buttons created with the Button Control can have 
-* a label that is different from its value.  With the inclusion of the optional 
-* <a href="module_menu.html">Menu Control</a>, the Button Control can also be
-* used to create menu buttons and split buttons, controls that are not 
-* available natively in HTML.  The Button Control can also be thought of as a 
-* way to create more visually engaging implementations of the browser's 
-* default radio-button and check-box controls.</p>
-* <p>The Button Control supports the following types:</p>
-* <dl>
-* <dt>push</dt>
-* <dd>Basic push button that can execute a user-specified command when 
-* pressed.</dd>
-* <dt>link</dt>
-* <dd>Navigates to a specified url when pressed.</dd>
-* <dt>submit</dt>
-* <dd>Submits the parent form when pressed.</dd>
-* <dt>reset</dt>
-* <dd>Resets the parent form when pressed.</dd>
-* <dt>checkbox</dt>
-* <dd>Maintains a "checked" state that can be toggled on and off.</dd>
-* <dt>radio</dt>
-* <dd>Maintains a "checked" state that can be toggled on and off.  Use with 
-* the ButtonGroup class to create a set of controls that are mutually 
-* exclusive; checking one button in the set will uncheck all others in 
-* the group.</dd>
-* <dt>menu</dt>
-* <dd>When pressed will show/hide a menu.</dd>
-* <dt>split</dt>
-* <dd>Can execute a user-specified command or display a menu when pressed.</dd>
-* </dl>
-* @title Button
-* @namespace YAHOO.widget
-* @requires yahoo, dom, element, event
-* @optional container, menu
-* @beta
-*/
-
-
-(function () {
-
-
-    /**
-    * The Button class creates a rich, graphical button.
-    * @param {String} p_oElement String specifying the id attribute of the 
-    * <code>&#60;input&#62;</code>, <code>&#60;button&#62;</code>,
-    * <code>&#60;a&#62;</code>, or <code>&#60;span&#62;</code> element to 
-    * be used to create the button.
-    * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-
-    * one-html.html#ID-6043025">HTMLInputElement</a>|<a href="http://www.w3.org
-    * /TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-34812697">
-    * HTMLButtonElement</a>|<a href="
-    * http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#
-    * ID-33759296">HTMLElement</a>} p_oElement Object reference for the 
-    * <code>&#60;input&#62;</code>, <code>&#60;button&#62;</code>, 
-    * <code>&#60;a&#62;</code>, or <code>&#60;span&#62;</code> element to be 
-    * used to create the button.
-    * @param {Object} p_oElement Object literal specifying a set of   
-    * configuration attributes used to create the button.
-    * @param {Object} p_oAttributes Optional. Object literal specifying a set  
-    * of configuration attributes used to create the button.
-    * @namespace YAHOO.widget
-    * @class Button
-    * @constructor
-    * @extends YAHOO.util.Element
-    */
-
-
-
-    // Shorthard for utilities
-
-    var Dom = YAHOO.util.Dom,
-        Event = YAHOO.util.Event,
-        Lang = YAHOO.lang,
-        Overlay = YAHOO.widget.Overlay,
-        Menu = YAHOO.widget.Menu,
-    
-    
-        // Private member variables
-    
-        m_oButtons = {},    // Collection of all Button instances
-        m_oOverlayManager = null,   // YAHOO.widget.OverlayManager instance
-        m_oSubmitTrigger = null,    // The button that submitted the form 
-        m_oFocusedButton = null;    // The button that has focus
-
-
-
-    // Private methods
-
-    
-    
-    /**
-    * @method createInputElement
-    * @description Creates an <code>&#60;input&#62;</code> element of the 
-    * specified type.
-    * @private
-    * @param {String} p_sType String specifying the type of 
-    * <code>&#60;input&#62;</code> element to create.
-    * @param {String} p_sName String specifying the name of 
-    * <code>&#60;input&#62;</code> element to create.
-    * @param {String} p_sValue String specifying the value of 
-    * <code>&#60;input&#62;</code> element to create.
-    * @param {String} p_bChecked Boolean specifying if the  
-    * <code>&#60;input&#62;</code> element is to be checked.
-    * @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-
-    * one-html.html#ID-6043025">HTMLInputElement</a>}
-    */
-    function createInputElement(p_sType, p_sName, p_sValue, p_bChecked) {
-    
-        var oInput,
-            sInput;
-    
-        if (Lang.isString(p_sType) && Lang.isString(p_sName)) {
-        
-            if (YAHOO.env.ua.ie) {
-        
-                /*
-                    For IE it is necessary to create the element with the 
-                    "type," "name," "value," and "checked" properties set all 
-                    at once.
-                */
-            
-                sInput = "<input type=\"" + p_sType + "\" name=\"" + 
-                    p_sName + "\"";
-        
-                if (p_bChecked) {
-        
-                    sInput += " checked";
-                
-                }
-                
-                sInput += ">";
-        
-                oInput = document.createElement(sInput);
-        
-            }
-            else {
-            
-                oInput = document.createElement("input");
-                oInput.name = p_sName;
-                oInput.type = p_sType;
-        
-                if (p_bChecked) {
-        
-                    oInput.checked = true;
-                
-                }
-        
-            }
-        
-            oInput.value = p_sValue;
-            
-            return oInput;
-        
-        }
-    
-    }
-    
-    
-    /**
-    * @method setAttributesFromSrcElement
-    * @description Gets the values for all the attributes of the source element 
-    * (either <code>&#60;input&#62;</code> or <code>&#60;a&#62;</code>) that 
-    * map to Button configuration attributes and sets them into a collection 
-    * that is passed to the Button constructor.
-    * @private
-    * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-
-    * one-html.html#ID-6043025">HTMLInputElement</a>|<a href="http://www.w3.org/
-    * TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-
-    * 48250443">HTMLAnchorElement</a>} p_oElement Object reference to the HTML 
-    * element (either <code>&#60;input&#62;</code> or <code>&#60;span&#62;
-    * </code>) used to create the button.
-    * @param {Object} p_oAttributes Object reference for the collection of 
-    * configuration attributes used to create the button.
-    */
-    function setAttributesFromSrcElement(p_oElement, p_oAttributes) {
-    
-        var sSrcElementNodeName = p_oElement.nodeName.toUpperCase(),
-            me = this,
-            oAttribute,
-            oRootNode,
-            sText;
-            
-    
-        /**
-        * @method setAttributeFromDOMAttribute
-        * @description Gets the value of the specified DOM attribute and sets it 
-        * into the collection of configuration attributes used to configure 
-        * the button.
-        * @private
-        * @param {String} p_sAttribute String representing the name of the 
-        * attribute to retrieve from the DOM element.
-        */
-        function setAttributeFromDOMAttribute(p_sAttribute) {
-    
-            if ( !(p_sAttribute in p_oAttributes) ) {
-    
-                /*
-                    Need to use "getAttributeNode" instead of "getAttribute" 
-                    because using "getAttribute," IE will return the innerText 
-                    of a <code>&#60;button&#62;</code> for the value attribute  
-                    rather than the value of the "value" attribute.
-                */
-        
-                oAttribute = p_oElement.getAttributeNode(p_sAttribute);
-        
-    
-                if (oAttribute && ("value" in oAttribute)) {
-    
-    
-                    p_oAttributes[p_sAttribute] = oAttribute.value;
-    
-                }
-    
-            }
-        
-        }
-    
-    
-        /**
-        * @method setFormElementProperties
-        * @description Gets the value of the attributes from the form element  
-        * and sets them into the collection of configuration attributes used to 
-        * configure the button.
-        * @private
-        */
-        function setFormElementProperties() {
-    
-            setAttributeFromDOMAttribute("type");
-    
-            if (p_oAttributes.type == "button") {
-            
-                p_oAttributes.type = "push";
-            
-            }
-    
-            if ( !("disabled" in p_oAttributes) ) {
-    
-                p_oAttributes.disabled = p_oElement.disabled;
-    
-            }
-    
-            setAttributeFromDOMAttribute("name");
-            setAttributeFromDOMAttribute("value");
-            setAttributeFromDOMAttribute("title");
-    
-        }
-
-    
-        switch (sSrcElementNodeName) {
-        
-        case "A":
-            
-            p_oAttributes.type = "link";
-            
-            setAttributeFromDOMAttribute("href");
-            setAttributeFromDOMAttribute("target");
-        
-            break;
-    
-        case "INPUT":
-
-            setFormElementProperties();
-
-            if ( !("checked" in p_oAttributes) ) {
-    
-                p_oAttributes.checked = p_oElement.checked;
-    
-            }
-
-            break;
-
-        case "BUTTON":
-
-            setFormElementProperties();
-
-            oRootNode = p_oElement.parentNode.parentNode;
-
-            if (Dom.hasClass(oRootNode, this.CSS_CLASS_NAME + "-checked")) {
-            
-                p_oAttributes.checked = true;
-            
-            }
-
-            if (Dom.hasClass(oRootNode, this.CSS_CLASS_NAME + "-disabled")) {
-
-                p_oAttributes.disabled = true;
-            
-            }
-
-            p_oElement.removeAttribute("value");
-
-            p_oElement.setAttribute("type", "button");
-
-            break;
-        
-        }
-
-        p_oElement.removeAttribute("id");
-        p_oElement.removeAttribute("name");
-        
-        if ( !("tabindex" in p_oAttributes) ) {
-
-            p_oAttributes.tabindex = p_oElement.tabIndex;
-
-        }
-    
-        if ( !("label" in p_oAttributes) ) {
-    
-            // Set the "label" property
-        
-            sText = sSrcElementNodeName == "INPUT" ? 
-                            p_oElement.value : p_oElement.innerHTML;
-        
-    
-            if (sText && sText.length > 0) {
-                
-                p_oAttributes.label = sText;
-                
-            } 
-    
-        }
-    
-    }
-    
-    
-    /**
-    * @method initConfig
-    * @description Initializes the set of configuration attributes that are 
-    * used to instantiate the button.
-    * @private
-    * @param {Object} Object representing the button's set of 
-    * configuration attributes.
-    */
-    function initConfig(p_oConfig) {
-    
-        var oAttributes = p_oConfig.attributes,
-            oSrcElement = oAttributes.srcelement,
-            sSrcElementNodeName = oSrcElement.nodeName.toUpperCase(),
-            me = this;
-    
-    
-        if (sSrcElementNodeName == this.NODE_NAME) {
-    
-            p_oConfig.element = oSrcElement;
-            p_oConfig.id = oSrcElement.id;
-
-            Dom.getElementsBy(function (p_oElement) {
-            
-                switch (p_oElement.nodeName.toUpperCase()) {
-                
-                case "BUTTON":
-                case "A":
-                case "INPUT":
-
-                    setAttributesFromSrcElement.call(me, p_oElement, 
-                        oAttributes);
-
-                    break;                        
-                
-                }
-            
-            }, "*", oSrcElement);
-        
-        }
-        else {
-    
-            switch (sSrcElementNodeName) {
-
-            case "BUTTON":
-            case "A":
-            case "INPUT":
-
-                setAttributesFromSrcElement.call(this, oSrcElement, 
-                    oAttributes);
-
-                break;
-
-            }
-        
-        }
-    
-    }
-
-
-
-    //  Constructor
-
-    YAHOO.widget.Button = function (p_oElement, p_oAttributes) {
-    
-        var fnSuperClass = YAHOO.widget.Button.superclass.constructor,
-            oConfig,
-            oElement;
-    
-        if (arguments.length == 1 && !Lang.isString(p_oElement) && 
-            !p_oElement.nodeName) {
-    
-            if (!p_oElement.id) {
-    
-                p_oElement.id = Dom.generateId();
-    
-    
-            }
-    
-    
-    
-            fnSuperClass.call(this, 
-                (this.createButtonElement(p_oElement.type)),
-                p_oElement);
-    
-        }
-        else {
-    
-            oConfig = { element: null, attributes: (p_oAttributes || {}) };
-    
-    
-            if (Lang.isString(p_oElement)) {
-    
-                oElement = Dom.get(p_oElement);
-    
-                if (oElement) {
-
-                    if (!oConfig.attributes.id) {
-                    
-                        oConfig.attributes.id = p_oElement;
-                    
-                    }
-    
-                
-                
-                
-                    oConfig.attributes.srcelement = oElement;
-                
-                    initConfig.call(this, oConfig);
-                
-                
-                    if (!oConfig.element) {
-                
-                
-                        oConfig.element = 
-                            this.createButtonElement(oConfig.attributes.type);
-                
-                    }
-                
-                    fnSuperClass.call(this, oConfig.element, 
-                        oConfig.attributes);
-    
-                }
-    
-            }
-            else if (p_oElement.nodeName) {
-    
-                if (!oConfig.attributes.id) {
-    
-                    if (p_oElement.id) {
-        
-                        oConfig.attributes.id = p_oElement.id;
-                    
-                    }
-                    else {
-        
-                        oConfig.attributes.id = Dom.generateId();
-        
-        
-                    }
-    
-                }
-    
-    
-    
-    
-    
-                oConfig.attributes.srcelement = p_oElement;
-        
-                initConfig.call(this, oConfig);
-        
-        
-                if (!oConfig.element) {
-    
-            
-                    oConfig.element = 
-                        this.createButtonElement(oConfig.attributes.type);
-            
-                }
-            
-                fnSuperClass.call(this, oConfig.element, oConfig.attributes);
-            
-            }
-    
-        }
-    
-    };
-
-
-
-    YAHOO.extend(YAHOO.widget.Button, YAHOO.util.Element, {
-    
-    
-        // Protected properties
-        
-        
-        /** 
-        * @property _button
-        * @description Object reference to the button's internal 
-        * <code>&#60;a&#62;</code> or <code>&#60;button&#62;</code> element.
-        * @default null
-        * @protected
-        * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-        * level-one-html.html#ID-48250443">HTMLAnchorElement</a>|<a href="
-        * http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html
-        * #ID-34812697">HTMLButtonElement</a>
-        */
-        _button: null,
-        
-        
-        /** 
-        * @property _menu
-        * @description Object reference to the button's menu.
-        * @default null
-        * @protected
-        * @type {<a href="YAHOO.widget.Overlay.html">YAHOO.widget.Overlay</a>|
-        * <a href="YAHOO.widget.Menu.html">YAHOO.widget.Menu</a>}
-        */
-        _menu: null,
-        
-        
-        /** 
-        * @property _hiddenFields
-        * @description Object reference to the <code>&#60;input&#62;</code>  
-        * element, or array of HTML form elements used to represent the button
-        *  when its parent form is submitted.
-        * @default null
-        * @protected
-        * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-        * level-one-html.html#ID-6043025">HTMLInputElement</a>|Array
-        */
-        _hiddenFields: null,
-        
-        
-        /** 
-        * @property _onclickAttributeValue
-        * @description Object reference to the button's current value for the 
-        * "onclick" configuration attribute.
-        * @default null
-        * @protected
-        * @type Object
-        */
-        _onclickAttributeValue: null,
-        
-        
-        /** 
-        * @property _activationKeyPressed
-        * @description Boolean indicating if the key(s) that toggle the button's 
-        * "active" state have been pressed.
-        * @default false
-        * @protected
-        * @type Boolean
-        */
-        _activationKeyPressed: false,
-        
-        
-        /** 
-        * @property _activationButtonPressed
-        * @description Boolean indicating if the mouse button that toggles 
-        * the button's "active" state has been pressed.
-        * @default false
-        * @protected
-        * @type Boolean
-        */
-        _activationButtonPressed: false,
-        
-        
-        /** 
-        * @property _hasKeyEventHandlers
-        * @description Boolean indicating if the button's "blur", "keydown" and 
-        * "keyup" event handlers are assigned
-        * @default false
-        * @protected
-        * @type Boolean
-        */
-        _hasKeyEventHandlers: false,
-        
-        
-        /** 
-        * @property _hasMouseEventHandlers
-        * @description Boolean indicating if the button's "mouseout," 
-        * "mousedown," and "mouseup" event handlers are assigned
-        * @default false
-        * @protected
-        * @type Boolean
-        */
-        _hasMouseEventHandlers: false,
-        
-        
-        
-        // Constants
-        
-        
-        /**
-        * @property NODE_NAME
-        * @description The name of the node to be used for the button's 
-        * root element.
-        * @default "SPAN"
-        * @final
-        * @type String
-        */
-        NODE_NAME: "SPAN",
-        
-        
-        /**
-        * @property CHECK_ACTIVATION_KEYS
-        * @description Array of numbers representing keys that (when pressed) 
-        * toggle the button's "checked" attribute.
-        * @default [32]
-        * @final
-        * @type Array
-        */
-        CHECK_ACTIVATION_KEYS: [32],
-        
-        
-        /**
-        * @property ACTIVATION_KEYS
-        * @description Array of numbers representing keys that (when presed) 
-        * toggle the button's "active" state.
-        * @default [13, 32]
-        * @final
-        * @type Array
-        */
-        ACTIVATION_KEYS: [13, 32],
-        
-        
-        /**
-        * @property OPTION_AREA_WIDTH
-        * @description Width (in pixels) of the area of a split button that  
-        * when pressed will display a menu.
-        * @default 20
-        * @final
-        * @type Number
-        */
-        OPTION_AREA_WIDTH: 20,
-        
-        
-        /**
-        * @property CSS_CLASS_NAME
-        * @description String representing the CSS class(es) to be applied to  
-        * the button's root element.
-        * @default "yui-button"
-        * @final
-        * @type String
-        */
-        CSS_CLASS_NAME: "yui-button",
-        
-        
-        /**
-        * @property RADIO_DEFAULT_TITLE
-        * @description String representing the default title applied to buttons 
-        * of type "radio." 
-        * @default "Unchecked.  Click to check."
-        * @final
-        * @type String
-        */
-        RADIO_DEFAULT_TITLE: "Unchecked.  Click to check.",
-        
-        
-        /**
-        * @property RADIO_CHECKED_TITLE
-        * @description String representing the title applied to buttons of 
-        * type "radio" when checked.
-        * @default "Checked.  Click to uncheck."
-        * @final
-        * @type String
-        */
-        RADIO_CHECKED_TITLE: "Checked.  Click to uncheck.",
-        
-        
-        /**
-        * @property CHECKBOX_DEFAULT_TITLE
-        * @description String representing the default title applied to 
-        * buttons of type "checkbox." 
-        * @default "Unchecked.  Click to check."
-        * @final
-        * @type String
-        */
-        CHECKBOX_DEFAULT_TITLE: "Unchecked.  Click to check.",
-        
-        
-        /**
-        * @property CHECKBOX_CHECKED_TITLE
-        * @description String representing the title applied to buttons of type 
-        * "checkbox" when checked.
-        * @default "Checked.  Click to uncheck."
-        * @final
-        * @type String
-        */
-        CHECKBOX_CHECKED_TITLE: "Checked.  Click to uncheck.",
-        
-        
-        /**
-        * @property MENUBUTTON_DEFAULT_TITLE
-        * @description String representing the default title applied to 
-        * buttons of type "menu." 
-        * @default "Menu collapsed.  Click to expand."
-        * @final
-        * @type String
-        */
-        MENUBUTTON_DEFAULT_TITLE: "Menu collapsed.  Click to expand.",
-        
-        
-        /**
-        * @property MENUBUTTON_MENU_VISIBLE_TITLE
-        * @description String representing the title applied to buttons of type 
-        * "menu" when the button's menu is visible. 
-        * @default "Menu expanded.  Click or press Esc to collapse."
-        * @final
-        * @type String
-        */
-        MENUBUTTON_MENU_VISIBLE_TITLE: 
-            "Menu expanded.  Click or press Esc to collapse.",
-        
-        
-        /**
-        * @property SPLITBUTTON_DEFAULT_TITLE
-        * @description  String representing the default title applied to 
-        * buttons of type "split." 
-        * @default "Menu collapsed.  Click inside option region or press 
-        * Ctrl + Shift + M to show the menu."
-        * @final
-        * @type String
-        */
-        SPLITBUTTON_DEFAULT_TITLE: ("Menu collapsed.  Click inside option " + 
-            "region or press Ctrl + Shift + M to show the menu."),
-        
-        
-        /**
-        * @property SPLITBUTTON_OPTION_VISIBLE_TITLE
-        * @description String representing the title applied to buttons of type 
-        * "split" when the button's menu is visible. 
-        * @default "Menu expanded.  Press Esc or Ctrl + Shift + M to hide 
-        * the menu."
-        * @final
-        * @type String
-        */
-        SPLITBUTTON_OPTION_VISIBLE_TITLE: 
-            "Menu expanded.  Press Esc or Ctrl + Shift + M to hide the menu.",
-        
-        
-        /**
-        * @property SUBMIT_TITLE
-        * @description String representing the title applied to buttons of 
-        * type "submit." 
-        * @default "Click to submit form."
-        * @final
-        * @type String
-        */
-        SUBMIT_TITLE: "Click to submit form.",
-        
-        
-        
-        // Protected attribute setter methods
-        
-        
-        /**
-        * @method _setType
-        * @description Sets the value of the button's "type" attribute.
-        * @protected
-        * @param {String} p_sType String indicating the value for the button's 
-        * "type" attribute.
-        */
-        _setType: function (p_sType) {
-        
-            if (p_sType == "split") {
-        
-                this.on("option", this._onOption);
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method _setLabel
-        * @description Sets the value of the button's "label" attribute.
-        * @protected
-        * @param {String} p_sLabel String indicating the value for the button's 
-        * "label" attribute.
-        */
-        _setLabel: function (p_sLabel) {
-
-            this._button.innerHTML = p_sLabel;             
-        
-        },
-        
-        
-        /**
-        * @method _setTabIndex
-        * @description Sets the value of the button's "tabindex" attribute.
-        * @protected
-        * @param {Number} p_nTabIndex Number indicating the value for the 
-        * button's "tabindex" attribute.
-        */
-        _setTabIndex: function (p_nTabIndex) {
-        
-            this._button.tabIndex = p_nTabIndex;
-        
-        },
-        
-        
-        /**
-        * @method _setTitle
-        * @description Sets the value of the button's "title" attribute.
-        * @protected
-        * @param {String} p_nTabIndex Number indicating the value for 
-        * the button's "title" attribute.
-        */
-        _setTitle: function (p_sTitle) {
-        
-            var sTitle = p_sTitle;
-        
-            if (this.get("type") != "link") {
-        
-                if (!sTitle) {
-        
-                    switch (this.get("type")) {
-        
-                    case "radio":
-    
-                        sTitle = this.RADIO_DEFAULT_TITLE;
-    
-                        break;
-    
-                    case "checkbox":
-    
-                        sTitle = this.CHECKBOX_DEFAULT_TITLE;
-    
-                        break;
-                    
-                    case "menu":
-    
-                        sTitle = this.MENUBUTTON_DEFAULT_TITLE;
-    
-                        break;
-    
-                    case "split":
-    
-                        sTitle = this.SPLITBUTTON_DEFAULT_TITLE;
-    
-                        break;
-    
-                    case "submit":
-    
-                        sTitle = this.SUBMIT_TITLE;
-    
-                        break;
-        
-                    }
-        
-                }
-        
-                this._button.title = sTitle;
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method _setDisabled
-        * @description Sets the value of the button's "disabled" attribute.
-        * @protected
-        * @param {Boolean} p_bDisabled Boolean indicating the value for 
-        * the button's "disabled" attribute.
-        */
-        _setDisabled: function (p_bDisabled) {
-        
-            if (this.get("type") != "link") {
-        
-                if (p_bDisabled) {
-        
-                    if (this._menu) {
-        
-                        this._menu.hide();
-        
-                    }
-        
-                    if (this.hasFocus()) {
-                    
-                        this.blur();
-                    
-                    }
-        
-                    this._button.setAttribute("disabled", "disabled");
-        
-                    this.addStateCSSClasses("disabled");
-        
-                }
-                else {
-        
-                    this._button.removeAttribute("disabled");
-        
-                    this.removeStateCSSClasses("disabled");
-                
-                }
-        
-            }
-        
-        },
-
-        
-        /**
-        * @method _setHref
-        * @description Sets the value of the button's "href" attribute.
-        * @protected
-        * @param {String} p_sHref String indicating the value for the button's 
-        * "href" attribute.
-        */
-        _setHref: function (p_sHref) {
-        
-            if (this.get("type") == "link") {
-        
-                this._button.href = p_sHref;
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method _setTarget
-        * @description Sets the value of the button's "target" attribute.
-        * @protected
-        * @param {String} p_sTarget String indicating the value for the button's 
-        * "target" attribute.
-        */
-        _setTarget: function (p_sTarget) {
-        
-            if (this.get("type") == "link") {
-        
-                this._button.setAttribute("target", p_sTarget);
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method _setChecked
-        * @description Sets the value of the button's "target" attribute.
-        * @protected
-        * @param {Boolean} p_bChecked Boolean indicating the value for  
-        * the button's "checked" attribute.
-        */
-        _setChecked: function (p_bChecked) {
-        
-            var sType = this.get("type"),
-                sTitle;
-        
-            if (sType == "checkbox" || sType == "radio") {
-        
-                if (p_bChecked) {
-        
-                    this.addStateCSSClasses("checked");
-                    
-                    sTitle = (sType == "radio") ? 
-                                this.RADIO_CHECKED_TITLE : 
-                                this.CHECKBOX_CHECKED_TITLE;
-                
-                }
-                else {
-
-                    this.removeStateCSSClasses("checked");
-        
-                    sTitle = (sType == "radio") ? 
-                                this.RADIO_DEFAULT_TITLE : 
-                                this.CHECKBOX_DEFAULT_TITLE;
-                
-                }
-        
-                this.set("title", sTitle);
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method _setMenu
-        * @description Sets the value of the button's "menu" attribute.
-        * @protected
-        * @param {Object} p_oMenu Object indicating the value for the button's 
-        * "menu" attribute.
-        */
-        _setMenu: function (p_oMenu) {
-
-            var bLazyLoad = this.get("lazyloadmenu"),
-                oButtonElement = this.get("element"),
-        
-                /*
-                    Boolean indicating if the value of p_oMenu is an instance 
-                    of YAHOO.widget.Menu or YAHOO.widget.Overlay.
-                */
-        
-                bInstance = false,
-        
-
-                oMenu,
-                oMenuElement,
-                oSrcElement,
-                aItems,
-                nItems,
-                oItem,
-                i;
-        
-        
-            if (!Overlay) {
-        
-        
-                return false;
-            
-            }
-        
-        
-            if (!Menu) {
-        
-        
-                return false;
-            
-            }
-        
-        
-            function onAppendTo() {
-
-                oMenu.render(oButtonElement.parentNode);
-                
-                this.removeListener("appendTo", onAppendTo);
-            
-            }
-        
-        
-            function initMenu() {
-        
-                if (oMenu) {
-
-                    Dom.addClass(oMenu.element, this.get("menuclassname"));
-                    Dom.addClass(oMenu.element, 
-                            "yui-" + this.get("type") + "-button-menu");
-
-                    oMenu.showEvent.subscribe(this._onMenuShow, null, this);
-                    oMenu.hideEvent.subscribe(this._onMenuHide, null, this);
-                    oMenu.renderEvent.subscribe(this._onMenuRender, null, this);
-        
-        
-                    if (oMenu instanceof Menu) {
-        
-                        oMenu.keyDownEvent.subscribe(this._onMenuKeyDown, 
-                            this, true);
-
-                        oMenu.clickEvent.subscribe(this._onMenuClick, 
-                            this, true);
-
-                        oMenu.itemAddedEvent.subscribe(this._onMenuItemAdded, 
-                            this, true);
-        
-                        oSrcElement = oMenu.srcElement;
-        
-                        if (oSrcElement && 
-                            oSrcElement.nodeName.toUpperCase() == "SELECT") {
-                
-                            oSrcElement.style.display = "none";
-                            oSrcElement.parentNode.removeChild(oSrcElement);
-        
-                        }
-        
-                    }
-                    else if (oMenu instanceof Overlay) {
-        
-                        if (!m_oOverlayManager) {
-        
-                            m_oOverlayManager = 
-                                new YAHOO.widget.OverlayManager();
-                        
-                        }
-                        
-                        m_oOverlayManager.register(oMenu);
-                        
-                    }
-        
-        
-                    this._menu = oMenu;
-
-        
-                    if (!bInstance) {
-        
-                        if (bLazyLoad && !(oMenu instanceof Menu)) {
-        
-                            /*
-                                Mimic Menu's "lazyload" functionality by adding  
-                                a "beforeshow" event listener that renders the 
-                                Overlay instance before it is made visible by  
-                                the button.
-                            */
-        
-                            oMenu.beforeShowEvent.subscribe(
-                                this._onOverlayBeforeShow, null, this);
-            
-                        }
-                        else if (!bLazyLoad) {
-        
-                            if (Dom.inDocument(oButtonElement)) {
-        
-                                oMenu.render(oButtonElement.parentNode);
-                            
-                            }
-                            else {
-            
-                                this.on("appendTo", onAppendTo);
-                            
-                            }
-                        
-                        }
-                    
-                    }
-        
-                }
-        
-            }
-        
-        
-            if (p_oMenu && (p_oMenu instanceof Menu)) {
-        
-                oMenu = p_oMenu;
-                aItems = oMenu.getItems();
-                nItems = aItems.length;
-                bInstance = true;
-        
-        
-                if (nItems > 0) {
-        
-                    i = nItems - 1;
-        
-                    do {
-        
-                        oItem = aItems[i];
-        
-                        if (oItem) {
-        
-                            oItem.cfg.subscribeToConfigEvent("selected", 
-                                this._onMenuItemSelected, 
-                                oItem, 
-                                this);
-        
-                        }
-        
-                    }
-                    while (i--);
-        
-                }
-        
-                initMenu.call(this);
-        
-            }
-            else if (p_oMenu && (p_oMenu instanceof Overlay)) {
-        
-                oMenu = p_oMenu;
-                bInstance = true;
-        
-                oMenu.cfg.setProperty("visible", false);
-                oMenu.cfg.setProperty("context", [oButtonElement, "tl", "bl"]);
-        
-                initMenu.call(this);
-        
-            }
-            else if (Lang.isArray(p_oMenu)) {
-        
-                this.on("appendTo", function () {
-        
-                    oMenu = new Menu(Dom.generateId(), { lazyload: bLazyLoad, 
-                        itemdata: p_oMenu });
-        
-                    initMenu.call(this);
-        
-                });
-        
-            }
-            else if (Lang.isString(p_oMenu)) {
-        
-                oMenuElement = Dom.get(p_oMenu);
-        
-                if (oMenuElement) {
-        
-                    if (Dom.hasClass(oMenuElement, 
-                        Menu.prototype.CSS_CLASS_NAME) || 
-                        oMenuElement.nodeName == "SELECT") {
-            
-                        oMenu = new Menu(p_oMenu, { lazyload: bLazyLoad });
-            
-                        initMenu.call(this);
-            
-                    }
-                    else {
-        
-                        oMenu = new Overlay(p_oMenu, { visible: false, 
-                            context: [oButtonElement, "tl", "bl"] });
-            
-                        initMenu.call(this);
-            
-                    }
-        
-                }
-        
-            }
-            else if (p_oMenu && p_oMenu.nodeName) {
-        
-                if (Dom.hasClass(p_oMenu, Menu.prototype.CSS_CLASS_NAME) || 
-                        p_oMenu.nodeName == "SELECT") {
-        
-                    oMenu = new Menu(p_oMenu, { lazyload: bLazyLoad });
-                
-                    initMenu.call(this);
-        
-                }
-                else {
-        
-                    if (!p_oMenu.id) {
-                    
-                        Dom.generateId(p_oMenu);
-                    
-                    }
-        
-                    oMenu = new Overlay(p_oMenu, { visible: false, 
-                                    context: [oButtonElement, "tl", "bl"] });
-        
-                    initMenu.call(this);
-                
-                }
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method _setOnClick
-        * @description Sets the value of the button's "onclick" attribute.
-        * @protected
-        * @param {Object} p_oObject Object indicating the value for the button's 
-        * "onclick" attribute.
-        */
-        _setOnClick: function (p_oObject) {
-        
-            /*
-                Remove any existing listeners if a "click" event handler 
-                has already been specified.
-            */
-        
-            if (this._onclickAttributeValue && 
-                (this._onclickAttributeValue != p_oObject)) {
-        
-                this.removeListener("click", this._onclickAttributeValue.fn);
-        
-                this._onclickAttributeValue = null;
-        
-            }
-        
-        
-            if (!this._onclickAttributeValue && 
-                Lang.isObject(p_oObject) && 
-                Lang.isFunction(p_oObject.fn)) {
-        
-                this.on("click", p_oObject.fn, p_oObject.obj, p_oObject.scope);
-        
-                this._onclickAttributeValue = p_oObject;
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method _setSelectedMenuItem
-        * @description Sets the value of the button's 
-        * "selectedMenuItem" attribute.
-        * @protected
-        * @param {Number} p_nIndex Number representing the index of the item 
-        * in the button's menu that is currently selected.
-        */
-        _setSelectedMenuItem: function (p_nIndex) {
-
-            var oMenu = this._menu,
-                oMenuItem;
-
-
-            if (oMenu && oMenu instanceof Menu) {
-
-                oMenuItem = oMenu.getItem(p_nIndex);
-                
-
-                if (oMenuItem && !oMenuItem.cfg.getProperty("selected")) {
-                
-                    oMenuItem.cfg.setProperty("selected", true);
-                
-                }
-            
-            }
-
-        },
-        
-        
-        // Protected methods
-
-        
-        
-        /**
-        * @method _isActivationKey
-        * @description Determines if the specified keycode is one that toggles  
-        * the button's "active" state.
-        * @protected
-        * @param {Number} p_nKeyCode Number representing the keycode to 
-        * be evaluated.
-        * @return {Boolean}
-        */
-        _isActivationKey: function (p_nKeyCode) {
-        
-            var sType = this.get("type"),
-                aKeyCodes = (sType == "checkbox" || sType == "radio") ? 
-                    this.CHECK_ACTIVATION_KEYS : this.ACTIVATION_KEYS,
-        
-                nKeyCodes = aKeyCodes.length,
-                i;
-        
-            if (nKeyCodes > 0) {
-        
-                i = nKeyCodes - 1;
-        
-                do {
-        
-                    if (p_nKeyCode == aKeyCodes[i]) {
-        
-                        return true;
-        
-                    }
-        
-                }
-                while (i--);
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method _isSplitButtonOptionKey
-        * @description Determines if the specified keycode is one that toggles  
-        * the display of the split button's menu.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        * @return {Boolean}
-        */
-        _isSplitButtonOptionKey: function (p_oEvent) {
-        
-            return (p_oEvent.ctrlKey && p_oEvent.shiftKey && 
-                Event.getCharCode(p_oEvent) == 77);
-        
-        },
-        
-        
-        /**
-        * @method _addListenersToForm
-        * @description Adds event handlers to the button's form.
-        * @protected
-        */
-        _addListenersToForm: function () {
-        
-            var oForm = this.getForm(),
-                oSrcElement,
-                aListeners,
-                nListeners,
-                i,
-                bHasKeyPressListener;
-        
-        
-            if (oForm) {
-        
-                Event.on(oForm, "reset", this._onFormReset, null, this);
-                Event.on(oForm, "submit", this.createHiddenFields, null, this);
-        
-                oSrcElement = this.get("srcelement");
-        
-        
-                if (this.get("type") == "submit" || 
-                    (oSrcElement && oSrcElement.type == "submit")) 
-                {
-                
-                    aListeners = Event.getListeners(oForm, "keypress");
-                    bHasKeyPressListener = false;
-            
-                    if (aListeners) {
-            
-                        nListeners = aListeners.length;
-        
-                        if (nListeners > 0) {
-            
-                            i = nListeners - 1;
-                            
-                            do {
-               
-                                if (aListeners[i].fn == 
-                                    YAHOO.widget.Button.onFormKeyPress) 
-                                {
-                
-                                    bHasKeyPressListener = true;
-                                    break;
-                                
-                                }
-                
-                            }
-                            while (i--);
-                        
-                        }
-                    
-                    }
-            
-            
-                    if (!bHasKeyPressListener) {
-        
-                        Event.on(oForm, "keypress", 
-                            YAHOO.widget.Button.onFormKeyPress);
-            
-                    }
-        
-                }
-            
-            }
-        
-        },
-        
-        
-        _originalMaxHeight: -1,
-        
-        
-        /**
-        * @method _showMenu
-        * @description Shows the button's menu.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object 
-        * passed back by the event utility (YAHOO.util.Event) that triggered 
-        * the display of the menu.
-        */
-        _showMenu: function (p_oEvent) {
-        
-            YAHOO.widget.MenuManager.hideVisible();
-        
-            if (m_oOverlayManager) {
-        
-                m_oOverlayManager.hideAll();
-            
-            }
-        
-        
-            var oMenu = this._menu,
-                nViewportHeight = Dom.getViewportHeight(),
-                nMenuHeight,
-                nScrollTop,
-                nY;
-        
-        
-            if (oMenu && (oMenu instanceof Menu)) {
-        
-                oMenu.cfg.applyConfig({ context: [this.get("id"), "tl", "bl"],
-                    constraintoviewport: false,
-                    clicktohide: false,
-                    visible: true });
-                    
-                oMenu.cfg.fireQueue();
-            
-                oMenu.align("tl", "bl");
-        
-                /*
-                    Stop the propagation of the event so that the MenuManager 
-                    doesn't blur the menu after it gets focus.
-                */
-        
-                if (p_oEvent.type == "mousedown") {
-        
-                    Event.stopPropagation(p_oEvent);
-        
-                }
-
-
-                if (this.get("focusmenu")) {
-        
-                    this._menu.focus();
-                
-                }
-        
-                nMenuHeight = oMenu.element.offsetHeight;
-        
-        
-                if ((oMenu.cfg.getProperty("y") + nMenuHeight) > 
-                    nViewportHeight) {
-        
-        
-                    oMenu.align("bl", "tl");
-        
-                    nY = oMenu.cfg.getProperty("y");
-        
-                    nScrollTop = Dom.getDocumentScrollTop();
-        
-        
-                    if (nScrollTop >= nY) {
-        
-                        if (this._originalMaxHeight == -1) {
-        
-                            this._originalMaxHeight = 
-                                    oMenu.cfg.getProperty("maxheight");
-        
-                        }
-        
-                        oMenu.cfg.setProperty("maxheight", 
-                                    (nMenuHeight - ((nScrollTop - nY) + 20)));
-        
-                        oMenu.align("bl", "tl");
-        
-                    }
-        
-                }
-        
-            }
-            else if (oMenu && (oMenu instanceof Overlay)) {
-        
-                oMenu.show();
-                oMenu.align("tl", "bl");
-
-                nMenuHeight = oMenu.element.offsetHeight;
-        
-        
-                if ((oMenu.cfg.getProperty("y") + nMenuHeight) > 
-                    nViewportHeight) {
-        
-        
-                    oMenu.align("bl", "tl");
-                    
-                }
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method _hideMenu
-        * @description Hides the button's menu.
-        * @protected
-        */
-        _hideMenu: function () {
-        
-            var oMenu = this._menu;
-        
-            if (oMenu) {
-        
-                oMenu.hide();
-        
-            }
-        
-        },
-        
-        
-        
-        
-        // Protected event handlers
-        
-        
-        /**
-        * @method _onMouseOver
-        * @description "mouseover" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onMouseOver: function (p_oEvent) {
-        
-            if (!this._hasMouseEventHandlers) {
-        
-                this.on("mouseout", this._onMouseOut);
-                this.on("mousedown", this._onMouseDown);
-                this.on("mouseup", this._onMouseUp);
-        
-                this._hasMouseEventHandlers = true;
-        
-            }
-        
-            this.addStateCSSClasses("hover");
-        
-            if (this._activationButtonPressed) {
-        
-                this.addStateCSSClasses("active");
-        
-            }
-        
-        
-            if (this._bOptionPressed) {
-        
-                this.addStateCSSClasses("activeoption");
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onMouseOut
-        * @description "mouseout" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onMouseOut: function (p_oEvent) {
-        
-            this.removeStateCSSClasses("hover");
-        
-            if (this.get("type") != "menu") {
-        
-                this.removeStateCSSClasses("active");
-        
-            }
-        
-            if (this._activationButtonPressed || this._bOptionPressed) {
-        
-                Event.on(document, "mouseup", this._onDocumentMouseUp, 
-                    null, this);
-        
-            }
-            
-        },
-        
-        
-        /**
-        * @method _onDocumentMouseUp
-        * @description "mouseup" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onDocumentMouseUp: function (p_oEvent) {
-        
-            this._activationButtonPressed = false;
-            this._bOptionPressed = false;
-        
-            var sType = this.get("type");
-        
-            if (sType == "menu" || sType == "split") {
-        
-                this.removeStateCSSClasses(
-                    (sType == "menu" ? "active" : "activeoption"));
-        
-                this._hideMenu();
-        
-            }
-        
-            Event.removeListener(document, "mouseup", this._onDocumentMouseUp);
-        
-        },
-        
-        
-        /**
-        * @method _onMouseDown
-        * @description "mousedown" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onMouseDown: function (p_oEvent) {
-        
-            var sType,
-                oElement,
-                nX,
-                me;
-        
-        
-            function onMouseUp() {
-            
-                this._hideMenu();
-                this.removeListener("mouseup", onMouseUp);
-            
-            }
-        
-        
-            if ((p_oEvent.which || p_oEvent.button) == 1) {
-        
-        
-                if (!this.hasFocus()) {
-                
-                    this.focus();
-                
-                }
-        
-        
-                sType = this.get("type");
-        
-        
-                if (sType == "split") {
-                
-                    oElement = this.get("element");
-                    nX = Event.getPageX(p_oEvent) - Dom.getX(oElement);
-        
-                    if ((oElement.offsetWidth - this.OPTION_AREA_WIDTH) < nX) {
-                        
-                        this.fireEvent("option", p_oEvent);
-        
-                    }
-                    else {
-        
-                        this.addStateCSSClasses("active");
-        
-                        this._activationButtonPressed = true;
-        
-                    }
-        
-                }
-                else if (sType == "menu") {
-        
-                    if (this.isActive()) {
-        
-                        this._hideMenu();
-        
-                        this._activationButtonPressed = false;
-        
-                    }
-                    else {
-        
-                        this._showMenu(p_oEvent);
-        
-                        this._activationButtonPressed = true;
-                    
-                    }
-        
-                }
-                else {
-        
-                    this.addStateCSSClasses("active");
-        
-                    this._activationButtonPressed = true;
-                
-                }
-        
-        
-        
-                if (sType == "split" || sType == "menu") {
-
-                    me = this;
-        
-                    this._hideMenuTimerId = window.setTimeout(function () {
-                    
-                        me.on("mouseup", onMouseUp);
-                    
-                    }, 250);
-        
-                }
-        
-            }
-            
-        },
-        
-        
-        /**
-        * @method _onMouseUp
-        * @description "mouseup" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onMouseUp: function (p_oEvent) {
-        
-            var sType = this.get("type");
-        
-        
-            if (this._hideMenuTimerId) {
-        
-                window.clearTimeout(this._hideMenuTimerId);
-        
-            }
-        
-        
-            if (sType == "checkbox" || sType == "radio") {
-        
-                this.set("checked", !(this.get("checked")));
-            
-            }
-        
-        
-            this._activationButtonPressed = false;
-            
-        
-            if (this.get("type") != "menu") {
-        
-                this.removeStateCSSClasses("active");
-            
-            }
-            
-        },
-        
-        
-        /**
-        * @method _onFocus
-        * @description "focus" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onFocus: function (p_oEvent) {
-        
-            var oElement;
-        
-            this.addStateCSSClasses("focus");
-        
-            if (this._activationKeyPressed) {
-        
-                this.addStateCSSClasses("active");
-           
-            }
-        
-            m_oFocusedButton = this;
-        
-        
-            if (!this._hasKeyEventHandlers) {
-        
-                oElement = this._button;
-        
-                Event.on(oElement, "blur", this._onBlur, null, this);
-                Event.on(oElement, "keydown", this._onKeyDown, null, this);
-                Event.on(oElement, "keyup", this._onKeyUp, null, this);
-        
-                this._hasKeyEventHandlers = true;
-        
-            }
-        
-        
-            this.fireEvent("focus", p_oEvent);
-        
-        },
-        
-        
-        /**
-        * @method _onBlur
-        * @description "blur" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onBlur: function (p_oEvent) {
-        
-            this.removeStateCSSClasses("focus");
-        
-            if (this.get("type") != "menu") {
-        
-                this.removeStateCSSClasses("active");
-        
-            }    
-        
-            if (this._activationKeyPressed) {
-        
-                Event.on(document, "keyup", this._onDocumentKeyUp, null, this);
-        
-            }
-        
-        
-            m_oFocusedButton = null;
-        
-            this.fireEvent("blur", p_oEvent);
-           
-        },
-        
-        
-        /**
-        * @method _onDocumentKeyUp
-        * @description "keyup" event handler for the document.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onDocumentKeyUp: function (p_oEvent) {
-        
-            if (this._isActivationKey(Event.getCharCode(p_oEvent))) {
-        
-                this._activationKeyPressed = false;
-                
-                Event.removeListener(document, "keyup", this._onDocumentKeyUp);
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onKeyDown
-        * @description "keydown" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onKeyDown: function (p_oEvent) {
-        
-            var oMenu = this._menu;
-        
-        
-            if (this.get("type") == "split" && 
-                this._isSplitButtonOptionKey(p_oEvent)) {
-        
-                this.fireEvent("option", p_oEvent);
-        
-            }
-            else if (this._isActivationKey(Event.getCharCode(p_oEvent))) {
-        
-                if (this.get("type") == "menu") {
-        
-                    this._showMenu(p_oEvent);
-        
-                }
-                else {
-        
-                    this._activationKeyPressed = true;
-                    
-                    this.addStateCSSClasses("active");
-                
-                }
-            
-            }
-        
-        
-            if (oMenu && oMenu.cfg.getProperty("visible") && 
-                Event.getCharCode(p_oEvent) == 27) {
-            
-                oMenu.hide();
-                this.focus();
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onKeyUp
-        * @description "keyup" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onKeyUp: function (p_oEvent) {
-        
-            var sType;
-        
-            if (this._isActivationKey(Event.getCharCode(p_oEvent))) {
-        
-                sType = this.get("type");
-        
-                if (sType == "checkbox" || sType == "radio") {
-        
-                    this.set("checked", !(this.get("checked")));
-                
-                }
-        
-                this._activationKeyPressed = false;
-        
-                if (this.get("type") != "menu") {
-        
-                    this.removeStateCSSClasses("active");
-        
-                }
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onClick
-        * @description "click" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onClick: function (p_oEvent) {
-        
-            var sType = this.get("type"),
-                sTitle,
-                oForm,
-                oSrcElement,
-                oElement,
-                nX;
-        
-        
-            switch (sType) {
-        
-            case "radio":
-            case "checkbox":
-    
-                if (this.get("checked")) {
-                    
-                    sTitle = (sType == "radio") ? 
-                                this.RADIO_CHECKED_TITLE : 
-                                this.CHECKBOX_CHECKED_TITLE;
-                
-                }
-                else {
-                
-                    sTitle = (sType == "radio") ? 
-                                this.RADIO_DEFAULT_TITLE : 
-                                this.CHECKBOX_DEFAULT_TITLE;
-                
-                }
-                
-                this.set("title", sTitle);
-    
-                break;
-    
-            case "submit":
-    
-                this.submitForm();
-            
-                break;
-    
-            case "reset":
-    
-                oForm = this.getForm();
-    
-                if (oForm) {
-    
-                    oForm.reset();
-                
-                }
-    
-                break;
-    
-            case "menu":
-    
-                sTitle = this._menu.cfg.getProperty("visible") ? 
-                                this.MENUBUTTON_MENU_VISIBLE_TITLE : 
-                                this.MENUBUTTON_DEFAULT_TITLE;
-    
-                this.set("title", sTitle);
-    
-                break;
-    
-            case "split":
-    
-                oElement = this.get("element");
-                nX = Event.getPageX(p_oEvent) - Dom.getX(oElement);
-    
-                if ((oElement.offsetWidth - this.OPTION_AREA_WIDTH) < nX) {
-    
-                    return false;
-                
-                }
-                else {
-    
-                    this._hideMenu();
-        
-                    oSrcElement = this.get("srcelement");
-        
-                    if (oSrcElement && oSrcElement.type == "submit") {
-    
-                        this.submitForm();
-                    
-                    }
-                
-                }
-    
-                sTitle = this._menu.cfg.getProperty("visible") ? 
-                                this.SPLITBUTTON_OPTION_VISIBLE_TITLE : 
-                                this.SPLITBUTTON_DEFAULT_TITLE;
-    
-                this.set("title", sTitle);
-    
-                break;
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onAppendTo
-        * @description "appendTo" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onAppendTo: function (p_oEvent) {
-        
-            /*
-                It is necessary to call "getForm" using "setTimeout" to make 
-                sure that the button's "form" property returns a node 
-                reference.  Sometimes, if you try to get the reference 
-                immediately after appending the field, it is null.
-            */
-        
-            var me = this;
-        
-            window.setTimeout(function () {
-        
-                me._addListenersToForm();
-        
-            }, 0);
-        
-        },
-        
-        
-        /**
-        * @method _onFormReset
-        * @description "reset" event handler for the button's form.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event 
-        * object passed back by the event utility (YAHOO.util.Event).
-        */
-        _onFormReset: function (p_oEvent) {
-        
-            var sType = this.get("type"),
-                oMenu = this._menu;
-        
-            if (sType == "checkbox" || sType == "radio") {
-        
-                this.resetValue("checked");
-        
-            }
-        
-        
-            if (oMenu && (oMenu instanceof Menu)) {
-        
-                this.resetValue("selectedMenuItem");
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onDocumentMouseDown
-        * @description "mousedown" event handler for the document.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onDocumentMouseDown: function (p_oEvent) {
-        
-            var oTarget = Event.getTarget(p_oEvent),
-                oButtonElement = this.get("element"),
-                oMenuElement = this._menu.element;
-        
-            if (oTarget != oButtonElement && 
-                !Dom.isAncestor(oButtonElement, oTarget) && 
-                oTarget != oMenuElement && 
-                !Dom.isAncestor(oMenuElement, oTarget)) {
-        
-                this._hideMenu();
-        
-                Event.removeListener(document, "mousedown", 
-                    this._onDocumentMouseDown);    
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onOption
-        * @description "option" event handler for the button.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onOption: function (p_oEvent) {
-        
-            if (this.hasClass("yui-split-button-activeoption")) {
-        
-                this._hideMenu();
-        
-                this._bOptionPressed = false;
-        
-            }
-            else {
-        
-                this._showMenu(p_oEvent);    
-        
-                this._bOptionPressed = true;
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onOverlayBeforeShow
-        * @description "beforeshow" event handler for the 
-        * <a href="YAHOO.widget.Overlay.html">YAHOO.widget.Overlay</a> instance 
-        * serving as the button's menu.
-        * @private
-        * @param {String} p_sType String representing the name of the event  
-        * that was fired.
-        */
-        _onOverlayBeforeShow: function (p_sType) {
-        
-            var oMenu = this._menu;
-        
-            oMenu.render(this.get("element").parentNode);
-            
-            oMenu.beforeShowEvent.unsubscribe(this._onOverlayBeforeShow);
-        
-        },
-        
-        
-        /**
-        * @method _onMenuShow
-        * @description "show" event handler for the button's menu.
-        * @private
-        * @param {String} p_sType String representing the name of the event  
-        * that was fired.
-        */
-        _onMenuShow: function (p_sType) {
-        
-            Event.on(document, "mousedown", this._onDocumentMouseDown, 
-                null, this);
-        
-            var sTitle,
-                sState;
-            
-            if (this.get("type") == "split") {
-        
-                sTitle = this.SPLITBUTTON_OPTION_VISIBLE_TITLE;
-                sState = "activeoption";
-            
-            }
-            else {
-        
-                sTitle = this.MENUBUTTON_MENU_VISIBLE_TITLE;        
-                sState = "active";
-        
-            }
-        
-            this.addStateCSSClasses(sState);
-            this.set("title", sTitle);
-        
-        },
-        
-        
-        /**
-        * @method _onMenuHide
-        * @description "hide" event handler for the button's menu.
-        * @private
-        * @param {String} p_sType String representing the name of the event  
-        * that was fired.
-        */
-        _onMenuHide: function (p_sType) {
-            
-            var oMenu = this._menu,
-                sTitle,
-                sState;
-        
-            if (oMenu && (oMenu instanceof Menu) && 
-                this._originalMaxHeight != -1) {
-            
-                this._menu.cfg.setProperty("maxheight", 
-                    this._originalMaxHeight);
-        
-            }
-        
-            
-            if (this.get("type") == "split") {
-        
-                sTitle = this.SPLITBUTTON_DEFAULT_TITLE;
-                sState = "activeoption";
-        
-            }
-            else {
-        
-                sTitle = this.MENUBUTTON_DEFAULT_TITLE;        
-                sState = "active";
-            }
-        
-        
-            this.removeStateCSSClasses(sState);
-            this.set("title", sTitle);
-        
-        
-            if (this.get("type") == "split") {
-        
-                this._bOptionPressed = false;
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onMenuKeyDown
-        * @description "keydown" event handler for the button's menu.
-        * @private
-        * @param {String} p_sType String representing the name of the event  
-        * that was fired.
-        * @param {Array} p_aArgs Array of arguments sent when the event 
-        * was fired.
-        */
-        _onMenuKeyDown: function (p_sType, p_aArgs) {
-        
-            var oEvent = p_aArgs[0];
-        
-            if (Event.getCharCode(oEvent) == 27) {
-        
-                this.focus();
-        
-                if (this.get("type") == "split") {
-                
-                    this._bOptionPressed = false;
-                
-                }
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onMenuRender
-        * @description "render" event handler for the button's menu.
-        * @private
-        * @param {String} p_sType String representing the name of the  
-        * event thatwas fired.
-        */
-        _onMenuRender: function (p_sType) {
-        
-            var oButtonElement = this.get("element"),
-                oButtonParent = oButtonElement.parentNode,
-                oMenuElement = this._menu.element;
-        
-        
-            if (oButtonParent != oMenuElement.parentNode) {
-        
-                oButtonParent.appendChild(oMenuElement);
-            
-            }
-
-            this.set("selectedMenuItem", this.get("selectedMenuItem"));
-
-        },
-        
-        
-        /**
-        * @method _onMenuItemSelected
-        * @description "selectedchange" event handler for each item in the 
-        * button's menu.
-        * @private
-        * @param {String} p_sType String representing the name of the event  
-        * that was fired.
-        * @param {Array} p_aArgs Array of arguments sent when the event 
-        * was fired.
-        * @param {Number} p_nItem Number representing the index of the menu
-        * item that subscribed to the event.
-        */
-        _onMenuItemSelected: function (p_sType, p_aArgs, p_nItem) {
-
-            var bSelected = p_aArgs[0];
-
-            if (bSelected) {
-            
-                this.set("selectedMenuItem", p_nItem);
-
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onMenuItemAdded
-        * @description "itemadded" event handler for the button's menu.
-        * @private
-        * @param {String} p_sType String representing the name of the event  
-        * that was fired.
-        * @param {Array} p_aArgs Array of arguments sent when the event
-        * was fired.
-        * @param {<a href="YAHOO.widget.MenuItem.html">
-        * YAHOO.widget.MenuItem</a>} p_oItem Object representing the menu 
-        * item that subscribed to the event.
-        */
-        _onMenuItemAdded: function (p_sType, p_aArgs, p_oItem) {
-            
-            var oItem = p_aArgs[0];
-        
-            oItem.cfg.subscribeToConfigEvent("selected", 
-                this._onMenuItemSelected, 
-                oItem.index, 
-                this);
-        
-        },
-        
-        
-        /**
-        * @method _onMenuClick
-        * @description "click" event handler for the button's menu.
-        * @private
-        * @param {String} p_sType String representing the name of the event  
-        * that was fired.
-        * @param {Array} p_aArgs Array of arguments sent when the event 
-        * was fired.
-        */
-        _onMenuClick: function (p_sType, p_aArgs) {
-        
-            var oItem = p_aArgs[1],
-                oSrcElement;
-        
-            if (oItem) {
-        
-                oSrcElement = this.get("srcelement");
-            
-                if (oSrcElement && oSrcElement.type == "submit") {
-        
-                    this.submitForm();
-            
-                }
-            
-                this._hideMenu();
-            
-            }
-        
-        },
-        
-        
-        
-        // Public methods
-        
-        
-        /**
-        * @method createButtonElement
-        * @description Creates the button's HTML elements.
-        * @param {String} p_sType String indicating the type of element 
-        * to create.
-        * @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-        * level-one-html.html#ID-58190037">HTMLElement</a>}
-        */
-        createButtonElement: function (p_sType) {
-        
-            var sNodeName = this.NODE_NAME,
-                oElement = document.createElement(sNodeName);
-        
-            oElement.innerHTML =  "<" + sNodeName + " class=\"first-child\">" + 
-                (p_sType == "link" ? "<a></a>" : 
-                "<button type=\"button\"></button>") + "</" + sNodeName + ">";
-        
-            return oElement;
-        
-        },
-
-        
-        /**
-        * @method addStateCSSClasses
-        * @description Appends state-specific CSS classes to the button's root 
-        * DOM element.
-        */
-        addStateCSSClasses: function (p_sState) {
-        
-            var sType = this.get("type");
-        
-            if (Lang.isString(p_sState)) {
-        
-                if (p_sState != "activeoption") {
-        
-                    this.addClass(this.CSS_CLASS_NAME + ("-" + p_sState));
-        
-                }
-        
-                this.addClass("yui-" + sType + ("-button-" + p_sState));
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method removeStateCSSClasses
-        * @description Removes state-specific CSS classes to the button's root 
-        * DOM element.
-        */
-        removeStateCSSClasses: function (p_sState) {
-        
-            var sType = this.get("type");
-        
-            if (Lang.isString(p_sState)) {
-        
-                this.removeClass(this.CSS_CLASS_NAME + ("-" + p_sState));
-                this.removeClass("yui-" + sType + ("-button-" + p_sState));
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method createHiddenFields
-        * @description Creates the button's hidden form field and appends it 
-        * to its parent form.
-        * @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-        * level-one-html.html#ID-6043025">HTMLInputElement</a>|Array}
-        */
-        createHiddenFields: function () {
-        
-            this.removeHiddenFields();
-        
-            var oForm = this.getForm(),
-                oButtonField,
-                sType,     
-                bCheckable,
-                oMenu,
-                oMenuItem,
-                sName,
-                oValue,
-                oMenuField;
-        
-        
-            if (oForm && !this.get("disabled")) {
-        
-                sType = this.get("type");
-                bCheckable = (sType == "checkbox" || sType == "radio");
-        
-        
-                if (bCheckable || (m_oSubmitTrigger == this)) {
-                
-        
-                    oButtonField = createInputElement(
-                                    (bCheckable ? sType : "hidden"),
-                                    this.get("name"),
-                                    this.get("value"),
-                                    this.get("checked"));
-            
-            
-                    if (oButtonField) {
-            
-                        if (bCheckable) {
-            
-                            oButtonField.style.display = "none";
-            
-                        }
-            
-                        oForm.appendChild(oButtonField);
-            
-                    }
-        
-                }
-                    
-        
-                oMenu = this._menu;
-            
-            
-                if (oMenu && (oMenu instanceof Menu)) {
-        
-        
-                    oMenuField = oMenu.srcElement;
-                    oMenuItem = oMenu.getItem(this.get("selectedMenuItem"));
-        
-                    if (oMenuField && 
-                        oMenuField.nodeName.toUpperCase() == "SELECT") {
-        
-                        oForm.appendChild(oMenuField);
-                        oMenuField.selectedIndex = oMenuItem.index;
-        
-                    }
-                    else {
-        
-                        oValue = (oMenuItem.value === null || 
-                                    oMenuItem.value === "") ? 
-                                    oMenuItem.cfg.getProperty("text") : 
-                                    oMenuItem.value;
-        
-                        sName = this.get("name");
-        
-                        if (oValue && sName) {
-        
-                            oMenuField = createInputElement("hidden", 
-                                                (sName + "_options"),
-                                                oValue);
-        
-                            oForm.appendChild(oMenuField);
-        
-                        }
-        
-                    }  
-        
-                }
-            
-            
-                if (oButtonField && oMenuField) {
-        
-                    this._hiddenFields = [oButtonField, oMenuField];
-        
-                }
-                else if (!oButtonField && oMenuField) {
-        
-                    this._hiddenFields = oMenuField;
-                
-                }
-                else if (oButtonField && !oMenuField) {
-        
-                    this._hiddenFields = oButtonField;
-                
-                }
-        
-        
-                return this._hiddenFields;
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method removeHiddenFields
-        * @description Removes the button's hidden form field(s) from its 
-        * parent form.
-        */
-        removeHiddenFields: function () {
-        
-            var oField = this._hiddenFields,
-                nFields,
-                i;
-        
-            function removeChild(p_oElement) {
-        
-                if (Dom.inDocument(p_oElement)) {
-        
-                    p_oElement.parentNode.removeChild(p_oElement);
-                
-                }
-                
-            }
-            
-        
-            if (oField) {
-        
-                if (Lang.isArray(oField)) {
-        
-                    nFields = oField.length;
-                    
-                    if (nFields > 0) {
-                    
-                        i = nFields - 1;
-                        
-                        do {
-        
-                            removeChild(oField[i]);
-        
-                        }
-                        while (i--);
-                    
-                    }
-                
-                }
-                else {
-        
-                    removeChild(oField);
-        
-                }
-        
-                this._hiddenFields = null;
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method submitForm
-        * @description Submits the form to which the button belongs.  Returns  
-        * true if the form was submitted successfully, false if the submission 
-        * was cancelled.
-        * @protected
-        * @return {Boolean}
-        */
-        submitForm: function () {
-        
-            var oForm = this.getForm(),
-        
-                oSrcElement = this.get("srcelement"),
-        
-                /*
-                    Boolean indicating if the event fired successfully 
-                    (was not cancelled by any handlers)
-                */
-        
-                bSubmitForm = false,
-                
-                oEvent;
-        
-        
-            if (oForm) {
-        
-                if (this.get("type") == "submit" || 
-                    (oSrcElement && oSrcElement.type == "submit")) 
-                {
-        
-                    m_oSubmitTrigger = this;
-                    
-                }
-        
-        
-                if (YAHOO.env.ua.ie) {
-        
-                    bSubmitForm = oForm.fireEvent("onsubmit");
-        
-                }
-                else {  // Gecko, Opera, and Safari
-        
-                    oEvent = document.createEvent("HTMLEvents");
-                    oEvent.initEvent("submit", true, true);
-        
-                    bSubmitForm = oForm.dispatchEvent(oEvent);
-        
-                }
-        
-        
-                /*
-                    In IE and Safari, dispatching a "submit" event to a form 
-                    WILL cause the form's "submit" event to fire, but WILL NOT 
-                    submit the form.  Therefore, we need to call the "submit" 
-                    method as well.
-                */
-              
-                if ((YAHOO.env.ua.ie || YAHOO.env.ua.webkit) && bSubmitForm) {
-        
-                    oForm.submit();
-                
-                }
-            
-            }
-        
-            return bSubmitForm;
-            
-        },
-        
-        
-        /**
-        * @method init
-        * @description The Button class's initialization method.
-        * @param {String} p_oElement String specifying the id attribute of the 
-        * <code>&#60;input&#62;</code>, <code>&#60;button&#62;</code>,
-        * <code>&#60;a&#62;</code>, or <code>&#60;span&#62;</code> element to 
-        * be used to create the button.
-        * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-        * level-one-html.html#ID-6043025">HTMLInputElement</a>|<a href="http://
-        * www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html
-        * #ID-34812697">HTMLButtonElement</a>|<a href="http://www.w3.org/TR
-        * /2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-33759296">
-        * HTMLElement</a>} p_oElement Object reference for the 
-        * <code>&#60;input&#62;</code>, <code>&#60;button&#62;</code>, 
-        * <code>&#60;a&#62;</code>, or <code>&#60;span&#62;</code> element to be 
-        * used to create the button.
-        * @param {Object} p_oElement Object literal specifying a set of 
-        * configuration attributes used to create the button.
-        * @param {Object} p_oAttributes Optional. Object literal specifying a 
-        * set of configuration attributes used to create the button.
-        */
-        init: function (p_oElement, p_oAttributes) {
-        
-            var sNodeName = p_oAttributes.type == "link" ? "A" : "BUTTON",
-                oSrcElement = p_oAttributes.srcelement,
-                oButton = p_oElement.getElementsByTagName(sNodeName)[0],
-                oInput;
-        
-
-            if (!oButton) {
-
-                oInput = p_oElement.getElementsByTagName("INPUT")[0];
-
-
-                if (oInput) {
-
-                    oButton = document.createElement("BUTTON");
-                    oButton.setAttribute("type", "button");
-
-                    oInput.parentNode.replaceChild(oButton, oInput);
-                
-                }
-
-            }
-
-            this._button = oButton;
-        
-
-            YAHOO.widget.Button.superclass.init.call(this, p_oElement, 
-                p_oAttributes);
-        
-        
-            m_oButtons[this.get("id")] = this;
-        
-        
-            this.addClass(this.CSS_CLASS_NAME);
-            
-            this.addClass("yui-" + this.get("type") + "-button");
-        
-            Event.on(this._button, "focus", this._onFocus, null, this);
-            this.on("mouseover", this._onMouseOver);
-            this.on("click", this._onClick);
-            this.on("appendTo", this._onAppendTo);
-            
-        
-            var oContainer = this.get("container"),
-                oElement = this.get("element"),
-                bElInDoc = Dom.inDocument(oElement),
-                oParentNode;
-
-
-            if (oContainer) {
-        
-                if (oSrcElement && oSrcElement != oElement) {
-                
-                    oParentNode = oSrcElement.parentNode;
-
-                    if (oParentNode) {
-                    
-                        oParentNode.removeChild(oSrcElement);
-                    
-                    }
-
-                }
-        
-                if (Lang.isString(oContainer)) {
-        
-                    Event.onContentReady(oContainer, function () {
-        
-                        this.appendTo(oContainer);
-                    
-                    }, null, this);
-        
-                }
-                else {
-        
-                    this.appendTo(oContainer);
-        
-                }
-        
-            }
-            else if (!bElInDoc && oSrcElement && oSrcElement != oElement) {
-
-                oParentNode = oSrcElement.parentNode;
-        
-                if (oParentNode) {
-        
-                    this.fireEvent("beforeAppendTo", {
-                        type: "beforeAppendTo",
-                        target: oParentNode
-                    });
-            
-                    oParentNode.replaceChild(oElement, oSrcElement);
-            
-                    this.fireEvent("appendTo", {
-                        type: "appendTo",
-                        target: oParentNode
-                    });
-                
-                }
-        
-            }
-            else if (this.get("type") != "link" && bElInDoc && oSrcElement && 
-                oSrcElement == oElement) {
-        
-                this._addListenersToForm();
-        
-            }
-        
-        
-        },
-        
-        
-        /**
-        * @method initAttributes
-        * @description Initializes all of the configuration attributes used to  
-        * create the button.
-        * @param {Object} p_oAttributes Object literal specifying a set of 
-        * configuration attributes used to create the button.
-        */
-        initAttributes: function (p_oAttributes) {
-        
-            var oAttributes = p_oAttributes || {};
-        
-            YAHOO.widget.Button.superclass.initAttributes.call(this, 
-                oAttributes);
-        
-        
-            /**
-            * @config type
-            * @description String specifying the button's type.  Possible 
-            * values are: "push," "link," "submit," "reset," "checkbox," 
-            * "radio," "menu," and "split."
-            * @default "push"
-            * @type String
-            */
-            this.setAttributeConfig("type", {
-        
-                value: (oAttributes.type || "push"),
-                validator: Lang.isString,
-                writeOnce: true,
-                method: this._setType
-        
-            });
-        
-        
-            /**
-            * @config label
-            * @description String specifying the button's text label 
-            * or innerHTML.
-            * @default null
-            * @type String
-            */
-            this.setAttributeConfig("label", {
-        
-                value: oAttributes.label,
-                validator: Lang.isString,
-                method: this._setLabel
-        
-            });
-        
-        
-            /**
-            * @config value
-            * @description Object specifying the value for the button.
-            * @default null
-            * @type Object
-            */
-            this.setAttributeConfig("value", {
-        
-                value: oAttributes.value
-        
-            });
-        
-        
-            /**
-            * @config name
-            * @description String specifying the name for the button.
-            * @default null
-            * @type String
-            */
-            this.setAttributeConfig("name", {
-        
-                value: oAttributes.name,
-                validator: Lang.isString
-        
-            });
-        
-        
-            /**
-            * @config tabindex
-            * @description Number specifying the tabindex for the button.
-            * @default null
-            * @type Number
-            */
-            this.setAttributeConfig("tabindex", {
-        
-                value: oAttributes.tabindex,
-                validator: Lang.isNumber,
-                method: this._setTabIndex
-        
-            });
-        
-        
-            /**
-            * @config title
-            * @description String specifying the title for the button.
-            * @default null
-            * @type String
-            */
-            this.configureAttribute("title", {
-        
-                value: oAttributes.title,
-                validator: Lang.isString,
-                method: this._setTitle
-        
-            });
-        
-        
-            /**
-            * @config disabled
-            * @description Boolean indicating if the button should be disabled.  
-            * (Disabled buttons are dimmed and will not respond to user input 
-            * or fire events.  Does not apply to button's of type "link.")
-            * @default false
-            * @type Boolean
-            */
-            this.setAttributeConfig("disabled", {
-        
-                value: (oAttributes.disabled || false),
-                validator: Lang.isBoolean,
-                method: this._setDisabled
-        
-            });
-        
-        
-            /**
-            * @config href
-            * @description String specifying the href for the button.  Applies
-            * only to buttons of type "link."
-            * @type String
-            */
-            this.setAttributeConfig("href", {
-        
-                value: oAttributes.href,
-                validator: Lang.isString,
-                method: this._setHref
-        
-            });
-        
-        
-            /**
-            * @config target
-            * @description String specifying the target for the button.  
-            * Applies only to buttons of type "link."
-            * @type String
-            */
-            this.setAttributeConfig("target", {
-        
-                value: oAttributes.target,
-                validator: Lang.isString,
-                method: this._setTarget
-        
-            });
-        
-        
-            /**
-            * @config checked
-            * @description Boolean indicating if the button is checked. 
-            * Applies only to buttons of type "radio" and "checkbox."
-            * @default false
-            * @type Boolean
-            */
-            this.setAttributeConfig("checked", {
-        
-                value: (oAttributes.checked || false),
-                validator: Lang.isBoolean,
-                method: this._setChecked
-        
-            });
-        
-        
-            /**
-            * @config container
-            * @description HTML element reference or string specifying the id 
-            * attribute of the HTML element that the button's markup should be 
-            * rendered into.
-            * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-            * level-one-html.html#ID-58190037">HTMLElement</a>|String
-            * @default null
-            */
-            this.setAttributeConfig("container", {
-        
-                value: oAttributes.container,
-                writeOnce: true
-        
-            });
-        
-        
-            /**
-            * @config srcelement
-            * @description Object reference to the HTML element (either 
-            * <code>&#60;input&#62;</code> or <code>&#60;span&#62;</code>) 
-            * used to create the button.
-            * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-            * level-one-html.html#ID-58190037">HTMLElement</a>|String
-            * @default null
-            */
-            this.setAttributeConfig("srcelement", {
-        
-                value: oAttributes.srcelement,
-                writeOnce: true
-        
-            });
-        
-        
-            /**
-            * @config menu
-            * @description Object specifying the menu for the button.  
-            * The value can be one of the following:
-            * <ul>
-            * <li>Object specifying a <a href="YAHOO.widget.Menu.html">
-            * YAHOO.widget.Menu</a> instance.</li>
-            * <li>Object specifying a <a href="YAHOO.widget.Overlay.html">
-            * YAHOO.widget.Overlay</a> instance.</li>
-            * <li>String specifying the id attribute of the <code>&#60;div&#62;
-            * </code> element used to create the menu.  By default the menu 
-            * will be created as an instance of 
-            * <a href="YAHOO.widget.Overlay.html">YAHOO.widget.Overlay</a>.  
-            * If the <a href="YAHOO.widget.Menu.html#CSS_CLASS_NAME">
-            * default CSS class name for YAHOO.widget.Menu</a> is applied to 
-            * the <code>&#60;div&#62;</code> element, it will be created as an
-            * instance of <a href="YAHOO.widget.Menu.html">YAHOO.widget.Menu
-            * </a>.</li><li>String specifying the id attribute of the 
-            * <code>&#60;select&#62;</code> element used to create the menu.
-            * </li><li>Object specifying the <code>&#60;div&#62;</code> element
-            * used to create the menu.</li>
-            * <li>Object specifying the <code>&#60;select&#62;</code> element
-            * used to create the menu.</li>
-            * <li>Array of object literals, each representing a set of 
-            * <a href="YAHOO.widget.MenuItem.html">YAHOO.widget.MenuItem</a> 
-            * configuration attributes.</li>
-            * <li>Array of strings representing the text labels for each menu 
-            * item in the menu.</li>
-            * </ul>
-            * @type <a href="YAHOO.widget.Menu.html">YAHOO.widget.Menu</a>|<a 
-            * href="YAHOO.widget.Overlay.html">YAHOO.widget.Overlay</a>|<a 
-            * href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-
-            * one-html.html#ID-58190037">HTMLElement</a>|String|Array
-            * @default null
-            */
-            this.setAttributeConfig("menu", {
-        
-                value: null,
-                method: this._setMenu,
-                writeOnce: true
-            
-            });
-        
-        
-            /**
-            * @config lazyloadmenu
-            * @description Boolean indicating the value to set for the 
-            * <a href="YAHOO.widget.Menu.html#lazyLoad">"lazyload"</a>
-            * configuration property of the button's menu.  Setting 
-            * "lazyloadmenu" to <code>true </code> will defer rendering of 
-            * the button's menu until the first time it is made visible.  
-            * If "lazyloadmenu" is set to <code>false</code>, the button's 
-            * menu will be rendered immediately if the button is in the 
-            * document, or in response to the button's "appendTo" event if 
-            * the button is not yet in the document.  In either case, the 
-            * menu is rendered into the button's parent HTML element.  
-            * <em>This attribute does not apply if a 
-            * <a href="YAHOO.widget.Menu.html">YAHOO.widget.Menu</a> or 
-            * <a href="YAHOO.widget.Overlay.html">YAHOO.widget.Overlay</a> 
-            * instance is passed as the value of the button's "menu" 
-            * configuration attribute. <a href="YAHOO.widget.Menu.html">
-            * YAHOO.widget.Menu</a> or <a href="YAHOO.widget.Overlay.html">
-            * YAHOO.widget.Overlay</a> instances should be rendered before 
-            * being set as the value for the "menu" configuration 
-            * attribute.</em>
-            * @default true
-            * @type Boolean
-            */
-            this.setAttributeConfig("lazyloadmenu", {
-        
-                value: (oAttributes.lazyloadmenu === false ? false : true),
-                validator: Lang.isBoolean,
-                writeOnce: true
-        
-            });
-
-
-            /**
-            * @config menuclassname
-            * @description String representing the CSS class name to be 
-            * applied to the root element of the button's menu.
-            * @type String
-            * @default "yui-button-menu"
-            */
-            this.setAttributeConfig("menuclassname", {
-        
-                value: (oAttributes.menuclassname || "yui-button-menu"),
-                validator: Lang.isString,
-                method: this._setMenuClassName,
-                writeOnce: true
-        
-            });        
-
-
-            /**
-            * @config selectedMenuItem
-            * @description Number representing the index of the item in the 
-            * button's menu that is currently selected.
-            * @type Number
-            * @default null
-            */
-            this.setAttributeConfig("selectedMenuItem", {
-        
-                value: 0,
-                validator: Lang.isNumber,
-                method: this._setSelectedMenuItem
-        
-            });
-        
-        
-            /**
-            * @config onclick
-            * @description Object literal representing the code to be executed  
-            * when the button is clicked.  Format:<br> <code> {<br> 
-            * <strong>fn:</strong> Function,   &#47;&#47; The handler to call 
-            * when the event fires.<br> <strong>obj:</strong> Object, 
-            * &#47;&#47; An object to pass back to the handler.<br> 
-            * <strong>scope:</strong> Object &#47;&#47;  The object to use 
-            * for the scope of the handler.<br> } </code>
-            * @type Object
-            * @default null
-            */
-            this.setAttributeConfig("onclick", {
-        
-                value: oAttributes.onclick,
-                method: this._setOnClick
-            
-            });
-
-
-            /**
-            * @config focusmenu
-            * @description Boolean indicating whether or not the button's menu 
-            * should be focused when it is made visible.
-            * @type Boolean
-            * @default true
-            */
-            this.setAttributeConfig("focusmenu", {
-        
-                value: (oAttributes.focusmenu === false ? false : true),
-                validator: Lang.isBoolean
-        
-            });
-
-        },
-        
-        
-        /**
-        * @method focus
-        * @description Causes the button to receive the focus and fires the 
-        * button's "focus" event.
-        */
-        focus: function () {
-        
-            if (!this.get("disabled")) {
-        
-                this._button.focus();
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method blur
-        * @description Causes the button to lose focus and fires the button's
-        * "blur" event.
-        */
-        blur: function () {
-        
-            if (!this.get("disabled")) {
-        
-                this._button.blur();
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method hasFocus
-        * @description Returns a boolean indicating whether or not the button 
-        * has focus.
-        * @return {Boolean}
-        */
-        hasFocus: function () {
-        
-            return (m_oFocusedButton == this);
-        
-        },
-        
-        
-        /**
-        * @method isActive
-        * @description Returns a boolean indicating whether or not the button 
-        * is active.
-        * @return {Boolean}
-        */
-        isActive: function () {
-        
-            return this.hasClass(this.CSS_CLASS_NAME + "-active");
-        
-        },
-        
-        
-        /**
-        * @method getMenu
-        * @description Returns a reference to the button's menu.
-        * @return {<a href="YAHOO.widget.Overlay.html">
-        * YAHOO.widget.Overlay</a>|<a 
-        * href="YAHOO.widget.Menu.html">YAHOO.widget.Menu</a>}
-        */
-        getMenu: function () {
-        
-            return this._menu;
-        
-        },
-        
-        
-        /**
-        * @method getForm
-        * @description Returns a reference to the button's parent form.
-        * @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-
-        * 20000929/level-one-html.html#ID-40002357">HTMLFormElement</a>}
-        */
-        getForm: function () {
-        
-            return this._button.form;
-        
-        },
-        
-        
-        /** 
-        * @method getHiddenFields
-        * @description Returns an <code>&#60;input&#62;</code> element or 
-        * array of form elements used to represent the button when its parent 
-        * form is submitted.  
-        * @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-        * level-one-html.html#ID-6043025">HTMLInputElement</a>|Array}
-        */
-        getHiddenFields: function () {
-        
-            return this._hiddenFields;
-        
-        },
-        
-        
-        /**
-        * @method destroy
-        * @description Removes the button's element from its parent element and 
-        * removes all event handlers.
-        */
-        destroy: function () {
-        
-        
-            var oElement = this.get("element"),
-                oParentNode = oElement.parentNode,
-                oMenu = this._menu;
-        
-            if (oMenu) {
-        
-        
-                oMenu.destroy();
-        
-            }
-        
-        
-            Event.purgeElement(oElement);
-            Event.purgeElement(this._button);
-            Event.removeListener(document, "mouseup", this._onDocumentMouseUp);
-            Event.removeListener(document, "keyup", this._onDocumentKeyUp);
-            Event.removeListener(document, "mousedown", 
-                this._onDocumentMouseDown);
-        
-        
-            var oForm = this.getForm();
-            
-            if (oForm) {
-        
-                Event.removeListener(oForm, "reset", this._onFormReset);
-                Event.removeListener(oForm, "submit", this.createHiddenFields);
-        
-            }
-        
-        
-            oParentNode.removeChild(oElement);
-        
-        
-            delete m_oButtons[this.get("id")];
-        
-        
-        },
-        
-        
-        fireEvent: function (p_sType , p_aArgs) {
-        
-            //  Disabled buttons should not respond to DOM events
-        
-            if (this.DOM_EVENTS[p_sType] && this.get("disabled")) {
-        
-                return;
-        
-            }
-        
-            YAHOO.widget.Button.superclass.fireEvent.call(this, p_sType, 
-                p_aArgs);
-        
-        },
-        
-        
-        /**
-        * @method toString
-        * @description Returns a string representing the button.
-        * @return {String}
-        */
-        toString: function () {
-        
-            return ("Button " + this.get("id"));
-        
-        }
-    
-    });
-    
-    
-    /**
-    * @method YAHOO.widget.Button.onFormKeyPress
-    * @description "keypress" event handler for the button's form.
-    * @param {Event} p_oEvent Object representing the DOM event object passed 
-    * back by the event utility (YAHOO.util.Event).
-    */
-    YAHOO.widget.Button.onFormKeyPress = function (p_oEvent) {
-    
-        var oTarget = Event.getTarget(p_oEvent),
-            nCharCode = Event.getCharCode(p_oEvent),
-            sNodeName = oTarget.nodeName && oTarget.nodeName.toUpperCase(),
-            sType = oTarget.type,
-    
-            /*
-                Boolean indicating if the form contains any enabled or 
-                disabled YUI submit buttons
-            */
-    
-            bFormContainsYUIButtons = false,
-    
-            oButton,
-    
-            oYUISubmitButton,   // The form's first, enabled YUI submit button
-    
-            /*
-                 The form's first, enabled HTML submit button that precedes any 
-                 YUI submit button
-            */
-    
-            oPrecedingSubmitButton,
-            
-    
-            /*
-                 The form's first, enabled HTML submit button that follows a 
-                 YUI button
-            */
-            
-            oFollowingSubmitButton; 
-    
-    
-        function isSubmitButton(p_oElement) {
-    
-            var sId,
-                oSrcElement;
-    
-            switch (p_oElement.nodeName.toUpperCase()) {
-    
-            case "INPUT":
-            case "BUTTON":
-            
-                if (p_oElement.type == "submit" && !p_oElement.disabled) {
-                    
-                    if (!bFormContainsYUIButtons && 
-                        !oPrecedingSubmitButton) {
-
-                        oPrecedingSubmitButton = p_oElement;
-
-                    }
-                    
-                    if (oYUISubmitButton && !oFollowingSubmitButton) {
-                    
-                        oFollowingSubmitButton = p_oElement;
-                    
-                    }
-                
-                }
-
-                break;
-            
-
-            default:
-            
-                sId = p_oElement.id;
-    
-                if (sId) {
-    
-                    oButton = m_oButtons[sId];
-        
-                    if (oButton) {
-
-                        bFormContainsYUIButtons = true;
-        
-                        if (!oButton.get("disabled")) {
-
-                            oSrcElement = oButton.get("srcelement");
-    
-                            if (!oYUISubmitButton &&
-                                (oButton.get("type") == "submit" || 
-                                (oSrcElement && oSrcElement.type == "submit"))) 
-                            {
-
-                                oYUISubmitButton = oButton;
-                            
-                            }
-                        
-                        }
-                        
-                    }
-                
-                }
-
-                break;
-    
-            }
-    
-        }
-    
-    
-        if (nCharCode == 13 && ((sNodeName == "INPUT" && (sType == "text" || 
-            sType == "password" || sType == "checkbox" || sType == "radio" || 
-            sType == "file") ) || sNodeName == "SELECT"))
-        {
-    
-            Dom.getElementsBy(isSubmitButton, "*", this);
-    
-    
-            if (oPrecedingSubmitButton) {
-    
-                /*
-                     Need to set focus to the first enabled submit button
-                     to make sure that IE includes its name and value 
-                     in the form's data set.
-                */
-    
-                oPrecedingSubmitButton.focus();
-            
-            }
-            else if (!oPrecedingSubmitButton && oYUISubmitButton) {
-    
-                if (oFollowingSubmitButton) {
-    
-                    /*
-                        Need to call "preventDefault" to ensure that 
-                        the name and value of the regular submit button 
-                        following the YUI button doesn't get added to the 
-                        form's data set when it is submitted.
-                    */
-    
-                    Event.preventDefault(p_oEvent);
-                
-                }
-    
-                oYUISubmitButton.submitForm();
-    
-            }
-            
-        }
-    
-    };
-    
-    
-    /**
-    * @method addHiddenFieldsToForm
-    * @description Searches the specified form and adds hidden fields for  
-    * instances of YAHOO.widget.Button that are of type "radio," "checkbox," 
-    * "menu," and "split."
-    * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-
-    * one-html.html#ID-40002357">HTMLFormElement</a>} p_oForm Object reference 
-    * for the form to search.
-    */
-    YAHOO.widget.Button.addHiddenFieldsToForm = function (p_oForm) {
-    
-        var aButtons = Dom.getElementsByClassName(
-                            YAHOO.widget.Button.prototype.CSS_CLASS_NAME, 
-                            "*", 
-                            p_oForm),
-    
-            nButtons = aButtons.length,
-            oButton,
-            sId,
-            i;
-    
-        if (nButtons > 0) {
-    
-    
-            for (i = 0; i < nButtons; i++) {
-    
-                sId = aButtons[i].id;
-    
-                if (sId) {
-    
-                    oButton = m_oButtons[sId];
-        
-                    if (oButton) {
-           
-                        oButton.createHiddenFields();
-                        
-                    }
-                
-                }
-            
-            }
-    
-        }
-    
-    };
-    
-    
-    
-    // Events
-    
-    
-    /**
-    * @event focus
-    * @description Fires when the menu item receives focus.  Passes back a  
-    * single object representing the original DOM event object passed back by 
-    * the event utility (YAHOO.util.Event) when the event was fired.  See 
-    * <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> 
-    * for more information on listening for this event.
-    * @type YAHOO.util.CustomEvent
-    */
-    
-    
-    /**
-    * @event blur
-    * @description Fires when the menu item loses the input focus.  Passes back  
-    * a single object representing the original DOM event object passed back by 
-    * the event utility (YAHOO.util.Event) when the event was fired.  See 
-    * <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for  
-    * more information on listening for this event.
-    * @type YAHOO.util.CustomEvent
-    */
-    
-    
-    /**
-    * @event option
-    * @description Fires when the user invokes the button's option.  Passes 
-    * back a single object representing the original DOM event (either 
-    * "mousedown" or "keydown") that caused the "option" event to fire.  See 
-    * <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> 
-    * for more information on listening for this event.
-    * @type YAHOO.util.CustomEvent
-    */
-
-})();
-(function () {
-
-    // Shorthard for utilities
-    
-    var Dom = YAHOO.util.Dom,
-        Event = YAHOO.util.Event,
-        Lang = YAHOO.lang,
-        Button = YAHOO.widget.Button,  
-    
-        // Private collection of radio buttons
-    
-        m_oButtons = {};
-
-
-
-    /**
-    * The ButtonGroup class creates a set of buttons that are mutually 
-    * exclusive; checking one button in the set will uncheck all others in the 
-    * button group.
-    * @param {String} p_oElement String specifying the id attribute of the 
-    * <code>&#60;div&#62;</code> element of the button group.
-    * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-    * level-one-html.html#ID-22445964">HTMLDivElement</a>} p_oElement Object 
-    * specifying the <code>&#60;div&#62;</code> element of the button group.
-    * @param {Object} p_oElement Object literal specifying a set of 
-    * configuration attributes used to create the button group.
-    * @param {Object} p_oAttributes Optional. Object literal specifying a set 
-    * of configuration attributes used to create the button group.
-    * @namespace YAHOO.widget
-    * @class ButtonGroup
-    * @constructor
-    * @extends YAHOO.util.Element
-    */
-    YAHOO.widget.ButtonGroup = function (p_oElement, p_oAttributes) {
-    
-        var fnSuperClass = YAHOO.widget.ButtonGroup.superclass.constructor,
-            sNodeName,
-            oElement,
-            sId;
-    
-        if (arguments.length == 1 && !Lang.isString(p_oElement) && 
-            !p_oElement.nodeName) {
-    
-            if (!p_oElement.id) {
-    
-                sId = Dom.generateId();
-    
-                p_oElement.id = sId;
-    
-    
-            }
-    
-    
-    
-            fnSuperClass.call(this, (this._createGroupElement()), p_oElement);
-    
-        }
-        else if (Lang.isString(p_oElement)) {
-    
-            oElement = Dom.get(p_oElement);
-    
-            if (oElement) {
-            
-                if (oElement.nodeName.toUpperCase() == this.NODE_NAME) {
-    
-            
-                    fnSuperClass.call(this, oElement, p_oAttributes);
-    
-                }
-    
-            }
-        
-        }
-        else {
-    
-            sNodeName = p_oElement.nodeName;
-    
-            if (sNodeName && sNodeName == this.NODE_NAME) {
-        
-                if (!p_oElement.id) {
-        
-                    p_oElement.id = Dom.generateId();
-        
-        
-                }
-        
-        
-                fnSuperClass.call(this, p_oElement, p_oAttributes);
-    
-            }
-    
-        }
-    
-    };
-    
-    
-    YAHOO.extend(YAHOO.widget.ButtonGroup, YAHOO.util.Element, {
-    
-    
-        // Protected properties
-        
-        
-        /** 
-        * @property _buttons
-        * @description Array of buttons in the button group.
-        * @default null
-        * @protected
-        * @type Array
-        */
-        _buttons: null,
-        
-        
-        
-        // Constants
-        
-        
-        /**
-        * @property NODE_NAME
-        * @description The name of the tag to be used for the button 
-        * group's element. 
-        * @default "DIV"
-        * @final
-        * @type String
-        */
-        NODE_NAME: "DIV",
-        
-        
-        /**
-        * @property CSS_CLASS_NAME
-        * @description String representing the CSS class(es) to be applied  
-        * to the button group's element.
-        * @default "yui-buttongroup"
-        * @final
-        * @type String
-        */
-        CSS_CLASS_NAME: "yui-buttongroup",
-    
-    
-    
-        // Protected methods
-        
-        
-        /**
-        * @method _createGroupElement
-        * @description Creates the button group's element.
-        * @protected
-        * @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-        * level-one-html.html#ID-22445964">HTMLDivElement</a>}
-        */
-        _createGroupElement: function () {
-        
-            var oElement = document.createElement(this.NODE_NAME);
-        
-            return oElement;
-        
-        },
-        
-        
-        
-        // Protected attribute setter methods
-        
-        
-        /**
-        * @method _setDisabled
-        * @description Sets the value of the button groups's 
-        * "disabled" attribute.
-        * @protected
-        * @param {Boolean} p_bDisabled Boolean indicating the value for
-        * the button group's "disabled" attribute.
-        */
-        _setDisabled: function (p_bDisabled) {
-        
-            var nButtons = this.getCount(),
-                i;
-        
-            if (nButtons > 0) {
-        
-                i = nButtons - 1;
-                
-                do {
-        
-                    this._buttons[i].set("disabled", p_bDisabled);
-                
-                }
-                while (i--);
-        
-            }
-        
-        },
-        
-        
-        
-        // Protected event handlers
-        
-        
-        /**
-        * @method _onKeyDown
-        * @description "keydown" event handler for the button group.
-        * @protected
-        * @param {Event} p_oEvent Object representing the DOM event object  
-        * passed back by the event utility (YAHOO.util.Event).
-        */
-        _onKeyDown: function (p_oEvent) {
-        
-            var oTarget = Event.getTarget(p_oEvent),
-                nCharCode = Event.getCharCode(p_oEvent),
-                sId = oTarget.parentNode.parentNode.id,
-                oButton = m_oButtons[sId],
-                nIndex = -1;
-        
-        
-            if (nCharCode == 37 || nCharCode == 38) {
-        
-                nIndex = (oButton.index === 0) ? 
-                            (this._buttons.length - 1) : (oButton.index - 1);
-            
-            }
-            else if (nCharCode == 39 || nCharCode == 40) {
-        
-                nIndex = (oButton.index === (this._buttons.length - 1)) ? 
-                            0 : (oButton.index + 1);
-        
-            }
-        
-        
-            if (nIndex > -1) {
-        
-                this.check(nIndex);
-                this.getButton(nIndex).focus();
-            
-            }        
-        
-        },
-        
-        
-        /**
-        * @method _onAppendTo
-        * @description "appendTo" event handler for the button group.
-        * @protected
-        * @param {Event} p_oEvent Object representing the event that was fired.
-        */
-        _onAppendTo: function (p_oEvent) {
-        
-            var aButtons = this._buttons,
-                nButtons = aButtons.length,
-                i;
-        
-            for (i = 0; i < nButtons; i++) {
-        
-                aButtons[i].appendTo(this.get("element"));
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method _onButtonCheckedChange
-        * @description "checkedChange" event handler for each button in the 
-        * button group.
-        * @protected
-        * @param {Event} p_oEvent Object representing the event that was fired.
-        * @param {<a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a>}  
-        * p_oButton Object representing the button that fired the event.
-        */
-        _onButtonCheckedChange: function (p_oEvent, p_oButton) {
-        
-            var bChecked = p_oEvent.newValue,
-                oCheckedButton = this.get("checkedButton");
-        
-            if (bChecked && oCheckedButton != p_oButton) {
-        
-                if (oCheckedButton) {
-        
-                    oCheckedButton.set("checked", false, true);
-        
-                }
-        
-                this.set("checkedButton", p_oButton);
-                this.set("value", p_oButton.get("value"));
-        
-            }
-            else if (oCheckedButton && !oCheckedButton.set("checked")) {
-        
-                oCheckedButton.set("checked", true, true);
-        
-            }
-           
-        },
-        
-        
-        
-        // Public methods
-        
-        
-        /**
-        * @method init
-        * @description The ButtonGroup class's initialization method.
-        * @param {String} p_oElement String specifying the id attribute of the 
-        * <code>&#60;div&#62;</code> element of the button group.
-        * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-        * level-one-html.html#ID-22445964">HTMLDivElement</a>} p_oElement Object 
-        * specifying the <code>&#60;div&#62;</code> element of the button group.
-        * @param {Object} p_oElement Object literal specifying a set of  
-        * configuration attributes used to create the button group.
-        * @param {Object} p_oAttributes Optional. Object literal specifying a
-        * set of configuration attributes used to create the button group.
-        */
-        init: function (p_oElement, p_oAttributes) {
-        
-            this._buttons = [];
-        
-            YAHOO.widget.ButtonGroup.superclass.init.call(this, p_oElement, 
-                    p_oAttributes);
-        
-            this.addClass(this.CSS_CLASS_NAME);
-        
-        
-            var aButtons = this.getElementsByClassName("yui-radio-button");
-        
-        
-            if (aButtons.length > 0) {
-        
-        
-                this.addButtons(aButtons);
-        
-            }
-        
-        
-        
-            function isRadioButton(p_oElement) {
-        
-                return (p_oElement.type == "radio");
-        
-            }
-        
-            aButtons = 
-                Dom.getElementsBy(isRadioButton, "input", this.get("element"));
-        
-        
-            if (aButtons.length > 0) {
-        
-        
-                this.addButtons(aButtons);
-        
-            }
-        
-            this.on("keydown", this._onKeyDown);
-            this.on("appendTo", this._onAppendTo);
-        
-
-            var oContainer = this.get("container");
-
-            if (oContainer) {
-        
-                if (Lang.isString(oContainer)) {
-        
-                    Event.onContentReady(oContainer, function () {
-        
-                        this.appendTo(oContainer);            
-                    
-                    }, null, this);
-        
-                }
-                else {
-        
-                    this.appendTo(oContainer);
-        
-                }
-        
-            }
-        
-        
-        
-        },
-        
-        
-        /**
-        * @method initAttributes
-        * @description Initializes all of the configuration attributes used to  
-        * create the button group.
-        * @param {Object} p_oAttributes Object literal specifying a set of 
-        * configuration attributes used to create the button group.
-        */
-        initAttributes: function (p_oAttributes) {
-        
-            var oAttributes = p_oAttributes || {};
-        
-            YAHOO.widget.ButtonGroup.superclass.initAttributes.call(
-                this, oAttributes);
-        
-        
-            /**
-            * @config name
-            * @description String specifying the name for the button group.  
-            * This name will be applied to each button in the button group.
-            * @default null
-            * @type String
-            */
-            this.setAttributeConfig("name", {
-        
-                value: oAttributes.name,
-                validator: Lang.isString
-        
-            });
-        
-        
-            /**
-            * @config disabled
-            * @description Boolean indicating if the button group should be 
-            * disabled.  Disabling the button group will disable each button 
-            * in the button group.  Disabled buttons are dimmed and will not 
-            * respond to user input or fire events.
-            * @default false
-            * @type Boolean
-            */
-            this.setAttributeConfig("disabled", {
-        
-                value: (oAttributes.disabled || false),
-                validator: Lang.isBoolean,
-                method: this._setDisabled
-        
-            });
-        
-        
-            /**
-            * @config value
-            * @description Object specifying the value for the button group.
-            * @default null
-            * @type Object
-            */
-            this.setAttributeConfig("value", {
-        
-                value: oAttributes.value
-        
-            });
-        
-        
-            /**
-            * @config container
-            * @description HTML element reference or string specifying the id 
-            * attribute of the HTML element that the button group's markup
-            * should be rendered into.
-            * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-            * level-one-html.html#ID-58190037">HTMLElement</a>|String
-            * @default null
-            */
-            this.setAttributeConfig("container", {
-        
-                value: oAttributes.container,
-                writeOnce: true
-        
-            });
-        
-        
-            /**
-            * @config checkedButton
-            * @description Reference for the button in the button group that 
-            * is checked.
-            * @type {<a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a>}
-            * @default null
-            */
-            this.setAttributeConfig("checkedButton", {
-        
-                value: null
-        
-            });
-        
-        },
-        
-        
-        /**
-        * @method addButton
-        * @description Adds the button to the button group.
-        * @param {<a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a>}  
-        * p_oButton Object reference for the <a href="YAHOO.widget.Button.html">
-        * YAHOO.widget.Button</a> instance to be added to the button group.
-        * @param {String} p_oButton String specifying the id attribute of the 
-        * <code>&#60;input&#62;</code> or <code>&#60;span&#62;</code> element 
-        * to be used to create the button to be added to the button group.
-        * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/
-        * level-one-html.html#ID-6043025">HTMLInputElement</a>|<a href="
-        * http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#
-        * ID-33759296">HTMLElement</a>} p_oButton Object reference for the 
-        * <code>&#60;input&#62;</code> or <code>&#60;span&#62;</code> element 
-        * to be used to create the button to be added to the button group.
-        * @param {Object} p_oButton Object literal specifying a set of 
-        * <a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a> 
-        * configuration attributes used to configure the button to be added to 
-        * the button group.
-        * @return {<a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a>} 
-        */
-        addButton: function (p_oButton) {
-        
-            var oButton,
-                oButtonElement,
-                oGroupElement,
-                nIndex,
-                sButtonName,
-                sGroupName;
-        
-        
-            if (p_oButton instanceof Button && 
-                p_oButton.get("type") == "radio") {
-        
-                oButton = p_oButton;
-        
-            }
-            else if (!Lang.isString(p_oButton) && !p_oButton.nodeName) {
-        
-                p_oButton.type = "radio";
-        
-                oButton = new Button(p_oButton);
-
-            }
-            else {
-        
-                oButton = new Button(p_oButton, { type: "radio" });
-        
-            }
-        
-        
-            if (oButton) {
-        
-                nIndex = this._buttons.length;
-                sButtonName = oButton.get("name");
-                sGroupName = this.get("name");
-        
-                oButton.index = nIndex;
-        
-                this._buttons[nIndex] = oButton;
-                m_oButtons[oButton.get("id")] = oButton;
-        
-        
-                if (sButtonName != sGroupName) {
-        
-                    oButton.set("name", sGroupName);
-                
-                }
-        
-        
-                if (this.get("disabled")) {
-        
-                    oButton.set("disabled", true);
-        
-                }
-        
-        
-                if (oButton.get("checked")) {
-        
-                    this.set("checkedButton", oButton);
-        
-                }
-
-                
-                oButtonElement = oButton.get("element");
-                oGroupElement = this.get("element");
-                
-                if (oButtonElement.parentNode != oGroupElement) {
-                
-                    oGroupElement.appendChild(oButtonElement);
-                
-                }
-        
-                
-                oButton.on("checkedChange", 
-                    this._onButtonCheckedChange, oButton, this);
-        
-        
-                return oButton;
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method addButtons
-        * @description Adds the array of buttons to the button group.
-        * @param {Array} p_aButtons Array of <a href="YAHOO.widget.Button.html">
-        * YAHOO.widget.Button</a> instances to be added 
-        * to the button group.
-        * @param {Array} p_aButtons Array of strings specifying the id 
-        * attribute of the <code>&#60;input&#62;</code> or <code>&#60;span&#62;
-        * </code> elements to be used to create the buttons to be added to the 
-        * button group.
-        * @param {Array} p_aButtons Array of object references for the 
-        * <code>&#60;input&#62;</code> or <code>&#60;span&#62;</code> elements 
-        * to be used to create the buttons to be added to the button group.
-        * @param {Array} p_aButtons Array of object literals, each containing
-        * a set of <a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a>  
-        * configuration attributes used to configure each button to be added 
-        * to the button group.
-        * @return {Array}
-        */
-        addButtons: function (p_aButtons) {
-    
-            var nButtons,
-                oButton,
-                aButtons,
-                i;
-        
-            if (Lang.isArray(p_aButtons)) {
-            
-                nButtons = p_aButtons.length;
-                aButtons = [];
-        
-                if (nButtons > 0) {
-        
-                    for (i = 0; i < nButtons; i++) {
-        
-                        oButton = this.addButton(p_aButtons[i]);
-                        
-                        if (oButton) {
-        
-                            aButtons[aButtons.length] = oButton;
-        
-                        }
-                    
-                    }
-        
-                    if (aButtons.length > 0) {
-        
-        
-                        return aButtons;
-        
-                    }
-                
-                }
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method removeButton
-        * @description Removes the button at the specified index from the 
-        * button group.
-        * @param {Number} p_nIndex Number specifying the index of the button 
-        * to be removed from the button group.
-        */
-        removeButton: function (p_nIndex) {
-        
-            var oButton = this.getButton(p_nIndex),
-                nButtons,
-                i;
-            
-            if (oButton) {
-        
-        
-                this._buttons.splice(p_nIndex, 1);
-                delete m_oButtons[oButton.get("id")];
-        
-                oButton.removeListener("checkedChange", 
-                    this._onButtonCheckedChange);
-
-                oButton.destroy();
-        
-        
-                nButtons = this._buttons.length;
-                
-                if (nButtons > 0) {
-        
-                    i = this._buttons.length - 1;
-                    
-                    do {
-        
-                        this._buttons[i].index = i;
-        
-                    }
-                    while (i--);
-                
-                }
-        
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method getButton
-        * @description Returns the button at the specified index.
-        * @param {Number} p_nIndex The index of the button to retrieve from the 
-        * button group.
-        * @return {<a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a>}
-        */
-        getButton: function (p_nIndex) {
-        
-            if (Lang.isNumber(p_nIndex)) {
-        
-                return this._buttons[p_nIndex];
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method getButtons
-        * @description Returns an array of the buttons in the button group.
-        * @return {Array}
-        */
-        getButtons: function () {
-        
-            return this._buttons;
-        
-        },
-        
-        
-        /**
-        * @method getCount
-        * @description Returns the number of buttons in the button group.
-        * @return {Number}
-        */
-        getCount: function () {
-        
-            return this._buttons.length;
-        
-        },
-        
-        
-        /**
-        * @method focus
-        * @description Sets focus to the button at the specified index.
-        * @param {Number} p_nIndex Number indicating the index of the button 
-        * to focus. 
-        */
-        focus: function (p_nIndex) {
-        
-            var oButton,
-                nButtons,
-                i;
-        
-            if (Lang.isNumber(p_nIndex)) {
-        
-                oButton = this._buttons[p_nIndex];
-                
-                if (oButton) {
-        
-                    oButton.focus();
-        
-                }
-            
-            }
-            else {
-        
-                nButtons = this.getCount();
-        
-                for (i = 0; i < nButtons; i++) {
-        
-                    oButton = this._buttons[i];
-        
-                    if (!oButton.get("disabled")) {
-        
-                        oButton.focus();
-                        break;
-        
-                    }
-        
-                }
-        
-            }
-        
-        },
-        
-        
-        /**
-        * @method check
-        * @description Checks the button at the specified index.
-        * @param {Number} p_nIndex Number indicating the index of the button 
-        * to check. 
-        */
-        check: function (p_nIndex) {
-        
-            var oButton = this.getButton(p_nIndex);
-            
-            if (oButton) {
-        
-                oButton.set("checked", true);
-            
-            }
-        
-        },
-        
-        
-        /**
-        * @method destroy
-        * @description Removes the button group's element from its parent 
-        * element and removes all event handlers.
-        */
-        destroy: function () {
-        
-        
-            var nButtons = this._buttons.length,
-                oElement = this.get("element"),
-                oParentNode = oElement.parentNode,
-                i;
-            
-            if (nButtons > 0) {
-        
-                i = this._buttons.length - 1;
-        
-                do {
-        
-                    this._buttons[i].destroy();
-        
-                }
-                while (i--);
-            
-            }
-        
-        
-            Event.purgeElement(oElement);
-            
-        
-            oParentNode.removeChild(oElement);
-        
-        },
-        
-        
-        /**
-        * @method toString
-        * @description Returns a string representing the button group.
-        * @return {String}
-        */
-        toString: function () {
-        
-            return ("ButtonGroup " + this.get("id"));
-        
-        }
-    
-    });
-
-})();
-YAHOO.register("button", YAHOO.widget.Button, {version: "2.3.0", build: "442"});
diff --git a/lib/yui/colorpicker/colorpicker-beta-debug.js b/lib/yui/colorpicker/colorpicker-beta-debug.js
deleted file mode 100755 (executable)
index 83d861b..0000000
+++ /dev/null
@@ -1,1745 +0,0 @@
-/*
-Copyright (c) 2007, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 2.3.0
-*/
-/**
- * Provides color conversion and validation utils
- * @class YAHOO.util.Color
- * @namespace YAHOO.util
- */
-YAHOO.util.Color = function() {
-
-    var HCHARS="0123456789ABCDEF", lang=YAHOO.lang;
-
-    return {
-
-        /**
-         * Converts 0-1 to 0-255
-         * @method real2dec
-         * @param n {float} the number to convert
-         * @return {int} a number 0-255
-         */
-        real2dec: function(n) {
-            return Math.min(255, Math.round(n*256));
-        },
-
-        /**
-         * Converts HSV (h[0-360], s[0-1]), v[0-1] to RGB [255,255,255]
-         * @method hsv2rgb
-         * @param h {int|[int, float, float]} the hue, or an
-         *        array containing all three parameters
-         * @param s {float} the saturation
-         * @param v {float} the value/brightness
-         * @return {[int, int, int]} the red, green, blue values in
-         *          decimal.
-         */
-        hsv2rgb: function(h, s, v) { 
-
-            if (lang.isArray(h)) {
-                return this.hsv2rgb.call(this, h[0], h[1], h[2]);
-            }
-
-            var r, g, b, i, f, p, q, t;
-            i = Math.floor((h/60)%6);
-            f = (h/60)-i;
-            p = v*(1-s);
-            q = v*(1-f*s);
-            t = v*(1-(1-f)*s);
-            switch(i) {
-                case 0: r=v; g=t; b=p; break;
-                case 1: r=q; g=v; b=p; break;
-                case 2: r=p; g=v; b=t; break;
-                case 3: r=p; g=q; b=v; break;
-                case 4: r=t; g=p; b=v; break;
-                case 5: r=v; g=p; b=q; break;
-            }
-
-            var fn=this.real2dec;
-
-            return [fn(r), fn(g), fn(b)];
-        },
-
-        /**
-         * Converts to RGB [255,255,255] to HSV (h[0-360], s[0-1]), v[0-1]
-         * @method rgb2hsv
-         * @param r {int|[int, int, int]} the red value, or an
-         *        array containing all three parameters
-         * @param g {int} the green value
-         * @param b {int} the blue value
-         * @return {[int, float, float]} the value converted to hsv
-         */
-        rgb2hsv: function(r, g, b) {
-
-            if (lang.isArray(r)) {
-                return this.rgb2hsv.call(this, r[0], r[1], r[2]);
-            }
-
-            r=r/255;
-            g=g/255;
-            b=b/255;
-
-            var min,max,delta,h,s,v;
-            min = Math.min(Math.min(r,g),b);
-            max = Math.max(Math.max(r,g),b);
-            delta = max-min;
-
-            switch (max) {
-                case min: h=0; break;
-                case r:   h=60*(g-b)/delta; 
-                          if (g<b) {
-                              h+=360;
-                          }
-                          break;
-                case g:   h=(60*(b-r)/delta)+120; break;
-                case b:   h=(60*(r-g)/delta)+240; break;
-            }
-            
-            s = (max === 0) ? 0 : 1-(min/max);
-
-            var hsv = [Math.round(h), s, max];
-
-            return hsv;
-
-        },
-
-        /**
-         * Converts decimal rgb values into a hex string
-         * 255,255,255 -> FFFFFF
-         * @method rgb2hex
-         * @param r {int|[int, int, int]} the red value, or an
-         *        array containing all three parameters
-         * @param g {int} the green value
-         * @param b {int} the blue value
-         * @return {string} the hex string
-         */
-        rgb2hex: function(r, g, b) {
-            if (lang.isArray(r)) {
-                return this.rgb2hex.call(this, r[0], r[1], r[2]);
-            }
-
-            var f=this.dec2hex;
-            return f(r) + f(g) + f(b);
-        },
-     
-        /**
-         * Converts an int 0...255 to hex pair 00...FF
-         * @method dec2hex
-         * @param n {int} the number to convert
-         * @return {string} the hex equivalent
-         */
-        dec2hex: function(n) {
-            n = parseInt(n, 10);
-            n = (lang.isNumber(n)) ? n : 0;
-            n = (n > 255 || n < 0) ? 0 : n;
-
-            return HCHARS.charAt((n - n % 16) / 16) + HCHARS.charAt(n % 16);
-        },
-
-        /**
-         * Converts a hex pair 00...FF to an int 0...255 
-         * @method hex2dec
-         * @param str {string} the hex pair to convert
-         * @return {int} the decimal
-         */
-        hex2dec: function(str) {
-            var f = function(c) {
-                return HCHARS.indexOf(c.toUpperCase());
-            };
-
-            var s=str.split('');
-            
-            return ((f(s[0]) * 16) + f(s[1]));
-        },
-
-        /**
-         * Converts a hex string to rgb
-         * @method hex2rgb
-         * @param str {string} the hex string
-         * @return {[int, int, int]} an array containing the rgb values
-         */
-        hex2rgb: function(s) { 
-            var f = this.hex2dec;
-            return [f(s.substr(0, 2)), f(s.substr(2, 2)), f(s.substr(4, 2))];
-        },
-
-        /**
-         * Returns the closest websafe color to the supplied rgb value.
-         * @method websafe
-         * @param r {int|[int, int, int]} the red value, or an
-         *        array containing all three parameters
-         * @param g {int} the green value
-         * @param b {int} the blue value
-         * @return {[int, int, int]} an array containing the closes
-         *                           websafe rgb colors.
-         */
-        websafe: function(r, g, b) {
-
-            if (lang.isArray(r)) {
-                return this.websafe.call(this, r[0], r[1], r[2]);
-            }
-
-            // returns the closest match [0, 51, 102, 153, 204, 255]
-            var f = function(v) {
-                if (lang.isNumber(v)) {
-                    v = Math.min(Math.max(0, v), 255);
-                    var i, next;
-                    for (i=0; i<256; i=i+51) {
-                        next = i+51;
-                        if (v >= i && v <= next) {
-                            return (v-i > 25) ? next : i;
-                        }
-                    }
- YAHOO.log("Error calculating the websafe value for " + v, "warn");
-                }
-
-                return v;
-            };
-
-            return [f(r), f(g), f(b)];
-        }
-    };
-}();
-
-
-(function() {
-
-    var pickercount = 0;
-
-    /**
-     * The colorpicker module provides a widget for selecting colors
-     * @module colorpicker
-     * @requires yahoo, dom, event, element, slider
-     */
-
-    /**
-     * A widget to select colors
-     * @namespace YAHOO.widget
-     * @class YAHOO.widget.ColorPicker
-     * @extends YAHOO.util.Element
-     * @constructor
-     * @param {HTMLElement | String | Object} el(optional) The html 
-     * element that represents the colorpicker, or the attribute object to use. 
-     * An element will be created if none provided.
-     * @param {Object} attr (optional) A key map of the colorpicker's 
-     * initial attributes.  Ignored if first arg is attributes object.
-     */
-    YAHOO.widget.ColorPicker = function(el, attr) {
-        pickercount = pickercount + 1;
-        this.logger = new YAHOO.widget.LogWriter("ColorPicker");
-        attr = attr || {};
-        if (arguments.length === 1 && !YAHOO.lang.isString(el) && !el.nodeName) {
-            attr = el; // treat first arg as attr object
-            el = attr.element || null;
-        }
-        
-        if (!el && !attr.element) { // create if we dont have one
-            this.logger.log("creating host element");
-            el = _createHostElement.call(this, attr);
-        }
-
-       YAHOO.widget.ColorPicker.superclass.constructor.call(this, el, attr); 
-    };
-
-    YAHOO.extend(YAHOO.widget.ColorPicker, YAHOO.util.Element);
-    
-    var proto = YAHOO.widget.ColorPicker.prototype,
-        Slider=YAHOO.widget.Slider,
-        Color=YAHOO.util.Color,
-        Dom = YAHOO.util.Dom,
-        Event = YAHOO.util.Event,
-        lang = YAHOO.lang,
-        sub = lang.substitute;
-    
-
-    var b = "yui-picker";
-
-    /**
-     * The element ids used by this control
-     * @property ID
-     * @final
-     */
-    proto.ID = {
-
-        /**
-         * The id for the "red" form field
-         * @property ID.R
-         * @type String
-         * @final
-         * @default yui-picker-r
-         */
-        R: b + "-r",
-
-        /**
-         * The id for the "red" hex pair output
-         * @property ID.R_HEX
-         * @type String
-         * @final
-         * @default yui-picker-rhex
-         */
-        R_HEX: b + "-rhex",
-
-        /**
-         * The id for the "green" form field
-         * @property ID.G
-         * @type String
-         * @final
-         * @default yui-picker-g
-         */
-        G: b + "-g",
-
-        /**
-         * The id for the "green" hex pair output
-         * @property ID.G_HEX
-         * @type String
-         * @final
-         * @default yui-picker-ghex
-         */
-        G_HEX: b + "-ghex",
-
-
-        /**
-         * The id for the "blue" form field
-         * @property ID.B
-         * @type String
-         * @final
-         * @default yui-picker-b
-         */
-        B: b + "-b",
-
-        /**
-         * The id for the "blue" hex pair output
-         * @property ID.B_HEX
-         * @type String
-         * @final
-         * @default yui-picker-bhex
-         */
-        B_HEX: b + "-bhex",
-
-        /**
-         * The id for the "hue" form field
-         * @property ID.H
-         * @type String
-         * @final
-         * @default yui-picker-h
-         */
-        H: b + "-h",
-
-        /**
-         * The id for the "saturation" form field
-         * @property ID.S
-         * @type String
-         * @final
-         * @default yui-picker-s
-         */
-        S: b + "-s",
-
-        /**
-         * The id for the "value" form field
-         * @property ID.V
-         * @type String
-         * @final
-         * @default yui-picker-v
-         */
-        V: b + "-v",
-
-        /**
-         * The id for the picker region slider
-         * @property ID.PICKER_BG
-         * @type String
-         * @final
-         * @default yui-picker-bg
-         */
-        PICKER_BG:      b + "-bg",
-
-        /**
-         * The id for the picker region thumb
-         * @property ID.PICKER_THUMB
-         * @type String
-         * @final
-         * @default yui-picker-thumb
-         */
-        PICKER_THUMB:   b + "-thumb",
-
-        /**
-         * The id for the hue slider
-         * @property ID.HUE_BG
-         * @type String
-         * @final
-         * @default yui-picker-hue-bg
-         */
-        HUE_BG:         b + "-hue-bg",
-
-        /**
-         * The id for the hue thumb
-         * @property ID.HUE_THUMB
-         * @type String
-         * @final
-         * @default yui-picker-hue-thumb
-         */
-        HUE_THUMB:      b + "-hue-thumb",
-
-        /**
-         * The id for the hex value form field
-         * @property ID.HEX
-         * @type String
-         * @final
-         * @default yui-picker-hex
-         */
-        HEX:            b + "-hex",
-
-        /**
-         * The id for the color swatch
-         * @property ID.SWATCH
-         * @type String
-         * @final
-         * @default yui-picker-swatch
-         */
-        SWATCH:         b + "-swatch",
-
-        /**
-         * The id for the websafe color swatch
-         * @property ID.WEBSAFE_SWATCH
-         * @type String
-         * @final
-         * @default yui-picker-websafe-swatch
-         */
-        WEBSAFE_SWATCH: b + "-websafe-swatch",
-
-        /**
-         * The id for the control details
-         * @property ID.CONTROLS
-         * @final
-         * @default yui-picker-controls
-         */
-        CONTROLS: b + "-controls",
-
-        /**
-         * The id for the rgb controls
-         * @property ID.RGB_CONTROLS
-         * @final
-         * @default yui-picker-rgb-controls
-         */
-        RGB_CONTROLS: b + "-rgb-controls",
-
-        /**
-         * The id for the hsv controls
-         * @property ID.HSV_CONTROLS
-         * @final
-         * @default yui-picker-hsv-controls
-         */
-        HSV_CONTROLS: b + "-hsv-controls",
-        
-        /**
-         * The id for the hsv controls
-         * @property ID.HEX_CONTROLS
-         * @final
-         * @default yui-picker-hex-controls
-         */
-        HEX_CONTROLS: b + "-hex-controls",
-
-        /**
-         * The id for the hex summary
-         * @property ID.HEX_SUMMARY
-         * @final
-         * @default yui-picker-hex-summary
-         */
-        HEX_SUMMARY: b + "-hex-summary",
-
-        /**
-         * The id for the controls section header
-         * @property ID.CONTROLS_LABEL
-         * @final
-         * @default yui-picker-controls-label
-         */
-        CONTROLS_LABEL: b + "-controls-label"
-    };
-
-    /**
-     * Constants for any script-generated messages.  The values here
-     * are the default messages.  They can be updated by providing
-     * the complete list to the constructor for the "txt" attribute.
-     * @property TXT
-     * @final
-     */
-    proto.TXT = {
-        ILLEGAL_HEX: "Illegal hex value entered",
-        SHOW_CONTROLS: "Show color details",
-        HIDE_CONTROLS: "Hide color details",
-        CURRENT_COLOR: "Currently selected color: {rgb}",
-        CLOSEST_WEBSAFE: "Closest websafe color: {rgb}. Click to select.",
-        R: "R",
-        G: "G",
-        B: "B",
-        H: "H",
-        S: "S",
-        V: "V",
-        HEX: "#",
-        DEG: "\u00B0",
-        PERCENT: "%"
-    };
-
-    /**
-     * Constants for the default image locations for img tags that are
-     * generated by the control.  They can be modified by passing the
-     * complete list to the contructor for the "images" attribute
-     * @property IMAGE
-     * @final
-     */
-    proto.IMAGE = {
-        PICKER_THUMB: "../../build/colorpicker/assets/picker_thumb.png",
-        HUE_THUMB: "../../build/colorpicker/assets/hue_thumb.png"
-    };
-
-    /*
-     * Constants for the control's custom event names.  subscribe
-     * to the rgbChange event instead.
-     * @property EVENT
-     * @final
-     */
-    //proto.EVENT = {
-        //CHANGE: "change"
-    //};
-
-    //proto.CSS = { };
-
-    /**
-     * Constants for the control's default default values
-     * @property DEFAULT
-     * @final
-     */
-    proto.DEFAULT = {
-        PICKER_SIZE: 180
-    };
-
-    /**
-     * Constants for the control's configuration attributes
-     * @property OPT
-     * @final
-     */
-    proto.OPT = {
-        HUE: "hue",
-        SATURATION: "saturation",
-        VALUE: "value",
-        RED: "red",
-        GREEN: "green",
-        BLUE: "blue",
-        HSV: "hsv",
-        RGB: "rgb",
-        WEBSAFE: "websafe",
-        HEX: "hex",
-        PICKER_SIZE: "pickersize",
-        SHOW_CONTROLS: "showcontrols",
-        SHOW_RGB_CONTROLS: "showrgbcontrols",
-        SHOW_HSV_CONTROLS: "showhsvcontrols",
-        SHOW_HEX_CONTROLS: "showhexcontrols",
-        SHOW_HEX_SUMMARY: "showhexsummary",
-        SHOW_WEBSAFE: "showwebsafe",
-        //SHOW_SUBMIT: "showsubmit",
-        CONTAINER: "container",
-        IDS: "ids",
-        ELEMENTS: "elements",
-        TXT: "txt",
-        IMAGES: "images",
-        ANIMATE: "animate"
-    };
-
-    /**
-     * Sets the control to the specified rgb value and
-     * moves the sliders to the proper positions
-     * @method setValue
-     * @param rgb {[int, int, int]} the rgb value
-     * @param silent {boolean} whether or not to fire the change event
-     */
-    proto.setValue = function(rgb, silent) {
-        silent = (silent) || false;
-        this.set(this.OPT.RGB, rgb, silent);
-        _updateSliders.call(this);
-    };
-
-    /**
-     * The hue slider
-     * @property hueSlider
-     * @type YAHOO.widget.Slider
-     */
-    proto.hueSlider = null; 
-    
-    /**
-     * The picker region
-     * @property pickerSlider
-     * @type YAHOO.widget.Slider
-     */
-    proto.pickerSlider = null;
-
-    /**
-     * Translates the slider value into hue, int[0,359]
-     * @method _getH
-     * @private
-     * @return {int} the hue from 0 to 359
-     */
-    var _getH = function() {
-        var size = this.get(this.OPT.PICKER_SIZE),
-            h = (size - this.hueSlider.getValue()) / size;
-        h = Math.round(h*360);
-        return (h === 360) ? 0 : h;
-    };
-
-    /**
-     * Translates the slider value into saturation, int[0,1], left to right
-     * @method _getS
-     * @private
-     * @return {int} the saturation from 0 to 1
-     */
-    var _getS = function() {
-        return this.pickerSlider.getXValue() / this.get(this.OPT.PICKER_SIZE);
-    };
-
-    /**
-     * Translates the slider value into value/brightness, int[0,1], top
-     * to bottom
-     * @method _getV
-     * @private
-     * @return {int} the value from 0 to 1
-     */
-    var _getV = function() {
-        var size = this.get(this.OPT.PICKER_SIZE);
-        return (size - this.pickerSlider.getYValue()) / size;
-    };
-
-    /**
-     * Updates the background of the swatch with the current rbg value.
-     * Also updates the websafe swatch to the closest websafe color
-     * @method _updateSwatch
-     * @private
-     */
-    var _updateSwatch = function() {
-        var rgb = this.get(this.OPT.RGB),
-            websafe = this.get(this.OPT.WEBSAFE),
-            el = this.getElement(this.ID.SWATCH),
-            color = rgb.join(","),
-            txt = this.get(this.OPT.TXT);
-
-        Dom.setStyle(el, "background-color", "rgb(" + color  + ")");
-        el.title = lang.substitute(txt.CURRENT_COLOR, {
-                "rgb": "#" + this.get(this.OPT.HEX)
-            });
-
-
-        el = this.getElement(this.ID.WEBSAFE_SWATCH);
-        color = websafe.join(",");
-
-        Dom.setStyle(el, "background-color", "rgb(" + color + ")");
-        el.title = lang.substitute(txt.CLOSEST_WEBSAFE, {
-                "rgb": "#" + Color.rgb2hex(websafe)
-            });
-
-    };
-
-    /**
-     * Reads the sliders and converts the values to RGB, updating the
-     * internal state for all the individual form fields
-     * @method _getValuesFromSliders
-     * @private
-     */
-    var _getValuesFromSliders = function() {
-        var h=_getH.call(this), s=_getS.call(this), v=_getV.call(this);
-        YAHOO.log("hsv " + [h, s, v]);
-
-        rgb = Color.hsv2rgb(h, s, v);
-        var websafe = Color.websafe(rgb);
-        var hex = Color.rgb2hex(rgb[0], rgb[1], rgb[2]);
-
-        this.set(this.OPT.RGB, rgb);
-    };
-
-    /**
-     * Updates the form field controls with the state data contained
-     * in the control.
-     * @method _updateFormFields
-     * @private
-     */
-    var _updateFormFields = function() {
-        this.getElement(this.ID.H).value = this.get(this.OPT.HUE);
-        this.getElement(this.ID.S).value = this.get(this.OPT.SATURATION);
-        this.getElement(this.ID.V).value = this.get(this.OPT.VALUE);
-        this.getElement(this.ID.R).value = this.get(this.OPT.RED);
-        this.getElement(this.ID.R_HEX).innerHTML = Color.dec2hex(this.get(this.OPT.RED));
-        this.getElement(this.ID.G).value = this.get(this.OPT.GREEN);
-        this.getElement(this.ID.G_HEX).innerHTML = Color.dec2hex(this.get(this.OPT.GREEN));
-        this.getElement(this.ID.B).value = this.get(this.OPT.BLUE);
-        this.getElement(this.ID.B_HEX).innerHTML = Color.dec2hex(this.get(this.OPT.BLUE));
-        this.getElement(this.ID.HEX).value = this.get(this.OPT.HEX);
-    };
-
-    /**
-     * Event handler for the hue slider.
-     * @method _onHueSliderChange
-     * @param newOffset {int} pixels from the start position
-     * @private
-     */
-    var _onHueSliderChange = function(newOffset) {
-        this.logger.log("hue update: " + newOffset , "warn");
-
-        var h = _getH.call(this);
-        this.set(this.OPT.HUE, h, true);
-
-        // set picker background to the hue
-        var rgb = Color.hsv2rgb(h, 1, 1);
-        var styleDef = "rgb(" + rgb.join(",") + ")";
-
-        Dom.setStyle(this.getElement(this.ID.PICKER_BG), "background-color", styleDef);
-
-        if (this.hueSlider.valueChangeSource === this.hueSlider.SOURCE_UI_EVENT) {
-            _getValuesFromSliders.call(this);
-        }
-
-        _updateFormFields.call(this);
-        _updateSwatch.call(this);
-    };
-
-    /**
-     * Event handler for the picker slider, which controls the
-     * saturation and value/brightness.
-     * @method _onPickerSliderChange
-     * @param newOffset {{x: int, y: int}} x/y pixels from the start position
-     * @private
-     */
-    var _onPickerSliderChange = function(newOffset) {
-        this.logger.log(sub("picker update [{x}, {y}]", newOffset));
-
-        var s=_getS.call(this), v=_getV.call(this);
-        this.set(this.OPT.SATURATION, Math.round(s*100), true);
-        this.set(this.OPT.VALUE, Math.round(v*100), true);
-
-        if (this.pickerSlider.valueChangeSource === this.pickerSlider.SOURCE_UI_EVENT) {
-            _getValuesFromSliders.call(this);
-        }
-
-        _updateFormFields.call(this);
-        _updateSwatch.call(this);
-    };
-
-
-    /**
-     * Key map to well-known commands for txt field input
-     * @method _getCommand
-     * @param e {Event} the keypress or keydown event
-     * @return {int} a command code
-     * <ul>
-     * <li>0 = not a number, letter in range, or special key</li>
-     * <li>1 = number</li>
-     * <li>2 = a-fA-F</li>
-     * <li>3 = increment (up arrow)</li>
-     * <li>4 = decrement (down arrow)</li>
-     * <li>5 = special key (tab, delete, return, escape, left, right)</li> 
-     * <li>6 = return</li>
-     * </ul>
-     * @private
-     */
-    var _getCommand = function(e) {
-        var c = Event.getCharCode(e);
-
-        //alert(Event.getCharCode(e) + ", " + e.keyCode + ", " + e.charCode);
-
-        // special keys
-        if (c === 38) { // up arrow
-            return 3;
-        } else if (c === 13) { // return
-            return 6;
-        } else if (c === 40) { // down array
-            return 4;
-        } else if (c >= 48 && c<=57) { // 0-9
-            return 1;
-        } else if (c >= 97 && c<=102) { // a-f
-            return 2;
-        } else if (c >= 65 && c<=70) { // A-F
-            return 2;
-        //} else if ("8, 9, 13, 27, 37, 39".indexOf(c) > -1 || 
-        //              (c >= 112 && c <=123)) { // including F-keys
-        // tab, delete, return, escape, left, right
-        } else if ("8, 9, 13, 27, 37, 39".indexOf(c) > -1) { // special chars
-            return 5;
-        } else { // something we probably don't want
-            return 0;
-        }
-    };
-
-    /**
-     * Handle keypress on one of the rgb or hsv fields.
-     * @method _rgbFieldKeypress
-     * @param e {Event} the keypress event
-     * @param el {HTMLElement} the field
-     * @param prop {string} the key to the linked property
-     * @private
-     */
-    var _rgbFieldKeypress = function(e, el, prop) {
-        var command = _getCommand(e);
-        var inc = (e.shiftKey) ? 10 : 1;
-        switch (command) {
-            case 6: // return, update the value
-                _useFieldValue.apply(this, arguments);
-                break;
-                        
-            case 3: // up arrow, increment
-                this.set(prop, Math.min(this.get(prop)+inc, 255));
-                _updateFormFields.call(this);
-                //Event.stopEvent(e);
-                break;
-            case 4: // down arrow, decrement
-                this.set(prop, Math.max(this.get(prop)-inc, 0));
-                _updateFormFields.call(this);
-                //Event.stopEvent(e);
-                break;
-
-            default:
-        }
-
-    };
-
-    /**
-     * Handle keydown on the hex field
-     * @method _hexFieldKeypress
-     * @param e {Event} the keypress event
-     * @param el {HTMLElement} the field
-     * @param prop {string} the key to the linked property
-     * @private
-     */
-    var _hexFieldKeypress = function(e, el, prop) {
-        var command = _getCommand(e);
-        if (command === 6) { // return, update the value
-            _useFieldValue.apply(this, arguments);
-        }
-    };
-
-    /**
-     * Use the value of the text field to update the control
-     * @method _hexFieldKeypress
-     * @param e {Event} an event
-     * @param el {HTMLElement} the field
-     * @param prop {string} the key to the linked property
-     * @private
-     */
-    var _useFieldValue = function(e, el, prop) {
-        var val = el.value;
-
-        if (prop !== this.OPT.HEX) {
-            val = parseInt(val, 10);
-        }
-
-        if (val !== this.get(prop)) {
-            this.set(prop, val);
-        }
-    };
-
-    /** 
-     * Allows numbers and special chars only.  Used for the
-     * rgb and hsv fields keypress handler.
-     * @method _numbersOnly
-     * @param e {Event} the event
-     * @private
-     * @return {boolean} false if we are canceling the event
-     */
-    var _numbersOnly = function(e) {
-        return _hexOnly(e, true);
-    };
-
-    /** 
-     * Allows numbers and special chars, and by default allows a-f.  
-     * Used for the hex field keypress handler.
-     * @method _hexOnly
-     * @param e {Event} the event
-     * @param numbersOnly omits a-f if set to true
-     * @private
-     * @return {boolean} false if we are canceling the event
-     */
-    var _hexOnly = function(e, numbersOnly) {
-        var command = _getCommand(e);
-        switch (command) {
-            case 6: // return
-            case 5: // special char
-            case 1: // number
-                break;
-            case 2: // hex char (a-f)
-                if (numbersOnly !== true) {
-                    break;
-                }
-
-                // fallthrough is intentional
-
-            default: // prevent alpha and punctuation
-                Event.stopEvent(e);
-                return false;
-        }
-    };
-
-    /**
-     * Returns the element reference that is saved.  The id can be either
-     * the element id, or the key for this id in the "id" config attribute.
-     * For instance, the host element id can be obtained by passing its
-     * id (default: "yui_picker") or by its key "YUI_PICKER".
-     * @param id {string} the element id, or key 
-     * @return {HTMLElement} a reference to the element
-     */
-    proto.getElement = function(id) { 
-        return this.get(this.OPT.ELEMENTS)[this.get(this.OPT.IDS)[id]]; 
-    };
-
-    _createElements = function() {
-        this.logger.log("Building markup");
-        var el, child, img, fld, i, 
-            ids = this.get(this.OPT.IDS),
-            txt = this.get(this.OPT.TXT),
-            images = this.get(this.OPT.IMAGES),
-            Elem = function(type, o) {
-                var n = document.createElement(type);
-                if (o) {
-                    lang.augmentObject(n, o, true);
-                }
-                return n;
-            },
-            RGBElem = function(type, obj) {
-                var o = lang.merge({
-                        //type: "txt",
-                        autocomplete: "off",
-                        value: "0",
-                        size: 3,
-                        maxlength: 3
-                    }, obj);
-
-                o.name = o.id;
-                return new Elem(type, o);
-            };
-
-        var p = this.get("element");
-
-        // Picker slider (S and V) ---------------------------------------------
-
-        el = new Elem("div", {
-            id: ids[this.ID.PICKER_BG],
-            className: "yui-picker-bg",
-            tabIndex: -1,
-            hideFocus: true
-        });
-
-        child = new Elem("div", {
-            id: ids[this.ID.PICKER_THUMB],
-            className: "yui-picker-thumb"
-        });
-
-        img = new Elem("img", {
-            src: images.PICKER_THUMB
-        });
-
-        child.appendChild(img);
-        el.appendChild(child);
-        p.appendChild(el);
-        
-        // Hue slider ---------------------------------------------
-        el = new Elem("div", {
-            id: ids[this.ID.HUE_BG],
-            className: "yui-picker-hue-bg",
-            tabIndex: -1,
-            hideFocus: true
-        });
-
-        child = new Elem("div", {
-            id: ids[this.ID.HUE_THUMB],
-            className: "yui-picker-hue-thumb"
-        });
-
-        img = new Elem("img", {
-            src: images.HUE_THUMB
-        });
-
-        child.appendChild(img);
-        el.appendChild(child);
-        p.appendChild(el);
-
-
-        // controls ---------------------------------------------
-
-        el = new Elem("div", {
-            id: ids[this.ID.CONTROLS],
-            className: "yui-picker-controls"
-        });
-
-        p.appendChild(el);
-        p = el;
-
-            // controls header
-            el = new Elem("div", {
-                className: "hd"
-            });
-
-            child = new Elem("a", {
-                id: ids[this.ID.CONTROLS_LABEL],
-                //className: "yui-picker-controls-label",
-                href: "#"
-            });
-            el.appendChild(child);
-            p.appendChild(el);
-
-            // bd
-            el = new Elem("div", {
-                className: "bd"
-            });
-
-            p.appendChild(el);
-            p = el;
-
-                // rgb
-                el = new Elem("ul", {
-                    id: ids[this.ID.RGB_CONTROLS],
-                    className: "yui-picker-rgb-controls"
-                });
-
-                child = new Elem("li");
-                child.appendChild(document.createTextNode(txt.R + " "));
-
-                fld = new RGBElem("input", {
-                    id: ids[this.ID.R],
-                    className: "yui-picker-r"
-                });
-
-                child.appendChild(fld);
-                el.appendChild(child);
-
-                child = new Elem("li");
-                child.appendChild(document.createTextNode(txt.G + " "));
-
-                fld = new RGBElem("input", {
-                    id: ids[this.ID.G],
-                    className: "yui-picker-g"
-                });
-
-                child.appendChild(fld);
-                el.appendChild(child);
-
-                child = new Elem("li");
-                child.appendChild(document.createTextNode(txt.B + " "));
-
-                fld = new RGBElem("input", {
-                    id: ids[this.ID.B],
-                    className: "yui-picker-b"
-                });
-
-                child.appendChild(fld);
-                el.appendChild(child);
-
-                p.appendChild(el);
-
-                // hsv
-                el = new Elem("ul", {
-                    id: ids[this.ID.HSV_CONTROLS],
-                    className: "yui-picker-hsv-controls"
-                });
-
-                child = new Elem("li");
-                child.appendChild(document.createTextNode(txt.H + " "));
-
-                fld = new RGBElem("input", {
-                    id: ids[this.ID.H],
-                    className: "yui-picker-h"
-                });
-
-                child.appendChild(fld);
-                child.appendChild(document.createTextNode(" " + txt.DEG));
-
-                el.appendChild(child);
-
-                child = new Elem("li");
-                child.appendChild(document.createTextNode(txt.S + " "));
-
-                fld = new RGBElem("input", {
-                    id: ids[this.ID.S],
-                    className: "yui-picker-s"
-                });
-
-                child.appendChild(fld);
-                child.appendChild(document.createTextNode(" " + txt.PERCENT));
-
-                el.appendChild(child);
-
-                child = new Elem("li");
-                child.appendChild(document.createTextNode(txt.V + " "));
-
-                fld = new RGBElem("input", {
-                    id: ids[this.ID.V],
-                    className: "yui-picker-v"
-                });
-
-                child.appendChild(fld);
-                child.appendChild(document.createTextNode(" " + txt.PERCENT));
-
-                el.appendChild(child);
-                p.appendChild(el);
-
-
-                // hex summary
-
-                el = new Elem("ul", {
-                    id: ids[this.ID.HEX_SUMMARY],
-                    className: "yui-picker-hex_summary"
-                });
-
-                child = new Elem("li", {
-                    id: ids[this.ID.R_HEX]
-                });
-                el.appendChild(child);
-
-                child = new Elem("li", {
-                    id: ids[this.ID.G_HEX]
-                });
-                el.appendChild(child);
-
-                child = new Elem("li", {
-                    id: ids[this.ID.B_HEX]
-                });
-                el.appendChild(child);
-                p.appendChild(el);
-
-                // hex field
-                el = new Elem("div", {
-                    id: ids[this.ID.HEX_CONTROLS],
-                    className: "yui-picker-hex-controls"
-                });
-                el.appendChild(document.createTextNode(txt.HEX + " "));
-
-                child = new RGBElem("input", {
-                    id: ids[this.ID.HEX],
-                    className: "yui-picker-hex",
-                    size: 6,
-                    maxlength: 6
-                });
-
-                el.appendChild(child);
-                p.appendChild(el);
-
-                p = this.get("element");
-
-                // swatch
-                el = new Elem("div", {
-                    id: ids[this.ID.SWATCH],
-                    className: "yui-picker-swatch"
-                });
-
-                p.appendChild(el);
-
-                // websafe swatch
-                el = new Elem("div", {
-                    id: ids[this.ID.WEBSAFE_SWATCH],
-                    className: "yui-picker-websafe-swatch"
-                });
-
-                p.appendChild(el);
-
-    };
-
-    /**
-     * Sets the initial state of the sliders
-     * @method initPicker
-     */
-    proto.initPicker = function () {
-
-        // bind all of our elements
-        var o=this.OPT, 
-            ids = this.get(o.IDS), 
-            els = this.get(o.ELEMENTS), 
-                  i, el, id;
-
-        // Add the default value as a key for each element for easier lookup
-        for (i in this.ID) {
-            if (lang.hasOwnProperty(this.ID, i)) {
-                ids[this.ID[i]] = ids[i];
-            }
-        }
-
-        // Check for picker element, if not there, create all of them
-        el = Dom.get(ids[this.ID.PICKER_BG]);
-        if (!el) {
-            _createElements.call(this);
-        } else {
-            this.logger.log("Using pre-existing markup");
-        }
-
-        for (i in ids) {
-            if (lang.hasOwnProperty(ids, i)) {
-                // look for element
-                el = Dom.get(ids[i]);
-
-                // generate an id if the implementer passed in an element reference,
-                // and the element did not have an id already
-                id = Dom.generateId(el);
-
-                // update the id in case we generated the id
-                ids[i] = id; // key is WEBSAFE_SWATCH
-                ids[ids[i]] = id; // key is websafe_swatch
-
-                // store the dom ref
-                els[id] = el;
-            }
-        }
-
-        // set the initial visibility state of our controls
-            els = [o.SHOW_CONTROLS, 
-                   o.SHOW_RGB_CONTROLS,
-                   o.SHOW_HSV_CONTROLS,
-                   o.SHOW_HEX_CONTROLS,
-                   o.SHOW_HEX_SUMMARY,
-                   o.SHOW_WEBSAFE
-                   ];
-
-        for (i=0; i<els.length; i=i+1) {
-            this.set(els[i], this.get(els[i]));
-        }
-
-        var s = this.get(o.PICKER_SIZE);
-        this.logger.log("picker size" + s);
-
-        this.hueSlider = Slider.getVertSlider(this.getElement(this.ID.HUE_BG), 
-                                              this.getElement(this.ID.HUE_THUMB), 0, s);
-        this.hueSlider.subscribe("change", _onHueSliderChange, this, true);
-
-        this.pickerSlider = Slider.getSliderRegion(this.getElement(this.ID.PICKER_BG), 
-                                                   this.getElement(this.ID.PICKER_THUMB), 0, s, 0, s);
-        this.pickerSlider.subscribe("change", _onPickerSliderChange, this, true);
-
-        //_onHueSliderChange.call(this, 0);
-
-        Event.on(this.getElement(this.ID.WEBSAFE_SWATCH), "click", function(e) {
-               this.setValue(this.get(o.WEBSAFE));
-               //_updateSliders
-           }, this, true);
-
-        Event.on(this.getElement(this.ID.CONTROLS_LABEL), "click", function(e) {
-               this.set(o.SHOW_CONTROLS, !this.get(o.SHOW_CONTROLS));
-               Event.preventDefault(e);
-           }, this, true);
-
-        _attachRGBHSV.call(this, this.ID.R, this.OPT.RED); 
-        _attachRGBHSV.call(this, this.ID.G, this.OPT.GREEN); 
-        _attachRGBHSV.call(this, this.ID.B, this.OPT.BLUE); 
-        _attachRGBHSV.call(this, this.ID.H, this.OPT.HUE); 
-        _attachRGBHSV.call(this, this.ID.S, this.OPT.SATURATION); 
-        _attachRGBHSV.call(this, this.ID.V, this.OPT.VALUE); 
-
-        Event.on(this.getElement(this.ID.HEX), "keydown", function(e, me) {
-                _hexFieldKeypress.call(me, e, this, me.OPT.HEX);
-            }, this);
-
-        Event.on(this.getElement(this.ID.HEX), "keypress", _hexOnly, this);
-        Event.on(this.getElement(this.ID.HEX), "blur", function(e, me) {
-                _useFieldValue.call(me, e, this, me.OPT.HEX);
-            }, this);
-    };
-
-    _attachRGBHSV = function(id, config) {
-        Event.on(this.getElement(id), "keydown", function(e, me) {
-                _rgbFieldKeypress.call(me, e, this, config);
-            }, this);
-        Event.on(this.getElement(id), "keypress", _numbersOnly, this);
-        Event.on(this.getElement(id), "blur", function(e, me) {
-                _useFieldValue.call(me, e, this, config);
-            }, this);
-    };
-
-
-    /**
-     * Sets up the config attributes and the change listeners for this
-     * properties
-     * @method initAttributes
-     * @param attr An object containing default attribute values
-     */
-    proto.initAttributes = function(attr) {
-
-        attr = attr || {};
-        YAHOO.widget.ColorPicker.superclass.initAttributes.call(this, attr);
-        
-        /**
-         * The size of the picker. Trying to change this is not recommended.
-         * @config pickersize
-         * @default 180
-         * @type int
-         */
-        this.setAttributeConfig(this.OPT.PICKER_SIZE, {
-                value: attr.size || this.DEFAULT.PICKER_SIZE
-            });
-
-        /**
-         * The current hue value 0-360
-         * @config hue
-         * @type int
-         */
-        this.setAttributeConfig(this.OPT.HUE, {
-                value: attr.hue || 0,
-                validator: lang.isNumber
-            });
-
-        /**
-         * The current saturation value 0-100
-         * @config saturation
-         * @type int
-         */
-        this.setAttributeConfig(this.OPT.SATURATION, {
-                value: attr.saturation || 0,
-                validator: lang.isNumber
-            });
-
-        /**
-         * The current value/brightness value 0-100
-         * @config value
-         * @type int
-         */
-        this.setAttributeConfig(this.OPT.VALUE, {
-                value: attr.value || 100,
-                validator: lang.isNumber
-            });
-
-        /**
-         * The current red value 0-255
-         * @config red
-         * @type int
-         */
-        this.setAttributeConfig(this.OPT.RED, {
-                value: attr.red || 255,
-                validator: lang.isNumber
-            });
-
-        /**
-         * The current green value 0-255
-         * @config green 
-         * @type int
-         */
-        this.setAttributeConfig(this.OPT.GREEN, {
-                value: attr.red || 255,
-                validator: lang.isNumber
-            });
-
-        /**
-         * The current blue value 0-255
-         * @config blue
-         * @type int
-         */
-        this.setAttributeConfig(this.OPT.BLUE, {
-                value: attr.blue || 255,
-                validator: lang.isNumber
-            });
-
-        /**
-         * The current hex value #000000-#FFFFFF, without the #
-         * @config hex
-         * @type string
-         */
-        this.setAttributeConfig(this.OPT.HEX, {
-                value: attr.hex || "FFFFFF",
-                validator: lang.isString
-            });
-
-        /**
-         * The current rgb value.  Updates the state of all of the
-         * other value fields.  Read-only: use setValue to set the
-         * controls rgb value.
-         * @config hex
-         * @type [int, int, int]
-         * @readonly
-         */
-        this.setAttributeConfig(this.OPT.RGB, {
-                value: attr.rgb || [255,255,255],
-                method: function(rgb) {
-
-                    this.set(this.OPT.RED, rgb[0], true);
-                    this.set(this.OPT.GREEN, rgb[1], true);
-                    this.set(this.OPT.BLUE, rgb[2], true);
-
-                    var websafe = Color.websafe(rgb);
-                    this.set(this.OPT.WEBSAFE, websafe, true);
-
-                    var hex = Color.rgb2hex(rgb);
-                    this.set(this.OPT.HEX, hex, true);
-
-                    var hsv = Color.rgb2hsv(rgb);
-
-                    this.logger.log(sub("RGB value set to {rgb} (hsv: {hsv})", {
-                            "hsv": hsv, "rgb": rgb
-                        }));
-
-                    this.set(this.OPT.HUE, hsv[0], true);
-                    this.set(this.OPT.SATURATION, Math.round(hsv[1]*100), true);
-                    this.set(this.OPT.VALUE, Math.round(hsv[2]*100), true);
-                },
-                readonly: true
-            });
-
-        /**
-         * If the color picker will live inside of a container object,
-         * set, provide a reference to it so the control can use the
-         * container's events.
-         * @config container
-         * @type YAHOO.widget.Panel
-         */
-        this.setAttributeConfig(this.OPT.CONTAINER, {
-                    value: null,
-                    method: function(container) {
-                        if (container) {
-                            // Position can get out of sync when the
-                            // control is manipulated while display is
-                            // none.  Resetting the slider constraints
-                            // when it is visible gets the state back in
-                            // order.
-                            container.showEvent.subscribe(function() {
-                                // this.pickerSlider.thumb.resetConstraints();
-                                // this.hueSlider.thumb.resetConstraints();
-                                this.pickerSlider.focus();
-                            }, this, true);
-                        }
-                    }
-                });
-        /**
-         * The closest current websafe value
-         * @config websafe
-         * @type int
-         */
-        this.setAttributeConfig(this.OPT.WEBSAFE, {
-                value: attr.websafe || [255,255,255]
-            });
-
-
-        ids = attr.ids || lang.merge({}, this.ID);
-
-        if (!attr.ids && pickercount > 1) {
-            for (var i in ids) {
-                if (lang.hasOwnProperty(ids, i)) {
-                    ids[i] = ids[i] + pickercount;
-                }
-            }
-        }
-
-
-        /**
-         * A list of element ids and/or element references used by the 
-         * control.  The default is the this.ID list, and can be customized
-         * by passing a list in the contructor
-         * @config ids
-         * @type {referenceid: realid}
-         * @writeonce
-         */
-        this.setAttributeConfig(this.OPT.IDS, {
-                value: ids,
-                writeonce: true
-            });
-
-        /**
-         * A list of txt strings for internationalization.  Default
-         * is this.TXT
-         * @config txt
-         * @type {key: txt}
-         * @writeonce
-         */
-        this.setAttributeConfig(this.OPT.TXT, {
-                value: attr.txt || this.TXT,
-                writeonce: true
-            });
-
-        /**
-         * The img src default list
-         * is this.IMAGES
-         * @config images
-         * @type {key: image}
-         * @writeonce
-         */
-        this.setAttributeConfig(this.OPT.IMAGES, {
-                value: attr.images || this.IMAGE,
-                writeonce: true
-            });
-        /**
-         * The element refs used by this control.  Set at initialization
-         * @config elements
-         * @type {id: HTMLElement}
-         * @readonly
-         */
-        this.setAttributeConfig(this.OPT.ELEMENTS, {
-                value: {},
-                readonly: true
-            });
-
-        /**
-         * Returns the cached element reference.  If the id is not a string, it
-         * is assumed that it is an element and this is returned.
-         * @param id {string|HTMLElement} the element key, id, or ref
-         * @param on {boolean} hide or show.  If true, show
-         * @private */
-        _hideShowEl = function(id, on) {
-            var el = (lang.isString(id) ? this.getElement(id) : id);
-            //Dom.setStyle(id, "visibility", (on) ? "" : "hidden");
-            Dom.setStyle(el, "display", (on) ? "" : "none");
-        };
-
-        /**
-         * Hide/show the entire set of controls
-         * @config showcontrols
-         * @type boolean
-         * @default true
-         */
-        this.setAttributeConfig(this.OPT.SHOW_CONTROLS, {
-                value: (attr.showcontrols) || true,
-                method: function(on) {
-
-                    var el = Dom.getElementsByClassName("bd", "div", 
-                            this.getElement(this.ID.CONTROLS))[0];
-
-                    _hideShowEl.call(this, el, on);
-
-                    this.getElement(this.ID.CONTROLS_LABEL).innerHTML = 
-                        (on) ? this.get(this.OPT.TXT).HIDE_CONTROLS :
-                               this.get(this.OPT.TXT).SHOW_CONTROLS;
-
-                }
-            });
-
-        /**
-         * Hide/show the rgb controls
-         * @config showrgbcontrols
-         * @type boolean
-         * @default true
-         */
-        this.setAttributeConfig(this.OPT.SHOW_RGB_CONTROLS, {
-                value: (attr.showrgbcontrols) || true,
-                method: function(on) {
-                    //Dom.setStyle(this.getElement(this.ID.RBG_CONTROLS), "visibility", (on) ? "" : "hidden");
-                    _hideShowEl.call(this, this.ID.RGB_CONTROLS, on);
-                }
-            });
-
-        /**
-         * Hide/show the hsv controls
-         * @config showhsvcontrols
-         * @type boolean
-         * @default false
-         */
-        this.setAttributeConfig(this.OPT.SHOW_HSV_CONTROLS, {
-                value: (attr.showhsvcontrols) || false,
-                method: function(on) {
-                    //Dom.setStyle(this.getElement(this.ID.HSV_CONTROLS), "visibility", (on) ? "" : "hidden");
-                    _hideShowEl.call(this, this.ID.HSV_CONTROLS, on);
-
-                    // can't show both the hsv controls and the rbg hex summary
-                    if (on && this.get(this.OPT.SHOW_HEX_SUMMARY)) {
-                        this.set(this.OPT.SHOW_HEX_SUMMARY, false);
-                    }
-                }
-            });
-
-        /**
-         * Hide/show the hex controls
-         * @config showhexcontrols
-         * @type boolean
-         * @default true
-         */
-        this.setAttributeConfig(this.OPT.SHOW_HEX_CONTROLS, {
-                value: (attr.showhexcontrols) || false,
-                method: function(on) {
-                    _hideShowEl.call(this, this.ID.HEX_CONTROLS, on);
-                }
-            });
-
-        /**
-         * Hide/show the websafe swatch
-         * @config showwebsafe
-         * @type boolean
-         * @default true
-         */
-        this.setAttributeConfig(this.OPT.SHOW_WEBSAFE, {
-                value: (attr.showwebsafe) || true,
-                method: function(on) {
-                    _hideShowEl.call(this, this.ID.WEBSAFE_SWATCH, on);
-                }
-            });
-
-        /**
-         * Hide/show the hex summary
-         * @config showhexsummary
-         * @type boolean
-         * @default true
-         */
-        this.setAttributeConfig(this.OPT.SHOW_HEX_SUMMARY, {
-                value: (attr.showhexsummary) || true,
-                method: function(on) {
-                    _hideShowEl.call(this, this.ID.HEX_SUMMARY, on);
-
-                    // can't show both the hsv controls and the rbg hex summary
-                    if (on && this.get(this.OPT.SHOW_HSV_CONTROLS)) {
-                        this.set(this.OPT.SHOW_HSV_CONTROLS, false);
-                    }
-                }
-            });
-        this.setAttributeConfig(this.OPT.ANIMATE, {
-                value: (attr.animate) || true,
-                method: function(on) {
-                    this.pickerSlider.animate = on;
-                    this.hueSlider.animate = on;
-                }
-            });
-
-        this.on(this.OPT.HUE + "Change", _updateRGBFromHSV, this, true);
-        this.on(this.OPT.SATURATION + "Change", _updateRGBFromHSV, this, true);
-        this.on(this.OPT.VALUE + "Change", _updatePickerSlider, this, true);
-
-        this.on(this.OPT.RED + "Change", _updateRGB, this, true);
-        this.on(this.OPT.GREEN + "Change", _updateRGB, this, true);
-        this.on(this.OPT.BLUE + "Change", _updateRGB, this, true);
-
-        this.on(this.OPT.HEX + "Change", _updateHex, this, true);
-
-        this.initPicker();
-    };
-
-    /**
-     * Updates the rgb attribute with the current state of the r,g,b
-     * fields.  This is invoked from change listeners on these
-     * attributes to facilitate updating these values from the
-     * individual form fields
-     * @method _updateRGB
-     * @private
-     */
-    var _updateRGB = function() {
-        var rgb = [this.get(this.OPT.RED), 
-                   this.get(this.OPT.GREEN),
-                   this.get(this.OPT.BLUE)];
-
-        this.logger.log("RGB value set to " + rgb);
-        this.set(this.OPT.RGB, rgb);
-
-        _updateSliders.call(this);
-    };
-
-    /**
-     * Updates the RGB values from the current state of the HSV
-     * values.  Executed when the one of the HSV form fields are
-     * updated
-     * _updateRGBFromHSV
-     * @private
-     */
-    var _updateRGBFromHSV = function() {
-        var hsv = [this.get(this.OPT.HUE), 
-                   this.get(this.OPT.SATURATION)/100,
-                   this.get(this.OPT.VALUE)/100];
-
-        var rgb = Color.hsv2rgb(hsv);
-
-        this.logger.log("HSV converted to RGB " + hsv + " : " + rgb);
-        this.set(this.OPT.RGB, rgb);
-
-        _updateSliders.call(this);
-    };
-
-    /**
-     * Parses the hex string to normalize shorthand values, converts
-     * the hex value to rgb and updates the rgb attribute (which
-     * updates the state for all of the other values)
-     * method _updateHex
-     * @private
-     */
-    var _updateHex = function() {
-       
-        var hex = this.get(this.OPT.HEX), l=hex.length;
-
-        // support #369 -> #336699 shorthand
-        if (l === 3) {
-            var c = hex.split(""), i;
-            for (i=0; i<l; i=i+1) {
-                c[i] = c[i] + c[i];
-            }
-
-            hex = c.join("");
-        }
-
-        if (hex.length !== 6) {
-            this.logger.log(this.get(this.TXT.ILLEGAL_HEX), "error");
-            return false;
-        }
-
-        var rgb = Color.hex2rgb(hex);
-
-        this.logger.log(sub("Hex value set to {hex} ({rgb})", {
-                hex: hex, rgb: rgb
-            }));
-
-        this.setValue(rgb);
-
-        //_updateSliders.call(this);
-
-    };
-
-    /**
-     * Moves the sliders into the position dictated by the current state
-     * of the control
-     * @method _updateSliders
-     * @private
-     */
-    var _updateSliders = function() {
-        _updateHueSlider.call(this);
-        _updatePickerSlider.call(this);
-    };
-
-    /**
-     * Moves the hue slider into the position dictated by the current state
-     * of the control
-     * @method _updateHueSlider
-     * @private
-     */
-    var _updateHueSlider = function() {
-        var size = this.get(this.OPT.PICKER_SIZE),
-            h = this.get(this.OPT.HUE);
-
-        h = size - Math.round(h / 360 * size);
-        
-        // 0 is at the top and bottom of the hue slider.  Always go to
-        // the top so we don't end up sending the thumb to the bottom
-        // when the value didn't actually change (e.g., a conversion
-        // produced 360 instead of 0 and the value was already 0).
-        if (h === size) {
-            h = 0;
-        }
-        this.logger.log("Hue slider is being set to " + h);
-
-        this.hueSlider.setValue(h);
-    };
-
-    /**
-     * Moves the picker slider into the position dictated by the current state
-     * of the control
-     * @method _updatePickerSlider
-     * @private
-     */
-    var _updatePickerSlider = function() {
-        var size = this.get(this.OPT.PICKER_SIZE),
-            s = this.get(this.OPT.SATURATION),
-            v = this.get(this.OPT.VALUE);
-
-        s = Math.round(s * size / 100);
-        v = Math.round(size - (v * size / 100));
-
-        this.logger.log("Setting picker slider to " + [s, v]);
-
-        this.pickerSlider.setRegionValue(s, v);
-    };
-
-    /**
-     * Creates the host element if it doesn't exist
-     * @method _createHostElement
-     * @private
-     */
-    var _createHostElement = function() {
-        var el = document.createElement('div');
-
-        if (this.CSS.BASE) {
-            el.className = this.CSS.BASE;
-        }
-        
-        return el;
-    };
-
-
-})();
-YAHOO.register("colorpicker", YAHOO.widget.ColorPicker, {version: "2.3.0", build: "442"});
diff --git a/lib/yui/colorpicker/colorpicker-beta-min.js b/lib/yui/colorpicker/colorpicker-beta-min.js
deleted file mode 100755 (executable)
index e047a19..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-Copyright (c) 2007, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 2.3.0
-*/
-
-YAHOO.util.Color=function(){var HCHARS="0123456789ABCDEF",lang=YAHOO.lang;return{real2dec:function(n){return Math.min(255,Math.round(n*256));},hsv2rgb:function(h,s,v){if(lang.isArray(h)){return this.hsv2rgb.call(this,h[0],h[1],h[2]);}
-var r,g,b,i,f,p,q,t;i=Math.floor((h/60)%6);f=(h/60)-i;p=v*(1-s);q=v*(1-f*s);t=v*(1-(1-f)*s);switch(i){case 0:r=v;g=t;b=p;break;case 1:r=q;g=v;b=p;break;case 2:r=p;g=v;b=t;break;case 3:r=p;g=q;b=v;break;case 4:r=t;g=p;b=v;break;case 5:r=v;g=p;b=q;break;}
-var fn=this.real2dec;return[fn(r),fn(g),fn(b)];},rgb2hsv:function(r,g,b){if(lang.isArray(r)){return this.rgb2hsv.call(this,r[0],r[1],r[2]);}
-r=r/255;g=g/255;b=b/255;var min,max,delta,h,s,v;min=Math.min(Math.min(r,g),b);max=Math.max(Math.max(r,g),b);delta=max-min;switch(max){case min:h=0;break;case r:h=60*(g-b)/delta;if(g<b){h+=360;}
-break;case g:h=(60*(b-r)/delta)+120;break;case b:h=(60*(r-g)/delta)+240;break;}
-s=(max===0)?0:1-(min/max);var hsv=[Math.round(h),s,max];return hsv;},rgb2hex:function(r,g,b){if(lang.isArray(r)){return this.rgb2hex.call(this,r[0],r[1],r[2]);}
-var f=this.dec2hex;return f(r)+f(g)+f(b);},dec2hex:function(n){n=parseInt(n,10);n=(lang.isNumber(n))?n:0;n=(n>255||n<0)?0:n;return HCHARS.charAt((n-n%16)/16)+HCHARS.charAt(n%16);},hex2dec:function(str){var f=function(c){return HCHARS.indexOf(c.toUpperCase());};var s=str.split('');return((f(s[0])*16)+f(s[1]));},hex2rgb:function(s){var f=this.hex2dec;return[f(s.substr(0,2)),f(s.substr(2,2)),f(s.substr(4,2))];},websafe:function(r,g,b){if(lang.isArray(r)){return this.websafe.call(this,r[0],r[1],r[2]);}
-var f=function(v){if(lang.isNumber(v)){v=Math.min(Math.max(0,v),255);var i,next;for(i=0;i<256;i=i+51){next=i+51;if(v>=i&&v<=next){return(v-i>25)?next:i;}}}
-return v;};return[f(r),f(g),f(b)];}};}();(function(){var pickercount=0;YAHOO.widget.ColorPicker=function(el,attr){pickercount=pickercount+1;attr=attr||{};if(arguments.length===1&&!YAHOO.lang.isString(el)&&!el.nodeName){attr=el;el=attr.element||null;}
-if(!el&&!attr.element){el=_createHostElement.call(this,attr);}
-YAHOO.widget.ColorPicker.superclass.constructor.call(this,el,attr);};YAHOO.extend(YAHOO.widget.ColorPicker,YAHOO.util.Element);var proto=YAHOO.widget.ColorPicker.prototype,Slider=YAHOO.widget.Slider,Color=YAHOO.util.Color,Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,lang=YAHOO.lang,sub=lang.substitute;var b="yui-picker";proto.ID={R:b+"-r",R_HEX:b+"-rhex",G:b+"-g",G_HEX:b+"-ghex",B:b+"-b",B_HEX:b+"-bhex",H:b+"-h",S:b+"-s",V:b+"-v",PICKER_BG:b+"-bg",PICKER_THUMB:b+"-thumb",HUE_BG:b+"-hue-bg",HUE_THUMB:b+"-hue-thumb",HEX:b+"-hex",SWATCH:b+"-swatch",WEBSAFE_SWATCH:b+"-websafe-swatch",CONTROLS:b+"-controls",RGB_CONTROLS:b+"-rgb-controls",HSV_CONTROLS:b+"-hsv-controls",HEX_CONTROLS:b+"-hex-controls",HEX_SUMMARY:b+"-hex-summary",CONTROLS_LABEL:b+"-controls-label"};proto.TXT={ILLEGAL_HEX:"Illegal hex value entered",SHOW_CONTROLS:"Show color details",HIDE_CONTROLS:"Hide color details",CURRENT_COLOR:"Currently selected color: {rgb}",CLOSEST_WEBSAFE:"Closest websafe color: {rgb}. Click to select.",R:"R",G:"G",B:"B",H:"H",S:"S",V:"V",HEX:"#",DEG:"\u00B0",PERCENT:"%"};proto.IMAGE={PICKER_THUMB:"../../build/colorpicker/assets/picker_thumb.png",HUE_THUMB:"../../build/colorpicker/assets/hue_thumb.png"};proto.DEFAULT={PICKER_SIZE:180};proto.OPT={HUE:"hue",SATURATION:"saturation",VALUE:"value",RED:"red",GREEN:"green",BLUE:"blue",HSV:"hsv",RGB:"rgb",WEBSAFE:"websafe",HEX:"hex",PICKER_SIZE:"pickersize",SHOW_CONTROLS:"showcontrols",SHOW_RGB_CONTROLS:"showrgbcontrols",SHOW_HSV_CONTROLS:"showhsvcontrols",SHOW_HEX_CONTROLS:"showhexcontrols",SHOW_HEX_SUMMARY:"showhexsummary",SHOW_WEBSAFE:"showwebsafe",CONTAINER:"container",IDS:"ids",ELEMENTS:"elements",TXT:"txt",IMAGES:"images",ANIMATE:"animate"};proto.setValue=function(rgb,silent){silent=(silent)||false;this.set(this.OPT.RGB,rgb,silent);_updateSliders.call(this);};proto.hueSlider=null;proto.pickerSlider=null;var _getH=function(){var size=this.get(this.OPT.PICKER_SIZE),h=(size-this.hueSlider.getValue())/size;h=Math.round(h*360);return(h===360)?0:h;};var _getS=function(){return this.pickerSlider.getXValue()/this.get(this.OPT.PICKER_SIZE);};var _getV=function(){var size=this.get(this.OPT.PICKER_SIZE);return(size-this.pickerSlider.getYValue())/size;};var _updateSwatch=function(){var rgb=this.get(this.OPT.RGB),websafe=this.get(this.OPT.WEBSAFE),el=this.getElement(this.ID.SWATCH),color=rgb.join(","),txt=this.get(this.OPT.TXT);Dom.setStyle(el,"background-color","rgb("+color+")");el.title=lang.substitute(txt.CURRENT_COLOR,{"rgb":"#"+this.get(this.OPT.HEX)});el=this.getElement(this.ID.WEBSAFE_SWATCH);color=websafe.join(",");Dom.setStyle(el,"background-color","rgb("+color+")");el.title=lang.substitute(txt.CLOSEST_WEBSAFE,{"rgb":"#"+Color.rgb2hex(websafe)});};var _getValuesFromSliders=function(){var h=_getH.call(this),s=_getS.call(this),v=_getV.call(this);rgb=Color.hsv2rgb(h,s,v);var websafe=Color.websafe(rgb);var hex=Color.rgb2hex(rgb[0],rgb[1],rgb[2]);this.set(this.OPT.RGB,rgb);};var _updateFormFields=function(){this.getElement(this.ID.H).value=this.get(this.OPT.HUE);this.getElement(this.ID.S).value=this.get(this.OPT.SATURATION);this.getElement(this.ID.V).value=this.get(this.OPT.VALUE);this.getElement(this.ID.R).value=this.get(this.OPT.RED);this.getElement(this.ID.R_HEX).innerHTML=Color.dec2hex(this.get(this.OPT.RED));this.getElement(this.ID.G).value=this.get(this.OPT.GREEN);this.getElement(this.ID.G_HEX).innerHTML=Color.dec2hex(this.get(this.OPT.GREEN));this.getElement(this.ID.B).value=this.get(this.OPT.BLUE);this.getElement(this.ID.B_HEX).innerHTML=Color.dec2hex(this.get(this.OPT.BLUE));this.getElement(this.ID.HEX).value=this.get(this.OPT.HEX);};var _onHueSliderChange=function(newOffset){var h=_getH.call(this);this.set(this.OPT.HUE,h,true);var rgb=Color.hsv2rgb(h,1,1);var styleDef="rgb("+rgb.join(",")+")";Dom.setStyle(this.getElement(this.ID.PICKER_BG),"background-color",styleDef);if(this.hueSlider.valueChangeSource===this.hueSlider.SOURCE_UI_EVENT){_getValuesFromSliders.call(this);}
-_updateFormFields.call(this);_updateSwatch.call(this);};var _onPickerSliderChange=function(newOffset){var s=_getS.call(this),v=_getV.call(this);this.set(this.OPT.SATURATION,Math.round(s*100),true);this.set(this.OPT.VALUE,Math.round(v*100),true);if(this.pickerSlider.valueChangeSource===this.pickerSlider.SOURCE_UI_EVENT){_getValuesFromSliders.call(this);}
-_updateFormFields.call(this);_updateSwatch.call(this);};var _getCommand=function(e){var c=Event.getCharCode(e);if(c===38){return 3;}else if(c===13){return 6;}else if(c===40){return 4;}else if(c>=48&&c<=57){return 1;}else if(c>=97&&c<=102){return 2;}else if(c>=65&&c<=70){return 2;}else if("8, 9, 13, 27, 37, 39".indexOf(c)>-1){return 5;}else{return 0;}};var _rgbFieldKeypress=function(e,el,prop){var command=_getCommand(e);var inc=(e.shiftKey)?10:1;switch(command){case 6:_useFieldValue.apply(this,arguments);break;case 3:this.set(prop,Math.min(this.get(prop)+inc,255));_updateFormFields.call(this);break;case 4:this.set(prop,Math.max(this.get(prop)-inc,0));_updateFormFields.call(this);break;default:}};var _hexFieldKeypress=function(e,el,prop){var command=_getCommand(e);if(command===6){_useFieldValue.apply(this,arguments);}};var _useFieldValue=function(e,el,prop){var val=el.value;if(prop!==this.OPT.HEX){val=parseInt(val,10);}
-if(val!==this.get(prop)){this.set(prop,val);}};var _numbersOnly=function(e){return _hexOnly(e,true);};var _hexOnly=function(e,numbersOnly){var command=_getCommand(e);switch(command){case 6:case 5:case 1:break;case 2:if(numbersOnly!==true){break;}
-default:Event.stopEvent(e);return false;}};proto.getElement=function(id){return this.get(this.OPT.ELEMENTS)[this.get(this.OPT.IDS)[id]];};_createElements=function(){var el,child,img,fld,i,ids=this.get(this.OPT.IDS),txt=this.get(this.OPT.TXT),images=this.get(this.OPT.IMAGES),Elem=function(type,o){var n=document.createElement(type);if(o){lang.augmentObject(n,o,true);}
-return n;},RGBElem=function(type,obj){var o=lang.merge({autocomplete:"off",value:"0",size:3,maxlength:3},obj);o.name=o.id;return new Elem(type,o);};var p=this.get("element");el=new Elem("div",{id:ids[this.ID.PICKER_BG],className:"yui-picker-bg",tabIndex:-1,hideFocus:true});child=new Elem("div",{id:ids[this.ID.PICKER_THUMB],className:"yui-picker-thumb"});img=new Elem("img",{src:images.PICKER_THUMB});child.appendChild(img);el.appendChild(child);p.appendChild(el);el=new Elem("div",{id:ids[this.ID.HUE_BG],className:"yui-picker-hue-bg",tabIndex:-1,hideFocus:true});child=new Elem("div",{id:ids[this.ID.HUE_THUMB],className:"yui-picker-hue-thumb"});img=new Elem("img",{src:images.HUE_THUMB});child.appendChild(img);el.appendChild(child);p.appendChild(el);el=new Elem("div",{id:ids[this.ID.CONTROLS],className:"yui-picker-controls"});p.appendChild(el);p=el;el=new Elem("div",{className:"hd"});child=new Elem("a",{id:ids[this.ID.CONTROLS_LABEL],href:"#"});el.appendChild(child);p.appendChild(el);el=new Elem("div",{className:"bd"});p.appendChild(el);p=el;el=new Elem("ul",{id:ids[this.ID.RGB_CONTROLS],className:"yui-picker-rgb-controls"});child=new Elem("li");child.appendChild(document.createTextNode(txt.R+" "));fld=new RGBElem("input",{id:ids[this.ID.R],className:"yui-picker-r"});child.appendChild(fld);el.appendChild(child);child=new Elem("li");child.appendChild(document.createTextNode(txt.G+" "));fld=new RGBElem("input",{id:ids[this.ID.G],className:"yui-picker-g"});child.appendChild(fld);el.appendChild(child);child=new Elem("li");child.appendChild(document.createTextNode(txt.B+" "));fld=new RGBElem("input",{id:ids[this.ID.B],className:"yui-picker-b"});child.appendChild(fld);el.appendChild(child);p.appendChild(el);el=new Elem("ul",{id:ids[this.ID.HSV_CONTROLS],className:"yui-picker-hsv-controls"});child=new Elem("li");child.appendChild(document.createTextNode(txt.H+" "));fld=new RGBElem("input",{id:ids[this.ID.H],className:"yui-picker-h"});child.appendChild(fld);child.appendChild(document.createTextNode(" "+txt.DEG));el.appendChild(child);child=new Elem("li");child.appendChild(document.createTextNode(txt.S+" "));fld=new RGBElem("input",{id:ids[this.ID.S],className:"yui-picker-s"});child.appendChild(fld);child.appendChild(document.createTextNode(" "+txt.PERCENT));el.appendChild(child);child=new Elem("li");child.appendChild(document.createTextNode(txt.V+" "));fld=new RGBElem("input",{id:ids[this.ID.V],className:"yui-picker-v"});child.appendChild(fld);child.appendChild(document.createTextNode(" "+txt.PERCENT));el.appendChild(child);p.appendChild(el);el=new Elem("ul",{id:ids[this.ID.HEX_SUMMARY],className:"yui-picker-hex_summary"});child=new Elem("li",{id:ids[this.ID.R_HEX]});el.appendChild(child);child=new Elem("li",{id:ids[this.ID.G_HEX]});el.appendChild(child);child=new Elem("li",{id:ids[this.ID.B_HEX]});el.appendChild(child);p.appendChild(el);el=new Elem("div",{id:ids[this.ID.HEX_CONTROLS],className:"yui-picker-hex-controls"});el.appendChild(document.createTextNode(txt.HEX+" "));child=new RGBElem("input",{id:ids[this.ID.HEX],className:"yui-picker-hex",size:6,maxlength:6});el.appendChild(child);p.appendChild(el);p=this.get("element");el=new Elem("div",{id:ids[this.ID.SWATCH],className:"yui-picker-swatch"});p.appendChild(el);el=new Elem("div",{id:ids[this.ID.WEBSAFE_SWATCH],className:"yui-picker-websafe-swatch"});p.appendChild(el);};proto.initPicker=function(){var o=this.OPT,ids=this.get(o.IDS),els=this.get(o.ELEMENTS),i,el,id;for(i in this.ID){if(lang.hasOwnProperty(this.ID,i)){ids[this.ID[i]]=ids[i];}}
-el=Dom.get(ids[this.ID.PICKER_BG]);if(!el){_createElements.call(this);}else{}
-for(i in ids){if(lang.hasOwnProperty(ids,i)){el=Dom.get(ids[i]);id=Dom.generateId(el);ids[i]=id;ids[ids[i]]=id;els[id]=el;}}
-els=[o.SHOW_CONTROLS,o.SHOW_RGB_CONTROLS,o.SHOW_HSV_CONTROLS,o.SHOW_HEX_CONTROLS,o.SHOW_HEX_SUMMARY,o.SHOW_WEBSAFE];for(i=0;i<els.length;i=i+1){this.set(els[i],this.get(els[i]));}
-var s=this.get(o.PICKER_SIZE);this.hueSlider=Slider.getVertSlider(this.getElement(this.ID.HUE_BG),this.getElement(this.ID.HUE_THUMB),0,s);this.hueSlider.subscribe("change",_onHueSliderChange,this,true);this.pickerSlider=Slider.getSliderRegion(this.getElement(this.ID.PICKER_BG),this.getElement(this.ID.PICKER_THUMB),0,s,0,s);this.pickerSlider.subscribe("change",_onPickerSliderChange,this,true);Event.on(this.getElement(this.ID.WEBSAFE_SWATCH),"click",function(e){this.setValue(this.get(o.WEBSAFE));},this,true);Event.on(this.getElement(this.ID.CONTROLS_LABEL),"click",function(e){this.set(o.SHOW_CONTROLS,!this.get(o.SHOW_CONTROLS));Event.preventDefault(e);},this,true);_attachRGBHSV.call(this,this.ID.R,this.OPT.RED);_attachRGBHSV.call(this,this.ID.G,this.OPT.GREEN);_attachRGBHSV.call(this,this.ID.B,this.OPT.BLUE);_attachRGBHSV.call(this,this.ID.H,this.OPT.HUE);_attachRGBHSV.call(this,this.ID.S,this.OPT.SATURATION);_attachRGBHSV.call(this,this.ID.V,this.OPT.VALUE);Event.on(this.getElement(this.ID.HEX),"keydown",function(e,me){_hexFieldKeypress.call(me,e,this,me.OPT.HEX);},this);Event.on(this.getElement(this.ID.HEX),"keypress",_hexOnly,this);Event.on(this.getElement(this.ID.HEX),"blur",function(e,me){_useFieldValue.call(me,e,this,me.OPT.HEX);},this);};_attachRGBHSV=function(id,config){Event.on(this.getElement(id),"keydown",function(e,me){_rgbFieldKeypress.call(me,e,this,config);},this);Event.on(this.getElement(id),"keypress",_numbersOnly,this);Event.on(this.getElement(id),"blur",function(e,me){_useFieldValue.call(me,e,this,config);},this);};proto.initAttributes=function(attr){attr=attr||{};YAHOO.widget.ColorPicker.superclass.initAttributes.call(this,attr);this.setAttributeConfig(this.OPT.PICKER_SIZE,{value:attr.size||this.DEFAULT.PICKER_SIZE});this.setAttributeConfig(this.OPT.HUE,{value:attr.hue||0,validator:lang.isNumber});this.setAttributeConfig(this.OPT.SATURATION,{value:attr.saturation||0,validator:lang.isNumber});this.setAttributeConfig(this.OPT.VALUE,{value:attr.value||100,validator:lang.isNumber});this.setAttributeConfig(this.OPT.RED,{value:attr.red||255,validator:lang.isNumber});this.setAttributeConfig(this.OPT.GREEN,{value:attr.red||255,validator:lang.isNumber});this.setAttributeConfig(this.OPT.BLUE,{value:attr.blue||255,validator:lang.isNumber});this.setAttributeConfig(this.OPT.HEX,{value:attr.hex||"FFFFFF",validator:lang.isString});this.setAttributeConfig(this.OPT.RGB,{value:attr.rgb||[255,255,255],method:function(rgb){this.set(this.OPT.RED,rgb[0],true);this.set(this.OPT.GREEN,rgb[1],true);this.set(this.OPT.BLUE,rgb[2],true);var websafe=Color.websafe(rgb);this.set(this.OPT.WEBSAFE,websafe,true);var hex=Color.rgb2hex(rgb);this.set(this.OPT.HEX,hex,true);var hsv=Color.rgb2hsv(rgb);this.set(this.OPT.HUE,hsv[0],true);this.set(this.OPT.SATURATION,Math.round(hsv[1]*100),true);this.set(this.OPT.VALUE,Math.round(hsv[2]*100),true);},readonly:true});this.setAttributeConfig(this.OPT.CONTAINER,{value:null,method:function(container){if(container){container.showEvent.subscribe(function(){this.pickerSlider.focus();},this,true);}}});this.setAttributeConfig(this.OPT.WEBSAFE,{value:attr.websafe||[255,255,255]});ids=attr.ids||lang.merge({},this.ID);if(!attr.ids&&pickercount>1){for(var i in ids){if(lang.hasOwnProperty(ids,i)){ids[i]=ids[i]+pickercount;}}}
-this.setAttributeConfig(this.OPT.IDS,{value:ids,writeonce:true});this.setAttributeConfig(this.OPT.TXT,{value:attr.txt||this.TXT,writeonce:true});this.setAttributeConfig(this.OPT.IMAGES,{value:attr.images||this.IMAGE,writeonce:true});this.setAttributeConfig(this.OPT.ELEMENTS,{value:{},readonly:true});_hideShowEl=function(id,on){var el=(lang.isString(id)?this.getElement(id):id);Dom.setStyle(el,"display",(on)?"":"none");};this.setAttributeConfig(this.OPT.SHOW_CONTROLS,{value:(attr.showcontrols)||true,method:function(on){var el=Dom.getElementsByClassName("bd","div",this.getElement(this.ID.CONTROLS))[0];_hideShowEl.call(this,el,on);this.getElement(this.ID.CONTROLS_LABEL).innerHTML=(on)?this.get(this.OPT.TXT).HIDE_CONTROLS:this.get(this.OPT.TXT).SHOW_CONTROLS;}});this.setAttributeConfig(this.OPT.SHOW_RGB_CONTROLS,{value:(attr.showrgbcontrols)||true,method:function(on){_hideShowEl.call(this,this.ID.RGB_CONTROLS,on);}});this.setAttributeConfig(this.OPT.SHOW_HSV_CONTROLS,{value:(attr.showhsvcontrols)||false,method:function(on){_hideShowEl.call(this,this.ID.HSV_CONTROLS,on);if(on&&this.get(this.OPT.SHOW_HEX_SUMMARY)){this.set(this.OPT.SHOW_HEX_SUMMARY,false);}}});this.setAttributeConfig(this.OPT.SHOW_HEX_CONTROLS,{value:(attr.showhexcontrols)||false,method:function(on){_hideShowEl.call(this,this.ID.HEX_CONTROLS,on);}});this.setAttributeConfig(this.OPT.SHOW_WEBSAFE,{value:(attr.showwebsafe)||true,method:function(on){_hideShowEl.call(this,this.ID.WEBSAFE_SWATCH,on);}});this.setAttributeConfig(this.OPT.SHOW_HEX_SUMMARY,{value:(attr.showhexsummary)||true,method:function(on){_hideShowEl.call(this,this.ID.HEX_SUMMARY,on);if(on&&this.get(this.OPT.SHOW_HSV_CONTROLS)){this.set(this.OPT.SHOW_HSV_CONTROLS,false);}}});this.setAttributeConfig(this.OPT.ANIMATE,{value:(attr.animate)||true,method:function(on){this.pickerSlider.animate=on;this.hueSlider.animate=on;}});this.on(this.OPT.HUE+"Change",_updateRGBFromHSV,this,true);this.on(this.OPT.SATURATION+"Change",_updateRGBFromHSV,this,true);this.on(this.OPT.VALUE+"Change",_updatePickerSlider,this,true);this.on(this.OPT.RED+"Change",_updateRGB,this,true);this.on(this.OPT.GREEN+"Change",_updateRGB,this,true);this.on(this.OPT.BLUE+"Change",_updateRGB,this,true);this.on(this.OPT.HEX+"Change",_updateHex,this,true);this.initPicker();};var _updateRGB=function(){var rgb=[this.get(this.OPT.RED),this.get(this.OPT.GREEN),this.get(this.OPT.BLUE)];this.set(this.OPT.RGB,rgb);_updateSliders.call(this);};var _updateRGBFromHSV=function(){var hsv=[this.get(this.OPT.HUE),this.get(this.OPT.SATURATION)/100,this.get(this.OPT.VALUE)/100];var rgb=Color.hsv2rgb(hsv);this.set(this.OPT.RGB,rgb);_updateSliders.call(this);};var _updateHex=function(){var hex=this.get(this.OPT.HEX),l=hex.length;if(l===3){var c=hex.split(""),i;for(i=0;i<l;i=i+1){c[i]=c[i]+c[i];}
-hex=c.join("");}
-if(hex.length!==6){return false;}
-var rgb=Color.hex2rgb(hex);this.setValue(rgb);};var _updateSliders=function(){_updateHueSlider.call(this);_updatePickerSlider.call(this);};var _updateHueSlider=function(){var size=this.get(this.OPT.PICKER_SIZE),h=this.get(this.OPT.HUE);h=size-Math.round(h/360*size);if(h===size){h=0;}
-this.hueSlider.setValue(h);};var _updatePickerSlider=function(){var size=this.get(this.OPT.PICKER_SIZE),s=this.get(this.OPT.SATURATION),v=this.get(this.OPT.VALUE);s=Math.round(s*size/100);v=Math.round(size-(v*size/100));this.pickerSlider.setRegionValue(s,v);};var _createHostElement=function(){var el=document.createElement('div');if(this.CSS.BASE){el.className=this.CSS.BASE;}
-return el;};})();YAHOO.register("colorpicker",YAHOO.widget.ColorPicker,{version:"2.3.0",build:"442"});
\ No newline at end of file
diff --git a/lib/yui/colorpicker/colorpicker-beta.js b/lib/yui/colorpicker/colorpicker-beta.js
deleted file mode 100755 (executable)
index 56d40f5..0000000
+++ /dev/null
@@ -1,1725 +0,0 @@
-/*
-Copyright (c) 2007, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 2.3.0
-*/
-/**
- * Provides color conversion and validation utils
- * @class YAHOO.util.Color
- * @namespace YAHOO.util
- */
-YAHOO.util.Color = function() {
-
-    var HCHARS="0123456789ABCDEF", lang=YAHOO.lang;
-
-    return {
-
-        /**
-         * Converts 0-1 to 0-255
-         * @method real2dec
-         * @param n {float} the number to convert
-         * @return {int} a number 0-255
-         */
-        real2dec: function(n) {
-            return Math.min(255, Math.round(n*256));
-        },
-
-        /**
-         * Converts HSV (h[0-360], s[0-1]), v[0-1] to RGB [255,255,255]
-         * @method hsv2rgb
-         * @param h {int|[int, float, float]} the hue, or an
-         *        array containing all three parameters
-         * @param s {float} the saturation
-         * @param v {float} the value/brightness
-         * @return {[int, int, int]} the red, green, blue values in
-         *          decimal.
-         */
-        hsv2rgb: function(h, s, v) { 
-
-            if (lang.isArray(h)) {
-                return this.hsv2rgb.call(this, h[0], h[1], h[2]);
-            }
-
-            var r, g, b, i, f, p, q, t;
-            i = Math.floor((h/60)%6);
-            f = (h/60)-i;
-            p = v*(1-s);
-            q = v*(1-f*s);
-            t = v*(1-(1-f)*s);
-            switch(i) {
-                case 0: r=v; g=t; b=p; break;
-                case 1: r=q; g=v; b=p; break;
-                case 2: r=p; g=v; b=t; break;
-                case 3: r=p; g=q; b=v; break;
-                case 4: r=t; g=p; b=v; break;
-                case 5: r=v; g=p; b=q; break;
-            }
-
-            var fn=this.real2dec;
-
-            return [fn(r), fn(g), fn(b)];
-        },
-
-        /**
-         * Converts to RGB [255,255,255] to HSV (h[0-360], s[0-1]), v[0-1]
-         * @method rgb2hsv
-         * @param r {int|[int, int, int]} the red value, or an
-         *        array containing all three parameters
-         * @param g {int} the green value
-         * @param b {int} the blue value
-         * @return {[int, float, float]} the value converted to hsv
-         */
-        rgb2hsv: function(r, g, b) {
-
-            if (lang.isArray(r)) {
-                return this.rgb2hsv.call(this, r[0], r[1], r[2]);
-            }
-
-            r=r/255;
-            g=g/255;
-            b=b/255;
-
-            var min,max,delta,h,s,v;
-            min = Math.min(Math.min(r,g),b);
-            max = Math.max(Math.max(r,g),b);
-            delta = max-min;
-
-            switch (max) {
-                case min: h=0; break;
-                case r:   h=60*(g-b)/delta; 
-                          if (g<b) {
-                              h+=360;
-                          }
-                          break;
-                case g:   h=(60*(b-r)/delta)+120; break;
-                case b:   h=(60*(r-g)/delta)+240; break;
-            }
-            
-            s = (max === 0) ? 0 : 1-(min/max);
-
-            var hsv = [Math.round(h), s, max];
-
-            return hsv;
-
-        },
-
-        /**
-         * Converts decimal rgb values into a hex string
-         * 255,255,255 -> FFFFFF
-         * @method rgb2hex
-         * @param r {int|[int, int, int]} the red value, or an
-         *        array containing all three parameters
-         * @param g {int} the green value
-         * @param b {int} the blue value
-         * @return {string} the hex string
-         */
-        rgb2hex: function(r, g, b) {
-            if (lang.isArray(r)) {
-                return this.rgb2hex.call(this, r[0], r[1], r[2]);
-            }
-
-            var f=this.dec2hex;
-            return f(r) + f(g) + f(b);
-        },
-     
-        /**
-         * Converts an int 0...255 to hex pair 00...FF
-         * @method dec2hex
-         * @param n {int} the number to convert
-         * @return {string} the hex equivalent
-         */
-        dec2hex: function(n) {
-            n = parseInt(n, 10);
-            n = (lang.isNumber(n)) ? n : 0;
-            n = (n > 255 || n < 0) ? 0 : n;
-
-            return HCHARS.charAt((n - n % 16) / 16) + HCHARS.charAt(n % 16);
-        },
-
-        /**
-         * Converts a hex pair 00...FF to an int 0...255 
-         * @method hex2dec
-         * @param str {string} the hex pair to convert
-         * @return {int} the decimal
-         */
-        hex2dec: function(str) {
-            var f = function(c) {
-                return HCHARS.indexOf(c.toUpperCase());
-            };
-
-            var s=str.split('');
-            
-            return ((f(s[0]) * 16) + f(s[1]));
-        },
-
-        /**
-         * Converts a hex string to rgb
-         * @method hex2rgb
-         * @param str {string} the hex string
-         * @return {[int, int, int]} an array containing the rgb values
-         */
-        hex2rgb: function(s) { 
-            var f = this.hex2dec;
-            return [f(s.substr(0, 2)), f(s.substr(2, 2)), f(s.substr(4, 2))];
-        },
-
-        /**
-         * Returns the closest websafe color to the supplied rgb value.
-         * @method websafe
-         * @param r {int|[int, int, int]} the red value, or an
-         *        array containing all three parameters
-         * @param g {int} the green value
-         * @param b {int} the blue value
-         * @return {[int, int, int]} an array containing the closes
-         *                           websafe rgb colors.
-         */
-        websafe: function(r, g, b) {
-
-            if (lang.isArray(r)) {
-                return this.websafe.call(this, r[0], r[1], r[2]);
-            }
-
-            // returns the closest match [0, 51, 102, 153, 204, 255]
-            var f = function(v) {
-                if (lang.isNumber(v)) {
-                    v = Math.min(Math.max(0, v), 255);
-                    var i, next;
-                    for (i=0; i<256; i=i+51) {
-                        next = i+51;
-                        if (v >= i && v <= next) {
-                            return (v-i > 25) ? next : i;
-                        }
-                    }
-                }
-
-                return v;
-            };
-
-            return [f(r), f(g), f(b)];
-        }
-    };
-}();
-
-
-(function() {
-
-    var pickercount = 0;
-
-    /**
-     * The colorpicker module provides a widget for selecting colors
-     * @module colorpicker
-     * @requires yahoo, dom, event, element, slider
-     */
-
-    /**
-     * A widget to select colors
-     * @namespace YAHOO.widget
-     * @class YAHOO.widget.ColorPicker
-     * @extends YAHOO.util.Element
-     * @constructor
-     * @param {HTMLElement | String | Object} el(optional) The html 
-     * element that represents the colorpicker, or the attribute object to use. 
-     * An element will be created if none provided.
-     * @param {Object} attr (optional) A key map of the colorpicker's 
-     * initial attributes.  Ignored if first arg is attributes object.
-     */
-    YAHOO.widget.ColorPicker = function(el, attr) {
-        pickercount = pickercount + 1;
-        attr = attr || {};
-        if (arguments.length === 1 && !YAHOO.lang.isString(el) && !el.nodeName) {
-            attr = el; // treat first arg as attr object
-            el = attr.element || null;
-        }
-        
-        if (!el && !attr.element) { // create if we dont have one
-            el = _createHostElement.call(this, attr);
-        }
-
-       YAHOO.widget.ColorPicker.superclass.constructor.call(this, el, attr); 
-    };
-
-    YAHOO.extend(YAHOO.widget.ColorPicker, YAHOO.util.Element);
-    
-    var proto = YAHOO.widget.ColorPicker.prototype,
-        Slider=YAHOO.widget.Slider,
-        Color=YAHOO.util.Color,
-        Dom = YAHOO.util.Dom,
-        Event = YAHOO.util.Event,
-        lang = YAHOO.lang,
-        sub = lang.substitute;
-    
-
-    var b = "yui-picker";
-
-    /**
-     * The element ids used by this control
-     * @property ID
-     * @final
-     */
-    proto.ID = {
-
-        /**
-         * The id for the "red" form field
-         * @property ID.R
-         * @type String
-         * @final
-         * @default yui-picker-r
-         */
-        R: b + "-r",
-
-        /**
-         * The id for the "red" hex pair output
-         * @property ID.R_HEX
-         * @type String
-         * @final
-         * @default yui-picker-rhex
-         */
-        R_HEX: b + "-rhex",
-
-        /**
-         * The id for the "green" form field
-         * @property ID.G
-         * @type String
-         * @final
-         * @default yui-picker-g
-         */
-        G: b + "-g",
-
-        /**
-         * The id for the "green" hex pair output
-         * @property ID.G_HEX
-         * @type String
-         * @final
-         * @default yui-picker-ghex
-         */
-        G_HEX: b + "-ghex",
-
-
-        /**
-         * The id for the "blue" form field
-         * @property ID.B
-         * @type String
-         * @final
-         * @default yui-picker-b
-         */
-        B: b + "-b",
-
-        /**
-         * The id for the "blue" hex pair output
-         * @property ID.B_HEX
-         * @type String
-         * @final
-         * @default yui-picker-bhex
-         */
-        B_HEX: b + "-bhex",
-
-        /**
-         * The id for the "hue" form field
-         * @property ID.H
-         * @type String
-         * @final
-         * @default yui-picker-h
-         */
-        H: b + "-h",
-
-        /**
-         * The id for the "saturation" form field
-         * @property ID.S
-         * @type String
-         * @final
-         * @default yui-picker-s
-         */
-        S: b + "-s",
-
-        /**
-         * The id for the "value" form field
-         * @property ID.V
-         * @type String
-         * @final
-         * @default yui-picker-v
-         */
-        V: b + "-v",
-
-        /**
-         * The id for the picker region slider
-         * @property ID.PICKER_BG
-         * @type String
-         * @final
-         * @default yui-picker-bg
-         */
-        PICKER_BG:      b + "-bg",
-
-        /**
-         * The id for the picker region thumb
-         * @property ID.PICKER_THUMB
-         * @type String
-         * @final
-         * @default yui-picker-thumb
-         */
-        PICKER_THUMB:   b + "-thumb",
-
-        /**
-         * The id for the hue slider
-         * @property ID.HUE_BG
-         * @type String
-         * @final
-         * @default yui-picker-hue-bg
-         */
-        HUE_BG:         b + "-hue-bg",
-
-        /**
-         * The id for the hue thumb
-         * @property ID.HUE_THUMB
-         * @type String
-         * @final
-         * @default yui-picker-hue-thumb
-         */
-        HUE_THUMB:      b + "-hue-thumb",
-
-        /**
-         * The id for the hex value form field
-         * @property ID.HEX
-         * @type String
-         * @final
-         * @default yui-picker-hex
-         */
-        HEX:            b + "-hex",
-
-        /**
-         * The id for the color swatch
-         * @property ID.SWATCH
-         * @type String
-         * @final
-         * @default yui-picker-swatch
-         */
-        SWATCH:         b + "-swatch",
-
-        /**
-         * The id for the websafe color swatch
-         * @property ID.WEBSAFE_SWATCH
-         * @type String
-         * @final
-         * @default yui-picker-websafe-swatch
-         */
-        WEBSAFE_SWATCH: b + "-websafe-swatch",
-
-        /**
-         * The id for the control details
-         * @property ID.CONTROLS
-         * @final
-         * @default yui-picker-controls
-         */
-        CONTROLS: b + "-controls",
-
-        /**
-         * The id for the rgb controls
-         * @property ID.RGB_CONTROLS
-         * @final
-         * @default yui-picker-rgb-controls
-         */
-        RGB_CONTROLS: b + "-rgb-controls",
-
-        /**
-         * The id for the hsv controls
-         * @property ID.HSV_CONTROLS
-         * @final
-         * @default yui-picker-hsv-controls
-         */
-        HSV_CONTROLS: b + "-hsv-controls",
-        
-        /**
-         * The id for the hsv controls
-         * @property ID.HEX_CONTROLS
-         * @final
-         * @default yui-picker-hex-controls
-         */
-        HEX_CONTROLS: b + "-hex-controls",
-
-        /**
-         * The id for the hex summary
-         * @property ID.HEX_SUMMARY
-         * @final
-         * @default yui-picker-hex-summary
-         */
-        HEX_SUMMARY: b + "-hex-summary",
-
-        /**
-         * The id for the controls section header
-         * @property ID.CONTROLS_LABEL
-         * @final
-         * @default yui-picker-controls-label
-         */
-        CONTROLS_LABEL: b + "-controls-label"
-    };
-
-    /**
-     * Constants for any script-generated messages.  The values here
-     * are the default messages.  They can be updated by providing
-     * the complete list to the constructor for the "txt" attribute.
-     * @property TXT
-     * @final
-     */
-    proto.TXT = {
-        ILLEGAL_HEX: "Illegal hex value entered",
-        SHOW_CONTROLS: "Show color details",
-        HIDE_CONTROLS: "Hide color details",
-        CURRENT_COLOR: "Currently selected color: {rgb}",
-        CLOSEST_WEBSAFE: "Closest websafe color: {rgb}. Click to select.",
-        R: "R",
-        G: "G",
-        B: "B",
-        H: "H",
-        S: "S",
-        V: "V",
-        HEX: "#",
-        DEG: "\u00B0",
-        PERCENT: "%"
-    };
-
-    /**
-     * Constants for the default image locations for img tags that are
-     * generated by the control.  They can be modified by passing the
-     * complete list to the contructor for the "images" attribute
-     * @property IMAGE
-     * @final
-     */
-    proto.IMAGE = {
-        PICKER_THUMB: "../../build/colorpicker/assets/picker_thumb.png",
-        HUE_THUMB: "../../build/colorpicker/assets/hue_thumb.png"
-    };
-
-    /*
-     * Constants for the control's custom event names.  subscribe
-     * to the rgbChange event instead.
-     * @property EVENT
-     * @final
-     */
-    //proto.EVENT = {
-        //CHANGE: "change"
-    //};
-
-    //proto.CSS = { };
-
-    /**
-     * Constants for the control's default default values
-     * @property DEFAULT
-     * @final
-     */
-    proto.DEFAULT = {
-        PICKER_SIZE: 180
-    };
-
-    /**
-     * Constants for the control's configuration attributes
-     * @property OPT
-     * @final
-     */
-    proto.OPT = {
-        HUE: "hue",
-        SATURATION: "saturation",
-        VALUE: "value",
-        RED: "red",
-        GREEN: "green",
-        BLUE: "blue",
-        HSV: "hsv",
-        RGB: "rgb",
-        WEBSAFE: "websafe",
-        HEX: "hex",
-        PICKER_SIZE: "pickersize",
-        SHOW_CONTROLS: "showcontrols",
-        SHOW_RGB_CONTROLS: "showrgbcontrols",
-        SHOW_HSV_CONTROLS: "showhsvcontrols",
-        SHOW_HEX_CONTROLS: "showhexcontrols",
-        SHOW_HEX_SUMMARY: "showhexsummary",
-        SHOW_WEBSAFE: "showwebsafe",
-        //SHOW_SUBMIT: "showsubmit",
-        CONTAINER: "container",
-        IDS: "ids",
-        ELEMENTS: "elements",
-        TXT: "txt",
-        IMAGES: "images",
-        ANIMATE: "animate"
-    };
-
-    /**
-     * Sets the control to the specified rgb value and
-     * moves the sliders to the proper positions
-     * @method setValue
-     * @param rgb {[int, int, int]} the rgb value
-     * @param silent {boolean} whether or not to fire the change event
-     */
-    proto.setValue = function(rgb, silent) {
-        silent = (silent) || false;
-        this.set(this.OPT.RGB, rgb, silent);
-        _updateSliders.call(this);
-    };
-
-    /**
-     * The hue slider
-     * @property hueSlider
-     * @type YAHOO.widget.Slider
-     */
-    proto.hueSlider = null; 
-    
-    /**
-     * The picker region
-     * @property pickerSlider
-     * @type YAHOO.widget.Slider
-     */
-    proto.pickerSlider = null;
-
-    /**
-     * Translates the slider value into hue, int[0,359]
-     * @method _getH
-     * @private
-     * @return {int} the hue from 0 to 359
-     */
-    var _getH = function() {
-        var size = this.get(this.OPT.PICKER_SIZE),
-            h = (size - this.hueSlider.getValue()) / size;
-        h = Math.round(h*360);
-        return (h === 360) ? 0 : h;
-    };
-
-    /**
-     * Translates the slider value into saturation, int[0,1], left to right
-     * @method _getS
-     * @private
-     * @return {int} the saturation from 0 to 1
-     */
-    var _getS = function() {
-        return this.pickerSlider.getXValue() / this.get(this.OPT.PICKER_SIZE);
-    };
-
-    /**
-     * Translates the slider value into value/brightness, int[0,1], top
-     * to bottom
-     * @method _getV
-     * @private
-     * @return {int} the value from 0 to 1
-     */
-    var _getV = function() {
-        var size = this.get(this.OPT.PICKER_SIZE);
-        return (size - this.pickerSlider.getYValue()) / size;
-    };
-
-    /**
-     * Updates the background of the swatch with the current rbg value.
-     * Also updates the websafe swatch to the closest websafe color
-     * @method _updateSwatch
-     * @private
-     */
-    var _updateSwatch = function() {
-        var rgb = this.get(this.OPT.RGB),
-            websafe = this.get(this.OPT.WEBSAFE),
-            el = this.getElement(this.ID.SWATCH),
-            color = rgb.join(","),
-            txt = this.get(this.OPT.TXT);
-
-        Dom.setStyle(el, "background-color", "rgb(" + color  + ")");
-        el.title = lang.substitute(txt.CURRENT_COLOR, {
-                "rgb": "#" + this.get(this.OPT.HEX)
-            });
-
-
-        el = this.getElement(this.ID.WEBSAFE_SWATCH);
-        color = websafe.join(",");
-
-        Dom.setStyle(el, "background-color", "rgb(" + color + ")");
-        el.title = lang.substitute(txt.CLOSEST_WEBSAFE, {
-                "rgb": "#" + Color.rgb2hex(websafe)
-            });
-
-    };
-
-    /**
-     * Reads the sliders and converts the values to RGB, updating the
-     * internal state for all the individual form fields
-     * @method _getValuesFromSliders
-     * @private
-     */
-    var _getValuesFromSliders = function() {
-        var h=_getH.call(this), s=_getS.call(this), v=_getV.call(this);
-
-        rgb = Color.hsv2rgb(h, s, v);
-        var websafe = Color.websafe(rgb);
-        var hex = Color.rgb2hex(rgb[0], rgb[1], rgb[2]);
-
-        this.set(this.OPT.RGB, rgb);
-    };
-
-    /**
-     * Updates the form field controls with the state data contained
-     * in the control.
-     * @method _updateFormFields
-     * @private
-     */
-    var _updateFormFields = function() {
-        this.getElement(this.ID.H).value = this.get(this.OPT.HUE);
-        this.getElement(this.ID.S).value = this.get(this.OPT.SATURATION);
-        this.getElement(this.ID.V).value = this.get(this.OPT.VALUE);
-        this.getElement(this.ID.R).value = this.get(this.OPT.RED);
-        this.getElement(this.ID.R_HEX).innerHTML = Color.dec2hex(this.get(this.OPT.RED));
-        this.getElement(this.ID.G).value = this.get(this.OPT.GREEN);
-        this.getElement(this.ID.G_HEX).innerHTML = Color.dec2hex(this.get(this.OPT.GREEN));
-        this.getElement(this.ID.B).value = this.get(this.OPT.BLUE);
-        this.getElement(this.ID.B_HEX).innerHTML = Color.dec2hex(this.get(this.OPT.BLUE));
-        this.getElement(this.ID.HEX).value = this.get(this.OPT.HEX);
-    };
-
-    /**
-     * Event handler for the hue slider.
-     * @method _onHueSliderChange
-     * @param newOffset {int} pixels from the start position
-     * @private
-     */
-    var _onHueSliderChange = function(newOffset) {
-
-        var h = _getH.call(this);
-        this.set(this.OPT.HUE, h, true);
-
-        // set picker background to the hue
-        var rgb = Color.hsv2rgb(h, 1, 1);
-        var styleDef = "rgb(" + rgb.join(",") + ")";
-
-        Dom.setStyle(this.getElement(this.ID.PICKER_BG), "background-color", styleDef);
-
-        if (this.hueSlider.valueChangeSource === this.hueSlider.SOURCE_UI_EVENT) {
-            _getValuesFromSliders.call(this);
-        }
-
-        _updateFormFields.call(this);
-        _updateSwatch.call(this);
-    };
-
-    /**
-     * Event handler for the picker slider, which controls the
-     * saturation and value/brightness.
-     * @method _onPickerSliderChange
-     * @param newOffset {{x: int, y: int}} x/y pixels from the start position
-     * @private
-     */
-    var _onPickerSliderChange = function(newOffset) {
-
-        var s=_getS.call(this), v=_getV.call(this);
-        this.set(this.OPT.SATURATION, Math.round(s*100), true);
-        this.set(this.OPT.VALUE, Math.round(v*100), true);
-
-        if (this.pickerSlider.valueChangeSource === this.pickerSlider.SOURCE_UI_EVENT) {
-            _getValuesFromSliders.call(this);
-        }
-
-        _updateFormFields.call(this);
-        _updateSwatch.call(this);
-    };
-
-
-    /**
-     * Key map to well-known commands for txt field input
-     * @method _getCommand
-     * @param e {Event} the keypress or keydown event
-     * @return {int} a command code
-     * <ul>
-     * <li>0 = not a number, letter in range, or special key</li>
-     * <li>1 = number</li>
-     * <li>2 = a-fA-F</li>
-     * <li>3 = increment (up arrow)</li>
-     * <li>4 = decrement (down arrow)</li>
-     * <li>5 = special key (tab, delete, return, escape, left, right)</li> 
-     * <li>6 = return</li>
-     * </ul>
-     * @private
-     */
-    var _getCommand = function(e) {
-        var c = Event.getCharCode(e);
-
-        //alert(Event.getCharCode(e) + ", " + e.keyCode + ", " + e.charCode);
-
-        // special keys
-        if (c === 38) { // up arrow
-            return 3;
-        } else if (c === 13) { // return
-            return 6;
-        } else if (c === 40) { // down array
-            return 4;
-        } else if (c >= 48 && c<=57) { // 0-9
-            return 1;
-        } else if (c >= 97 && c<=102) { // a-f
-            return 2;
-        } else if (c >= 65 && c<=70) { // A-F
-            return 2;
-        //} else if ("8, 9, 13, 27, 37, 39".indexOf(c) > -1 || 
-        //              (c >= 112 && c <=123)) { // including F-keys
-        // tab, delete, return, escape, left, right
-        } else if ("8, 9, 13, 27, 37, 39".indexOf(c) > -1) { // special chars
-            return 5;
-        } else { // something we probably don't want
-            return 0;
-        }
-    };
-
-    /**
-     * Handle keypress on one of the rgb or hsv fields.
-     * @method _rgbFieldKeypress
-     * @param e {Event} the keypress event
-     * @param el {HTMLElement} the field
-     * @param prop {string} the key to the linked property
-     * @private
-     */
-    var _rgbFieldKeypress = function(e, el, prop) {
-        var command = _getCommand(e);
-        var inc = (e.shiftKey) ? 10 : 1;
-        switch (command) {
-            case 6: // return, update the value
-                _useFieldValue.apply(this, arguments);
-                break;
-                        
-            case 3: // up arrow, increment
-                this.set(prop, Math.min(this.get(prop)+inc, 255));
-                _updateFormFields.call(this);
-                //Event.stopEvent(e);
-                break;
-            case 4: // down arrow, decrement
-                this.set(prop, Math.max(this.get(prop)-inc, 0));
-                _updateFormFields.call(this);
-                //Event.stopEvent(e);
-                break;
-
-            default:
-        }
-
-    };
-
-    /**
-     * Handle keydown on the hex field
-     * @method _hexFieldKeypress
-     * @param e {Event} the keypress event
-     * @param el {HTMLElement} the field
-     * @param prop {string} the key to the linked property
-     * @private
-     */
-    var _hexFieldKeypress = function(e, el, prop) {
-        var command = _getCommand(e);
-        if (command === 6) { // return, update the value
-            _useFieldValue.apply(this, arguments);
-        }
-    };
-
-    /**
-     * Use the value of the text field to update the control
-     * @method _hexFieldKeypress
-     * @param e {Event} an event
-     * @param el {HTMLElement} the field
-     * @param prop {string} the key to the linked property
-     * @private
-     */
-    var _useFieldValue = function(e, el, prop) {
-        var val = el.value;
-
-        if (prop !== this.OPT.HEX) {
-            val = parseInt(val, 10);
-        }
-
-        if (val !== this.get(prop)) {
-            this.set(prop, val);
-        }
-    };
-
-    /** 
-     * Allows numbers and special chars only.  Used for the
-     * rgb and hsv fields keypress handler.
-     * @method _numbersOnly
-     * @param e {Event} the event
-     * @private
-     * @return {boolean} false if we are canceling the event
-     */
-    var _numbersOnly = function(e) {
-        return _hexOnly(e, true);
-    };
-
-    /** 
-     * Allows numbers and special chars, and by default allows a-f.  
-     * Used for the hex field keypress handler.
-     * @method _hexOnly
-     * @param e {Event} the event
-     * @param numbersOnly omits a-f if set to true
-     * @private
-     * @return {boolean} false if we are canceling the event
-     */
-    var _hexOnly = function(e, numbersOnly) {
-        var command = _getCommand(e);
-        switch (command) {
-            case 6: // return
-            case 5: // special char
-            case 1: // number
-                break;
-            case 2: // hex char (a-f)
-                if (numbersOnly !== true) {
-                    break;
-                }
-
-                // fallthrough is intentional
-
-            default: // prevent alpha and punctuation
-                Event.stopEvent(e);
-                return false;
-        }
-    };
-
-    /**
-     * Returns the element reference that is saved.  The id can be either
-     * the element id, or the key for this id in the "id" config attribute.
-     * For instance, the host element id can be obtained by passing its
-     * id (default: "yui_picker") or by its key "YUI_PICKER".
-     * @param id {string} the element id, or key 
-     * @return {HTMLElement} a reference to the element
-     */
-    proto.getElement = function(id) { 
-        return this.get(this.OPT.ELEMENTS)[this.get(this.OPT.IDS)[id]]; 
-    };
-
-    _createElements = function() {
-        var el, child, img, fld, i, 
-            ids = this.get(this.OPT.IDS),
-            txt = this.get(this.OPT.TXT),
-            images = this.get(this.OPT.IMAGES),
-            Elem = function(type, o) {
-                var n = document.createElement(type);
-                if (o) {
-                    lang.augmentObject(n, o, true);
-                }
-                return n;
-            },
-            RGBElem = function(type, obj) {
-                var o = lang.merge({
-                        //type: "txt",
-                        autocomplete: "off",
-                        value: "0",
-                        size: 3,
-                        maxlength: 3
-                    }, obj);
-
-                o.name = o.id;
-                return new Elem(type, o);
-            };
-
-        var p = this.get("element");
-
-        // Picker slider (S and V) ---------------------------------------------
-
-        el = new Elem("div", {
-            id: ids[this.ID.PICKER_BG],
-            className: "yui-picker-bg",
-            tabIndex: -1,
-            hideFocus: true
-        });
-
-        child = new Elem("div", {
-            id: ids[this.ID.PICKER_THUMB],
-            className: "yui-picker-thumb"
-        });
-
-        img = new Elem("img", {
-            src: images.PICKER_THUMB
-        });
-
-        child.appendChild(img);
-        el.appendChild(child);
-        p.appendChild(el);
-        
-        // Hue slider ---------------------------------------------
-        el = new Elem("div", {
-            id: ids[this.ID.HUE_BG],
-            className: "yui-picker-hue-bg",
-            tabIndex: -1,
-            hideFocus: true
-        });
-
-        child = new Elem("div", {
-            id: ids[this.ID.HUE_THUMB],
-            className: "yui-picker-hue-thumb"
-        });
-
-        img = new Elem("img", {
-            src: images.HUE_THUMB
-        });
-
-        child.appendChild(img);
-        el.appendChild(child);
-        p.appendChild(el);
-
-
-        // controls ---------------------------------------------
-
-        el = new Elem("div", {
-            id: ids[this.ID.CONTROLS],
-            className: "yui-picker-controls"
-        });
-
-        p.appendChild(el);
-        p = el;
-
-            // controls header
-            el = new Elem("div", {
-                className: "hd"
-            });
-
-            child = new Elem("a", {
-                id: ids[this.ID.CONTROLS_LABEL],
-                //className: "yui-picker-controls-label",
-                href: "#"
-            });
-            el.appendChild(child);
-            p.appendChild(el);
-
-            // bd
-            el = new Elem("div", {
-                className: "bd"
-            });
-
-            p.appendChild(el);
-            p = el;
-
-                // rgb
-                el = new Elem("ul", {
-                    id: ids[this.ID.RGB_CONTROLS],
-                    className: "yui-picker-rgb-controls"
-                });
-
-                child = new Elem("li");
-                child.appendChild(document.createTextNode(txt.R + " "));
-
-                fld = new RGBElem("input", {
-                    id: ids[this.ID.R],
-                    className: "yui-picker-r"
-                });
-
-                child.appendChild(fld);
-                el.appendChild(child);
-
-                child = new Elem("li");
-                child.appendChild(document.createTextNode(txt.G + " "));
-
-                fld = new RGBElem("input", {
-                    id: ids[this.ID.G],
-                    className: "yui-picker-g"
-                });
-
-                child.appendChild(fld);
-                el.appendChild(child);
-
-                child = new Elem("li");
-                child.appendChild(document.createTextNode(txt.B + " "));
-
-                fld = new RGBElem("input", {
-                    id: ids[this.ID.B],
-                    className: "yui-picker-b"
-                });
-
-                child.appendChild(fld);
-                el.appendChild(child);
-
-                p.appendChild(el);
-
-                // hsv
-                el = new Elem("ul", {
-                    id: ids[this.ID.HSV_CONTROLS],
-                    className: "yui-picker-hsv-controls"
-                });
-
-                child = new Elem("li");
-                child.appendChild(document.createTextNode(txt.H + " "));
-
-                fld = new RGBElem("input", {
-                    id: ids[this.ID.H],
-                    className: "yui-picker-h"
-                });
-
-                child.appendChild(fld);
-                child.appendChild(document.createTextNode(" " + txt.DEG));
-
-                el.appendChild(child);
-
-                child = new Elem("li");
-                child.appendChild(document.createTextNode(txt.S + " "));
-
-                fld = new RGBElem("input", {
-                    id: ids[this.ID.S],
-                    className: "yui-picker-s"
-                });
-
-                child.appendChild(fld);
-                child.appendChild(document.createTextNode(" " + txt.PERCENT));
-
-                el.appendChild(child);
-
-                child = new Elem("li");
-                child.appendChild(document.createTextNode(txt.V + " "));
-
-                fld = new RGBElem("input", {
-                    id: ids[this.ID.V],
-                    className: "yui-picker-v"
-                });
-
-                child.appendChild(fld);
-                child.appendChild(document.createTextNode(" " + txt.PERCENT));
-
-                el.appendChild(child);
-                p.appendChild(el);
-
-
-                // hex summary
-
-                el = new Elem("ul", {
-                    id: ids[this.ID.HEX_SUMMARY],
-                    className: "yui-picker-hex_summary"
-                });
-
-                child = new Elem("li", {
-                    id: ids[this.ID.R_HEX]
-                });
-                el.appendChild(child);
-
-                child = new Elem("li", {
-                    id: ids[this.ID.G_HEX]
-                });
-                el.appendChild(child);
-
-                child = new Elem("li", {
-                    id: ids[this.ID.B_HEX]
-                });
-                el.appendChild(child);
-                p.appendChild(el);
-
-                // hex field
-                el = new Elem("div", {
-                    id: ids[this.ID.HEX_CONTROLS],
-                    className: "yui-picker-hex-controls"
-                });
-                el.appendChild(document.createTextNode(txt.HEX + " "));
-
-                child = new RGBElem("input", {
-                    id: ids[this.ID.HEX],
-                    className: "yui-picker-hex",
-                    size: 6,
-                    maxlength: 6
-                });
-
-                el.appendChild(child);
-                p.appendChild(el);
-
-                p = this.get("element");
-
-                // swatch
-                el = new Elem("div", {
-                    id: ids[this.ID.SWATCH],
-                    className: "yui-picker-swatch"
-                });
-
-                p.appendChild(el);
-
-                // websafe swatch
-                el = new Elem("div", {
-                    id: ids[this.ID.WEBSAFE_SWATCH],
-                    className: "yui-picker-websafe-swatch"
-                });
-
-                p.appendChild(el);
-
-    };
-
-    /**
-     * Sets the initial state of the sliders
-     * @method initPicker
-     */
-    proto.initPicker = function () {
-
-        // bind all of our elements
-        var o=this.OPT, 
-            ids = this.get(o.IDS), 
-            els = this.get(o.ELEMENTS), 
-                  i, el, id;
-
-        // Add the default value as a key for each element for easier lookup
-        for (i in this.ID) {
-            if (lang.hasOwnProperty(this.ID, i)) {
-                ids[this.ID[i]] = ids[i];
-            }
-        }
-
-        // Check for picker element, if not there, create all of them
-        el = Dom.get(ids[this.ID.PICKER_BG]);
-        if (!el) {
-            _createElements.call(this);
-        } else {
-        }
-
-        for (i in ids) {
-            if (lang.hasOwnProperty(ids, i)) {
-                // look for element
-                el = Dom.get(ids[i]);
-
-                // generate an id if the implementer passed in an element reference,
-                // and the element did not have an id already
-                id = Dom.generateId(el);
-
-                // update the id in case we generated the id
-                ids[i] = id; // key is WEBSAFE_SWATCH
-                ids[ids[i]] = id; // key is websafe_swatch
-
-                // store the dom ref
-                els[id] = el;
-            }
-        }
-
-        // set the initial visibility state of our controls
-            els = [o.SHOW_CONTROLS, 
-                   o.SHOW_RGB_CONTROLS,
-                   o.SHOW_HSV_CONTROLS,
-                   o.SHOW_HEX_CONTROLS,
-                   o.SHOW_HEX_SUMMARY,
-                   o.SHOW_WEBSAFE
-                   ];
-
-        for (i=0; i<els.length; i=i+1) {
-            this.set(els[i], this.get(els[i]));
-        }
-
-        var s = this.get(o.PICKER_SIZE);
-
-        this.hueSlider = Slider.getVertSlider(this.getElement(this.ID.HUE_BG), 
-                                              this.getElement(this.ID.HUE_THUMB), 0, s);
-        this.hueSlider.subscribe("change", _onHueSliderChange, this, true);
-
-        this.pickerSlider = Slider.getSliderRegion(this.getElement(this.ID.PICKER_BG), 
-                                                   this.getElement(this.ID.PICKER_THUMB), 0, s, 0, s);
-        this.pickerSlider.subscribe("change", _onPickerSliderChange, this, true);
-
-        //_onHueSliderChange.call(this, 0);
-
-        Event.on(this.getElement(this.ID.WEBSAFE_SWATCH), "click", function(e) {
-               this.setValue(this.get(o.WEBSAFE));
-               //_updateSliders
-           }, this, true);
-
-        Event.on(this.getElement(this.ID.CONTROLS_LABEL), "click", function(e) {
-               this.set(o.SHOW_CONTROLS, !this.get(o.SHOW_CONTROLS));
-               Event.preventDefault(e);
-           }, this, true);
-
-        _attachRGBHSV.call(this, this.ID.R, this.OPT.RED); 
-        _attachRGBHSV.call(this, this.ID.G, this.OPT.GREEN); 
-        _attachRGBHSV.call(this, this.ID.B, this.OPT.BLUE); 
-        _attachRGBHSV.call(this, this.ID.H, this.OPT.HUE); 
-        _attachRGBHSV.call(this, this.ID.S, this.OPT.SATURATION); 
-        _attachRGBHSV.call(this, this.ID.V, this.OPT.VALUE); 
-
-        Event.on(this.getElement(this.ID.HEX), "keydown", function(e, me) {
-                _hexFieldKeypress.call(me, e, this, me.OPT.HEX);
-            }, this);
-
-        Event.on(this.getElement(this.ID.HEX), "keypress", _hexOnly, this);
-        Event.on(this.getElement(this.ID.HEX), "blur", function(e, me) {
-                _useFieldValue.call(me, e, this, me.OPT.HEX);
-            }, this);
-    };
-
-    _attachRGBHSV = function(id, config) {
-        Event.on(this.getElement(id), "keydown", function(e, me) {
-                _rgbFieldKeypress.call(me, e, this, config);
-            }, this);
-        Event.on(this.getElement(id), "keypress", _numbersOnly, this);
-        Event.on(this.getElement(id), "blur", function(e, me) {
-                _useFieldValue.call(me, e, this, config);
-            }, this);
-    };
-
-
-    /**
-     * Sets up the config attributes and the change listeners for this
-     * properties
-     * @method initAttributes
-     * @param attr An object containing default attribute values
-     */
-    proto.initAttributes = function(attr) {
-
-        attr = attr || {};
-        YAHOO.widget.ColorPicker.superclass.initAttributes.call(this, attr);
-        
-        /**
-         * The size of the picker. Trying to change this is not recommended.
-         * @config pickersize
-         * @default 180
-         * @type int
-         */
-        this.setAttributeConfig(this.OPT.PICKER_SIZE, {
-                value: attr.size || this.DEFAULT.PICKER_SIZE
-            });
-
-        /**
-         * The current hue value 0-360
-         * @config hue
-         * @type int
-         */
-        this.setAttributeConfig(this.OPT.HUE, {
-                value: attr.hue || 0,
-                validator: lang.isNumber
-            });
-
-        /**
-         * The current saturation value 0-100
-         * @config saturation
-         * @type int
-         */
-        this.setAttributeConfig(this.OPT.SATURATION, {
-                value: attr.saturation || 0,
-                validator: lang.isNumber
-            });
-
-        /**
-         * The current value/brightness value 0-100
-         * @config value
-         * @type int
-         */
-        this.setAttributeConfig(this.OPT.VALUE, {
-                value: attr.value || 100,
-                validator: lang.isNumber
-            });
-
-        /**
-         * The current red value 0-255
-         * @config red
-         * @type int
-         */
-        this.setAttributeConfig(this.OPT.RED, {
-                value: attr.red || 255,
-                validator: lang.isNumber
-            });
-
-        /**
-         * The current green value 0-255
-         * @config green 
-         * @type int
-         */
-        this.setAttributeConfig(this.OPT.GREEN, {
-                value: attr.red || 255,
-                validator: lang.isNumber
-            });
-
-        /**
-         * The current blue value 0-255
-         * @config blue
-         * @type int
-         */
-        this.setAttributeConfig(this.OPT.BLUE, {
-                value: attr.blue || 255,
-                validator: lang.isNumber
-            });
-
-        /**
-         * The current hex value #000000-#FFFFFF, without the #
-         * @config hex
-         * @type string
-         */
-        this.setAttributeConfig(this.OPT.HEX, {
-                value: attr.hex || "FFFFFF",
-                validator: lang.isString
-            });
-
-        /**
-         * The current rgb value.  Updates the state of all of the
-         * other value fields.  Read-only: use setValue to set the
-         * controls rgb value.
-         * @config hex
-         * @type [int, int, int]
-         * @readonly
-         */
-        this.setAttributeConfig(this.OPT.RGB, {
-                value: attr.rgb || [255,255,255],
-                method: function(rgb) {
-
-                    this.set(this.OPT.RED, rgb[0], true);
-                    this.set(this.OPT.GREEN, rgb[1], true);
-                    this.set(this.OPT.BLUE, rgb[2], true);
-
-                    var websafe = Color.websafe(rgb);
-                    this.set(this.OPT.WEBSAFE, websafe, true);
-
-                    var hex = Color.rgb2hex(rgb);
-                    this.set(this.OPT.HEX, hex, true);
-
-                    var hsv = Color.rgb2hsv(rgb);
-
-
-                    this.set(this.OPT.HUE, hsv[0], true);
-                    this.set(this.OPT.SATURATION, Math.round(hsv[1]*100), true);
-                    this.set(this.OPT.VALUE, Math.round(hsv[2]*100), true);
-                },
-                readonly: true
-            });
-
-        /**
-         * If the color picker will live inside of a container object,
-         * set, provide a reference to it so the control can use the
-         * container's events.
-         * @config container
-         * @type YAHOO.widget.Panel
-         */
-        this.setAttributeConfig(this.OPT.CONTAINER, {
-                    value: null,
-                    method: function(container) {
-                        if (container) {
-                            // Position can get out of sync when the
-                            // control is manipulated while display is
-                            // none.  Resetting the slider constraints
-                            // when it is visible gets the state back in
-                            // order.
-                            container.showEvent.subscribe(function() {
-                                // this.pickerSlider.thumb.resetConstraints();
-                                // this.hueSlider.thumb.resetConstraints();
-                                this.pickerSlider.focus();
-                            }, this, true);
-                        }
-                    }
-                });
-        /**
-         * The closest current websafe value
-         * @config websafe
-         * @type int
-         */
-        this.setAttributeConfig(this.OPT.WEBSAFE, {
-                value: attr.websafe || [255,255,255]
-            });
-
-
-        ids = attr.ids || lang.merge({}, this.ID);
-
-        if (!attr.ids && pickercount > 1) {
-            for (var i in ids) {
-                if (lang.hasOwnProperty(ids, i)) {
-                    ids[i] = ids[i] + pickercount;
-                }
-            }
-        }
-
-
-        /**
-         * A list of element ids and/or element references used by the 
-         * control.  The default is the this.ID list, and can be customized
-         * by passing a list in the contructor
-         * @config ids
-         * @type {referenceid: realid}
-         * @writeonce
-         */
-        this.setAttributeConfig(this.OPT.IDS, {
-                value: ids,
-                writeonce: true
-            });
-
-        /**
-         * A list of txt strings for internationalization.  Default
-         * is this.TXT
-         * @config txt
-         * @type {key: txt}
-         * @writeonce
-         */
-        this.setAttributeConfig(this.OPT.TXT, {
-                value: attr.txt || this.TXT,
-                writeonce: true
-            });
-
-        /**
-         * The img src default list
-         * is this.IMAGES
-         * @config images
-         * @type {key: image}
-         * @writeonce
-         */
-        this.setAttributeConfig(this.OPT.IMAGES, {
-                value: attr.images || this.IMAGE,
-                writeonce: true
-            });
-        /**
-         * The element refs used by this control.  Set at initialization
-         * @config elements
-         * @type {id: HTMLElement}
-         * @readonly
-         */
-        this.setAttributeConfig(this.OPT.ELEMENTS, {
-                value: {},
-                readonly: true
-            });
-
-        /**
-         * Returns the cached element reference.  If the id is not a string, it
-         * is assumed that it is an element and this is returned.
-         * @param id {string|HTMLElement} the element key, id, or ref
-         * @param on {boolean} hide or show.  If true, show
-         * @private */
-        _hideShowEl = function(id, on) {
-            var el = (lang.isString(id) ? this.getElement(id) : id);
-            //Dom.setStyle(id, "visibility", (on) ? "" : "hidden");
-            Dom.setStyle(el, "display", (on) ? "" : "none");
-        };
-
-        /**
-         * Hide/show the entire set of controls
-         * @config showcontrols
-         * @type boolean
-         * @default true
-         */
-        this.setAttributeConfig(this.OPT.SHOW_CONTROLS, {
-                value: (attr.showcontrols) || true,
-                method: function(on) {
-
-                    var el = Dom.getElementsByClassName("bd", "div", 
-                            this.getElement(this.ID.CONTROLS))[0];
-
-                    _hideShowEl.call(this, el, on);
-
-                    this.getElement(this.ID.CONTROLS_LABEL).innerHTML = 
-                        (on) ? this.get(this.OPT.TXT).HIDE_CONTROLS :
-                               this.get(this.OPT.TXT).SHOW_CONTROLS;
-
-                }
-            });
-
-        /**
-         * Hide/show the rgb controls
-         * @config showrgbcontrols
-         * @type boolean
-         * @default true
-         */
-        this.setAttributeConfig(this.OPT.SHOW_RGB_CONTROLS, {
-                value: (attr.showrgbcontrols) || true,
-                method: function(on) {
-                    //Dom.setStyle(this.getElement(this.ID.RBG_CONTROLS), "visibility", (on) ? "" : "hidden");
-                    _hideShowEl.call(this, this.ID.RGB_CONTROLS, on);
-                }
-            });
-
-        /**
-         * Hide/show the hsv controls
-         * @config showhsvcontrols
-         * @type boolean
-         * @default false
-         */
-        this.setAttributeConfig(this.OPT.SHOW_HSV_CONTROLS, {
-                value: (attr.showhsvcontrols) || false,
-                method: function(on) {
-                    //Dom.setStyle(this.getElement(this.ID.HSV_CONTROLS), "visibility", (on) ? "" : "hidden");
-                    _hideShowEl.call(this, this.ID.HSV_CONTROLS, on);
-
-                    // can't show both the hsv controls and the rbg hex summary
-                    if (on && this.get(this.OPT.SHOW_HEX_SUMMARY)) {
-                        this.set(this.OPT.SHOW_HEX_SUMMARY, false);
-                    }
-                }
-            });
-
-        /**
-         * Hide/show the hex controls
-         * @config showhexcontrols
-         * @type boolean
-         * @default true
-         */
-        this.setAttributeConfig(this.OPT.SHOW_HEX_CONTROLS, {
-                value: (attr.showhexcontrols) || false,
-                method: function(on) {
-                    _hideShowEl.call(this, this.ID.HEX_CONTROLS, on);
-                }
-            });
-
-        /**
-         * Hide/show the websafe swatch
-         * @config showwebsafe
-         * @type boolean
-         * @default true
-         */
-        this.setAttributeConfig(this.OPT.SHOW_WEBSAFE, {
-                value: (attr.showwebsafe) || true,
-                method: function(on) {
-                    _hideShowEl.call(this, this.ID.WEBSAFE_SWATCH, on);
-                }
-            });
-
-        /**
-         * Hide/show the hex summary
-         * @config showhexsummary
-         * @type boolean
-         * @default true
-         */
-        this.setAttributeConfig(this.OPT.SHOW_HEX_SUMMARY, {
-                value: (attr.showhexsummary) || true,
-                method: function(on) {
-                    _hideShowEl.call(this, this.ID.HEX_SUMMARY, on);
-
-                    // can't show both the hsv controls and the rbg hex summary
-                    if (on && this.get(this.OPT.SHOW_HSV_CONTROLS)) {
-                        this.set(this.OPT.SHOW_HSV_CONTROLS, false);
-                    }
-                }
-            });
-        this.setAttributeConfig(this.OPT.ANIMATE, {
-                value: (attr.animate) || true,
-                method: function(on) {
-                    this.pickerSlider.animate = on;
-                    this.hueSlider.animate = on;
-                }
-            });
-
-        this.on(this.OPT.HUE + "Change", _updateRGBFromHSV, this, true);
-        this.on(this.OPT.SATURATION + "Change", _updateRGBFromHSV, this, true);
-        this.on(this.OPT.VALUE + "Change", _updatePickerSlider, this, true);
-
-        this.on(this.OPT.RED + "Change", _updateRGB, this, true);
-        this.on(this.OPT.GREEN + "Change", _updateRGB, this, true);
-        this.on(this.OPT.BLUE + "Change", _updateRGB, this, true);
-
-        this.on(this.OPT.HEX + "Change", _updateHex, this, true);
-
-        this.initPicker();
-    };
-
-    /**
-     * Updates the rgb attribute with the current state of the r,g,b
-     * fields.  This is invoked from change listeners on these
-     * attributes to facilitate updating these values from the
-     * individual form fields
-     * @method _updateRGB
-     * @private
-     */
-    var _updateRGB = function() {
-        var rgb = [this.get(this.OPT.RED), 
-                   this.get(this.OPT.GREEN),
-                   this.get(this.OPT.BLUE)];
-
-        this.set(this.OPT.RGB, rgb);
-
-        _updateSliders.call(this);
-    };
-
-    /**
-     * Updates the RGB values from the current state of the HSV
-     * values.  Executed when the one of the HSV form fields are
-     * updated
-     * _updateRGBFromHSV
-     * @private
-     */
-    var _updateRGBFromHSV = function() {
-        var hsv = [this.get(this.OPT.HUE), 
-                   this.get(this.OPT.SATURATION)/100,
-                   this.get(this.OPT.VALUE)/100];
-
-        var rgb = Color.hsv2rgb(hsv);
-
-        this.set(this.OPT.RGB, rgb);
-
-        _updateSliders.call(this);
-    };
-
-    /**
-     * Parses the hex string to normalize shorthand values, converts
-     * the hex value to rgb and updates the rgb attribute (which
-     * updates the state for all of the other values)
-     * method _updateHex
-     * @private
-     */
-    var _updateHex = function() {
-       
-        var hex = this.get(this.OPT.HEX), l=hex.length;
-
-        // support #369 -> #336699 shorthand
-        if (l === 3) {
-            var c = hex.split(""), i;
-            for (i=0; i<l; i=i+1) {
-                c[i] = c[i] + c[i];
-            }
-
-            hex = c.join("");
-        }
-
-        if (hex.length !== 6) {
-            return false;
-        }
-
-        var rgb = Color.hex2rgb(hex);
-
-
-        this.setValue(rgb);
-
-        //_updateSliders.call(this);
-
-    };
-
-    /**
-     * Moves the sliders into the position dictated by the current state
-     * of the control
-     * @method _updateSliders
-     * @private
-     */
-    var _updateSliders = function() {
-        _updateHueSlider.call(this);
-        _updatePickerSlider.call(this);
-    };
-
-    /**
-     * Moves the hue slider into the position dictated by the current state
-     * of the control
-     * @method _updateHueSlider
-     * @private
-     */
-    var _updateHueSlider = function() {
-        var size = this.get(this.OPT.PICKER_SIZE),
-            h = this.get(this.OPT.HUE);
-
-        h = size - Math.round(h / 360 * size);
-        
-        // 0 is at the top and bottom of the hue slider.  Always go to
-        // the top so we don't end up sending the thumb to the bottom
-        // when the value didn't actually change (e.g., a conversion
-        // produced 360 instead of 0 and the value was already 0).
-        if (h === size) {
-            h = 0;
-        }
-
-        this.hueSlider.setValue(h);
-    };
-
-    /**
-     * Moves the picker slider into the position dictated by the current state
-     * of the control
-     * @method _updatePickerSlider
-     * @private
-     */
-    var _updatePickerSlider = function() {
-        var size = this.get(this.OPT.PICKER_SIZE),
-            s = this.get(this.OPT.SATURATION),
-            v = this.get(this.OPT.VALUE);
-
-        s = Math.round(s * size / 100);
-        v = Math.round(size - (v * size / 100));
-
-
-        this.pickerSlider.setRegionValue(s, v);
-    };
-
-    /**
-     * Creates the host element if it doesn't exist
-     * @method _createHostElement
-     * @private
-     */
-    var _createHostElement = function() {
-        var el = document.createElement('div');
-
-        if (this.CSS.BASE) {
-            el.className = this.CSS.BASE;
-        }
-        
-        return el;
-    };
-
-
-})();
-YAHOO.register("colorpicker", YAHOO.widget.ColorPicker, {version: "2.3.0", build: "442"});
diff --git a/lib/yui/history/history-beta-debug.js b/lib/yui/history/history-beta-debug.js
deleted file mode 100755 (executable)
index f3cf3b9..0000000
+++ /dev/null
@@ -1,768 +0,0 @@
-/*
-Copyright (c) 2007, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 2.3.0
-*/
-/**
- * The Browser History Manager provides the ability to use the
- * back/forward navigation buttons in a DHTML application. It also allows
- * a DHTML application to be bookmarked in a specific state.
- *
- * @module history
- * @requires yahoo,event
- * @namespace YAHOO.util
- * @title Browser History Manager
- * @experimental
- */
-
-/**
- * The History class provides the ability to use the back/forward navigation
- * buttons in a DHTML application. It also allows a DHTML application to
- * be bookmarked in a specific state.
- *
- * @class History
- * @constructor
- */
-YAHOO.util.History = ( function () {
-
-    /**
-     * Our hidden IFrame used to store the browsing history.
-     *
-     * @property _iframe
-     * @type HTMLIFrameElement
-     * @default null
-     * @private
-     */
-    var _iframe = null;
-
-    /**
-     * INPUT field (with type="hidden" or type="text") or TEXTAREA.
-     * This field keeps the value of the initial state, current state
-     * the list of all states across pages within a single browser session.
-     *
-     * @property _storageField
-     * @type HTMLInputElement|HTMLTextAreaElement
-     * @default null
-     * @private
-     */
-    var _storageField = null;
-
-    /**
-     * Flag used to tell whether YAHOO.util.History.initialize has been called.
-     *
-     * @property _initialized
-     * @type boolean
-     * @default false
-     * @private
-     */
-    var _initialized = false;
-
-    /**
-     * Flag used to tell whether the storage field is ready to be used.
-     *
-     * @property _storageFieldReady
-     * @type boolean
-     * @default false
-     * @private
-     */
-    var _storageFieldReady = false;
-
-    /**
-     * Flag used to tell whether the Browser History Manager is ready.
-     *
-     * @property _bhmReady
-     * @type boolean
-     * @default false
-     * @private
-     */
-    var _bhmReady = false;
-
-    /**
-     * List of registered modules.
-     *
-     * @property _modules
-     * @type array
-     * @default []
-     * @private
-     */
-    var _modules = [];
-
-    /**
-     * List of fully qualified states. This is used only by Safari.
-     *
-     * @property _fqstates
-     * @type array
-     * @default []
-     * @private
-     */
-    var _fqstates = [];
-
-    /**
-     * Trims a string.
-     *
-     * @method _trim
-     * @param {string} str The string to be trimmed.
-     * @return {string} The trimmed string
-     * @private
-     */
-    function _trim( str ) {
-        return str.replace( /^\s*(\S*(\s+\S+)*)\s*$/, "$1" );
-    }
-
-    /**
-     * location.hash is a bit buggy on Opera. I have seen instances where
-     * navigating the history using the back/forward buttons, and hence
-     * changing the URL, would not change location.hash. That's ok, the
-     * implementation of an equivalent is trivial.
-     *
-     * @method _getHash
-     * @return {string} The hash portion of the document's location
-     * @private
-     */
-    function _getHash() {
-
-        var href;
-        var i;
-
-        href = top.location.href;
-        i = href.indexOf( "#" );
-        return i >= 0 ? href.substr( i + 1 ) : null;
-    }
-
-    /**
-     * Stores all the registered modules' initial state and current state.
-     * On Safari, we also store all the fully qualified states visited by
-     * the application within a single browser session. The storage takes
-     * place in the form field specified during initialization.
-     *
-     * @method _storeStates
-     * @private
-     */
-    function _storeStates() {
-
-        var moduleName;
-        var moduleObj;
-        var initialStates = [];
-        var currentStates = [];
-
-        for ( moduleName in _modules ) {
-            if ( YAHOO.lang.hasOwnProperty( _modules, moduleName ) ) {
-                moduleObj = _modules[moduleName];
-                initialStates.push( moduleName + "=" + moduleObj.initialState );
-                currentStates.push( moduleName + "=" + moduleObj.currentState );
-            }
-        }
-
-        _storageField.value = initialStates.join( "&" ) + "|" + currentStates.join( "&" );
-
-        if ( YAHOO.env.ua.webkit ) {
-            _storageField.value += "|" + _fqstates.join( "," );
-        }
-    }
-
-    /**
-     * Sets the new currentState attribute of all modules depending on the new
-     * fully qualified state. Also notifies the modules which current state has
-     * changed.
-     *
-     * @method _handleFQStateChange
-     * @param {string} fqstate Fully qualified state
-     * @private
-     */
-    function _handleFQStateChange( fqstate ) {
-
-        var i;
-        var len;
-        var moduleName;
-        var moduleObj;
-        var modules;
-        var states;
-        var tokens;
-        var currentState;
-
-        if ( !fqstate ) {
-            // Notifies all modules
-            for ( moduleName in _modules ) {
-                if ( YAHOO.lang.hasOwnProperty( _modules, moduleName ) ) {
-                    moduleObj = _modules[moduleName];
-                    moduleObj.currentState = moduleObj.initialState;
-                    moduleObj.onStateChange( unescape( moduleObj.currentState ) );
-                }
-            }
-            return;
-        }
-
-        modules = [];
-        states = fqstate.split( "&" );
-        for ( i = 0, len = states.length ; i < len ; i++ ) {
-            tokens = states[i].split( "=" );
-            if ( tokens.length === 2 ) {
-                moduleName = tokens[0];
-                currentState = tokens[1];
-                modules[moduleName] = currentState;
-            }
-        }
-
-        for ( moduleName in _modules ) {
-            if ( YAHOO.lang.hasOwnProperty( _modules, moduleName ) ) {
-                moduleObj = _modules[moduleName];
-                currentState = modules[moduleName];
-                if ( !currentState || moduleObj.currentState !== currentState ) {
-                    moduleObj.currentState = currentState || moduleObj.initialState;
-                    moduleObj.onStateChange( unescape( moduleObj.currentState ) );
-                }
-            }
-        }
-    }
-
-    /**
-     * Periodically checks whether our internal IFrame is ready to be used.
-     *
-     * @method _checkIframeLoaded
-     * @private
-     */
-    function _checkIframeLoaded() {
-
-        var doc;
-        var elem;
-        var fqstate;
-
-        if ( !_iframe.contentWindow || !_iframe.contentWindow.document ) {
-            // Check again in 10 msec...
-            setTimeout( _checkIframeLoaded, 10 );
-            return;
-        }
-
-        // Start the thread that will have the responsibility to
-        // periodically check whether a navigate operation has been
-        // requested on the main window. This will happen when
-        // YAHOO.util.History.navigate has been called or after
-        // the user has hit the back/forward button.
-
-        doc = _iframe.contentWindow.document;
-        elem = doc.getElementById( "state" );
-        // We must use innerText, and not innerHTML because our string contains
-        // the "&" character (which would end up being escaped as "&amp;") and
-        // the string comparison would fail...
-        fqstate = elem ? elem.innerText : null;
-
-        setInterval( function () {
-
-            var newfqstate;
-            var hash;
-            var states;
-            var moduleName;
-            var moduleObj;
-
-            doc = _iframe.contentWindow.document;
-            elem = doc.getElementById( "state" );
-            // See my comment above about using innerText instead of innerHTML...
-            newfqstate = elem ? elem.innerText : null;
-
-            if ( newfqstate !== fqstate ) {
-                fqstate = newfqstate;
-                _handleFQStateChange( fqstate );
-
-                if ( !fqstate ) {
-                    states = [];
-                    for ( moduleName in _modules ) {
-                        if ( YAHOO.lang.hasOwnProperty( _modules, moduleName ) ) {
-                            moduleObj = _modules[moduleName];
-                            states.push( moduleName + "=" + moduleObj.initialState );
-                        }
-                    }
-                    hash = states.join( "&" );
-                } else {
-                    hash = fqstate;
-                }
-
-                // Allow the state to be bookmarked by setting the top window's
-                // URL fragment identifier. Note that here, we are on IE, and
-                // IE does not touch the browser history when setting the hash
-                // (unlike all the other browsers). I used to write:
-                //     top.location.replace( "#" + hash );
-                // but this had a side effect when the page was not the top frame.
-                top.location.hash = hash;
-
-                _storeStates();
-            }
-        }, 50 );
-
-        _bhmReady = true;
-
-        YAHOO.util.History.onLoadEvent.fire();
-    }
-
-    /**
-     * Finish up the initialization of the Browser History Manager.
-     *
-     * @method _initialize
-     * @private
-     */
-    function _initialize() {
-
-        var i;
-        var len;
-        var parts;
-        var tokens;
-        var moduleName;
-        var moduleObj;
-        var initialStates;
-        var initialState;
-        var currentStates;
-        var currentState;
-        var counter;
-        var hash;
-
-        _storageField = document.getElementById( "yui_hist_field" );
-
-        // Decode the content of our storage field...
-        parts = _storageField.value.split( "|" );
-
-        if ( parts.length > 1 ) {
-
-            initialStates = parts[0].split( "&" );
-            for ( i = 0, len = initialStates.length ; i < len ; i++ ) {
-                tokens = initialStates[i].split( "=" );
-                if ( tokens.length === 2 ) {
-                    moduleName = tokens[0];
-                    initialState = tokens[1];
-                    moduleObj = _modules[moduleName];
-                    if ( moduleObj ) {
-                        moduleObj.initialState = initialState;
-                    }
-                }
-            }
-
-            currentStates = parts[1].split( "&" );
-            for ( i = 0, len = currentStates.length ; i < len ; i++ ) {
-                tokens = currentStates[i].split( "=" );
-                if ( tokens.length >= 2 ) {
-                    moduleName = tokens[0];
-                    currentState = tokens[1];
-                    moduleObj = _modules[moduleName];
-                    if ( moduleObj ) {
-                        moduleObj.currentState = currentState;
-                    }
-                }
-            }
-        }
-
-        if ( parts.length > 2 ) {
-            _fqstates = parts[2].split( "," );
-        }
-
-        _storageFieldReady = true;
-
-        if ( YAHOO.env.ua.ie ) {
-
-            _iframe = document.getElementById( "yui_hist_iframe" );
-            _checkIframeLoaded();
-
-        } else {
-
-            // Start the thread that will have the responsibility to
-            // periodically check whether a navigate operation has been
-            // requested on the main window. This will happen when
-            // YAHOO.util.History.navigate has been called or after
-            // the user has hit the back/forward button.
-
-            // On Safari 1.x and 2.0, the only way to catch a back/forward
-            // operation is to watch history.length... We basically exploit
-            // what I consider to be a bug (history.length is not supposed
-            // to change when going back/forward in the history...) This is
-            // why, in the following thread, we first compare the hash,
-            // because the hash thing will be fixed in the next major
-            // version of Safari. So even if they fix the history.length
-            // bug, all this will still work!
-            counter = history.length;
-
-            // On Gecko and Opera, we just need to watch the hash...
-            hash = _getHash();
-
-            setInterval( function () {
-
-                var state;
-                var newHash;
-                var newCounter;
-
-                newHash = _getHash();
-                newCounter = history.length;
-                if ( newHash !== hash ) {
-                    hash = newHash;
-                    counter = newCounter;
-                    _handleFQStateChange( hash );
-                    _storeStates();
-                } else if ( newCounter !== counter ) {
-                    // If we ever get here, we should be on Safari...
-                    hash = newHash;
-                    counter = newCounter;
-                    state = _fqstates[counter - 1];
-                    _handleFQStateChange( state );
-                    _storeStates();
-                }
-            }, 50 );
-
-            _bhmReady = true;
-
-            YAHOO.util.History.onLoadEvent.fire();
-        }
-    }
-
-    return {
-
-        /**
-         * Fired when the Browser History Manager is ready.
-         *
-         * @event onLoadEvent
-         */
-        onLoadEvent: new YAHOO.util.CustomEvent( "onLoad" ),
-
-        /**
-         * Registers a new module.
-         *
-         * @method register
-         * @param {string} module Non-empty string uniquely identifying the
-         *     module you wish to register.
-         * @param {string} initialState The initial state of the specified
-         *     module corresponding to its earliest history entry.
-         * @param {function} onStateChange Callback called when the
-         *     state of the specified module has changed.
-         * @param {object} obj An arbitrary object that will be passed as a
-         *     parameter to the handler.
-         * @param {boolean} override If true, the obj passed in becomes the
-         *     execution scope of the listener.
-         */
-        register: function ( module, initialState, onStateChange, obj, override ) {
-
-            var scope;
-            var wrappedFn;
-
-            if ( typeof module !== "string" || _trim( module ) === "" ||
-                 typeof initialState !== "string" ||
-                 typeof onStateChange !== "function" ) {
-                throw new Error( "Missing or invalid argument passed to YAHOO.util.History.register" );
-            }
-
-            if ( _modules[module] ) {
-                // Here, we used to throw an exception. However, users have
-                // complained about this behavior, so we now just return.
-                return;
-            }
-
-            // Note: A module CANNOT be registered after calling
-            // YAHOO.util.History.initialize. Indeed, we set the initial state
-            // of each registered module in YAHOO.util.History.initialize.
-            // If you could register a module after initializing the Browser
-            // History Manager, you would not read the correct state using
-            // YAHOO.util.History.getCurrentState when coming back to the
-            // page using the back button.
-            if ( _initialized ) {
-                throw new Error( "All modules must be registered before calling YAHOO.util.History.initialize" );
-            }
-
-            // Make sure the strings passed in do not contain our separators "," and "|"
-            module = escape( module );
-            initialState = escape( initialState );
-
-            // If the user chooses to override the scope, we use the
-            // custom object passed in as the execution scope.
-            scope = null;
-            if ( override === true ) {
-                scope = obj;
-            } else {
-                scope = override;
-            }
-
-            wrappedFn = function ( state ) {
-                return onStateChange.call( scope, state, obj );
-            };
-
-            _modules[module] = {
-                name: module,
-                initialState: initialState,
-                currentState: initialState,
-                onStateChange: wrappedFn
-            };
-        },
-
-        /**
-         * Initializes the Browser History Manager. Call this method
-         * from a script block located right after the opening body tag.
-         *
-         * @method initialize
-         * @param {string} iframeTarget Optional - Path to an existing
-         *     HTML document accessible from the same domain. If not
-         *     specified, defaults to "blank.html". This is only useful
-         *     if you use https.
-         * @public
-         */
-        initialize: function ( iframeTarget ) {
-
-            // Return if the browser history manager has already been initialized
-            if ( _initialized ) {
-                return;
-            }
-
-            if ( !iframeTarget ) {
-                iframeTarget = "blank.html";
-            }
-
-            if ( typeof iframeTarget !== "string" || _trim( iframeTarget ) === "" ) {
-                throw new Error( "Invalid argument passed to YAHOO.util.History.initialize" );
-            }
-
-            document.write( '<input type="hidden" id="yui_hist_field">' );
-
-            if ( YAHOO.env.ua.ie ) {
-                if ( location.protocol === "https:" ) {
-                    // If we use https, we MUST point the IFrame to a valid
-                    // document on the same server. If we don't, we will get
-                    // a warning (do you want to display non secure items?)
-                    document.write( '<iframe id="yui_hist_iframe" src="' + iframeTarget + '" style="position:absolute;visibility:hidden;"></iframe>' );
-                } else {
-                    // This trick allows us to do without having to download
-                    // the asset, saving one HTTP request...
-                    document.write( '<iframe id="yui_hist_iframe" src="javascript:document.open();document.write(&quot;' + new Date().getTime() + '&quot;);document.close();" style="position:absolute;visibility:hidden;"></iframe>' );
-                }
-            }
-
-            // We have to wait for the window's onload handler. Otherwise, our
-            // hidden form field will always be empty (i.e. the browser won't
-            // have had enough time to restore the session)
-            YAHOO.util.Event.addListener( window, "load", _initialize );
-
-            _initialized = true;
-        },
-
-        /**
-         * Call this method when you want to store a new entry in the browser's history.
-         *
-         * @method navigate
-         * @param {string} module Non-empty string representing your module.
-         * @param {string} state String representing the new state of the specified module.
-         * @return {boolean} Indicates whether the new state was successfully added to the history.
-         * @public
-         */
-        navigate: function ( module, state ) {
-
-            var currentStates;
-            var moduleName;
-            var moduleObj;
-            var currentState;
-            var states;
-
-            if ( typeof module !== "string" || typeof state !== "string" ) {
-                throw new Error( "Missing or invalid argument passed to YAHOO.util.History.navigate" );
-            }
-
-            states = {};
-            states[module] = state;
-
-            return YAHOO.util.History.multiNavigate( states );
-        },
-
-        /**
-         * Call this method when you want to store a new entry in the browser's history.
-         *
-         * @method multiNavigate
-         * @param {object} states Associative array of module-state pairs to set simultaneously.
-         * @return {boolean} Indicates whether the new state was successfully added to the history.
-         * @public
-         */
-        multiNavigate: function ( states ) {
-
-            var currentStates;
-            var moduleName;
-            var moduleObj;
-            var currentState;
-            var fqstate;
-            var html;
-            var doc;
-
-            if ( typeof states !== "object" ) {
-                throw new Error( "Missing or invalid argument passed to YAHOO.util.History.multiNavigate" );
-            }
-
-            if ( !_bhmReady ) {
-                throw new Error( "The Browser History Manager is not initialized" );
-            }
-
-            for ( moduleName in states ) {
-                if ( !_modules[moduleName] ) {
-                    throw new Error( "The following module has not been registered: " + moduleName );
-                }
-            }
-
-            // Generate our new full state string mod1=xxx&mod2=yyy
-            currentStates = [];
-
-            for ( moduleName in _modules ) {
-                if ( YAHOO.lang.hasOwnProperty( _modules, moduleName ) ) {
-                    moduleObj = _modules[moduleName];
-                    if ( YAHOO.lang.hasOwnProperty( states, moduleName ) ) {
-                        currentState = states[moduleName];
-                    } else {
-                        currentState = moduleObj.currentState;
-                    }
-
-                    // Make sure the strings passed in do not contain our separators "," and "|"
-                    moduleName = escape( moduleName );
-                    currentState = escape( currentState );
-
-                    currentStates.push( moduleName + "=" + currentState );
-                }
-            }
-
-            fqstate = currentStates.join( "&" );
-
-            if ( YAHOO.env.ua.ie ) {
-
-                html = '<html><body><div id="state">' + fqstate + '</div></body></html>';
-                try {
-                    doc = _iframe.contentWindow.document;
-                    doc.open();
-                    doc.write( html );
-                    doc.close();
-                } catch ( e ) {
-                    return false;
-                }
-
-            } else {
-
-                // Known bug: On Safari 1.x and 2.0, if you have tab browsing
-                // enabled, Safari will show an endless loading icon in the
-                // tab. This has apparently been fixed in recent WebKit builds.
-                // One work around found by Dav Glass is to submit a form that
-                // points to the same document. This indeed works on Safari 1.x
-                // and 2.0 but creates bigger problems on WebKit. So for now,
-                // we'll consider this an acceptable bug, and hope that Apple
-                // comes out with their next version of Safari very soon.
-                top.location.hash = fqstate;
-                if ( YAHOO.env.ua.webkit ) {
-                    // The following two lines are only useful for Safari 1.x
-                    // and 2.0. Recent nightly builds of WebKit do not require
-                    // that, but unfortunately, it is not easy to differentiate
-                    // between the two. Once Safari 2.0 departs the A-grade
-                    // list, we can remove the following two lines...
-                    _fqstates[history.length] = fqstate;
-                    _storeStates();
-                }
-
-            }
-
-            return true;
-        },
-
-        /**
-         * Returns the current state of the specified module.
-         *
-         * @method getCurrentState
-         * @param {string} module Non-empty string representing your module.
-         * @return {string} The current state of the specified module.
-         * @public
-         */
-        getCurrentState: function ( module ) {
-
-            var moduleObj;
-
-            if ( typeof module !== "string" ) {
-                throw new Error( "Missing or invalid argument passed to YAHOO.util.History.getCurrentState" );
-            }
-
-            if ( !_storageFieldReady ) {
-                throw new Error( "The Browser History Manager is not initialized" );
-            }
-
-            moduleObj = _modules[module];
-            if ( !moduleObj ) {
-                throw new Error( "No such registered module: " + module );
-            }
-
-            return unescape( moduleObj.currentState );
-        },
-
-        /**
-         * Returns the state of a module according to the URL fragment
-         * identifier. This method is useful to initialize your modules
-         * if your application was bookmarked from a particular state.
-         *
-         * @method getBookmarkedState
-         * @param {string} module Non-empty string representing your module.
-         * @return {string} The bookmarked state of the specified module.
-         * @public
-         */
-        getBookmarkedState: function ( module ) {
-
-            var i;
-            var len;
-            var hash;
-            var states;
-            var tokens;
-            var moduleName;
-
-            if ( typeof module !== "string" ) {
-                throw new Error( "Missing or invalid argument passed to YAHOO.util.History.getBookmarkedState" );
-            }
-
-            hash = top.location.hash.substr(1);
-            states = hash.split( "&" );
-            for ( i = 0, len = states.length ; i < len ; i++ ) {
-                tokens = states[i].split( "=" );
-                if ( tokens.length === 2 ) {
-                    moduleName = tokens[0];
-                    if ( moduleName === module ) {
-                        return unescape( tokens[1] );
-                    }
-                }
-            }
-
-            return null;
-        },
-
-        /**
-         * Returns the value of the specified query string parameter.
-         * This method is not used internally by the Browser History Manager.
-         * However, it is provided here as a helper since many applications
-         * using the Browser History Manager will want to read the value of
-         * url parameters to initialize themselves.
-         *
-         * @method getQueryStringParameter
-         * @param {string} paramName Name of the parameter we want to look up.
-         * @param {string} queryString Optional URL to look at. If not specified,
-         *     this method uses the URL in the address bar.
-         * @return {string} The value of the specified parameter, or null.
-         * @public
-         */
-        getQueryStringParameter: function ( paramName, url ) {
-
-            var i;
-            var len;
-            var idx;
-            var queryString;
-            var params;
-            var tokens;
-
-            url = url || top.location.href;
-
-            idx = url.indexOf( "?" );
-            queryString = idx >= 0 ? url.substr( idx + 1 ) : url;
-            params = queryString.split( "&" );
-
-            for ( i = 0, len = params.length ; i < len ; i++ ) {
-                tokens = params[i].split( "=" );
-                if ( tokens.length >= 2 ) {
-                    if ( tokens[0] === paramName ) {
-                        return unescape( tokens[1] );
-                    }
-                }
-            }
-
-            return null;
-        }
-
-    };
-
-} )();
-YAHOO.register("history", YAHOO.util.History, {version: "2.3.0", build: "442"});
diff --git a/lib/yui/history/history-beta-min.js b/lib/yui/history/history-beta-min.js
deleted file mode 100755 (executable)
index 46620ec..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-Copyright (c) 2007, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 2.3.0
-*/
-
-YAHOO.util.History=(function(){var _iframe=null;var _storageField=null;var _initialized=false;var _storageFieldReady=false;var _bhmReady=false;var _modules=[];var _fqstates=[];function _trim(str){return str.replace(/^\s*(\S*(\s+\S+)*)\s*$/,"$1");}
-function _getHash(){var href;var i;href=top.location.href;i=href.indexOf("#");return i>=0?href.substr(i+1):null;}
-function _storeStates(){var moduleName;var moduleObj;var initialStates=[];var currentStates=[];for(moduleName in _modules){if(YAHOO.lang.hasOwnProperty(_modules,moduleName)){moduleObj=_modules[moduleName];initialStates.push(moduleName+"="+moduleObj.initialState);currentStates.push(moduleName+"="+moduleObj.currentState);}}
-_storageField.value=initialStates.join("&")+"|"+currentStates.join("&");if(YAHOO.env.ua.webkit){_storageField.value+="|"+_fqstates.join(",");}}
-function _handleFQStateChange(fqstate){var i;var len;var moduleName;var moduleObj;var modules;var states;var tokens;var currentState;if(!fqstate){for(moduleName in _modules){if(YAHOO.lang.hasOwnProperty(_modules,moduleName)){moduleObj=_modules[moduleName];moduleObj.currentState=moduleObj.initialState;moduleObj.onStateChange(unescape(moduleObj.currentState));}}
-return;}
-modules=[];states=fqstate.split("&");for(i=0,len=states.length;i<len;i++){tokens=states[i].split("=");if(tokens.length===2){moduleName=tokens[0];currentState=tokens[1];modules[moduleName]=currentState;}}
-for(moduleName in _modules){if(YAHOO.lang.hasOwnProperty(_modules,moduleName)){moduleObj=_modules[moduleName];currentState=modules[moduleName];if(!currentState||moduleObj.currentState!==currentState){moduleObj.currentState=currentState||moduleObj.initialState;moduleObj.onStateChange(unescape(moduleObj.currentState));}}}}
-function _checkIframeLoaded(){var doc;var elem;var fqstate;if(!_iframe.contentWindow||!_iframe.contentWindow.document){setTimeout(_checkIframeLoaded,10);return;}
-doc=_iframe.contentWindow.document;elem=doc.getElementById("state");fqstate=elem?elem.innerText:null;setInterval(function(){var newfqstate;var hash;var states;var moduleName;var moduleObj;doc=_iframe.contentWindow.document;elem=doc.getElementById("state");newfqstate=elem?elem.innerText:null;if(newfqstate!==fqstate){fqstate=newfqstate;_handleFQStateChange(fqstate);if(!fqstate){states=[];for(moduleName in _modules){if(YAHOO.lang.hasOwnProperty(_modules,moduleName)){moduleObj=_modules[moduleName];states.push(moduleName+"="+moduleObj.initialState);}}
-hash=states.join("&");}else{hash=fqstate;}
-top.location.hash=hash;_storeStates();}},50);_bhmReady=true;YAHOO.util.History.onLoadEvent.fire();}
-function _initialize(){var i;var len;var parts;var tokens;var moduleName;var moduleObj;var initialStates;var initialState;var currentStates;var currentState;var counter;var hash;_storageField=document.getElementById("yui_hist_field");parts=_storageField.value.split("|");if(parts.length>1){initialStates=parts[0].split("&");for(i=0,len=initialStates.length;i<len;i++){tokens=initialStates[i].split("=");if(tokens.length===2){moduleName=tokens[0];initialState=tokens[1];moduleObj=_modules[moduleName];if(moduleObj){moduleObj.initialState=initialState;}}}
-currentStates=parts[1].split("&");for(i=0,len=currentStates.length;i<len;i++){tokens=currentStates[i].split("=");if(tokens.length>=2){moduleName=tokens[0];currentState=tokens[1];moduleObj=_modules[moduleName];if(moduleObj){moduleObj.currentState=currentState;}}}}
-if(parts.length>2){_fqstates=parts[2].split(",");}
-_storageFieldReady=true;if(YAHOO.env.ua.ie){_iframe=document.getElementById("yui_hist_iframe");_checkIframeLoaded();}else{counter=history.length;hash=_getHash();setInterval(function(){var state;var newHash;var newCounter;newHash=_getHash();newCounter=history.length;if(newHash!==hash){hash=newHash;counter=newCounter;_handleFQStateChange(hash);_storeStates();}else if(newCounter!==counter){hash=newHash;counter=newCounter;state=_fqstates[counter-1];_handleFQStateChange(state);_storeStates();}},50);_bhmReady=true;YAHOO.util.History.onLoadEvent.fire();}}
-return{onLoadEvent:new YAHOO.util.CustomEvent("onLoad"),register:function(module,initialState,onStateChange,obj,override){var scope;var wrappedFn;if(typeof module!=="string"||_trim(module)===""||typeof initialState!=="string"||typeof onStateChange!=="function"){throw new Error("Missing or invalid argument passed to YAHOO.util.History.register");}
-if(_modules[module]){return;}
-if(_initialized){throw new Error("All modules must be registered before calling YAHOO.util.History.initialize");}
-module=escape(module);initialState=escape(initialState);scope=null;if(override===true){scope=obj;}else{scope=override;}
-wrappedFn=function(state){return onStateChange.call(scope,state,obj);};_modules[module]={name:module,initialState:initialState,currentState:initialState,onStateChange:wrappedFn};},initialize:function(iframeTarget){if(_initialized){return;}
-if(!iframeTarget){iframeTarget="blank.html";}
-if(typeof iframeTarget!=="string"||_trim(iframeTarget)===""){throw new Error("Invalid argument passed to YAHOO.util.History.initialize");}
-document.write('<input type="hidden" id="yui_hist_field">');if(YAHOO.env.ua.ie){if(location.protocol==="https:"){document.write('<iframe id="yui_hist_iframe" src="'+iframeTarget+'" style="position:absolute;visibility:hidden;"></iframe>');}else{document.write('<iframe id="yui_hist_iframe" src="javascript:document.open();document.write(&quot;'+new Date().getTime()+'&quot;);document.close();" style="position:absolute;visibility:hidden;"></iframe>');}}
-YAHOO.util.Event.addListener(window,"load",_initialize);_initialized=true;},navigate:function(module,state){var currentStates;var moduleName;var moduleObj;var currentState;var states;if(typeof module!=="string"||typeof state!=="string"){throw new Error("Missing or invalid argument passed to YAHOO.util.History.navigate");}
-states={};states[module]=state;return YAHOO.util.History.multiNavigate(states);},multiNavigate:function(states){var currentStates;var moduleName;var moduleObj;var currentState;var fqstate;var html;var doc;if(typeof states!=="object"){throw new Error("Missing or invalid argument passed to YAHOO.util.History.multiNavigate");}
-if(!_bhmReady){throw new Error("The Browser History Manager is not initialized");}
-for(moduleName in states){if(!_modules[moduleName]){throw new Error("The following module has not been registered: "+moduleName);}}
-currentStates=[];for(moduleName in _modules){if(YAHOO.lang.hasOwnProperty(_modules,moduleName)){moduleObj=_modules[moduleName];if(YAHOO.lang.hasOwnProperty(states,moduleName)){currentState=states[moduleName];}else{currentState=moduleObj.currentState;}
-moduleName=escape(moduleName);currentState=escape(currentState);currentStates.push(moduleName+"="+currentState);}}
-fqstate=currentStates.join("&");if(YAHOO.env.ua.ie){html='<html><body><div id="state">'+fqstate+'</div></body></html>';try{doc=_iframe.contentWindow.document;doc.open();doc.write(html);doc.close();}catch(e){return false;}}else{top.location.hash=fqstate;if(YAHOO.env.ua.webkit){_fqstates[history.length]=fqstate;_storeStates();}}
-return true;},getCurrentState:function(module){var moduleObj;if(typeof module!=="string"){throw new Error("Missing or invalid argument passed to YAHOO.util.History.getCurrentState");}
-if(!_storageFieldReady){throw new Error("The Browser History Manager is not initialized");}
-moduleObj=_modules[module];if(!moduleObj){throw new Error("No such registered module: "+module);}
-return unescape(moduleObj.currentState);},getBookmarkedState:function(module){var i;var len;var hash;var states;var tokens;var moduleName;if(typeof module!=="string"){throw new Error("Missing or invalid argument passed to YAHOO.util.History.getBookmarkedState");}
-hash=top.location.hash.substr(1);states=hash.split("&");for(i=0,len=states.length;i<len;i++){tokens=states[i].split("=");if(tokens.length===2){moduleName=tokens[0];if(moduleName===module){return unescape(tokens[1]);}}}
-return null;},getQueryStringParameter:function(paramName,url){var i;var len;var idx;var queryString;var params;var tokens;url=url||top.location.href;idx=url.indexOf("?");queryString=idx>=0?url.substr(idx+1):url;params=queryString.split("&");for(i=0,len=params.length;i<len;i++){tokens=params[i].split("=");if(tokens.length>=2){if(tokens[0]===paramName){return unescape(tokens[1]);}}}
-return null;}};})();YAHOO.register("history",YAHOO.util.History,{version:"2.3.0",build:"442"});
\ No newline at end of file
diff --git a/lib/yui/history/history-beta.js b/lib/yui/history/history-beta.js
deleted file mode 100755 (executable)
index f3cf3b9..0000000
+++ /dev/null
@@ -1,768 +0,0 @@
-/*
-Copyright (c) 2007, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 2.3.0
-*/
-/**
- * The Browser History Manager provides the ability to use the
- * back/forward navigation buttons in a DHTML application. It also allows
- * a DHTML application to be bookmarked in a specific state.
- *
- * @module history
- * @requires yahoo,event
- * @namespace YAHOO.util
- * @title Browser History Manager
- * @experimental
- */
-
-/**
- * The History class provides the ability to use the back/forward navigation
- * buttons in a DHTML application. It also allows a DHTML application to
- * be bookmarked in a specific state.
- *
- * @class History
- * @constructor
- */
-YAHOO.util.History = ( function () {
-
-    /**
-     * Our hidden IFrame used to store the browsing history.
-     *
-     * @property _iframe
-     * @type HTMLIFrameElement
-     * @default null
-     * @private
-     */
-    var _iframe = null;
-
-    /**
-     * INPUT field (with type="hidden" or type="text") or TEXTAREA.
-     * This field keeps the value of the initial state, current state
-     * the list of all states across pages within a single browser session.
-     *
-     * @property _storageField
-     * @type HTMLInputElement|HTMLTextAreaElement
-     * @default null
-     * @private
-     */
-    var _storageField = null;
-
-    /**
-     * Flag used to tell whether YAHOO.util.History.initialize has been called.
-     *
-     * @property _initialized
-     * @type boolean
-     * @default false
-     * @private
-     */
-    var _initialized = false;
-
-    /**
-     * Flag used to tell whether the storage field is ready to be used.
-     *
-     * @property _storageFieldReady
-     * @type boolean
-     * @default false
-     * @private
-     */
-    var _storageFieldReady = false;
-
-    /**
-     * Flag used to tell whether the Browser History Manager is ready.
-     *
-     * @property _bhmReady
-     * @type boolean
-     * @default false
-     * @private
-     */
-    var _bhmReady = false;
-
-    /**
-     * List of registered modules.
-     *
-     * @property _modules
-     * @type array
-     * @default []
-     * @private
-     */
-    var _modules = [];
-
-    /**
-     * List of fully qualified states. This is used only by Safari.
-     *
-     * @property _fqstates
-     * @type array
-     * @default []
-     * @private
-     */
-    var _fqstates = [];
-
-    /**
-     * Trims a string.
-     *
-     * @method _trim
-     * @param {string} str The string to be trimmed.
-     * @return {string} The trimmed string
-     * @private
-     */
-    function _trim( str ) {
-        return str.replace( /^\s*(\S*(\s+\S+)*)\s*$/, "$1" );
-    }
-
-    /**
-     * location.hash is a bit buggy on Opera. I have seen instances where
-     * navigating the history using the back/forward buttons, and hence
-     * changing the URL, would not change location.hash. That's ok, the
-     * implementation of an equivalent is trivial.
-     *
-     * @method _getHash
-     * @return {string} The hash portion of the document's location
-     * @private
-     */
-    function _getHash() {
-
-        var href;
-        var i;
-
-        href = top.location.href;
-        i = href.indexOf( "#" );
-        return i >= 0 ? href.substr( i + 1 ) : null;
-    }
-
-    /**
-     * Stores all the registered modules' initial state and current state.
-     * On Safari, we also store all the fully qualified states visited by
-     * the application within a single browser session. The storage takes
-     * place in the form field specified during initialization.
-     *
-     * @method _storeStates
-     * @private
-     */
-    function _storeStates() {
-
-        var moduleName;
-        var moduleObj;
-        var initialStates = [];
-        var currentStates = [];
-
-        for ( moduleName in _modules ) {
-            if ( YAHOO.lang.hasOwnProperty( _modules, moduleName ) ) {
-                moduleObj = _modules[moduleName];
-                initialStates.push( moduleName + "=" + moduleObj.initialState );
-                currentStates.push( moduleName + "=" + moduleObj.currentState );
-            }
-        }
-
-        _storageField.value = initialStates.join( "&" ) + "|" + currentStates.join( "&" );
-
-        if ( YAHOO.env.ua.webkit ) {
-            _storageField.value += "|" + _fqstates.join( "," );
-        }
-    }
-
-    /**
-     * Sets the new currentState attribute of all modules depending on the new
-     * fully qualified state. Also notifies the modules which current state has
-     * changed.
-     *
-     * @method _handleFQStateChange
-     * @param {string} fqstate Fully qualified state
-     * @private
-     */
-    function _handleFQStateChange( fqstate ) {
-
-        var i;
-        var len;
-        var moduleName;
-        var moduleObj;
-        var modules;
-        var states;
-        var tokens;
-        var currentState;
-
-        if ( !fqstate ) {
-            // Notifies all modules
-            for ( moduleName in _modules ) {
-                if ( YAHOO.lang.hasOwnProperty( _modules, moduleName ) ) {
-                    moduleObj = _modules[moduleName];
-                    moduleObj.currentState = moduleObj.initialState;
-                    moduleObj.onStateChange( unescape( moduleObj.currentState ) );
-                }
-            }
-            return;
-        }
-
-        modules = [];
-        states = fqstate.split( "&" );
-        for ( i = 0, len = states.length ; i < len ; i++ ) {
-            tokens = states[i].split( "=" );
-            if ( tokens.length === 2 ) {
-                moduleName = tokens[0];
-                currentState = tokens[1];
-                modules[moduleName] = currentState;
-            }
-        }
-
-        for ( moduleName in _modules ) {
-            if ( YAHOO.lang.hasOwnProperty( _modules, moduleName ) ) {
-                moduleObj = _modules[moduleName];
-                currentState = modules[moduleName];
-                if ( !currentState || moduleObj.currentState !== currentState ) {
-                    moduleObj.currentState = currentState || moduleObj.initialState;
-                    moduleObj.onStateChange( unescape( moduleObj.currentState ) );
-                }
-            }
-        }
-    }
-
-    /**
-     * Periodically checks whether our internal IFrame is ready to be used.
-     *
-     * @method _checkIframeLoaded
-     * @private
-     */
-    function _checkIframeLoaded() {
-
-        var doc;
-        var elem;
-        var fqstate;
-
-        if ( !_iframe.contentWindow || !_iframe.contentWindow.document ) {
-            // Check again in 10 msec...
-            setTimeout( _checkIframeLoaded, 10 );
-            return;
-        }
-
-        // Start the thread that will have the responsibility to
-        // periodically check whether a navigate operation has been
-        // requested on the main window. This will happen when
-        // YAHOO.util.History.navigate has been called or after
-        // the user has hit the back/forward button.
-
-        doc = _iframe.contentWindow.document;
-        elem = doc.getElementById( "state" );
-        // We must use innerText, and not innerHTML because our string contains
-        // the "&" character (which would end up being escaped as "&amp;") and
-        // the string comparison would fail...
-        fqstate = elem ? elem.innerText : null;
-
-        setInterval( function () {
-
-            var newfqstate;
-            var hash;
-            var states;
-            var moduleName;
-            var moduleObj;
-
-            doc = _iframe.contentWindow.document;
-            elem = doc.getElementById( "state" );
-            // See my comment above about using innerText instead of innerHTML...
-            newfqstate = elem ? elem.innerText : null;
-
-            if ( newfqstate !== fqstate ) {
-                fqstate = newfqstate;
-                _handleFQStateChange( fqstate );
-
-                if ( !fqstate ) {
-                    states = [];
-                    for ( moduleName in _modules ) {
-                        if ( YAHOO.lang.hasOwnProperty( _modules, moduleName ) ) {
-                            moduleObj = _modules[moduleName];
-                            states.push( moduleName + "=" + moduleObj.initialState );
-                        }
-                    }
-                    hash = states.join( "&" );
-                } else {
-                    hash = fqstate;
-                }
-
-                // Allow the state to be bookmarked by setting the top window's
-                // URL fragment identifier. Note that here, we are on IE, and
-                // IE does not touch the browser history when setting the hash
-                // (unlike all the other browsers). I used to write:
-                //     top.location.replace( "#" + hash );
-                // but this had a side effect when the page was not the top frame.
-                top.location.hash = hash;
-
-                _storeStates();
-            }
-        }, 50 );
-
-        _bhmReady = true;
-
-        YAHOO.util.History.onLoadEvent.fire();
-    }
-
-    /**
-     * Finish up the initialization of the Browser History Manager.
-     *
-     * @method _initialize
-     * @private
-     */
-    function _initialize() {
-
-        var i;
-        var len;
-        var parts;
-        var tokens;
-        var moduleName;
-        var moduleObj;
-        var initialStates;
-        var initialState;
-        var currentStates;
-        var currentState;
-        var counter;
-        var hash;
-
-        _storageField = document.getElementById( "yui_hist_field" );
-
-        // Decode the content of our storage field...
-        parts = _storageField.value.split( "|" );
-
-        if ( parts.length > 1 ) {
-
-            initialStates = parts[0].split( "&" );
-            for ( i = 0, len = initialStates.length ; i < len ; i++ ) {
-                tokens = initialStates[i].split( "=" );
-                if ( tokens.length === 2 ) {
-                    moduleName = tokens[0];
-                    initialState = tokens[1];
-                    moduleObj = _modules[moduleName];
-                    if ( moduleObj ) {
-                        moduleObj.initialState = initialState;
-                    }
-                }
-            }
-
-            currentStates = parts[1].split( "&" );
-            for ( i = 0, len = currentStates.length ; i < len ; i++ ) {
-                tokens = currentStates[i].split( "=" );
-                if ( tokens.length >= 2 ) {
-                    moduleName = tokens[0];
-                    currentState = tokens[1];
-                    moduleObj = _modules[moduleName];
-                    if ( moduleObj ) {
-                        moduleObj.currentState = currentState;
-                    }
-                }
-            }
-        }
-
-        if ( parts.length > 2 ) {
-            _fqstates = parts[2].split( "," );
-        }
-
-        _storageFieldReady = true;
-
-        if ( YAHOO.env.ua.ie ) {
-
-            _iframe = document.getElementById( "yui_hist_iframe" );
-            _checkIframeLoaded();
-
-        } else {
-
-            // Start the thread that will have the responsibility to
-            // periodically check whether a navigate operation has been
-            // requested on the main window. This will happen when
-            // YAHOO.util.History.navigate has been called or after
-            // the user has hit the back/forward button.
-
-            // On Safari 1.x and 2.0, the only way to catch a back/forward
-            // operation is to watch history.length... We basically exploit
-            // what I consider to be a bug (history.length is not supposed
-            // to change when going back/forward in the history...) This is
-            // why, in the following thread, we first compare the hash,
-            // because the hash thing will be fixed in the next major
-            // version of Safari. So even if they fix the history.length
-            // bug, all this will still work!
-            counter = history.length;
-
-            // On Gecko and Opera, we just need to watch the hash...
-            hash = _getHash();
-
-            setInterval( function () {
-
-                var state;
-                var newHash;
-                var newCounter;
-
-                newHash = _getHash();
-                newCounter = history.length;
-                if ( newHash !== hash ) {
-                    hash = newHash;
-                    counter = newCounter;
-                    _handleFQStateChange( hash );
-                    _storeStates();
-                } else if ( newCounter !== counter ) {
-                    // If we ever get here, we should be on Safari...
-                    hash = newHash;
-                    counter = newCounter;
-                    state = _fqstates[counter - 1];
-                    _handleFQStateChange( state );
-                    _storeStates();
-                }
-            }, 50 );
-
-            _bhmReady = true;
-
-            YAHOO.util.History.onLoadEvent.fire();
-        }
-    }
-
-    return {
-
-        /**
-         * Fired when the Browser History Manager is ready.
-         *
-         * @event onLoadEvent
-         */
-        onLoadEvent: new YAHOO.util.CustomEvent( "onLoad" ),
-
-        /**
-         * Registers a new module.
-         *
-         * @method register
-         * @param {string} module Non-empty string uniquely identifying the
-         *     module you wish to register.
-         * @param {string} initialState The initial state of the specified
-         *     module corresponding to its earliest history entry.
-         * @param {function} onStateChange Callback called when the
-         *     state of the specified module has changed.
-         * @param {object} obj An arbitrary object that will be passed as a
-         *     parameter to the handler.
-         * @param {boolean} override If true, the obj passed in becomes the
-         *     execution scope of the listener.
-         */
-        register: function ( module, initialState, onStateChange, obj, override ) {
-
-            var scope;
-            var wrappedFn;
-
-            if ( typeof module !== "string" || _trim( module ) === "" ||
-                 typeof initialState !== "string" ||
-                 typeof onStateChange !== "function" ) {
-                throw new Error( "Missing or invalid argument passed to YAHOO.util.History.register" );
-            }
-
-            if ( _modules[module] ) {
-                // Here, we used to throw an exception. However, users have
-                // complained about this behavior, so we now just return.
-                return;
-            }
-
-            // Note: A module CANNOT be registered after calling
-            // YAHOO.util.History.initialize. Indeed, we set the initial state
-            // of each registered module in YAHOO.util.History.initialize.
-            // If you could register a module after initializing the Browser
-            // History Manager, you would not read the correct state using
-            // YAHOO.util.History.getCurrentState when coming back to the
-            // page using the back button.
-            if ( _initialized ) {
-                throw new Error( "All modules must be registered before calling YAHOO.util.History.initialize" );
-            }
-
-            // Make sure the strings passed in do not contain our separators "," and "|"
-            module = escape( module );
-            initialState = escape( initialState );
-
-            // If the user chooses to override the scope, we use the
-            // custom object passed in as the execution scope.
-            scope = null;
-            if ( override === true ) {
-                scope = obj;
-            } else {
-                scope = override;
-            }
-
-            wrappedFn = function ( state ) {
-                return onStateChange.call( scope, state, obj );
-            };
-
-            _modules[module] = {
-                name: module,
-                initialState: initialState,
-                currentState: initialState,
-                onStateChange: wrappedFn
-            };
-        },
-
-        /**
-         * Initializes the Browser History Manager. Call this method
-         * from a script block located right after the opening body tag.
-         *
-         * @method initialize
-         * @param {string} iframeTarget Optional - Path to an existing
-         *     HTML document accessible from the same domain. If not
-         *     specified, defaults to "blank.html". This is only useful
-         *     if you use https.
-         * @public
-         */
-        initialize: function ( iframeTarget ) {
-
-            // Return if the browser history manager has already been initialized
-            if ( _initialized ) {
-                return;
-            }
-
-            if ( !iframeTarget ) {
-                iframeTarget = "blank.html";
-            }
-
-            if ( typeof iframeTarget !== "string" || _trim( iframeTarget ) === "" ) {
-                throw new Error( "Invalid argument passed to YAHOO.util.History.initialize" );
-            }
-
-            document.write( '<input type="hidden" id="yui_hist_field">' );
-
-            if ( YAHOO.env.ua.ie ) {
-                if ( location.protocol === "https:" ) {
-                    // If we use https, we MUST point the IFrame to a valid
-                    // document on the same server. If we don't, we will get
-                    // a warning (do you want to display non secure items?)
-                    document.write( '<iframe id="yui_hist_iframe" src="' + iframeTarget + '" style="position:absolute;visibility:hidden;"></iframe>' );
-                } else {
-                    // This trick allows us to do without having to download
-                    // the asset, saving one HTTP request...
-                    document.write( '<iframe id="yui_hist_iframe" src="javascript:document.open();document.write(&quot;' + new Date().getTime() + '&quot;);document.close();" style="position:absolute;visibility:hidden;"></iframe>' );
-                }
-            }
-
-            // We have to wait for the window's onload handler. Otherwise, our
-            // hidden form field will always be empty (i.e. the browser won't
-            // have had enough time to restore the session)
-            YAHOO.util.Event.addListener( window, "load", _initialize );
-
-            _initialized = true;
-        },
-
-        /**
-         * Call this method when you want to store a new entry in the browser's history.
-         *
-         * @method navigate
-         * @param {string} module Non-empty string representing your module.
-         * @param {string} state String representing the new state of the specified module.
-         * @return {boolean} Indicates whether the new state was successfully added to the history.
-         * @public
-         */
-        navigate: function ( module, state ) {
-
-            var currentStates;
-            var moduleName;
-            var moduleObj;
-            var currentState;
-            var states;
-
-            if ( typeof module !== "string" || typeof state !== "string" ) {
-                throw new Error( "Missing or invalid argument passed to YAHOO.util.History.navigate" );
-            }
-
-            states = {};
-            states[module] = state;
-
-            return YAHOO.util.History.multiNavigate( states );
-        },
-
-        /**
-         * Call this method when you want to store a new entry in the browser's history.
-         *
-         * @method multiNavigate
-         * @param {object} states Associative array of module-state pairs to set simultaneously.
-         * @return {boolean} Indicates whether the new state was successfully added to the history.
-         * @public
-         */
-        multiNavigate: function ( states ) {
-
-            var currentStates;
-            var moduleName;
-            var moduleObj;
-            var currentState;
-            var fqstate;
-            var html;
-            var doc;
-
-            if ( typeof states !== "object" ) {
-                throw new Error( "Missing or invalid argument passed to YAHOO.util.History.multiNavigate" );
-            }
-
-            if ( !_bhmReady ) {
-                throw new Error( "The Browser History Manager is not initialized" );
-            }
-
-            for ( moduleName in states ) {
-                if ( !_modules[moduleName] ) {
-                    throw new Error( "The following module has not been registered: " + moduleName );
-                }
-            }
-
-            // Generate our new full state string mod1=xxx&mod2=yyy
-            currentStates = [];
-
-            for ( moduleName in _modules ) {
-                if ( YAHOO.lang.hasOwnProperty( _modules, moduleName ) ) {
-                    moduleObj = _modules[moduleName];
-                    if ( YAHOO.lang.hasOwnProperty( states, moduleName ) ) {
-                        currentState = states[moduleName];
-                    } else {
-                        currentState = moduleObj.currentState;
-                    }
-
-                    // Make sure the strings passed in do not contain our separators "," and "|"
-                    moduleName = escape( moduleName );
-                    currentState = escape( currentState );
-
-                    currentStates.push( moduleName + "=" + currentState );
-                }
-            }
-
-            fqstate = currentStates.join( "&" );
-
-            if ( YAHOO.env.ua.ie ) {
-
-                html = '<html><body><div id="state">' + fqstate + '</div></body></html>';
-                try {
-                    doc = _iframe.contentWindow.document;
-                    doc.open();
-                    doc.write( html );
-                    doc.close();
-                } catch ( e ) {
-                    return false;
-                }
-
-            } else {
-
-                // Known bug: On Safari 1.x and 2.0, if you have tab browsing
-                // enabled, Safari will show an endless loading icon in the
-                // tab. This has apparently been fixed in recent WebKit builds.
-                // One work around found by Dav Glass is to submit a form that
-                // points to the same document. This indeed works on Safari 1.x
-                // and 2.0 but creates bigger problems on WebKit. So for now,
-                // we'll consider this an acceptable bug, and hope that Apple
-                // comes out with their next version of Safari very soon.
-                top.location.hash = fqstate;
-                if ( YAHOO.env.ua.webkit ) {
-                    // The following two lines are only useful for Safari 1.x
-                    // and 2.0. Recent nightly builds of WebKit do not require
-                    // that, but unfortunately, it is not easy to differentiate
-                    // between the two. Once Safari 2.0 departs the A-grade
-                    // list, we can remove the following two lines...
-                    _fqstates[history.length] = fqstate;
-                    _storeStates();
-                }
-
-            }
-
-            return true;
-        },
-
-        /**
-         * Returns the current state of the specified module.
-         *
-         * @method getCurrentState
-         * @param {string} module Non-empty string representing your module.
-         * @return {string} The current state of the specified module.
-         * @public
-         */
-        getCurrentState: function ( module ) {
-
-            var moduleObj;
-
-            if ( typeof module !== "string" ) {
-                throw new Error( "Missing or invalid argument passed to YAHOO.util.History.getCurrentState" );
-            }
-
-            if ( !_storageFieldReady ) {
-                throw new Error( "The Browser History Manager is not initialized" );
-            }
-
-            moduleObj = _modules[module];
-            if ( !moduleObj ) {
-                throw new Error( "No such registered module: " + module );
-            }
-
-            return unescape( moduleObj.currentState );
-        },
-
-        /**
-         * Returns the state of a module according to the URL fragment
-         * identifier. This method is useful to initialize your modules
-         * if your application was bookmarked from a particular state.
-         *
-         * @method getBookmarkedState
-         * @param {string} module Non-empty string representing your module.
-         * @return {string} The bookmarked state of the specified module.
-         * @public
-         */
-        getBookmarkedState: function ( module ) {
-
-            var i;
-            var len;
-            var hash;
-            var states;
-            var tokens;
-            var moduleName;
-
-            if ( typeof module !== "string" ) {
-                throw new Error( "Missing or invalid argument passed to YAHOO.util.History.getBookmarkedState" );
-            }
-
-            hash = top.location.hash.substr(1);
-            states = hash.split( "&" );
-            for ( i = 0, len = states.length ; i < len ; i++ ) {
-                tokens = states[i].split( "=" );
-                if ( tokens.length === 2 ) {
-                    moduleName = tokens[0];
-                    if ( moduleName === module ) {
-                        return unescape( tokens[1] );
-                    }
-                }
-            }
-
-            return null;
-        },
-
-        /**
-         * Returns the value of the specified query string parameter.
-         * This method is not used internally by the Browser History Manager.
-         * However, it is provided here as a helper since many applications
-         * using the Browser History Manager will want to read the value of
-         * url parameters to initialize themselves.
-         *
-         * @method getQueryStringParameter
-         * @param {string} paramName Name of the parameter we want to look up.
-         * @param {string} queryString Optional URL to look at. If not specified,
-         *     this method uses the URL in the address bar.
-         * @return {string} The value of the specified parameter, or null.
-         * @public
-         */
-        getQueryStringParameter: function ( paramName, url ) {
-
-            var i;
-            var len;
-            var idx;
-            var queryString;
-            var params;
-            var tokens;
-
-            url = url || top.location.href;
-
-            idx = url.indexOf( "?" );
-            queryString = idx >= 0 ? url.substr( idx + 1 ) : url;
-            params = queryString.split( "&" );
-
-            for ( i = 0, len = params.length ; i < len ; i++ ) {
-                tokens = params[i].split( "=" );
-                if ( tokens.length >= 2 ) {
-                    if ( tokens[0] === paramName ) {
-                        return unescape( tokens[1] );
-                    }
-                }
-            }
-
-            return null;
-        }
-
-    };
-
-} )();
-YAHOO.register("history", YAHOO.util.History, {version: "2.3.0", build: "442"});
diff --git a/lib/yui/imageloader/imageloader-experimental-debug.js b/lib/yui/imageloader/imageloader-experimental-debug.js
deleted file mode 100755 (executable)
index 55b85c5..0000000
+++ /dev/null
@@ -1,442 +0,0 @@
-/*
-Copyright (c) 2007, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 2.3.0
-*/
-/**
- * The image loader is a framework to dynamically load images
- * according to certain triggers, enabling faster load times
- * and a more responsive UI.
- *
- * @module imageloader
- * @namespace YAHOO.util
- * @experimental
- */
-
-if (typeof(YAHOO.util.ImageLoader) == 'undefined') {
-       YAHOO.util.ImageLoader = {};
-}
-
-/**
- * A group for images. A group can have one time limit and a series of triggers. Thus the images belonging to this group must share these constraints.
- * @class YAHOO.util.ImageLoader.group
- * @requires YAHOO.util.Dom
- * @requires YAHOO.util.Event
- * @constructor
- * @param {String|HTMLElement} trigEl  The HTML element id or reference to assign the trigger event to. Can be null for no trigger
- * @param {String}     trigAct The type of event to assign to trigEl. Can be null for no trigger
- * @param {Number}     timeout Timeout (time limit) length, in seconds. Can be undefined, or <= 0, for no time limit
- */
-YAHOO.util.ImageLoader.group = function(trigEl, trigAct, timeout) {
-       /**
-        * Name for the group. Only used to identify the group in logging statements
-        * @property name
-        * @type String
-        */
-       this.name = 'unnamed';
-       
-       /**
-        * Collection of images registered with this group
-        * @property _imgObjs
-        * @private
-        * @type Object
-        */
-       this._imgObjs = {};
-       
-       /**
-        * Timeout (time limit) length, in seconds
-        * @property timeoutLen
-        * @type Number
-        */
-       this.timeoutLen = timeout;
-       
-       /**
-        * Timeout object to keep a handle on the time limit
-        * @property _timeout
-        * @private
-        * @type Object
-        */
-       this._timeout = null;
-       
-       /**
-        * Collection of triggers for this group.
-        * Keeps track of each trigger's element, event, and event-listener-callback "fetch" function
-        * @property _triggers
-        * @private
-        * @type Array
-        */
-       this._triggers = [];
-
-       /**
-        * Flag to check if images are above the fold. If foldConditional is true, the group will check each of its image locations at page load. If any part of the image is within the client viewport, the image is displayed immediately
-        * @property foldConditional
-        * @type Boolean
-        */
-       this.foldConditional = false;
-
-       /**
-        * Class name that will identify images belonging to the group. This class name will be removed from each element in order to fetch images.
-        * This class should have, in its CSS style definition, "background:none !important;"
-        * @property className
-        * @type String
-        */
-       this.className = null;
-
-       /**
-        * HTML elements having the class name that is associated with this group
-        * Elements are stored during the _foldCheck function and reused later during the fetch function. Gives a slight performance improvement when className and foldConditional are both used
-        * @property _classImageEls
-        * @private
-        * @type Array
-        */
-       this._classImageEls = null;
-
-       // add a listener to set the time limit in the onload
-       YAHOO.util.Event.addListener(window, 'load', this._onloadTasks, this, true);
-       // add the trigger
-       this.addTrigger(trigEl, trigAct);
-
-};
-
-/**
- * Adds a trigger to the group. Call this with the same style as YAHOO.util.Event.addListener
- * @method addTrigger
- * @param {String|HTMLElement} trigEl  The HTML element id or reference to assign the trigger event to
- * @param {String} trigAct The type of event to assign to trigEl
- */
-YAHOO.util.ImageLoader.group.prototype.addTrigger = function(trigEl, trigAct) {
-       if (! trigEl || ! trigAct) {
-               return;
-       }
-       /* Need to wrap the fetch function. Event Util can't distinguish prototyped functions of different instantiations
-        *   Leads to this scenario: groupA and groupZ both have window-scroll triggers. groupZ also has a 2-sec timeout (groupA has no timeout).
-        *   groupZ's timeout fires; we remove the triggers. The removeListener call finds the first window-scroll event with Y.u.IL.p.fetch, which is groupA's. 
-        *   groupA's trigger is removed and never fires, leaving images unfetched
-        */
-       var wrappedFetch = function() {
-               this.fetch();
-       };
-       this._triggers.push([trigEl, trigAct, wrappedFetch]);
-       YAHOO.util.Event.addListener(trigEl, trigAct, wrappedFetch, this, true);
-};
-
-/**
- * Setup to do in the window's onload
- * Initiates time limit for group; executes the fold check for the images
- * @method _onloadTasks
- * @private
- */
-YAHOO.util.ImageLoader.group.prototype._onloadTasks = function() {
-       if (this.timeoutLen && typeof(this.timeoutLen) == 'number' && this.timeoutLen > 0) {
-               this._timeout = setTimeout(this._getFetchTimeout(), this.timeoutLen * 1000);
-       }
-
-       if (this.foldConditional) {
-               this._foldCheck();
-       }
-};
-
-/**
- * Returns the group's fetch method, with the proper closure, for use with setTimeout
- * @method _getFetchTimeout
- * @return {Function}  group's fetch method
- * @private
- */
-YAHOO.util.ImageLoader.group.prototype._getFetchTimeout = function() {
-       var self = this;
-       return function() { self.fetch(); };
-};
-
-/**
- * Registers a background image with the group
- * @method registerBgImage
- * @param {String}     domId   HTML DOM id of the image element
- * @param {String}     url     URL for the image
- * @return {Object}    bgImgObj that was registered, for modifying any attributes in the object
- */
-YAHOO.util.ImageLoader.group.prototype.registerBgImage = function(domId, url) {
-       this._imgObjs[domId] = new YAHOO.util.ImageLoader.bgImgObj(domId, url);
-       return this._imgObjs[domId];
-};
-/**
- * Registers a src image with the group
- * @method registerSrcImage
- * @param {String}     domId   HTML DOM id of the image element
- * @param {String}     url     URL for the image
- * @param {Int}        width   pixel width of the image - defaults to image's natural size
- * @param {Int}        height  pixel height of the image - defaults to image's natural size
- * @return {Object}    srcImgObj that was registered, for modifying any attributes in the object
- */
-YAHOO.util.ImageLoader.group.prototype.registerSrcImage = function(domId, url, width, height) {
-       this._imgObjs[domId] = new YAHOO.util.ImageLoader.srcImgObj(domId, url, width, height);
-       return this._imgObjs[domId];
-};
-/**
- * Registers an alpha-channel-type png background image with the group
- * @method registerPngBgImage
- * @param {String}     domId   HTML DOM id of the image element
- * @param {String}     url     URL for the image
- * @return {Object}    pngBgImgObj that was registered, for modifying any attributes in the object
- */
-YAHOO.util.ImageLoader.group.prototype.registerPngBgImage = function(domId, url) {
-       this._imgObjs[domId] = new YAHOO.util.ImageLoader.pngBgImgObj(domId, url);
-       return this._imgObjs[domId];
-};
-
-/**
- * Displays the images in the group
- * @method fetch
- */
-YAHOO.util.ImageLoader.group.prototype.fetch = function() {
-       YAHOO.log('Fetching images in group: "' + this.name + '".', 'info', 'imageloader');
-
-       clearTimeout(this._timeout);
-       // remove all listeners
-       for (var i=0; i < this._triggers.length; i++) {
-               YAHOO.util.Event.removeListener(this._triggers[i][0], this._triggers[i][1], this._triggers[i][2]);
-       }
-
-       // fetch whatever we need to by className
-       this._fetchByClass();
-
-       // fetch registered images
-       for (var id in this._imgObjs) {
-               if (YAHOO.lang.hasOwnProperty(this._imgObjs, id)) {
-                       this._imgObjs[id].fetch();
-               }
-       }
-};
-
-/**
- * Checks the position of each image in the group. If any part of the image is within the client viewport, shows the image immediately.
- * @method _foldCheck
- * @private
- */
-YAHOO.util.ImageLoader.group.prototype._foldCheck = function() {
-       YAHOO.log('Checking for images above the fold in group: "' + this.name + '"', 'info', 'imageloader');
-       var scrollTop = (document.compatMode != 'CSS1Compat') ? document.body.scrollTop : document.documentElement.scrollTop;
-       var viewHeight = YAHOO.util.Dom.getViewportHeight();
-       var hLimit = scrollTop + viewHeight;
-       var scrollLeft = (document.compatMode != 'CSS1Compat') ? document.body.scrollLeft : document.documentElement.scrollLeft;
-       var viewWidth = YAHOO.util.Dom.getViewportWidth();
-       var wLimit = scrollLeft + viewWidth;
-       for (var id in this._imgObjs) {
-               if (YAHOO.lang.hasOwnProperty(this._imgObjs, id)) {
-                       var elPos = YAHOO.util.Dom.getXY(this._imgObjs[id].domId);
-                       if (elPos[1] < hLimit && elPos[0] < wLimit) {
-                               YAHOO.log('Image with id "' + this._imgObjs[id].domId + '" is above the fold. Fetching image.', 'info', 'imageloader');
-                               this._imgObjs[id].fetch();
-                       }
-               }
-       }
-       // and by class
-       if (this.className) {
-               this._classImageEls = YAHOO.util.Dom.getElementsByClassName(this.className);
-               for (var i=0; i < this._classImageEls.length; i++) {
-                       var elPos = YAHOO.util.Dom.getXY(this._classImageEls[i]);
-                       if (elPos[1] < hLimit && elPos[0] < wLimit) {
-                               YAHOO.log('Image with id "' + this._classImageEls[i].id + '" is above the fold. Fetching image. (Image registered by class name with the group - may not have an id.)', 'info', 'imageloader');
-                               YAHOO.util.Dom.removeClass(this._classImageEls[i], this.className);
-                       }
-               }
-       }
-};
-
-/**
- * Finds all elements in the Dom with the class name specified in the group. Removes the class from the element in order to let the style definitions trigger the image fetching
- * @method _fetchByClass
- * @private
- */
-YAHOO.util.ImageLoader.group.prototype._fetchByClass = function() {
-       if (! this.className) {
-               return;
-       }
-
-       YAHOO.log('Fetching all images with class "' + this.className + '" in group "' + this.name + '".', 'info', 'imageloader');
-       // this._classImageEls may have been set during _foldCheck
-       if (this._classImageEls === null) {
-               this._classImageEls = YAHOO.util.Dom.getElementsByClassName(this.className);
-       }
-       YAHOO.util.Dom.removeClass(this._classImageEls, this.className);
-};
-
-
-/**
- * Base class for image objects to be registered with the groups
- * @class YAHOO.util.ImageLoader.imgObj
- * @constructor
- * @param {String}     domId   HTML DOM id of the image element
- * @param {String}     url     URL for the image
- */
-YAHOO.util.ImageLoader.imgObj = function(domId, url) {
-       /**
-        * HTML DOM id of the image element
-        * @property domId
-        * @type String
-        */
-       this.domId = domId;
-
-       /**
-        * URL for the image
-        * @property url
-        * @type String
-        */
-       this.url = url;
-
-       /**
-        * Pixel width of the image. Will be set as a "width" attribute after the image is fetched.
-        * Detaults to the natural width of the image.
-        * Only appropriate with src images
-        * @property width
-        * @type Int
-        */
-       this.width = null;
-
-       /**
-        * Pixel height of the image. Will be set as a "height" attribute after the image is fetched.
-        * Detaults to the natural height of the image.
-        * Only appropriate with src images
-        * @property height
-        * @type Int
-        */
-       this.height = null;
-
-       /**
-        * Whether the style.visibility should be set to "visible" after the image is fetched.
-        * Used when setting src images as visibility:hidden prior to image fetching
-        * @property setVisible
-        * @type Boolean
-        */
-       this.setVisible = false;
-
-       /**
-        * Whether the image has already been fetched. In the case of a foldCondional group, keeps track for when the trigger is fired so images aren't fetched twice
-        * @property _fetched
-        * @type Boolean
-        * @private
-        */
-       this._fetched = false;
-};
-
-/**
- * Displays the image; puts the URL into the DOM
- * @method fetch
- */
-YAHOO.util.ImageLoader.imgObj.prototype.fetch = function() {
-       if (this._fetched) {
-               return;
-       }
-       var el = document.getElementById(this.domId);
-       if (! el) {
-               return;
-       }
-       YAHOO.log('Fetching image with id "' + this.domId + '".', 'info', 'imageloader');
-       this._applyUrl(el);
-
-       if (this.setVisible) {
-               el.style.visibility = 'visible';
-       }
-       if (this.width) {
-               el.width = this.width;
-       }
-       if (this.height) {
-               el.height = this.height;
-       }
-       this._fetched = true;
-};
-
-/**
- * Inserts the image URL into the DOM so that the image is displayed.
- * Must be overridden by child class
- * @method _applyUrl
- * @param {Object}     el      HTML DOM element
- * @private
- */
-YAHOO.util.ImageLoader.imgObj.prototype._applyUrl = function(el) {
-};
-
-/**
- * Background image object. A background image is one whose URL is specified by "background-image" in the element's style
- * @class YAHOO.util.ImageLoader.bgImgObj
- * @constructor
- * @extends YAHOO.util.ImageLoader.imgObj
- * @param {String}     domId   HTML DOM id of the image element
- * @param {String}     url     URL for the image
- */
-YAHOO.util.ImageLoader.bgImgObj = function(domId, url) {
-       YAHOO.util.ImageLoader.bgImgObj.superclass.constructor.call(this, domId, url);
-};
-
-YAHOO.lang.extend(YAHOO.util.ImageLoader.bgImgObj, YAHOO.util.ImageLoader.imgObj);
-
-/**
- * Inserts the image URL into the DOM so that the image is displayed.
- * Sets style.backgroundImage
- * @method _applyUrl
- * @param {Object}     el      HTML DOM element
- * @private
- */
-YAHOO.util.ImageLoader.bgImgObj.prototype._applyUrl = function(el) {
-       el.style.backgroundImage = "url('" + this.url + "')";
-};
-
-/**
- * Source image object. A source image is one whose URL is specified by a src attribute in the DOM element
- * @class YAHOO.util.ImageLoader.srcImgObj
- * @constructor
- * @extends YAHOO.util.ImageLoader.imgObj
- * @param {String}     domId   HTML DOM id of the image element
- * @param {String}     url     URL for the image
- * @param {Int}        width   pixel width of the image - defaults to image's natural size
- * @param {Int}        height  pixel height of the image - defaults to image's natural size
- */
-YAHOO.util.ImageLoader.srcImgObj = function(domId, url, width, height) {
-       YAHOO.util.ImageLoader.srcImgObj.superclass.constructor.call(this, domId, url);
-       this.width = width;
-       this.height = height;
-};
-
-YAHOO.lang.extend(YAHOO.util.ImageLoader.srcImgObj, YAHOO.util.ImageLoader.imgObj);
-
-/**
- * Inserts the image URL into the DOM so that the image is displayed.
- * Sets src
- * @method _applyUrl
- * @param {Object}     el      HTML DOM element
- * @private
- */
-YAHOO.util.ImageLoader.srcImgObj.prototype._applyUrl = function(el) {
-       el.src = this.url;
-};
-
-/**
- * PNG background image object. A PNG background image is one whose URL is specified through AlphaImageLoader or by "background-image" in the element's style
- * @class YAHOO.util.ImageLoader.pngBgImgObj
- * @constructor
- * @extends YAHOO.util.ImageLoader.imgObj
- * @param {String}     domId   HTML DOM id of the image element
- * @param {String}     url     URL for the image
- */
-YAHOO.util.ImageLoader.pngBgImgObj = function(domId, url) {
-       YAHOO.util.ImageLoader.pngBgImgObj.superclass.constructor.call(this, domId, url);
-};
-
-YAHOO.lang.extend(YAHOO.util.ImageLoader.pngBgImgObj, YAHOO.util.ImageLoader.imgObj);
-
-/**
- * Inserts the image URL into the DOM so that the image is displayed.
- * If the browser is determined to be IE6 (or older), sets the AlphaImageLoader src; otherwise sets style.backgroundImage
- * @method _applyUrl
- * @param {Object}     el      HTML DOM element
- * @private
- */
-YAHOO.util.ImageLoader.pngBgImgObj.prototype._applyUrl = function(el) {
-       if (YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 6) {
-               el.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + this.url + '", sizingMethod="scale")';
-       }
-       else {
-               el.style.backgroundImage = "url('" + this.url + "')";
-       }
-};
-YAHOO.register("imageloader", YAHOO.util.ImageLoader, {version: "2.3.0", build: "442"});
diff --git a/lib/yui/imageloader/imageloader-experimental-min.js b/lib/yui/imageloader/imageloader-experimental-min.js
deleted file mode 100755 (executable)
index da9a475..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-Copyright (c) 2007, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 2.3.0
-*/
-
-if(typeof(YAHOO.util.ImageLoader)=='undefined'){YAHOO.util.ImageLoader={};}
-YAHOO.util.ImageLoader.group=function(trigEl,trigAct,timeout){this.name='unnamed';this._imgObjs={};this.timeoutLen=timeout;this._timeout=null;this._triggers=[];this.foldConditional=false;this.className=null;this._classImageEls=null;YAHOO.util.Event.addListener(window,'load',this._onloadTasks,this,true);this.addTrigger(trigEl,trigAct);};YAHOO.util.ImageLoader.group.prototype.addTrigger=function(trigEl,trigAct){if(!trigEl||!trigAct){return;}
-var wrappedFetch=function(){this.fetch();};this._triggers.push([trigEl,trigAct,wrappedFetch]);YAHOO.util.Event.addListener(trigEl,trigAct,wrappedFetch,this,true);};YAHOO.util.ImageLoader.group.prototype._onloadTasks=function(){if(this.timeoutLen&&typeof(this.timeoutLen)=='number'&&this.timeoutLen>0){this._timeout=setTimeout(this._getFetchTimeout(),this.timeoutLen*1000);}
-if(this.foldConditional){this._foldCheck();}};YAHOO.util.ImageLoader.group.prototype._getFetchTimeout=function(){var self=this;return function(){self.fetch();};};YAHOO.util.ImageLoader.group.prototype.registerBgImage=function(domId,url){this._imgObjs[domId]=new YAHOO.util.ImageLoader.bgImgObj(domId,url);return this._imgObjs[domId];};YAHOO.util.ImageLoader.group.prototype.registerSrcImage=function(domId,url,width,height){this._imgObjs[domId]=new YAHOO.util.ImageLoader.srcImgObj(domId,url,width,height);return this._imgObjs[domId];};YAHOO.util.ImageLoader.group.prototype.registerPngBgImage=function(domId,url){this._imgObjs[domId]=new YAHOO.util.ImageLoader.pngBgImgObj(domId,url);return this._imgObjs[domId];};YAHOO.util.ImageLoader.group.prototype.fetch=function(){YAHOO.log('Fetching images in group: "'+this.name+'".','info','imageloader');clearTimeout(this._timeout);for(var i=0;i<this._triggers.length;i++){YAHOO.util.Event.removeListener(this._triggers[i][0],this._triggers[i][1],this._triggers[i][2]);}
-this._fetchByClass();for(var id in this._imgObjs){if(YAHOO.lang.hasOwnProperty(this._imgObjs,id)){this._imgObjs[id].fetch();}}};YAHOO.util.ImageLoader.group.prototype._foldCheck=function(){YAHOO.log('Checking for images above the fold in group: "'+this.name+'"','info','imageloader');var scrollTop=(document.compatMode!='CSS1Compat')?document.body.scrollTop:document.documentElement.scrollTop;var viewHeight=YAHOO.util.Dom.getViewportHeight();var hLimit=scrollTop+viewHeight;var scrollLeft=(document.compatMode!='CSS1Compat')?document.body.scrollLeft:document.documentElement.scrollLeft;var viewWidth=YAHOO.util.Dom.getViewportWidth();var wLimit=scrollLeft+viewWidth;for(var id in this._imgObjs){if(YAHOO.lang.hasOwnProperty(this._imgObjs,id)){var elPos=YAHOO.util.Dom.getXY(this._imgObjs[id].domId);if(elPos[1]<hLimit&&elPos[0]<wLimit){YAHOO.log('Image with id "'+this._imgObjs[id].domId+'" is above the fold. Fetching image.','info','imageloader');this._imgObjs[id].fetch();}}}
-if(this.className){this._classImageEls=YAHOO.util.Dom.getElementsByClassName(this.className);for(var i=0;i<this._classImageEls.length;i++){var elPos=YAHOO.util.Dom.getXY(this._classImageEls[i]);if(elPos[1]<hLimit&&elPos[0]<wLimit){YAHOO.log('Image with id "'+this._classImageEls[i].id+'" is above the fold. Fetching image. (Image registered by class name with the group - may not have an id.)','info','imageloader');YAHOO.util.Dom.removeClass(this._classImageEls[i],this.className);}}}};YAHOO.util.ImageLoader.group.prototype._fetchByClass=function(){if(!this.className){return;}
-YAHOO.log('Fetching all images with class "'+this.className+'" in group "'+this.name+'".','info','imageloader');if(this._classImageEls===null){this._classImageEls=YAHOO.util.Dom.getElementsByClassName(this.className);}
-YAHOO.util.Dom.removeClass(this._classImageEls,this.className);};YAHOO.util.ImageLoader.imgObj=function(domId,url){this.domId=domId;this.url=url;this.width=null;this.height=null;this.setVisible=false;this._fetched=false;};YAHOO.util.ImageLoader.imgObj.prototype.fetch=function(){if(this._fetched){return;}
-var el=document.getElementById(this.domId);if(!el){return;}
-YAHOO.log('Fetching image with id "'+this.domId+'".','info','imageloader');this._applyUrl(el);if(this.setVisible){el.style.visibility='visible';}
-if(this.width){el.width=this.width;}
-if(this.height){el.height=this.height;}
-this._fetched=true;};YAHOO.util.ImageLoader.imgObj.prototype._applyUrl=function(el){};YAHOO.util.ImageLoader.bgImgObj=function(domId,url){YAHOO.util.ImageLoader.bgImgObj.superclass.constructor.call(this,domId,url);};YAHOO.lang.extend(YAHOO.util.ImageLoader.bgImgObj,YAHOO.util.ImageLoader.imgObj);YAHOO.util.ImageLoader.bgImgObj.prototype._applyUrl=function(el){el.style.backgroundImage="url('"+this.url+"')";};YAHOO.util.ImageLoader.srcImgObj=function(domId,url,width,height){YAHOO.util.ImageLoader.srcImgObj.superclass.constructor.call(this,domId,url);this.width=width;this.height=height;};YAHOO.lang.extend(YAHOO.util.ImageLoader.srcImgObj,YAHOO.util.ImageLoader.imgObj);YAHOO.util.ImageLoader.srcImgObj.prototype._applyUrl=function(el){el.src=this.url;};YAHOO.util.ImageLoader.pngBgImgObj=function(domId,url){YAHOO.util.ImageLoader.pngBgImgObj.superclass.constructor.call(this,domId,url);};YAHOO.lang.extend(YAHOO.util.ImageLoader.pngBgImgObj,YAHOO.util.ImageLoader.imgObj);YAHOO.util.ImageLoader.pngBgImgObj.prototype._applyUrl=function(el){if(YAHOO.env.ua.ie&&YAHOO.env.ua.ie<=6){el.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+this.url+'", sizingMethod="scale")';}
-else{el.style.backgroundImage="url('"+this.url+"')";}};YAHOO.register("imageloader",YAHOO.util.ImageLoader,{version:"2.3.0",build:"442"});
\ No newline at end of file
diff --git a/lib/yui/imageloader/imageloader-experimental.js b/lib/yui/imageloader/imageloader-experimental.js
deleted file mode 100755 (executable)
index 55b85c5..0000000
+++ /dev/null
@@ -1,442 +0,0 @@
-/*
-Copyright (c) 2007, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 2.3.0
-*/
-/**
- * The image loader is a framework to dynamically load images
- * according to certain triggers, enabling faster load times
- * and a more responsive UI.
- *
- * @module imageloader
- * @namespace YAHOO.util
- * @experimental
- */
-
-if (typeof(YAHOO.util.ImageLoader) == 'undefined') {
-       YAHOO.util.ImageLoader = {};
-}
-
-/**
- * A group for images. A group can have one time limit and a series of triggers. Thus the images belonging to this group must share these constraints.
- * @class YAHOO.util.ImageLoader.group
- * @requires YAHOO.util.Dom
- * @requires YAHOO.util.Event
- * @constructor
- * @param {String|HTMLElement} trigEl  The HTML element id or reference to assign the trigger event to. Can be null for no trigger
- * @param {String}     trigAct The type of event to assign to trigEl. Can be null for no trigger
- * @param {Number}     timeout Timeout (time limit) length, in seconds. Can be undefined, or <= 0, for no time limit
- */
-YAHOO.util.ImageLoader.group = function(trigEl, trigAct, timeout) {
-       /**
-        * Name for the group. Only used to identify the group in logging statements
-        * @property name
-        * @type String
-        */
-       this.name = 'unnamed';
-       
-       /**
-        * Collection of images registered with this group
-        * @property _imgObjs
-        * @private
-        * @type Object
-        */
-       this._imgObjs = {};
-       
-       /**
-        * Timeout (time limit) length, in seconds
-        * @property timeoutLen
-        * @type Number
-        */
-       this.timeoutLen = timeout;
-       
-       /**
-        * Timeout object to keep a handle on the time limit
-        * @property _timeout
-        * @private
-        * @type Object
-        */
-       this._timeout = null;
-       
-       /**
-        * Collection of triggers for this group.
-        * Keeps track of each trigger's element, event, and event-listener-callback "fetch" function
-        * @property _triggers
-        * @private
-        * @type Array
-        */
-       this._triggers = [];
-
-       /**
-        * Flag to check if images are above the fold. If foldConditional is true, the group will check each of its image locations at page load. If any part of the image is within the client viewport, the image is displayed immediately
-        * @property foldConditional
-        * @type Boolean
-        */
-       this.foldConditional = false;
-
-       /**
-        * Class name that will identify images belonging to the group. This class name will be removed from each element in order to fetch images.
-        * This class should have, in its CSS style definition, "background:none !important;"
-        * @property className
-        * @type String
-        */
-       this.className = null;
-
-       /**
-        * HTML elements having the class name that is associated with this group
-        * Elements are stored during the _foldCheck function and reused later during the fetch function. Gives a slight performance improvement when className and foldConditional are both used
-        * @property _classImageEls
-        * @private
-        * @type Array
-        */
-       this._classImageEls = null;
-
-       // add a listener to set the time limit in the onload
-       YAHOO.util.Event.addListener(window, 'load', this._onloadTasks, this, true);
-       // add the trigger
-       this.addTrigger(trigEl, trigAct);
-
-};
-
-/**
- * Adds a trigger to the group. Call this with the same style as YAHOO.util.Event.addListener
- * @method addTrigger
- * @param {String|HTMLElement} trigEl  The HTML element id or reference to assign the trigger event to
- * @param {String} trigAct The type of event to assign to trigEl
- */
-YAHOO.util.ImageLoader.group.prototype.addTrigger = function(trigEl, trigAct) {
-       if (! trigEl || ! trigAct) {
-               return;
-       }
-       /* Need to wrap the fetch function. Event Util can't distinguish prototyped functions of different instantiations
-        *   Leads to this scenario: groupA and groupZ both have window-scroll triggers. groupZ also has a 2-sec timeout (groupA has no timeout).
-        *   groupZ's timeout fires; we remove the triggers. The removeListener call finds the first window-scroll event with Y.u.IL.p.fetch, which is groupA's. 
-        *   groupA's trigger is removed and never fires, leaving images unfetched
-        */
-       var wrappedFetch = function() {
-               this.fetch();
-       };
-       this._triggers.push([trigEl, trigAct, wrappedFetch]);
-       YAHOO.util.Event.addListener(trigEl, trigAct, wrappedFetch, this, true);
-};
-
-/**
- * Setup to do in the window's onload
- * Initiates time limit for group; executes the fold check for the images
- * @method _onloadTasks
- * @private
- */
-YAHOO.util.ImageLoader.group.prototype._onloadTasks = function() {
-       if (this.timeoutLen && typeof(this.timeoutLen) == 'number' && this.timeoutLen > 0) {
-               this._timeout = setTimeout(this._getFetchTimeout(), this.timeoutLen * 1000);
-       }
-
-       if (this.foldConditional) {
-               this._foldCheck();
-       }
-};
-
-/**
- * Returns the group's fetch method, with the proper closure, for use with setTimeout
- * @method _getFetchTimeout
- * @return {Function}  group's fetch method
- * @private
- */
-YAHOO.util.ImageLoader.group.prototype._getFetchTimeout = function() {
-       var self = this;
-       return function() { self.fetch(); };
-};
-
-/**
- * Registers a background image with the group
- * @method registerBgImage
- * @param {String}     domId   HTML DOM id of the image element
- * @param {String}     url     URL for the image
- * @return {Object}    bgImgObj that was registered, for modifying any attributes in the object
- */
-YAHOO.util.ImageLoader.group.prototype.registerBgImage = function(domId, url) {
-       this._imgObjs[domId] = new YAHOO.util.ImageLoader.bgImgObj(domId, url);
-       return this._imgObjs[domId];
-};
-/**
- * Registers a src image with the group
- * @method registerSrcImage
- * @param {String}     domId   HTML DOM id of the image element
- * @param {String}     url     URL for the image
- * @param {Int}        width   pixel width of the image - defaults to image's natural size
- * @param {Int}        height  pixel height of the image - defaults to image's natural size
- * @return {Object}    srcImgObj that was registered, for modifying any attributes in the object
- */
-YAHOO.util.ImageLoader.group.prototype.registerSrcImage = function(domId, url, width, height) {
-       this._imgObjs[domId] = new YAHOO.util.ImageLoader.srcImgObj(domId, url, width, height);
-       return this._imgObjs[domId];
-};
-/**
- * Registers an alpha-channel-type png background image with the group
- * @method registerPngBgImage
- * @param {String}     domId   HTML DOM id of the image element
- * @param {String}     url     URL for the image
- * @return {Object}    pngBgImgObj that was registered, for modifying any attributes in the object
- */
-YAHOO.util.ImageLoader.group.prototype.registerPngBgImage = function(domId, url) {
-       this._imgObjs[domId] = new YAHOO.util.ImageLoader.pngBgImgObj(domId, url);
-       return this._imgObjs[domId];
-};
-
-/**
- * Displays the images in the group
- * @method fetch
- */
-YAHOO.util.ImageLoader.group.prototype.fetch = function() {
-       YAHOO.log('Fetching images in group: "' + this.name + '".', 'info', 'imageloader');
-
-       clearTimeout(this._timeout);
-       // remove all listeners
-       for (var i=0; i < this._triggers.length; i++) {
-               YAHOO.util.Event.removeListener(this._triggers[i][0], this._triggers[i][1], this._triggers[i][2]);
-       }
-
-       // fetch whatever we need to by className
-       this._fetchByClass();
-
-       // fetch registered images
-       for (var id in this._imgObjs) {
-               if (YAHOO.lang.hasOwnProperty(this._imgObjs, id)) {
-                       this._imgObjs[id].fetch();
-               }
-       }
-};
-
-/**
- * Checks the position of each image in the group. If any part of the image is within the client viewport, shows the image immediately.
- * @method _foldCheck
- * @private
- */
-YAHOO.util.ImageLoader.group.prototype._foldCheck = function() {
-       YAHOO.log('Checking for images above the fold in group: "' + this.name + '"', 'info', 'imageloader');
-       var scrollTop = (document.compatMode != 'CSS1Compat') ? document.body.scrollTop : document.documentElement.scrollTop;
-       var viewHeight = YAHOO.util.Dom.getViewportHeight();
-       var hLimit = scrollTop + viewHeight;
-       var scrollLeft = (document.compatMode != 'CSS1Compat') ? document.body.scrollLeft : document.documentElement.scrollLeft;
-       var viewWidth = YAHOO.util.Dom.getViewportWidth();
-       var wLimit = scrollLeft + viewWidth;
-       for (var id in this._imgObjs) {
-               if (YAHOO.lang.hasOwnProperty(this._imgObjs, id)) {
-                       var elPos = YAHOO.util.Dom.getXY(this._imgObjs[id].domId);
-                       if (elPos[1] < hLimit && elPos[0] < wLimit) {
-                               YAHOO.log('Image with id "' + this._imgObjs[id].domId + '" is above the fold. Fetching image.', 'info', 'imageloader');
-                               this._imgObjs[id].fetch();
-                       }
-               }
-       }
-       // and by class
-       if (this.className) {
-               this._classImageEls = YAHOO.util.Dom.getElementsByClassName(this.className);
-               for (var i=0; i < this._classImageEls.length; i++) {
-                       var elPos = YAHOO.util.Dom.getXY(this._classImageEls[i]);
-                       if (elPos[1] < hLimit && elPos[0] < wLimit) {
-                               YAHOO.log('Image with id "' + this._classImageEls[i].id + '" is above the fold. Fetching image. (Image registered by class name with the group - may not have an id.)', 'info', 'imageloader');
-                               YAHOO.util.Dom.removeClass(this._classImageEls[i], this.className);
-                       }
-               }
-       }
-};
-
-/**
- * Finds all elements in the Dom with the class name specified in the group. Removes the class from the element in order to let the style definitions trigger the image fetching
- * @method _fetchByClass
- * @private
- */
-YAHOO.util.ImageLoader.group.prototype._fetchByClass = function() {
-       if (! this.className) {
-               return;
-       }
-
-       YAHOO.log('Fetching all images with class "' + this.className + '" in group "' + this.name + '".', 'info', 'imageloader');
-       // this._classImageEls may have been set during _foldCheck
-       if (this._classImageEls === null) {
-               this._classImageEls = YAHOO.util.Dom.getElementsByClassName(this.className);
-       }
-       YAHOO.util.Dom.removeClass(this._classImageEls, this.className);
-};
-
-
-/**
- * Base class for image objects to be registered with the groups
- * @class YAHOO.util.ImageLoader.imgObj
- * @constructor
- * @param {String}     domId   HTML DOM id of the image element
- * @param {String}     url     URL for the image
- */
-YAHOO.util.ImageLoader.imgObj = function(domId, url) {
-       /**
-        * HTML DOM id of the image element
-        * @property domId
-        * @type String
-        */
-       this.domId = domId;
-
-       /**
-        * URL for the image
-        * @property url
-        * @type String
-        */
-       this.url = url;
-
-       /**
-        * Pixel width of the image. Will be set as a "width" attribute after the image is fetched.
-        * Detaults to the natural width of the image.
-        * Only appropriate with src images
-        * @property width
-        * @type Int
-        */
-       this.width = null;
-
-       /**
-        * Pixel height of the image. Will be set as a "height" attribute after the image is fetched.
-        * Detaults to the natural height of the image.
-        * Only appropriate with src images
-        * @property height
-        * @type Int
-        */
-       this.height = null;
-
-       /**
-        * Whether the style.visibility should be set to "visible" after the image is fetched.
-        * Used when setting src images as visibility:hidden prior to image fetching
-        * @property setVisible
-        * @type Boolean
-        */
-       this.setVisible = false;
-
-       /**
-        * Whether the image has already been fetched. In the case of a foldCondional group, keeps track for when the trigger is fired so images aren't fetched twice
-        * @property _fetched
-        * @type Boolean
-        * @private
-        */
-       this._fetched = false;
-};
-
-/**
- * Displays the image; puts the URL into the DOM
- * @method fetch
- */
-YAHOO.util.ImageLoader.imgObj.prototype.fetch = function() {
-       if (this._fetched) {
-               return;
-       }
-       var el = document.getElementById(this.domId);
-       if (! el) {
-               return;
-       }
-       YAHOO.log('Fetching image with id "' + this.domId + '".', 'info', 'imageloader');
-       this._applyUrl(el);
-
-       if (this.setVisible) {
-               el.style.visibility = 'visible';
-       }
-       if (this.width) {
-               el.width = this.width;
-       }
-       if (this.height) {
-               el.height = this.height;
-       }
-       this._fetched = true;
-};
-
-/**
- * Inserts the image URL into the DOM so that the image is displayed.
- * Must be overridden by child class
- * @method _applyUrl
- * @param {Object}     el      HTML DOM element
- * @private
- */
-YAHOO.util.ImageLoader.imgObj.prototype._applyUrl = function(el) {
-};
-
-/**
- * Background image object. A background image is one whose URL is specified by "background-image" in the element's style
- * @class YAHOO.util.ImageLoader.bgImgObj
- * @constructor
- * @extends YAHOO.util.ImageLoader.imgObj
- * @param {String}     domId   HTML DOM id of the image element
- * @param {String}     url     URL for the image
- */
-YAHOO.util.ImageLoader.bgImgObj = function(domId, url) {
-       YAHOO.util.ImageLoader.bgImgObj.superclass.constructor.call(this, domId, url);
-};
-
-YAHOO.lang.extend(YAHOO.util.ImageLoader.bgImgObj, YAHOO.util.ImageLoader.imgObj);
-
-/**
- * Inserts the image URL into the DOM so that the image is displayed.
- * Sets style.backgroundImage
- * @method _applyUrl
- * @param {Object}     el      HTML DOM element
- * @private
- */
-YAHOO.util.ImageLoader.bgImgObj.prototype._applyUrl = function(el) {
-       el.style.backgroundImage = "url('" + this.url + "')";
-};
-
-/**
- * Source image object. A source image is one whose URL is specified by a src attribute in the DOM element
- * @class YAHOO.util.ImageLoader.srcImgObj
- * @constructor
- * @extends YAHOO.util.ImageLoader.imgObj
- * @param {String}     domId   HTML DOM id of the image element
- * @param {String}     url     URL for the image
- * @param {Int}        width   pixel width of the image - defaults to image's natural size
- * @param {Int}        height  pixel height of the image - defaults to image's natural size
- */
-YAHOO.util.ImageLoader.srcImgObj = function(domId, url, width, height) {
-       YAHOO.util.ImageLoader.srcImgObj.superclass.constructor.call(this, domId, url);
-       this.width = width;
-       this.height = height;
-};
-
-YAHOO.lang.extend(YAHOO.util.ImageLoader.srcImgObj, YAHOO.util.ImageLoader.imgObj);
-
-/**
- * Inserts the image URL into the DOM so that the image is displayed.
- * Sets src
- * @method _applyUrl
- * @param {Object}     el      HTML DOM element
- * @private
- */
-YAHOO.util.ImageLoader.srcImgObj.prototype._applyUrl = function(el) {
-       el.src = this.url;
-};
-
-/**
- * PNG background image object. A PNG background image is one whose URL is specified through AlphaImageLoader or by "background-image" in the element's style
- * @class YAHOO.util.ImageLoader.pngBgImgObj
- * @constructor
- * @extends YAHOO.util.ImageLoader.imgObj
- * @param {String}     domId   HTML DOM id of the image element
- * @param {String}     url     URL for the image
- */
-YAHOO.util.ImageLoader.pngBgImgObj = function(domId, url) {
-       YAHOO.util.ImageLoader.pngBgImgObj.superclass.constructor.call(this, domId, url);
-};
-
-YAHOO.lang.extend(YAHOO.util.ImageLoader.pngBgImgObj, YAHOO.util.ImageLoader.imgObj);
-
-/**
- * Inserts the image URL into the DOM so that the image is displayed.
- * If the browser is determined to be IE6 (or older), sets the AlphaImageLoader src; otherwise sets style.backgroundImage
- * @method _applyUrl
- * @param {Object}     el      HTML DOM element
- * @private
- */
-YAHOO.util.ImageLoader.pngBgImgObj.prototype._applyUrl = function(el) {
-       if (YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 6) {
-               el.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + this.url + '", sizingMethod="scale")';
-       }
-       else {
-               el.style.backgroundImage = "url('" + this.url + "')";
-       }
-};
-YAHOO.register("imageloader", YAHOO.util.ImageLoader, {version: "2.3.0", build: "442"});
diff --git a/lib/yui/menu/assets/map.gif b/lib/yui/menu/assets/map.gif
deleted file mode 100755 (executable)
index 88dae00..0000000
Binary files a/lib/yui/menu/assets/map.gif and /dev/null differ
diff --git a/lib/yui/menu/assets/menuarodwn8_dim_1.gif b/lib/yui/menu/assets/menuarodwn8_dim_1.gif
deleted file mode 100755 (executable)
index 60b3836..0000000
Binary files a/lib/yui/menu/assets/menuarodwn8_dim_1.gif and /dev/null differ
diff --git a/lib/yui/menu/assets/menuarodwn8_hov_1.gif b/lib/yui/menu/assets/menuarodwn8_hov_1.gif
deleted file mode 100755 (executable)
index 66632e8..0000000
Binary files a/lib/yui/menu/assets/menuarodwn8_hov_1.gif and /dev/null differ
diff --git a/lib/yui/menu/assets/menuarodwn8_nrm_1.gif b/lib/yui/menu/assets/menuarodwn8_nrm_1.gif
deleted file mode 100755 (executable)
index bf5d3f1..0000000
Binary files a/lib/yui/menu/assets/menuarodwn8_nrm_1.gif and /dev/null differ
diff --git a/lib/yui/menu/assets/menuarorght8_dim_1.gif b/lib/yui/menu/assets/menuarorght8_dim_1.gif
deleted file mode 100755 (executable)
index 0780b66..0000000
Binary files a/lib/yui/menu/assets/menuarorght8_dim_1.gif and /dev/null differ
diff --git a/lib/yui/menu/assets/menuarorght8_hov_1.gif b/lib/yui/menu/assets/menuarorght8_hov_1.gif
deleted file mode 100755 (executable)
index 0d87f1a..0000000
Binary files a/lib/yui/menu/assets/menuarorght8_hov_1.gif and /dev/null differ
diff --git a/lib/yui/menu/assets/menuarorght8_nrm_1.gif b/lib/yui/menu/assets/menuarorght8_nrm_1.gif
deleted file mode 100755 (executable)
index 3cdc2a9..0000000
Binary files a/lib/yui/menu/assets/menuarorght8_nrm_1.gif and /dev/null differ
diff --git a/lib/yui/menu/assets/menuchk8_dim_1.gif b/lib/yui/menu/assets/menuchk8_dim_1.gif
deleted file mode 100755 (executable)
index d282a6c..0000000
Binary files a/lib/yui/menu/assets/menuchk8_dim_1.gif and /dev/null differ
diff --git a/lib/yui/menu/assets/menuchk8_hov_1.gif b/lib/yui/menu/assets/menuchk8_hov_1.gif
deleted file mode 100755 (executable)
index 2fabaef..0000000
Binary files a/lib/yui/menu/assets/menuchk8_hov_1.gif and /dev/null differ
diff --git a/lib/yui/menu/assets/menuchk8_nrm_1.gif b/lib/yui/menu/assets/menuchk8_nrm_1.gif
deleted file mode 100755 (executable)
index 9732837..0000000
Binary files a/lib/yui/menu/assets/menuchk8_nrm_1.gif and /dev/null differ
diff --git a/lib/yui/reset-fonts-grids/reset-fonts-grids-min.css b/lib/yui/reset-fonts-grids/reset-fonts-grids-min.css
deleted file mode 100755 (executable)
index bf76e56..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-/*Copyright (c) 2006,Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt version: 0.12.0 */\r
-/*reset.css*/body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}ol,ul {list-style:none;}caption,th {text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym {border:0;}\r
-/*fonts.css*/body{font:13px arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}table {font-size:inherit;font:100%;}select, input, textarea {font:99% arial,helvetica,clean,sans-serif;}pre, code {font:115% monospace;*font-size:100%;}body * {line-height:1.22em;}\r
-/*grids.css*/body{text-align:center;}#ft{clear:both;}#doc,#doc2,#doc3,.yui-t1,.yui-t2,.yui-t3,.yui-t4,.yui-t5,.yui-t6,.yui-t7{margin:auto;text-align:left;width:57.69em;*width:56.3em;min-width:750px;}#doc2{width:73.074em;*width:71.313em;min-width:950px;}#doc3{margin:auto 10px;width:auto;}.yui-b{position:relative;}.yui-b{_position:static;}#yui-main .yui-b{position:static;}#yui-main{width:100%;}.yui-t1 #yui-main,.yui-t2 #yui-main,.yui-t3 #yui-main{float:right;margin-left:-25em;}.yui-t4 #yui-main,.yui-t5 #yui-main,.yui-t6 #yui-main{float:left;margin-right:-25em;}.yui-t1 .yui-b{float:left;width:12.3207em;*width:12.0106em;}.yui-t1 #yui-main .yui-b{margin-left:13.3207em;*margin-left:13.0106em;}.yui-t2 .yui-b{float:left;width:13.8456em;*width:13.512em;}.yui-t2 #yui-main .yui-b{margin-left:14.8456em;*margin-left:14.512em;}.yui-t3 .yui-b{float:left;width:23.0759em;*width:22.52em;}.yui-t3 #yui-main .yui-b{margin-left:24.0759em;*margin-left:23.52em;}.yui-t4 .yui-b{float:right;width:13.8456em;*width:13.512em;}.yui-t4 #yui-main .yui-b{margin-right:14.8456em;*margin-right:14.512em;}.yui-t5 .yui-b{float:right;width:18.4608em;*width:18.016em;}.yui-t5 #yui-main .yui-b{margin-right:19.4608em;*margin-right:19.016em;}.yui-t6 .yui-b{float:right;width:23.0759em;*width:22.52em;}.yui-t6 #yui-main .yui-b{margin-right:24.0759em;*margin-right:23.52em;}.yui-t7 #yui-main .yui-b{display:block;margin:0 0 1em 0;}#yui-main .yui-b{float:none;width:auto;}.yui-g .yui-u,.yui-g .yui-g,.yui-gc .yui-u,.yui-gc .yui-g .yui-u,.yui-ge .yui-u,.yui-gf .yui-u{float:right;display:inline;}.yui-g div.first,.yui-gc div.first,.yui-gc div.first div.first,.yui-gd div.first,.yui-ge div.first,.yui-gf div.first{float:left;}.yui-g .yui-u,.yui-g .yui-g{width:49.1%;}.yui-g .yui-g .yui-u,.yui-gc .yui-g .yui-u{width:48.1%;}.yui-gb .yui-u,.yui-gc .yui-u,.yui-gd .yui-u{float:left;margin-left:2%;*margin-left:1.895%;width:32%;}.yui-gb div.first,.yui-gc div.first,.yui-gd div.first{margin-left:0;}.yui-gc div.first,.yui-gd .yui-u{width:66%;}.yui-gd div.first{width:32%;}.yui-ge .yui-u{width:24%;}.yui-ge div.first,.yui-gf .yui-u{width:74.2%;}.yui-gf div.first{width:24%;}.yui-ge div.first{width:74.2%;}#bd:after,.yui-g:after,.yui-gb:after,.yui-gc:after,.yui-gd:after,.yui-ge:after,.yui-gf:after{content:".";display:block;height:0;clear:both;visibility:hidden;}#bd,.yui-g,.yui-gb,.yui-gc,.yui-gd,.yui-ge,.yui-gf{zoom:1;}
\ No newline at end of file
diff --git a/lib/yui/treeview/assets/lm.gif b/lib/yui/treeview/assets/lm.gif
deleted file mode 100755 (executable)
index e7d0a3c..0000000
Binary files a/lib/yui/treeview/assets/lm.gif and /dev/null differ
diff --git a/lib/yui/treeview/assets/lmh.gif b/lib/yui/treeview/assets/lmh.gif
deleted file mode 100755 (executable)
index 3ff6302..0000000
Binary files a/lib/yui/treeview/assets/lmh.gif and /dev/null differ
diff --git a/lib/yui/treeview/assets/ln.gif b/lib/yui/treeview/assets/ln.gif
deleted file mode 100755 (executable)
index b7b3e55..0000000
Binary files a/lib/yui/treeview/assets/ln.gif and /dev/null differ
diff --git a/lib/yui/treeview/assets/loading.gif b/lib/yui/treeview/assets/loading.gif
deleted file mode 100755 (executable)
index 0bbf3bc..0000000
Binary files a/lib/yui/treeview/assets/loading.gif and /dev/null differ
diff --git a/lib/yui/treeview/assets/lp.gif b/lib/yui/treeview/assets/lp.gif
deleted file mode 100755 (executable)
index b87f003..0000000
Binary files a/lib/yui/treeview/assets/lp.gif and /dev/null differ
diff --git a/lib/yui/treeview/assets/lph.gif b/lib/yui/treeview/assets/lph.gif
deleted file mode 100755 (executable)
index e3478d8..0000000
Binary files a/lib/yui/treeview/assets/lph.gif and /dev/null differ
diff --git a/lib/yui/treeview/assets/tm.gif b/lib/yui/treeview/assets/tm.gif
deleted file mode 100755 (executable)
index e30abad..0000000
Binary files a/lib/yui/treeview/assets/tm.gif and /dev/null differ
diff --git a/lib/yui/treeview/assets/tmh.gif b/lib/yui/treeview/assets/tmh.gif
deleted file mode 100755 (executable)
index ad7e557..0000000
Binary files a/lib/yui/treeview/assets/tmh.gif and /dev/null differ
diff --git a/lib/yui/treeview/assets/tn.gif b/lib/yui/treeview/assets/tn.gif
deleted file mode 100755 (executable)
index 4a28039..0000000
Binary files a/lib/yui/treeview/assets/tn.gif and /dev/null differ
diff --git a/lib/yui/treeview/assets/tp.gif b/lib/yui/treeview/assets/tp.gif
deleted file mode 100755 (executable)
index d6d0ed0..0000000
Binary files a/lib/yui/treeview/assets/tp.gif and /dev/null differ
diff --git a/lib/yui/treeview/assets/tph.gif b/lib/yui/treeview/assets/tph.gif
deleted file mode 100755 (executable)
index e4d7d99..0000000
Binary files a/lib/yui/treeview/assets/tph.gif and /dev/null differ
diff --git a/lib/yui/treeview/assets/tree.css b/lib/yui/treeview/assets/tree.css
deleted file mode 100755 (executable)
index 0d805f5..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
-
-/* first or middle sibling, no children */
-.ygtvtn {
-       width:16px; height:22px; 
-       background: url(tn.gif) 0 0 no-repeat; 
-}
-
-/* first or middle sibling, collapsable */
-.ygtvtm {
-       width:16px; height:22px; 
-       cursor:pointer ;
-       background: url(tm.gif) 0 0 no-repeat; 
-}
-
-/* first or middle sibling, collapsable, hover */
-.ygtvtmh {
-       width:16px; height:22px; 
-       cursor:pointer ;
-       background: url(tmh.gif) 0 0 no-repeat; 
-}
-
-/* first or middle sibling, expandable */
-.ygtvtp {
-       width:16px; height:22px; 
-       cursor:pointer ;
-       background: url(tp.gif) 0 0 no-repeat; 
-}
-
-/* first or middle sibling, expandable, hover */
-.ygtvtph {
-       width:16px; height:22px; 
-       cursor:pointer ;
-       background: url(tph.gif) 0 0 no-repeat; 
-}
-
-/* last sibling, no children */
-.ygtvln {
-       width:16px; height:22px; 
-       background: url(ln.gif) 0 0 no-repeat; 
-}
-
-/* Last sibling, collapsable */
-.ygtvlm {
-       width:16px; height:22px; 
-       cursor:pointer ;
-       background: url(lm.gif) 0 0 no-repeat; 
-}
-
-/* Last sibling, collapsable, hover */
-.ygtvlmh {
-       width:16px; height:22px; 
-       cursor:pointer ;
-       background: url(lmh.gif) 0 0 no-repeat; 
-}
-
-/* Last sibling, expandable */
-.ygtvlp { 
-       width:16px; height:22px; 
-       cursor:pointer ;
-       background: url(lp.gif) 0 0 no-repeat; 
-}
-
-/* Last sibling, expandable, hover */
-.ygtvlph { 
-       width:16px; height:22px; cursor:pointer ;
-       background: url(lph.gif) 0 0 no-repeat; 
-}
-
-/* Loading icon */
-.ygtvloading { 
-       width:16px; height:22px; 
-       background: url(loading.gif) 0 0 no-repeat; 
-}
-
-/* the style for the empty cells that are used for rendering the depth 
- * of the node */
-.ygtvdepthcell { 
-       width:16px; height:22px; 
-       background: url(vline.gif) 0 0 no-repeat; 
-}
-
-.ygtvblankdepthcell { width:16px; height:22px; }
-
-/* the style of the div around each node */
-.ygtvitem { }  
-
-/* the style of the div around each node's collection of children */
-.ygtvchildren { }  
-* html .ygtvchildren { height:2%; }  
-
-/* the style of the text label in ygTextNode */
-.ygtvlabel, .ygtvlabel:link, .ygtvlabel:visited, .ygtvlabel:hover { 
-       margin-left:2px;
-       text-decoration: none;
-}
-
-.ygtvspacer { height: 10px; width: 10px; margin: 2px; }
diff --git a/lib/yui/treeview/assets/vline.gif b/lib/yui/treeview/assets/vline.gif
deleted file mode 100755 (executable)
index 1fb0de8..0000000
Binary files a/lib/yui/treeview/assets/vline.gif and /dev/null differ
index 5e4a15e9a3e1495397fe94a544475ff1b9ddbc29..4f7a6712c3be0900442bf5bdf0b326fd602df1dd 100644 (file)
@@ -48,7 +48,7 @@
                 print_error('cannotfinduser', '', '', $username);
             }
 
-            set_moodle_cookie($USER->username);
+            $SESSION->set_moodle_cookie($USER->username);
 
             if ( ! empty($SESSION->wantsurl) ) {   // Send them where they were going
                 $goto = $SESSION->wantsurl;
index f8a61df48c561699f394544abb02feaee8bb1e3f..03b7c1a6065759124db676237e9375da63e7a99d 100644 (file)
@@ -99,7 +99,7 @@ httpsrequired();
 
 /// Check if the user has actually submitted login data to us
 
-    if (empty($CFG->usesid) and $testcookies and (get_moodle_cookie() == '')) {    // Login without cookie when test requested
+    if (empty($CFG->usesid) and $testcookies and ($SESSION->get_moodle_cookie() == '')) {    // Login without cookie when test requested
 
         $errormsg = get_string("cookiesnotenabled");
         $errorcode = 1;
@@ -268,12 +268,12 @@ httpsrequired();
 
 /// Generate the login page with forms
 
-    if (get_moodle_cookie() == '') {
-        set_moodle_cookie('nobody');   // To help search for cookies
+    if ($SESSION->get_moodle_cookie() == '') {
+        $SESSION->set_moodle_cookie('nobody');   // To help search for cookies
     }
 
     if (empty($frm->username) && $authsequence[0] != 'shibboleth') {  // See bug 5184
-        $frm->username = get_moodle_cookie() === 'nobody' ? '' : get_moodle_cookie();
+        $frm->username = $SESSION->get_moodle_cookie() === 'nobody' ? '' : $SESSION->get_moodle_cookie();
         $frm->password = "";
     }
 
index c8863ece009e0e1cb0ded5687864d58a9f3aef1b..c581001bb91cc7db228e7004a8a715d6cd83ce43 100644 (file)
@@ -93,11 +93,11 @@ class mnet_environment {
     }
 
     function get_keypair() {
-        global $DB;
+        global $DB, $SESSION;
 
         // We don't generate keys on install/upgrade because we want the USER
         // record to have an email address, city and country already.
-        if (!empty($_SESSION['upgraderunning'])) return true;
+        if (!empty($SESSION->upgraderunning)) return true;
         if (!extension_loaded("openssl")) return true;
         if (!empty($this->keypair)) return true;
 
diff --git a/mod/assignment/db/mysql.php b/mod/assignment/db/mysql.php
deleted file mode 100644 (file)
index b54e4c3..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function assignment_upgrade($oldversion) {
-// This function does anything necessary to upgrade
-// older versions to match current functionality
-
-    global $CFG;
-
-    if ($oldversion < 2002080500) {
-
-        execute_sql("
-        CREATE TABLE `assignment` (
-          `id` int(10) unsigned NOT NULL auto_increment,
-          `course` int(10) unsigned NOT NULL default '0',
-          `name` varchar(255) NOT NULL default '',
-          `description` text NOT NULL,
-          `type` int(10) unsigned NOT NULL default '1',
-          `maxbytes` int(10) unsigned NOT NULL default '100000',
-          `timedue` int(10) unsigned NOT NULL default '0',
-          `grade` int(10) NOT NULL default '0',
-          `timemodified` int(10) unsigned NOT NULL default '0',
-          PRIMARY KEY  (`id`)
-        ) COMMENT='Defines assignments'
-        ");
-        
-        execute_sql("
-        CREATE TABLE `assignment_submissions` (
-          `id` int(10) unsigned NOT NULL default '0',
-          `assignment` int(10) unsigned NOT NULL default '0',
-          `user` int(10) unsigned NOT NULL default '0',
-          `timecreated` int(10) unsigned NOT NULL default '0',
-          `timemodified` int(10) unsigned NOT NULL default '0',
-          `numfiles` int(10) unsigned NOT NULL default '0',
-          `grade` int(11) NOT NULL default '0',
-          `comment` text NOT NULL,
-          `teacher` int(10) unsigned NOT NULL default '0',
-          `timemarked` int(10) unsigned NOT NULL default '0',
-          `mailed` tinyint(1) unsigned NOT NULL default '0',
-          PRIMARY KEY  (`id`)
-        ) COMMENT='Info about submitted assignments'
-        ");
-        
-        execute_sql(" INSERT INTO log_display (module, action, mtable, field) VALUES ('assignment', 'view', 'assignment', 'name') ");
-        execute_sql(" INSERT INTO log_display (module, action, mtable, field) VALUES ('assignment', 'add', 'assignment', 'name') ");
-        execute_sql(" INSERT INTO log_display (module, action, mtable, field) VALUES ('assignment', 'update', 'assignment', 'name') ");
-        execute_sql(" INSERT INTO log_display (module, action, mtable, field) VALUES ('assignment', 'view submissions', 'assignment', 'name') ");
-        execute_sql(" INSERT INTO log_display (module, action, mtable, field) VALUES ('assignment', 'upload', 'assignment', 'name') ");
-    }
-
-    if ($oldversion < 2002080701) {
-        execute_sql(" ALTER TABLE `assignment_submissions` CHANGE `id` `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT ");
-    }
-
-    if ($oldversion < 2002082806) {
-        // assignment file area was moved, so rename all the directories in existing courses
-
-        notify("Moving location of assignment files...");
-
-        $basedir = opendir("$CFG->dataroot");
-        while (false !== ($dir = readdir($basedir))) {
-            if ($dir == "." || $dir == ".." || $dir == "users") {
-                continue;
-            }
-            if (filetype("$CFG->dataroot/$dir") != "dir") {
-                continue;
-            }
-            $coursedir = "$CFG->dataroot/$dir";
-
-            if (! $coursemoddata = make_mod_upload_directory($dir)) {
-                echo "Error: could not create mod upload directory: $coursemoddata";
-                continue;
-            }
-
-            if (file_exists("$coursedir/assignment")) {
-                if (! rename("$coursedir/assignment", "$coursemoddata/assignment")) {
-                    echo "Error: could not move $coursedir/assignment to $coursemoddata/assignment\n";
-                }
-            }
-        }
-    }
-
-    if ($oldversion < 2002101600) {
-        execute_sql(" ALTER TABLE `assignment` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `description` ");
-    }
-    if ($oldversion < 2002110302) {
-        execute_sql(" UPDATE `assignment` SET `type` = '1'");
-    }
-    if ($oldversion < 2002111500) {
-        execute_sql(" ALTER TABLE `assignment` ADD `resubmit` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `format` ");
-    }
-    if ($oldversion < 2002122300) {
-        execute_sql("ALTER TABLE `assignment_submissions` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
-    }
-    if ($oldversion < 2004021700) {
-        set_field("log_display", "action", "view submission", "module", "assignment", "action", "view submissions");
-    }
-    if ($oldversion < 2004040100) {
-        include_once("$CFG->dirroot/mod/assignment/lib.php");
-        assignment_refresh_events();
-    }
-
-    if ($oldversion < 2004111200) { 
-        execute_sql("ALTER TABLE {$CFG->prefix}assignment DROP INDEX course;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}assignment_submissions DROP INDEX assignment;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}assignment_submissions DROP INDEX userid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}assignment_submissions DROP INDEX mailed;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}assignment_submissions DROP INDEX timemarked;",false);
-
-        modify_database('','ALTER TABLE prefix_assignment ADD INDEX course (course);');
-        modify_database('','ALTER TABLE prefix_assignment_submissions ADD INDEX assignment(assignment);');
-        modify_database('','ALTER TABLE prefix_assignment_submissions ADD INDEX userid (userid);');
-        modify_database('','ALTER TABLE prefix_assignment_submissions ADD INDEX mailed (mailed);');
-        modify_database('','ALTER TABLE prefix_assignment_submissions ADD INDEX timemarked (timemarked);');
-    }
-
-    if ($oldversion < 2005010500) {  // New field for sending out mail to teachers
-        table_column('assignment', '', 'emailteachers', 'integer', '2', 'unsigned', 0, 'not null', 'resubmit');
-    }
-
-    if ($oldversion < 2005041100) { // replace wiki-like with markdown
-        include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
-        $wtm = new WikiToMarkdown();
-        $wtm->update( 'assignment','description','format' );
-    }
-
-    if ($oldversion < 2005041400) {  // Add new fields for the new refactored version of assignment
-        table_column('assignment', '', 'timeavailable', 'integer', '10', 'unsigned', 0, 'not null', 'timedue');
-        table_column('assignment', '', 'assignmenttype', 'varchar', '50', '', '', 'not null', 'format');
-        execute_sql("UPDATE {$CFG->prefix}assignment SET assignmenttype = 'offline' WHERE type = '0';");
-        execute_sql("UPDATE {$CFG->prefix}assignment SET assignmenttype = 'uploadsingle' WHERE type = '1';");
-        execute_sql('ALTER TABLE '.$CFG->prefix.'assignment DROP type;');
-    }
-
-    if ($oldversion < 2005041501) {  // Add two new fields for general data handling, 
-                                     // so most assignment types won't need new fields and backups stay simple
-        table_column('assignment_submissions', '', 'data2', 'MEDIUMTEXT', '', '', '', 'not null', 'numfiles');
-        table_column('assignment_submissions', '', 'data1', 'MEDIUMTEXT', '', '', '', 'not null', 'numfiles');
-    }
-
-    if ($oldversion < 2005041600) {  // Add five new fields for general assignment parameters
-                                     // so most assignment types won't need new fields and backups stay simple
-        table_column('assignment', '', 'var5', 'integer', '10', '', 0, 'null', 'emailteachers');
-        table_column('assignment', '', 'var4', 'integer', '10', '', 0, 'null', 'emailteachers');
-        table_column('assignment', '', 'var3', 'integer', '10', '', 0, 'null', 'emailteachers');
-        table_column('assignment', '', 'var2', 'integer', '10', '', 0, 'null', 'emailteachers');
-        table_column('assignment', '', 'var1', 'integer', '10', '', 0, 'null', 'emailteachers');
-    }
-
-    if ($oldversion < 2005041700) {  // Allow comments to have a formatting
-        table_column('assignment_submissions', '', 'format', 'integer', '4', 'unsigned', '0', 'not null', 'comment');
-    }
-
-    if ($oldversion < 2005041800) {  // Prevent late submissions?  (default no)
-        table_column('assignment', '', 'preventlate', 'integer', '2', 'unsigned', '0', 'not null', 'resubmit');
-    }
-
-    if ($oldversion < 2005060100) {
-        include_once("$CFG->dirroot/mod/assignment/lib.php");
-        assignment_refresh_events();
-    }
-
-    if ($oldversion < 2006092100) {
-        table_column('assignment_submissions', 'comment', 'submissioncomment', 'text', '', '', '');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-
-?>
diff --git a/mod/assignment/db/postgres7.php b/mod/assignment/db/postgres7.php
deleted file mode 100644 (file)
index d7558df..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function assignment_upgrade($oldversion) {
-// This function does anything necessary to upgrade
-// older versions to match current functionality
-
-    global $CFG;
-
-    if ($oldversion < 2002080500) {
-
-        execute_sql("
-        CREATE TABLE `assignment` (
-          `id` SERIAL PRIMARY KEY,
-          `course` integer NOT NULL default '0',
-          `name` varchar(255) NOT NULL default '',
-          `description` text NOT NULL,
-          `type` integer NOT NULL default '1',
-          `maxbytes` integer NOT NULL default '100000',
-          `timedue` integer NOT NULL default '0',
-          `grade` integer NOT NULL default '0',
-          `timemodified` integer NOT NULL default '0'
-        )
-        ");
-        
-        execute_sql("
-        CREATE TABLE `assignment_submissions` (
-          `id` integer NOT NULL PRIMARY KEY default '0',
-          `assignment` integer NOT NULL default '0',
-          `user` integer NOT NULL default '0',
-          `timecreated` integer NOT NULL default '0',
-          `timemodified` integer NOT NULL default '0',
-          `numfiles` integer NOT NULL default '0',
-          `grade` integer NOT NULL default '0',
-          `comment` text NOT NULL,
-          `teacher` integer NOT NULL default '0',
-          `timemarked` integer NOT NULL default '0',
-          `mailed` integer NOT NULL default '0'
-        )
-        ");
-        
-        execute_sql(" INSERT INTO log_display (module, action, mtable, field) VALUES ('assignment', 'view', 'assignment', 'name') ");
-        execute_sql(" INSERT INTO log_display (module, action, mtable, field) VALUES ('assignment', 'add', 'assignment', 'name') ");
-        execute_sql(" INSERT INTO log_display (module, action, mtable, field) VALUES ('assignment', 'update', 'assignment', 'name') ");
-        execute_sql(" INSERT INTO log_display (module, action, mtable, field) VALUES ('assignment', 'view submissions', 'assignment', 'name') ");
-        execute_sql(" INSERT INTO log_display (module, action, mtable, field) VALUES ('assignment', 'upload', 'assignment', 'name') ");
-    }
-
-    if ($oldversion < 2002080701) {
-        execute_sql(" ALTER TABLE `assignment_submissions` CHANGE `id` `id` SERIAL PRIMARY KEY ");
-    }
-
-    if ($oldversion < 2002082806) {
-        // assignment file area was moved, so rename all the directories in existing courses
-
-        notify("Moving location of assignment files...");
-
-        $basedir = opendir("$CFG->dataroot");
-        while (false !== ($dir = readdir($basedir))) {
-            if ($dir == "." || $dir == ".." || $dir == "users") {
-                continue;
-            }
-            if (filetype("$CFG->dataroot/$dir") != "dir") {
-                continue;
-            }
-            $coursedir = "$CFG->dataroot/$dir";
-
-            if (! $coursemoddata = make_mod_upload_directory($dir)) {
-                echo "Error: could not create mod upload directory: $coursemoddata";
-                continue;
-            }
-
-            if (file_exists("$coursedir/assignment")) {
-                if (! rename("$coursedir/assignment", "$coursemoddata/assignment")) {
-                    echo "Error: could not move $coursedir/assignment to $coursemoddata/assignment\n";
-                }
-            }
-        }
-    }
-
-    if ($oldversion < 2002101600) {
-        execute_sql(" ALTER TABLE `assignment` ADD `format` INTEGER DEFAULT '0' NOT NULL AFTER `description` ");
-    }
-    if ($oldversion < 2002110302) {
-        execute_sql(" UPDATE `assignment` SET `type` = '1'");
-    }
-    if ($oldversion < 2003091000) {
-        # Old field that was never added!
-        table_column("assignment", "", "resubmit", "integer", "2", "unsigned", "0", "", "format");
-    }
-
-    if ($oldversion < 2004021700) {
-        set_field("log_display", "action", "view submission", "module", "assignment", "action", "view submissions");
-    }
-
-    if ($oldversion < 2004040100) {
-        include_once("$CFG->dirroot/mod/assignment/lib.php");
-        assignment_refresh_events();
-    }
-
-    if ($oldversion < 2004111200) { 
-        execute_sql("DROP INDEX {$CFG->prefix}assignment_course_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}assignment_submissions_assignment_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}assignment_submissions_userid_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}assignment_submissions_mailed_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}assignment_submissions_timemarked_idx;",false);
-
-        modify_database('','CREATE INDEX prefix_assignment_course_idx ON prefix_assignment (course);');
-        modify_database('','CREATE INDEX prefix_assignment_submissions_assignment_idx ON prefix_assignment_submissions (assignment);');
-        modify_database('','CREATE INDEX prefix_assignment_submissions_userid_idx ON prefix_assignment_submissions (userid);');
-        modify_database('','CREATE INDEX prefix_assignment_submissions_mailed_idx ON prefix_assignment_submissions (mailed);');
-        modify_database('','CREATE INDEX prefix_assignment_submissions_timemarked_idx ON prefix_assignment_submissions (timemarked);');
-    }
-
-    if ($oldversion < 2005010500) { 
-        table_column('assignment', '', 'emailteachers', 'integer', '2', 'unsigned', 0, 'not null', 'resubmit');
-    }
-
-    if ($oldversion < 2005041100) { // replace wiki-like with markdown
-        include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
-        $wtm = new WikiToMarkdown();
-        $wtm->update( 'assignment','description','format' );
-    }
-
-    if ($oldversion < 2005041400) {  // Add new fields for the new refactored version of assignment
-        table_column('assignment', '', 'timeavailable', 'integer', '10', 'unsigned', 0, 'not null', 'timedue');
-        table_column('assignment', '', 'assignmenttype', 'varchar', '50', '', '', 'not null', 'format');
-        execute_sql("UPDATE {$CFG->prefix}assignment SET assignmenttype = 'offline' WHERE type = '0';",false);
-        execute_sql("UPDATE {$CFG->prefix}assignment SET assignmenttype = 'uploadsingle' WHERE type = '1';",false);
-        execute_sql('ALTER TABLE '.$CFG->prefix.'assignment DROP type;');
-    }
-
-    if ($oldversion < 2005041501) {  // Add two new fields for general data handling, 
-                                     // so most assignment types won't need new fields and backups stay simple
-        table_column('assignment_submissions', '', 'data2', 'TEXT', '', '', '', 'not null', 'numfiles');
-        table_column('assignment_submissions', '', 'data1', 'TEXT', '', '', '', 'not null', 'numfiles');
-    }
-
-    if ($oldversion < 2005041600) {  // Add five new fields for general assignment parameters
-                                     // so most assignment types won't need new fields and backups stay simple
-        table_column('assignment', '', 'var5', 'integer', '10', '', 0, 'null', 'emailteachers');
-        table_column('assignment', '', 'var4', 'integer', '10', '', 0, 'null', 'emailteachers');
-        table_column('assignment', '', 'var3', 'integer', '10', '', 0, 'null', 'emailteachers');
-        table_column('assignment', '', 'var2', 'integer', '10', '', 0, 'null', 'emailteachers');
-        table_column('assignment', '', 'var1', 'integer', '10', '', 0, 'null', 'emailteachers');
-    }
-
-    if ($oldversion < 2005041700) {  // Allow comments to have a formatting
-        table_column('assignment_submissions', '', 'format', 'integer', '4', 'unsigned', '0', 'not null', 'comment');
-    }
-
-    if ($oldversion < 2005041800) {  // Prevent late submissions?  (default no)
-        table_column('assignment', '', 'preventlate', 'integer', '2', 'unsigned', '0', 'not null', 'resubmit');
-    }
-
-    if ($oldversion < 2005060100) {
-        include_once("$CFG->dirroot/mod/assignment/lib.php");
-        assignment_refresh_events();
-    }
-
-    if ($oldversion < 2005060101) { // Mass cleanup of bad upgrade scripts
-        modify_database('','ALTER TABLE prefix_assignment ALTER assignmenttype SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_assignment ALTER emailteachers SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_assignment ALTER preventlate SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_assignment ALTER timeavailable SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_assignment_submissions ALTER data1 SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_assignment_submissions ALTER data2 SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_assignment_submissions ALTER format SET NOT NULL');
-    }
-
-    if ($oldversion < 2006092100) {
-        table_column('assignment_submissions', 'comment', 'submissioncomment', 'text', '', '', '');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-
-?>
diff --git a/mod/assignment/type/online/db/mysql.php b/mod/assignment/type/online/db/mysql.php
deleted file mode 100644 (file)
index eab8285..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-<?php  // $Id$
-
-
-function assignment_type_online_upgrade($oldversion)  {
-    global $CFG, $db;
-
-    if ($oldversion < 2005042900 and empty($CFG->noconvertjournals)) {  // Phase out Journals, convert them 
-
-        $affectedcourses = array();
-                                                                        // to Online Assignment
-        if ($journals = get_records('journal')) {
-
-            require_once($CFG->dirroot.'/course/lib.php');
-
-            $assignmentmodule = get_record('modules', 'name', 'assignment');
-
-            foreach ($journals as $journal) {
-
-                $affectedcourses[$journal->course] = $journal->course;
-
-            /// First create the assignment instance
-                $assignment = new object();
-                $assignment->course = $journal->course;
-                $assignment->name = addslashes($journal->name);
-                $assignment->description = addslashes($journal->intro);
-                $assignment->format = FORMAT_MOODLE;
-                $assignment->assignmenttype = 'online';
-                $assignment->resubmit = 1;
-                $assignment->preventlate = 0;
-                $assignment->emailteachers = 0;
-                $assignment->var1 = 1;
-                $assignment->var2 = 0;
-                $assignment->var3 = 0;
-                $assignment->var4 = 0;
-                $assignment->var5 = 0;
-                $assignment->var5 = 0;
-                $assignment->maxbytes = 0;
-                $assignment->timedue = 0;          /// Don't have time to work this out .... :-(
-                $assignment->timeavailable = 0;
-                $assignment->grade = $journal->assessed;
-                $assignment->timemodified = $journal->timemodified;
-
-                $assignment->id = insert_record('assignment', $assignment);
-
-            /// Now create a new course module record
-
-                $oldcm = get_coursemodule_from_instance('journal', $journal->id, $journal->course);
-
-                $newcm = clone($oldcm);
-                $newcm->module   = $assignmentmodule->id; 
-                $newcm->instance = $assignment->id;
-                $newcm->added    = time();
-
-                if (! $newcm->id = add_course_module($newcm) ) {
-                    print_error("Could not add a new course module");
-                }
-                
-            /// And locate it above the old one
-
-                if (!$section = get_record('course_sections', 'id', $oldcm->section)) {
-                    $section->section = 0;  // So it goes somewhere!
-                }
-
-                $newcm->coursemodule = $newcm->id;
-                $newcm->section      = $section->section;  // need relative reference
-
-                if (! $sectionid = add_mod_to_section($newcm, $oldcm) ) {  // Add it before Journal
-                    print_error("Could not add the new course module to that section");
-                }
-                
-            /// Convert any existing entries from users
-                if ($entries = get_records('journal_entries', 'journal', $journal->id)) {
-                    foreach ($entries as $entry) {
-                        $submission = new object;
-                        $submission->assignment    = $assignment->id;
-                        $submission->userid        = $entry->userid;
-                        $submission->timecreated   = $entry->modified;
-                        $submission->timemodified  = $entry->modified;
-                        $submission->numfiles      = 0;
-                        $submission->data1         = addslashes($entry->text);
-                        $submission->data2         = $entry->format;
-                        $submission->grade         = $entry->rating;
-                        $submission->submissioncomment       = addslashes($entry->comment);
-                        $submission->format        = FORMAT_MOODLE;
-                        $submission->teacher       = $entry->teacher;
-                        $submission->timemarked    = $entry->timemarked;
-                        $submission->mailed        = $entry->mailed;
-                    
-                        $submission->id = insert_record('assignment_submissions', $submission);
-                    }
-                }
-            }
-
-        /// Clear the cache so this stuff appears
-
-            foreach ($affectedcourses as $courseid) {
-                rebuild_course_cache($courseid);
-            }
-        }
-
-    /// Hide the whole Journal module (but not individual items, just to make undo easier)
-        set_field('modules', 'visible', 0, 'name', 'journal');
-
-        if($journals === false) {
-            notify('The Journal module is becoming obsolete and being replaced by the superior Online Assignments, and  
-                    it has been disabled on your site.  If you really want Journal back, you can enable it using the 
-                    "eye" icon here:  Admin >> Modules >> Journal.');
-        }
-        else {
-            notify('The Journal module is becoming obsolete and being replaced by the superior Online Assignments.  
-                    It has been disabled on your site, and the '.count($journals).' Journal activites you had have been
-                    converted into Online Assignments.  If you really want Journal back, you can enable it using the 
-                    "eye" icon here:  Admin >> Modules >> Journal.');
-        }
-    }
-
-    return true;
-
-}
diff --git a/mod/assignment/type/online/db/postgres7.php b/mod/assignment/type/online/db/postgres7.php
deleted file mode 100644 (file)
index eab8285..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-<?php  // $Id$
-
-
-function assignment_type_online_upgrade($oldversion)  {
-    global $CFG, $db;
-
-    if ($oldversion < 2005042900 and empty($CFG->noconvertjournals)) {  // Phase out Journals, convert them 
-
-        $affectedcourses = array();
-                                                                        // to Online Assignment
-        if ($journals = get_records('journal')) {
-
-            require_once($CFG->dirroot.'/course/lib.php');
-
-            $assignmentmodule = get_record('modules', 'name', 'assignment');
-
-            foreach ($journals as $journal) {
-
-                $affectedcourses[$journal->course] = $journal->course;
-
-            /// First create the assignment instance
-                $assignment = new object();
-                $assignment->course = $journal->course;
-                $assignment->name = addslashes($journal->name);
-                $assignment->description = addslashes($journal->intro);
-                $assignment->format = FORMAT_MOODLE;
-                $assignment->assignmenttype = 'online';
-                $assignment->resubmit = 1;
-                $assignment->preventlate = 0;
-                $assignment->emailteachers = 0;
-                $assignment->var1 = 1;
-                $assignment->var2 = 0;
-                $assignment->var3 = 0;
-                $assignment->var4 = 0;
-                $assignment->var5 = 0;
-                $assignment->var5 = 0;
-                $assignment->maxbytes = 0;
-                $assignment->timedue = 0;          /// Don't have time to work this out .... :-(
-                $assignment->timeavailable = 0;
-                $assignment->grade = $journal->assessed;
-                $assignment->timemodified = $journal->timemodified;
-
-                $assignment->id = insert_record('assignment', $assignment);
-
-            /// Now create a new course module record
-
-                $oldcm = get_coursemodule_from_instance('journal', $journal->id, $journal->course);
-
-                $newcm = clone($oldcm);
-                $newcm->module   = $assignmentmodule->id; 
-                $newcm->instance = $assignment->id;
-                $newcm->added    = time();
-
-                if (! $newcm->id = add_course_module($newcm) ) {
-                    print_error("Could not add a new course module");
-                }
-                
-            /// And locate it above the old one
-
-                if (!$section = get_record('course_sections', 'id', $oldcm->section)) {
-                    $section->section = 0;  // So it goes somewhere!
-                }
-
-                $newcm->coursemodule = $newcm->id;
-                $newcm->section      = $section->section;  // need relative reference
-
-                if (! $sectionid = add_mod_to_section($newcm, $oldcm) ) {  // Add it before Journal
-                    print_error("Could not add the new course module to that section");
-                }
-                
-            /// Convert any existing entries from users
-                if ($entries = get_records('journal_entries', 'journal', $journal->id)) {
-                    foreach ($entries as $entry) {
-                        $submission = new object;
-                        $submission->assignment    = $assignment->id;
-                        $submission->userid        = $entry->userid;
-                        $submission->timecreated   = $entry->modified;
-                        $submission->timemodified  = $entry->modified;
-                        $submission->numfiles      = 0;
-                        $submission->data1         = addslashes($entry->text);
-                        $submission->data2         = $entry->format;
-                        $submission->grade         = $entry->rating;
-                        $submission->submissioncomment       = addslashes($entry->comment);
-                        $submission->format        = FORMAT_MOODLE;
-                        $submission->teacher       = $entry->teacher;
-                        $submission->timemarked    = $entry->timemarked;
-                        $submission->mailed        = $entry->mailed;
-                    
-                        $submission->id = insert_record('assignment_submissions', $submission);
-                    }
-                }
-            }
-
-        /// Clear the cache so this stuff appears
-
-            foreach ($affectedcourses as $courseid) {
-                rebuild_course_cache($courseid);
-            }
-        }
-
-    /// Hide the whole Journal module (but not individual items, just to make undo easier)
-        set_field('modules', 'visible', 0, 'name', 'journal');
-
-        if($journals === false) {
-            notify('The Journal module is becoming obsolete and being replaced by the superior Online Assignments, and  
-                    it has been disabled on your site.  If you really want Journal back, you can enable it using the 
-                    "eye" icon here:  Admin >> Modules >> Journal.');
-        }
-        else {
-            notify('The Journal module is becoming obsolete and being replaced by the superior Online Assignments.  
-                    It has been disabled on your site, and the '.count($journals).' Journal activites you had have been
-                    converted into Online Assignments.  If you really want Journal back, you can enable it using the 
-                    "eye" icon here:  Admin >> Modules >> Journal.');
-        }
-    }
-
-    return true;
-
-}
index 972063ff35270480ae1f4a0d90ed373f58a333d7..dd69746fbc9bc01e7e9df1bb3e608c1eba657a83 100755 (executable)
@@ -27,7 +27,7 @@ $_SERVER['PHP_SELF']        = 'dummy';
 $_SERVER['SERVER_NAME']     = 'dummy';
 $_SERVER['HTTP_USER_AGENT'] = 'dummy';
 
-$nomoodlecookie = true;
+define('NO_MOODLE_COOKIES', true); // session not used here
 
 include('../../config.php');
 include('lib.php');
diff --git a/mod/chat/db/mysql.php b/mod/chat/db/mysql.php
deleted file mode 100644 (file)
index b31f409..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function chat_upgrade($oldversion) {
-// This function does anything necessary to upgrade
-// older versions to match current functionality
-
-    global $CFG;
-
-    if ($oldversion < 2003072100) {
-        modify_database ("", " INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('chat', 'report', 'chat', 'name'); ");
-    }
-
-    if ($oldversion < 2003072101) {
-        table_column("chat", "messages", "keepdays", "integer", "10", "unsigned", "0", "not null");
-    }
-
-    if ($oldversion < 2003072102) {
-        table_column("chat", "", "studentlogs", "integer", "4", "unsigned", "0", "not null", "keepdays");
-    }
-
-    if ($oldversion < 2003072500) {
-        table_column("chat", "", "chattime", "integer", "10", "unsigned", "0", "not null", "studentlogs");
-        table_column("chat", "", "schedule", "integer", "4", "", "0", "not null", "studentlogs");
-    }
-
-    if ($oldversion < 2004022300) {
-        table_column("chat_messages", "", "groupid", "integer", "10", "unsigned", "0", "not null", "userid");
-        table_column("chat_users",    "", "groupid", "integer", "10", "unsigned", "0", "not null", "userid");
-    }
-
-    if ($oldversion < 2004042500) {
-        include_once("$CFG->dirroot/mod/chat/lib.php");
-        chat_refresh_events();
-    }
-
-    if ($oldversion < 2004043000) {
-        modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('chat', 'talk', 'chat', 'name');");
-    }
-
-    if ($oldversion < 2004111200) {
-        execute_sql("ALTER TABLE {$CFG->prefix}chat DROP INDEX `course`;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}chat_messages DROP INDEX  `chatid`;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}chat_messages DROP INDEX `userid`;",false); 
-        execute_sql("ALTER TABLE {$CFG->prefix}chat_messages DROP INDEX `groupid`;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}chat_users DROP INDEX  `chatid`;",false); 
-        execute_sql("ALTER TABLE {$CFG->prefix}chat_users DROP INDEX  `groupid`;",false);
-
-        modify_database('','ALTER TABLE prefix_chat ADD INDEX `course` (`course`);');
-        modify_database('','ALTER TABLE prefix_chat_messages ADD INDEX  `chatid` (`chatid`);');
-        modify_database('','ALTER TABLE prefix_chat_messages ADD INDEX `userid` (`userid`);');
-        modify_database('','ALTER TABLE prefix_chat_messages ADD INDEX `groupid` (`groupid`);');
-        modify_database('','ALTER TABLE prefix_chat_users ADD INDEX  `chatid` (`chatid`);');
-        modify_database('','ALTER TABLE prefix_chat_users ADD INDEX  `groupid` (`groupid`);');
-    }
-
-    if ($oldversion < 2005020300) {
-        table_column('chat_users', '', 'course', 'integer', '10', 'unsigned', '0', 'not null', '');
-        table_column('chat_users', '', 'lang'  , 'varchar', '10', ''        , '' , 'not null', '');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-
-?>
diff --git a/mod/chat/db/postgres7.php b/mod/chat/db/postgres7.php
deleted file mode 100644 (file)
index f3b6f0a..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function chat_upgrade($oldversion) {
-// This function does anything necessary to upgrade
-// older versions to match current functionality
-
-    global $CFG;
-
-    if ($oldversion < 2004022300) {
-        table_column("chat_messages", "", "groupid", "integer", "10", "unsigned", "0", "not null", "userid");
-        table_column("chat_users",    "", "groupid", "integer", "10", "unsigned", "0", "not null", "userid");
-    }
-
-    if ($oldversion < 2004042500) {
-        include_once("$CFG->dirroot/mod/chat/lib.php");
-        chat_refresh_events();
-    }
-
-    if ($oldversion < 2004043000) {
-        modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('chat', 'talk', 'chat', 'name');");
-    }
-
-    if ($oldversion < 2004111200) { //drop them first to avoid collisions with upgrades from 1.4.2+
-        execute_sql("DROP INDEX {$CFG->prefix}chat_course_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}chat_messages_chatid_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}chat_messages_userid_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}chat_messages_groupid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}chat_messages_timemodifiedchatid_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}chat_users_chatid_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}chat_users_userid_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}chat_users_groupid_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}chat_users_lastping_idx;",false);
-
-        modify_database('','CREATE INDEX prefix_chat_course_idx ON prefix_chat(course);');
-        modify_database('','CREATE INDEX prefix_chat_messages_chatid_idx ON prefix_chat_messages (chatid);');
-        modify_database('','CREATE INDEX prefix_chat_messages_userid_idx ON prefix_chat_messages (userid);');
-        modify_database('','CREATE INDEX prefix_chat_messages_groupid_idx ON prefix_chat_messages (groupid);');
-        modify_database('','CREATE INDEX prefix_chat_messages_timemodifiedchatid_idx ON prefix_chat_messages(timestamp,chatid);');
-        modify_database('','CREATE INDEX prefix_chat_users_chatid_idx ON prefix_chat_users (chatid);');
-        modify_database('','CREATE INDEX prefix_chat_users_userid_idx ON prefix_chat_users (userid);');
-        modify_database('','CREATE INDEX prefix_chat_users_groupid_idx ON prefix_chat_users (groupid);');
-        modify_database('','CREATE INDEX prefix_chat_users_lastping_idx ON prefix_chat_users (lastping);');
-    }
-
-    if ($oldversion < 2005020300) {
-        table_column('chat_users', '', 'course', 'integer', '10', 'unsigned', '0', 'not null', '');
-        table_column('chat_users', '', 'lang'  , 'varchar', '10', ''        , '' , 'not null', '');
-    }
-
-    if ($oldversion < 2005031001) { // Mass cleanup of bad upgrade scripts
-        modify_database('','ALTER TABLE prefix_chat_users ALTER course SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_chat_users ALTER lang SET NOT NULL');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-
-?>
index 54d275869100c97df66b82389897122ee8a44344..33f410b956f0e22811556aec28222151b066c30e 100644 (file)
@@ -17,7 +17,7 @@
 
 
     define('CHAT_MAX_CLIENT_UPDATES', 1000);
-    $nomoodlecookie = true;     // Session not needed!
+    define('NO_MOODLE_COOKIES', true); // session not used here
 
     require('../../../config.php');
     require('../lib.php');
index 60453d5396279cf7a9466682d8320e614d8463b3..991c6a94903e6366a77c1d526ded3958c95b3960 100644 (file)
@@ -1,6 +1,6 @@
 <?php  // $Id$
 
-    $nomoodlecookie = true;     // Session not needed!
+    define('NO_MOODLE_COOKIES', true); // session not used here
 
     require('../../../config.php');
     require('../lib.php');
index f873cf0bd515b4095b80b1efe93d998afb38c79b..be9cef51cc3dc075a947f83de21c52abbc9cbf85 100644 (file)
@@ -1,6 +1,6 @@
 <?php  // $Id$
 
-    $nomoodlecookie = true;     // Session not needed!
+    define('NO_MOODLE_COOKIES', true); // session not used here
 
     require('../../../config.php');
     require('../lib.php');
diff --git a/mod/choice/db/mysql.php b/mod/choice/db/mysql.php
deleted file mode 100644 (file)
index e95cb1c..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function choice_upgrade($oldversion) {
-    
-    global $CFG;
-
-// This function does anything necessary to upgrade
-// older versions to match current functionality
-
-    if ($oldversion < 2002090800) {
-        execute_sql(" ALTER TABLE `choice` CHANGE `answer1` `answer1` VARCHAR( 255 )");
-        execute_sql(" ALTER TABLE `choice` CHANGE `answer2` `answer2` VARCHAR( 255 )");
-    }
-    if ($oldversion < 2002102400) {
-        execute_sql(" ALTER TABLE `choice` ADD `answer3` varchar(255) NOT NULL AFTER `answer2`");
-        execute_sql(" ALTER TABLE `choice` ADD `answer4` varchar(255) NOT NULL AFTER `answer3`");
-        execute_sql(" ALTER TABLE `choice` ADD `answer5` varchar(255) NOT NULL AFTER `answer4`");
-        execute_sql(" ALTER TABLE `choice` ADD `answer6` varchar(255) NOT NULL AFTER `answer5`");
-    }
-    if ($oldversion < 2002122300) {
-        execute_sql("ALTER TABLE `choice_answers` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
-    }
-    if ($oldversion < 2003010100) {
-        execute_sql(" ALTER TABLE `choice` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `text` ");
-        execute_sql(" ALTER TABLE `choice` ADD `publish` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `answer6` ");
-    }
-
-    if ($oldversion < 2004010100) {
-        table_column("choice", "", "showunanswered", "integer", "4", "unsigned", "0", "", "publish");
-    }
-    if ($oldversion < 2004021700) {
-        modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('choice', 'choose', 'choice', 'name');");
-        modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('choice', 'choose again', 'choice', 'name');");
-    }
-    if ($oldversion < 2004070100) {
-        table_column("choice", "", "timeclose", "integer", "10", "unsigned", "0", "", "showunanswered");
-        table_column("choice", "", "timeopen", "integer", "10", "unsigned", "0", "", "showunanswered");
-    }
-    if ($oldversion < 2004070101) {
-        table_column("choice", "", "release", "integer", "2", "unsigned", "0", "", "publish");
-        table_column("choice", "", "allowupdate", "integer", "2", "unsigned", "0", "", "release");
-    }
-    if ($oldversion < 2004070102) {
-        modify_database("", "UPDATE prefix_choice SET allowupdate = '1' WHERE publish = 0;");
-        modify_database("", "UPDATE prefix_choice SET release = '1' WHERE publish > 0;");
-        modify_database("", "UPDATE prefix_choice SET publish = publish - 1 WHERE publish > 0;");
-    }
-
-    if ($oldversion < 2004111200){  // drop first to avoid conflicts when upgrading from 1.4+
-        execute_sql("ALTER TABLE {$CFG->prefix}choice DROP INDEX course;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}choice_answers DROP INDEX choice;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}choice_answers DROP INDEX userid;",false);       
-        
-        modify_database('','ALTER TABLE prefix_choice ADD INDEX course (course);');
-        modify_database('','ALTER TABLE prefix_choice_answers ADD INDEX choice (choice);');
-        modify_database('','ALTER TABLE prefix_choice_answers ADD INDEX userid (userid);');
-    }
-    
-    if ($oldversion < 2005033001){  
-        if (execute_sql("CREATE TABLE {$CFG->prefix}choice_options (
-                             `id` int(10) unsigned NOT NULL auto_increment, 
-                             `choiceid` int(10) unsigned NOT NULL default '0', 
-                             `text` TEXT, 
-                             `timemodified` int(10) NOT NULL default '0', 
-                             PRIMARY KEY  (id), 
-                             UNIQUE KEY id (id), 
-                             KEY choiceid (choiceid)
-                         ) TYPE=MyISAM;")) {
-    
-            table_column('choice_answers', 'choice', 'choiceid', 'integer', '10', 'unsigned', 0, 'not null');
-            table_column('choice_answers', 'answer', 'optionid', 'integer', '10', 'unsigned', 0, 'not null');
-    
-            table_column('choice', '', 'display', 'integer', '4', 'unsigned', 0, 'not null', 'release');
-    
-            
-            /// move old answers from choice to choice_options
-    
-            if ($choices = get_records('choice')) {
-                foreach ($choices as $choice) {
-                    for ($i=1; $i<=6; $i++) {      // We used to have six columns
-                        $option = new stdClass;
-                        $option->text         = addslashes($choice->{'answer'.$i});
-                        if ($option->text) {   /// Don't bother with blank options
-                            $option->choiceid     = $choice->id;
-                            $option->timemodified = $choice->timemodified;
-                            if ($option->id = insert_record('choice_options', $option)) { 
-                                /// Update all the user answers to fit the new value
-                                execute_sql("UPDATE {$CFG->prefix}choice_answers 
-                                                SET optionid='$option->id' 
-                                              WHERE choiceid='$choice->id' 
-                                                AND optionid='$i'");                                                            
-                            }
-                        }
-                    }
-                }
-            }
-            
-            //drop old fields
-    
-            modify_database('','ALTER TABLE prefix_choice DROP `answer1`;');
-            modify_database('','ALTER TABLE prefix_choice DROP `answer2`;');
-            modify_database('','ALTER TABLE prefix_choice DROP `answer3`;');
-            modify_database('','ALTER TABLE prefix_choice DROP `answer4`;');
-            modify_database('','ALTER TABLE prefix_choice DROP `answer5`;');
-            modify_database('','ALTER TABLE prefix_choice DROP `answer6`;');
-
-        } else {
-            notify('SERIOUS PROBLEM OCCURRED WHILE UPGRADING A TABLE - you may have to manually upgrade your tables ... see mod/choice/db/mysql.php');
-            return false;
-        }
-    }
-    
-    if ($oldversion < 2005041100) { // replace wiki-like with markdown
-        include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
-        $wtm = new WikiToMarkdown();
-        $wtm->update( 'choice','text','format' );
-    }
-    if ($oldversion < 2005041500) { //new limit feature
-        table_column('choice', '', 'limitanswers', 'TINYINT', '2', 'unsigned', 0, 'not null', 'showunanswered');
-        table_column('choice_options', '', 'maxanswers', 'INTEGER', '10', 'unsigned', 0, 'null', 'text');
-    }      
-    if ($oldversion < 2006020900) { //rename release column to showanswers - Release is now reserved word in mySql
-        table_column('choice', '`release`', 'showresults', 'TINYINT', '2', 'unsigned', 0, 'not null');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-
-?>
diff --git a/mod/choice/db/postgres7.php b/mod/choice/db/postgres7.php
deleted file mode 100644 (file)
index 3e124d3..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function choice_upgrade($oldversion) {
-
-    global $CFG;
-
-// This function does anything necessary to upgrade
-// older versions to match current functionality
-
-    if ($oldversion < 2003010100) {
-        execute_sql(" ALTER TABLE `choice` ADD `format` INTEGER DEFAULT '0' NOT NULL AFTER `text` ");
-        execute_sql(" ALTER TABLE `choice` ADD `publish` INTEGER DEFAULT '0' NOT NULL AFTER `answer6` ");
-    }
-    if ($oldversion < 2004010100) {
-        table_column("choice", "", "showunanswered", "integer", "4", "unsigned", "0", "", "publish");
-    }
-    if ($oldversion < 2004021700) {
-        modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('choice', 'choose', 'choice', 'name');");
-        modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('choice', 'choose again', 'choice', 'name');");
-    }
-    if ($oldversion < 2004070100) {
-        table_column("choice", "", "timeclose", "integer", "10", "unsigned", "0", "", "showunanswered");
-        table_column("choice", "", "timeopen", "integer", "10", "unsigned", "0", "", "showunanswered");
-    }
-    if ($oldversion < 2004070101) {
-        table_column("choice", "", "release", "integer", "2", "unsigned", "0", "", "publish");
-        table_column("choice", "", "allowupdate", "integer", "2", "unsigned", "0", "", "release");
-    }
-    if ($oldversion < 2004070102) {
-        modify_database("", "UPDATE prefix_choice SET allowupdate = '1' WHERE publish = 0;");
-        modify_database("", "UPDATE prefix_choice SET release = '1' WHERE publish > 0;");
-        modify_database("", "UPDATE prefix_choice SET publish = publish - 1 WHERE publish > 0;");
-    }
-
-    if ($oldversion < 2004111200) { // drop first to avoid conflicts when upgrading from 1.4+
-        execute_sql("DROP INDEX {$CFG->prefix}choice_course_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}choice_answers_choice_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}choice_answers_userid_idx;",false);
-
-        modify_database('','CREATE INDEX prefix_choice_course_idx ON prefix_choice (course);');
-        modify_database('','CREATE INDEX prefix_choice_answers_choice_idx ON prefix_choice_answers (choice);');
-        modify_database('','CREATE INDEX prefix_choice_answers_userid_idx ON prefix_choice_answers (userid);');
-    }
-    if ($oldversion < 2005033000){
-        if (execute_sql("CREATE TABLE {$CFG->prefix}choice_options (id SERIAL PRIMARY KEY, choiceid integer NOT NULL default '0', text TEXT, timemodified integer NOT NULL default '0');") ) {
-            execute_sql("CREATE INDEX {$CFG->prefix}choice_options_choice_idx ON {$CFG->prefix}choice_options (choiceid);");
-
-            table_column('choice_answers', 'choice', 'choiceid', 'integer', '10', 'unsigned', 0, 'not null');
-            table_column('choice_answers', 'answer', 'optionid', 'integer', '10', 'unsigned', 0, 'not null');
-            table_column('choice', '', 'display', 'integer', '4', 'unsigned', 0, 'not null', 'release');
-
-            // move old answers from choice to choice_options
-            if ($choices = get_records('choice')) {
-                foreach ($choices as $choice) {
-                    for ($i=1; $i<=6; $i++) {      // We used to have six columns
-                        $option = new stdClass;
-                        $option->text         = addslashes($choice->{'answer'.$i});
-                        if ($option->text) {   /// Don't bother with blank options
-                            $option->choiceid     = $choice->id;
-                            $option->timemodified = $choice->timemodified;
-                            if ($option->id = insert_record('choice_options', $option)) {
-                                /// Update all the user answers to fit the new value 
-                                execute_sql("UPDATE {$CFG->prefix}choice_answers
-                                                SET optionid={$option->id}
-                                              WHERE choiceid={$choice->id}
-                                                AND optionid={$i}");
-                            }
-                        }
-                    }
-                }
-            }
-
-      // drop old fields
-         modify_database('','ALTER TABLE prefix_choice DROP answer1;');
-         modify_database('','ALTER TABLE prefix_choice DROP answer2;');
-         modify_database('','ALTER TABLE prefix_choice DROP answer3;');
-         modify_database('','ALTER TABLE prefix_choice DROP answer4;');
-         modify_database('','ALTER TABLE prefix_choice DROP answer5;');
-         modify_database('','ALTER TABLE prefix_choice DROP answer6;');
-
-       }
-    }
-
-    if ($oldversion < 2005041100) { // replace wiki-like with markdown
-        include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
-        $wtm = new WikiToMarkdown();
-        $wtm->update( 'choice','text','format' );
-    }
-    if ($oldversion < 2005041500) { //new limit feature
-        table_column('choice', '', 'limitanswers', 'INTEGER', '2', 'unsigned', 0, 'not null', 'showunanswered');
-        table_column('choice_options', '', 'maxanswers', 'INTEGER', '10', 'unsigned', 0, 'null', 'text');
-    }
-
-    if ($oldversion < 2005041501) { // Mass cleanup of bad upgrade scripts
-        modify_database('','CREATE INDEX prefix_choice_answers_choice_idx ON prefix_choice_answers (choiceid)');
-        notify('The above error can be ignored if the index already exists, its possible that it was cleaned up already before running this upgrade');
-        modify_database('','ALTER TABLE prefix_choice ALTER display SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_choice ALTER limitanswers SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_choice_answers ALTER choiceid SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_choice_answers ALTER optionid SET NOT NULL');
-    }
-    if ($oldversion < 2006020900) { //rename release column to showanswers - Release is now reserved word in mySql
-        table_column('choice', 'release', 'showresults', 'TINYINT', '2', 'unsigned', 0, 'not null');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
index 393d9eacbeb3c1e4f3ddc5067b64f63137b87cfb..5a598894919bff13099fc02f7d45265ea91dc40c 100755 (executable)
 //                                                                       //
 ///////////////////////////////////////////////////////////////////////////
 
-    $lifetime  = 600;                                   // Seconds to cache this stylesheet
-    $nomoodlecookie = true;                             // Cookies prevent caching, so don't use them
+    define('NO_MOODLE_COOKIES', true); // session not used here
 
     require_once('../../config.php');
 
     $d = optional_param('d', 0, PARAM_INT);   // database id
+    $lifetime  = 600;                                   // Seconds to cache this stylesheet
 
     if ($data = $DB->get_record('data', array('id'=>$d))) {
         header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
diff --git a/mod/data/db/mysql.php b/mod/data/db/mysql.php
deleted file mode 100644 (file)
index 0589396..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-<?php
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function data_upgrade($oldversion) {
-/// This function does anything necessary to upgrade
-/// older versions to match current functionality
-
-    global $CFG;
-
-    if ($oldversion < 2006011900) {
-        table_column("data_content", "", "content1", "longtext", "", "", "", "not null");
-        table_column("data_content", "", "content2", "longtext", "", "", "", "not null");
-        table_column("data_content", "", "content3", "longtext", "", "", "", "not null");
-        table_column("data_content", "", "content4", "longtext", "", "", "", "not null");
-    }
-
-    if ($oldversion < 2006011901) {
-        table_column("data", "", "approval", "tinyint", "4");
-        table_column("data_records", "", "approved", "tinyint", "4");
-    }
-
-    if ($oldversion < 2006020801) {
-        table_column("data", "", "scale", "integer", "10", "signed");
-        table_column("data", "", "assessed", "integer", "10");
-        table_column("data", "", "assesspublic", "integer", "4");
-    }
-
-    if ($oldversion < 2006022700) {
-        table_column("data_comments", "", "created", "integer", "10");
-        table_column("data_comments", "", "modified", "integer", "10");
-    }
-
-    if ($oldversion < 2006030700) {
-        modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'add', 'data', 'name')");
-        modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'update', 'data', 'name')");
-        modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'record delete', 'data', 'name')");
-        modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'fields add', 'data_fields', 'name')");
-        modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'fields update', 'data_fields', 'name')");
-        modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'templates saved', 'data', 'name')");
-        modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'templates def', 'data', 'name')");
-    }
-
-    if ($oldversion < 2006032700) {
-        table_column('data', '', 'defaultsort', 'integer', '10', 'unsigned', '0');
-        table_column('data', '', 'defaultsortdir', 'tinyint', '4', 'unsigned', '0', 'not null', 'defaultsort');
-        table_column('data', '', 'editany', 'tinyint', '4', 'unsigned', '0', 'not null', 'defaultsortdir');
-    }
-
-    if ($oldversion < 2006032900) {
-        table_column('data', '', 'csstemplate', 'text', '', '', '', 'not null', 'rsstemplate');
-    }
-
-    if ($oldversion < 2006050500) { // 2 fields have got no default null values
-        table_column('data_comments','content','content','text','','','','not null');
-        table_column('data_fields','description','description','text','','','','not null');
-        table_column('data_fields','param1','param1','text','','','','not null');
-        table_column('data_fields','param2','param2','text','','','','not null');
-        table_column('data_fields','param3','param3','text','','','','not null');
-        table_column('data_fields','param4','param4','text','','','','not null');
-        table_column('data_fields','param5','param5','text','','','','not null');
-        table_column('data_fields','param6','param6','text','','','','not null');
-        table_column('data_fields','param7','param7','text','','','','not null');
-        table_column('data_fields','param8','param8','text','','','','not null');
-        table_column('data_fields','param9','param9','text','','','','not null');
-        table_column('data_fields','param10','param10','text','','','','not null');
-    }
-
-    if ($oldversion < 2006052400) {
-        table_column('data','','rsstitletemplate','text','','','','not null','rsstemplate');
-    }
-
-    if ($oldversion < 2006081700) {
-        table_column('data', '', 'jstemplate', 'text', '', '', '', 'not null', 'csstemplate');
-    }
-
-    if ($oldversion < 2006092000) {
-        // Upgrades for new roles and capabilities support.
-        require_once($CFG->dirroot.'/mod/data/lib.php');
-
-        $datamod = get_record('modules', 'name', 'data');
-
-        if ($data = get_records('data')) {
-
-            if (!$teacherroles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW)) {
-                notify('Default teacher role was not found. Roles and permissions '.
-                       'for all your forums will have to be manually set after '.
-                       'this upgrade.');
-            }
-            if (!$studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) {
-                notify('Default student role was not found. Roles and permissions '.
-                       'for all your forums will have to be manually set after '.
-                       'this upgrade.');
-            }
-            foreach ($data as $d) {
-                if (!data_convert_to_roles($d, $teacherroles, $studentroles)) {
-                    notify('Data with id '.$d->id.' was not upgraded');
-                }
-            }
-            // We need to rebuild all the course caches to refresh the state of
-            // the forum modules.
-            include_once( "$CFG->dirroot/course/lib.php" );
-            rebuild_course_cache();
-
-        } // End if.
-
-        modify_database('', 'ALTER TABLE prefix_data DROP COLUMN participants;');
-        modify_database('', 'ALTER TABLE prefix_data DROP COLUMN assesspublic;');
-        modify_database('', 'ALTER TABLE prefix_data DROP COLUMN ratings;');
-
-    }
-
-    if ($oldversion < 2006092302) { // Changing some TEXT fields to NULLable and no default
-        execute_sql("ALTER TABLE {$CFG->prefix}data CHANGE singletemplate singletemplate text NULL AFTER rssarticles");
-        execute_sql("ALTER TABLE {$CFG->prefix}data CHANGE listtemplate listtemplate text NULL AFTER singletemplate");
-        execute_sql("ALTER TABLE {$CFG->prefix}data CHANGE listtemplateheader listtemplateheader text NULL AFTER listtemplate");
-        execute_sql("ALTER TABLE {$CFG->prefix}data CHANGE listtemplatefooter listtemplatefooter text NULL AFTER listtemplateheader");
-        execute_sql("ALTER TABLE {$CFG->prefix}data CHANGE addtemplate addtemplate text NULL AFTER listtemplatefooter");
-        execute_sql("ALTER TABLE {$CFG->prefix}data CHANGE rsstemplate rsstemplate text NULL AFTER addtemplate");
-        execute_sql("ALTER TABLE {$CFG->prefix}data CHANGE rsstitletemplate rsstitletemplate text NULL AFTER rsstemplate");
-        execute_sql("ALTER TABLE {$CFG->prefix}data CHANGE csstemplate csstemplate text NULL AFTER rsstitletemplate");
-        execute_sql("ALTER TABLE {$CFG->prefix}data CHANGE jstemplate jstemplate text NULL AFTER csstemplate");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields CHANGE param1 param1 text NULL AFTER description");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields CHANGE param2 param2 text NULL AFTER param1");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields CHANGE param3 param3 text NULL AFTER param2");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields CHANGE param4 param4 text NULL AFTER param3");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields CHANGE param5 param5 text NULL AFTER param4");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields CHANGE param6 param6 text NULL AFTER param5");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields CHANGE param7 param7 text NULL AFTER param6");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields CHANGE param8 param8 text NULL AFTER param7");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields CHANGE param9 param9 text NULL AFTER param8");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields CHANGE param10 param10 text NULL AFTER param9");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data_content CHANGE content content longtext NULL AFTER recordid");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_content CHANGE content1 content1 longtext NULL AFTER content");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_content CHANGE content2 content2 longtext NULL AFTER content1");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_content CHANGE content3 content3 longtext NULL AFTER content2");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_content CHANGE content4 content4 longtext NULL AFTER content3");
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/mod/data/db/postgres7.php b/mod/data/db/postgres7.php
deleted file mode 100644 (file)
index 3a5d764..0000000
+++ /dev/null
@@ -1,279 +0,0 @@
-<?php
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function data_upgrade($oldversion) {
-/// This function does anything necessary to upgrade
-/// older versions to match current functionality
-
-    global $CFG;
-
-    if ($oldversion < 2006011900) {
-        table_column("data_content", "", "content1", "text", "", "", "", "not null");
-        table_column("data_content", "", "content2", "text", "", "", "", "not null");
-        table_column("data_content", "", "content3", "text", "", "", "", "not null");
-        table_column("data_content", "", "content4", "text", "", "", "", "not null");
-    }
-
-    if ($oldversion < 2006011901) {
-        table_column("data", "", "approval", "integer", "4", "unsigned", "0", "not null");
-        table_column("data_records", "", "approved", "integer", "4", "unsigned", "0", "not null");
-    }
-
-    if ($oldversion < 2006020801) {
-        table_column("data", "", "scale", "integer");
-        table_column("data", "", "assessed", "integer");
-        table_column("data", "", "assesspublic", "integer");
-    }
-
-    if ($oldversion < 2006022700) {
-        table_column("data_comments", "", "created", "integer");
-        table_column("data_comments", "", "modified", "integer");
-    }
-
-    if ($oldversion < 2006030700) {
-        modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'view', 'data', 'name');");
-        modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'add', 'data', 'name')");
-        modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'update', 'data', 'name')");
-        modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'record delete', 'data', 'name')");
-        modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'fields add', 'data_fields', 'name')");
-        modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'fields update', 'data_fields', 'name')");
-        modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'templates saved', 'data', 'name')");
-        modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'templates defaults', 'data', 'name')");
-    }
-
-    if ($oldversion < 2006032700) {
-        table_column('data', '', 'defaultsort', 'integer', '10', 'unsigned', '0');
-        table_column('data', '', 'defaultsortdir', 'tinyint', '4', 'unsigned', '0', 'not null', 'defaultsort');
-        table_column('data', '', 'editany', 'tinyint', '4', 'unsigned', '0', 'not null', 'defaultsortdir');
-    }
-
-    if ($oldversion < 2006032900) {
-        table_column('data', '', 'csstemplate', 'text', '', '', '', 'not null', 'rsstemplate');
-    }
-
-    if ($oldversion < 2006050500) { // drop all tables, and create from scratch
-
-        execute_sql("DROP TABLE {$CFG->prefix}data", false);
-        execute_sql("DROP TABLE {$CFG->prefix}data_content", false);
-        execute_sql("DROP TABLE {$CFG->prefix}data_fields", false);
-        execute_sql("DROP TABLE {$CFG->prefix}data_records", false);
-        execute_sql("DROP TABLE {$CFG->prefix}data_comments", false);
-        execute_sql("DROP TABLE {$CFG->prefix}data_ratings", false);
-
-        modify_database('',"CREATE TABLE prefix_data (
-                              id SERIAL PRIMARY KEY,
-                              course integer NOT NULL default '0',
-                              name varchar(255) NOT NULL default '',
-                              intro text NOT NULL default '',
-                              ratings integer NOT NULL default '0',
-                              comments integer NOT NULL default '0',
-                              timeavailablefrom integer NOT NULL default '0',
-                              timeavailableto integer NOT NULL default '0',
-                              timeviewfrom integer NOT NULL default '0',
-                              timeviewto integer NOT NULL default '0',
-                              participants integer NOT NULL default '0',
-                              requiredentries integer NOT NULL default '0',
-                              requiredentriestoview integer NOT NULL default '0',
-                              maxentries integer NOT NULL default '0',
-                              rssarticles integer NOT NULL default '0',
-                              singletemplate text NOT NULL default '',
-                              listtemplate text NOT NULL default '',
-                              listtemplateheader text NOT NULL default '',
-                              listtemplatefooter text NOT NULL default '',
-                              addtemplate text NOT NULL default '',
-                              rsstemplate text NOT NULL default '',
-                              csstemplate text NOT NULL default '',
-                              approval integer NOT NULL default '0',
-                              scale integer NOT NULL default '0',
-                              assessed integer NOT NULL default '0',
-                              assesspublic integer NOT NULL default '0',
-                              defaultsort integer NOT NULL default '0',
-                              defaultsortdir integer NOT NULL default '0',
-                              editany integer NOT NULL default '0'
-                            );
-
-                            CREATE TABLE prefix_data_content (
-                              id SERIAL PRIMARY KEY,
-                              fieldid integer NOT NULL default '0',
-                              recordid integer NOT NULL default '0',
-                              content text NOT NULL default '',
-                              content1 text NOT NULL default '',
-                              content2 text NOT NULL default '',
-                              content3 text NOT NULL default '',
-                              content4 text NOT NULL default ''
-                            );
-
-                            CREATE TABLE prefix_data_fields (
-                              id SERIAL PRIMARY KEY,
-                              dataid integer NOT NULL default '0',
-                              type varchar(255) NOT NULL default '',
-                              name varchar(255) NOT NULL default '',
-                              description text NOT NULL default '',
-                              param1  text NOT NULL default '',
-                              param2  text NOT NULL default '',
-                              param3  text NOT NULL default '',
-                              param4  text NOT NULL default '',
-                              param5  text NOT NULL default '',
-                              param6  text NOT NULL default '',
-                              param7  text NOT NULL default '',
-                              param8  text NOT NULL default '',
-                              param9  text NOT NULL default '',
-                              param10 text NOT NULL default ''
-                            );
-
-                            CREATE TABLE prefix_data_records (
-                              id SERIAL PRIMARY KEY,
-                              userid integer NOT NULL default '0',
-                              groupid integer NOT NULL default '0',
-                              dataid integer NOT NULL default '0',
-                              timecreated integer NOT NULL default '0',
-                              timemodified integer NOT NULL default '0',
-                              approved integer NOT NULL default '0'
-                            );
-
-                            CREATE TABLE prefix_data_comments (
-                              id SERIAL PRIMARY KEY,
-                              userid integer NOT NULL default '0',
-                              recordid integer NOT NULL default '0',
-                              content text NOT NULL default '',
-                              created integer NOT NULL default '0',
-                              modified integer NOT NULL default '0'
-                            );
-
-                            CREATE TABLE prefix_data_ratings (
-                              id SERIAL PRIMARY KEY,
-                              userid integer NOT NULL default '0',
-                              recordid integer NOT NULL default '0',
-                              rating integer NOT NULL default '0'
-                            );");
-
-    }
-
-    if ($oldversion < 2006052400) {
-        table_column('data','','rsstitletemplate','text','','','','not null','rsstemplate');
-    }
-
-    if ($oldversion < 2006081700) {
-        table_column('data', '', 'jstemplate', 'text', '', '', '', 'not null', 'csstemplate');
-    }
-
-    if ($oldversion < 2006092000) {
-        // Upgrades for new roles and capabilities support.
-        require_once($CFG->dirroot.'/mod/data/lib.php');
-
-        $datamod = get_record('modules', 'name', 'data');
-
-        if ($data = get_records('data')) {
-
-            if (!$teacherroles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW)) {
-                notify('Default teacher role was not found. Roles and permissions '.
-                       'for all your forums will have to be manually set after '.
-                       'this upgrade.');
-            }
-            if (!$studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) {
-                notify('Default student role was not found. Roles and permissions '.
-                       'for all your forums will have to be manually set after '.
-                       'this upgrade.');
-            }
-            foreach ($data as $d) {
-                if (!data_convert_to_roles($d, $teacherroles, $studentroles)) {
-                    notify('Data with id '.$d->id.' was not upgraded');
-                }
-            }
-            // We need to rebuild all the course caches to refresh the state of
-            // the forum modules.
-            include_once( "$CFG->dirroot/course/lib.php" );
-            rebuild_course_cache();
-
-        } // End if.
-
-        modify_database('', 'ALTER TABLE prefix_data DROP COLUMN participants;');
-        modify_database('', 'ALTER TABLE prefix_data DROP COLUMN assesspublic;');
-        modify_database('', 'ALTER TABLE prefix_data DROP COLUMN ratings;');
-
-    }
-
-    if ($oldversion < 2006092302) { // Changing some TEXT fields to NULLable and no default
-        execute_sql("ALTER TABLE {$CFG->prefix}data ALTER COLUMN singletemplate DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data ALTER COLUMN singletemplate DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data ALTER COLUMN listtemplate DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data ALTER COLUMN listtemplate DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data ALTER COLUMN listtemplateheader DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data ALTER COLUMN listtemplateheader DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data ALTER COLUMN listtemplatefooter DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data ALTER COLUMN listtemplatefooter DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data ALTER COLUMN addtemplate DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data ALTER COLUMN addtemplate DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data ALTER COLUMN rsstemplate DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data ALTER COLUMN rsstemplate DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data ALTER COLUMN rsstitletemplate DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data ALTER COLUMN rsstitletemplate DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data ALTER COLUMN csstemplate DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data ALTER COLUMN csstemplate DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data ALTER COLUMN jstemplate DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data ALTER COLUMN jstemplate DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields ALTER COLUMN param1 DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields ALTER COLUMN param1 DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields ALTER COLUMN param2 DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields ALTER COLUMN param2 DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields ALTER COLUMN param3 DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields ALTER COLUMN param3 DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields ALTER COLUMN param4 DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields ALTER COLUMN param4 DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields ALTER COLUMN param5 DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields ALTER COLUMN param5 DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields ALTER COLUMN param6 DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields ALTER COLUMN param6 DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields ALTER COLUMN param7 DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields ALTER COLUMN param7 DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields ALTER COLUMN param8 DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields ALTER COLUMN param8 DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields ALTER COLUMN param9 DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields ALTER COLUMN param9 DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields ALTER COLUMN param10 DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_fields ALTER COLUMN param10 DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data_content ALTER COLUMN content DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_content ALTER COLUMN content DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data_content ALTER COLUMN content1 DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_content ALTER COLUMN content1 DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data_content ALTER COLUMN content2 DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_content ALTER COLUMN content2 DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data_content ALTER COLUMN content3 DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_content ALTER COLUMN content3 DROP DEFAULT");
-
-        execute_sql("ALTER TABLE {$CFG->prefix}data_content ALTER COLUMN content4 DROP NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}data_content ALTER COLUMN content4 DROP DEFAULT");
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
index 0151721e860a1afeafc3adba4dcf95342941fa3b..288be5ad5ced98d063da725f4d9530dc4fe019b5 100644 (file)
 //                                                                       //
 ///////////////////////////////////////////////////////////////////////////
 
-    $lifetime  = 600;                                   // Seconds to cache this stylesheet
-    $nomoodlecookie = true;                             // Cookies prevent caching, so don't use them
+    define('NO_MOODLE_COOKIES', true); // session not used here
 
     require_once('../../config.php');
 
     $d = optional_param('d', 0, PARAM_INT);   // database id
+    $lifetime  = 600;                                   // Seconds to cache this stylesheet
 
     if ($data = $DB->get_record('data', array('id'=>$d))) {
         header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
diff --git a/mod/exercise/assessments.php b/mod/exercise/assessments.php
deleted file mode 100644 (file)
index 5327aff..0000000
+++ /dev/null
@@ -1,1174 +0,0 @@
-<?php  // $Id$
-
-/*************************************************
-    ACTIONS handled are:
-
-    adminamendgradinggrading
-    adminconfirmdelete
-    admindelete
-    adminedit
-    adminlist
-    adminlistbystudent
-    assessresubmission
-    assesssubmission
-    displaygradingform
-    editelements (teachers only)
-    insertelements (for teachers)
-    listungradedstudentsubmissions (for teachers)
-    listungradedstudentassessments (for teachers)
-    listteachersubmissions
-    regradestudentassessments (for teachers)
-    teacherassessment (for teachers)
-    teachertable
-    updateassessment
-    updateteacherassessment
-    userconfirmdelete
-    userdelete
-    viewassessment
-
-************************************************/
-
-    require_once("../../config.php");
-    require_once("lib.php");
-    require_once("locallib.php");
-
-    $id     = required_param('id', PARAM_INT);    // Course Module ID
-    $action = required_param('action', PARAM_ALPHA);
-    $aid    = optional_param('aid', 0, PARAM_INT);
-    $sid    = optional_param('sid', 0, PARAM_INT);
-    $userid = optional_param('userid', 0, PARAM_INT);
-
-    // get some esential stuff...
-    if (! $cm = get_coursemodule_from_id('exercise', $id)) {
-        print_error("Course Module ID was incorrect");
-    }
-
-    if (! $course = get_record("course", "id", $cm->course)) {
-        print_error("Course is misconfigured");
-    }
-
-    if (! $exercise = get_record("exercise", "id", $cm->instance)) {
-        print_error("Course module is incorrect");
-    }
-
-    exercise_add_custom_scales($exercise);
-
-    require_login($course->id, false, $cm);
-
-    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
-    $strexercises = get_string("modulenameplural", "exercise");
-    $strexercise  = get_string("modulename", "exercise");
-    $strassessments = get_string("assessments", "exercise");
-
-    // ... print the header and...
-    $navigation = build_navigation($strassessments, $cm);
-    print_header_simple(format_string($exercise->name), "", $navigation,
-                  "", "", true);
-
-    //...get the action
-
-
-    /******************* admin amend Grading Grade ************************************/
-    if ($action == 'adminamendgradinggrade' ) {
-
-        if (!has_capability('mod/exercise:assess', $context)) {
-            print_error("Only teachers can look at this page");
-        }
-        if (empty($aid)) {
-            print_error("Admin Amend Grading grade: assessment id missing");
-        }
-
-        if (!$assessment = get_record("exercise_assessments", "id", $aid)) {
-            print_error("Amin Amend Grading grade: assessment not found");
-        }
-        print_heading(get_string("amend", "exercise")." ".get_string("gradeforstudentsassessment",
-                    "exercise", $course->student));
-        echo "<form id=\"amendgrade\" method=\"post\" action=\"assessments.php\">\n";
-        echo "<input type=\"hidden\" name=\"aid\" value=\"$aid\" />\n";
-        echo "<input type=\"hidden\" name=\"action\" value=\"updategradinggrade\" />\n";
-        echo "<input type=\"hidden\" name=\"id\" value=\"$cm->id\" />\n";
-        echo "<table width=\"50%\" align=\"center\" border=\"1\" />\n";
-        echo "<tr><td align=\"right\"><b>".get_string("gradeforstudentsassessment", "exercise",
-                $course->student)." :</td><td>\n";
-        // set up coment scale
-        for ($i=$exercise->gradinggrade; $i>=0; $i--) {
-            $num[$i] = $i;
-            }
-        choose_from_menu($num, "gradinggrade",
-                number_format($exercise->gradinggrade * $assessment->gradinggrade / 100, 0), "");
-        echo "</td></tr>\n";
-        echo "<tr><td colspan=\"2\" align=\"center\">";
-        echo "<input type=\"submit\" value=\"".get_string("amend", "exercise")."\" />\n";
-        echo "</td></tr>\n";
-        echo "</table>\n";
-        echo "</center>";
-        echo "</form>\n";
-    }
-
-
-    /******************* admin confirm delete ************************************/
-    elseif ($action == 'adminconfirmdelete' ) {
-
-        if (!has_capability('mod/exercise:assess', $context)) {
-            print_error("Only teachers can look at this page");
-        }
-        if (empty($aid)) {
-            print_error("Admin confirm delete: assessment id missing");
-        }
-
-        notice_yesno(get_string("confirmdeletionofthisitem","exercise", get_string("assessment", "exercise")),
-             "assessments.php?action=admindelete&amp;id=$cm->id&amp;aid=$aid",
-             "submissions.php?action=adminlist&amp;id=$cm->id");
-        }
-
-
-    /******************* admin delete ************************************/
-    elseif ($action == 'admindelete' ) {
-
-        if (!has_capability('mod/exercise:assess', $context)) {
-            print_error("Only teachers can look at this page");
-        }
-        if (empty($aid)) {
-            print_error("Admin delete: submission id missing");
-        }
-
-        print_string("deleting", "exercise");
-        // first delete all the associated records...
-        delete_records("exercise_grades", "assessmentid", $aid);
-        // ...now delete the assessment...
-        delete_records("exercise_assessments", "id", $aid);
-
-        print_continue("submissions.php?id=$cm->id&amp;action=adminlist");
-        }
-
-
-    /*********************** admin list of asssessments (of a submission) (by teachers)**************/
-    elseif ($action == 'adminlist') {
-
-        if (!has_capability('mod/exercise:assess', $context)) {
-            print_error("Only teachers can look at this page");
-        }
-
-        if (empty($sid)) {
-            error ("exercise asssessments: adminlist called with no sid");
-        }
-        $submission = get_record("exercise_submissions", "id", $sid);
-        exercise_print_assessments_for_admin($exercise, $submission);
-        print_continue("submissions.php?action=adminlist&amp;id=$cm->id");
-        }
-
-
-    /****************** admin list of asssessments by a student (used by teachers only )******************/
-    elseif ($action == 'adminlistbystudent') {
-
-        if (!has_capability('mod/exercise:assess', $context)) {
-            print_error("Only teachers can look at this page");
-        }
-
-        if (empty($userid)) {
-            error ("exercise asssessments: adminlistbystudent called with no userid");
-        }
-        $user = get_record("user", "id", $userid);
-        exercise_print_assessments_by_user_for_admin($exercise, $user);
-        print_continue("submissions.php?action=adminlist&amp;id=$cm->id");
-        }
-
-
-    /****************** Assess resubmission (by teacher) ***************************/
-    elseif ($action == 'assessresubmission') {
-
-        if (empty($sid)) {
-            error ("exercise asssessments: assessresubmission called with no sid");
-        }
-
-        if (! $submission = get_record("exercise_submissions", "id", $sid)) {
-            print_error("Assess submission is misconfigured - no submission record!");
-        }
-        if (!$submissionowner = get_record("user", "id", $submission->userid)) {
-            print_error("Assess resubmission: user record not found");
-        }
-
-        // there can be an assessment record, if there isn't...
-        if (!$assessment = exercise_get_submission_assessment($submission, $USER)) {
-            if (!$submissions = exercise_get_user_submissions($exercise, $submissionowner)) {
-                print_error("Assess resubmission: submission records not found");
-            }
-            $lastone= '';
-            // just the last but one submission
-            foreach ($submissions as $submission) {
-                $prevsubmission = $lastone;
-                $lastone = $submission;
-            }
-            // get the teacher's assessment of the student's previous submission
-            if (!$prevassessment = exercise_get_submission_assessment($prevsubmission, $USER)) {
-                print_error("Assess resubmission: Previous assessment record not found");
-            }
-            // copy this assessment with comments...
-            $assessment = exercise_copy_assessment($prevassessment, $submission, true);
-        }
-
-        print_heading(get_string("thisisaresubmission", "exercise",
-            fullname($submissionowner)));
-        // show assessment and allow changes
-        exercise_print_assessment_form($exercise, $assessment, true, $_SERVER["HTTP_REFERER"]);
-    }
-
-
-    /****************** Assess submission (by teacher or student) ***************************/
-    elseif ($action == 'assesssubmission') {
-
-        if (empty($sid)) {
-            error ("exercise asssessments: assesssubmission called with no sid");
-        }
-
-        if (! $submission = get_record("exercise_submissions", "id", $sid)) {
-            print_error("Assess submission is misconfigured - no submission record!");
-        }
-
-        // there can be an assessment record (for teacher submissions), if there isn't...
-        if (!$assessment = exercise_get_submission_assessment($submission, $USER)) {
-            $yearfromnow = time() + 365 * 86400;
-            // ...create one and set timecreated way in the future, this is reset when record is updated
-            $assessment->exerciseid = $exercise->id;
-            $assessment->submissionid = $submission->id;
-            $assessment->userid = $USER->id;
-            $assessment->grade = -1; // set impossible grade
-            $assessment->timecreated = $yearfromnow;
-            $assessment->timegraded = 0;
-            if (!$assessment->id = insert_record("exercise_assessments", $assessment)) {
-                print_error("Could not insert exercise assessment!");
-            }
-        }
-
-        // show assessment and allow changes
-        exercise_print_assessment_form($exercise, $assessment, true, $_SERVER["HTTP_REFERER"]);
-    }
-
-
-    /****************** display grading form (viewed by student) *********************************/
-    elseif ($action == 'displaygradingform') {
-
-    print_heading_with_help(get_string("specimenassessmentform", "exercise"), "specimen", "exercise");
-
-    exercise_print_assessment_form($exercise); // called with no assessment
-    print_continue("view.php?id=$cm->id");
-    }
-
-
-    /****************** edit assessment elements (for teachers) ***********************/
-    elseif ($action == 'editelements') {
-
-        if (!has_capability('mod/exercise:assess', $context)) {
-            print_error("Only teachers can look at this page");
-        }
-
-        $count = count_records("exercise_grades", "exerciseid", $exercise->id);
-        if ($exercise->phase > 1 and $count) {
-            notify(get_string("warningonamendingelements", "exercise"));
-        }
-        // set up heading, form and table
-        print_heading_with_help(get_string("editingassessmentelements", "exercise"), "elements", "exercise");
-        ?>
-        <form id="form" method="post" action="assessments.php">
-        <input type="hidden" name="id" value="<?php echo $cm->id ?>" />
-        <input type="hidden" name="action" value="insertelements" />
-        <center><table cellpadding="5" border="1">
-        <?php
-
-        // get existing elements, if none set up appropriate default ones
-        if ($elementsraw = get_records("exercise_elements", "exerciseid", $exercise->id, "elementno ASC" )) {
-            foreach ($elementsraw as $element) {
-                $elements[] = $element;   // to renumber index 0,1,2...
-            }
-        }
-        // check for missing elements (this happens either the first time round or when the number
-        // of elements is icreased)
-        for ($i=0; $i<$exercise->nelements; $i++) {
-            if (!isset($elements[$i])) {
-                $elements[$i]->description = '';
-                $elements[$i]->scale =0;
-                $elements[$i]->maxscore = 0;
-                $elements[$i]->weight = 11;
-            }
-        }
-        switch ($exercise->gradingstrategy) {
-            case 0: // no grading
-                for ($i=0; $i<$exercise->nelements; $i++) {
-                    $iplus1 = $i+1;
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td align=\"right\"><p><b>". get_string("element","exercise")." $iplus1:</b></p></td>\n";
-                    echo "<td><textarea name=\"description[]\" rows=\"3\" cols=\"75\" wrap=\"virtual\">".
-                        $elements[$i]->description."</textarea>\n";
-                    echo "  </td></tr>\n";
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td colspan=\"2\">&nbsp;</td>\n";
-                    echo "</tr>\n";
-                }
-                break;
-
-            case 1: // accumulative grading
-                // set up scales name
-                foreach ($EXERCISE_SCALES as $KEY => $SCALE) {
-                    $SCALES[] = $SCALE['name'];
-                }
-
-                for ($i=0; $i<$exercise->nelements; $i++) {
-                    $iplus1 = $i+1;
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td align=\"right\"><p><b>". get_string("element","exercise")." $iplus1:</b></p></td>\n";
-                    echo "<td><textarea name=\"description[]\" rows=\"3\" cols=\"75\" wrap=\"virtual\">".
-                        $elements[$i]->description."</textarea>\n";
-                    echo "  </td></tr>\n";
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td align=\"right\"><p><b>". get_string("typeofscale", "exercise"). ":</b></p></td>\n";
-                    echo "<td valign=\"top\">\n";
-                    choose_from_menu($SCALES, "scale[]", $elements[$i]->scale, "");
-                    if ($elements[$i]->weight == '') { // not set
-                        $elements[$i]->weight = 11; // unity
-                    }
-                    echo "</td></tr>\n";
-                    echo "<tr valign=\"top\"><td align=\"right\"><b>".get_string("elementweight", "exercise").
-                        ":</b></td><td>\n";
-                    exercise_choose_from_menu($EXERCISE_EWEIGHTS, "weight[]", $elements[$i]->weight, "");
-                    echo "      </td>\n";
-                    echo "</tr>\n";
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td colspan=\"2\">&nbsp;</td>\n";
-                    echo "</tr>\n";
-                }
-                break;
-
-            case 2: // error banded grading
-                for ($i=0; $i<$exercise->nelements; $i++) {
-                    $iplus1 = $i+1;
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td align=\"right\"><p><b>". get_string("element","exercise")." $iplus1:</b></p></td>\n";
-                    echo "<td><textarea name=\"description[$i]\" rows=\"3\" cols=\"75\" wrap=\"virtual\">".
-                        $elements[$i]->description."</textarea>\n";
-                    echo "  </td></tr>\n";
-                    if ($elements[$i]->weight == '') { // not set
-                        $elements[$i]->weight = 11; // unity
-                    }
-                    echo "</tr>\n";
-                    echo "<tr valign=\"top\"><td align=\"right\"><b>".get_string("elementweight", "exercise").
-                        ":</b></td><td>\n";
-                    exercise_choose_from_menu($EXERCISE_EWEIGHTS, "weight[]", $elements[$i]->weight, "");
-                    echo "      </td>\n";
-                    echo "</tr>\n";
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td colspan=\"2\">&nbsp;</td>\n";
-                    echo "</tr>\n";
-                }
-                echo "</center></table><br />\n";
-                echo "<p><center><b>".get_string("gradetable","exercise")."</b></p></center>\n";
-                echo "<center><table cellpadding=\"5\" border=\"1\"><tr><td align=\"CENTER\">".
-                    get_string("numberofnegativeresponses", "exercise");
-                echo "</td><td>". get_string("suggestedgrade", "exercise")."</td></tr>\n";
-                for ($j = $exercise->grade; $j >= 0; $j--) {
-                    $numbers[$j] = $j;
-                }
-                for ($i=0; $i<=$exercise->nelements; $i++) {
-                    echo "<tr><td align=\"CENTER\">$i</td><td align=\"CENTER\">";
-                    if (!isset($elements[$i])) {  // the "last one" will be!
-                        $elements[$i]->description = "";
-                        $elements[$i]->maxscore = 0;
-                    }
-                    choose_from_menu($numbers, "maxscore[$i]", $elements[$i]->maxscore, "");
-                    echo "</td></tr>\n";
-                }
-                break;
-
-            case 3: // criterion grading
-                for ($j = $exercise->grade; $j >= 0; $j--) {
-                    $numbers[$j] = $j;
-                }
-                for ($i=0; $i<$exercise->nelements; $i++) {
-                    $iplus1 = $i+1;
-                    echo "<tr valign=\"top\">\n";
-
-                    echo "  <td align=\"right\"><p><b>". get_string("criterion","exercise")." $iplus1:</b></p></td>\n";
-                    echo "<td><textarea name=\"description[$i]\" rows=\"3\" cols=\"75\" wrap=\"virtual\">".
-                        $elements[$i]->description."</textarea>\n";
-                    echo "  </td></tr>\n";
-                    echo "<tr><td><b>". get_string("suggestedgrade", "exercise").":</b></td><td>\n";
-                    choose_from_menu($numbers, "maxscore[$i]", $elements[$i]->maxscore, "");
-                    echo "</td></tr>\n";
-                    echo "<tr valign=\"top\">\n";
-
-                    echo "  <td colspan=\"2\">&nbsp;</td>\n";
-                    echo "</tr>\n";
-                }
-                break;
-
-            case 4: // rubric
-                for ($j = 100; $j >= 0; $j--) {
-                    $numbers[$j] = $j;
-                }
-                if ($rubricsraw = get_records("exercise_rubrics", "exerciseid", $exercise->id)) {
-                    foreach ($rubricsraw as $rubric) {
-                        $rubrics[$rubric->elementno][$rubric->rubricno] = $rubric->description; // reindex 0,1,2...
-                    }
-                }
-                for ($i=0; $i<$exercise->nelements; $i++) {
-                    $iplus1 = $i+1;
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td align=\"right\"><p><b>". get_string("element","exercise")." $iplus1:</b></p></td>\n";
-                    echo "<td><textarea name=\"description[$i]\" rows=\"3\" cols=\"75\" wrap=\"virtual\">".
-                        $elements[$i]->description."</textarea>\n";
-                    echo "  </td></tr>\n";
-                    echo "<tr valign=\"top\"><td align=\"right\"><b>".get_string("elementweight", "exercise").
-                        ":</b></td><td>\n";
-                    exercise_choose_from_menu($EXERCISE_EWEIGHTS, "weight[]", $elements[$i]->weight, "");
-                    echo "      </td>\n";
-                    echo "</tr>\n";
-
-                    for ($j=0; $j<5; $j++) {
-                        $jplus1 = $j+1;
-                        if (empty($rubrics[$i][$j])) {
-                            $rubrics[$i][$j] = "";
-                        }
-                        echo "<tr valign=\"top\">\n";
-                        echo "  <td align=\"right\"><p><b>". get_string("grade")." $j:</b></p></td>\n";
-                        echo "<td><textarea name=\"rubric[$i][$j]\" rows=\"3\" cols=\"75\" wrap=\"virtual\">".
-                            $rubrics[$i][$j]."</textarea>\n";
-                        echo "  </td></tr>\n";
-                    }
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td colspan=\"2\">&nbsp;</td>\n";
-                    echo "</tr>\n";
-                }
-                break;
-        }
-        // close table and form
-
-        ?>
-        </table><br />
-        <input type="submit" value="<?php  print_string("savechanges") ?>" />
-        <input type="submit" name="cancel" value="<?php  print_string("cancel") ?>" />
-        </center>
-
-        </form>
-        <?php
-    }
-
-
-    /****************** insert/update assignment elements (for teachers)***********************/
-    elseif ($action == 'insertelements') {
-
-        if (!has_capability('mod/exercise:assess', $context)) {
-            print_error("Only teachers can look at this page");
-        }
-
-        $form = data_submitted();
-
-        // let's not fool around here, dump the junk!
-        delete_records("exercise_elements", "exerciseid", $exercise->id);
-
-        // determine wich type of grading
-        switch ($exercise->gradingstrategy) {
-            case 0: // no grading
-                // Insert all the elements that contain something
-                foreach ($form->description as $key => $description) {
-                    if ($description) {
-                        unset($element);
-                        $element->description   = $description;
-                        $element->exerciseid = $exercise->id;
-                        $element->elementno = clean_param($key, PARAM_INT);
-                        if (!$element->id = insert_record("exercise_elements", $element)) {
-                            print_error("Could not insert exercise element!");
-                        }
-                    }
-                }
-                break;
-
-            case 1: // accumulative grading
-                // Insert all the elements that contain something
-                foreach ($form->description as $key => $description) {
-                    if ($description) {
-                        unset($element);
-                        $element->description   = $description;
-                        $element->exerciseid = $exercise->id;
-                        $element->elementno = clean_param($key, PARAM_INT);
-                        if (isset($form->scale[$key])) {
-                            $element->scale = $form->scale[$key];
-                            switch ($EXERCISE_SCALES[$form->scale[$key]]['type']) {
-                                case 'radio' :  $element->maxscore = $EXERCISE_SCALES[$form->scale[$key]]['size'] - 1;
-                                                break;
-                                case 'selection' :  $element->maxscore = $EXERCISE_SCALES[$form->scale[$key]]['size'];
-                                                    break;
-                            }
-                        }
-                        if (isset($form->weight[$key])) {
-                            $element->weight = $form->weight[$key];
-                        }
-                        if (!$element->id = insert_record("exercise_elements", $element)) {
-                            print_error("Could not insert exercise element!");
-                        }
-                    }
-                }
-                break;
-
-            case 2: // error banded grading...
-            case 3: // ...and criterion grading
-                // Insert all the elements that contain something, the number of descriptions is
-                // one less than the number of grades
-                foreach ($form->maxscore as $key => $themaxscore) {
-                    unset($element);
-                    $element->exerciseid = $exercise->id;
-                    $element->elementno = clean_param($key, PARAM_INT);
-                    $element->maxscore = $themaxscore;
-                    if (isset($form->description[$key])) {
-                        $element->description   = $form->description[$key];
-                    }
-                    if (isset($form->weight[$key])) {
-                        $element->weight = $form->weight[$key];
-                    }
-                    if (!$element->id = insert_record("exercise_elements", $element)) {
-                        print_error("Could not insert exercise element!");
-                    }
-                }
-                break;
-
-            case 4: // ...and criteria grading
-                // Insert all the elements that contain something
-                foreach ($form->description as $key => $description) {
-                    unset($element);
-                    $element->exerciseid = $exercise->id;
-                    $element->elementno = clean_param($key, PARAM_INT);
-                    $element->description   = $description;
-                    $element->weight = $form->weight[$key];
-                    for ($j=0;$j<5;$j++) {
-                        if (empty($form->rubric[$key][$j]))
-                            break;
-                    }
-                    $element->maxscore = $j - 1;
-                    if (!$element->id = insert_record("exercise_elements", $element)) {
-                        print_error("Could not insert exercise element!");
-                    }
-                }
-                // let's not fool around here, dump the junk!
-                delete_records("exercise_rubrics", "exerciseid", $exercise->id);
-                for ($i=0;$i<$exercise->nelements;$i++) {
-                    for ($j=0;$j<5;$j++) {
-                        unset($element);
-                        if (empty($form->rubric[$i][$j])) {  // OK to have an element with fewer than 5 items
-                             break;
-                        }
-                        $element->exerciseid = $exercise->id;
-                        $element->elementno = $i;
-                        $element->rubricno = $j;
-                        $element->description   = $form->rubric[$i][$j];
-                        if (!$element->id = insert_record("exercise_rubrics", $element)) {
-                            print_error("Could not insert exercise element!");
-                        }
-                    }
-                }
-                break;
-        } // end of switch
-        redirect("view.php?id=$cm->id", get_string("savedok", "exercise"));
-    }
-
-
-    /****************** list assessments for grading (Student submissions)(by teachers)*********************/
-    elseif ($action == 'listungradedstudentsubmissions') {
-
-        if (!has_capability('mod/exercise:assess', $context)) {
-            print_error("Only teachers can look at this page");
-        }
-        exercise_list_ungraded_assessments($exercise, "student");
-        print_continue("view.php?id=$cm->id");
-    }
-
-
-    /***************** list assessments for grading student assessments ( linked to the
-    ******************Teacher's submissions) (by teachers)****/
-    elseif ($action == 'listungradedstudentassessments') {
-
-        if (!has_capability('mod/exercise:assess', $context)) {
-            print_error("Only teachers can look at this page");
-        }
-        exercise_list_ungraded_assessments($exercise, "teacher");
-        print_continue("view.php?id=$cm->id");
-    }
-
-
-    /****************** list teacher submissions ***********************/
-    elseif ($action == 'listteachersubmissions') {
-
-        exercise_list_teacher_submissions($exercise, $USER);
-        print_continue("view.php?id=$cm->id");
-    }
-
-
-    /******************* regrade student assessments ************************************/
-    elseif ($action == 'regradestudentassessments' ) {
-
-        if (!has_capability('mod/exercise:assess', $context)) {
-            print_error("Only teachers can look at this page");
-        }
-        // get all the student assessments
-        if ($assessments = exercise_get_teacher_submission_assessments($exercise)) {
-            foreach ($assessments as $studentassessment) {
-                if ($studentassessment->timegraded > 0) {
-                    if (!$submissions = get_records_select("exercise_submissions",
-                           "userid = $studentassessment->userid AND exerciseid = $exercise->id", "timecreated ASC")) {
-                        print_error("Regrade student assessments: student submission not found");
-                    }
-                    foreach ($submissions as $submission) { // only the first one is relavant
-                        if (!$teacherassessments = get_records("exercise_assessments", "submissionid",
-                                    $submission->id, "timecreated ASC")) {
-                            print_error("Regrade student assessments: teacher assessment(s) not found");
-                        }
-                        foreach ($teacherassessments as $teacherassessment) { // only the first one is relavent
-                            $newgrade = exercise_compare_assessments($exercise, $studentassessment, $teacherassessment);
-                            set_field("exercise_assessments", "gradinggrade", $newgrade, "id", $studentassessment->id);
-                            break;
-                        }
-                        break;
-                    }
-                }
-            }
-        }
-        redirect("submissions.php?id=$cm->id&amp;action=adminlist");
-    }
-
-
-    /****************** teacher assessment : grading of assessment and submission (from student) ************/
-    elseif ($action == 'teacherassessment') {
-
-        if (!has_capability('mod/exercise:assess', $context)) {
-            print_error("Only teachers can look at this page");
-        }
-
-        if (empty($aid)) {
-            print_error("assessment id missing");
-        }
-        if (empty($sid)) {
-            error ("no sid");
-        }
-        if (!$assessment = get_record("exercise_assessments", "id", $aid)) {
-            print_error("Teacher assessment: User's assessment record not found");
-        }
-        if (!$submission = get_record("exercise_submissions", "id", $sid)) {
-            print_error("Teacher assessment: User's submission record not found");
-        }
-        exercise_print_teacher_assessment_form($exercise, $assessment, $submission, $_SERVER["HTTP_REFERER"]);
-    }
-
-
-    /****************** teacher table : show assessments by exercise and teacher ************/
-    elseif ($action == 'teachertable') {
-
-        if (!has_capability('mod/exercise:assess', $context)) {
-            print_error("Only teachers can look at this page");
-        }
-
-        exercise_print_teacher_table($course);
-        print_continue("index.php?id=$course->id");
-    }
-
-
-    /****************** update assessment (by teacher or student) ***************************/
-    elseif ($action == 'updateassessment') {
-
-        $timenow = time();
-        $form = data_submitted();
-
-        if (empty($aid)) {
-            print_error("assessment id missing");
-        }
-        if (! $assessment = get_record("exercise_assessments", "id", $aid)) {
-            print_error("exercise assessment is misconfigured");
-        }
-
-        // first get the assignment elements for maxscores and weights...
-        if (!$elementsraw = get_records("exercise_elements", "exerciseid", $exercise->id, "elementno ASC")) {
-            print_string("noteonassignmentelements", "exercise");
-        }
-        else {
-            foreach ($elementsraw as $element) {
-                $elements[] = $element;   // to renumber index 0,1,2...
-            }
-        }
-
-        // don't fiddle about, delete all the old and then add the new!
-        delete_records("exercise_grades", "assessmentid",  $assessment->id);
-
-        //determine what kind of grading we have
-        switch ($exercise->gradingstrategy) {
-            case 0: // no grading
-                // Insert all the elements that contain something
-                foreach ($form->feedback as $key => $thefeedback) {
-                    unset($element);
-                    $element->exerciseid = $exercise->id;
-                    $element->assessmentid = $assessment->id;
-                    $element->elementno = clean_param($key, PARAM_INT);
-                    $element->feedback   = clean_param($thefeedback, PARAM_CLEAN);
-                    if (!$element->id = insert_record("exercise_grades", $element)) {
-                        print_error("Could not insert exercise element!");
-                        }
-                    }
-                $grade = 0; // set to satisfy save to db
-                break;
-
-            case 1: // accumulative grading
-                // Insert all the elements that contain something
-                foreach ($form->grade as $key => $thegrade) {
-                    unset($element);
-                    $element->exerciseid = $exercise->id;
-                    $element->assessmentid = $assessment->id;
-                    $element->elementno = clean_param($key, PARAM_INT);
-                    $element->feedback   = clean_param($form->feedback[$key], PARAM_CLEAN);
-                    $element->grade = $thegrade;
-                    if (!$element->id = insert_record("exercise_grades", $element)) {
-                        print_error("Could not insert exercise element!");
-                    }
-                }
-                // now work out the grade...
-                $rawgrade=0;
-                $totalweight=0;
-                foreach ($form->grade as $key => $grade) {
-                    $maxscore = $elements[$key]->maxscore;
-                    $weight = $EXERCISE_EWEIGHTS[$elements[$key]->weight];
-                    if ($weight > 0) {
-                        $totalweight += $weight;
-                    }
-                    $rawgrade += ($grade / $maxscore) * $weight;
-                    // echo "\$key, \$maxscore, \$weight, \$totalweight, \$grade, \$rawgrade : $key, $maxscore, $weight, $totalweight, $grade, $rawgrade<br />";
-                }
-                $grade = 100.0 * ($rawgrade / $totalweight);
-                break;
-
-            case 2: // error banded graded
-                // Insert all the elements that contain something
-                $error = 0.0;
-                for ($i =0; $i < $exercise->nelements; $i++) {
-                    unset($element);
-                    $element->exerciseid = $exercise->id;
-                    $element->assessmentid = $assessment->id;
-                    $element->elementno = $i;
-                    $element->feedback   = clean_param($form->feedback[$i], PARAM_CLEAN);
-                    $element->grade = $form->grade[$i];
-                    if (!$element->id = insert_record("exercise_grades", $element)) {
-                        print_error("Could not insert exercise element!");
-                    }
-                    if (empty($form->grade[$i])){
-                        $error += $EXERCISE_EWEIGHTS[$elements[$i]->weight];
-                    }
-                }
-                // now save the adjustment
-                unset($element);
-                $i = $exercise->nelements;
-                $element->exerciseid = $exercise->id;
-                $element->assessmentid = $assessment->id;
-                $element->elementno = $i;
-                $element->grade = $form->grade[$i];
-                if (!$element->id = insert_record("exercise_grades", $element)) {
-                    print_error("Could not insert exercise element!");
-                }
-                $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i])
-                    * 100.0 / $exercise->grade;
-                // echo "<p><b>".get_string("weightederrorcount", "exercise", intval($error + 0.5)).
-                //  " ".get_string("adjustment", "exercise").": ".$form->grade[$i]."</b>\n";
-                // check the grade for sanity!
-                if ($grade > 100.0) {
-                    $grade = 100.0;
-                }
-                if ($grade < 0.0) {
-                    $grade = 0.0;
-                }
-                break;
-
-            case 3: // criteria grading
-                // save in the selected criteria value in element zero,
-                unset($element);
-                $element->exerciseid = $exercise->id;
-                $element->assessmentid = $assessment->id;
-                $element->elementno = 0;
-                $element->grade = $form->grade[0];
-                if (!$element->id = insert_record("exercise_grades", $element)) {
-                    print_error("Could not insert exercise element!");
-                }
-                // now save the adjustment in element one
-                unset($element);
-                $element->exerciseid = $exercise->id;
-                $element->assessmentid = $assessment->id;
-                $element->elementno = 1;
-                $element->grade = $form->grade[1];
-                if (!$element->id = insert_record("exercise_grades", $element)) {
-                    print_error("Could not insert exercise element!");
-                }
-                $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]) * 100 / $exercise->grade;
-                // check the grade for sanity!
-                if ($grade >100.0) {
-                    $grade = 100.0;
-                }
-                if ($grade < 0.0) {
-                    $grade = 0.0;
-                }
-                break;
-
-            case 4: // rubric grading (identical to accumulative grading)
-                // Insert all the elements that contain something
-                foreach ($form->grade as $key => $thegrade) {
-                    unset($element);
-                    $element->exerciseid = $exercise->id;
-                    $element->assessmentid = $assessment->id;
-                    $element->elementno = clean_param($key, PARAM_INT);
-                    $element->feedback   = clean_param($form->feedback[$key], PARAM_CLEAN);
-                    $element->grade = $thegrade;
-                    if (!$element->id = insert_record("exercise_grades", $element)) {
-                        print_error("Could not insert exercise element!");
-                    }
-                }
-                // now work out the grade...
-                $rawgrade=0;
-                $totalweight=0;
-                foreach ($form->grade as $key => $grade) {
-                    $maxscore = $elements[$key]->maxscore;
-                    $weight = $EXERCISE_EWEIGHTS[$elements[$key]->weight];
-                    if ($weight > 0) {
-                        $totalweight += $weight;
-                    }
-                    $rawgrade += ($grade / $maxscore) * $weight;
-                }
-                $grade = 100.0 * ($rawgrade / $totalweight);
-                break;
-
-        } // end of switch
-
-        // update the time of the assessment record (may be re-edited)...
-        set_field("exercise_assessments", "timecreated", $timenow, "id", $assessment->id);
-        set_field("exercise_assessments", "grade", $grade, "id", $assessment->id);
-        // ...and clear any grading of this assessment (these assessments are never graded but...)
-        set_field("exercise_assessments", "timegraded", 0, "id", $assessment->id);
-        set_field("exercise_assessments", "gradinggrade", 0, "id", $assessment->id);
-
-        // any comment?
-        if (!empty($form->generalcomment)) {
-            set_field("exercise_assessments", "generalcomment", clean_param($form->generalcomment, PARAM_CLEAN), "id", $assessment->id);
-        }
-
-        // is user allowed to resubmit?
-        if (has_capability('mod/exercise:assess', $context)) {
-            if (!$submission = get_record("exercise_submissions", "id", $assessment->submissionid)) {
-                error ("Updateassessment: submission record not found");
-            }
-            if ($form->resubmit == 1) {
-                set_field("exercise_submissions", "resubmit", 1, "id", $submission->id);
-            }
-            else {
-                // clear resubmit flag
-                set_field("exercise_submissions", "resubmit", 0, "id", $submission->id);
-            }
-        }
-
-        add_to_log($course->id, "exercise", "assess", "view.php?id=$cm->id", "$assessment->id");
-
-        // set up return address
-        if (!$returnto = $form->returnto) {
-            $returnto = "view.php?id=$cm->id";
-        }
-
-        // show grade if grading strategy is not zero
-        if ($exercise->gradingstrategy) {
-            redirect($returnto, "<p align=\"center\"><b>".get_string("thegradeis", "exercise").": ".
-                number_format($grade * $exercise->grade / 100.0, 1)." (".get_string("maximumgrade").
-                " ".number_format($exercise->grade).")</b></p>", 1);
-        }
-        else {
-            redirect($returnto);
-        }
-    }
-
-
-    /****************** update teacher assessment (by teacher only) ***************************/
-    elseif ($action == 'updateteacherassessment') {
-
-        if (!has_capability('mod/exercise:assess', $context)) {
-            print_error("Only teachers can look at this page");
-        }
-
-        $timenow = time();
-        $form = data_submitted();
-
-        // first do the (teacher's) assessment of the student's submission
-        if (! $submission = get_record("exercise_submissions", "id", $form->sid)) {
-            print_error("Update teacher assessment: student's submission record not found");
-        }
-        if (!$assessment = exercise_get_submission_assessment($submission, $USER)) {
-            print_error("Update teacher assessment: teacher's assessment record not found");
-        }
-
-        // first get the assignment elements for maxscores and weights...
-        if (!$elementsraw = get_records("exercise_elements", "exerciseid", $exercise->id, "elementno ASC")) {
-            print_string("noteonassignmentelements", "exercise");
-        }
-        else {
-            foreach ($elementsraw as $element) {
-                $elements[] = $element;   // to renumber index 0,1,2...
-            }
-        }
-
-        // don't fiddle about, delete all the old and then add the new!
-        delete_records("exercise_grades", "assessmentid",  $assessment->id);
-
-        //determine what kind of grading we have
-        switch ($exercise->gradingstrategy) {
-            case 0: // no grading
-                // Insert all the elements that contain something
-                foreach ($form->feedback as $key => $thefeedback) {
-                    unset($element);
-                    $element->exerciseid = $exercise->id;
-                    $element->assessmentid = $assessment->id;
-                    $element->elementno = clean_param($key, PARAM_INT);
-                    $element->feedback   = clean_param($thefeedback, PARAM_CLEAN);
-                    if (!$element->id = insert_record("exercise_grades", $element)) {
-                        print_error("Could not insert exercise element!");
-                    }
-                }
-                $grade = 0; // set to satisfy save to db
-                break;
-
-            case 1: // accumulative grading
-                // Insert all the elements that contain something
-                foreach ($form->grade as $key => $thegrade) {
-                    unset($element);
-                    $element->exerciseid = $exercise->id;
-                    $element->assessmentid = $assessment->id;
-                    $element->elementno = clean_param($key, PARAM_INT);
-                    $element->feedback   = clean_param($form->feedback[$key], PARAM_CLEAN);
-                    $element->grade = $thegrade;
-                    if (!$element->id = insert_record("exercise_grades", $element)) {
-                        print_error("Could not insert exercise element!");
-                    }
-                }
-                // now work out the grade...
-                $rawgrade=0;
-                $totalweight=0;
-                foreach ($form->grade as $key => $grade) {
-                    $maxscore = $elements[$key]->maxscore;
-                    $weight = $EXERCISE_EWEIGHTS[$elements[$key]->weight];
-                    if ($weight > 0) {
-                        $totalweight += $weight;
-                    }
-                    $rawgrade += ($grade / $maxscore) * $weight;
-                    // echo "\$key, \$maxscore, \$weight, \$totalweight, \$grade, \$rawgrade : $key, $maxscore, $weight, $totalweight, $grade, $rawgrade<br />";
-                }
-                $grade = 100.0 * ($rawgrade / $totalweight);
-                break;
-
-            case 2: // error banded graded
-                // Insert all the elements that contain something
-                $error = 0.0;
-                for ($i =0; $i < $exercise->nelements; $i++) {
-                    unset($element);
-                    $element->exerciseid = $exercise->id;
-                    $element->assessmentid = $assessment->id;
-                    $element->elementno = $i;
-                    $element->feedback   = clean_param($form->feedback[$i], PARAM_CLEAN);
-                    $element->grade = $form->grade[$i];
-                    if (!$element->id = insert_record("exercise_grades", $element)) {
-                        print_error("Could not insert exercise element!");
-                    }
-                    if (empty($form->grade[$i])){
-                        $error += $EXERCISE_EWEIGHTS[$elements[$i]->weight];
-                    }
-                }
-                // now save the adjustment
-                unset($element);
-                $i = $exercise->nelements;
-                $element->exerciseid = $exercise->id;
-                $element->assessmentid = $assessment->id;
-                $element->elementno = $i;
-                $element->grade = $form->grade[$i];
-                if (!$element->id = insert_record("exercise_grades", $element)) {
-                    print_error("Could not insert exercise element!");
-                }
-                $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i]) * 100 / $exercise->grade;
-                echo "<p><b>".get_string("weightederrorcount", "exercise", intval($error + 0.5))."</b></p>\n";
-                break;
-
-            case 3: // criteria grading
-                // save in the selected criteria value in element zero,
-                unset($element);
-                $element->exerciseid = $exercise->id;
-                $element->assessmentid = $assessment->id;
-                $element->elementno = 0;
-                $element->grade = $form->grade[0];
-                if (!$element->id = insert_record("exercise_grades", $element)) {
-                    print_error("Could not insert exercise element!");
-                }
-                // now save the adjustment in element one
-                unset($element);
-                $element->exerciseid = $exercise->id;
-                $element->assessmentid = $assessment->id;
-                $element->elementno = 1;
-                $element->grade = $form->grade[1];
-                if (!$element->id = insert_record("exercise_grades", $element)) {
-                    print_error("Could not insert exercise element!");
-                }
-                $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]) * 100 / $exercise->grade;
-                break;
-
-            case 4: // rubric grading (identical to accumulative grading)
-                // Insert all the elements that contain something
-                foreach ($form->grade as $key => $thegrade) {
-                    unset($element);
-                    $element->exerciseid = $exercise->id;
-                    $element->assessmentid = $assessment->id;
-                    $element->elementno = clean_param($key, PARAM_INT);
-                    $element->feedback   = clean_param($form->feedback[$key], PARAM_CLEAN);
-                    $element->grade = $thegrade;
-                    if (!$element->id = insert_record("exercise_grades", $element)) {
-                        print_error("Could not insert exercise element!");
-                    }
-                }
-                // now work out the grade...
-                $rawgrade=0;
-                $totalweight=0;
-                foreach ($form->grade as $key => $grade) {
-                    $maxscore = $elements[$key]->maxscore;
-                    $weight = $EXERCISE_EWEIGHTS[$elements[$key]->weight];
-                    if ($weight > 0) {
-                        $totalweight += $weight;
-                    }
-                    $rawgrade += ($grade / $maxscore) * $weight;
-                }
-                $grade = 100.0 * ($rawgrade / $totalweight);
-                break;
-
-        } // end of switch
-
-        // update the time of the assessment record (may be re-edited)...
-        set_field("exercise_assessments", "timecreated", $timenow, "id", $assessment->id);
-        set_field("exercise_assessments", "grade", $grade, "id", $assessment->id);
-        // ...and clear any grading of this assessment (never needed but...)
-        set_field("exercise_assessments", "timegraded", 0, "id", $assessment->id);
-        set_field("exercise_assessments", "gradinggrade", 0, "id", $assessment->id);
-
-        // any comment?
-        if (!empty($form->generalcomment)) {
-            set_field("exercise_assessments", "generalcomment", clean_param($form->generalcomment, PARAM_CLEAN), "id", $assessment->id);
-        }
-
-        // now calculate the (grading) grade of the student's assessment...
-        if (!$stassessment = get_record("exercise_assessments", "id", $form->said)) {
-            print_error("Update teacher assessment: student's assessment record not found");
-        }
-        $gradinggrade = exercise_compare_assessments($exercise, $assessment, $stassessment);
-        // ...and save the grade for the assessment
-        set_field("exercise_assessments", "gradinggrade", $gradinggrade, "id", $stassessment->id);
-        set_field("exercise_assessments", "timegraded", $timenow, "id", $stassessment->id);
-        set_field("exercise_assessments", "mailed", 0, "id", $stassessment->id);
-        echo "<centre><b>".get_string("savedok", "exercise")."</b></centre><br />\n";
-
-        add_to_log($course->id, "exercise", "grade", "view.php?id=$cm->id", "$stassessment->id");
-
-        // is user allowed to resubmit?
-        if ($form->resubmit == 1) {
-            set_field("exercise_submissions", "resubmit", 1, "id", $submission->id);
-        }
-        else {
-            // clear resubmit flag
-            set_field("exercise_submissions", "resubmit", 0, "id", $submission->id);
-        }
-
-        add_to_log($course->id, "exercise", "assess", "view.php?id=$cm->id", "$assessment->id");
-
-        // set up return address
-        if (!$returnto = $form->returnto) {
-            $returnto = "view.php?id=$cm->id";
-        }
-
-        // show grade if grading strategy is not zero
-        if ($exercise->gradingstrategy) {
-            redirect($returnto, "<p align=\"center\"><b>".get_string("gradeforstudentsassessment",
-                "exercise", $course->student).": ".number_format($gradinggrade * $exercise->gradinggrade / 100.0, 1).
-                " (".get_string("maximumgrade")." ".number_format($exercise->gradinggrade, 1).")</b></p><p><b>".
-                get_string("thegradeis", "exercise").": ".number_format($grade * $exercise->grade / 100.0, 1).
-                " (".get_string("maximumgrade")." ".number_format($exercise->grade, 1).")</b></p>");
-        }
-        else {
-            redirect($returnto);
-        }
-    }
-
-
-    /****************** update grading grade(by teacher) ***************************/
-    elseif ($action == 'updategradinggrade') {
-
-        if (!has_capability('mod/exercise:assess', $context)) {
-            print_error("Only teachers can look at this page");
-            }
-
-        if (empty($aid)) {
-            print_error("submission id missing");
-        }
-        // normalise gradinggrade
-        $gradinggrade = $_POST['gradinggrade'] * 100 / $exercise->gradinggrade;
-        if (!set_field("exercise_assessments", "gradinggrade", $gradinggrade, "id",
-                    $aid)) {
-            print_error("Update grading grade: asseesment not updated");
-        }
-        redirect("submissions.php?id=$cm->id&amp;action=adminlist", get_string("savedok", "exercise"), 1);
-    }
-
-
-    /****************** user confirm delete ************************************/
-    elseif ($action == 'userconfirmdelete' ) {
-
-        if (empty($aid)) {
-            print_error("User confirm delete: assessment id missing");
-        }
-
-        notice_yesno(get_string("confirmdeletionofthisitem","exercise", get_string("assessment", "exercise")),
-             "assessments.php?action=userdelete&amp;id=$cm->id&amp;aid=$aid", "view.php?id=$cm->id");
-    }
-
-
-    /****************** user delete ************************************/
-    elseif ($action == 'userdelete' ) {
-
-        if (empty($aid)) {
-            print_error("User delete: assessment id missing");
-        }
-
-        print_string("deleting", "exercise");
-        // first delete all the associated records...
-        delete_records("exercise_grades", "assessmentid", $aid);
-        // ...now delete the assessment...
-        delete_records("exercise_assessments", "id", $aid);
-
-        print_continue("view.php?id=$cm->id");
-    }
-
-
-    /****************** view assessment ***********************/
-    elseif ($action == 'viewassessment') {
-
-        if (empty($aid)) {
-            print_error("assessment id missing");
-        }
-
-        // get the assessment record
-        if (!$assessment = get_record("exercise_assessments", "id", $aid)) {
-            print_error("Assessment record not found");
-        }
-
-        // show assessment but don't allow changes
-        exercise_print_assessment_form($exercise, $assessment);
-
-        print_continue("view.php?id=$cm->id");
-    }
-
-
-    /*************** no man's land **************************************/
-    else {
-        print_error("Fatal Error: Unknown Action: ".$action."\n");
-    }
-
-    print_footer($course);
-
-?>
diff --git a/mod/exercise/backuplib.php b/mod/exercise/backuplib.php
deleted file mode 100644 (file)
index dc158fc..0000000
+++ /dev/null
@@ -1,466 +0,0 @@
-<?php //$Id$
-    //This php script contains all the stuff to backup/restore
-    //exercise mods
-
-    //This is the "graphical" structure of the exercise mod: 
-    //
-    //                                          exercise
-    //                                         (CL,pk->id)             
-    //                                             |
-    //                                             |
-    //                                             |
-    //              |------------------------------|---------------------------------------------|
-    //              |                                                                            |
-    //              |                                                                            |
-    //              |                                                                   exercise_submissions
-    //              |                                                        (UL,pk->id,fk->exerciseid,files)
-    //              |                                                                            |
-    //              |                                                                            |
-    //              |                                                                            |
-    //              |        |---------------------|      |------------------------------|       |
-    //              |        |                     |      |                              |       |
-    //        exercise_elements                 exercise_grades                    exercise_assessments
-    //    (CL,pk->id,fk->exerciseid)      (UL,pk->id,fk->assessmentid)         (UL,pk->id,fk->submissionid)
-    //              |                     (          fk->elementno   )  
-    //              |                                                        
-    //              |                                                        
-    //          exercise_rubrics             
-    //    (CL,pk->id,fk->elementno)          
-    //
-    // Meaning: pk->primary key field of the table
-    //          fk->foreign key to link with parent
-    //          nt->nested field (recursive data)
-    //          CL->course level info
-    //          UL->user level info
-    //          files->table may have files)
-    //
-    //-----------------------------------------------------------
-
-    //This function executes all the backup procedure about this mod
-    function exercise_backup_mods($bf,$preferences) {
-
-        global $CFG;
-
-        $status = true;
-
-        //Iterate over exercise table
-        $exercises = get_records ("exercise","course",$preferences->backup_course,"id");
-        if ($exercises) {
-            foreach ($exercises as $exercise) {
-                if (backup_mod_selected($preferences,'exercise',$exercise->id)) {
-                    $status = exercise_backup_one_mod($bf,$preferences,$exercise);
-                }
-            }
-        }
-        return $status;  
-    }
-
-    function exercise_backup_one_mod($bf,$preferences,$exercise) {
-
-        global $CFG;
-    
-        if (is_numeric($exercise)) {
-            $exercise = get_record('exercise','id',$exercise);
-        }
-    
-        $status = true;
-
-        //Start mod
-        fwrite ($bf,start_tag("MOD",3,true));
-        //Print exercise data
-        fwrite ($bf,full_tag("ID",4,false,$exercise->id));
-        fwrite ($bf,full_tag("MODTYPE",4,false,"exercise"));
-        fwrite ($bf,full_tag("NAME",4,false,$exercise->name));
-        fwrite ($bf,full_tag("NELEMENTS",4,false,$exercise->nelements));
-        fwrite ($bf,full_tag("PHASE",4,false,$exercise->phase));
-        fwrite ($bf,full_tag("GRADINGSTRATEGY",4,false,$exercise->gradingstrategy));
-        fwrite ($bf,full_tag("USEMAXIMUM",4,false,$exercise->usemaximum));
-        fwrite ($bf,full_tag("ASSESSMENTCOMPS",4,false,$exercise->assessmentcomps));
-        fwrite ($bf,full_tag("ANONYMOUS",4,false,$exercise->anonymous));
-        fwrite ($bf,full_tag("MAXBYTES",4,false,$exercise->maxbytes));
-        fwrite ($bf,full_tag("DEADLINE",4,false,$exercise->deadline));
-        fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$exercise->timemodified));
-        fwrite ($bf,full_tag("GRADE",4,false,$exercise->grade));
-        fwrite ($bf,full_tag("GRADINGGRADE",4,false,$exercise->gradinggrade));
-        fwrite ($bf,full_tag("SHOWLEAGUETABLE",4,false,$exercise->showleaguetable));
-        fwrite ($bf,full_tag("USEPASSWORD",4,false,$exercise->usepassword));
-        fwrite ($bf,full_tag("PASSWORD",4,false,$exercise->password));
-        //Now we backup exercise elements
-        $status = backup_exercise_elements($bf,$preferences,$exercise->id);
-        //Now we backup any teacher submissions (these are an integral part of the exercise)
-        $status = backup_exercise_submissions($bf, $preferences, $exercise->id);
-        //End mod
-        $status =fwrite ($bf,end_tag("MOD",3,true));
-        //we need to backup the teacher files (the exercise descriptions)
-        $status = backup_exercise_teacher_files($bf, $preferences, $exercise->id);
-        //if we've selected to backup users info, then backup files too
-        if ($status) {
-            if (backup_userdata_selected($preferences,'exercise',$exercise->id)) {
-                $status = backup_exercise_student_files($bf,$preferences, $exercise->id);
-            }
-        }
-
-        return $status;
-    }
-
-    //Backup exercise_elements contents (executed from exercise_backup_mods)
-    function backup_exercise_elements ($bf,$preferences,$exercise) {
-
-        global $CFG;
-
-        $status = true;
-
-        $exercise_elements = get_records("exercise_elements","exerciseid",$exercise,"id");
-        //If there is exercise_elements
-        if ($exercise_elements) {
-            //Write start tag
-            $status =fwrite ($bf,start_tag("ELEMENTS",4,true));
-            //Iterate over each element
-            foreach ($exercise_elements as $element) {
-                //Start element
-                $status =fwrite ($bf,start_tag("ELEMENT",5,true));
-                //Print element contents
-                fwrite ($bf,full_tag("ELEMENTNO",6,false,$element->elementno));
-                fwrite ($bf,full_tag("DESCRIPTION",6,false,$element->description));
-                fwrite ($bf,full_tag("SCALE",6,false,$element->scale));
-                fwrite ($bf,full_tag("MAXSCORE",6,false,$element->maxscore));
-                fwrite ($bf,full_tag("WEIGHT",6,false,$element->weight));
-                //Now we backup exercise rubrics
-                $status = backup_exercise_rubrics($bf,$preferences,$exercise,$element->elementno);
-                //End element
-                $status =fwrite ($bf,end_tag("ELEMENT",5,true));
-            }
-            //Write end tag
-            $status =fwrite ($bf,end_tag("ELEMENTS",4,true));
-        }
-        return $status;
-    }
-
-    //Backup exercise_rubrics contents (executed from backup_exercise_elements)
-    function backup_exercise_rubrics ($bf,$preferences,$exercise,$elementno) {
-
-        global $CFG;
-
-        $status = true;
-
-        $exercise_rubrics = get_records_sql("SELECT * from {$CFG->prefix}exercise_rubrics r
-                                             WHERE r.exerciseid = '$exercise' and r.elementno = '$elementno'
-                                             ORDER BY r.elementno");
-
-        //If there is exercise_rubrics
-        if ($exercise_rubrics) {
-            //Write start tag
-            $status =fwrite ($bf,start_tag("RUBRICS",6,true));
-            //Iterate over each element
-            foreach ($exercise_rubrics as $rubric) {
-                //Start rubric
-                $status =fwrite ($bf,start_tag("RUBRIC",7,true));
-                //Print rubric contents
-                fwrite ($bf,full_tag("RUBRICNO",8,false,$rubric->rubricno));
-                fwrite ($bf,full_tag("DESCRIPTION",8,false,$rubric->description));
-                //End rubric
-                $status =fwrite ($bf,end_tag("RUBRIC",7,true));
-            }
-            //Write end tag
-            $status =fwrite ($bf,end_tag("RUBRICS",6,true));
-        }
-        return $status;
-    }
-
-    //Backup exercise_submissions contents (executed from exercise_backup_mods)
-    function backup_exercise_submissions ($bf,$preferences,$exerciseid) {
-
-        global $CFG;
-
-        $status = true;
-
-        $exercise_submissions = get_records_select("exercise_submissions","exerciseid = $exerciseid
-                AND isexercise = 1");
-        //If there is submissions
-        if ($exercise_submissions) {
-            //Write start tag
-            $status =fwrite ($bf,start_tag("SUBMISSIONS",4,true));
-            //Iterate over each submission
-            foreach ($exercise_submissions as $submission) {
-                //Start submission
-                $status =fwrite ($bf,start_tag("SUBMISSION",5,true));
-                //Print submission contents
-                fwrite ($bf,full_tag("ID",6,false,$submission->id));       
-                fwrite ($bf,full_tag("USERID",6,false,$submission->userid));       
-                fwrite ($bf,full_tag("TITLE",6,false,$submission->title));       
-                fwrite ($bf,full_tag("TIMECREATED",6,false,$submission->timecreated));       
-                fwrite ($bf,full_tag("RESUBMIT",6,false,$submission->resubmit));       
-                fwrite ($bf,full_tag("MAILED",6,false,$submission->mailed));       
-                fwrite ($bf,full_tag("ISEXERCISE",6,false,$submission->isexercise));       
-                fwrite ($bf,full_tag("LATE",6,false,$submission->late));       
-                //Now we backup any exercise assessments (if student data required)
-                if (backup_userdata_selected($preferences,'exercise',$exerciseid)) {
-                    $status = backup_exercise_assessments($bf,$preferences,$exerciseid,$submission->id);
-                }
-                //End submission
-                $status =fwrite ($bf,end_tag("SUBMISSION",5,true));
-            }
-            //if we've selected to backup users info, then backup the student submisions
-            if (backup_userdata_selected($preferences,'exercise',$exerciseid)) {
-                $exercise_submissions = get_records_select("exercise_submissions","exerciseid = $exerciseid
-                        AND isexercise = 0");
-                //If there is submissions
-                if ($exercise_submissions) {
-                    //Iterate over each submission
-                    foreach ($exercise_submissions as $submission) {
-                        //Start submission
-                        $status =fwrite ($bf,start_tag("SUBMISSION",5,true));
-                        //Print submission contents
-                        fwrite ($bf,full_tag("ID",6,false,$submission->id));       
-                        fwrite ($bf,full_tag("USERID",6,false,$submission->userid));       
-                        fwrite ($bf,full_tag("TITLE",6,false,$submission->title));       
-                        fwrite ($bf,full_tag("TIMECREATED",6,false,$submission->timecreated));       
-                        fwrite ($bf,full_tag("RESUBMIT",6,false,$submission->resubmit));       
-                        fwrite ($bf,full_tag("MAILED",6,false,$submission->mailed));       
-                        fwrite ($bf,full_tag("ISEXERCISE",6,false,$submission->isexercise));       
-                        fwrite ($bf,full_tag("LATE",6,false,$submission->late));       
-                        //Now we backup any exercise assessments
-                        $status = backup_exercise_assessments($bf,$preferences,$exerciseid,$submission->id);
-                        //End submission
-                        $status =fwrite ($bf,end_tag("SUBMISSION",5,true));
-                    }
-                }
-            }
-            //Write end tag
-            $status =fwrite ($bf,end_tag("SUBMISSIONS",4,true));
-        }
-        return $status;
-    }
-
-    //Backup exercise_student_submissions contents (executed from exercise_backup_mods)
-    function backup_exercise_student_submissions ($bf,$preferences,$exerciseid) {
-
-        global $CFG;
-
-        $status = true;
-
-        return $status;
-    }
-
-    //Backup exercise_assessments contents (executed from backup_exercise_submissions)
-    function backup_exercise_assessments ($bf,$preferences,$exercise,$submission) {
-
-        global $CFG;
-
-        $status = true;
-
-        //NOTE: I think that the exerciseid can go out (submissionid is a good unique fk), but mantain it, as is in db !!
-        $exercise_assessments = get_records_sql("SELECT * from {$CFG->prefix}exercise_assessments a
-                                                 WHERE a.exerciseid = '$exercise' and a.submissionid = '$submission'
-                                                 ORDER BY a.id");
-
-        //If there is exercise_assessments
-        if ($exercise_assessments) {
-            //Write start tag
-            $status =fwrite ($bf,start_tag("ASSESSMENTS",6,true));
-            //Iterate over each assessment
-            foreach ($exercise_assessments as $wor_ass) {
-                //Start assessment
-                $status =fwrite ($bf,start_tag("ASSESSMENT",7,true));
-                //Print assessment contents
-                fwrite ($bf,full_tag("ID",8,false,$wor_ass->id));
-                fwrite ($bf,full_tag("USERID",8,false,$wor_ass->userid));
-                fwrite ($bf,full_tag("TIMECREATED",8,false,$wor_ass->timecreated));
-                fwrite ($bf,full_tag("TIMEGRADED",8,false,$wor_ass->timegraded));
-                fwrite ($bf,full_tag("GRADE",8,false,$wor_ass->grade));
-                fwrite ($bf,full_tag("GRADINGGRADE",8,false,$wor_ass->gradinggrade));
-                fwrite ($bf,full_tag("MAILED",8,false,$wor_ass->mailed));
-                fwrite ($bf,full_tag("GENERALCOMMENT",8,false,$wor_ass->generalcomment));
-                fwrite ($bf,full_tag("TEACHERCOMMENT",8,false,$wor_ass->teachercomment));
-                //Now we backup exercise grades
-                $status = backup_exercise_grades($bf,$preferences,$exercise,$wor_ass->id);
-                //End assessment
-                $status =fwrite ($bf,end_tag("ASSESSMENT",7,true));
-            }
-            //Write end tag
-            $status =fwrite ($bf,end_tag("ASSESSMENTS",6,true));
-        }
-        return $status;
-    }
-
-
-    //Backup exercise_grades contents (executed from backup_exercise_assessments)
-    function backup_exercise_grades ($bf,$preferences,$exercise,$assessmentid) {
-
-        global $CFG;
-
-        $status = true;
-
-        //NOTE: I think that the exerciseid can go out (assessmentid is a good unique fk), but mantain it, as is in db !!
-        $exercise_grades = get_records_sql("SELECT * from {$CFG->prefix}exercise_grades g
-                                              WHERE g.exerciseid = '$exercise' and g.assessmentid = '$assessmentid'
-                                              ORDER BY g.elementno");
-
-        //If there is exercise_grades
-        if ($exercise_grades) {
-            //Write start tag
-            $status =fwrite ($bf,start_tag("GRADES",8,true));
-            //Iterate over each grade
-            foreach ($exercise_grades as $wor_gra) {
-                //Start grade
-                $status =fwrite ($bf,start_tag("GRADE",9,true));
-                //Print grade contents
-                fwrite ($bf,full_tag("ELEMENTNO",10,false,$wor_gra->elementno));
-                fwrite ($bf,full_tag("FEEDBACK",10,false,$wor_gra->feedback));
-                fwrite ($bf,full_tag("GRADE_VALUE",10,false,$wor_gra->grade));
-                //End comment
-                $status =fwrite ($bf,end_tag("GRADE",9,true));
-            }
-            //Write end tag
-            $status =fwrite ($bf,end_tag("GRADES",8,true));
-        }
-        return $status;
-    }
-
-
-    //Backup the teacher's exercise files (they are an integral part of the exercise)
-    function backup_exercise_teacher_files($bf,$preferences, $exerciseid) {
-
-        global $CFG;
-       
-        $status = true;
-
-        //First we check to moddata exists and create it as necessary
-        //in temp/backup/$backup_code  dir
-        $status = check_and_create_moddata_dir($preferences->backup_unique_code);
-        //in temp/backup/$backup_code/moddate create the exercise diretory
-        $status = check_dir_exists("$CFG->dataroot/temp/backup/$preferences->backup_unique_code/moddata/exercise", true);
-        if ($status) {
-            //Now copy the submission dirs
-            if ($submissions = get_records_select("exercise_submissions", "exerciseid = $exerciseid
-                        AND isexercise = 1")) {
-                foreach ($submissions as $submission) {
-                    //Only if it exists !! Thanks to Daniel Miksik.
-                    if (is_dir("{$CFG->dataroot}/$preferences->backup_course/{$CFG->moddata}/exercise/$submission->id")) {
-                        // create directory
-                        // $status = check_dir_exists("$CFG->dataroot/temp/backup/$preferences->backup_unique_code/moddata/exercise", true);
-                        // copy all the files in the directory
-                        $status = backup_copy_file("{$CFG->dataroot}/$preferences->backup_course/{$CFG->moddata}/exercise/$submission->id", "{$CFG->dataroot}/temp/backup/$preferences->backup_unique_code/moddata/exercise/$submission->id");
-                    }
-                }
-            }
-        }
-
-        return $status;
-
-    } 
-
-    //Backup students' exercise files because we've selected to backup user info
-    //and files are user info's level
-    function backup_exercise_student_files($bf,$preferences, $exerciseid) {
-
-        global $CFG;
-       
-        $status = true;
-
-        //First we check to moddata exists and create it as necessary
-        //in temp/backup/$backup_code  dir
-        $status = check_and_create_moddata_dir($preferences->backup_unique_code);
-        if ($status) {
-            //Now copy the submission dirs
-            if ($submissions = get_records_select("exercise_submissions", "exerciseid = $exerciseid
-                        AND isexercise = 0")) {
-                foreach ($submissions as $submission) {
-                    //Only if it exists !! Thanks to Daniel Miksik.
-                    if (is_dir("{$CFG->dataroot}/$preferences->backup_course/$CFG->moddata/exercise/$submission->id")) {
-                        $status = backup_copy_file("{$CFG->dataroot}/$preferences->backup_course/{$CFG->moddata}/exercise/$submission->id", "{$CFG->dataroot}/temp/backup/$preferences->backup_unique_code/moddata/exercise/$submission->id");
-                    }
-                }
-            }
-        }
-
-        return $status;
-
-    } 
-
-    //Return an array of info (name,value)
-    function exercise_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
-        if (!empty($instances) && is_array($instances) && count($instances)) {
-            $info = array();
-            foreach ($instances as $id => $instance) {
-                $info += exercise_check_backup_mods_instances($instance,$backup_unique_code);
-            }
-            return $info;
-        }
-        //First the course data
-        $info[0][0] = get_string("modulenameplural","exercise");
-        if ($ids = exercise_ids ($course)) {
-            $info[0][1] = count($ids);
-        } else {
-            $info[0][1] = 0;
-        }
-
-        //Now, if requested, the user_data
-        if ($user_data) {
-            $info[1][0] = get_string("submissions","exercise");
-            if ($ids = exercise_submission_ids_by_course ($course)) { 
-                $info[1][1] = count($ids);
-            } else {
-                $info[1][1] = 0;
-            }
-        }
-        return $info;
-    }
-
-    //Return an array of info (name,value)
-    function exercise_check_backup_mods_instances($instance,$backup_unique_code) {
-        //First the course data
-        $info[$instance->id.'0'][0] = '<b>'.$instance->name.'</b>';
-        $info[$instance->id.'0'][1] = '';
-
-        //Now, if requested, the user_data
-        if (!empty($instance->userdata)) {
-            $info[$instance->id.'1'][0] = get_string("submissions","exercise");
-            if ($ids = exercise_submission_ids_by_instance ($instance->id)) { 
-                $info[$instance->id.'1'][1] = count($ids);
-            } else {
-                $info[$instance->id.'1'][1] = 0;
-            }
-        }
-        return $info;
-    }
-
-
-
-
-
-
-    // INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE
-
-    //Returns an array of exercise id 
-    function exercise_ids ($course) {
-
-        global $CFG;
-
-        return get_records_sql ("SELECT w.id, w.course
-                                 FROM {$CFG->prefix}exercise w
-                                 WHERE w.course = '$course'");
-    }
-    
-    //Returns an array of exercise_submissions id
-    function exercise_submission_ids_by_course ($course) {
-
-        global $CFG;
-
-        return get_records_sql ("SELECT s.id , s.exerciseid
-                                 FROM {$CFG->prefix}exercise_submissions s,
-                                      {$CFG->prefix}exercise w
-                                 WHERE w.course = '$course' AND
-                                       s.exerciseid = w.id");
-    }
-
-    //Returns an array of exercise_submissions id
-    function exercise_submission_ids_by_instance ($instanceid) {
-
-        global $CFG;
-
-        return get_records_sql ("SELECT s.id , s.exerciseid
-                                 FROM {$CFG->prefix}exercise_submissions s
-                                 WHERE s.exerciseid = $instanceid");
-    }
-?>
diff --git a/mod/exercise/construction_icon.gif b/mod/exercise/construction_icon.gif
deleted file mode 100755 (executable)
index 1611162..0000000
Binary files a/mod/exercise/construction_icon.gif and /dev/null differ
diff --git a/mod/exercise/db/access.php b/mod/exercise/db/access.php
deleted file mode 100644 (file)
index ebedaae..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-//
-// Capability definitions for the exercise module.
-//
-// The capabilities are loaded into the database table when the module is
-// installed or updated. Whenever the capability definitions are updated,
-// the module version number should be bumped up.
-//
-// The system has four possible values for a capability:
-// CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT, and inherit (not set).
-//
-//
-// CAPABILITY NAMING CONVENTION
-//
-// It is important that capability names are unique. The naming convention
-// for capabilities that are specific to modules and blocks is as follows:
-//   [mod/block]/<component_name>:<capabilityname>
-//
-// component_name should be the same as the directory name of the mod or block.
-//
-// Core moodle capabilities are defined thus:
-//    moodle/<capabilityclass>:<capabilityname>
-//
-// Examples: mod/forum:viewpost
-//           block/recent_activity:view
-//           moodle/site:deleteuser
-//
-// The variable name for the capability definitions array follows the format
-//   $<componenttype>_<component_name>_capabilities
-//
-// For the core capabilities, the variable is $moodle_capabilities.
-
-
-$mod_exercise_capabilities = array(
-
-    'mod/exercise:assess' => array(
-
-        'captype' => 'write',
-        'contextlevel' => CONTEXT_MODULE,
-        'legacy' => array(
-            'teacher' => CAP_ALLOW,
-            'editingteacher' => CAP_ALLOW,
-            'admin' => CAP_ALLOW
-        )
-    )
-
-);
-
-?>
diff --git a/mod/exercise/db/install.xml b/mod/exercise/db/install.xml
deleted file mode 100644 (file)
index e63f760..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/exercise/db" VERSION="20060810" COMMENT="XMLDB file for Moodle mod/exercise">
-  <TABLES>
-    <TABLE NAME="exercise" COMMENT="Defines exercise" NEXT="exercise_submissions">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="course"/>
-        <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="name"/>
-        <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="course" NEXT="nelements"/>
-        <FIELD NAME="nelements" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="phase"/>
-        <FIELD NAME="phase" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="nelements" NEXT="gradingstrategy"/>
-        <FIELD NAME="gradingstrategy" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="phase" NEXT="usemaximum"/>
-        <FIELD NAME="usemaximum" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="gradingstrategy" NEXT="assessmentcomps"/>
-        <FIELD NAME="assessmentcomps" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="2" SEQUENCE="false" ENUM="false" PREVIOUS="usemaximum" NEXT="anonymous"/>
-        <FIELD NAME="anonymous" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="assessmentcomps" NEXT="maxbytes"/>
-        <FIELD NAME="maxbytes" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="100000" SEQUENCE="false" ENUM="false" PREVIOUS="anonymous" NEXT="deadline"/>
-        <FIELD NAME="deadline" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="maxbytes" NEXT="timemodified"/>
-        <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="deadline" NEXT="grade"/>
-        <FIELD NAME="grade" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timemodified" NEXT="gradinggrade"/>
-        <FIELD NAME="gradinggrade" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="grade" NEXT="showleaguetable"/>
-        <FIELD NAME="showleaguetable" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="gradinggrade" NEXT="usepassword"/>
-        <FIELD NAME="usepassword" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="showleaguetable" NEXT="password"/>
-        <FIELD NAME="password" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="usepassword"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" />
-      </KEYS>
-      <INDEXES>
-        <INDEX NAME="course" UNIQUE="false" FIELDS="course"/>
-      </INDEXES>
-    </TABLE>
-    <TABLE NAME="exercise_submissions" COMMENT="Info about submitted work from teacher and students" PREVIOUS="exercise" NEXT="exercise_assessments">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="exerciseid"/>
-        <FIELD NAME="exerciseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="userid"/>
-        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="exerciseid" NEXT="title"/>
-        <FIELD NAME="title" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="timecreated"/>
-        <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="title" NEXT="resubmit"/>
-        <FIELD NAME="resubmit" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timecreated" NEXT="mailed"/>
-        <FIELD NAME="mailed" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="resubmit" NEXT="isexercise"/>
-        <FIELD NAME="isexercise" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="mailed" NEXT="late"/>
-        <FIELD NAME="late" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="isexercise"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="exerciseid"/>
-        <KEY NAME="exerciseid" TYPE="foreign" FIELDS="exerciseid" REFTABLE="exercise" REFFIELDS="id" PREVIOUS="primary"/>
-      </KEYS>
-      <INDEXES>
-        <INDEX NAME="userid" UNIQUE="false" FIELDS="userid"/>
-      </INDEXES>
-    </TABLE>
-    <TABLE NAME="exercise_assessments" COMMENT="Info about assessments by teacher and students" PREVIOUS="exercise_submissions" NEXT="exercise_elements">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="exerciseid"/>
-        <FIELD NAME="exerciseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="submissionid"/>
-        <FIELD NAME="submissionid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="exerciseid" NEXT="userid"/>
-        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="submissionid" NEXT="timecreated"/>
-        <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="timegraded"/>
-        <FIELD NAME="timegraded" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timecreated" NEXT="grade"/>
-        <FIELD NAME="grade" TYPE="float" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timegraded" NEXT="gradinggrade"/>
-        <FIELD NAME="gradinggrade" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="grade" NEXT="mailed"/>
-        <FIELD NAME="mailed" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="gradinggrade" NEXT="generalcomment"/>
-        <FIELD NAME="generalcomment" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="mailed" NEXT="teachercomment"/>
-        <FIELD NAME="teachercomment" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="generalcomment"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="exerciseid"/>
-        <KEY NAME="exerciseid" TYPE="foreign" FIELDS="exerciseid" REFTABLE="exercise" REFFIELDS="id" PREVIOUS="primary" NEXT="submissionid"/>
-        <KEY NAME="submissionid" TYPE="foreign" FIELDS="submissionid" REFTABLE="exercise_submissions" REFFIELDS="id" PREVIOUS="exerciseid"/>
-      </KEYS>
-      <INDEXES>
-        <INDEX NAME="userid" UNIQUE="false" FIELDS="userid"/>
-      </INDEXES>
-    </TABLE>
-    <TABLE NAME="exercise_elements" COMMENT="Info about marking scheme of assignment" PREVIOUS="exercise_assessments" NEXT="exercise_rubrics">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="exerciseid"/>
-        <FIELD NAME="exerciseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="elementno"/>
-        <FIELD NAME="elementno" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="exerciseid" NEXT="description"/>
-        <FIELD NAME="description" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="elementno" NEXT="scale"/>
-        <FIELD NAME="scale" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="description" NEXT="maxscore"/>
-        <FIELD NAME="maxscore" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="scale" NEXT="weight"/>
-        <FIELD NAME="weight" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="11" SEQUENCE="false" ENUM="false" PREVIOUS="maxscore"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="exerciseid"/>
-        <KEY NAME="exerciseid" TYPE="foreign" FIELDS="exerciseid" REFTABLE="exercise" REFFIELDS="id" PREVIOUS="primary"/>
-      </KEYS>
-    </TABLE>
-    <TABLE NAME="exercise_rubrics" COMMENT="Info about the rubrics marking scheme" PREVIOUS="exercise_elements" NEXT="exercise_grades">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="exerciseid"/>
-        <FIELD NAME="exerciseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="elementno"/>
-        <FIELD NAME="elementno" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="exerciseid" NEXT="rubricno"/>
-        <FIELD NAME="rubricno" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="elementno" NEXT="description"/>
-        <FIELD NAME="description" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="rubricno"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="exerciseid"/>
-        <KEY NAME="exerciseid" TYPE="foreign" FIELDS="exerciseid" REFTABLE="exercise" REFFIELDS="id" PREVIOUS="primary"/>
-      </KEYS>
-    </TABLE>
-    <TABLE NAME="exercise_grades" COMMENT="Info about individual grades given to each element" PREVIOUS="exercise_rubrics">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="exerciseid"/>
-        <FIELD NAME="exerciseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="assessmentid"/>
-        <FIELD NAME="assessmentid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="exerciseid" NEXT="elementno"/>
-        <FIELD NAME="elementno" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="assessmentid" NEXT="feedback"/>
-        <FIELD NAME="feedback" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="elementno" NEXT="grade"/>
-        <FIELD NAME="grade" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="feedback"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="exerciseid"/>
-        <KEY NAME="exerciseid" TYPE="foreign" FIELDS="exerciseid" REFTABLE="exercise" REFFIELDS="id" PREVIOUS="primary" NEXT="assessmentid"/>
-        <KEY NAME="assessmentid" TYPE="foreign" FIELDS="assessmentid" REFTABLE="exercise_assessements" REFFIELDS="id" PREVIOUS="exerciseid"/>
-      </KEYS>
-    </TABLE>
-  </TABLES>
-  <STATEMENTS>
-    <STATEMENT NAME="insert log_display" TYPE="insert" TABLE="log_display" COMMENT="Initial insert of records on table log_display">
-      <SENTENCES>
-        <SENTENCE TEXT="(module, action, mtable, field) VALUES ('exercise', 'close', 'exercise', 'name')" />
-        <SENTENCE TEXT="(module, action, mtable, field) VALUES ('exercise', 'open', 'exercise', 'name')" />
-        <SENTENCE TEXT="(module, action, mtable, field) VALUES ('exercise', 'submit', 'exercise', 'name')" />
-        <SENTENCE TEXT="(module, action, mtable, field) VALUES ('exercise', 'view', 'exercise', 'name')" />
-        <SENTENCE TEXT="(module, action, mtable, field) VALUES ('exercise', 'update', 'exercise', 'name')" />
-      </SENTENCES>
-    </STATEMENT>
-  </STATEMENTS>
-</XMLDB>
diff --git a/mod/exercise/db/mysql.php b/mod/exercise/db/mysql.php
deleted file mode 100644 (file)
index d2a0f46..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function exercise_upgrade($oldversion) {
-// This function does anything necessary to upgrade
-// older versions to match current functionality
-
-    global $CFG;
-
-    if ($oldversion < 2003111400) {
-        execute_sql(" ALTER TABLE `{$CFG->prefix}exercise_submissions` ADD INDEX (`userid`)");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}exercise_submissions` DROP INDEX `title`");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}exercise_assessments` ADD INDEX (`submissionid`)");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}exercise_assessments` ADD INDEX (`userid`)");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}exercise_grades` ADD INDEX (`assessmentid`)");
-    }
-    
-    if ($oldversion < 2003121000) {
-        execute_sql(" ALTER TABLE `{$CFG->prefix}exercise_submissions` ADD `late` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0'");
-    }
-
-    if ($oldversion < 2004062300) {
-        table_column("exercise", "", "gradinggrade", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "grade");
-        table_column("exercise", "", "assessmentcomps", "INTEGER", "4", "UNSIGNED", "2", "NOT NULL", "usemaximum");
-        execute_sql("ALTER TABLE `{$CFG->prefix}exercise` DROP COLUMN `teacherweight`");
-        execute_sql("ALTER TABLE `{$CFG->prefix}exercise` DROP COLUMN `gradingweight`");
-    }
-
-    if ($oldversion < 2004090200) {
-        table_column("exercise", "", "usepassword", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL");
-        table_column("exercise", "", "password", "VARCHAR", "32", "", "", "NOT NULL");
-    }
-
-    if ($oldversion < 2004091000) {
-        table_column("exercise_assessments","generalcomment","generalcomment","text","","","","NOT NULL");
-        table_column("exercise_assessments","teachercomment","teachercomment","text","","","","NOT NULL");
-    }
-
-    if ($oldversion < 2004100800) {
-        include_once("$CFG->dirroot/mod/exercise/lib.php");
-        exercise_refresh_events();
-    }
-
-    if ($oldversion < 2004111200) {
-        execute_sql("ALTER TABLE {$CFG->prefix}exercise DROP INDEX course;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}exercise_submissions DROP INDEX exerciseid;",false); 
-        execute_sql("ALTER TABLE {$CFG->prefix}exercise_assessments DROP INDEX exerciseid;",false); 
-        execute_sql("ALTER TABLE {$CFG->prefix}exercise_elements DROP INDEX exerciseid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}exercise_rubrics DROP INDEX exerciseid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}exercise_grades DROP INDEX exerciseid;",false);
-
-        modify_database('','ALTER TABLE prefix_exercise ADD INDEX course (course);');
-        modify_database('','ALTER TABLE prefix_exercise_submissions ADD INDEX exerciseid (exerciseid);');
-        modify_database('','ALTER TABLE prefix_exercise_assessments ADD INDEX exerciseid (exerciseid);');
-        modify_database('','ALTER TABLE prefix_exercise_elements ADD INDEX exerciseid (exerciseid);');
-        modify_database('','ALTER TABLE prefix_exercise_rubrics ADD INDEX exerciseid (exerciseid);');
-        modify_database('','ALTER TABLE prefix_exercise_grades ADD INDEX exerciseid (exerciseid);');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-
-?>
diff --git a/mod/exercise/db/postgres7.php b/mod/exercise/db/postgres7.php
deleted file mode 100644 (file)
index a78c6e8..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function exercise_upgrade($oldversion) {
-// This function does anything necessary to upgrade
-// older versions to match current functionality
-
-    global $CFG;
-
-    if ($oldversion < 2004062300) {
-        table_column("exercise", "", "gradinggrade", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "grade");
-        table_column("exercise", "", "assessmentcomps", "INTEGER", "4", "UNSIGNED", "2", "NOT NULL", "usemaximum");
-    }
-
-    if ($oldversion < 2004090200) {
-        table_column("exercise", "", "usepassword", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL");
-        table_column("exercise", "", "password", "VARCHAR", "32", "", "", "NOT NULL");
-    }
-
-    if ($oldversion < 2004091000) {
-        table_column("exercise_assessments","generalcomment","generalcomment","text","","","","NOT NULL");
-        table_column("exercise_assessments","teachercomment","teachercomment","text","","","","NOT NULL");
-    }
-
-    if ($oldversion < 2004100800) {
-        include_once("$CFG->dirroot/mod/exercise/lib.php");
-        exercise_refresh_events();
-    }
-
-    if ($oldversion < 2004111200) {
-        execute_sql("DROP INDEX {$CFG->prefix}exercise_course_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}exercise_submissions_exerciseid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}exercise_assessments_exerciseid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}exercise_rubrics_exerciseid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}exercise_grades_exerciseid_idx;",false);
-
-        modify_database('','CREATE INDEX prefix_exercise_course_idx ON prefix_exercise (course);');
-        modify_database('','CREATE INDEX prefix_exercise_submissions_exerciseid_idx ON prefix_exercise_submissions (exerciseid);');
-        modify_database('','CREATE INDEX prefix_exercise_assessments_exerciseid_idx ON prefix_exercise_assessments (exerciseid);');
-        modify_database('','CREATE INDEX prefix_exercise_rubrics_exerciseid_idx ON prefix_exercise_rubrics (exerciseid);');
-        modify_database('','CREATE INDEX prefix_exercise_grades_exerciseid_idx ON prefix_exercise_grades (exerciseid);');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-
-?>
diff --git a/mod/exercise/db/upgrade.php b/mod/exercise/db/upgrade.php
deleted file mode 100644 (file)
index 6ad8536..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php  //$Id$
-
-// This file keeps track of upgrades to 
-// the exercise module
-//
-// Sometimes, changes between versions involve
-// alterations to database structures and other
-// major things that may break installations.
-//
-// The upgrade function in this file will attempt
-// to perform all the necessary actions to upgrade
-// your older installtion to the current version.
-//
-// If there's something it cannot do itself, it
-// will tell you what you need to do.
-//
-// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
-
-function xmldb_exercise_upgrade($oldversion=0) {
-
-    global $CFG, $THEME, $db;
-
-    $result = true;
-
-    if ($result && $oldversion < 2007110500) {
-        $table = new XMLDBTable('exercise_submissions');
-        $field = new XMLDBField('late');
-        $field->setAttributes(XMLDB_TYPE_INTEGER, '3', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0, 'isexercise');
-        $result = $result && add_field($table, $field);
-    }
-
-    return $result;
-}
-
-?>
diff --git a/mod/exercise/defaults.php b/mod/exercise/defaults.php
deleted file mode 100644 (file)
index c5a0cb5..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php  // $Id$
-    if (empty($CFG->exercise_initialdisable)) {
-        if (!count_records('exercise')) {
-            set_field('modules', 'visible', 0, 'name', 'exercise');  // Disable it by default
-            set_config('exercise_initialdisable', 1);
-        }
-    }
-
-?>
diff --git a/mod/exercise/icon.gif b/mod/exercise/icon.gif
deleted file mode 100644 (file)
index a40a640..0000000
Binary files a/mod/exercise/icon.gif and /dev/null differ
diff --git a/mod/exercise/icon.png b/mod/exercise/icon.png
deleted file mode 100644 (file)
index 466d4b7..0000000
Binary files a/mod/exercise/icon.png and /dev/null differ
diff --git a/mod/exercise/icon2.gif b/mod/exercise/icon2.gif
deleted file mode 100644 (file)
index a40a640..0000000
Binary files a/mod/exercise/icon2.gif and /dev/null differ
diff --git a/mod/exercise/icon2.png b/mod/exercise/icon2.png
deleted file mode 100644 (file)
index 466d4b7..0000000
Binary files a/mod/exercise/icon2.png and /dev/null differ
diff --git a/mod/exercise/index.php b/mod/exercise/index.php
deleted file mode 100644 (file)
index 6a8084c..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-<?php // $Id$
-
-    require_once("../../config.php");
-    require_once("lib.php");
-    require_once("locallib.php");
-
-    $id = required_param('id', PARAM_INT); // course
-
-    if (! $course = get_record("course", "id", $id)) {
-        print_error("Course ID is incorrect");
-    }
-
-    require_login($course->id);
-    add_to_log($course->id, "exercise", "view all", "index.php?id=$course->id", "");
-
-    $strexercises = get_string("modulenameplural", "exercise");
-    $strexercise = get_string("modulename", "exercise");
-    $strweek = get_string("week");
-    $strtopic = get_string("topic");
-    $strname = get_string("name");
-    $strtitle = get_string("title", "exercise");
-    $strphase = get_string("phase", "exercise");
-    $strgrade = get_string("grade");
-    $strdeadline = get_string("deadline", "exercise");
-    $strsubmitted = get_string("submitted", "assignment");
-    
-    $navlinks = array();
-    $navlinks[] = array('name' => $strexercises, 'link' => '', 'type' => 'activity');
-    $navigation = build_navigation($navlinks);
-    
-    print_header_simple("$strexercises", "", $navigation, "", "", true, "", navmenu($course));
-
-    if (! $exercises = get_all_instances_in_course("exercise", $course)) {
-        notice(get_string('thereareno', 'moodle', $strexercises), "../../course/view.php?id=$course->id");
-        die;
-    }
-
-    $timenow = time();
-
-    if ($course->format == "weeks") {
-        if (isteacher($course->id)) {
-            $table->head  = array ($strweek, $strname, $strtitle, $strphase, $strsubmitted, $strdeadline);
-        } else {
-            $table->head  = array ($strweek, $strname, $strtitle, $strgrade, $strsubmitted, $strdeadline);
-        }
-        $table->align = array ("center", "left", "left","center","left", "left");
-    } else if ($course->format == "topics") {
-        if (isteacher($course->id)) {
-            $table->head  = array ($strtopic, $strname, $strtitle, $strphase, $strsubmitted, $strdeadline);
-        } else {
-            $table->head  = array ($strtopic, $strname, $strtitle, $strgrade, $strsubmitted, $strdeadline);
-        }
-        $table->align = array ("center", "left", "left", "center", "left", "left");
-    } else {
-        $table->head  = array ($strname, $strsubmitted, $strdeadline);
-        $table->align = array ("left", "left", "left");
-    }
-
-    foreach ($exercises as $exercise) {
-        if ($exercise->deadline > $timenow) {
-            $due = userdate($exercise->deadline);
-        } else {
-            $due = "<font color=\"red\">".userdate($exercise->deadline)."</font>";
-        }
-        if ($submissions = exercise_get_user_submissions($exercise, $USER)) {
-            foreach ($submissions as $submission) {
-                if ($submission->late) {
-                    $submitted = "<font color=\"red\">".userdate($submission->timecreated)."</font>";
-                    } 
-                else {
-                    $submitted = userdate($submission->timecreated);
-                    }
-                $link = "<a href=\"view.php?id=$exercise->coursemodule\">".format_string($exercise->name,true)."</a>";
-                $title = $submission->title;
-                if ($course->format == "weeks" or $course->format == "topics") {
-                    if (isteacher($course->id)) {
-                        $phase = '';
-                        switch ($exercise->phase) {
-                            case 0:
-                            case 1: $phase = get_string("phase1short", "exercise");
-                                    break;
-                            case 2: $phase = get_string("phase2short", "exercise");
-                                    if ($num = exercise_count_unassessed_student_submissions($exercise)) {
-                                        $phase .= " [".get_string("unassessed", "exercise", $num)."]";
-                                    }
-                                    break;
-                            case 3: $phase = get_string("phase3short", "exercise");
-                                    if ($num = exercise_count_unassessed_student_submissions($exercise)) {
-                                        $phase .= " [".get_string("unassessed", "exercise", $num)."]";
-                                    }
-                                    break;
-                        }
-                        $table->data[] = array ($exercise->section, $link, $title, $phase, 
-                                $submitted, $due);
-                    } else { // it's a student
-                        if ($assessments = exercise_get_user_assessments($exercise, $USER)) { // should be only one...
-                            foreach ($assessments as $studentassessment) {
-                                break;
-                            }
-                            if ($studentassessment->timegraded) { // it's been assessed
-                                if ($teacherassessment = exercise_get_submission_assessment($submission)) {
-                                    $actualgrade = number_format(($studentassessment->gradinggrade * 
-                                        $exercise->gradinggrade / 100.0) + ($teacherassessment->grade * 
-                                        $exercise->grade / 100.0), 1);
-                                    if ($submission->late) {
-                                        $actualgrade = "<font color=\"red\">(".$actualgrade.")<font color=\"red\">";
-                                    }
-                                    $actualgrade .= " (".get_string("maximumshort").": ".
-                                        number_format($exercise->gradinggrade + $exercise->grade, 0).")";
-                                    $table->data[] = array ($exercise->section, $link, $title, $actualgrade, 
-                                        $submitted, $due);
-                                }
-                            } else {
-                                $table->data[] = array ($exercise->section, $link, $title, 
-                                    "-", $submitted, $due);
-                            }
-                        }
-                    } 
-                } else {
-                    $table->data[] = array ($link, $submitted, $due);
-                }
-            }
-        } else {
-            $submitted = get_string("no");
-            $title = '';
-            $link = "<a href=\"view.php?id=$exercise->coursemodule\">".format_string($exercise->name,true)."</a>";
-            if ($course->format == "weeks" or $course->format == "topics") {
-                if (isteacher($course->id)) {
-                    $table->data[] = array ($exercise->section, $link, $title, $exercise->phase, 
-                            $submitted, $due);
-                } else {
-                    $table->data[] = array ($exercise->section, $link, $title, "-", $submitted, $due);
-                } 
-            } else {
-                $table->data[] = array ($link, $submitted, $due);
-            }
-        }
-    }
-    echo "<br />";
-
-    print_table($table);
-
-    print_footer($course);
-?>
diff --git a/mod/exercise/lib.php b/mod/exercise/lib.php
deleted file mode 100644 (file)
index 28abcb5..0000000
+++ /dev/null
@@ -1,752 +0,0 @@
-<?php  // $Id: lib.php,v 1.1 23 Aug 2003
-
-// exercise constants and standard moodle functions plus those functions called directly
-// see locallib.php for other non-standard exercise functions
-
-require_once($CFG->libdir.'/filelib.php');
-require_once('locallib.php');
-
-/*** Constants **********************************/
-
-$EXERCISE_TYPE = array (0 => get_string("notgraded", "exercise"),
-                          1 => get_string("accumulative", "exercise"),
-                          2 => get_string("errorbanded", "exercise"),
-                          3 => get_string("criterion", "exercise"),
-                          4 => get_string("rubric", "exercise") );
-
-$EXERCISE_SCALES = array(
-                    0 => array( 'name' => get_string("scaleyes", "exercise"), 'type' => 'radio', 'size' => 2, 'start' => get_string("yes"), 'end' => get_string("no")),
-                    1 => array( 'name' => get_string("scalepresent", "exercise"), 'type' => 'radio', 'size' => 2, 'start' => get_string("present", "exercise"), 'end' => get_string("absent", "exercise")),
-                    2 => array( 'name' => get_string("scalecorrect", "exercise"), 'type' => 'radio', 'size' => 2, 'start' => get_string("correct", "exercise"), 'end' => get_string("incorrect", "exercise")),
-                    3 => array( 'name' => get_string("scalegood3", "exercise"), 'type' => 'radio', 'size' => 3, 'start' => get_string("good", "exercise"), 'end' => get_string("poor", "exercise")),
-                    4 => array( 'name' => get_string("scaleexcellent4", "exercise"), 'type' => 'radio', 'size' => 4, 'start' => get_string("excellent", "exercise"), 'end' => get_string("verypoor", "exercise")),
-                    5 => array( 'name' => get_string("scaleexcellent5", "exercise"), 'type' => 'radio', 'size' => 5, 'start' => get_string("excellent", "exercise"), 'end' => get_string("verypoor", "exercise")),
-                    6 => array( 'name' => get_string("scaleexcellent7", "exercise"), 'type' => 'radio', 'size' => 7, 'start' => get_string("excellent", "exercise"), 'end' => get_string("verypoor", "exercise")),
-                    7 => array( 'name' => get_string("scale10", "exercise"), 'type' => 'selection', 'size' => 10),
-                    8 => array( 'name' => get_string("scale20", "exercise"), 'type' => 'selection', 'size' => 20),
-                    9 => array( 'name' => get_string("scale100", "exercise"), 'type' => 'selection', 'size' => 100));
-
-$EXERCISE_EWEIGHTS = array(  0 => -4.0, 1 => -2.0, 2 => -1.5, 3 => -1.0, 4 => -0.75, 5 => -0.5,  6 => -0.25,
-                             7 => 0.0, 8 => 0.25, 9 => 0.5, 10 => 0.75, 11=> 1.0, 12 => 1.5, 13=> 2.0, 14 => 4.0);
-
-$EXERCISE_ASSESSMENT_COMPS = array (
-                          0 => array('name' => get_string("verylax", "exercise"), 'value' => 1),
-                          1 => array('name' => get_string("lax", "exercise"), 'value' => 0.6),
-                          2 => array('name' => get_string("fair", "exercise"), 'value' => 0.4),
-                          3 => array('name' => get_string("strict", "exercise"), 'value' => 0.33),
-                          4 => array('name' => get_string("verystrict", "exercise"), 'value' => 0.2) );
-
-/*** Standard Moodle functions ******************
-function exercise_add_instance($exercise)
-function exercise_choose_from_menu ($options, $name, $selected="", $nothing="choose", $script="", $nothingvalue="0", $return=false) {
-function exercise_cron ()
-function exercise_delete_instance($id)
-function exercise_grades($exerciseid)
-function exercise_print_recent_activity(&$logs, $isteacher=false)
-function exercise_update_instance($exercise)
-function exercise_user_outline($course, $user, $mod, $exercise)
-function exercise_user_complete($course, $user, $mod, $exercise)
-**********************************************/
-
-/*******************************************************************/
-function exercise_add_instance($exercise) {
-// Given an object containing all the necessary data,
-// (defined by the form in mod.html) this function
-// will create a new instance and return the id number
-// of the new instance.
-
-    $exercise->timemodified = time();
-
-    // encode password if necessary
-    if (!empty($exercise->password)) {
-        $exercise->password = md5($exercise->password);
-    } else {
-        unset($exercise->password);
-    }
-
-    if ($returnid = insert_record("exercise", $exercise)) {
-
-        $event = NULL;
-        $event->name        = $exercise->name;
-        $event->description = $exercise->description;
-        $event->courseid    = $exercise->course;
-        $event->groupid     = 0;
-        $event->userid      = 0;
-        $event->modulename  = 'exercise';
-        $event->instance    = $returnid;
-        $event->eventtype   = 'deadline';
-        $event->timestart   = $exercise->deadline;
-        $event->timeduration = 0;
-
-        add_event($event);
-    }
-
-
-    return $returnid;
-}
-
-
-/*******************************************************************/
-function exercise_choose_from_menu ($options, $name, $selected="", $nothing="choose", $script="", $nothingvalue="0", $return=false) {
-/// Given an array of value, creates a popup menu to be part of a form
-/// $options["value"]["label"]
-
-    if ($nothing == "choose") {
-        $nothing = get_string("choose")."...";
-    }
-
-    if ($script) {
-        $javascript = "onChange=\"$script\"";
-    } else {
-        $javascript = "";
-    }
-
-    $output = "<select name=\"$name\" $javascript>\n";
-    if ($nothing) {
-        $output .= "   <option value=\"$nothingvalue\"\n";
-        if ($nothingvalue == $selected) {
-            $output .= " selected=\"selected\"";
-        }
-        $output .= ">$nothing</option>\n";
-    }
-    if (!empty($options)) {
-        foreach ($options as $value => $label) {
-            $output .= "   <option value=\"$value\"";
-            if ($value == $selected) {
-                $output .= " selected=\"selected\"";
-            }
-            // stop zero label being replaced by array index value
-            // if ($label) {
-            //    $output .= ">$label</option>\n";
-            // } else {
-            //     $output .= ">$value</option>\n";
-            //  }
-            $output .= ">$label</option>\n";
-
-        }
-    }
-    $output .= "</select>\n";
-
-    if ($return) {
-        return $output;
-    } else {
-        echo $output;
-    }
-}
-
-
-/*******************************************************************/
-function exercise_cron() {
-// Function to be run periodically according to the moodle cron
-// Finds all exercise notifications that have yet to be mailed out, and mails them
-
-    global $CFG, $USER;
-
-    $cutofftime = time() - $CFG->maxeditingtime;
-
-    // look for new assessments
-    if ($assessments = exercise_get_unmailed_assessments($cutofftime)) {
-        $timenow = time();
-
-        foreach ($assessments as $assessment) {
-            echo "Processing exercise assessment $assessment->id\n";
-            // switch on mailed
-            if (! set_field("exercise_assessments", "mailed", "1", "id", "$assessment->id")) {
-                echo "Could not update the mailed field for id $assessment->id\n";
-                }
-            if (! $submission = get_record("exercise_submissions", "id", "$assessment->submissionid")) {
-                echo "Could not find submission $assessment->submissionid\n";
-                continue;
-            }
-            if (! $exercise = get_record("exercise", "id", $submission->exerciseid)) {
-                echo "Could not find exercise record for id $submission->exerciseid\n";
-                continue;
-            }
-            if (! $course = get_record("course", "id", "$exercise->course")) {
-                echo "Could not find course $exercise->course\n";
-                continue;
-            }
-            if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-                print_error("Course Module ID was incorrect");
-                continue;
-            }
-            if (! $submissionowner = get_record("user", "id", "$submission->userid")) {
-                echo "Could not find user $submission->userid\n";
-                continue;
-            }
-            if (! $assessmentowner = get_record("user", "id", "$assessment->userid")) {
-                echo "Could not find user $assessment->userid\n";
-                continue;
-            }
-            if (! isstudent($course->id, $submissionowner->id) and !isteacher($course->id, $submissionowner->id)) {
-                continue;  // Not an active participant
-            }
-            if (! isstudent($course->id, $assessmentowner->id) and !isteacher($course->id, $assessmentowner->id)) {
-                continue;  // Not an active participant
-            }
-
-            // if the submission belongs to a teacher it's a student assessment. No need to email anything.
-            if (isteacher($course->id, $submissionowner->id)) {
-                continue;
-            }
-
-            $strexercises = get_string("modulenameplural", "exercise");
-            $strexercise  = get_string("modulename", "exercise");
-
-            // it's an assessment, tell the submission owner
-            $USER->lang = $submissionowner->lang;
-            $sendto = $submissionowner;
-            // "Your assignment \"$submission->title\" has been assessed by"
-            $msg = get_string("mail1", "exercise", $submission->title).' '.fullname($assessmentowner).".\n";
-            // "The comments and grade can be seen in the exercise assignment '$exercise->name'
-            $msg .= get_string("mail2", "exercise", format_string($exercise->name,true))."\n\n";
-
-            $postsubject = "$course->shortname: $strexercises: ".format_string($exercise->name,true);
-            $posttext  = "$course->shortname -> $strexercises -> ".format_string($exercise->name,true)."\n";
-            $posttext .= "---------------------------------------------------------------------\n";
-            $posttext .= $msg;
-            // "You can see it in your exercise assignment"
-            $posttext .= get_string("mail3", "exercise").":\n";
-            $posttext .= "   $CFG->wwwroot/mod/exercise/view.php?id=$cm->id\n";
-            $posttext .= "---------------------------------------------------------------------\n";
-            if ($sendto->mailformat == 1) {  // HTML
-                $posthtml = "<p><font face=\"sans-serif\">".
-              "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->".
-              "<a href=\"$CFG->wwwroot/mod/exercise/index.php?id=$course->id\">$strexercises</a> ->".
-              "<a href=\"$CFG->wwwroot/mod/exercise/view.php?id=$cm->id\">".format_string($exercise->name,true)."</a></font></p>";
-              $posthtml .= "<hr /><font face=\"sans-serif\">";
-              $posthtml .= "<p>$msg</p>";
-              $posthtml .= "<p>".get_string("mail3", "exercise").
-                  " <a href=\"$CFG->wwwroot/mod/exercise/view.php?id=$cm->id\">".format_string($exercise->name,true)."</a>.</p></font><hr />";
-            } else {
-              $posthtml = "";
-            }
-
-            if (!$teacher = get_teacher($course->id)) {
-                echo "Error: can not find teacher for course $course->id!\n";
-            }
-
-            if (! email_to_user($sendto, $teacher, $postsubject, $posttext, $posthtml)) {
-                echo "Error: exercise cron: Could not send out mail for id $submission->id to user $sendto->id ($sendto->email)\n";
-            }
-        }
-    }
-    return true;
-}
-
-
-/*******************************************************************/
-function exercise_delete_instance($id) {
-// Given an ID of an instance of this module,
-// this function will permanently delete the instance
-// and any data that depends on it.
-
-    if (! $exercise = get_record("exercise", "id", "$id")) {
-        return false;
-    }
-
-    // delete all the associated records in the exercise tables, start positive...
-    $result = true;
-
-    if (! delete_records("exercise_grades", "exerciseid", "$exercise->id")) {
-        $result = false;
-    }
-
-    if (! delete_records("exercise_rubrics", "exerciseid", "$exercise->id")) {
-        $result = false;
-    }
-
-    if (! delete_records("exercise_elements", "exerciseid", "$exercise->id")) {
-        $result = false;
-    }
-
-    if (! delete_records("exercise_assessments", "exerciseid", "$exercise->id")) {
-        $result = false;
-    }
-
-    if (! delete_records("exercise_submissions", "exerciseid", "$exercise->id")) {
-        $result = false;
-    }
-
-    if (! delete_records("exercise", "id", "$exercise->id")) {
-        $result = false;
-    }
-
-    return $result;
-}
-
-
-/*******************************************************************/
-function exercise_grades($exerciseid) {
-/// Must return an array of grades, indexed by user, and a max grade.
-    if (!$exercise = get_record("exercise", "id", $exerciseid)) {
-        print_error("Exercise record not found");
-    }
-
-    if (! $course = get_record("course", "id", $exercise->course)) {
-        print_error("Course is misconfigured");
-    }
-
-    if (!$return->maxgrade = ($exercise->grade + $exercise->gradinggrade)) {
-        return NULL;
-    }
-    // how to handle multiple submissions?
-    if ($exercise->usemaximum) {
-        if ($bestgrades = exercise_get_best_submission_grades($exercise)) {
-            foreach ($bestgrades as $grade) {
-                $usergrade[$grade->userid] = $grade->grade * $exercise->grade / 100.0;
-            }
-        }
-    }
-
-    else { // use mean values
-        if ($meangrades = exercise_get_mean_submission_grades($exercise)) {
-            foreach ($meangrades as $grade) {
-                $usergrade[$grade->userid] = $grade->grade * $exercise->grade / 100.0;
-            }
-        }
-    }
-    // now get the users grading grades
-    if ($assessments = exercise_get_teacher_submission_assessments($exercise)) {
-        foreach ($assessments as $assessment) {
-            // add the grading grade if the student's work has been assessed
-            if (isset($usergrade[$assessment->userid])) {
-                $usergrade[$assessment->userid] += $assessment->gradinggrade * $exercise->gradinggrade / 100.0;
-            }
-        }
-    }
-    // tidy the numbers and set up the return array
-    if (isset($usergrade)) {
-        foreach ($usergrade as $userid => $g) {
-            $return->grades[$userid] = number_format($g, 1);
-        }
-    }
-    return $return;
-}
-
-
-/*******************************************************************/
-function exercise_print_recent_activity($course, $viewfullanmes, $timestart) {
-    global $CFG;
-
-    $isteacher = has_capability('mod/exercise:assess', get_context_instance(CONTEXT_COURSE, $course->id));
-
-    $modinfo = get_fast_modinfo($course);
-
-    // have a look for new submissions (only show to teachers)
-    $submitcontent = false;
-    if ($isteacher) {
-        if ($logs = exercise_get_submit_logs($course, $timestart)) {
-            // if we got some 'live' ones then output them
-            $submitcontent = true;
-            print_headline(get_string('exercisesubmissions', 'exercise').':');
-            foreach ($logs as $log) {
-                print_recent_activity_note($log->time, $log, $log->name,
-                                           $CFG->wwwroot.'/mod/exercise/'.str_replace('&', '&amp;', $log->url));
-            }
-        }
-    }
-
-    // have a look for new assessment gradings for this user
-    $gradecontent = false;
-    if ($logs = exercise_get_grade_logs($course, $timestart)) {
-        // got some, see if any belong to a visible module
-        foreach ($logs as $id=>$log) {
-            $cm = $modinfo->instances['exercise'][$log->exerciseid];
-            if (!$cm->uservisible) {
-                unset($logs[$id]);
-                continue;
-            }
-        }
-        // if we got some "live" ones then output them
-        if ($logs) {
-            $gradecontent = true;
-            print_headline(get_string('exercisefeedback', 'exercise').':');
-            foreach ($logs as $log) {
-                print_recent_activity_note($log->time, $log, $log->name,
-                                           $CFG->wwwroot.'/mod/exercise/'.str_replace('&', '&amp;', $log->url));
-            }
-        }
-    }
-
-    // have a look for new assessments for this user
-    $assesscontent = false;
-    if (!$isteacher) { // teachers only need to see submissions
-        if ($logs = exercise_get_assess_logs($course, $timestart)) {
-            // got some, see if any belong to a visible module
-            foreach ($logs as $id=>$log) {
-                $cm = $modinfo->instances['exercise'][$log->exerciseid];
-                if (!$cm->uservisible) {
-                    unset($logs[$id]);
-                    continue;
-                }
-            }
-            // if we got some "live" ones then output them
-            if ($logs) {
-                $assesscontent = true;
-                print_headline(get_string('exerciseassessments', 'exercise').':');
-                foreach ($logs as $log) {
-                    print_recent_activity_note($log->time, $log, $log->name,
-                                               $CFG->wwwroot.'/mod/exercise/'.str_replace('&', '&amp;', $log->url));
-                }
-            }
-        }
-    }
-    return $submitcontent or $gradecontent or $assesscontent;
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-function exercise_refresh_events($courseid = 0) {
-// This standard function will check all instances of this module
-// and make sure there are up-to-date events created for each of them.
-// If courseid = 0, then every exercise event in the site is checked, else
-// only exercise events belonging to the course specified are checked.
-// This function is used, in its new format, by restore_refresh_events()
-
-    if ($courseid == 0) {
-        if (! $exercises = get_records("exercise")) {
-            return true;
-        }
-    } else {
-        if (! $exercises = get_records("exercise", "course", $courseid)) {
-            return true;
-        }
-    }
-    $moduleid = get_field('modules', 'id', 'name', 'exercise');
-
-    foreach ($exercises as $exercise) {
-        $event = NULL;
-        $event->name        = addslashes($exercise->name);
-        $event->description = addslashes($exercise->description);
-        $event->timestart   = $exercise->deadline;
-
-        if ($event->id = get_field('event', 'id', 'modulename', 'exercise', 'instance', $exercise->id)) {
-            update_event($event);
-
-        } else {
-            $event->courseid    = $exercise->course;
-            $event->groupid     = 0;
-            $event->userid      = 0;
-            $event->modulename  = 'exercise';
-            $event->instance    = $exercise->id;
-            $event->eventtype   = 'deadline';
-            $event->timeduration = 0;
-            $event->visible     = get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $exercise->id);
-            add_event($event);
-        }
-
-    }
-    return true;
-}
-
-
-/*******************************************************************/
-function exercise_update_instance($exercise) {
-// Given an object containing all the necessary data,
-// (defined by the form in mod.html) this function
-// will update an existing instance with new data.
-
-    $exercise->timemodified = time();
-
-    // encode password if necessary
-    if (!empty($exercise->password)) {
-        $exercise->password = md5($exercise->password);
-    } else {
-        unset($exercise->password);
-    }
-
-    $exercise->id = $exercise->instance;
-
-    if ($returnid = update_record("exercise", $exercise)) {
-
-        $event = NULL;
-
-        if ($event->id = get_field('event', 'id', 'modulename', 'exercise', 'instance', $exercise->id)) {
-
-            $event->name        = $exercise->name;
-            $event->description = $exercise->description;
-            $event->timestart   = $exercise->deadline;
-
-            update_event($event);
-        }
-    }
-
-    return $returnid;
-}
-
-
-/*******************************************************************/
-function exercise_user_complete($course, $user, $mod, $exercise) {
-    if ($submissions = exercise_get_user_submissions($exercise, $user)) {
-        print_simple_box_start();
-        $table->head = array (get_string("submission", "exercise"),  get_string("submitted", "exercise"),
-            get_string("assessed", "exercise"), get_string("grade"));
-        $table->width = "100%";
-        $table->align = array ("left", "left", "left", "center");
-        $table->size = array ("*", "*", "*", "*");
-        $table->cellpadding = 2;
-        $table->cellspacing = 0;
-
-        foreach ($submissions as $submission) {
-            if ($assessments = exercise_get_assessments($submission)) {
-                // should only be one but we'll loop anyway
-                foreach ($assessments as $assessment) {
-                    $table->data[] = array(exercise_print_submission_title($exercise, $submission),
-                            userdate($submission->timecreated), userdate($assessment->timecreated),
-                            $assessment->grade * $exercise->grade / 100.0);
-                }
-            } else {
-                // submission not yet assessed (by teacher)
-                $table->data[] = array(exercise_print_submission_title($exercise, $submission),
-                        userdate($submission->timecreated), get_string("notassessedyet", "exercise"), 0);
-            }
-        }
-        print_table($table);
-        print_simple_box_end();
-    } else {
-        print_string("nosubmissions", "exercise");
-    }
-}
-
-
-/*******************************************************************/
-function exercise_user_outline($course, $user, $mod, $exercise) {
-    if ($submissions = exercise_get_user_submissions($exercise, $user)) {
-        $result->info = count($submissions)." ".get_string("submissions", "exercise");
-        foreach ($submissions as $submission) { // the first one is the most recent one
-            $result->time = $submission->timecreated;
-            break;
-            }
-        return $result;
-    }
-    return NULL;
-}
-
-
-/*******************************************************************/
-function exercise_get_participants($exerciseid) {
-//Returns the users with data in one exercise
-//(users with records in exercise_submissions and exercise_assessments, students)
-
-    global $CFG;
-
-    //Get students from exercise_submissions
-    $st_submissions = get_records_sql("SELECT DISTINCT u.id, u.id
-                                       FROM {$CFG->prefix}user u,
-                                            {$CFG->prefix}exercise_submissions s
-                                       WHERE s.exerciseid = '$exerciseid' and
-                                             u.id = s.userid");
-    //Get students from exercise_assessments
-    $st_assessments = get_records_sql("SELECT DISTINCT u.id, u.id
-                                 FROM {$CFG->prefix}user u,
-                                      {$CFG->prefix}exercise_assessments a
-                                 WHERE a.exerciseid = '$exerciseid' and
-                                       u.id = a.userid");
-
-    //Add st_assessments to st_submissions
-    if ($st_assessments) {
-        foreach ($st_assessments as $st_assessment) {
-            $st_submissions[$st_assessment->id] = $st_assessment;
-        }
-    }
-    //Return st_submissions array (it contains an array of unique users)
-    return ($st_submissions);
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-// Non-standard Exercise functions
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_file_area($exercise, $submission) {
-    return make_upload_directory( exercise_file_area_name($exercise, $submission) );
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_file_area_name($exercise, $submission) {
-//  Creates a directory file name, suitable for make_upload_directory()
-    global $CFG;
-
-    return "$exercise->course/$CFG->moddata/exercise/$submission->id";
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_get_assess_logs($course, $timestart) {
-    // get the "assess" entries for this user and add the first and last names...
-    global $CFG, $USER;
-    if (empty($USER->id)) {
-        return false;
-    }
-    $timethen = time() - $CFG->maxeditingtime;
-    return get_records_sql("SELECT l.time, l.url, u.firstname, u.lastname, a.exerciseid, e.name
-                             FROM {$CFG->prefix}log l,
-                                {$CFG->prefix}exercise e,
-                                {$CFG->prefix}exercise_submissions s,
-                                {$CFG->prefix}exercise_assessments a,
-                                {$CFG->prefix}user u
-                            WHERE l.time > $timestart AND l.time < $timethen
-                                AND l.course = $course->id AND l.module = 'exercise'    AND l.action = 'assess'
-                                AND a.id = l.info AND s.id = a.submissionid AND s.userid = $USER->id
-                                AND u.id = a.userid AND e.id = a.exerciseid");
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_get_assessments($submission) {
-    // Return all assessments for this submission provided they are after the editing time,
-    // ordered oldest first, newest last
-    global $CFG;
-
-    $timenow = time();
-    return get_records_select("exercise_assessments", "(submissionid = $submission->id) AND
-        (timecreated < $timenow - $CFG->maxeditingtime)", "timecreated ASC");
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_get_best_grade($submission) {
-// Returns the best grade of students' submission (there may, occassionally be more than one assessment)
-    global $CFG;
-
-    return get_record_sql("SELECT MAX(a.grade) AS grade FROM
-                        {$CFG->prefix}exercise_assessments a
-                            WHERE a.submissionid = $submission->id
-                              GROUP BY a.submissionid");
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_get_grade_logs($course, $timestart) {
-    // get the "grade" entries for this user and add the first and last names...
-    global $CFG, $USER;
-    if (empty($USER->id)) {
-        return false;
-    }
-
-    $timethen = time() - $CFG->maxeditingtime;
-    return get_records_sql("SELECT l.time, l.url, u.firstname, u.lastname, a.exerciseid, e.name
-                             FROM {$CFG->prefix}log l,
-                                {$CFG->prefix}exercise e,
-                                {$CFG->prefix}exercise_submissions s,
-                                {$CFG->prefix}exercise_assessments a,
-                                {$CFG->prefix}user u
-                            WHERE l.time > $timestart AND l.time < $timethen
-                                AND l.course = $course->id AND l.module = 'exercise'    AND l.action = 'grade'
-                                AND a.id = l.info AND s.id = a.submissionid AND a.userid = $USER->id
-                                AND u.id = s.userid AND e.id = a.exerciseid");
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_get_mean_submission_grades($exercise) {
-// Returns the mean grades of students' submissions
-// ignores hot assessments
-    global $CFG;
-
-    $timenow = time();
-    $grades = get_records_sql("SELECT DISTINCT u.userid, AVG(a.grade) AS grade FROM
-                        {$CFG->prefix}exercise_submissions s,
-                        {$CFG->prefix}exercise_assessments a
-                            WHERE
-                              s.exerciseid = $exercise->id
-                              AND s.late = 0
-                              AND a.submissionid = s.id
-                              AND a.timecreated < $timenow
-                              GROUP BY s.userid");
-    return $grades;
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_get_submit_logs($course, $timestart) {
-    // get the "submit" entries and add the first and last names...
-    global $CFG, $USER;
-
-    $timethen = time() - $CFG->maxeditingtime;
-    return get_records_sql("SELECT l.time, l.url, u.firstname, u.lastname, l.info as exerciseid, e.name
-                             FROM {$CFG->prefix}log l,
-                                {$CFG->prefix}exercise e,
-                                {$CFG->prefix}user u
-                            WHERE l.time > $timestart AND l.time < $timethen
-                                AND l.course = $course->id AND l.module = 'exercise'
-                                AND l.action = 'submit'
-                                AND e.id = l.info
-                                AND u.id = l.userid");
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_get_teacher_submission_assessments($exercise) {
-// Return all assessments on the teacher submissions, order by youngest first, oldest last
-    global $CFG;
-
-    return get_records_sql("SELECT a.* FROM {$CFG->prefix}exercise_submissions s, {$CFG->prefix}exercise_assessments a
-                            WHERE s.isexercise = 1
-                              AND s.exerciseid = $exercise->id
-                              AND a.submissionid = s.id
-                              ORDER BY a.timecreated DESC");
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_get_unmailed_assessments($cutofftime) {
-    /// Return list of (ungraded) assessments that have not been mailed out
-    global $CFG;
-    return get_records_sql("SELECT a.*, e.course, e.name
-                              FROM {$CFG->prefix}exercise_assessments a, {$CFG->prefix}exercise e
-                             WHERE a.mailed = 0
-                               AND a.timecreated < $cutofftime
-                               AND e.id = a.exerciseid");
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_get_user_submissions($exercise, $user) {
-    // return submission of user oldest first, newest last
-    // teachers submit "exercises"
-    if (! $course = get_record("course", "id", $exercise->course)) {
-        print_error("Course is misconfigured");
-        }
-    if (isteacher($course->id, $user->id)) {
-        return get_records_select("exercise_submissions",
-             "exerciseid = $exercise->id AND isexercise = 1", "timecreated" );
-        }
-    return get_records_select("exercise_submissions",
-             "exerciseid = $exercise->id AND userid = $user->id", "timecreated" );
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_print_submission_title($exercise, $submission) {
-    global $CFG;
-
-    if (!$submission->timecreated) { // a "no submission"
-        return $submission->title;
-        }
-
-    $filearea = exercise_file_area_name($exercise, $submission);
-    if ($basedir = exercise_file_area($exercise, $submission)) {
-        if (list($file) = get_directory_list($basedir)) {
-            $icon = mimeinfo("icon", $file);
-            if ($CFG->slasharguments) {
-                $ffurl = "file.php/$filearea/$file";
-            } else {
-                $ffurl = "file.php?file=/$filearea/$file";
-            }
-            return "<img src=\"$CFG->pixpath/f/$icon\" class=\"icon\" alt=\"".get_string('file')."\" />".
-                "&nbsp;<a target=\"uploadedfile\" href=\"$CFG->wwwroot/$ffurl\">$submission->title</a>";
-        }
-    }
-}
-
-function exercise_get_view_actions() {
-    return array('view','view all','display');
-}
-
-function exercise_get_post_actions() {
-    return array('assess','delete','grade','open','set up','submit');
-}
-
-?>
diff --git a/mod/exercise/locallib.php b/mod/exercise/locallib.php
deleted file mode 100644 (file)
index e15c329..0000000
+++ /dev/null
@@ -1,2947 +0,0 @@
-<?php  // $Id$
-
-/// Library of extra functions for the exercise module
-
-//////////////////////////////////////////////////////////////////////////////////////
-
-/*** Functions for the exercise module ******
-
-function exercise_add_custom_scales($exercise) {
-function exercise_compare_assessments($exercise, $assessment1, $assessment2) {
-function exercise_copy_assessment($assessment, $submission, $withfeedback = false) {
-function exercise_count_all_submissions_for_assessment($exercise, $user) {
-function exercise_count_assessments($submission) {
-function exercise_count_assessments_by_teacher($exercise, $teacher) {
-function exercise_count_student_submissions($exercise) {
-function exercise_count_teacher_assessments($exercise, $user) {
-function exercise_count_teacher_submissions($exercise) {
-function exercise_count_teacher_submissions_for_assessment($exercise, $user) {
-function exercise_count_unassessed_student_submissions($exercise) {
-function exercise_count_ungraded_assessments_student($exercise) {
-function exercise_count_ungraded_assessments_teacher($exercise) {
-function exercise_count_user_assessments($exercise, $user, $type = "all") { $type is all, student or teacher
-function exercise_count_user_assessments_done($exercise,$user) {
-function exercise_count_user_submissions($exercise, $user) {
-
-function exercise_delete_submitted_files($exercise, $submission) {
-function exercise_delete_user_files($exercise, $user, $exception) {
-
-function exercise_file_area($exercise, $submission) { <--- in lib.php
-function exercise_file_area_name($exercise, $submission) { <--- in lib.php
-
-function exercise_get_assess_logs($course, $timestart) {  <--- in lib.php
-function exercise_get_assessments($submission)   <--- in lib.php{
-function exercise_get_best_submission_grades($exercise) {  <--- in lib.php
-function exercise_get_grade_logs($course, $timestart) {  <--- in lib.php
-function exercise_get_mean_submission_grades($exercise) {  <--- in lib.php
-function exercise_get_student_submission($exercise, $user) {
-function exercise_get_student_submissions($exercise) {
-function exercise_get_submission_assessment($submission, $user) {
-function exercise_get_submit_logs($course, $timestart) {
-function exercise_get_teacher_submission_assessments($exercise) {  <--- in lib.php
-function exercise_get_teacher_submissions($exercise) {
-function exercise_get_ungraded_assessments($exercise) {
-function exercise_get_unmailed_assessments($cutofftime) {  <--- in lib.php
-function exercise_get_unmailed_graded_assessments($cutofftime) {  <--- in lib.php
-function exercise_get_user_assessments($exercise, $user) {
-function exercise_get_user_submissions($exercise, $user) {
-
-function exercise_list_all_ungraded_assessments($exercise) {
-function exercise_list_submissions_for_admin($exercise) {
-function exercise_list_teacher_assessments($exercise, $user) {
-function exercise_list_teacher_submissions($exercise, $user, $reassess) {
-function exercise_list_unassessed_student_submissions($exercise, $user) {
-function exercise_list_unassessed_teacher_submissions($exercise, $user) {
-function exercise_list_ungraded_assessments($exercise, $stype) {
-function exercise_list_user_submissions($exercise, $user) {
-
-
-function exercise_print_assessment_form($exercise, $assessment, $allowchanges, $returnto)
-function exercise_print_assessments_by_user_for_admin($exercise, $user) {
-function exercise_print_assessments_for_admin($exercise, $submission) {
-function exercise_print_assignment_info($exercise) {
-function exercise_print_difference($time) {
-function exercise_print_feedback($course, $submission) {
-function exercise_print_league_table($exercise) {
-function exercise_print_submission_assessments($exercise, $submission, $type) {
-function exercise_print_submission_title($exercise, $submission) {  <--- in lib.php
-function exercise_print_tabbed_table($table) {
-function exercise_print_teacher_assessment_form($exercise, $assessment, $submission, $returnto)
-function exercise_print_teacher_table($course) {
-function exercise_print_time_to_deadline($time) {
-function exercise_print_upload_form($exercise) {
-function exercise_print_user_assessments($exercise, $user) {
-
-function exercise_test_for_resubmission($exercise, $user) {
-function exercise_test_user_assessments($exercise, $user) {
-***************************************/
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_add_custom_scales($exercise) {
-    global $EXERCISE_SCALES;
-
-    if (! $course = get_record("course", "id", $exercise->course)) {
-        print_error("Course is misconfigured");
-    }
-
-    if ($scales = get_records("scale", "courseid", $course->id, "name ASC")) {
-        foreach ($scales as $scale) {
-            $labels = explode(",", $scale->scale);
-            $EXERCISE_SCALES[] = array('name' => $scale->name, 'type' => 'radio', 'size' => count($labels), 
-                    'start' => trim($labels[0]), 'end' => trim($labels[count($labels) - 1]));
-        }
-    }
-    return;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_compare_assessments($exercise, $assessment1, $assessment2) {
-    global $EXERCISE_ASSESSMENT_COMPS, $EXERCISE_EWEIGHTS;
-    // first get the assignment elements for maxscores...
-    $elementsraw = get_records("exercise_elements", "exerciseid", $exercise->id, "elementno ASC");
-    foreach ($elementsraw as $element) {
-        $maxscore[] = $element->maxscore;   // to renumber index 0,1,2...
-        $weight[] = $EXERCISE_EWEIGHTS[$element->weight];   // get real value and renumber index 0,1,2...
-    }
-    for ($i = 0; $i < 2; $i++) {
-        if ($i) {
-            $rawgrades = get_records("exercise_grades", "assessmentid", $assessment1->id, "elementno ASC");
-        } else {
-            $rawgrades = get_records("exercise_grades", "assessmentid", $assessment2->id, "elementno ASC");
-        }
-        foreach ($rawgrades as $grade) {
-            $grades[$i][] = $grade->grade;
-        }
-    }
-    $sumdiffs = 0;
-    $sumweights = 0;
-    switch ($exercise->gradingstrategy) {
-        case 1 : // accumulative grading and...
-        case 4 : // ...rubic grading
-            for ($i=0; $i < $exercise->nelements; $i++) {
-                $diff = ($grades[0][$i] - $grades[1][$i]) * $weight[$i] / $maxscore[$i];
-                $sumdiffs += $diff * $diff; // use squared distances
-                $sumweights += $weight[$i];
-                }
-            break;
-        case 2 :  // error banded grading
-            // ignore maxscores here, the grades are either 0 or 1,
-            for ($i=0; $i < $exercise->nelements; $i++) {
-                $diff = ($grades[0][$i] - $grades[1][$i]) * $weight[$i];
-                $sumdiffs += $diff * $diff; // use squared distances
-                $sumweights += $weight[$i];
-                }
-            break;
-        case 3 : // criterion grading
-            // here we only need to look at the difference between the "zero" grade elements
-            $diff = ($grades[0][0] - $grades[1][0]) / (count($elementsraw) - 1);
-            $sumdiffs = $diff * $diff;
-            $sumweights = 1;
-            break;
-    }            
-    // convert to a sensible grade (always out of 100)
-    $COMP = (object)$EXERCISE_ASSESSMENT_COMPS[$exercise->assessmentcomps];
-    $factor = $COMP->value;
-    $gradinggrade = (($factor - ($sumdiffs / $sumweights)) / $factor) * 100;
-    if ($gradinggrade < 0) {
-        $gradinggrade = 0;
-    }
-    return $gradinggrade;
-}
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_copy_assessment($assessment, $submission, $withfeedback = false) {
-    // adds a copy of the given assessment for the submission specified to the exercise_assessemnts table. 
-    // The grades and optionally the comments are added to the exercise_grades table. Returns the new
-    // assessment object
-    global $USER;
-    
-    $yearfromnow = time() + 365 * 86400;
-    $newassessment->exerciseid = $assessment->exerciseid;
-    $newassessment->submissionid = $submission->id;
-    $newassessment->userid = $USER->id;
-    $newassessment->timecreated = $yearfromnow;
-    $newassessment->timegraded = 0;
-    $newassessment->grade = $assessment->grade;
-    if ($withfeedback) {
-        $newassessment->generalcomment = addslashes($assessment->generalcomment);
-        $newassessment->teachercomment = addslashes($assessment->teachercomment);
-    }
-    if (!$newassessment->id = insert_record("exercise_assessments", $newassessment)) {
-        print_error("Copy Assessment: Could not insert exercise assessment!");
-    }
-
-    if ($grades = get_records("exercise_grades", "assessmentid", $assessment->id)) {
-        foreach ($grades as $grade) {
-            unset($grade->id); // clear id, insert record now seems to believe it!
-            if (!$withfeedback) {
-                $grade->feedback = '';
-            }
-            else {
-                $grade->feedback = addslashes($grade->feedback);
-                // $grade->feedback = $grade->feedback;
-            }
-            $grade->assessmentid = $newassessment->id;
-            if (!$grade->id = insert_record("exercise_grades", $grade)) {
-                print_error("Copy Assessment: Could not insert exercise grade!");
-            }
-        }
-    }
-    if ($withfeedback) {
-        // remove the slashes from comments as the new assessment record is used 
-        // in assessments and in lib
-        $newassessment->generalcomment = stripslashes($assessment->generalcomment);
-        $newassessment->teachercomment = stripslashes($assessment->teachercomment);
-    }
-    return $newassessment;
-}
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_count_all_submissions_for_assessment($exercise, $user) {
-    // looks at all submissions and deducts the number which has been assessed by this user
-    $n = 0;
-    if ($submissions = get_records_select("exercise_submissions", "exerciseid = $exercise->id AND timecreated > 0")) {
-        $n =count($submissions);
-        foreach ($submissions as $submission) {
-            $n -= count_records("exercise_assessments", "submissionid", $submission->id, "userid", $user->id);
-            }
-        }
-    return $n;
-    }
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_count_assessments($submission) {
-    // Return the (cold) assessments for this submission, 
-    global $CFG;
-    
-    $timethen = time() - $CFG->maxeditingtime;
-   return count_records_select("exercise_assessments", "submissionid = $submission->id AND
-       timecreated < $timethen");
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_count_assessments_by_teacher($exercise, $teacher) {
-    // Return the number of assessments done by a teacher 
-    
-   return count_records_select("exercise_assessments", "exerciseid = $exercise->id AND
-       userid = $teacher->id");
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_count_student_submissions($exercise) {
-    global $CFG;
-
-    // make sure it works on the site course
-    // Where is table u? I remove it, try to make SQL correct.
-    // $select = "u.course = '$exercise->course' AND";
-    // if ($exercise->course == SITEID) {
-    //     $select = '';
-    // }
-
-    return count_records_sql("SELECT count(*) FROM {$CFG->prefix}exercise_submissions s
-                            WHERE s.exerciseid = $exercise->id
-                              AND timecreated > 0");
-    }
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_count_teacher_assessments($exercise, $user) {
-    // returns the number of assessments made by teachers on user's submissions
-    
-    $n = 0;
-    if ($submissions = exercise_get_user_submissions($exercise, $user)) {
-        foreach ($submissions as $submission) {
-            if ($assessments = exercise_get_assessments($submission)) {
-                foreach ($assessments as $assessment) {
-                    // count only teacher assessments
-                    if (isteacher($exercise->course, $assessment->userid)) {
-                        $n++;
-                        }
-                    }
-                }
-            }
-        }
-    return $n;
-    }
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_count_teacher_submissions($exercise) {
-    
-     return count_records("exercise_submissions", "isexercise", 1, "exerciseid", $exercise->id);
-    }
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_count_teacher_submissions_for_assessment($exercise, $user) {
-
-    $n = 0;
-    if ($submissions = exercise_get_teacher_submissions($exercise)) {
-        $n =count($submissions);
-        foreach ($submissions as $submission) {
-            $n -= count_records("exercise_assessments", "submissionid", $submission->id, "userid", $user->id);
-            }
-        }
-    return $n;
-    }
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_count_unassessed_student_submissions($exercise) {
-// returns the number of students submissions which have not been assessed by a teacher
-    global $CFG;
-    
-    if (! $course = get_record("course", "id", $exercise->course)) {
-        print_error("Course is misconfigured");
-    }
-    $timenow = time();
-    $n = 0;
-    // look at all the student submissions, exercise_get_student_submissions is group aware
-    $groupid = get_current_group($course->id);
-    if ($submissions = exercise_get_student_submissions($exercise, "time", $groupid)) {
-        foreach ($submissions as $submission) {
-            // only look at "cold" submissions
-            if ($submission->timecreated < $timenow - $CFG->maxeditingtime) {
-                $teacherassessed = false;
-                if ($assessments = exercise_get_assessments($submission)) {
-                    foreach ($assessments as $assessment) {
-                        // exercise_get_assessments only returns "cold" assessments, look for one made by a teacher
-                        if (isteacher($course->id, $assessment->userid)) {
-                            $teacherassessed = true;
-                            break; // no need to look further
-                        }
-                    }
-                }
-                if (!$teacherassessed) {
-                    $n++;
-                }
-            }
-        }
-    }
-    return $n;
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_count_ungraded_assessments_student($exercise, $groupid = 0) {
-    // function returns the number of ungraded assessments by students of STUDENT submissions
-    
-    $n = 0;
-    if ($submissions = exercise_get_student_submissions($exercise, $groupid)) {
-        foreach ($submissions as $submission) {
-            if ($assessments = exercise_get_assessments($submission)) {
-                foreach ($assessments as $assessment) {
-                    if ($assessment->timegraded == 0) {
-                        // ignore teacher assessments
-                        if (!isteacher($exercise->course, $assessment->userid)) {
-                            $n++;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    return $n;
-    }
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_count_ungraded_assessments_teacher($exercise) {
-    // function returns the number of ungraded assessments by students of TEACHER submissions
-    global $CFG;
-
-    $timenow = time();
-    $n = 0;
-    if ($submissions = exercise_get_teacher_submissions($exercise)) {
-        foreach ($submissions as $submission) {
-            if ($assessments = exercise_get_assessments($submission)) {
-                foreach ($assessments as $assessment) {
-                    if ($assessment->timegraded == 0) {
-                        // ignore teacher assessments
-                        if (!isteacher($exercise->course, $assessment->userid)) {
-                            // must have created a little time ago
-                            if (($timenow - $assessment->timecreated) > $CFG->maxeditingtime) {
-                                $n++;
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    return $n;
-    }
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_count_user_assessments($exercise, $user, $stype = "all") {
-    // returns the number of assessments allocated/made by a user, all of them, or just those for the student or teacher submissions
-    // the student's self assessments are included in the count
-    // the maxeditingtime is NOT taken into account here also allocated assessments which have not yet
-    // been done are counted as well
-    
-    $n = 0;
-    if ($assessments = exercise_get_user_assessments($exercise, $user)) {
-         foreach ($assessments as $assessment) {
-            switch ($stype) {
-                case "all" :
-                    $n++;
-                    break;
-                case "student" :
-                     $submission = get_record("exercise_submissions", "id", $assessment->submissionid);
-                    if (isstudent($exercise->course, $submission->userid)) {
-                        $n++;
-                        }
-                    break;
-                case "teacher" :
-                     $submission = get_record("exercise_submissions", "id", $assessment->submissionid);
-                    if (isteacher($exercise->course, $submission->userid)) {
-                        $n++;
-                        }
-                    break;
-                }
-            }
-        }
-    return $n;
-    }
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_count_user_assessments_done($exercise, $user) {
-    // returns the number of assessments actually done by a user
-    // the student's self assessments are included in the count
-    // the maxeditingtime is NOT taken into account here 
-    
-    $n = 0;
-    $timenow = time();
-    if ($assessments = exercise_get_user_assessments($exercise, $user)) {
-         foreach ($assessments as $assessment) {
-            if ($assessment->timecreated < $timenow) {
-                $n++;
-            }
-        }
-    }
-    return $n;
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_count_user_submissions($exercise, $user) {
-    // returns the number of submissions make by this user
-    return count_records("exercise_submissions", "exerciseid", $exercise->id, "userid", $user->id);
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_delete_submitted_files($exercise, $submission) {
-// Deletes the files in the exercise area for this submission
-
-    if ($basedir = exercise_file_area($exercise, $submission)) {
-        if ($files = get_directory_list($basedir)) {
-            foreach ($files as $file) {
-                if (unlink("$basedir/$file")) {
-                    notify("Existing file '$file' has been deleted!");
-                }
-                else {
-                    notify("Attempt to delete file $basedir/$file has failed!");
-                }
-            }
-        }
-    }
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_delete_user_files($exercise, $user, $exception) {
-// Deletes all the user files in the exercise area for a user
-// EXCEPT for any file named $exception
-
-    if (!$submissions = exercise_get_submissions($exercise, $user)) {
-        notify("No submissions!");
-        return;
-        }
-    foreach ($submissions as $submission) {
-        if ($basedir = exercise_file_area($exercise, $submission)) {
-            if ($files = get_directory_list($basedir)) {
-                foreach ($files as $file) {
-                    if ($file != $exception) {
-                        unlink("$basedir/$file");
-                        notify("Existing file '$file' has been deleted!");
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_get_best_submission_grades($exercise) {
-// Returns the grades of students' best submissions
-    global $CFG;
-
-    // make sure it works on the site course
-    // Where is table u? I remove it, try to make SQL correct.
-    // $select = "u.course = '$exercise->course' AND";
-    // if ($exercise->course == SITEID) {
-    //     $select = '';
-    // }
-
-    return get_records_sql("SELECT DISTINCT s.userid, MAX(a.grade) AS grade FROM 
-                        {$CFG->prefix}exercise_submissions s, 
-                        {$CFG->prefix}exercise_assessments a
-                              WHERE s.exerciseid = $exercise->id
-                              AND s.late = 0
-                              AND a.submissionid = s.id
-                              GROUP BY s.userid");
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_get_mean_grade($submission) {
-// Returns the mean grade of students' submission (may, very occassionally, be more than one assessment)
-    global $CFG;
-    
-    return get_record_sql("SELECT AVG(a.grade) AS grade FROM 
-                        {$CFG->prefix}exercise_assessments a 
-                            WHERE a.submissionid = $submission->id
-                              GROUP BY a.submissionid");
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_get_student_submission($exercise, $user) {
-// Return a submission for a particular user
-    global $CFG;
-
-    $submission = get_record("exercise_submissions", "exerciseid", $exercise->id, "userid", $user->id);
-    if (!empty($submission->timecreated)) {
-        return $submission;
-    }
-    return NULL;
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_get_student_submissions($exercise, $order = "time", $groupid = 0) {
-// Return all  ENROLLED student submissions
-// if order can grade|title|name|nothing, nothing is oldest first, youngest last
-    global $CFG;
-    
-    if ($groupid) { 
-        // just look at a single group
-        if ($order == "grade") {
-            // allow for multiple assessments of submissions (coming from different teachers)
-                    
-            // make sure it works on the site course
-            // Where is table u? I remove it, try to make SQL correct.
-            // $select = "u.course = '$exercise->course' AND";
-            // if ($exercise->course == SITEID) {
-            //     $select = '';
-            // }
-
-            return get_records_sql("SELECT s.*, AVG(a.grade) AS grade FROM 
-                    {$CFG->prefix}groups_members g, {$CFG->prefix}exercise_submissions s, 
-                    {$CFG->prefix}exercise_assessments a
-                    WHERE g.groupid = $groupid
-                    AND s.exerciseid = $exercise->id
-                    AND a.submissionid = s.id
-                    GROUP BY s.id
-                    ORDER BY a.grade DESC");
-        }
-
-        if ($order == "title") {
-            $order = "s.title";
-        } elseif ($order == "name") {
-            $order = "n.firstname, n.lastname, s.timecreated DESC";
-        } elseif ($order == "time") {
-            $order = "s.timecreated";
-        }
-
-        // make sure it works on the site course
-        // Where is table u? I remove it, try to make SQL correct.
-        // $select = "u.course = '$exercise->course' AND";
-        // if ($exercise->course == SITEID) {
-        //     $select = '';
-        // }
-
-        return get_records_sql("SELECT s.* FROM  {$CFG->prefix}user n, 
-                {$CFG->prefix}groups_members g, {$CFG->prefix}exercise_submissions s
-                WHERE g.groupid = $groupid
-                AND s.exerciseid = $exercise->id
-                ORDER BY $order");
-
-    } 
-    else { // no group - all users
-        if ($order == "grade") {
-            // allow for multiple assessments of submissions (coming from different teachers)
-
-            // make sure it works on the site course
-            // Where is table u? I remove it, try to make SQL correct.
-            // $select = "u.course = '$exercise->course' AND";
-            // if ($exercise->course == SITEID) {
-            //     $select = '';
-            // }
-
-            return get_records_sql("SELECT s.*, AVG(a.grade) AS grade FROM {$CFG->prefix}exercise_submissions s, 
-                    {$CFG->prefix}exercise_assessments a
-                    WHERE s.exerciseid = $exercise->id
-                    AND a.submissionid = s.id
-                    GROUP BY s.id
-                    ORDER BY a.grade DESC");
-        }
-
-        if ($order == "title") {
-            $order = "s.title";
-        } elseif ($order == "name") {
-            $order = "n.firstname, n.lastname, s.timecreated DESC";
-        } elseif ($order == "time") {
-            $order = "s.timecreated";
-        }
-
-        // make sure it works on the site course
-        // Where is table u? I remove it, try to make SQL correct.
-        // $select = "u.course = '$exercise->course' AND";
-        // if ($exercise->course == SITEID) {
-        //     $select = '';
-        // }
-
-        return get_records_sql("SELECT s.* FROM {$CFG->prefix}exercise_submissions s, 
-                {$CFG->prefix}user n  
-                WHERE s.exerciseid = $exercise->id
-                ORDER BY $order");
-    }
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_get_submission_assessment($submission, $user = null) {
-    // Return a user's assessment for this submission
-    if ($user) {
-        return get_record("exercise_assessments", "submissionid", $submission->id, "userid", $user->id);
-    } else { // likely to be the teacher's assessment
-        return get_record("exercise_assessments", "submissionid", $submission->id);
-    }
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_get_teacher_submissions($exercise) {
-// Return all  teacher submissions, ordered by title
-    global $CFG;
-    
-    return get_records_sql("SELECT s.* FROM {$CFG->prefix}exercise_submissions s
-                        WHERE s.isexercise = 1
-                              AND s.exerciseid = $exercise->id 
-                              ORDER BY s.title");
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_get_ungraded_assessments($exercise) {
-    global $CFG;
-    // Return all assessments which have not been graded or just graded
-    $cutofftime =time() - $CFG->maxeditingtime;
-    return get_records_select("exercise_assessments", "exerciseid = $exercise->id AND (timegraded = 0 OR 
-                timegraded > $cutofftime)", "timecreated"); 
-    }
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_get_ungraded_assessments_student($exercise) {
-    global $CFG;
-    // Return all assessments which have not been graded or just graded of student's submissions
-
-    // make sure it works on the site course
-    // $select = "u.course = '$exercise->course' AND";
-    // if ($exercise->course == SITEID) {
-    //     $select = '';
-    // }
-
-    $cutofftime =time() - $CFG->maxeditingtime;
-    return get_records_sql("SELECT a.* FROM {$CFG->prefix}exercise_submissions s
-                            {$CFG->prefix}exercise_assessments a
-                            WHERE s.exerciseid = $exercise->id
-                              AND a.submissionid = s.id
-                              AND (a.timegraded = 0 OR a.timegraded > $cutofftime)
-                              AND a.timecreated < $cutofftime
-                              ORDER BY a.timecreated ASC"); 
-    }
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_get_ungraded_assessments_teacher($exercise) {
-    global $CFG;
-    // Return all assessments which have not been graded or just graded of teacher's submissions
-    
-    $cutofftime =time() - $CFG->maxeditingtime;
-    return get_records_sql("SELECT a.* FROM {$CFG->prefix}exercise_submissions s, {$CFG->prefix}exercise_assessments a
-                            WHERE s.isexercise = 1
-                              AND s.exerciseid = $exercise->id
-                              AND a.submissionid = s.id
-                              AND (a.timegraded = 0 OR a.timegraded > $cutofftime)
-                              AND a.timecreated < $cutofftime
-                              ORDER BY a.timecreated ASC"); 
-    }
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_get_user_assessments($exercise, $user) {
-    // Return all the  user's assessments, newest first, oldest last
-    // students will have only one, teachers will have more...
-    return get_records_select("exercise_assessments", "exerciseid = $exercise->id AND userid = $user->id", 
-                "timecreated DESC");
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_list_all_ungraded_assessments($exercise) {
-    // lists all the assessments for comment by teacher
-    global $CFG;
-    
-    $table->head = array (get_string("title", "exercise"), get_string("timeassessed", "exercise"), get_string("action", "exercise"));
-    $table->align = array ("left", "left", "left");
-    $table->size = array ("*", "*", "*");
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-    $timenow = time();
-    
-    if ($assessments = exercise_get_ungraded_assessments($exercise)) {
-        foreach ($assessments as $assessment) {
-            if (!isteacher($exercise->course, $assessment->userid)) {
-                if (($timenow - $assessment->timegraded) < $CFG->maxeditingtime) {
-                    $action = "<a href=\"assessments.php?action=gradeassessment&amp;a=$exercise->id&amp;aid=$assessment->id\">".
-                        get_string("edit", "exercise")."</a>";
-                    }
-                else {
-                    $action = "<a href=\"assessments.php?action=gradeassessment&amp;a=$exercise->id&amp;aid=$assessment->id\">".
-                        get_string("gradeassessment", "exercise")."</a>";
-                    }
-                $submission = get_record("exercise_submissions", "id", $assessment->submissionid);
-                $table->data[] = array(exercise_print_submission_title($exercise, $submission), 
-                    userdate($assessment->timecreated), $action);
-                }
-            }
-        if (isset($table->data)) {
-            print_table($table);
-            }
-        }
-    }
-    
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_list_submissions_for_admin($exercise) {
-    // list the teacher sublmissions first
-    global $CFG, $USER;
-    
-    if (! $course = get_record("course", "id", $exercise->course)) {
-        print_error("Course is misconfigured");
-        }
-    if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        print_error("Course Module ID was incorrect");
-    }
-    $groupid = get_current_group($course->id);
-    
-    exercise_print_assignment_info($exercise);
-    print_heading_with_help(get_string("administration"), "administration", "exercise");
-    echo"<p align=\"center\"><b><a href=\"assessments.php?action=teachertable&amp;id=$cm->id\">".
-            get_string("teacherassessmenttable", "exercise", $course->teacher)."</a></b></p>\n";
-
-
-    if (isteacheredit($course->id)) {
-        // list any teacher submissions
-        $table->head = array (get_string("title", "exercise"), get_string("submitted", "exercise"), 
-                get_string("action", "exercise"));
-        $table->align = array ("left", "left", "left");
-        $table->size = array ("*", "*", "*");
-        $table->cellpadding = 2;
-        $table->cellspacing = 0;
-
-        if ($submissions = exercise_get_teacher_submissions($exercise)) {
-            foreach ($submissions as $submission) {
-                $action = "<a href=\"submissions.php?action=adminamendtitle&amp;id=$cm->id&amp;sid=$submission->id\">".
-                    get_string("amendtitle", "exercise")."</a>";
-                if (isteacheredit($course->id)) {
-                    $action .= " | <a href=\"submissions.php?action=adminconfirmdelete&amp;id=$cm->id&amp;sid=$submission->id\">".
-                        get_string("delete", "exercise")."</a>";
-                }
-                $table->data[] = array(exercise_print_submission_title($exercise, $submission), 
-                        userdate($submission->timecreated), $action);
-            }
-            print_heading(get_string("studentsubmissions", "exercise", $course->teacher), "center");
-            print_table($table);
-        }
-    }
-
-    // list student assessments
-    // Get all the students...
-    if ($users = get_course_students($course->id, "u.lastname, u.firstname")) {
-        $timenow = time();
-        unset($table);
-        $table->head = array(get_string("name"), get_string("title", "exercise"), 
-                get_string("assessed", "exercise"), get_string("action", "exercise"));
-        $table->align = array ("left", "left", "left", "left");
-        $table->size = array ("*", "*", "*", "*");
-        $table->cellpadding = 2;
-        $table->cellspacing = 0;
-        $nassessments = 0;
-        foreach ($users as $user) {
-            // check group membership, if necessary
-            if ($groupid) {
-                // check user's group
-                if (!groups_is_member($groupid, $user->id)) {
-                    continue; // skip this user
-                }
-            }
-            if ($assessments = exercise_get_user_assessments($exercise, $user)) {
-                $title ='';
-                foreach ($assessments as $assessment) {
-                    if (!$submission = get_record("exercise_submissions", "id", $assessment->submissionid)) {
-                        print_error("exercise_list_submissions_for_admin: Submission record not found!");
-                        }
-                    $title .= $submission->title;
-                    // test for allocated assesments which have not been done
-                    if ($assessment->timecreated < $timenow) {
-                        // show only warm or cold assessments
-                        $title .= " {".number_format($assessment->grade * $exercise->grade / 100.0, 0);
-                        if ($assessment->timegraded) {
-                            $title .= "/".number_format($assessment->gradinggrade * $exercise->gradinggrade / 100.0, 0);
-                        }
-                        $title .= "} ";
-                        if ($realassessments = exercise_count_user_assessments_done($exercise, $user)) {
-                            $action = "<a href=\"assessments.php?action=adminlistbystudent&amp;id=$cm->id&amp;userid=$user->id\">".
-                                get_string("view", "exercise")."</a>";
-                        }
-                        else {
-                            $action ="";
-                        }
-                        $nassessments++;
-                        $table->data[] = array(fullname($user), $title, 
-                                userdate($assessment->timecreated), $action);
-                    }
-                }
-            }
-        }
-        if (isset($table->data)) {
-            if ($groupid) {
-                if (! groups_group_exists($groupid)) { //TODO:
-                    print_error("List unassessed student submissions: group not found");
-                }
-                print_heading("$group->name ".get_string("studentassessments", "exercise", $course->student).
-                        " [$nassessments]");
-            } else {
-                print_heading(get_string("studentassessments", "exercise", $course->student)." [$nassessments]");
-            }
-            print_table($table);
-            echo "<p align=\"center\">".get_string("noteonstudentassessments", "exercise");
-            echo "<br />{".get_string("maximumgrade").": $exercise->grade / ".
-                get_string("maximumgrade").": $exercise->gradinggrade}</p>\n";
-            // grading grade analysis
-            unset($table);
-            $table->head = array (get_string("count", "exercise"), get_string("mean", "exercise"),
-                get_string("standarddeviation", "exercise"), get_string("maximum", "exercise"), 
-                get_string("minimum", "exercise"));
-            $table->align = array ("center", "center", "center", "center", "center");
-            $table->size = array ("*", "*", "*", "*", "*");
-            $table->cellpadding = 2;
-            $table->cellspacing = 0;
-            if ($groupid) {
-                $stats = get_record_sql("SELECT COUNT(*) as count, AVG(gradinggrade) AS mean, 
-                        STDDEV(gradinggrade) AS stddev, MIN(gradinggrade) AS min, MAX(gradinggrade) AS max 
-                        FROM {$CFG->prefix}groups_members g, {$CFG->prefix}exercise_assessments a 
-                        WHERE g.groupid = $groupid AND a.userid = g.userid AND a.timegraded > 0 
-                        AND a.exerciseid = $exercise->id");
-            } else { // no group/all participants
-                $stats = get_record_sql("SELECT COUNT(*) as count, AVG(gradinggrade) AS mean, 
-                        STDDEV(gradinggrade) AS stddev, MIN(gradinggrade) AS min, MAX(gradinggrade) AS max 
-                        FROM {$CFG->prefix}exercise_assessments a 
-                        WHERE a.timegraded > 0 AND a.exerciseid = $exercise->id");
-            }   
-            $table->data[] = array($stats->count, number_format($stats->mean * $exercise->gradinggrade / 100.0, 1), 
-                    number_format($stats->stddev * $exercise->gradinggrade / 100.0, 1), 
-                    number_format($stats->max * $exercise->gradinggrade / 100.0, 1), 
-                    number_format($stats->min * $exercise->gradinggrade / 100.0, 1));
-            print_heading(get_string("gradinggrade", "exercise")." ".get_string("analysis", "exercise"));
-            print_table($table);
-            echo "<p align=\"center\"><a href=\"assessments.php?id=$cm->id&amp;action=regradestudentassessments\">".
-                    get_string("regradestudentassessments", "exercise")."</a> ";
-            helpbutton("regrading", get_string("regradestudentassessments", "exercise"), "exercise");
-            echo "</p>\n";
-        }
-    }
-
-    // now the sudent submissions
-    unset($table);
-    if ($users) {
-        $table->head = array (get_string("submittedby", "exercise"), get_string("title", "exercise"),
-            get_string("submitted", "exercise"), get_string("action", "exercise"));
-        $table->align = array ("left", "left", "left", "left");
-        $table->size = array ("*", "*", "*", "*");
-        $table->cellpadding = 2;
-        $table->cellspacing = 0;
-
-        $nsubmissions = 0;
-        foreach ($users as $user) {
-            // check group membership, if necessary
-            if ($groupid) {
-                // check user's group
-                if (!groups_is_member($groupid, $user->id)) {
-                    continue; // skip this user
-                }
-            }
-            if ($submissions = exercise_get_user_submissions($exercise, $user)) {
-                foreach ($submissions as $submission) {
-                    $action = "<a href=\"submissions.php?action=adminamendtitle&amp;id=$cm->id&amp;sid=$submission->id\">".
-                        get_string("amendtitle", "exercise")."</a>";
-                    // has teacher already assessed this submission
-                    if ($assessment = get_record_select("exercise_assessments", 
-                                "submissionid = $submission->id AND userid = $USER->id")) {
-                        $curtime = time();
-                        if (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) {
-                            $action .= " | <a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
-                                get_string("reassess", "exercise")."</a>";
-                        }
-                        else { // there's still time left to edit...
-                            $action .= " | <a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
-                                get_string("edit", "exercise")."</a>";
-                        }
-                    }
-                    else { // user has not assessed this submission
-                        $action .= " | <a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
-                            get_string("assess", "exercise")."</a>";
-                    }
-                    if ($nassessments = exercise_count_assessments($submission)) {
-                        $action .= " | <a href=\"assessments.php?action=adminlist&amp;id=$cm->id&amp;sid=$submission->id\">".
-                            get_string("view", "exercise")." ($nassessments)</a>";
-                    }
-                    if ($submission->late) {
-                        $action .= " | <a href=\"submissions.php?action=adminlateflag&amp;id=$cm->id&amp;sid=$submission->id\">".
-                            get_string("clearlateflag", "exercise")."</a>";
-                    }
-                    $action .= " | <a href=\"submissions.php?action=adminconfirmdelete&amp;id=$cm->id&amp;sid=$submission->id\">".
-                        get_string("delete", "exercise")."</a>";
-                    $title = $submission->title;
-                    if ($submission->resubmit) {
-                        $title .= "*";
-                    }
-                    $datesubmitted = userdate($submission->timecreated);
-                    if ($submission->late) {
-                        $datesubmitted = "<font color=\"red\">".$datesubmitted."</font>";
-                    }
-                    $table->data[] = array(fullname($user), $title.
-                            " ".exercise_print_submission_assessments($exercise, $submission), 
-                            $datesubmitted, $action);
-                    $nsubmissions++;
-                }
-            }
-        }
-        if (isset($table->data)) {
-            if ($groupid) {
-                if (! groups_group_exists($groupid)) {
-                    print_error("List unassessed student submissions: group not found");
-                }
-                print_heading("$group->name ".get_string("studentsubmissions", "exercise", $course->student).
-                        " [$nsubmissions]");
-            } else {
-                print_heading(get_string("studentsubmissions", "exercise", $course->student)." [$nsubmissions]",
-                    "center");
-            }
-            print_table($table);
-            echo "<p align=\"center\">[] - ".get_string("gradeforsubmission", "exercise");
-            echo "<br />".get_string("maximumgrade").": $exercise->grade</p>\n";
-            echo "<p align=\"center\">".get_string("resubmitnote", "exercise", $course->student)."</p>\n";
-            // grade analysis
-            unset($table);
-            $table->head = array (get_string("count", "exercise"), get_string("mean", "exercise"),
-                get_string("standarddeviation", "exercise"), get_string("maximum", "exercise"), 
-                get_string("minimum", "exercise"));
-            $table->align = array ("center", "center", "center", "center", "center");
-            $table->size = array ("*", "*", "*", "*", "*");
-            $table->cellpadding = 2;
-            $table->cellspacing = 0;
-
-            /// NOTE:  user_teachers was ripped from the following SQL without a proper fix - XXX TO DO
-
-            if ($groupid) {
-                $stats = get_record_sql("SELECT COUNT(*) as count, AVG(grade) AS mean, 
-                        STDDEV(grade) AS stddev, MIN(grade) AS min, MAX(grade) AS max 
-                        FROM {$CFG->prefix}groups_members g, {$CFG->prefix}exercise_assessments a, 
-                        {$CFG->prefix}exercise_submissions s
-                        WHERE g.groupid = $groupid AND s.userid = g.userid AND a.submissionid = s.id 
-                        AND a.exerciseid = $exercise->id");
-            } else { // no group/all participants
-                $stats = get_record_sql("SELECT COUNT(*) as count, AVG(grade) AS mean, 
-                        STDDEV(grade) AS stddev, MIN(grade) AS min, MAX(grade) AS max 
-                        FROM {$CFG->prefix}exercise_assessments a
-                        WHERE a.exerciseid = $exercise->id");
-            }   
-            $table->data[] = array($stats->count, number_format($stats->mean * $exercise->grade / 100.0, 1), 
-                    number_format($stats->stddev * $exercise->grade / 100.0, 1), 
-                    number_format($stats->max * $exercise->grade / 100.0, 1), 
-                    number_format($stats->min * $exercise->grade / 100.0, 1));
-            print_heading(get_string("grade")." ".get_string("analysis", "exercise"));
-            print_table($table);
-        }
-    }
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_list_teacher_assessments($exercise, $user) {
-    global $CFG;
-    $timenow = time();
-    
-    if (! $course = get_record("course", "id", $exercise->course)) {
-        print_error("Course is misconfigured");
-    }
-    $table->head = array (get_string("title", "exercise"), get_string("action", "exercise"), get_string("comment", "exercise"));
-    $table->align = array ("left", "left", "left");
-    $table->size = array ("*", "*", "*");
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-
-    // get user's submissions
-    if ($submissions = exercise_get_user_submissions($exercise, $user)) {
-        foreach ($submissions as $submission) {
-            // get the assessments
-            if ($assessments = exercise_get_assessments($submission)) {
-                foreach ($assessments as $assessment) {
-                    if (isteacher($exercise->course, $assessment->userid)) { // assessments by teachers only
-                        $action = "<a href=\"assessments.php?action=viewassessment&amp;a=$exercise->id&amp;aid=$assessment->id\">".
-                            get_string("view", "exercise")."</a>";
-                        // has teacher commented on teacher's assessment? shouldn't happen but leave test in
-                        if ($assessment->timegraded and ($timenow - $assessment->timegraded > $CFG->maxeditingtime)) {
-                            $comment = get_string("gradedbyteacher", "exercise", $course->teacher);
-                            }
-                        else {
-                            $comment = userdate($assessment->timecreated);
-                            }
-                        $table->data[] = array(exercise_print_submission_title($exercise, $submission), $action, $comment);
-                        }
-                    }
-                }
-            }
-        }
-    if (isset($table->data)) {
-        print_table($table);
-        }
-    else {
-        echo "<center>".get_string("noassessmentsdone", "exercise")."</center>\n";
-        }
-    }
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_list_teacher_submissions($exercise, $user, $reassess = false) {
-    // always allow user to reassess if that flag is true
-    global $CFG;
-    
-    if (! $course = get_record("course", "id", $exercise->course)) {
-        print_error("Course is misconfigured");
-    }
-    if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        print_error("Course Module ID was incorrect");
-    }
-
-    $strexercises = get_string("modulenameplural", "exercise");
-    $strexercise  = get_string("modulename", "exercise");
-
-    // get any assessment this user has done (could include hot one)
-    if (!$assessment = get_record_select("exercise_assessments", "exerciseid = $exercise->id
-                    AND userid = $user->id")) {
-        // the user has not  yet assessed this exercise, set up a hot assessment record for this user for one 
-        // of the teacher submissions, first count the number of assessments for each teacher submission...
-        if ($submissions = exercise_get_teacher_submissions($exercise)) {
-            // mt_srand ((float)microtime()*1000000); // initialise random number generator, assume php>=4.2.0
-            foreach ($submissions as $submission) {
-                $n = count_records("exercise_assessments", "submissionid", $submission->id);
-                // ...OK to have zero, we add a small random number to randomise things...
-                $nassessments[$submission->id] = $n + mt_rand(0, 99) / 100;
-            }
-            // ...put the submissions with the lowest number of assessments first...
-            asort($nassessments);
-            reset($nassessments);
-            foreach ($nassessments as $submissionid => $n) { // break out of loop after the first element
-                $submission = get_record("exercise_submissions", "id", $submissionid);
-                // ... provided the user has NOT already assessed that submission...
-                if (!$assessment = exercise_get_submission_assessment($submission, $user)) {
-                    $yearfromnow = time() + 365 * 86400;
-                    // ...create one and set timecreated way in the future, reset when record is updated
-                    $assessment->exerciseid = $exercise->id;
-                    $assessment->submissionid = $submission->id;
-                    $assessment->userid = $user->id;
-                    $assessment->grade = -1; // set impossible grade
-                    $assessment->timecreated = $yearfromnow;
-                    $assessment->mailed = 1; // no need to email to the teacher!
-                    if (!$assessment->id = insert_record("exercise_assessments", $assessment)) {
-                        print_error("Could not insert exercise assessment!");
-                    }
-                    break;
-                }
-            }
-        }
-    } else {
-        // get hold of the teacher submission
-        if (!$submission = get_record("exercise_submissions", "id", $assessment->submissionid)) {
-            print_error("List teacher submissions: submission record not found");
-        }
-    }
-    print_simple_box_start("center");
-    print_heading_with_help(get_string("theexercise", "exercise"), "junk", "exercise");
-    print_simple_box_start("center");
-    echo "<p align=\"center\"><b>".get_string("description", "exercise").": </b>\n";
-    echo exercise_print_submission_title($exercise, $submission);
-    echo "</p>\n";
-    print_simple_box_end();
-    print_simple_box_end();
-    $table->head = array (get_string("action", "exercise"), get_string("assessed", "exercise"),
-        get_string("comment", "exercise"));
-    $table->align = array ("left", "left", "left");
-    $table->size = array ("*", "*", "*");
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-
-    // now list user's assessments (but only list those which come from teacher submissions)
-    print_heading(get_string("yourassessment", "exercise"));
-    $assessed = false;
-    if ($assessments = exercise_get_user_assessments($exercise, $user)) {
-        $timenow = time();
-        foreach ($assessments as $assessment) {
-            if (!$submission = get_record("exercise_submissions", "id", $assessment->submissionid)) {
-                error ("exercise_list_teacher_submissions: unable to get submission");
-            }
-            // submission from a teacher, i.e an exercise submission?
-            if ($submission->isexercise) {
-                $comment = '';
-                if ($reassess) {  // just show re-assess
-                    $action = "<a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
-                        get_string("reassess", "exercise")."</a>";
-                }
-                else { // reassess is false - assessment is a "normal state"
-                    // user assessment has three states: record created but not assessed (date created 
-                    // in the future); just assessed but still editable; and "static" (may or may not 
-                    // have been graded by teacher, that is shown in the comment) 
-                    if ($assessment->timecreated > $timenow) { // user needs to assess this submission
-                        $action = "<a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
-                            get_string("assess", "exercise")."</a>";
-                    }
-                    elseif ($assessment->timecreated > ($timenow - $CFG->maxeditingtime)) { 
-                        // there's still time left to edit...
-                        $action = "<a href=\"assessments.php?action=assesssubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
-                            get_string("edit", "exercise")."</a>";
-                    }
-                    else { 
-                        $action = "<a href=\"assessments.php?action=viewassessment&amp;id=$cm->id&amp;aid=$assessment->id\">"
-                            .get_string("view", "exercise")."</a>";
-                    }
-                }
-                // show the date if in the past (otherwise the user hasn't done the assessment yet
-                $assessmentdate = '';
-                if ($assessment->timecreated < $timenow) {
-                    $assessmentdate = userdate($assessment->timecreated);
-                    // if user has submitted work, see if teacher has graded assessment
-                    if (exercise_count_user_submissions($exercise, $user) > 0) {
-                        if ($assessment->timegraded and (($timenow - $assessment->timegraded) > $CFG->maxeditingtime)) {
-                            $comment .= get_string("gradeforassessment", "exercise").": ".
-                                number_format($assessment->gradinggrade * $exercise->gradinggrade / 100.0, 1).
-                                " (".get_string("maximumgrade")." ".number_format($exercise->gradinggrade, 0).")";
-                            $assessed = true;
-                        }
-                        else {
-                            $comment .= get_string("awaitingassessmentbythe", "exercise", $course->teacher);
-                        }
-                    }
-                }
-                $table->data[] = array($action, $assessmentdate, $comment);
-            }
-        }
-        print_table($table);
-        if ($assessed) {
-            echo "<p align=\"center\">".get_string("noteongradinggrade", "exercise", $course->teacher)."</p>\n";
-        }
-    }
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_list_unassessed_student_submissions($exercise, $user) {
-    // list the student submissions not assessed by the teacher
-    global $CFG;
-    
-    $timenow = time();
-    
-    if (! $course = get_record("course", "id", $exercise->course)) {
-        print_error("Course is misconfigured");
-    }
-    if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        print_error("Course Module ID was incorrect");
-    }
-
-    $table->head = array (get_string("title", "exercise"), get_string("submittedby", "exercise"),
-        get_string("submitted", "exercise"), get_string("action", "exercise"), 
-        get_string("comment", "exercise"));
-    $table->align = array ("left", "left", "left", "left", "left");
-    $table->size = array ("*", "*", "*", "*", "*");
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-
-    // get all the submissions, oldest first, youngest last
-    // exercise_get_student_submissions is group aware
-    $groupid = get_current_group($course->id);
-    if ($groupid) {
-        if (! groups_group_exists($groupid)) {
-            print_error("List unassessed student submissions: group not found");
-        }
-        print_heading(get_string("studentsubmissionsforassessment", "exercise", $group->name));
-    }
-    if ($submissions = exercise_get_student_submissions($exercise, "time", $groupid)) {
-        foreach ($submissions as $submission) {
-            // only consider "cold" submissions
-            if ($submission->timecreated < $timenow - $CFG->maxeditingtime) {
-                $comment = "";
-                // see if student has already submitted
-                $submissionowner = get_record("user", "id", $submission->userid);
-                if (exercise_count_user_submissions($exercise, $submissionowner) == 1) {
-                    // it's the student's first submission 
-                    // see if there are no cold assessments for this submission
-                    if (!exercise_count_assessments($submission)) {
-                        // now see if the teacher has already assessed this submission
-                        $warm = false;
-                        if ($assessments = get_records("exercise_assessments", "submissionid", $submission->id)) {
-                            foreach ($assessments as $assessment) {
-                                if (isteacher($course->id, $assessment->userid)) {
-                                    if ($assessment->timecreated > $timenow -$CFG->maxeditingtime) {
-                                        $warm = true;
-                                    }
-                                    break;  // no need to look further
-                                }
-                            }
-                        }
-                        // get their assessment
-                        if ($assessments = exercise_get_user_assessments($exercise, $submissionowner)) {
-                            foreach ($assessments as $assessment) {
-                                $studentassessment = $assessment;
-                                break; // there should only be one!
-                            }
-                            $timegap = get_string("ago", "exercise", format_time($submission->timecreated -
-                                        $timenow));
-                            if ($submission->late) {
-                                $timegap = "<font color=\"red\">".$timegap."</font>";
-                            }
-                            if ($warm) {
-                                // last chance salon
-                                $action = "<a href=\"assessments.php?action=teacherassessment&amp;id=$cm->id&amp;aid=$studentassessment->id&amp;sid=$submission->id\">".
-                                    get_string("edit", "exercise")."</a>";
-                                $table->data[] = array(exercise_print_submission_title($exercise, $submission), 
-                                        fullname($submissionowner), 
-                                        $timegap, $action, $comment);
-                            } else {
-                                $action = "<a href=\"assessments.php?action=teacherassessment&amp;id=$cm->id&amp;aid=$studentassessment->id&amp;sid=$submission->id\">".
-                                    get_string("assess", "exercise")."</a>";
-                                $table->data[] = array(exercise_print_submission_title($exercise, $submission), 
-                                        fullname($submissionowner), 
-                                        $timegap, $action, $comment);
-                            }
-                        } else {
-                            // there's no student assessment, odd!!
-                        }
-                    }
-                }
-                // this is student's second... submission
-                else {
-                    $teacherassessed = false;
-                    $warm = false;
-                    if ($assessments = get_records("exercise_assessments", "submissionid", $submission->id)) {
-                        foreach ($assessments as $assessment) {
-                            if (isteacher($course->id, $assessment->userid)) {
-                                $teacherassessed = true;
-                                if (!$teacher = get_record("user", "id", $assessment->userid)) {
-                                    print_error("List unassessed student submissions: teacher record not found");
-                                }
-                                $comment = get_string("resubmissionfor", "exercise",
-                                                fullname($teacher));
-                                if ($assessment->timecreated > $timenow - $CFG->maxeditingtime) {
-                                    $warm = true;
-                                }
-                                break; // no need to look further
-                            }
-                        }
-                    }
-                    if ($teacherassessed and $warm) {
-                        // last chance salon
-                        $action = "<a href=\"assessments.php?action=assessresubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
-                            get_string("edit", "exercise")."</a>";
-                        $timegap = get_string("ago", "exercise", format_time($submission->timecreated -
-                                    $timenow));
-                        if ($submission->late) {
-                            $timegap = "<font color=\"red\">".$timegap."</font>";
-                        }
-                        $table->data[] = array(exercise_print_submission_title($exercise, $submission), 
-                            fullname($submissionowner), 
-                            $timegap, $action, $comment);
-                    }
-                    if (!$teacherassessed) { 
-                        // no teacher's assessment
-                        // find who did the previous assessment
-                        if (!$submissions = exercise_get_user_submissions($exercise, $submissionowner)) {
-                            print_error("List unassessed student submissions: submission records not found");
-                        }
-                        // get the oldest submission, exercise_get_user_submissions returns that first
-                        foreach ($submissions as $tempsubmission) {
-                            $prevsubmission = $tempsubmission;
-                            break;
-                        }
-                        // get the teacher's assessment of the student's previous submission
-                        if ($assessments = get_records("exercise_assessments", "submissionid", 
-                                    $prevsubmission->id)) {
-                            foreach ($assessments as $assessment) {
-                                if (isteacher($course->id, $assessment->userid)) {
-                                    if (!$teacher = get_record("user", "id", $assessment->userid)) {
-                                        print_error("List unassessed student submissions: teacher record not found");
-                                    }
-                                    $comment = get_string("resubmissionfor", "exercise",
-                                                    fullname($teacher));
-                                    break; // no need to look further
-                                    
-                                }
-                            }
-                        }
-                        $action = "<a href=\"assessments.php?action=assessresubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
-                            get_string("assess", "exercise")."</a>";
-                        $timegap = get_string("ago", "exercise", format_time($submission->timecreated -
-                                    $timenow));
-                        if ($submission->late) {
-                             $timegap = "<font color=\"red\">".$timegap."</font>";
-                        }
-                        $table->data[] = array(exercise_print_submission_title($exercise, $submission), 
-                            fullname($submissionowner), 
-                            $timegap, $action, $comment);
-                    }
-                }
-            }
-        }
-        if (isset($table->data)) {
-            print_table($table);
-        }
-    }
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_list_unassessed_teacher_submissions($exercise, $user) {
-    // list the teacher submissions not assessed by this user
-    global $CFG;
-    
-    $table->head = array (get_string("title", "exercise"), get_string("action", "exercise"), get_string("comment", "exercise"));
-    $table->align = array ("left", "left", "left");
-    $table->size = array ("*", "*", "*");
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-
-    if ($submissions = exercise_get_teacher_submissions($exercise)) {
-        foreach ($submissions as $submission) {
-            $comment = "";
-            // see if user already graded this assessment
-            if ($assessment = get_record_select("exercise_assessments", "submissionid = $submission->id
-                    AND userid = $user->id")) {
-                $timenow = time();
-                if (($timenow - $assessment->timecreated < $CFG->maxeditingtime)) {
-                    // last chance salon
-                    $action = "<a href=\"assessments.php?action=assesssubmission&amp;a=$exercise->id&amp;sid=$submission->id\">".
-                        get_string("edit", "exercise")."</a>";
-                    $table->data[] = array(exercise_print_submission_title($exercise, $submission), $action, $comment);
-                    }
-                }
-            else { // no assessment
-                $action = "<a href=\"assessments.php?action=assesssubmission&amp;a=$exercise->id&amp;sid=$submission->id\">".
-                    get_string("assess", "exercise")."</a>";
-                $table->data[] = array(exercise_print_submission_title($exercise, $submission), $action, $comment);
-                }
-            }
-        if (isset($table->data)) {
-            print_table($table);
-            }
-        }
-    }
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_list_ungraded_assessments($exercise, $stype) {
-    global $CFG;
-    
-    if (! $course = get_record("course", "id", $exercise->course)) {
-        print_error("Course is misconfigured");
-        }
-    if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        print_error("Course Module ID was incorrect");
-    }
-
-    // lists all the assessments of student submissions for grading by teacher
-    $table->head = array (get_string("title", "exercise"), get_string("submittedby", "exercise"),
-    get_string("assessor", "exercise"), get_string("timeassessed", "exercise"), get_string("action", "exercise"));
-    $table->align = array ("left", "left", "left", "left");
-    $table->size = array ("*", "*", "*", "*");
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-    $timenow = time();
-    
-    switch ($stype) {
-        case "student" :
-            $assessments = exercise_get_ungraded_assessments_student($exercise);
-            break;
-        case "teacher" :
-            $assessments = exercise_get_ungraded_assessments_teacher($exercise);
-            break;
-        }
-    if ($assessments) {
-        foreach ($assessments as $assessment) {
-            if (!isteacher($exercise->course, $assessment->userid)) { // don't let teacher grade their own assessments
-                if (($timenow - $assessment->timegraded) < $CFG->maxeditingtime) {
-                    $action = "<a href=\"assessments.php?action=gradeassessment&amp;id=$cm->id&amp;stype=$stype&amp;aid=$assessment->id\">".
-                        get_string("edit", "exercise")."</a>";
-                    }
-                else {
-                    $action = "<a href=\"assessments.php?action=gradeassessment&amp;id=$cm->id&amp;stype=$stype&amp;aid=$assessment->id\">".
-                        get_string("grade")."</a>";
-                    }
-                $submission = get_record("exercise_submissions", "id", $assessment->submissionid);
-                $submissionowner = get_record("user", "id", $submission->userid);
-                $assessor = get_record("user", "id", $assessment->userid);
-                $table->data[] = array(exercise_print_submission_title($exercise, $submission), 
-                    fullname($submissionowner), 
-                    fullname($assessor), userdate($assessment->timecreated), $action);
-                }
-            }
-        if (isset($table->data)) {
-            print_table($table);
-            }
-        }
-    }
-    
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_list_user_submissions($exercise, $user) {
-    global $CFG;
-
-    if (! $course = get_record("course", "id", $exercise->course)) {
-        print_error("Course is misconfigured");
-    }
-    if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        print_error("Course Module ID was incorrect");
-    }
-    
-    $timenow = time();
-    $table->head = array (get_string("title", "exercise"),  get_string("action", "exercise"),
-        get_string("submitted", "exercise"),  get_string("assessment", "exercise"));
-    $table->align = array ("left", "left", "left", "left");
-    $table->size = array ("*", "*", "*", "*");
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-
-    if ($submissions = exercise_get_user_submissions($exercise, $user)) {
-        foreach ($submissions as $submission) {
-            $action = '';
-            $comment = '';
-            // allow user to delete submission if it's warm
-            if ($submission->timecreated > $timenow - $CFG->maxeditingtime) {
-                $action = "<a href=\"submissions.php?action=userconfirmdelete&amp;id=$cm->id&amp;sid=$submission->id\">".
-                    get_string("delete", "exercise")."</a>";
-            }
-            // if this is a teacher's submission (an exercise description) ignore any assessments
-            if (!$submission->isexercise) {
-                // get the teacher assessments (could be more than one, if unlikely, when multiple teachers)
-                if ($assessments = get_records_select("exercise_assessments", "exerciseid = $exercise->id AND 
-                            submissionid = $submission->id")) {
-                    foreach ($assessments as $assessment) {
-                        // make sure it's real
-                        if ($assessment->timecreated < $timenow - $CFG->maxeditingtime) { // it's cold
-                            if ($action) {
-                                $action .= " | ";
-                            }
-                            $action .= "<a href=\"assessments.php?action=viewassessment&amp;id=$cm->id&amp;aid=$assessment->id\">".
-                                get_string("viewteacherassessment", "exercise", $course->teacher)."</a>";
-                            if ($comment) {
-                                $comment .= " | ";
-                            }
-                            $comment .= get_string("teacherassessment", "exercise", $course->teacher).": ".
-                                number_format($assessment->grade * $exercise->grade / 100.0, 1).
-                                " (".get_string("maximumgrade")." ".number_format($exercise->grade, 0).")";
-                        }
-                    }
-                }
-            }
-            if (!$comment and isstudent($course->id, $user->id)) {
-                $comment = get_string("awaitingassessmentbythe", "exercise", $course->teacher);
-            }
-            $submissiondate = userdate($submission->timecreated);
-            if ($submission->late) {
-                $submissiondate = "<font color=\"red\">".$submissiondate."</font>";
-            }
-            $table->data[] = array(exercise_print_submission_title($exercise, $submission), $action,
-                $submissiondate, $comment);
-        }
-        print_table($table);
-    }
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_print_assessment_form($exercise, $assessment = false, $allowchanges = false, $returnto = '') {
-    // prints several variants of the assessment form
-    global $CFG, $USER, $EXERCISE_SCALES, $EXERCISE_EWEIGHTS;
-    
-    if (! $course = get_record("course", "id", $exercise->course)) {
-        print_error("Course is misconfigured");
-    }
-    if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        print_error("Course Module ID was incorrect");
-    }
-    
-    $timenow = time();
-
-    if ($assessment) {
-            
-        if (!$submission = get_record("exercise_submissions", "id", $assessment->submissionid)) {
-            error ("exercise_print_assessment_form: Submission record not found");
-            }
-        // test if this assessment is from a teacher or student.
-        // Teacher's assessments are more complicated as we need to go back a couple of steps
-        // to find the exercise. Student's assessments are directly associated with an exercise.
-        if (isteacher($course->id, $assessment->userid)) { 
-            // A teacher's assessment, requires getting the student's assessment(s) 
-            // and finding which of those assessments which comes from a teacher submission,
-            // that is the exercise
-            $exercisefound = false;
-            if (!$submissionowner = get_record("user", "id", $submission->userid)) {
-                error ("exercise_print_assessment_form: User record not found");
-                }
-            if ($initialassessments = exercise_get_user_assessments($exercise, $submissionowner)) {
-                // should only be one but we'll loop anyway
-                foreach($initialassessments as $initialassessment) {
-                    if (!$teachersubmission = get_record("exercise_submissions", "id", $initialassessment->submissionid)) {
-                        error ("exercise_print_assessment_form: Teacher Submission record not found");
-                        }
-                    if ($teachersubmission->isexercise) {
-                        $exercisefound = true;
-                        break;
-                        }
-                    }
-                }
-            if ($exercisefound) {
-                print_heading(get_string("theexerciseandthesubmissionby", "exercise", 
-                    fullname($submissionowner)));
-                echo "<center><table border=\"1\" width=\"30%\"><tr>
-                    <td align=\"center\">\n";
-                echo exercise_print_submission_title($exercise, $teachersubmission);
-                echo "</td></tr></table><br clear=\"all\" />\n";
-                }
-            }
-        else { 
-            // it's a student assessment, print instructions if it's their own assessment
-            if ($assessment->userid == $USER->id) {
-                print_heading_with_help(get_string("pleaseusethisform", "exercise"), "grading", "exercise");
-                }
-            }
-            
-        echo "<center><table border=\"1\" width=\"30%\"><tr>
-            <td align=\"center\">\n";
-        echo exercise_print_submission_title($exercise, $submission);
-        echo "</td></tr></table><br clear=\"all\" />\n";
-        
-        // only show the grade if grading strategy > 0 and the grade is positive
-        if ($exercise->gradingstrategy and $assessment->grade >= 0) { 
-
-            echo "<center><b>".get_string("thegradeis", "exercise").": ".
-                number_format($assessment->grade * $exercise->grade / 100.0, 2)." (".
-                get_string("maximumgrade")." ".number_format($exercise->grade, 0).")</b></center><br clear=\"all\" />\n";
-            }
-        }
-        
-    // now print the grading form with the teacher's comments if any
-    // FORM is needed for Mozilla browsers, else radio bttons are not checked
-        ?>
-    <form id="assessmentform" method="post" action="assessments.php">
-    <input type="hidden" name="id" value="<?php echo $cm->id ?>" />
-    <input type="hidden" name="aid" value="<?php echo @$assessment->id ?>" />
-    <input type="hidden" name="action" value="updateassessment" />
-    <input type="hidden" name="resubmit" value="0" />
-    <input type="hidden" name="returnto" value="<?php echo $returnto ?>" />
-    <?php
-    if ($assessment) {
-        if (!$assessmentowner = get_record("user", "id", $assessment->userid)) {
-            print_error("Exercise_print_assessment_form: could not find user record");
-            }
-        if ($assessmentowner->id == $USER->id) {
-            $formtitle = get_string("yourassessment", "exercise");
-            }
-        else {
-            $formtitle = get_string("assessmentby", "exercise", fullname($assessmentowner));
-            }
-        }
-    else {
-        $formtitle = get_string("assessmentform", "exercise");
-        }
-    echo "<center><table cellpadding=\"2\" border=\"1\">\n";
-    echo "<tr valign=\"top\">\n";
-
-    echo "  <td colspan=\"2\"><center><b>$formtitle</b></center></td>\n";
-
-    echo "</tr>\n";
-
-    // get the assignment elements...
-    if (!$elementsraw = get_records("exercise_elements", "exerciseid", $exercise->id, "elementno ASC")) {
-        print_string("noteonassignmentelements", "exercise");
-        }
-    else {
-        foreach ($elementsraw as $element) {
-            $elements[] = $element;   // to renumber index 0,1,2...
-            }
-        }
-
-    if ($assessment) {
-        $assessment->generalcomment = clean_text($assessment->generalcomment); //clean html first
-        // get any previous grades...
-        if ($gradesraw = get_records_select("exercise_grades", "assessmentid = $assessment->id", "elementno")) {
-            foreach ($gradesraw as $grade) {
-                $grade->feedback = clean_text($grade->feedback); //clean the html first
-                $grades[] = $grade;   // to renumber index 0,1,2...
-                }
-            }
-        }
-    else {
-        // setup dummy grades array
-        for($i = 0; $i < count($elementsraw); $i++) { // gives a suitable sized loop
-            $grades[$i]->feedback = get_string("yourfeedbackgoeshere", "exercise");
-            $grades[$i]->grade = 0;
-            }
-        }
-
-    // determine what sort of grading
-    switch ($exercise->gradingstrategy) {
-        case 0:  // no grading
-            // now print the form
-            for ($i=0; $i < count($elements); $i++) {
-                $iplus1 = $i+1;
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"right\"><p><b>". get_string("element","exercise")." $iplus1:</b></p></td>\n";
-                echo "  <td>".text_to_html($elements[$i]->description);
-                echo "</td></tr>\n";
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"right\"><p><b>". get_string("feedback").":</b></p></td>\n";
-                echo "  <td>\n";
-                if ($allowchanges) {
-                    echo "      <textarea name=\"feedback[]\" rows=\"3\" cols=\"75\" wrap=\"virtual\">\n";
-                    if (isset($grades[$i]->feedback)) {
-                        echo $grades[$i]->feedback;
-                        }
-                    echo "</textarea>\n";
-                    }
-                else {
-                    echo text_to_html($grades[$i]->feedback);
-                    }
-                echo "  </td>\n";
-                echo "</tr>\n";
-                echo "<tr valign=\"top\">\n";
-                echo "  <td colspan=\"2\">&nbsp;</td>\n";
-                echo "</tr>\n";
-                }
-            break;
-            
-        case 1: // accumulative grading
-            // now print the form
-            for ($i=0; $i < count($elements); $i++) {
-                $iplus1 = $i+1;
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"right\"><p><b>". get_string("element","exercise")." $iplus1:</b></p></td>\n";
-
-                echo "  <td>".text_to_html($elements[$i]->description);
-                echo "<p align=\"right\"><font size=\"1\">Weight: "
-                    .number_format($EXERCISE_EWEIGHTS[$elements[$i]->weight], 2)."</font>\n";
-                echo "</td></tr>\n";
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"right\"><p><b>". get_string("grade"). ":</b></p></td>\n";
-                echo "  <td valign=\"top\">\n";
-                
-                // get the appropriate scale
-                $scalenumber=$elements[$i]->scale;
-                $SCALE = (object)$EXERCISE_SCALES[$scalenumber];
-                switch ($SCALE->type) {
-                    case 'radio' :
-                            // show selections highest first
-                            echo "<center><b>$SCALE->start</b>&nbsp;&nbsp;&nbsp;";
-                            for ($j = $SCALE->size - 1; $j >= 0 ; $j--) {
-                                $checked = false;
-                                if (isset($grades[$i]->grade)) { 
-                                    if ($j == $grades[$i]->grade) {
-                                        $checked = true;
-                                        }
-                                    }
-                                else { // there's no previous grade so check the lowest option
-                                    if ($j == 0) {
-                                        $checked = true;
-                                        }
-                                    }
-                                if ($checked) {
-                                    echo " <input type=\"RADIO\" name=\"grade[$i]\" value=\"$j\" checked=\"checked\" /> &nbsp;&nbsp;&nbsp;\n";
-                                    }
-                                else {
-                                    echo " <input type=\"RADIO\" name=\"grade[$i]\" value=\"$j\" /> &nbsp;&nbsp;&nbsp;\n";
-                                    }
-                                }
-                            echo "&nbsp;&nbsp;&nbsp;<b>$SCALE->end</b></center>\n";
-                            break;
-                    case 'selection' :  
-                            unset($numbers);
-                            for ($j = $SCALE->size; $j >= 0; $j--) {
-                                $numbers[$j] = $j;
-                                }
-                            if (isset($grades[$i]->grade)) {
-                                choose_from_menu($numbers, "grade[$i]", $grades[$i]->grade, "");
-                                }
-                            else {
-                                choose_from_menu($numbers, "grade[$i]", 0, "");
-                                }
-                            break;
-                        
-                    echo "  </td>\n";
-                    echo "</tr>\n";
-                    }
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"right\"><p><b>". get_string("feedback").":</b></p></td>\n";
-                echo "  <td>\n";
-                if ($allowchanges) {
-                    echo "      <textarea name=\"feedback[]\" rows=\"3\" cols=\"75\" wrap=\"virtual\">\n";
-                    if (isset($grades[$i]->feedback)) {
-                        echo $grades[$i]->feedback;
-                        }
-                    echo "</textarea>\n";
-                    }
-                else {
-                    echo text_to_html($grades[$i]->feedback);
-                    }
-                echo "  </td>\n";
-                echo "</tr>\n";
-                echo "<tr valign=\"top\">\n";
-                echo "  <td colspan=\"2\">&nbsp;</td>\n";
-                echo "</tr>\n";
-                }
-            break;
-            
-        case 2: // error banded grading
-            // now run through the elements
-            $error = 0;
-            for ($i=0; $i < count($elements) - 1; $i++) {
-                $iplus1 = $i+1;
-                echo "<tr valign=\"top\">\n";
-
-                echo "  <td align=\"right\"><p><b>". get_string("element","exercise")." $iplus1:</b></p></td>\n";
-
-                echo "  <td>".text_to_html($elements[$i]->description);
-                echo "<p align=\"right\"><font size=\"1\">Weight: "
-                    .number_format($EXERCISE_EWEIGHTS[$elements[$i]->weight], 2)."</font>\n";
-                echo "</td></tr>\n";
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"right\"><p><b>". get_string("grade"). ":</b></p></td>\n";
-                echo "  <td valign=\"top\">\n";
-                    
-                // get the appropriate scale - yes/no scale (0)
-                $SCALE = (object) $EXERCISE_SCALES[0];
-                switch ($SCALE->type) {
-                    case 'radio' :
-                            // show selections highest first
-                            echo "<center><b>$SCALE->start</b>&nbsp;&nbsp;&nbsp;";
-                            for ($j = $SCALE->size - 1; $j >= 0 ; $j--) {
-                                $checked = false;
-                                if (isset($grades[$i]->grade)) { 
-                                    if ($j == $grades[$i]->grade) {
-                                        $checked = true;
-                                        }
-                                    }
-                                else { // there's no previous grade so check the lowest option
-                                    if ($j == 0) {
-                                        $checked = true;
-                                        }
-                                    }
-                                if ($checked) {
-                                    echo " <input type=\"RADIO\" name=\"grade[$i]\" value=\"$j\" checked=\"checked\" /> &nbsp;&nbsp;&nbsp;\n";
-                                    }
-                                else {
-                                    echo " <input type=\"RADIO\" name=\"grade[$i]\" value=\"$j\" /> &nbsp;&nbsp;&nbsp;\n";
-                                    }
-                                }
-                            echo "&nbsp;&nbsp;&nbsp;<b>$SCALE->end</b></center>\n";
-                            break;
-                    case 'selection' :  
-                            unset($numbers);
-                            for ($j = $SCALE->size; $j >= 0; $j--) {
-                                $numbers[$j] = $j;
-                                }
-                            if (isset($grades[$i]->grade)) {
-                                choose_from_menu($numbers, "grade[$i]", $grades[$i]->grade, "");
-                                }
-                            else {
-                                choose_from_menu($numbers, "grade[$i]", 0, "");
-                                }
-                            break;
-                    }
-        
-                echo "  </td>\n";
-                echo "</tr>\n";
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"right\"><p><b>". get_string("feedback").":</b></p></td>\n";
-                echo "  <td>\n";
-                if ($allowchanges) {
-                    echo "      <textarea name=\"feedback[$i]\" rows=\"3\" cols=\"75\" wrap=\"virtual\">\n";
-                    if (isset($grades[$i]->feedback)) {
-                        echo $grades[$i]->feedback;
-                        }
-                    echo "</textarea>\n";
-                    }
-                else {
-                    if (isset($grades[$i]->feedback)) {
-                        echo text_to_html($grades[$i]->feedback);
-                        }
-                    }
-                echo "&nbsp;</td>\n";
-                echo "</tr>\n";
-                echo "<tr valign=\"top\">\n";
-                echo "  <td colspan=\"2\">&nbsp;</td>\n";
-                echo "</tr>\n";
-                if (empty($grades[$i]->grade)) {
-                    $error += $EXERCISE_EWEIGHTS[$elements[$i]->weight];
-                    }
-                }
-            // print the number of negative elements
-            // echo "<tr><td>".get_string("numberofnegativeitems", "exercise")."</td><td>$negativecount</td></tr>\n";
-            // echo "<tr valign=\"top\">\n";
-            // echo "   <td colspan=\"2\">&nbsp;</td>\n";
-            echo "</table></center>\n";
-            // now print the grade table
-            echo "<p><center><b>".get_string("gradetable","exercise")."</b></center>\n";
-            echo "<center><table cellpadding=\"5\" border=\"1\"><tr><td align=\"CENTER\">".
-                get_string("numberofnegativeresponses", "exercise");
-            echo "</td><td>". get_string("suggestedgrade", "exercise")."</td></tr>\n";
-            for ($i=0; $i<=$exercise->nelements; $i++) {
-                if ($i == intval($error + 0.5)) {
-                    echo "<tr><td align=\"CENTER\"><img src=\"$CFG->pixpath/t/right.gif\" alt=\"\" /> $i</td><td align=\"CENTER\">{$elements[$i]->maxscore}</td></tr>\n";
-                    }
-                else {
-                    echo "<tr><td align=\"CENTER\">$i</td><td align=\"CENTER\">{$elements[$i]->maxscore}</td></tr>\n";
-                    }
-                }
-            echo "</table></center>\n";
-            echo "<p><center><table cellpadding=\"5\" border=\"1\"><tr><td align=\"right\"><b>".
-                get_string("optionaladjustment", "exercise").":</b></td><td>\n";
-            unset($numbers);
-            for ($j = 20; $j >= -20; $j--) {
-                $numbers[$j] = $j;
-                }
-            if (isset($grades[$exercise->nelements]->grade)) {
-                choose_from_menu($numbers, "grade[$exercise->nelements]", $grades[$exercise->nelements]->grade, "");
-                }
-            else {
-                choose_from_menu($numbers, "grade[$exercise->nelements]", 0, "");
-                }
-            echo "</td></tr>\n";
-            break;
-            
-        case 3: // criteria grading
-            echo "<tr valign=\"top\">\n";
-
-            echo "  <td>&nbsp;</td>\n";
-
-            echo "  <td><b>". get_string("criterion","exercise")."</b></td>\n";
-
-            echo "  <td><b>".get_string("select")."</b></td>\n";
-            echo "  <td><b>".get_string("suggestedgrade", "exercise")."</b></td>\n";
-            // find which criteria has been selected (saved in the zero element), if any
-            if (isset($grades[0]->grade)) {
-                $selection = $grades[0]->grade;
-                }
-            else {
-                $selection = 0;
-                }
-            // now run through the elements
-            for ($i=0; $i < count($elements); $i++) {
-                $iplus1 = $i+1;
-                echo "<tr valign=\"top\">\n";
-
-                echo "  <td>$iplus1</td><td>".text_to_html($elements[$i]->description)."</td>\n";
-                if ($selection == $i) {
-                    echo "  <td align=\"center\"><input type=\"RADIO\" name=\"grade[0]\" value=\"$i\" checked=\"checked\" /></td>\n";
-                    }
-                else {
-                    echo "  <td align=\"center\"><input type=\"RADIO\" name=\"grade[0]\" value=\"$i\" /></td>\n";
-                    }
-                echo "<td align=\"center\">{$elements[$i]->maxscore}</td></tr>\n";
-                }
-            echo "</table></center>\n";
-            echo "<p><center><table cellpadding=\"5\" border=\"1\"><tr><td align=\"right\"><b>".
-                get_string("optionaladjustment", "exercise")."</b></td><td>\n";
-            unset($numbers);
-            for ($j = 20; $j >= -20; $j--) {
-                $numbers[$j] = $j;
-                }
-            if (isset($grades[1]->grade)) {
-                choose_from_menu($numbers, "grade[1]", $grades[1]->grade, "");
-                }
-            else {
-                choose_from_menu($numbers, "grade[1]", 0, "");
-                }
-            echo "</td></tr>\n";
-            break;
-            
-        case 4: // rubric grading
-            // now run through the elements...
-            for ($i=0; $i < count($elements); $i++) {
-                $iplus1 = $i+1;
-                echo "<tr valign=\"top\">\n";
-
-                echo "<td align=\"right\"><b>".get_string("element", "exercise")." $iplus1:</b></td>\n";
-                echo "<td>".text_to_html($elements[$i]->description).
-                     "<p align=\"right\"><font size=\"1\">Weight: "
-                    .number_format($EXERCISE_EWEIGHTS[$elements[$i]->weight], 2)."</font></td></tr>\n";
-                echo "<tr valign=\"top\">\n";
-
-                echo "  <td align=\"center\"><b>".get_string("select")."</b></td>\n";
-                echo "  <td><b>". get_string("criterion","exercise")."</b></td></tr>\n";
-
-                if (isset($grades[$i])) {
-                    $selection = $grades[$i]->grade;
-                    } else {
-                    $selection = 0;
-                    }
-                // ...and the rubrics
-                if ($rubricsraw = get_records_select("exercise_rubrics", "exerciseid = $exercise->id AND 
-                        elementno = $i", "rubricno ASC")) {
-                    unset($rubrics);
-                    foreach ($rubricsraw as $rubic) {
-                        $rubrics[] = $rubic;   // to renumber index 0,1,2...
-                        }
-                    for ($j=0; $j<5; $j++) {
-                        if (empty($rubrics[$j]->description)) {
-                            break; // out of inner for loop
-                            }
-                        echo "<tr valign=\"top\">\n";
-
-                        if ($selection == $j) {
-                            echo "  <td align=\"center\"><input type=\"RADIO\" name=\"grade[$i]\" value=\"$j\" checked=\"checked\" /></td>\n";
-                            }else {
-                            echo "  <td align=\"center\"><input type=\"RADIO\" name=\"grade[$i]\" value=\"$j\" /></td>\n";
-                            }
-                        echo "<td>".text_to_html($rubrics[$j]->description)."</td>\n";
-                        }
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td align=\"right\"><p><b>". get_string("feedback").":</b></p></td>\n";
-                    echo "  <td>\n";
-                    if ($allowchanges) {
-                        echo "      <textarea name=\"feedback[]\" rows=\"3\" cols=\"75\" wrap=\"virtual\">\n";
-                        if (isset($grades[$i]->feedback)) {
-                            echo $grades[$i]->feedback;
-                            }
-                        echo "</textarea>\n";
-                        }
-                    else {
-                        echo text_to_html($grades[$i]->feedback);
-                        }
-                    echo "  </td>\n";
-                    echo "</tr>\n";
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td colspan=\"2\">&nbsp;</td>\n";
-                    echo "</tr>\n";
-                    }
-                }
-            break;
-        } // end of outer switch
-    
-    // now get the general comment (present in all types)
-    echo "<tr valign=\"top\">\n";
-    switch ($exercise->gradingstrategy) {
-        case 0:
-        case 1:
-        case 4 : // no grading, accumulative and rubic
-            echo "  <td align=\"right\"><p><b>". get_string("generalcomment", "exercise").":</b></p></td>\n";
-            break; 
-        default : 
-            echo "  <td align=\"right\"><p><b>". get_string("reasonforadjustment", "exercise").":</b></p></td>\n";
-        }
-    echo "  <td>\n";
-    if ($allowchanges) {
-        echo "      <textarea name=\"generalcomment\" rows=\"5\" cols=\"75\" wrap=\"virtual\">\n";
-        if (isset($assessment->generalcomment)) {
-            echo $assessment->generalcomment;
-            }
-        echo "</textarea>\n";
-        }
-    else {
-        if ($assessment) {
-            if (isset($assessment->generalcomment)) {
-                echo text_to_html($assessment->generalcomment);
-                }
-            }
-        else {
-            print_string("yourfeedbackgoeshere", "exercise");
-            }
-        }
-
-    echo "&nbsp;</td>\n";
-
-    echo "</tr>\n";
-
-    echo "<tr valign=\"top\">\n";
-
-    echo "  <td colspan=\"2\">&nbsp;</td>\n";
-
-    echo "</tr>\n";
-    
-    $timenow = time();
-    
-    // always show the teacher the grading grade if it's not their assessment!
-    if ($assessment and isteacher($course->id) and ($assessment->userid != $USER->id) and $exercise->gradinggrade) {  
-        echo "<tr><td align=\"right\"><b>".get_string("gradeforstudentsassessment", "exercise", $course->student).
-            "</td><td>\n";
-        echo number_format($exercise->gradinggrade * $assessment->gradinggrade / 100.0, 0);
-        echo "</td></tr>\n";
-        }
-        
-    // ...and close the table, show buttons if needed...
-    echo "</table><br />\n";
-    if ($assessment and $allowchanges) {  
-        if (isteacher($course->id)) { 
-            // ...show two buttons...to resubmit or not to resubmit
-            echo "<input type=\"button\" value=\"".get_string("studentnotallowed", "exercise", $course->student)."\" 
-                onclick=\"getElementById('assessmentform').submit();\" />\n";
-            echo "<input type=\"button\" value=\"".get_string("studentallowedtoresubmit", "exercise", $course->student)."\" 
-                onclick=\"getElementById('assessmentform').resubmit.value='1';getElementById('assessmentform').submit();\" />\n";
-            }
-        else {
-            // ... show save button
-            echo "<input type=\"submit\" value=\"".get_string("savemyassessment", "exercise")."\" />\n";
-            }
-        }
-    echo "</center></form>\n";
-    }
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_print_assessments_by_user_for_admin($exercise, $user) {
-
-    if (! $course = get_record("course", "id", $exercise->course)) {
-        print_error("Course is misconfigured");
-        }
-    if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        print_error("Course Module ID was incorrect");
-        }
-
-    if ($assessments =exercise_get_user_assessments($exercise, $user)) {
-        foreach ($assessments as $assessment) {
-            echo "<p><center><b>".get_string("assessmentby", "exercise", fullname($user))."</b></center></p>\n";
-            exercise_print_assessment_form($exercise, $assessment);
-            echo "<p align=\"right\"><a href=\"assessments.php?action=adminamendgradinggrade&amp;id=$cm->id&amp;aid=$assessment->id\">".
-                get_string("amend", "exercise")." ".get_string("gradeforstudentsassessment","exercise",
-                $course->student)."</a>\n";
-            echo " | <a href=\"assessments.php?action=adminconfirmdelete&amp;id=$cm->id&amp;aid=$assessment->id\">".
-                get_string("delete", "exercise")."</a></p><hr />\n";
-            }
-        }
-    }
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_print_assessments_for_admin($exercise, $submission) {
-
-    if (! $course = get_record("course", "id", $exercise->course)) {
-        print_error("Course is misconfigured");
-        }
-    if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        print_error("Course Module ID was incorrect");
-        }
-
-    if ($assessments = exercise_get_assessments($submission)) {
-        foreach ($assessments as $assessment) {
-            if (!$user = get_record("user", "id", $assessment->userid)) {
-                error (" exercise_print_assessments_for_admin: unable to get user record");
-                }
-            echo "<p><center><b>".get_string("assessmentby", "exercise", fullname($user))."</b></center></p>\n";
-            exercise_print_assessment_form($exercise, $assessment);
-            echo "<p align=\"right\"><a href=\"assessments.php?action=adminconfirmdelete&amp;id=$cm->id&amp;aid=$assessment->id\">".
-                get_string("delete", "exercise")."</a></p><hr />\n";
-            }
-        }
-    }
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_print_assignment_info($exercise) {
-
-    if (! $course = get_record("course", "id", $exercise->course)) {
-        print_error("Course is misconfigured");
-    }
-    if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        print_error("Course Module ID was incorrect");
-    }
-    // print standard assignment heading
-    $strdifference = format_time($exercise->deadline - time());
-    if (($exercise->deadline - time()) < 0) {
-        $strdifference = "<font color=\"red\">$strdifference</font>";
-    }
-    $strduedate = userdate($exercise->deadline)." ($strdifference)";
-    print_simple_box_start("center");
-    print_heading(format_string($exercise->name), "center");
-    print_simple_box_start("center");
-    echo "<b>".get_string("duedate", "exercise")."</b>: $strduedate<br />";
-    $maxgrade = $exercise->grade + $exercise->gradinggrade;
-    echo "<b>".get_string("maximumgrade")."</b>: $maxgrade<br />";
-    echo "<b>".get_string("handlingofmultiplesubmissions", "exercise")."</b>:";
-    if ($exercise->usemaximum) {
-        echo get_string("usemaximum", "exercise")."<br />\n";
-    }
-    else {
-        echo get_string("usemean", "exercise")."<br />\n";
-    }
-    echo "<b>".get_string("detailsofassessment", "exercise")."</b>: 
-        <a href=\"assessments.php?id=$cm->id&amp;action=displaygradingform\">".
-        get_string("specimenassessmentform", "exercise")."</a><br />";
-    print_simple_box_end();
-    print_simple_box_end();
-    echo "<br />";  
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_print_difference($time) {
-    if ($time < 0) {
-        $timetext = get_string("late", "assignment", format_time($time));
-        return " (<font color=\"red\">$timetext</font>)";
-    } else {
-        $timetext = get_string("early", "assignment", format_time($time));
-        return " ($timetext)";
-    }
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_print_feedback($course, $submission) {
-    global $CFG, $RATING;
-
-    if (! $teacher = get_record("user", "id", $submission->teacher)) {
-        print_error("Weird exercise error");
-    }
-
-    echo "\n<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" align=\"center\"><tr><td bgcolor=#888888>";
-    echo "\n<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" valign=\"top\">";
-
-    echo "\n<tr>";
-    echo "\n<td rowspan=\"3\" width=\"35\" valign=\"top\">";
-    print_user_picture($teacher->id, $course->id, $teacher->picture);
-    echo "</td>";
-    echo "<td nowrap=\"nowrap\" width=\"100%\">".fullname($teacher);
-    echo "&nbsp;&nbsp;<font size=\"2\"><i>".userdate($submission->timemarked)."</i>";
-    echo "</tr>";
-
-    echo "\n<tr><td width=\"100%\">";
-
-    echo "<p align=\"right\"><font size=-1><i>";
-    if ($submission->grade) {
-        echo get_string("grade").": $submission->grade";
-    } else {
-        echo get_string("nograde");
-    }
-    echo "</i></font></p>";
-
-    echo text_to_html($submission->assessorcomment);
-    echo "</td></tr></table>";
-    echo "</td></tr></table>";
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_print_league_table($exercise) {
-    // print an order table of (student) submissions in grade order, only print the student's best submission when
-    // there are multiple submissions
-    if (! $course = get_record("course", "id", $exercise->course)) {
-        print_error("Print league table: Course is misconfigured");
-    }
-    $groupid = get_current_group($course->id);
-    $nentries = $exercise->showleaguetable;
-    if ($nentries == 99) {
-        $nentries = 999999; // a large number
-        }
-
-    if ($exercise->anonymous and isstudent($course->id)) {
-        $table->head = array (get_string("title", "exercise"), get_string("grade"));
-        $table->align = array ("left", "center");
-        $table->size = array ("*", "*");
-    } else { // show names
-        $table->head = array (get_string("title", "exercise"),  get_string("name"), get_string("grade"));
-        $table->align = array ("left", "left", "center");
-        $table->size = array ("*", "*", "*");
-    }
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-
-    if ($submissions = exercise_get_student_submissions($exercise, "grade", $groupid)) {
-        $n = 1;
-        foreach ($submissions as $submission) {
-            if (empty($done[$submission->userid])) {
-                if ($submission->late) {
-                    continue;
-                }
-                if (!$user = get_record("user", "id", $submission->userid)) {
-                    print_error("Print league table: user not found");
-                    }
-                if ($exercise->anonymous and isstudent($course->id)) {
-                    $table->data[] = array(exercise_print_submission_title($exercise, $submission),
-                            number_format($submission->grade * $exercise->grade / 100.0, 1));
-                } else {
-                    $table->data[] = array(exercise_print_submission_title($exercise, $submission), 
-                            fullname($user), 
-                            number_format($submission->grade * $exercise->grade / 100.0, 1));
-                }
-                $n++;
-                if ($n > $nentries) {
-                    break;
-                }
-                $done[$submission->userid] = 'ok';
-                }
-            }
-        print_heading(get_string("leaguetable", "exercise"));
-        print_table($table);
-        }
-    }
-    
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_print_submission_assessments($exercise, $submission) {
-    // Returns a list of grades for this submission
-    
-    if (! $course = get_record("course", "id", $exercise->course)) {
-        print_error("Course is misconfigured");
-    }
-    if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        print_error("Course Module ID was incorrect");
-    }
-    
-    $str = '';
-    if ($assessments = exercise_get_assessments($submission)) {
-        foreach ($assessments as $assessment) {
-            if (isteacher($exercise->course, $assessment->userid)) {
-                $str .= "[".number_format($assessment->grade * $exercise->grade / 100.0, 0)."] ";
-                }
-            else { // assessment by student - shouldn't happen!
-                $str .= "{".number_format($assessment->grade * $exercise->grade / 100.0, 0)."} ";
-                }
-            }
-        }
-    if (!$str) {
-        $str = "&nbsp;";   // be kind to Mozilla browsers!
-        }
-    return $str;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function exercise_print_tabbed_heading($tabs) {
-// Prints a tabbed heading where one of the tabs highlighted.
-// $tabs is an object with several properties.
-//      $tabs->names      is an array of tab names
-//      $tabs->urls       is an array of links
-//      $tabs->align     is an array of column alignments (defaults to "center")
-//      $tabs->size      is an array of column sizes
-//      $tabs->wrap      is an array of "nowrap"s or nothing
-//      $tabs->highlight    is an index (zero based) of "active" heading .
-//      $tabs->width     is an percentage of the page (defualts to 80%)
-//      $tabs->cellpadding    padding on each cell (defaults to 5)
-
-    global $CFG;
-    
-    if (isset($tabs->names)) {
-        foreach ($tabs->names as $key => $name) {
-            if (!empty($tabs->urls[$key])) {
-                $url =$tabs->urls[$key];
-                if ($tabs->highlight == $key) {
-                    $tabcontents[$key] = "<b>$name</b>";
-                } else {
-                    $tabcontents[$key] = "<a class= \"dimmed\" href=\"$url\"><b>$name</b></a>";
-                }
-            } else {
-                $tabcontents[$key] = "<b>$name</b>";
-            }
-        }
-    }
-
-    if (empty($tabs->width)) {
-        $tabs->width = "80%";
-    }
-
-    if (empty($tabs->cellpadding)) {
-        $tabs->cellpadding = "5";
-    }
-
-    // print_simple_box_start("center", "$table->width", "#ffffff", 0);
-    echo "<table width=\"$tabs->width\" border=\"0\" valign=\"top\" align=\"center\" ";
-    echo " cellpadding=\"$tabs->cellpadding\" cellspacing=\"0\" class=\"generaltable\">\n";
-
-    if (!empty($tabs->names)) {
-        echo "<tr>";
-        echo "<td  class=\"generaltablecell\">".
-            "<img width=\"10\" src=\"$CFG->wwwroot/pix/spacer.gif\" alt=\"\" /></td>\n";
-        foreach ($tabcontents as $key => $tab) {
-            if (isset($align[$key])) {
-                $alignment = "align=\"$align[$key]\"";
-            } else {
-                $alignment = "align=\"center\"";
-            }
-            if (isset($size[$key])) {
-                $width = "width=\"$size[$key]\"";
-            } else {
-                $width = "";
-            }
-            if (isset($wrap[$key])) {
-                $wrapping = "no wrap";
-            } else {
-                $wrapping = "";
-            }
-            if ($key == $tabs->highlight) {
-                echo "<td valign=\"top\" class=\"generaltabselected\" $alignment $width $wrapping>$tab</td>\n";
-            } else {
-                echo "<td valign=\"top\" class=\"generaltab\" $alignment $width $wrapping>$tab</td>\n";
-            }
-        echo "<td  class=\"generaltablecell\">".
-            "<img width=\"10\" src=\"$CFG->wwwroot/pix/spacer.gif\" alt=\"\" /></td>\n";
-        }
-        echo "</tr>\n";
-    } else {
-        echo "<tr><td>No names specified</td></tr>\n";
-    }
-    // bottom stripe
-    $ncells = count($tabs->names)*2 +1;
-    $height = 2;
-    echo "<tr><td colspan=\"$ncells\">".
-        "<img height=\"$height\" src=\"$CFG->wwwroot/pix/spacer.gif\" alt=\"\" /></td></tr>\n";
-    echo "</table>\n";
-    // print_simple_box_end();
-
-    return true;
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_print_teacher_assessment_form($exercise, $assessment, $submission, $returnto = '') {
-    // prints an assessment form based on the student's assessment 
-    // if the teacher is re-assessing a submission they would use exercise_print_assessment_form()
-    // (for teachers only)
-    global $CFG, $USER, $EXERCISE_SCALES, $EXERCISE_EWEIGHTS;
-    
-    if (! $course = get_record("course", "id", $exercise->course)) {
-        print_error("Course is misconfigured");
-    }
-    if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        print_error("Course Module ID was incorrect");
-    }
-    
-    $timenow = time();
-
-    if(!$submissionowner = get_record("user", "id", $submission->userid)) {
-        print_error("Print teacher assessment form: User record not found");
-    }
-
-    echo "<center><table border=\"1\" width=\"30%\"><tr>
-        <td align=\"center\">\n";
-    if (!$teachersubmission = get_record("exercise_submissions", "id", $assessment->submissionid)) {
-        error ("Print teacher assessment form: Submission record not found");
-    }
-    echo exercise_print_submission_title($exercise, $teachersubmission);
-    echo "</td></tr></table><br clear=\"all\" />\n";
-    
-    echo "<center><table border=\"1\" width=\"30%\"><tr>
-        <td align=\"center\">\n";
-    echo exercise_print_submission_title($exercise, $submission);
-    echo "</td></tr></table></center><br clear=\"all\" />\n";
-
-    ?>
-    <form id="assessmentform" method="post" action="assessments.php">
-    <input type="hidden" name="id" value="<?php echo $cm->id ?>" />
-    <input type="hidden" name="said" value="<?php echo $assessment->id ?>" />
-    <input type="hidden" name="sid" value="<?php echo $submission->id ?>" />
-    <input type="hidden" name="action" value="updateteacherassessment" />
-    <input type="hidden" name="resubmit" value="0" />
-    <input type="hidden" name="returnto" value="<?php echo $returnto ?>" />
-    <?php
-
-    // now print a normal assessment form based on the student's assessment for this submission 
-    // and allow the teacher to grade and add additional comments
-    $studentassessment = $assessment;
-    $allowchanges = true;
-    
-    print_heading_with_help(get_string("pleasemakeyourownassessment", "exercise",
-        fullname($submissionowner)), "grading", "exercise");
-    
-    // is there an existing assessment for the submission
-    if (!$assessment = exercise_get_submission_assessment($submission, $USER)) {
-        // copy student's assessment with their comments for the teacher's assessment
-        $assessment = exercise_copy_assessment($studentassessment, $submission, true);
-        }
-
-    // only show the grade if grading strategy > 0 and the grade is positive
-    if ($exercise->gradingstrategy and $assessment->grade >= 0) { 
-        echo "<center><b>".get_string("thegradeis", "exercise").": ".
-            number_format($assessment->grade * $exercise->grade / 100.0, 2)." (".
-            get_string("maximumgrade")." ".number_format($exercise->grade, 0).")</b></center><br clear=\"all\" />\n";
-        }
-        
-    echo "<center><table cellpadding=\"2\" border=\"1\">\n";
-    echo "<tr valign=\"top\">\n";
-    echo "  <td colspan=\"2\"><center><b>".get_string("yourassessment", "exercise").
-        "</b></center></td>\n";
-    echo "</tr>\n";
-    
-    // get the assignment elements...
-    if (!$elementsraw = get_records("exercise_elements", "exerciseid", $exercise->id, "elementno ASC")) {
-        print_error("Teacher assessment form: Elements not found");
-    }
-    foreach ($elementsraw as $element) {
-        $elements[] = $element;   // to renumber index 0,1,2...
-    }
-     
-    // ...and get any previous grades...
-    if ($gradesraw = get_records_select("exercise_grades", "assessmentid = $assessment->id", "elementno")) {
-        foreach ($gradesraw as $grade) {
-            $grades[] = $grade;   // to renumber index 0,1,2...
-        }
-    }
-                
-    // determine what sort of grading
-    switch ($exercise->gradingstrategy) {
-        case 0:  // no grading
-            // now print the form
-            for ($i=0; $i < count($elements); $i++) {
-                $iplus1 = $i+1;
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"right\"><p><b>". get_string("element","exercise")." $iplus1:</b></p></td>\n";
-                echo "  <td>".text_to_html($elements[$i]->description);
-                echo "</td></tr>\n";
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"right\"><p><b>". get_string("feedback").":</b></p></td>\n";
-                echo "  <td>\n";
-                if ($allowchanges) {
-                    echo "      <textarea name=\"feedback[]\" rows=\"3\" cols=\"75\" wrap=\"virtual\">\n";
-                    if (isset($grades[$i]->feedback)) {
-                        echo $grades[$i]->feedback;
-                    }
-                    echo "</textarea>\n";
-                }
-                else {
-                    echo text_to_html($grades[$i]->feedback);
-                }
-                echo "  </td>\n";
-                echo "</tr>\n";
-                echo "<tr valign=\"top\">\n";
-                echo "  <td colspan=\"2\">&nbsp;</td>\n";
-                echo "</tr>\n";
-            }
-            break;
-            
-        case 1: // accumulative grading
-            // now print the form
-            for ($i=0; $i < count($elements); $i++) {
-                $iplus1 = $i+1;
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"right\"><p><b>". get_string("element","exercise")." $iplus1:</b></p></td>\n";
-                echo "  <td>".text_to_html($elements[$i]->description);
-                echo "<p align=\"right\"><font size=\"1\">Weight: "
-                    .number_format($EXERCISE_EWEIGHTS[$elements[$i]->weight], 2)."</font>\n";
-                echo "</td></tr>\n";
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"right\"><p><b>". get_string("grade"). ":</b></p></td>\n";
-                echo "  <td valign=\"top\">\n";
-                
-                // get the appropriate scale
-                $scalenumber=$elements[$i]->scale;
-                $SCALE = (object)$EXERCISE_SCALES[$scalenumber];
-                switch ($SCALE->type) {
-                    case 'radio' :
-                            // show selections highest first
-                            echo "<center><b>$SCALE->start</b>&nbsp;&nbsp;&nbsp;";
-                            for ($j = $SCALE->size - 1; $j >= 0 ; $j--) {
-                                $checked = false;
-                                if (isset($grades[$i]->grade)) { 
-                                    if ($j == $grades[$i]->grade) {
-                                        $checked = true;
-                                    }
-                                }
-                                else { // there's no previous grade so check the lowest option
-                                    if ($j == 0) {
-                                        $checked = true;
-                                    }
-                                }
-                                if ($checked) {
-                                    echo " <input type=\"RADIO\" name=\"grade[$i]\" value=\"$j\" checked=\"checked\" /> &nbsp;&nbsp;&nbsp;\n";
-                                }
-                                else {
-                                    echo " <input type=\"RADIO\" name=\"grade[$i]\" value=\"$j\" /> &nbsp;&nbsp;&nbsp;\n";
-                                }
-                            }
-                            echo "&nbsp;&nbsp;&nbsp;<b>$SCALE->end</b></center>\n";
-                            break;
-                    case 'selection' :  
-                            unset($numbers);
-                            for ($j = $SCALE->size; $j >= 0; $j--) {
-                                $numbers[$j] = $j;
-                            }
-                            if (isset($grades[$i]->grade)) {
-                                choose_from_menu($numbers, "grade[$i]", $grades[$i]->grade, "");
-                            }
-                            else {
-                                choose_from_menu($numbers, "grade[$i]", 0, "");
-                            }
-                            break;
-        
-                    echo "  </td>\n";
-                    echo "</tr>\n";
-                }
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"right\"><p><b>". get_string("feedback").":</b></p></td>\n";
-                echo "  <td>\n";
-                if ($allowchanges) {
-                    echo "      <textarea name=\"feedback[]\" rows=\"3\" cols=\"75\" wrap=\"virtual\">\n";
-                    if (isset($grades[$i]->feedback)) {
-                        echo $grades[$i]->feedback;
-                    }
-                    echo "</textarea>\n";
-                }
-                else {
-                    echo text_to_html($grades[$i]->feedback);
-                }
-                echo "  </td>\n";
-                echo "</tr>\n";
-                echo "<tr valign=\"top\">\n";
-                echo "  <td colspan=\"2\">&nbsp;</td>\n";
-                echo "</tr>\n";
-            }
-            break;
-            
-        case 2: // error banded grading
-            // now run through the elements
-            $error = 0;
-            for ($i=0; $i < count($elements) - 1; $i++) {
-                $iplus1 = $i+1;
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"right\"><p><b>". get_string("element","exercise")." $iplus1:</b></p></td>\n";
-                echo "  <td>".text_to_html($elements[$i]->description);
-                echo "<p align=\"right\"><font size=\"1\">Weight: "
-                    .number_format($EXERCISE_EWEIGHTS[$elements[$i]->weight], 2)."</font>\n";
-                echo "</td></tr>\n";
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"right\"><p><b>". get_string("grade"). ":</b></p></td>\n";
-                echo "  <td valign=\"top\">\n";
-                    
-                // get the appropriate scale - yes/no scale (0)
-                $SCALE = (object) $EXERCISE_SCALES[0];
-                switch ($SCALE->type) {
-                    case 'radio' :
-                            // show selections highest first
-                            echo "<center><b>$SCALE->start</b>&nbsp;&nbsp;&nbsp;";
-                            for ($j = $SCALE->size - 1; $j >= 0 ; $j--) {
-                                $checked = false;
-                                if (isset($grades[$i]->grade)) { 
-                                    if ($j == $grades[$i]->grade) {
-                                        $checked = true;
-                                    }
-                                }
-                                else { // there's no previous grade so check the lowest option
-                                    if ($j == 0) {
-                                        $checked = true;
-                                    }
-                                }
-                                if ($checked) {
-                                    echo " <input type=\"RADIO\" name=\"grade[$i]\" value=\"$j\" checked=\"checked\" /> &nbsp;&nbsp;&nbsp;\n";
-                                }
-                                else {
-                                    echo " <input type=\"RADIO\" name=\"grade[$i]\" value=\"$j\" /> &nbsp;&nbsp;&nbsp;\n";
-                                }
-                            }
-                            echo "&nbsp;&nbsp;&nbsp;<b>$SCALE->end</b></center>\n";
-                            break;
-                    case 'selection' :  
-                            unset($numbers);
-                            for ($j = $SCALE->size; $j >= 0; $j--) {
-                                $numbers[$j] = $j;
-                            }
-                            if (isset($grades[$i]->grade)) {
-                                choose_from_menu($numbers, "grade[$i]", $grades[$i]->grade, "");
-                            }
-                            else {
-                                choose_from_menu($numbers, "grade[$i]", 0, "");
-                            }
-                            break;
-                }
-        
-                echo "  </td>\n";
-                echo "</tr>\n";
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"right\"><p><b>". get_string("feedback").":</b></p></td>\n";
-                echo "  <td>\n";
-                if ($allowchanges) {
-                    echo "      <textarea name=\"feedback[$i]\" rows=\"3\" cols=\"75\" wrap=\"virtual\">\n";
-                    if (isset($grades[$i]->feedback)) {
-                        echo $grades[$i]->feedback;
-                    }
-                    echo "</textarea>\n";
-                    }
-                else {
-                    if (isset($grades[$i]->feedback)) {
-                        echo text_to_html($grades[$i]->feedback);
-                    }
-                }
-                echo "&nbsp;</td>\n";
-                echo "</tr>\n";
-                echo "<tr valign=\"top\">\n";
-                echo "  <td colspan=\"2\">&nbsp;</td>\n";
-                echo "</tr>\n";
-                if (empty($grades[$i]->grade)) {
-                        $error += $EXERCISE_EWEIGHTS[$elements[$i]->weight];
-                }
-            }
-            // print the number of negative elements
-            // echo "<tr><td>".get_string("numberofnegativeitems", "exercise")."</td><td>$negativecount</td></tr>\n";
-            // echo "<tr valign=\"top\">\n";
-            // echo "   <td colspan=\"2\">&nbsp;</td>\n";
-            echo "</table></center>\n";
-            // now print the grade table
-            echo "<p><center><b>".get_string("gradetable","exercise")."</b></center>\n";
-            echo "<center><table cellpadding=\"5\" border=\"1\"><tr><td align=\"CENTER\">".
-                get_string("numberofnegativeresponses", "exercise");
-            echo "</td><td>". get_string("suggestedgrade", "exercise")."</td></tr>\n";
-            for ($i=0; $i<=$exercise->nelements; $i++) {
-                if ($i == intval($error + 0.5)) {
-                    echo "<tr><td align=\"CENTER\"><img src=\"$CFG->pixpath/t/right.gif\" alt=\"\" /> $i</td><td align=\"CENTER\">{$elements[$i]->maxscore}</td></tr>\n";
-                }
-                else {
-                    echo "<tr><td align=\"CENTER\">$i</td><td align=\"CENTER\">{$elements[$i]->maxscore}</td></tr>\n";
-                }
-            }
-            echo "</table></center>\n";
-            echo "<p><center><table cellpadding=\"5\" border=\"1\"><tr><td align=\"right\"><b>".
-                get_string("optionaladjustment", "exercise")."</b></td><td>\n";
-            unset($numbers);
-            for ($j = 20; $j >= -20; $j--) {
-                $numbers[$j] = $j;
-            }
-            if (isset($grades[$exercise->nelements]->grade)) {
-                choose_from_menu($numbers, "grade[$exercise->nelements]", $grades[$exercise->nelements]->grade, "");
-            }
-            else {
-                choose_from_menu($numbers, "grade[$exercise->nelements]", 0, "");
-            }
-            echo "</td></tr>\n";
-            break;
-            
-        case 3: // criteria grading
-            echo "<tr valign=\"top\">\n";
-            echo "  <td>&nbsp;</td>\n";
-            echo "  <td><b>". get_string("criterion","exercise")."</b></td>\n";
-            echo "  <td><b>".get_string("select")."</b></td>\n";
-            echo "  <td><b>".get_string("suggestedgrade", "exercise")."</b></td>\n";
-            // find which criteria has been selected (saved in the zero element), if any
-            if (isset($grades[0]->grade)) {
-                $selection = $grades[0]->grade;
-            }
-            else {
-                $selection = 0;
-            }
-            // now run through the elements
-            for ($i=0; $i < count($elements); $i++) {
-                $iplus1 = $i+1;
-                echo "<tr valign=\"top\">\n";
-                echo "  <td>$iplus1</td><td>".text_to_html($elements[$i]->description)."</td>\n";
-                if ($selection == $i) {
-                    echo "  <td align=\"center\"><input type=\"RADIO\" name=\"grade[0]\" value=\"$i\" checked=\"checked\" /></td>\n";
-                }
-                else {
-                    echo "  <td align=\"center\"><input type=\"RADIO\" name=\"grade[0]\" value=\"$i\" /></td>\n";
-                }
-                echo "<td align=\"center\">{$elements[$i]->maxscore}</td></tr>\n";
-            }
-            echo "</table></center>\n";
-            echo "<p><center><table cellpadding=\"5\" border=\"1\"><tr><td align=\"right\"><b>".
-                get_string("optionaladjustment", "exercise")."</b></td><td>\n";
-            unset($numbers);
-            for ($j = 20; $j >= -20; $j--) {
-                $numbers[$j] = $j;
-            }
-            if (isset($grades[1]->grade)) {
-                choose_from_menu($numbers, "grade[1]", $grades[1]->grade, "");
-            }
-            else {
-                choose_from_menu($numbers, "grade[1]", 0, "");
-            }
-            echo "</td></tr>\n";
-            break;
-            
-        case 4: // rubric grading
-            // now run through the elements...
-            for ($i=0; $i < count($elements); $i++) {
-                $iplus1 = $i+1;
-                echo "<tr valign=\"top\">\n";
-                echo "<td align=\"right\"><b>".get_string("element", "exercise")." $iplus1:</b></td>\n";
-                echo "<td>".text_to_html($elements[$i]->description).
-                     "<p align=\"right\"><font size=\"1\">Weight: "
-                    .number_format($EXERCISE_EWEIGHTS[$elements[$i]->weight], 2)."</font></td></tr>\n";
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"center\"><b>".get_string("select")."</b></td>\n";
-                echo "  <td><b>". get_string("criterion","exercise")."</b></td></tr>\n";
-                if (isset($grades[$i])) {
-                    $selection = $grades[$i]->grade;
-                } else {
-                    $selection = 0;
-                }
-                // ...and the rubrics
-                if ($rubricsraw = get_records_select("exercise_rubrics", "exerciseid = $exercise->id AND 
-                        elementno = $i", "rubricno ASC")) {
-                    unset($rubrics);
-                    foreach ($rubricsraw as $rubic) {
-                        $rubrics[] = $rubic;   // to renumber index 0,1,2...
-                    }
-                    for ($j=0; $j<5; $j++) {
-                        if (empty($rubrics[$j]->description)) {
-                            break; // out of inner for loop
-                        }
-                        echo "<tr valign=\"top\">\n";
-                        if ($selection == $j) {
-                            echo "  <td align=\"center\"><input type=\"RADIO\" name=\"grade[$i]\" value=\"$j\" checked=\"checked\" /></td>\n";
-                        } else {
-                            echo "  <td align=\"center\"><input type=\"RADIO\" name=\"grade[$i]\" value=\"$j\" /></td>\n";
-                        }
-                        echo "<td>".text_to_html($rubrics[$j]->description)."</td>\n";
-                    }
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td align=\"right\"><p><b>". get_string("feedback").":</b></p></td>\n";
-                    echo "  <td>\n";
-                    if ($allowchanges) {
-                        echo "      <textarea name=\"feedback[]\" rows=\"3\" cols=\"75\" wrap=\"virtual\">\n";
-                        if (isset($grades[$i]->feedback)) {
-                            echo $grades[$i]->feedback;
-                        }
-                        echo "</textarea>\n";
-                    }
-                    else {
-                        echo text_to_html($grades[$i]->feedback);
-                    }
-                    echo "  </td>\n";
-                    echo "</tr>\n";
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td colspan=\"2\">&nbsp;</td>\n";
-                    echo "</tr>\n";
-                }
-            }
-            break;
-        } // end of outer switch
-    
-    // now get the general comment (present in all types)
-    echo "<tr valign=\"top\">\n";
-    switch ($exercise->gradingstrategy) {
-        case 0:
-        case 1:
-        case 4 : // no grading, accumulative and rubic
-            echo "  <td align=\"right\"><p><b>". get_string("generalcomment", "exercise").":</b></p></td>\n";
-            break; 
-        default : 
-            echo "  <td align=\"right\"><p><b>". get_string("reasonforadjustment", "exercise").":</b></p></td>\n";
-    }
-    echo "  <td>\n";
-    if ($allowchanges) {
-        echo "      <textarea name=\"generalcomment\" rows=\"5\" cols=\"75\" wrap=\"virtual\">\n";
-        if (isset($assessment->generalcomment)) {
-            echo $assessment->generalcomment;
-        }
-        echo "</textarea>\n";
-    }
-    else {
-        if ($assessment) {
-            if (isset($assessment->generalcomment)) {
-                echo text_to_html($assessment->generalcomment);
-            }
-        }
-        else {
-            print_string("yourfeedbackgoeshere", "exercise");
-        }
-    }
-    echo "&nbsp;</td>\n";
-    echo "</tr>\n";
-    echo "<tr valign=\"top\">\n";
-    echo "  <td colspan=\"2\">&nbsp;</td>\n";
-    echo "</tr>\n";
-    
-    // ...and close the table and show two buttons...to resubmit or not to resubmit
-    echo "</table>\n";
-    echo "<br /><input type=\"button\" value=\"".get_string("studentnotallowed", "exercise", $course->student)."\" 
-        onclick=\"getElementById('assessmentform').submit();\" />\n";
-    echo "<input type=\"button\" value=\"".get_string("studentallowedtoresubmit", "exercise", $course->student)."\" 
-        onclick=\"getElementById('assessmentform').resubmit.value='1';getElementById('assessmentform').submit();\" />\n";
-    echo "</center></form>\n";
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_print_teacher_table($course) {
-// print how many assessments each teacher has done in each exercise
-
-    if (! $exercises = get_all_instances_in_course("exercise", $course)) {
-        notice(get_string('thereareno', 'moodle', get_string('modulenameplural', 'exercise')), "../../course/view.php?id=$course->id");
-        die;
-    }
-
-    $timenow = time();
-    
-    $table->head[] = '';
-    $table->align[] = 'left';
-    $table->size[] = '*';
-    $table->head[] = get_string("total");
-    $table->align[] = "center";
-    $table->size[] = "*";
-        foreach ($exercises as $exercise) {
-        $table->head[] = format_string($exercise->name);
-        $table->align[] = "center";
-        $table->size[] = "*";
-        }
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-
-    if (!$teachers = get_course_teachers($course->id, "u.firstname, u.lastname")) {
-        print_error("No teachers on this course!");
-    }
-    for ($j = 0; $j < count($exercises); $j++) {
-        $grand[$j] = 0;
-    }
-    $grandtotal = 0;
-    foreach ($teachers as $teacher) {
-        unset($n);
-        $total = 0;
-        $j = 0;
-        foreach ($exercises as $exercise) {
-            $i = exercise_count_assessments_by_teacher($exercise, $teacher);
-            $n[] = $i;
-            $total += $i;
-            $grand[$j] += $i;
-            $j++;
-        }
-        $grandtotal += $total;
-        $table->data[] = array_merge(array(fullname($teacher)), array($total), $n);
-    }
-    $table->data[] = array_merge(array(get_string("total")), array($grandtotal), $grand);
-    print_heading(get_string("teacherassessmenttable", "exercise", $course->teacher));
-    print_table($table);
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_print_time_to_deadline($time) {
-    if ($time < 0) {
-        $timetext = get_string("afterdeadline", "exercise", format_time($time));
-        return " (<font color=\"red\">$timetext</font>)";
-    } else {
-        $timetext = get_string("beforedeadline", "exercise", format_time($time));
-        return " ($timetext)";
-    }
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_print_upload_form($exercise) {
-
-    global $CFG;
-
-    if (! $course = get_record("course", "id", $exercise->course)) {
-        print_error("Course is misconfigured");
-    }
-    if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        print_error("Course Module ID was incorrect");
-    }
-
-    echo "<div align=\"center\">";
-    echo "<form enctype=\"multipart/form-data\" method=\"post\" action=\"upload.php\">";
-    echo " <input type=\"hidden\" name=\"id\" value=\"$cm->id\" />";
-    require_once($CFG->dirroot.'/lib/uploadlib.php');
-    upload_print_form_fragment(1,array('newfile'),null,true,array('title'),$course->maxbytes,$exercise->maxbytes,false);
-    echo " <input type=\"submit\" name=\"save\" value=\"".get_string("uploadthisfile")."\" />";
-    echo " (".get_string("maximumupload").": ".display_size($exercise->maxbytes).")\n"; 
-    echo "</form>";
-    echo "</div>";
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_print_user_assessments($exercise, $user) {
-    // Returns the number of assessments and a hyperlinked list of grading grades for the assessments made by this user
-
-    if ($assessments = exercise_get_user_assessments($exercise, $user)) {
-        $n = count($assessments);
-        $str = "$n  (";
-        foreach ($assessments as $assessment) {
-            if ($assessment->timegraded) {
-                $gradingscaled = round($assessment->gradinggrade * $exercise->gradinggrade / 100.0);
-                $str .= "<a href=\"assessments.php?action=viewassessment&amp;a=$exercise->id&amp;aid=$assessment->id\">";
-                $str .= "$gradingscaled</a> ";
-                }
-            else {
-                $str .= "<a href=\"assessments.php?action=viewassessment&amp;a=$exercise->id&amp;aid=$assessment->id\">";
-                $str .= "-</a> ";
-                }
-            }
-        $str .= ")";
-        }
-    else {
-        $str ="0";
-        }
-    return $str;
-    }
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_test_for_resubmission($exercise, $user) {
-    // see if any of the user's submissions have the resubmit flag set
-    $result = false;
-    if ($submissions = exercise_get_user_submissions($exercise, $user)) {
-        foreach ($submissions as $submission) {
-            if ($submission->resubmit) {
-                $result =true;
-                break;
-                }
-            }
-        }
-    return $result;
-    }
-    
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_test_user_assessments($exercise, $user) {
-    // see if user has assessed one of  teacher's exercises/submissions...
-    global $CFG;
-    
-    $result = false;
-    $timenow =time();
-    if ($submissions = exercise_get_teacher_submissions($exercise)) {
-        foreach ($submissions as $submission) {
-            if ($assessment = exercise_get_submission_assessment($submission, $user)) {
-                // ...the date stamp on the assessment should be in the past 
-                if ($assessment->timecreated < $timenow) {
-                    $result = true;
-                    break;
-                    }
-                }
-            }
-        }
-    return $result;
-    }
-
-?>
diff --git a/mod/exercise/mod_form.php b/mod/exercise/mod_form.php
deleted file mode 100644 (file)
index 10adcf7..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-<?php
-require_once ($CFG->dirroot.'/course/moodleform_mod.php');
-
-class mod_exercise_mod_form extends moodleform_mod {
-
-    function definition() {
-
-        global $CFG, $COURSE, $EXERCISE_TYPE, $EXERCISE_ASSESSMENT_COMPS;
-        $mform    =& $this->_form;
-
-//-------------------------------------------------------------------------------
-        $mform->addElement('header', 'general', get_string('general', 'form'));
-
-        $mform->addElement('text', 'name', get_string('title', 'exercise'), array('size'=>'64'));
-        $mform->setType('name', PARAM_TEXT);
-        $mform->addRule('name', null, 'required', null, 'client');
-
-        $mform->addElement('static', 'description', get_string('description', 'exercise'), get_string('descriptionofexercise', 'exercise', $COURSE->students));
-
-        $filesize = array();
-        $sizelist = array('10Kb', '50Kb', '100Kb', '500Kb', '1Mb', '2Mb', '5Mb', '10Mb', '20Mb', '50Mb');
-        $maxsize = get_max_upload_file_size();
-        foreach ($sizelist as $size) {
-            $sizebytes = get_real_size($size);
-            if ($sizebytes < $maxsize) {
-                $filesize[$sizebytes] = $size;
-            }
-        }
-        $filesize[$maxsize] = display_size($maxsize);
-        ksort($filesize, SORT_NUMERIC);
-        $mform->addElement('select', 'maxbytes', get_string('maximumsize', 'exercise'), $filesize);
-        $mform->setHelpButton('maxbytes', array('comparisonofassessments', get_string('comparisonofassessments', 'exercise'), 'exercise'));
-        $mform->setDefault('maxbytes', get_real_size('500K'));
-
-        $mform->addElement('date_time_selector', 'deadline', get_string('deadline', 'exercise'));
-
-        $numbers = array();
-        $numbers[22] = 'All';
-        $numbers[21] = 50;
-        for ($i=20; $i>=0; $i--) {
-            $numbers[$i] = $i;
-        }
-//-------------------------------------------------------------------------------
-        $mform->addElement('header', 'leaguetablehdr', get_string('leaguetable', 'exercise'));
-        $mform->addElement('select', 'showleaguetable', get_string('numberofentriesinleaguetable', 'exercise'), $numbers);
-        $mform->setHelpButton('showleaguetable', array('leaguetable', get_string('numberofentriesinleaguetable', 'exercise'), 'exercise'));
-
-        $mform->addElement('selectyesno', 'anonymous', get_string('hidenamesfromstudents', 'exercise', $COURSE->students), $numbers);
-        $mform->setHelpButton('anonymous', array('leaguetablenames', get_string('hidenamesfromstudents', 'exercise', $COURSE->students), 'exercise'));
-
-//-------------------------------------------------------------------------------
-        $mform->addElement('header', 'gradeshdr', get_string('grades'));
-        $grades = array();
-        for ($i=100; $i>=0; $i--) {
-            $grades[$i] = $i;
-        }
-        $mform->addElement('select', 'gradinggrade', get_string('gradeforstudentsassessment', 'exercise', $COURSE->student), $grades);
-        $mform->setHelpButton('gradinggrade', array('gradinggrade', get_string('gradinggrade', 'exercise'), 'exercise'));
-        $mform->setDefault('gradinggrade', 100);
-
-        $mform->addElement('select', 'grade', get_string('gradeforsubmission', 'exercise'), $grades);
-        $mform->setHelpButton('grade', array('grade', get_string('gradeforsubmission', 'exercise'), 'exercise'));
-        $mform->setDefault('grade', 100);
-
-        $mform->addElement('select', 'gradingstrategy', get_string('gradingstrategy', 'exercise'), $EXERCISE_TYPE);
-        $mform->setHelpButton('gradingstrategy', array('gradingstrategy', get_string('gradingstrategy', 'exercise'), 'exercise'));
-        $mform->setDefault('gradingstrategy', 1);
-
-        $options= array(get_string('usemean', 'exercise'), get_string('usemaximum', 'exercise'));
-        $mform->addElement('select', 'usemaximum', get_string('handlingofmultiplesubmissions', 'exercise'), $options);
-        $mform->setHelpButton('usemaximum', array('usemax', get_string('handlingofmultiplesubmissions', 'exercise'), 'exercise'));
-        $mform->setDefault('usemaximum', 0);
-
-        $options= array();
-        for ($i=20; $i>=0; $i--) {
-            $options[$i] = $i;
-        }
-        $mform->addElement('select', 'nelements', get_string('numberofassessmentelements', 'exercise'), $options);
-        $mform->setHelpButton('nelements', array('nelements', get_string('numberofassessmentelements', 'exercise'), 'exercise'));
-        $mform->setDefault('nelements', 1);
-
-        $COMPARISONS=array();
-        foreach ($EXERCISE_ASSESSMENT_COMPS as $KEY => $COMPARISON) {
-            $COMPARISONS[] = $COMPARISON['name'];
-        }
-        $mform->addElement('select', 'assessmentcomps', get_string('comparisonofassessments', 'exercise'), $options);
-        $mform->setHelpButton('assessmentcomps', array('comparisonofassessments', get_string('comparisonofassessments', 'exercise'), 'exercise'));
-        $mform->setDefault('assessmentcomps', 2);
-
-//-------------------------------------------------------------------------------
-        $mform->addElement('header', 'passwordhdr', get_string('password'));
-        $mform->addElement('selectyesno', 'usepassword', get_string('usepassword', 'exercise'));
-        $mform->setHelpButton('usepassword', array('usepassword', get_string('usepassword', 'exercise'), 'exercise'));
-        $mform->setDefault('usepassword', 0);
-
-        $mform->addElement('text', 'password', get_string('password'));
-        $mform->setHelpButton('password', array('usepassword', get_string('usepassword', 'exercise'), 'exercise'));
-        $mform->setType('password', PARAM_RAW);
-
-//-------------------------------------------------------------------------------
-        $this->standard_coursemodule_elements();
-//-------------------------------------------------------------------------------
-// buttons
-        $this->add_action_buttons();
-    }
-
-
-
-}
-?>
diff --git a/mod/exercise/restorelib.php b/mod/exercise/restorelib.php
deleted file mode 100644 (file)
index c9430af..0000000
+++ /dev/null
@@ -1,452 +0,0 @@
-<?php //$Id$
-    //This php script contains all the stuff to backup/restore
-    //exercise mods
-
-    //This is the "graphical" structure of the exercise mod: 
-    //
-    //                                          exercise
-    //                                         (CL,pk->id)             
-    //                                             |
-    //                                             |
-    //                                             |
-    //              |------------------------------|---------------------------------------------|
-    //              |                                                                            |
-    //              |                                                                            |
-    //              |                                                                   exercise_submissions
-    //              |                                                        (UL,pk->id,fk->exerciseid,files)
-    //              |                                                                            |
-    //              |                                                                            |
-    //              |                                                                            |
-    //              |        |---------------------|      |------------------------------|       |
-    //              |        |                     |      |                              |       |
-    //        exercise_elements                 exercise_grades                    exercise_assessments
-    //    (CL,pk->id,fk->exerciseid)      (UL,pk->id,fk->assessmentid)         (UL,pk->id,fk->submissionid)
-    //              |                     (          fk->elementno   )  
-    //              |                                                        
-    //              |                                                        
-    //          exercise_rubrics             
-    //    (CL,pk->id,fk->elementno)          
-    //
-    // Meaning: pk->primary key field of the table
-    //          fk->foreign key to link with parent
-    //          nt->nested field (recursive data)
-    //          CL->course level info
-    //          UL->user level info
-    //          files->table may have files)
-    //
-    //-----------------------------------------------------------
-
-    //This function executes all the restore procedure about this mod
-    function exercise_restore_mods($mod,$restore) {
-
-        global $CFG;
-
-        $status = true;
-
-        //Get record from backup_ids
-        $data = backup_getid($restore->backup_unique_code,$mod->modtype,$mod->id);
-
-        if ($data) {
-            //Now get completed xmlized object
-            $info = $data->info;
-            // if necessary, write to restorelog and adjust date/time fields
-            if ($restore->course_startdateoffset) {
-                restore_log_date_changes('Exercise', $restore, $info['MOD']['#'], array('DEADLINE'));
-            }
-            //traverse_xmlize($info);                                                              //Debug
-            //print_object ($GLOBALS['traverse_array']);                                           //Debug
-            //$GLOBALS['traverse_array']="";                                                       //Debug
-
-            //Now, build the exercise record structure
-            $exercise->course = $restore->course_id;
-            $exercise->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
-            $exercise->nelements = backup_todb($info['MOD']['#']['NELEMENTS']['0']['#']);
-            $exercise->phase = backup_todb($info['MOD']['#']['PHASE']['0']['#']);
-            $exercise->gradingstrategy = backup_todb($info['MOD']['#']['GRADINGSTRATEGY']['0']['#']);
-            $exercise->usemaximum = backup_todb($info['MOD']['#']['USEMAXIMUM']['0']['#']);
-            $exercise->assessmentcomps = backup_todb($info['MOD']['#']['ASSESSMENTCOMPS']['0']['#']);
-            $exercise->anonymous = backup_todb($info['MOD']['#']['ANONYMOUS']['0']['#']);
-            $exercise->maxbytes = backup_todb($info['MOD']['#']['MAXBYTES']['0']['#']); 
-            $exercise->deadline = backup_todb($info['MOD']['#']['DEADLINE']['0']['#']);
-            $date = usergetdate($exercise->deadline);
-            fwrite ($restorelog_file,"<br/>The Exercise - ".$exercise->name." <br/>");
-            fwrite ($restorelog_file,"The DEADLINE was  " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");            
-            $exercise->deadline += $restore->course_startdateoffset;
-            $date = usergetdate($exercise->deadline);
-            fwrite ($restorelog_file,"&nbsp;&nbsp;&nbsp;the DEADLINE is now  " .$date['weekday'].",  ".$date['mday']." ".$date['month']." ".$date['year']."<br/>");         
-            $exercise->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
-            $exercise->grade = backup_todb($info['MOD']['#']['GRADE']['0']['#']);
-            $exercise->gradinggrade = backup_todb($info['MOD']['#']['GRADINGGRADE']['0']['#']);
-            $exercise->showleaguetable = backup_todb($info['MOD']['#']['SHOWLEAGUETABLE']['0']['#']);
-            $exercise->usepassword = backup_todb($info['MOD']['#']['USEPASSWORD']['0']['#']);
-            $exercise->password = backup_todb($info['MOD']['#']['PASSWORD']['0']['#']);
-
-            //The structure is equal to the db, so insert the exercise
-            $newid = insert_record ("exercise",$exercise);
-
-            //Do some output     
-            if (!defined('RESTORE_SILENTLY')) {
-                echo "<li>".get_string("modulename","exercise")." \"".format_string(stripslashes($exercise->name),true)."\"</li>";
-            }
-            backup_flush(300);
-
-            if ($newid) {
-                //We have the newid, update backup_ids
-                backup_putid($restore->backup_unique_code,$mod->modtype,
-                             $mod->id, $newid);
-                //We have to restore the exercise_elements table now (course level table)
-                $status = exercise_elements_restore($newid,$info,$restore);
-                //restore the teacher submissions and optionally the student submissions
-                $status = exercise_submissions_restore($mod->id, $newid,$info,$restore);
-            } else {
-                $status = false;
-            }
-        } else {
-            $status = false;
-        }
-
-        return $status;
-    }
-
-    //This function restores the exercise_elements
-    function exercise_elements_restore($exercise_id,$info,$restore) {
-
-        global $CFG;
-
-        $status = true;
-
-        //Get the exercise_elements array
-        $elements = $info['MOD']['#']['ELEMENTS']['0']['#']['ELEMENT'];
-
-        //Iterate over exercise_elements
-        for($i = 0; $i < sizeof($elements); $i++) {
-            $ele_info = $elements[$i];
-            //traverse_xmlize($ele_info);                                                          //Debug
-            //print_object ($GLOBALS['traverse_array']);                                           //Debug
-            //$GLOBALS['traverse_array']="";                                                       //Debug
-
-            //Now, build the exercise_ELEMENTS record structure
-            $element->exerciseid = $exercise_id;
-            $element->elementno = backup_todb($ele_info['#']['ELEMENTNO']['0']['#']);
-            $element->description = backup_todb($ele_info['#']['DESCRIPTION']['0']['#']);
-            $element->scale = backup_todb($ele_info['#']['SCALE']['0']['#']);
-            $element->maxscore = backup_todb($ele_info['#']['MAXSCORE']['0']['#']);
-            $element->weight = backup_todb($ele_info['#']['WEIGHT']['0']['#']);
-
-            //The structure is equal to the db, so insert the exercise_elements
-            $newid = insert_record ("exercise_elements",$element);
-
-            //Do some output
-            if (($i+1) % 10 == 0) {
-                if (!defined('RESTORE_SILENTLY')) {
-                    echo ".";
-                    if (($i+1) % 200 == 0) {
-                        echo "<br />";
-                    }
-                }
-                backup_flush(300);
-            }
-
-            if ($newid) {
-                //We have to restore the exercise_rubrics table now (course level table)
-                $status = exercise_rubrics_restore($exercise_id,$element->elementno,$ele_info,$restore);
-            } else {
-                $status = false;
-            }
-        }
-
-        return $status;
-    }
-
-
-    //This function restores the exercise_rubrics
-    function exercise_rubrics_restore($exercise_id,$elementno,$info,$restore) {
-
-        global $CFG;
-
-        $status = true;
-
-        //Get the exercise_rubrics array (optional)
-        if (isset($info['#']['RUBRICS']['0']['#']['RUBRIC'])) {
-            $rubrics = $info['#']['RUBRICS']['0']['#']['RUBRIC'];
-
-            //Iterate over exercise_rubrics
-            for($i = 0; $i < sizeof($rubrics); $i++) {
-                $rub_info = $rubrics[$i];
-                //traverse_xmlize($rub_info);                                  //Debug
-                //print_object ($GLOBALS['traverse_array']);                   //Debug
-                //$GLOBALS['traverse_array']="";                               //Debug
-
-                //Now, build the exercise_RUBRICS record structure
-                $rubric->exerciseid = $exercise_id;
-                $rubric->elementno = $elementno;
-                $rubric->rubricno = backup_todb($rub_info['#']['RUBRICNO']['0']['#']);
-                $rubric->description = backup_todb($rub_info['#']['DESCRIPTION']['0']['#']);
-
-                //The structure is equal to the db, so insert the exercise_rubrics
-                $newid = insert_record ("exercise_rubrics",$rubric);
-
-                //Do some output
-                if (($i+1) % 10 == 0) {
-                    if (!defined('RESTORE_SILENTLY')) {
-                        echo ".";
-                        if (($i+1) % 200 == 0) {
-                            echo "<br />";
-                        }
-                    }
-                    backup_flush(300);
-                }
-
-                if (!$newid) {
-                    $status = false;
-                }
-            }
-        }
-        return $status;
-    }
-
-
-    //This function restores the submissions
-    function exercise_submissions_restore($old_exercise_id, $new_exercise_id,$info,$restore) {
-
-        global $CFG;
-
-        $status = true;
-
-        //Get the submissions array (teacher submissions)
-        $submissions = $info['MOD']['#']['SUBMISSIONS']['0']['#']['SUBMISSION'];
-        //Iterate over submissions
-        for($i = 0; $i < sizeof($submissions); $i++) {
-            $sub_info = $submissions[$i];
-            //traverse_xmlize($sub_info);                                                         //Debug
-            //print_object ($GLOBALS['traverse_array']);                                          //Debug
-            //$GLOBALS['traverse_array']="";                                                      //Debug
-
-            //We'll need this later!!
-            $oldid = backup_todb($sub_info['#']['ID']['0']['#']);
-            $olduserid = backup_todb($sub_info['#']['USERID']['0']['#']);
-
-            //Now, build the exercise_SUBMISSIONS record structure
-            $submission->exerciseid = $new_exercise_id;
-            $submission->userid = backup_todb($sub_info['#']['USERID']['0']['#']);
-            $submission->title = backup_todb($sub_info['#']['TITLE']['0']['#']);
-            $submission->timecreated = backup_todb($sub_info['#']['TIMECREATED']['0']['#']);
-            $submission->resubmit = backup_todb($sub_info['#']['RESUBMIT']['0']['#']);
-            $submission->mailed = backup_todb($sub_info['#']['MAILED']['0']['#']);
-            $submission->isexercise = backup_todb($sub_info['#']['ISEXERCISE']['0']['#']);
-            $submission->late = backup_todb($sub_info['#']['LATE']['0']['#']);
-
-            // always save the exercise descriptions and optionally the student submissions
-            if ($submission->isexercise or restore_userdata_selected($restore,'exercise',$old_exercise_id)) {
-                //We have to recode the userid field
-                $user = backup_getid($restore->backup_unique_code,"user",$olduserid);
-                if ($user) {
-                    $submission->userid = $user->new_id;
-                }
-
-                //The structure is equal to the db, so insert the exercise_submission
-                $newid = insert_record ("exercise_submissions",$submission);
-
-                //Do some output
-                if (($i+1) % 50 == 0) {
-                    if (!defined('RESTORE_SILENTLY')) {
-                        echo ".";
-                        if (($i+1) % 1000 == 0) {
-                            echo "<br />";
-                        }
-                    }
-                    backup_flush(300);
-                }
-
-                if ($newid) {
-                    //We have the newid, update backup_ids
-                    backup_putid($restore->backup_unique_code,"exercise_submissions",$oldid,
-                            $newid);
-
-                    //Now copy moddata associated files
-                    $status = exercise_restore_files($oldid, $newid,$restore); 
-                    //Now we need to restore exercise_assessments (user level table)
-                    if ($status and restore_userdata_selected($restore,'exercise',$old_exercise_id)) {
-                        $status = exercise_assessments_restore($new_exercise_id, $newid,$sub_info,$restore);
-                    }
-                } else {
-                    $status = false;
-                }
-            }
-        }
-
-    return $status;
-    }
-
-    //This function restores the exercise_assessments       
-    function exercise_assessments_restore($new_exercise_id, $new_submission_id,$info,$restore) {
-
-        global $CFG;
-
-        $status = true;
-
-        //Get the assessments array (optional)
-        if (isset($info['#']['ASSESSMENTS']['0']['#']['ASSESSMENT'])) {
-            $assessments = $info['#']['ASSESSMENTS']['0']['#']['ASSESSMENT'];
-
-            //Iterate over assessments
-            for($i = 0; $i < sizeof($assessments); $i++) {
-                $ass_info = $assessments[$i];
-                //traverse_xmlize($ass_info);                                                         //Debug
-                //print_object ($GLOBALS['traverse_array']);                                          //Debug
-                //$GLOBALS['traverse_array']="";                                                      //Debug
-
-                //We'll need this later!!
-                $oldid = backup_todb($ass_info['#']['ID']['0']['#']);
-                $olduserid = backup_todb($ass_info['#']['USERID']['0']['#']);
-
-                //Now, build the exercise_ASSESSMENTS record structure
-                $assessment->exerciseid = $new_exercise_id;
-                $assessment->submissionid = $new_submission_id;
-                $assessment->userid = backup_todb($ass_info['#']['USERID']['0']['#']);
-                $assessment->timecreated = backup_todb($ass_info['#']['TIMECREATED']['0']['#']);
-                $assessment->timegraded = backup_todb($ass_info['#']['TIMEGRADED']['0']['#']);
-                $assessment->grade = backup_todb($ass_info['#']['GRADE']['0']['#']);
-                $assessment->gradinggrade = backup_todb($ass_info['#']['GRADINGGRADE']['0']['#']);
-                $assessment->mailed = backup_todb($ass_info['#']['MAILED']['0']['#']);
-                $assessment->generalcomment = backup_todb($ass_info['#']['GENERALCOMMENT']['0']['#']);
-                $assessment->teachercomment = backup_todb($ass_info['#']['TEACHERCOMMENT']['0']['#']);
-
-                //We have to recode the userid field
-                $user = backup_getid($restore->backup_unique_code,"user",$olduserid);
-                if ($user) {
-                    $assessment->userid = $user->new_id;
-                }
-
-                //The structure is equal to the db, so insert the exercise_assessment
-                $newid = insert_record ("exercise_assessments",$assessment);
-
-                //Do some output
-                if (($i+1) % 50 == 0) {
-                    if (!defined('RESTORE_SILENTLY')) {
-                        echo ".";
-                        if (($i+1) % 1000 == 0) {
-                            echo "<br />";
-                        }
-                    }
-                    backup_flush(300);
-                }
-
-                if ($newid) {
-                    //We have the newid, update backup_ids
-                    backup_putid($restore->backup_unique_code,"exercise_assessments",$oldid,
-                            $newid);
-
-                    //Now we need to restore exercise_grades (user level table)   
-                    if ($status) {
-                        $status = exercise_grades_restore_mods ($new_exercise_id, $newid,$ass_info,$restore);   
-                    }
-                } else {
-                    $status = false;
-                }
-            }
-        }
-
-        return $status;
-    }
-
-    //This function restores the exercise_grades
-    function exercise_grades_restore_mods($new_exercise_id, $new_assessment_id,$info,$restore) {
-
-        global $CFG;
-
-        $status = true;
-
-        //Get the grades array (optional)
-        if (isset($info['#']['GRADES']['0']['#']['GRADE'])) {
-            $grades = $info['#']['GRADES']['0']['#']['GRADE'];
-
-            //Iterate over grades
-            for($i = 0; $i < sizeof($grades); $i++) {
-                $gra_info = $grades[$i];
-                //traverse_xmlize($gra_info);                           //Debug
-                //print_object ($GLOBALS['traverse_array']);            //Debug
-                //$GLOBALS['traverse_array']="";                        //Debug
-
-                //Now, build the exercise_GRADES record structure
-                $grade->exerciseid = $new_exercise_id;
-                $grade->assessmentid = $new_assessment_id;
-                $grade->elementno = backup_todb($gra_info['#']['ELEMENTNO']['0']['#']);
-                $grade->feedback = backup_todb($gra_info['#']['FEEDBACK']['0']['#']);
-                $grade->grade = backup_todb($gra_info['#']['GRADE_VALUE']['0']['#']);
-
-                //The structure is equal to the db, so insert the exercise_grade
-                $newid = insert_record ("exercise_grades",$grade);
-
-                //Do some output
-                if (($i+1) % 50 == 0) {
-                    if (!defined('RESTORE_SILENTLY')) {
-                        echo ".";
-                        if (($i+1) % 1000 == 0) {
-                            echo "<br />";
-                        }
-                    }
-                    backup_flush(300);
-                }
-
-                if (!$newid) {
-                    $status = false;
-                }
-            }
-        }
-
-        return $status;
-    }
-
-    //This function copies the exercise related info from backup temp dir to course moddata folder,
-    //creating it if needed and recoding everything (submission_id) 
-    function exercise_restore_files ($oldsubmiss, $newsubmiss, $restore) {
-
-        global $CFG;
-
-        $status = true;
-        $todo = false;
-        $moddata_path = "";
-        $exercise_path = "";
-        $temp_path = "";
-
-        //First, we check to "course_id" exists and create is as necessary
-        //in CFG->dataroot
-        $dest_dir = $CFG->dataroot."/".$restore->course_id;
-        $status = check_dir_exists($dest_dir,true);
-
-        //Now, locate course's moddata directory
-        $moddata_path = $CFG->dataroot."/".$restore->course_id."/".$CFG->moddata;
-   
-        //Check it exists and create it
-        $status = check_dir_exists($moddata_path,true);
-
-        //Now, locate exercise directory
-        if ($status) {
-            $exercise_path = $moddata_path."/exercise";
-            //Check it exists and create it
-            $status = check_dir_exists($exercise_path,true);
-        }
-
-        //Now locate the temp dir we are gong to restore
-        if ($status) {
-            $temp_path = $CFG->dataroot."/temp/backup/".$restore->backup_unique_code.
-                         "/moddata/exercise/".$oldsubmiss;
-            //Check it exists
-            if (is_dir($temp_path)) {
-                $todo = true;
-            }
-        }
-
-        //If todo, we create the neccesary dirs in course moddata/exercise
-        if ($status and $todo) {
-            //First this exercise id
-            $this_exercise_path = $exercise_path."/".$newsubmiss;
-            $status = check_dir_exists($this_exercise_path,true);
-            //And now, copy temp_path to this_exercise_path
-            $status = backup_copy_file($temp_path, $this_exercise_path); 
-        }
-       
-        return $status;
-    }
-?>
diff --git a/mod/exercise/submissions.php b/mod/exercise/submissions.php
deleted file mode 100644 (file)
index e3aa4c7..0000000
+++ /dev/null
@@ -1,432 +0,0 @@
-<?php  // $Id$
-
-/*************************************************
-    ACTIONS handled are:
-
-    adminamendtitle
-    adminclearlate
-    adminconfirmdelete
-    admindelete
-    adminlateflag
-    adminlist
-    displayfinalgrades (teachers only)
-    listforassessmentstudent
-    listforassessmentteacher
-    saveweights
-    userconfirmdelete
-    userdelete
-
-
-************************************************/
-
-    require_once("../../config.php");
-    require_once("lib.php");
-    require_once("locallib.php");
-    require_once("version.php");
-
-    $id     = required_param('id', PARAM_INT); // Course Module ID
-    $action = required_param('action', PARAM_ALPHA);
-    $aid    = optional_param('aid', 0, PARAM_INT);
-    $sid    = optional_param('sid', 0, PARAM_INT);
-    $title  = optional_param('title', '', PARAM_CLEAN);
-
-    // get some essential stuff...
-    if (! $cm = get_coursemodule_from_id('exercise', $id)) {
-        print_error("Course Module ID was incorrect");
-    }
-
-    if (! $course = get_record("course", "id", $cm->course)) {
-        print_error("Course is misconfigured");
-    }
-
-    if (! $exercise = get_record("exercise", "id", $cm->instance)) {
-        print_error("Course module is incorrect");
-    }
-
-    require_login($course->id, false, $cm);
-
-    $strexercises = get_string("modulenameplural", "exercise");
-    $strexercise  = get_string("modulename", "exercise");
-    $strsubmissions = get_string("submissions", "exercise");
-
-    // ... print the header and...
-    $navigation = build_navigation($strsubmissions, $cm);
-    print_header_simple(format_string($exercise->name), "", $navigation,
-                  "", "", true);
-
-
-    /******************* admin amend title ************************************/
-    if ($action == 'adminamendtitle' ) {
-
-        if (!isteacher($course->id)) {
-            print_error("Only teachers can look at this page");
-        }
-        if (empty($sid)) {
-            print_error("Admin Amend Title: submission id missing");
-        }
-
-        $submission = get_record("exercise_submissions", "id", $sid);
-        print_heading(get_string("amendtitle", "exercise"));
-        ?>
-        <form id="amendtitleform" action="submissions.php" method="post">
-        <input type="hidden" name="action" value="adminupdatetitle" />
-        <input type="hidden" name="id" value="<?php echo $cm->id ?>" />
-        <input type="hidden" name="sid" value="<?php echo $sid ?>" />
-        <center>
-        <table celpadding="5" border="1">
-        <?php
-
-        // now get the comment
-        echo "<tr valign=\"top\">\n";
-        echo "    <td align=\"right\"><p><b>". get_string("title", "exercise").":</b></p></td>\n";
-        echo "    <td>\n";
-        echo "        <input type=\"text\" name=\"title\" size=\"60\" maxlength=\"100\" value=\"$submission->title\" />\n";
-        echo "    </td></tr></table>\n";
-        echo "<input type=\"submit\" value=\"".get_string("amendtitle", "exercise")."\" />\n";
-        echo "</center></form>\n";
-
-        }
-
-
-    /******************* admin clear late (flag) ************************************/
-    elseif ($action == 'adminclearlate' ) {
-
-        if (!isteacher($course->id)) {
-            print_error("Only teachers can look at this page");
-        }
-        if (empty($sid)) {
-            print_error("Admin clear late flag: submission id missing");
-        }
-
-        if (!$submission = get_record("exercise_submissions", "id", $sid)) {
-            print_error("Admin clear late flag: can not get submission record");
-        }
-        if (set_field("exercise_submissions", "late", 0, "id", $sid)) {
-            print_heading(get_string("clearlateflag", "exercise")." ".get_string("ok"));
-        }
-
-        add_to_log($course->id, "exercise", "late flag cleared", "view.php?id=$cm->id", "submission $submission->id");
-
-        redirect("submissions.php?id=$cm->id&amp;action=adminlist");
-    }
-
-
-    /******************* admin confirm delete ************************************/
-    elseif ($action == 'adminconfirmdelete' ) {
-
-        if (!isteacher($course->id)) {
-            print_error("Only teachers can look at this page");
-        }
-        if (empty($sid)) {
-            print_error("Admin confirm delete: submission id missing");
-        }
-        if (!$submission = get_record("exercise_submissions", "id", $sid)) {
-            print_error("Admin delete: can not get submission record");
-        }
-
-        if (isteacher($course->id, $submission->userid)) {
-            if (!isteacheredit($course->id)) {
-                print_error("Only teacher with editing permissions can delete teacher submissions.");
-            }
-            if ($assessments = exercise_get_assessments($submission)) {
-                echo "<p align=\"center\">".get_string("deletesubmissionwarning", "exercise", count($assessments)).
-                    "</p>\n";
-            }
-        }
-        notice_yesno(get_string("confirmdeletionofthisitem","exercise", get_string("submission", "exercise")),
-             "submissions.php?action=admindelete&amp;id=$cm->id&amp;sid=$sid", "submissions.php?id=$cm->id&amp;action=adminlist");
-        }
-
-
-    /******************* admin delete ************************************/
-    elseif ($action == 'admindelete' ) {
-
-        if (!isteacher($course->id)) {
-            print_error("Only teachers can look at this page");
-            }
-        if (empty($sid)) {
-            print_error("Admin delete: submission id missing");
-            }
-
-        if (!$submission = get_record("exercise_submissions", "id", $sid)) {
-            print_error("Admin delete: can not get submission record");
-            }
-        print_string("deleting", "exercise");
-        // first get any assessments...
-        if ($assessments = exercise_get_assessments($submission)) {
-            foreach($assessments as $assessment) {
-                // ...and all the associated records...
-                delete_records("exercise_grades", "assessmentid", $assessment->id);
-                echo ".";
-                }
-            // ...now delete the assessments...
-            delete_records("exercise_assessments", "submissionid", $submission->id);
-            }
-        // ...and the submission record...
-        delete_records("exercise_submissions", "id", $submission->id);
-        // ..and finally the submitted file
-        exercise_delete_submitted_files($exercise, $submission);
-        add_to_log($course->id, "exercise", "delete", "view.php?id=$cm->id", "submission $submission->id");
-
-        print_continue("submissions.php?id=$cm->id&amp;action=adminlist");
-        }
-
-
-    /******************* admin (confirm) late flag ************************************/
-    elseif ($action == 'adminlateflag' ) {
-
-        if (!isteacher($course->id)) {
-            print_error("Only teachers can look at this page");
-            }
-        if (empty($sid)) {
-            print_error("Admin confirm late flag: submission id missing");
-            }
-        if (!$submission = get_record("exercise_submissions", "id", $sid)) {
-            print_error("Admin confirm late flag: can not get submission record");
-            }
-
-        notice_yesno(get_string("clearlateflag","exercise")."?",
-             "submissions.php?action=adminclearlate&amp;id=$cm->id&amp;sid=$sid",
-             "submissions.php?id=$cm->id&amp;action=adminlist");
-        }
-
-
-    /******************* list all submissions ************************************/
-    elseif ($action == 'adminlist' ) {
-
-        if (!isteacher($course->id)) {
-            print_error("Only teachers can look at this page");
-        }
-
-        echo "<p><small>Exercise Version-> $module->version</small></p>";
-        exercise_list_submissions_for_admin($exercise);
-        print_continue("view.php?id=$cm->id");
-
-    }
-
-
-    /******************* admin update title ************************************/
-    elseif ($action == 'adminupdatetitle' ) {
-
-        if (!isteacher($course->id)) {
-            print_error("Only teachers can look at this page");
-            }
-        if (empty($sid)) {
-            print_error("Admin Update Title: submission id missing");
-            }
-
-        if (set_field("exercise_submissions", "title", $title, "id", $sid)) {
-            print_heading(get_string("amendtitle", "exercise")." ".get_string("ok"));
-            }
-        redirect("submissions.php?id=$cm->id&amp;action=adminlist");
-        }
-
-
-    /*************** display final grades (by teacher) ***************************/
-    elseif ($action == 'displayfinalgrades') {
-        $groupid = get_current_group($course->id);
-        // Get all the students
-        if (!$users = get_course_students($course->id, "u.lastname, u.firstname")) {
-            print_heading(get_string("nostudentsyet"));
-            print_footer($course);
-            exit;
-        }
-
-        // show the final grades as stored in the tables...
-        print_heading_with_help(get_string("displayoffinalgrades", "exercise"), "finalgrades", "exercise");
-        echo "<center><table border=\"1\" width=\"90%\"><tr>\n";
-        echo "<td><b>".$course->student."</b></td>";
-        echo "<td><b>".get_string("submission", "exercise")."</b></td>";
-        echo "<td align=\"center\"><b>".get_string("gradeforassessment", "exercise")."</b></td>";
-        echo "<td align=\"center\"><b>".get_string("gradeforsubmission", "exercise")."</b></td>";
-        echo "<td align=\"center\"><b>".get_string("overallgrade", "exercise")."</b></td></tr>\n";
-        // now the weights
-        echo "<tr><td><b>".get_string("maximumgrade")."</b></td>";
-        echo "<td><b>&nbsp;</b></td>\n";
-        echo "<td align=\"center\"><b>$exercise->gradinggrade</b></td>\n";
-        echo "<td align=\"center\"><b>$exercise->grade</b></td>\n";
-        echo "<td><b>&nbsp;</b></td></tr>\n";
-        foreach ($users as $user) {
-            // check group membership, if necessary
-            if ($groupid) {
-                // check user's group
-                if (!groups_is_member($groupid, $user->id)) {
-                    continue; // skip this user
-                }
-            }
-            // first get user's own assessment reord, it should contain their grading grade
-            if ($ownassessments = exercise_get_user_assessments($exercise, $user)) {
-                foreach ($ownassessments as $ownassessment) {
-                    break; // there should only be one
-                }
-            }
-            else {
-                $ownassessment->gradinggrade = 0;
-            }
-            if ($submissions = exercise_get_user_submissions($exercise, $user)) {
-                foreach ($submissions as $submission) {
-                    if ($assessments = exercise_get_assessments($submission)) {
-                        foreach ($assessments as $assessment) { // (normally there should only be one
-                            $gradinggrade = number_format($ownassessment->gradinggrade * $exercise->gradinggrade /
-                                    100.0, 1);
-                            $grade = number_format($assessment->grade * $exercise->grade / 100.0, 1);
-                            $overallgrade = number_format(($assessment->grade * $exercise->grade / 100.0) +
-                                ($ownassessment->gradinggrade * $exercise->gradinggrade / 100.0), 1);
-                            if ($submission->late) {
-                                $grade = "<font color=\"red\">(".$grade.")</font>";
-                                $overallgrade = "<font color=\"red\">(".$overallgrade.")</font>";
-                            }
-                            echo "<tr><td>".fullname($user)."</td>\n";
-                            echo "<td>".exercise_print_submission_title($exercise, $submission)."</td>\n";
-                            echo "<td align=\"center\">$gradinggrade</td>";
-                            echo "<td align=\"center\">$grade</td>";
-                            echo "<td align=\"center\">$overallgrade</td></tr>\n";
-                        }
-                    }
-                }
-            }
-        }
-        echo "</table><br clear=\"all\" />\n";
-        if ($exercise->showleaguetable) {
-            exercise_print_league_table($exercise);
-            echo "<br />\n";
-        }
-        echo get_string("maximumgrade").": $exercise->grade\n";
-        print_continue("view.php?id=$cm->id");
-    }
-
-
-    /******************* list for assessment student (submissions) ************************************/
-    elseif ($action == 'listforassessmentstudent' ) {
-        if (!$users = get_course_students($course->id)) {
-            print_heading(get_string("nostudentsyet"));
-            print_footer($course);
-            exit;
-            }
-        if (!isteacher($course->id)) {
-            print_error("Only teachers can look at this page");
-            }
-        exercise_list_unassessed_student_submissions($exercise, $USER);
-        print_continue("view.php?id=$cm->id");
-
-        }
-
-
-    /******************* list for assessment teacher (submissions) ************************************/
-    elseif ($action == 'listforassessmentteacher' ) {
-        if (!$users = get_course_students($course->id)) {
-            print_heading(get_string("nostudentsyet"));
-            print_footer($course);
-            exit;
-            }
-        exercise_list_unassessed_teacher_submissions($exercise, $USER);
-        print_continue("view.php?id=$cm->id");
-
-        }
-
-
-    /****************** save league table entries and anonimity setting (by teacher) **************/
-    elseif ($action == 'saveleaguetable') {
-
-        $form = (object)$_POST;
-
-        if (!isteacher($course->id)) {
-            print_error("Only teachers can look at this page");
-            }
-
-        // save the number of league table entries from the form...
-        if ($form->nentries == 'All') {
-            $nentries = 99;
-        } else {
-            $nentries = $form->nentries;
-        }
-        // ...and save it
-        set_field("exercise", "showleaguetable", $nentries, "id", "$exercise->id");
-
-        // ...and save the anonimity setting
-        set_field("exercise", "anonymous", $form->anonymous, "id", "$exercise->id");
-
-        redirect("submissions.php?id=$cm->id&amp;action=adminlist", get_string("entriessaved", "exercise"));
-        }
-
-        /*************** save weights (by teacher) ***************************/
-    elseif ($action == 'saveweights') {
-
-        $form = (object)$_POST;
-
-        if (!isteacher($course->id)) {
-            print_error("Only teachers can look at this page");
-            }
-
-        // save the weights from the form...
-        if (isset($form->teacherweight)) {
-            $teacherweight = $form->teacherweight;
-            // ...and save them
-            set_field("exercise", "teacherweight", $teacherweight, "id", "$exercise->id");
-            }
-
-        if (isset($form->gradingweight)) {
-            $gradingweight = $form->gradingweight;
-            // ...and save them
-            set_field("exercise", "gradingweight", $gradingweight, "id", "$exercise->id");
-            }
-
-        redirect("submissions.php?id=$cm->id&amp;action=adminlist", get_string("weightssaved", "exercise"));
-        }
-
-
-    /******************* user confirm delete ************************************/
-    elseif ($action == 'userconfirmdelete' ) {
-
-        if (empty($sid)) {
-            print_error("User Confirm Delete: submission id missing");
-            }
-
-        notice_yesno(get_string("confirmdeletionofthisitem","exercise", get_string("submission", "exercise")),
-             "submissions.php?action=userdelete&amp;id=$cm->id&amp;sid=$sid", "view.php?id=$cm->id");
-        }
-
-
-    /******************* user delete ************************************/
-    elseif ($action == 'userdelete' ) {
-
-        if (empty($sid)) {
-            print_error("User Delete: submission id missing");
-            }
-
-        if (!$submission = get_record("exercise_submissions", "id", $sid)) {
-            print_error("User Delete: can not get submission record");
-            }
-        print_string("deleting", "exercise");
-        // first get any assessments...
-        if ($assessments = exercise_get_assessments($submission)) {
-            foreach($assessments as $assessment) {
-                // ...and all the associated records...
-                delete_records("exercise_grades", "assessmentid", $assessment->id);
-                echo ".";
-                }
-            // ...now delete the assessments...
-            delete_records("exercise_assessments", "submissionid", $submission->id);
-            }
-        // ...and the submission record...
-        delete_records("exercise_submissions", "id", $submission->id);
-        // ..and finally the submitted file
-        exercise_delete_submitted_files($exercise, $submission);
-        add_to_log($course->id, "exercise", "delete", "view.php?id=$cm->id", "submission $submission->id");
-
-        print_continue("view.php?id=$cm->id");
-        }
-
-
-    /*************** no man's land **************************************/
-
-    else {
-
-        print_error("Fatal Error: Unknown Action: ".$action."\n");
-
-        }
-
-
-    print_footer($course);
-
-?>
diff --git a/mod/exercise/upload.php b/mod/exercise/upload.php
deleted file mode 100644 (file)
index d7ec94e..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-<?php  // $Id$
-
-    require_once("../../config.php");
-    require_once("lib.php");
-    require_once("locallib.php");
-
-    $id    = required_param('id', PARAM_INT);           // course module ID
-    $title = optional_param('title', '', PARAM_CLEAN);
-
-    $timenow = time();
-
-    // get some esential stuff...
-    if (! $cm = get_coursemodule_from_id('exercise', $id)) {
-        print_error("Course Module ID was incorrect");
-    }
-
-    if (! $course = get_record("course", "id", $cm->course)) {
-        print_error("Course is misconfigured");
-    }
-
-    if (! $exercise = get_record("exercise", "id", $cm->instance)) {
-        print_error("Course module is incorrect");
-    }
-
-    require_login($course->id, false, $cm);
-
-    $strexercises = get_string("modulenameplural", "exercise");
-    $strexercise  = get_string("modulename", "exercise");
-    $strupload      = get_string("upload");
-
-    $navigation = build_navigation($strupload, $cm);
-    print_header_simple(format_string($exercise->name)." : $strupload", "", $navigation,
-                  "", "", true);
-
-    // check that this is not a "rapid" second submission, caused by using the back button
-    // only check if a student, teachers may want to submit a set of exercise variants
-    if (isstudent($course->id)) {
-        if ($submissions = exercise_get_user_submissions($exercise, $USER)) {
-            // returns all submissions, newest on first
-            foreach ($submissions as $submission) {
-                if ($submission->timecreated > $timenow - $CFG->maxeditingtime) {
-                    // ignore this submission
-                    redirect("view.php?id=$cm->id");
-                    print_footer($course);
-                    exit();
-                }
-            }
-        }
-    }
-
-    // check existence of title
-    if ($title == '') {
-        notify(get_string("notitlegiven", "exercise") );
-    }
-    else {
-        require_once($CFG->dirroot.'/lib/uploadlib.php');
-        $um = new upload_manager('newfile',false,false,$course,false,$exercise->maxbytes);
-        if ($um->preprocess_files()) {
-            $newsubmission->exerciseid   = $exercise->id;
-            if (isteacher($course->id)) {
-                // it's an exercise submission, flag it as such
-                $newsubmission->userid         = 0;
-                $newsubmission->isexercise = 1;  // it's a description of an exercise
-            }
-            else {
-                $newsubmission->userid = $USER->id;
-            }
-            $newsubmission->title  = $title;
-            $newsubmission->timecreated  = $timenow;
-            if ($timenow > $exercise->deadline) {
-                $newsubmission->late = 1;
-            }
-            if (!$newsubmission->id = insert_record("exercise_submissions", $newsubmission)) {
-                print_error("exercise upload: Failure to create new submission record!");
-            }
-            $dir = exercise_file_area_name($exercise, $newsubmission);
-            if ($um->save_files($dir)) {
-                add_to_log($course->id, "exercise", "submit", "view.php?id=$cm->id", "$exercise->id");
-                print_heading(get_string("uploadsuccess", "assignment", $um->get_new_filename()) );
-            }
-            // upload manager will print errors.
-            // clear resubmit flags
-            if (!set_field("exercise_submissions", "resubmit", 0, "exerciseid", $exercise->id, "userid", $USER->id)) {
-                print_error("Exercise Upload: unable to reset resubmit flag");
-            }
-        }
-        // upload manager will print errors.
-    }
-    print_continue("view.php?id=$cm->id");
-
-    print_footer($course);
-
-?>
diff --git a/mod/exercise/version.php b/mod/exercise/version.php
deleted file mode 100644 (file)
index 59c6263..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php // $Id$
-
-////////////////////////////////////////////////////////////////////////////////
-//  Code fragment to define the module version etc.
-//  This fragment is called by /admin/index.php
-////////////////////////////////////////////////////////////////////////////////
-
-$module->version  = 2007110500;
-$module->requires = 2007101509;  // Requires this Moodle version
-$module->cron     = 60;
-
-?>
diff --git a/mod/exercise/view.php b/mod/exercise/view.php
deleted file mode 100644 (file)
index 5bad9a8..0000000
+++ /dev/null
@@ -1,412 +0,0 @@
-<?php  // $Id$
-
-/*************************************************
-    ACTIONS handled are:
-
-    displayfinalgrade (for students)
-    makeleaguetableavailable (for teachers)
-    notavailable (for students)
-    openexercise (for teachers)
-    setupassignment (for teachers)
-    showsubmissions (for students)
-    studentsview
-    submitassignment
-    teachersview
-
-************************************************/
-
-    require_once("../../config.php");
-    require_once("lib.php");
-    require_once("locallib.php");
-
-    $id          = required_param('id', PARAM_INT);    // Course Module ID
-    $action      = optional_param('action', '', PARAM_ALPHA);
-    $changegroup = optional_param('group', -1, PARAM_INT);
-
-    // get some esential stuff...
-    if (! $cm = get_coursemodule_from_id('exercise', $id)) {
-        print_error("Course Module ID was incorrect");
-    }
-
-    if (! $course = get_record("course", "id", $cm->course)) {
-        print_error("Course is misconfigured");
-    }
-
-    if (! $exercise = get_record("exercise", "id", $cm->instance)) {
-        print_error("Course module is incorrect");
-    }
-
-    require_login($course->id, false, $cm);
-
-    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
-    // ...log activity...
-    add_to_log($course->id, "exercise", "view", "view.php?id=$cm->id", $exercise->id, $cm->id);
-
-    $strexercises = get_string("modulenameplural", "exercise");
-    $strexercise  = get_string("modulename", "exercise");
-
-    // ...display header...
-    $navigation = build_navigation('', $cm);
-    
-    print_header_simple(format_string($exercise->name), "", $navigation,
-                  "", "", true, update_module_button($cm->id, $course->id, $strexercise), navmenu($course, $cm));
-
-    if (isteacher($course->id)) {
-        if (empty($action)) { // no action specified, either go straight to elements page else the admin page
-            // has the assignment any elements
-            if (count_records("exercise_elements", "exerciseid", $exercise->id)) {
-                $action = "teachersview";
-            }
-            else {
-                redirect("assessments.php?action=editelements&amp;id=$cm->id");
-            }
-        }
-    }
-    elseif (!isguest()) { // it's a student then
-        if (!$cm->visible) {
-            notice(get_string("activityiscurrentlyhidden"));
-        }
-        switch ($exercise->phase) {
-            case 0 :
-            case 1 : $action = 'notavailable'; break;
-            case 2 : $action = 'studentsview'; break;
-            case 3 : $action = 'displayfinalgrade';
-        }
-    }
-    else { // it's a guest, oh no!
-        $action = 'notavailable';
-    }
-
-
-    /****************** display final grade (for students) ************************************/
-    if ($action == 'displayfinalgrade' ) {
-
-        // show the final grades as stored in the tables...
-        print_heading(get_string("displayoffinalgrades", "exercise"));
-        if ($submissions = exercise_get_user_submissions($exercise, $USER)) { // any submissions from user?
-            echo "<center><table border=\"1\" width=\"90%\"><tr>";
-            echo "<td><b>".get_string("submissions", "exercise")."</b></td>";
-            echo "<td align=\"center\"><b>".get_string("gradeforassessment", "exercise")."</b></td>";
-            echo "<td align=\"center\"><b>".get_string("gradeforsubmission", "exercise", $course->teacher)."</b></td>";
-            echo "<td align=\"center\"><b>".get_string("overallgrade", "exercise")."</b></td></tr>\n";
-            // now the weights
-            echo "<tr><td><b>".get_string("maximumgrade")."</b></td>";
-            echo "<td align=\"center\"><b>$exercise->gradinggrade</b></td>\n";
-            echo "<td align=\"center\"><b>$exercise->grade</b></td>\n";
-            echo "<td><b>&nbsp;</b></td></tr>\n";
-            // first get user's own assessment reord, it should contain their grading grade
-            if ($ownassessments = exercise_get_user_assessments($exercise, $USER)) {
-                foreach ($ownassessments as $ownassessment) {
-                    break; // there should only be one
-                }
-            }
-            else {
-                $ownassessment->gradinggrade = 0;
-            }
-            foreach ($submissions as $submission) {
-                if ($assessments = exercise_get_assessments($submission)) {
-                    foreach ($assessments as $assessment) { // (normally there should only be one
-                        $gradinggrade = number_format($ownassessment->gradinggrade * $exercise->gradinggrade / 100.0,
-                                1);
-                        $grade = number_format($assessment->grade * $exercise->grade / 100.0, 1);
-                        $overallgrade = number_format(($assessment->grade * $exercise->grade / 100.0) +
-                            ($ownassessment->gradinggrade * $exercise->gradinggrade / 100.0 ), 1);
-                        if ($submission->late) {
-                            $grade = "<font color=\"red\">(".$grade.")</font>";
-                            $overallgrade = "<font color=\"red\">(".$overallgrade.")</font>";
-                        }
-                        echo "<tr><td>".exercise_print_submission_title($exercise, $submission)."</td>\n";
-                        echo "<td align=\"center\">$gradinggrade</td>";
-                        echo "<td align=\"center\">$grade</td>";
-                        echo "<td align=\"center\">$overallgrade</td></tr>\n";
-                    }
-                }
-            }
-        }
-        echo "</table></center><br clear=\"all\" />\n";
-        if ($exercise->showleaguetable) {
-            exercise_print_league_table($exercise);
-        }
-        echo "<br />".get_string("maximumgrade").": $exercise->grade<br />\n";
-    }
-
-
-    /****************** make final grades available (for teachers only)**************/
-    elseif ($action == 'makeleaguetableavailable') {
-
-        if (!isteacheredit($course->id)) {
-            print_error("Only teachers with editing permissions can do this.");
-        }
-
-        set_field("exercise", "phase", 3, "id", "$exercise->id");
-        add_to_log($course->id, "exercise", "display", "view.php?id=$cm->id", "$exercise->id", $cm->id);
-        redirect("view.php?id=$cm->id", get_string("movingtophase", "exercise", 3));
-    }
-
-
-    /*********************** assignment not available (for students)***********************/
-    elseif ($action == 'notavailable') {
-        print_heading(get_string("notavailable", "exercise"));
-    }
-
-
-    /****************** open exercise for student assessments and submissions (phase 2) (for teachers)**/
-    elseif ($action == 'openexercise') {
-
-        if (!isteacheredit($course->id)) {
-            print_error("Only teachers with editing permissions can do this.");
-        }
-
-        // move to phase 2, check that teacher has made enough submissions
-        if (exercise_count_teacher_submissions($exercise) == 0) {
-            redirect("view.php?id=$cm->id", get_string("noexercisedescriptionssubmitted", "exercise"));
-            }
-        elseif (($exercise->gradingstrategy == 3) and ($exercise->nelements ==1 )) {
-            // only one criterion specified
-            redirect("view.php?id=$cm->id", get_string("numberofcriterionelements", "exercise"));
-        } else {
-            set_field("exercise", "phase", 2, "id", "$exercise->id");
-            add_to_log($course->id, "exercise", "open", "view.php?id=$cm->id", "$exercise->id", $cm->id);
-            redirect("view.php?id=$cm->id", get_string("movingtophase", "exercise", 2));
-        }
-    }
-
-
-    /****************** set up assignment (move back to phase 1) (for teachers)***********************/
-    elseif ($action == 'setupassignment') {
-
-        if (!isteacher($course->id)) {
-            print_error("Only teachers with editing permissions can do this.");
-        }
-
-        set_field("exercise", "phase", 1, "id", "$exercise->id");
-        add_to_log($course->id, "exercise", "set up", "view.php?id=$cm->id", "$exercise->id", $cm->id);
-        redirect("view.php?id=$cm->id", get_string("movingtophase", "exercise", 1));
-    }
-
-
-    /****************** showsubmissions (for students, in phase 3)***********************/
-    elseif ($action == 'showsubmissions') {
-        exercise_print_assignment_info($exercise);
-        print_heading(get_string("submissionsnowclosed", "exercise"));
-        // show student's assessment (linked to the teacher's exercise/submission
-        print_heading(get_string("yourassessment", "exercise"));
-        exercise_list_teacher_submissions($exercise, $USER);
-        echo "<hr size=\"1\" noshade=\"noshade\" />";
-        if ($submissions = exercise_get_user_submissions($exercise, $USER)) {
-            print_heading(get_string("yoursubmission", "exercise"));
-            print_simple_box_start("center");
-            $table->head = array (get_string("submission", "exercise"),  get_string("submitted", "exercise"),
-                    get_string("assessed", "exercise"), get_string("grade"));
-            $table->width = "100%";
-            $table->align = array ("left", "left", "left", "center");
-            $table->size = array ("*", "*", "*", "*");
-            $table->cellpadding = 2;
-            $table->cellspacing = 0;
-
-            foreach ($submissions as $submission) {
-                if ($assessments = exercise_get_assessments($submission)) {
-                    // should only be one but we'll loop anyway
-                    foreach ($assessments as $assessment) {
-                        $table->data[] = array(exercise_print_submission_title($exercise, $submission),
-                                userdate($submission->timecreated), userdate($assessment->timecreated),
-                                "<a href=\"assessments.php?action=viewassessment&amp;id=$cm->id&amp;aid=$assessment->id\">".$assessment->grade * $exercise->grade / 100.0."</a>");
-                    }
-                } else {
-                    // submission not yet assessed (by teacher)
-                    $table->data[] = array(exercise_print_submission_title($exercise, $submission),
-                            userdate($submission->timecreated), get_string("notassessedyet", "exercise"), 0);
-                }
-            }
-            print_table($table);
-            print_simple_box_end();
-        } else {
-            print_heading(get_string("nosubmissions", "exercise"));
-        }
-        // always allow student to resubmit
-        if (exercise_test_for_resubmission($exercise, $USER)) {
-            // if resubmission requested print upload form
-            echo "<hr size=\"1\" noshade=\"noshade\" />";
-            print_heading(get_string("pleasesubmityourwork", "exercise").":");
-            exercise_print_upload_form($exercise);
-        }
-        echo "<hr size=\"1\" noshade=\"noshade\" />";
-    }
-
-
-    /****************** student's view could be in 1 of 3 stages ***********************/
-    elseif ($action == 'studentsview') {
-        exercise_print_assignment_info($exercise);
-        // is a password needed?
-        if ($exercise->usepassword) {
-            $correctpass = false;
-            if (isset($_POST['userpassword'])) {
-                if ($exercise->password == md5(trim($_POST['userpassword']))) {
-                    $USER->exerciseloggedin[$exercise->id] = true;
-                    $correctpass = true;
-                }
-            } elseif (isset($USER->exerciseloggedin[$exercise->id])) {
-                $correctpass = true;
-            }
-
-            if (!$correctpass) {
-                print_simple_box_start("center");
-                echo "<form id=\"password\" method=\"post\" action=\"view.php\">\n";
-                echo "<input type=\"hidden\" name=\"id\" value=\"$cm->id\" />\n";
-                echo "<table cellpadding=\"7px\">";
-                if (isset($_POST['userpassword'])) {
-                    echo "<tr align=\"center\" style='color:#DF041E;'><td>".get_string("wrongpassword", "exercise").
-                        "</td></tr>";
-                }
-                echo "<tr align=\"center\"><td>".get_string("passwordprotectedexercise", "exercise", format_string($exercise->name)).
-                    "</td></tr>";
-                echo "<tr align=\"center\"><td>".get_string("enterpassword", "exercise").
-                    " <input type=\"password\" name=\"userpassword\" /></td></tr>";
-
-                echo "<tr align=\"center\"><td>";
-                echo "<input type=\"button\" value=\"".get_string("cancel").
-                    "\" onclick=\"parent.location='../../course/view.php?id=$course->id';\">  ";
-                echo "<input type=\"button\" value=\"".get_string("continue").
-                    "\" onclick=\"document.password.submit();\" />";
-                echo "</td></tr></table>";
-                print_simple_box_end();
-                exit();
-            }
-        }
-        // in Stage 1 - the student must make an assessment (linked to the teacher's exercise/submission
-        if (!exercise_test_user_assessments($exercise, $USER)) {
-            print_heading(get_string("pleaseviewtheexercise", "exercise", $course->teacher));
-            exercise_list_teacher_submissions($exercise, $USER);
-        }
-        // in stage 2? - submit own first attempt
-        else {
-            // show assessment the teacher's examples, there may be feedback from teacher
-            if (exercise_count_user_submissions($exercise, $USER) == 0) {
-                print_heading(get_string("atthisstageyou", "exercise", $course->teacher));
-                exercise_list_teacher_submissions($exercise, $USER, true);  // true = allow re-assessing
-                // print upload form
-                print_heading(get_string("pleasesubmityourwork", "exercise").":");
-                exercise_print_upload_form($exercise);
-            }
-            // in stage 3? - awaiting grading of assessment and assessment of work by teacher,
-            // may resubmit if allowed
-            else {
-                exercise_list_teacher_submissions($exercise, $USER);
-                echo "<hr size=\"1\" noshade=\"noshade\" />";
-                print_heading(get_string("yoursubmission", "exercise"));
-                exercise_list_user_submissions($exercise, $USER);
-                if (exercise_test_for_resubmission($exercise, $USER)) {
-                    // if resubmission requested print upload form
-                    echo "<hr size=\"1\" noshade=\"noshade\" />";
-                    print_heading(get_string("pleasesubmityourwork", "exercise").":");
-                    exercise_print_upload_form($exercise);
-                    echo "<hr size=\"1\" noshade=\"noshade\" />";
-                }
-            }
-        }
-    }
-
-
-    /****************** submission of assignment by teacher only***********************/
-    elseif ($action == 'submitassignment') {
-
-        if (!has_capability('mod/exercise:assess', $context)) {
-            print_error("Only teachers with editing permissions can do this.");
-        }
-
-        exercise_print_assignment_info($exercise);
-
-        // list previous submissions from this user
-        exercise_list_user_submissions($exercise, $USER);
-
-        echo "<hr size=\"1\" noshade=\"noshade\" />";
-
-        // print upload form
-        print_heading(get_string("submitexercisedescription", "exercise").":");
-        exercise_print_upload_form($exercise);
-    }
-
-
-    /****************** teacher's view - display admin page (current phase options) ************/
-    elseif ($action == 'teachersview') {
-
-        if (!isteacher($course->id)) {
-            print_error("Only teachers can look at this page");
-        }
-
-        /// Check to see if groups are being used in this exercise
-        /// and if so, set $currentgroup to reflect the current group
-        $groupmode = groupmode($course, $cm);   // Groups are being used?
-        $currentgroup = setup_and_print_groups($course, $groupmode, "view.php?id=$cm->id");
-
-        print_heading_with_help(get_string("managingassignment", "exercise"), "managing", "exercise");
-
-        exercise_print_assignment_info($exercise);
-        $tabs->names = array("1. ".get_string("phase1", "exercise"),
-            "2. ".get_string("phase2", "exercise", $course->student),
-            "3. ".get_string("phase3", "exercise", $course->student));
-        if (isteacheredit($course->id)) {
-            $tabs->urls = array("view.php?id=$cm->id&amp;action=setupassignment",
-                "view.php?id=$cm->id&amp;action=openexercise",
-                "view.php?id=$cm->id&amp;action=makeleaguetableavailable");
-        } else {
-            // don't allow non-editing teacher to change phase
-            $tabs->urls = array("view.php?id=$cm->id",
-                "view.php?id=$cm->id",
-                "view.php?id=$cm->id");
-        }
-        if ($exercise->phase) { // phase 1 or more
-            $tabs->highlight = $exercise->phase - 1;
-            } else {
-            $tabs->highlight = 0; // phase is zero
-            }
-        exercise_print_tabbed_heading($tabs);
-
-        echo "<center>\n";
-            switch ($exercise->phase) {
-                case 0:
-                case 1: // set up assignment
-                    if (isteacheredit($course->id)) {
-                        echo "<p><b><a href=\"assessments.php?id=$cm->id&amp;action=editelements\">".
-                            get_string("amendassessmentelements", "exercise")."</a></b></p> \n";
-                        helpbutton("elements", get_string("amendassessmentelements", "exercise"), "exercise");
-                        echo "<p><b><a href=\"view.php?id=$cm->id&amp;action=submitassignment\">".
-                            get_string("submitexercisedescription", "exercise")."</a></b></p> \n";
-                        helpbutton("submissionofdescriptions", get_string("submitexercisedescription", "exercise"), "exercise");
-                    }
-                    break;
-
-                case 2: // submissions and assessments
-                    // just show student submissions link, the (self) assessments are show above the assessment form for
-                    // the submissions
-                    echo "<p><b><a href=\"submissions.php?id=$cm->id&amp;action=listforassessmentstudent\">".
-                          get_string("studentsubmissionsforassessment", "exercise",
-                          exercise_count_unassessed_student_submissions($exercise))."</a></b></p> \n";
-                    helpbutton("grading", get_string("studentsubmissionsforassessment", "exercise"),
-                            "exercise");
-                    break;
-
-                case 3: // show final grades
-                    echo "<p><b><a href=\"submissions.php?id=$cm->id&amp;action=listforassessmentstudent\">".
-                          get_string("studentsubmissionsforassessment", "exercise",
-                          exercise_count_unassessed_student_submissions($exercise))."</a></b></p> \n";
-                    helpbutton("grading", get_string("studentsubmissionsforassessment", "exercise"),
-                            "exercise");
-                    print_heading("<a href=\"submissions.php?id=$cm->id&amp;action=displayfinalgrades\">".
-                          get_string("displayoffinalgrades", "exercise")."</a>");
-        }
-        print_heading("<a href=\"submissions.php?id=$cm->id&amp;action=adminlist\">".
-            get_string("administration")."</a>");
-       echo "</center>\n";
-    }
-
-
-    /*************** no man's land **************************************/
-    else {
-        print_error("Fatal Error: Unknown Action: ".$action."\n");
-    }
-
-    print_footer($course);
-
-?>
diff --git a/mod/forum/db/mysql.php b/mod/forum/db/mysql.php
deleted file mode 100644 (file)
index aae07c2..0000000
+++ /dev/null
@@ -1,298 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function forum_upgrade($oldversion) {
-// This function does anything necessary to upgrade
-// older versions to match current functionality
-
-  global $CFG, $db;
-
-  if ($oldversion < 2002073008) {
-    execute_sql("DELETE FROM modules WHERE name = 'discuss' ");
-    execute_sql("ALTER TABLE `discuss` RENAME `forum_discussions` ");
-    execute_sql("ALTER TABLE `discuss_posts` RENAME `forum_posts` ");
-    execute_sql("ALTER TABLE `discuss_ratings` RENAME `forum_ratings` ");
-    execute_sql("ALTER TABLE `forum` CHANGE `intro` `intro` TEXT NOT NULL ");
-    execute_sql("ALTER TABLE `forum` ADD `forcesubscribe` TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL AFTER `assessed`");
-    execute_sql("ALTER TABLE `forum` CHANGE `type` `type` ENUM( 'single', 'news', 'social', 'general', 
-                             'eachuser', 'teacher' ) DEFAULT 'general' NOT NULL ");
-    execute_sql("ALTER TABLE `forum_posts` CHANGE `discuss` `discussion` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL ");
-    execute_sql("INSERT INTO log_display (module, action, mtable, field) VALUES ('forum', 'add', 'forum', 'name') ");
-    execute_sql("INSERT INTO log_display (module, action, mtable, field) VALUES ('forum', 'add discussion', 'forum_discussions', 'name') ");
-    execute_sql("INSERT INTO log_display (module, action, mtable, field) VALUES ('forum', 'add post', 'forum_posts', 'subject') ");
-    execute_sql("INSERT INTO log_display (module, action, mtable, field) VALUES ('forum', 'update post', 'forum_posts', 'subject') ");
-    execute_sql("INSERT INTO log_display (module, action, mtable, field) VALUES ('forum', 'view discussion', 'forum_discussions', 'name') ");
-    execute_sql("DELETE FROM log_display WHERE module = 'discuss' ");
-    execute_sql("UPDATE log SET action = 'view discussion' WHERE module = 'discuss' AND action = 'view' ");
-    execute_sql("UPDATE log SET action = 'add discussion' WHERE module = 'discuss' AND action = 'add' ");
-    execute_sql("UPDATE log SET module = 'forum' WHERE module = 'discuss' ");
-    notify("Renamed all the old discuss tables (now part of forum) and created new forum_types");
-  }
-
-  if ($oldversion < 2002080100) {
-    execute_sql("INSERT INTO log_display (module, action, mtable, field) VALUES ('forum', 'view subscribers', 'forum', 'name') ");
-    execute_sql("INSERT INTO log_display (module, action, mtable, field) VALUES ('forum', 'update', 'forum', 'name') ");
-  }
-
-  if ($oldversion < 2002082900) {
-    execute_sql(" ALTER TABLE `forum_posts` ADD `attachment` VARCHAR(100) NOT NULL AFTER `message` ");
-  }
-
-  if ($oldversion < 2002091000) {
-    if (! execute_sql(" ALTER TABLE `forum_posts` ADD `attachment` VARCHAR(100) NOT NULL AFTER `message` ")) {
-      echo "<p>Don't worry about this error - your server already had this upgrade applied";
-    }
-  }
-
-  if ($oldversion < 2002100300) {
-      execute_sql(" ALTER TABLE `forum` CHANGE `open` `open` TINYINT(2) UNSIGNED DEFAULT '2' NOT NULL ");
-      execute_sql(" UPDATE `forum` SET `open` = 2 WHERE `open` = 1 ");
-      execute_sql(" UPDATE `forum` SET `open` = 1 WHERE `open` = 0 ");
-  }
-  if ($oldversion < 2002101001) {
-      execute_sql(" ALTER TABLE `forum_posts` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `message` ");
-  }
-
-  if ($oldversion < 2002122300) {
-      execute_sql("ALTER TABLE `forum_posts` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
-      execute_sql("ALTER TABLE `forum_ratings` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
-      execute_sql("ALTER TABLE `forum_subscriptions` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
-  }
-
-  if ($oldversion < 2003042402) {
-      execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('forum', 'move discussion', 'forum_discussions', 'name')");
-  }
-
-  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");
-  }
-
-  if ($oldversion < 2003082502) {
-      table_column("forum", "scale", "scale", "integer", "10", "", "0");
-      execute_sql("UPDATE {$CFG->prefix}forum SET scale = (- scale)");
-  }
-
-  if ($oldversion < 2003100600) {
-      table_column("forum", "", "maxbytes", "integer", "10", "unsigned", "0", "", "scale");
-  }
-
-  if ($oldversion < 2004010100) {
-      table_column("forum", "", "assesspublic", "integer", "4", "unsigned", "0", "", "assessed");
-  }
-
-  if ($oldversion < 2004011404) {
-      table_column("forum_discussions", "", "userid", "integer", "10", "unsigned", "0", "", "firstpost");
-
-      if ($discussions = get_records_sql("SELECT d.id, p.userid
-                                            FROM {$CFG->prefix}forum_discussions as d, 
-                                                 {$CFG->prefix}forum_posts as p
-                                           WHERE d.firstpost = p.id")) {
-          foreach ($discussions as $discussion) {
-              update_record("forum_discussions", $discussion);
-          }
-      }
-  }
-
-  if ($oldversion < 2004012200) {
-      table_column("forum_discussions", "", "groupid", "integer", "10", "unsigned", "0", "", "userid");
-  }
-
-  if ($oldversion < 2004013000) {
-      table_column("forum_posts", "mailed", "mailed", "tinyint", "2");
-  }
-
-  if ($oldversion < 2004020600) {
-      table_column("forum_discussions", "", "usermodified", "integer", "10", "unsigned", "0", "", "timemodified");
-  }
-
-  if ($oldversion < 2004050300) {
-      table_column("forum","","rsstype","tinyint","2", "unsigned", "0", "", "forcesubscribe");
-      table_column("forum","","rssarticles","tinyint","2", "unsigned", "0", "", "rsstype");
-      set_config("forum_enablerssfeeds",0);
-  }
-
-  if ($oldversion < 2004060100) {
-      modify_database('', "CREATE TABLE `prefix_forum_queue` (
-                                `id` int(11) unsigned NOT NULL auto_increment,
-                                `userid` int(11) unsigned default 0 NOT NULL,
-                                `discussionid` int(11) unsigned default 0 NOT NULL,
-                                `postid` int(11) unsigned default 0 NOT NULL,
-                                PRIMARY KEY  (`id`),
-                                KEY `user` (userid),
-                                KEY `post` (postid)
-                              ) TYPE=MyISAM COMMENT='For keeping track of posts that will be mailed in digest form';");
-  }
-
-  if ($oldversion < 2004070700) {    // This may be redoing it from STABLE but that's OK
-      table_column("forum_discussions", "groupid", "groupid", "integer", "10", "", "0", "");
-  }
-  
-  if ($oldversion < 2004111700) {
-      execute_sql(" ALTER TABLE `{$CFG->prefix}forum_posts` DROP INDEX {$CFG->prefix}forum_posts_parent_idx;",false);
-      execute_sql(" ALTER TABLE `{$CFG->prefix}forum_posts` DROP INDEX {$CFG->prefix}forum_posts_discussion_idx;",false);
-      execute_sql(" ALTER TABLE `{$CFG->prefix}forum_posts` DROP INDEX {$CFG->prefix}forum_posts_userid_idx;",false);
-      execute_sql(" ALTER TABLE `{$CFG->prefix}forum_discussions` DROP INDEX {$CFG->prefix}forum_discussions_forum_idx;",false); 
-      execute_sql(" ALTER TABLE `{$CFG->prefix}forum_discussions` DROP INDEX {$CFG->prefix}forum_discussions_userid_idx;",false);
-
-      execute_sql(" ALTER TABLE `{$CFG->prefix}forum_posts` ADD INDEX {$CFG->prefix}forum_posts_parent_idx (parent) ");
-      execute_sql(" ALTER TABLE `{$CFG->prefix}forum_posts` ADD INDEX {$CFG->prefix}forum_posts_discussion_idx (discussion) ");
-      execute_sql(" ALTER TABLE `{$CFG->prefix}forum_posts` ADD INDEX {$CFG->prefix}forum_posts_userid_idx (userid) ");
-      execute_sql(" ALTER TABLE `{$CFG->prefix}forum_discussions` ADD INDEX {$CFG->prefix}forum_discussions_forum_idx (forum) ");
-      execute_sql(" ALTER TABLE `{$CFG->prefix}forum_discussions` ADD INDEX {$CFG->prefix}forum_discussions_userid_idx (userid) ");
-  }
-
-  if ($oldversion < 2004111700) {
-      execute_sql("ALTER TABLE {$CFG->prefix}forum DROP INDEX course;",false);
-      execute_sql("ALTER TABLE {$CFG->prefix}forum_ratings DROP INDEX userid;",false);
-      execute_sql("ALTER TABLE {$CFG->prefix}forum_ratings DROP INDEX post;",false);
-      execute_sql("ALTER TABLE {$CFG->prefix}forum_subscriptions DROP INDEX userid;",false);
-      execute_sql("ALTER TABLE {$CFG->prefix}forum_subscriptions DROP INDEX forum;",false);
-
-      modify_database('','ALTER TABLE prefix_forum ADD INDEX course (course);');
-      modify_database('','ALTER TABLE prefix_forum_ratings ADD INDEX userid (userid);');
-      modify_database('','ALTER TABLE prefix_forum_ratings ADD INDEX post (post);');
-      modify_database('','ALTER TABLE prefix_forum_subscriptions ADD INDEX userid (userid);');
-      modify_database('','ALTER TABLE prefix_forum_subscriptions ADD INDEX forum (forum);');
-  }
-
-  if ($oldversion < 2005011500) {
-      modify_database('','CREATE TABLE prefix_forum_read (
-                  `id` int(10) unsigned NOT NULL auto_increment, 
-                  `userid` int(10) NOT NULL default \'0\',
-                  `forumid` int(10) NOT NULL default \'0\',
-                  `discussionid` int(10) NOT NULL default \'0\',
-                  `postid` int(10) NOT NULL default \'0\',
-                  `firstread` int(10) NOT NULL default \'0\',
-                  `lastread` int(10) NOT NULL default \'0\',
-                  PRIMARY KEY  (`id`),
-                  KEY `prefix_forum_user_forum_idx` (`userid`,`forumid`),
-                  KEY `prefix_forum_user_discussion_idx` (`userid`,`discussionid`),
-                  KEY `prefix_forum_user_post_idx` (`userid`,`postid`)
-                  ) COMMENT=\'Tracks each users read posts\';');
-
-      set_config('upgrade', 'forumread');   // The upgrade of this table will be done later by admin/upgradeforumread.php
-  }
-
-  if ($oldversion < 2005032900) {
-      modify_database('','ALTER TABLE prefix_forum_posts ADD INDEX prefix_form_posts_created_idx (created);');
-      modify_database('','ALTER TABLE prefix_forum_posts ADD INDEX prefix_form_posts_mailed_idx (mailed);');
-  }
-
-  if ($oldversion < 2005041100) { // replace wiki-like with markdown
-      include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
-      $wtm = new WikiToMarkdown();
-      $sql = "select course from {$CFG->prefix}forum_discussions, {$CFG->prefix}forum_posts ";
-      $sql .=  "where {$CFG->prefix}forum_posts.discussion = {$CFG->prefix}forum_discussions.id ";
-      $sql .=  "and {$CFG->prefix}forum_posts.id = ";
-      $wtm->update( 'forum_posts','message','format',$sql );
-  }
-
-  if ($oldversion < 2005042300) { // Add tracking prefs table
-      modify_database('','CREATE TABLE prefix_forum_track_prefs (
-                  `id` int(10) unsigned NOT NULL auto_increment, 
-                  `userid` int(10) NOT NULL default \'0\',
-                  `forumid` int(10) NOT NULL default \'0\',
-                  PRIMARY KEY  (`id`),
-                  KEY `user_forum_idx` (`userid`,`forumid`)
-                  ) COMMENT=\'Tracks each users untracked forums.\';');
-  }
-
-  if ($oldversion < 2005042500) {
-      table_column('forum','','trackingtype','tinyint','2', 'unsigned', '1', '', 'forcesubscribe');
-  }
-
-  if ($oldversion < 2005111100) {
-      table_column('forum_discussions','','timestart','integer');
-      table_column('forum_discussions','','timeend','integer');
-  }
-  
-  if ($oldversion < 2006011600) {
-      execute_sql("alter table ".$CFG->prefix."forum change column type type enum('single','news','general','social','eachuser','teacher','qanda') not null default 'general'");
-  }
-
-  if ($oldversion < 2006011601) {
-      table_column('forum','','warnafter');
-      table_column('forum','','blockafter');
-      table_column('forum','','blockperiod');
-  }
-
-  if ($oldversion < 2006011700) {
-      table_column('forum_posts','','mailnow','integer');
-  }
-  
-  if ($oldversion < 2006011702) {
-      execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('forum', 'user report', 'user', 'CONCAT(firstname,\' \',lastname)')");
-  }
-  
-  
-  if ($oldversion < 2006081800) {
-      // Upgrades for new roles and capabilities support.
-      require_once($CFG->dirroot.'/mod/forum/lib.php');
-      
-      $forummod = get_record('modules', 'name', 'forum');
-      
-      if ($forums = get_records('forum')) {
-          
-          if (!$teacherroles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW)) {
-              notify('Default teacher role was not found. Roles and permissions '.
-                     'for all your forums will have to be manually set after '.
-                     'this upgrade.');
-          }
-          if (!$studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) {
-              notify('Default student role was not found. Roles and permissions '.
-                     'for all your forums will have to be manually set after '.
-                     'this upgrade.');
-          }
-          if (!$guestroles = get_roles_with_capability('moodle/legacy:guest', CAP_ALLOW)) {
-              notify('Default guest role was not found. Roles and permissions '.
-                     'for teacher forums will have to be manually set after '.
-                     'this upgrade.');
-          }
-          foreach ($forums as $forum) {
-              if (!forum_convert_to_roles($forum, $forummod->id, $teacherroles,
-                                          $studentroles, $guestroles)) {
-                  notify('Forum with id '.$forum->id.' was not upgraded');
-              }
-          }
-          // We need to rebuild all the course caches to refresh the state of
-          // the forum modules.
-          include_once( "$CFG->dirroot/course/lib.php" );
-          rebuild_course_cache();
-          
-      } // End if.
-      
-      // Drop column forum.open.
-      modify_database('', 'ALTER TABLE prefix_forum DROP COLUMN open;');
-        
-      // Drop column forum.assesspublic.
-      modify_database('', 'ALTER TABLE prefix_forum DROP COLUMN assesspublic;');
-  }
-
-  if ($oldversion < 2006082700) {
-      $sql = "UPDATE {$CFG->prefix}forum_posts SET message = REPLACE(message, '".TRUSTTEXT."', '');";
-      $likecond = sql_ilike()." '%".TRUSTTEXT."%'";
-      while (true) {
-          if (!count_records_select('forum_posts', "message $likecond")) {
-              break;
-          }
-          execute_sql($sql);
-      }
-  }
-
-  //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-  return true;
-  
-}
-
-
-?>
diff --git a/mod/forum/db/postgres7.php b/mod/forum/db/postgres7.php
deleted file mode 100644 (file)
index 98c07ee..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function forum_upgrade($oldversion) {
-// This function does anything necessary to upgrade
-// older versions to match current functionality
-
-  global $CFG;
-
-  if ($oldversion < 2003042402) {
-      execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) 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");
-  }
-
-  if ($oldversion < 2003082502) {
-      execute_sql("UPDATE {$CFG->prefix}forum SET scale = (- scale)");
-  }
-
-  if ($oldversion < 2003100600) {
-      table_column("forum", "", "maxbytes", "integer", "10", "unsigned", "0", "", "scale");
-  }
-
-  if ($oldversion < 2004010100) {
-      table_column("forum", "", "assesspublic", "integer", "4", "unsigned", "0", "", "assessed");
-  }
-
-  if ($oldversion < 2004011404) {
-      table_column("forum_discussions", "", "userid", "integer", "10", "unsigned", "0", "", "firstpost");
-
-      if ($discussions = get_records_sql("SELECT d.id, p.userid
-                                            FROM {$CFG->prefix}forum_discussions as d, 
-                                                 {$CFG->prefix}forum_posts as p
-                                           WHERE d.firstpost = p.id")) {
-          foreach ($discussions as $discussion) {
-              update_record("forum_discussions", $discussion);
-          }
-      }
-  }
-  if ($oldversion < 2004012200) {
-      table_column("forum_discussions", "", "groupid", "integer", "10", "unsigned", "0", "", "userid");
-  }
-
-  if ($oldversion < 2004020600) {
-      table_column("forum_discussions", "", "usermodified", "integer", "10", "unsigned", "0", "", "timemodified");
-  }
-
-  if ($oldversion < 2004050300) {
-      table_column("forum","","rsstype","integer","2", "unsigned", "0", "", "forcesubscribe");
-      table_column("forum","","rssarticles","integer","2", "unsigned", "0", "", "rsstype");
-      set_config("forum_enablerssfeeds",0);
-  }
-
-  if ($oldversion < 2004060100) {
-      modify_database('', "CREATE TABLE prefix_forum_queue (
-                           id SERIAL PRIMARY KEY,
-                           userid integer default 0 NOT NULL,
-                           discussionid integer default 0 NOT NULL,
-                           postid integer default 0 NOT NULL
-                           );");
-  }
-
-  if ($oldversion < 2004070700) {    // This may be redoing it from STABLE but that's OK
-      table_column("forum_discussions", "groupid", "groupid", "integer", "10", "", "0", "");
-  }
-
-
-  if ($oldversion < 2004111700) {
-      execute_sql(" DROP INDEX {$CFG->prefix}forum_posts_parent_idx;",false);
-      execute_sql(" DROP INDEX {$CFG->prefix}forum_posts_discussion_idx;",false);
-      execute_sql(" DROP INDEX {$CFG->prefix}forum_posts_userid_idx;",false);
-      execute_sql(" DROP INDEX {$CFG->prefix}forum_discussions_forum_idx;",false);
-      execute_sql(" DROP INDEX {$CFG->prefix}forum_discussions_userid_idx;",false);
-
-      execute_sql(" CREATE INDEX {$CFG->prefix}forum_posts_parent_idx ON {$CFG->prefix}forum_posts (parent) ");
-      execute_sql(" CREATE INDEX {$CFG->prefix}forum_posts_discussion_idx ON {$CFG->prefix}forum_posts (discussion) ");
-      execute_sql(" CREATE INDEX {$CFG->prefix}forum_posts_userid_idx ON {$CFG->prefix}forum_posts (userid) ");
-      execute_sql(" CREATE INDEX {$CFG->prefix}forum_discussions_forum_idx ON {$CFG->prefix}forum_discussions (forum) ");
-      execute_sql(" CREATE INDEX {$CFG->prefix}forum_discussions_userid_idx ON {$CFG->prefix}forum_discussions (userid) ");
-  }
-
-  if ($oldversion < 2004111200) {
-      execute_sql("DROP INDEX {$CFG->prefix}forum_course_idx;",false);
-      execute_sql("DROP INDEX {$CFG->prefix}forum_queue_userid_idx;",false);
-      execute_sql("DROP INDEX {$CFG->prefix}forum_queue_discussion_idx;",false); 
-      execute_sql("DROP INDEX {$CFG->prefix}forum_queue_postid_idx;",false); 
-      execute_sql("DROP INDEX {$CFG->prefix}forum_ratings_userid_idx;",false); 
-      execute_sql("DROP INDEX {$CFG->prefix}forum_ratings_post_idx;",false);
-      execute_sql("DROP INDEX {$CFG->prefix}forum_subscriptions_userid_idx;",false);
-      execute_sql("DROP INDEX {$CFG->prefix}forum_subscriptions_forum_idx;",false);
-
-      modify_database('','CREATE INDEX prefix_forum_course_idx ON prefix_forum (course);');
-      modify_database('','CREATE INDEX prefix_forum_queue_userid_idx ON prefix_forum_queue (userid);');
-      modify_database('','CREATE INDEX prefix_forum_queue_discussion_idx ON prefix_forum_queue (discussionid);');
-      modify_database('','CREATE INDEX prefix_forum_queue_postid_idx ON prefix_forum_queue (postid);');
-      modify_database('','CREATE INDEX prefix_forum_ratings_userid_idx ON prefix_forum_ratings (userid);');
-      modify_database('','CREATE INDEX prefix_forum_ratings_post_idx ON prefix_forum_ratings (post);');
-      modify_database('','CREATE INDEX prefix_forum_subscriptions_userid_idx ON prefix_forum_subscriptions (userid);');
-      modify_database('','CREATE INDEX prefix_forum_subscriptions_forum_idx ON prefix_forum_subscriptions (forum);');
-  }
-
-  if ($oldversion < 2005011500) {
-      modify_database('','CREATE TABLE prefix_forum_read (
-                          id SERIAL PRIMARY KEY,
-                          userid integer default 0 NOT NULL,
-                          forumid integer default 0 NOT NULL,
-                          discussionid integer default 0 NOT NULL,
-                          postid integer default 0 NOT NULL,
-                          firstread integer default 0 NOT NULL,
-                          lastread integer default 0 NOT NULL
-                        );');
-
-      modify_database('','CREATE INDEX prefix_forum_user_forum_idx ON prefix_forum_read (userid, forumid);');
-      modify_database('','CREATE INDEX prefix_forum_user_discussion_idx ON prefix_forum_read (userid, discussionid);');
-      modify_database('','CREATE INDEX prefix_forum_user_post_idx ON prefix_forum_read (userid, postid);');
-
-      set_config('upgrade', 'forumread');   // The upgrade of this table will be done later by admin/upgradeforumread.php
-  }
-
-  if ($oldversion < 2005032900) {
-      modify_database('','CREATE INDEX prefix_forum_posts_created_idx ON prefix_forum_posts (created);');
-      modify_database('','CREATE INDEX prefix_forum_posts_mailed_idx ON prefix_forum_posts (mailed);');
-  }
-
-  if ($oldversion < 2005041100) { // replace wiki-like with markdown
-      include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
-      $wtm = new WikiToMarkdown();
-      $sql = "select course from {$CFG->prefix}forum_discussions, {$CFG->prefix}forum_posts ";
-      $sql .=  "where {$CFG->prefix}forum_posts.discussion = {$CFG->prefix}forum_discussions.id ";
-      $sql .=  "and {$CFG->prefix}forum_posts.id = ";
-      $wtm->update( 'forum_posts','message','format',$sql );
-  }
-
-  if ($oldversion < 2005042300) { // Add tracking prefs table
-      modify_database('','CREATE TABLE prefix_forum_track_prefs (
-                          id SERIAL PRIMARY KEY, 
-                          userid integer default 0 NOT NULL,
-                          forumid integer default 0 NOT NULL
-                        );');
-  }
-
-  if ($oldversion < 2005042600) {
-      table_column('forum','','trackingtype','integer','2', 'unsigned', '1', '', 'forcesubscribe');
-      modify_database('','CREATE INDEX prefix_forum_track_user_forum_idx ON prefix_forum_track_prefs (userid, forumid);');
-  }
-
-  if ($oldversion < 2005042601) { // Mass cleanup of bad postgres upgrade scripts
-      modify_database('','ALTER TABLE prefix_forum ALTER trackingtype SET NOT NULL');
-  }
-
-  if ($oldversion < 2005111100) {
-      table_column('forum_discussions','','timestart','integer');
-      table_column('forum_discussions','','timeend','integer');
-  }
-
-  if ($oldversion < 2006011600) {
-      notify('forum_type does not exists, you can ignore and this will properly removed');
-      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')) ");
-  }
-
-  if ($oldversion < 2006011601) {
-      table_column('forum','','warnafter');
-      table_column('forum','','blockafter');
-      table_column('forum','','blockperiod');
-  }
-
-  if ($oldversion < 2006011700) {
-      table_column('forum_posts','','mailnow','integer');
-  }
-
-  if ($oldversion < 2006011701) {
-      execute_sql("ALTER TABLE {$CFG->prefix}forum DROP CONSTRAINT {$CFG->prefix}forum_type_check");
-  }
-
-  if ($oldversion < 2006011702) {
-      execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('forum', 'user report', 'user', 'firstname||\' \'||lastname')");
-  }
-
-  if ($oldversion < 2006081800) {
-      // Upgrades for new roles and capabilities support.
-      require_once($CFG->dirroot.'/mod/forum/lib.php');
-
-      $forummod = get_record('modules', 'name', 'forum');
-
-      if ($forums = get_records('forum')) {
-
-          if (!$teacherroles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW)) {
-              notify('Default teacher role was not found. Roles and permissions '.
-                     'for all your forums will have to be manually set after '.
-                     'this upgrade.');
-          }
-          if (!$studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) {
-              notify('Default student role was not found. Roles and permissions '.
-                     'for all your forums will have to be manually set after '.
-                     'this upgrade.');
-          }
-          if (!$guestroles = get_roles_with_capability('moodle/legacy:guest', CAP_ALLOW)) {
-              notify('Default guest role was not found. Roles and permissions '.
-                     'for teacher forums will have to be manually set after '.
-                     'this upgrade.');
-          }
-          foreach ($forums as $forum) {
-              if (!forum_convert_to_roles($forum, $forummod->id, $teacherroles,
-                                          $studentroles, $guestroles)) {
-                  notify('Forum with id '.$forum->id.' was not upgraded');
-              }
-          }
-          // We need to rebuild all the course caches to refresh the state of
-          // the forum modules.
-          rebuild_course_cache();
-      
-      } // End if.
-      
-      // Drop column forum.open.
-      modify_database('', 'ALTER TABLE prefix_forum DROP COLUMN open;');
-
-      // Drop column forum.assesspublic.
-      modify_database('', 'ALTER TABLE prefix_forum DROP COLUMN assesspublic;');
-  }
-    
-  if ($oldversion < 2006082700) {
-      $sql = "UPDATE {$CFG->prefix}forum_posts SET message = REPLACE(message, '".TRUSTTEXT."', '');";
-      $likecond = sql_ilike()." '%".TRUSTTEXT."%'";
-      while (true) {
-          if (!count_records_select('forum_posts', "message $likecond")) {
-              break;
-          }
-          execute_sql($sql);
-      }
-  }
-
-  //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-  return true;
-
-}
-
-
-?>
diff --git a/mod/glossary/db/mysql.php b/mod/glossary/db/mysql.php
deleted file mode 100644 (file)
index a7392c2..0000000
+++ /dev/null
@@ -1,451 +0,0 @@
-<?php   // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function glossary_upgrade($oldversion) {
-/// This function does anything necessary to upgrade
-/// older versions to match current functionality
-
-    global $CFG;
-
-    if ($oldversion < 2003091000) {
-        execute_sql(" ALTER TABLE `{$CFG->prefix}glossary` ".
-                    " ADD `allowduplicatedentries` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `studentcanpost` , ".
-                    " ADD `displayformat` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `allowduplicatedentries` , ".
-                    " ADD `mainglossary` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `displayformat` ");
-
-        execute_sql(" ALTER TABLE `{$CFG->prefix}glossary_entries` ".
-                    " ADD timecreated INT(10) UNSIGNED NOT NULL default '0' AFTER `format` , ".
-                    " ADD timemodified INT(10) UNSIGNED NOT NULL default '0' AFTER `timecreated` , ".
-                    " ADD teacherentry TINYINT(2) UNSIGNED NOT NULL default '0' AFTER `timemodified` ");
-
-        execute_sql(" INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('glossary', 'delete', 'glossary', 'name') ");
-        execute_sql(" INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('glossary', 'delete entry', 'glossary', 'name') ");
-    }
-    
-    if ( $oldversion < 2003091500 ) {
-        execute_sql(" ALTER TABLE `{$CFG->prefix}glossary_entries` ".
-                    " ADD attachment VARCHAR(100) NOT NULL default '' AFTER `format`");
-    }
-
-    if ( $oldversion < 2003091600 ) {
-        execute_sql(" ALTER TABLE `{$CFG->prefix}glossary` ".
-                    " ADD `showspecial` TINYINT(2) UNSIGNED DEFAULT '1' NOT NULL AFTER `mainglossary` , ".
-                    " ADD `showalphabet` TINYINT(2) UNSIGNED DEFAULT '1' NOT NULL AFTER `showspecial` , ".
-                    " ADD `showall` TINYINT(2) UNSIGNED DEFAULT '1' NOT NULL AFTER `showalphabet` ");
-    }
-    
-    if ( $oldversion < 2003091800 ) {
-
-        execute_sql("CREATE TABLE `{$CFG->prefix}glossary_categories` (
-                    `id` INT(10) unsigned NOT NULL auto_increment,
-                    `glossaryid` INT(10) UNSIGNED NOT NULL default '0',
-                    `name` VARCHAR(255) NOT NULL default '',
-                    PRIMARY KEY  (`id`)
-                    ) TYPE=MyISAM COMMENT='all categories for glossary entries'");
-
-        execute_sql("CREATE TABLE `{$CFG->prefix}glossary_entries_categories` (
-                    `categoryid` INT(10) UNSIGNED NOT NULL default '1',
-                    `entryid` INT(10) UNSIGNED NOT NULL default '0',
-                    PRIMARY KEY  (`categoryid`, `entryid`)
-                    ) TYPE=MyISAM COMMENT='categories of each glossary entry'");
-     }
-     
-     if ( $oldversion < 2003092100 ) {
-          execute_sql("ALTER TABLE `{$CFG->prefix}glossary_entries_categories` CHANGE `categoryid` `categoryid` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL ");
-     }
-
-    if ( $oldversion < 2003092102 ) {
-        execute_sql("ALTER TABLE `{$CFG->prefix}glossary_entries_categories` DROP PRIMARY KEY ");
-        execute_sql("ALTER TABLE `{$CFG->prefix}glossary_entries_categories` ADD `id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
-    }
-    
-    if ( $oldversion < 2003092400 ) {
-        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary_entries` " .
-                    "ADD `sourceglossaryid` INT(10) unsigned NOT NULL DEFAULT '0' AFTER `attachment` " );
-
-    }
-
-    if ( $oldversion < 2003101500 ) {
-        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary` " .
-                    "ADD `intro`  text NOT NULL DEFAULT '' AFTER `name` " );
-
-    }
-
-    if ( $oldversion < 2003101501 ) {
-        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary` " .
-                    "ADD `allowcomments`  TINYINT(2) UNSIGNED NOT NULL DEFAULT '0' AFTER `showall` " );
-
-        execute_sql("CREATE TABLE `{$CFG->prefix}glossary_comments` (
-                    `id` INT(10) unsigned NOT NULL auto_increment,
-                    `entryid` INT(10) UNSIGNED NOT NULL default '0',
-                    `userid` INT(10) UNSIGNED NOT NULL default '0',
-                    `comment` TEXT NOT NULL default '',
-                    `timemodified` INT(10) UNSIGNED NOT NULL default '0',
-                    `format` TINYINT(2) UNSIGNED NOT NULL default '0',
-                    PRIMARY KEY  (`id`)
-                    ) TYPE=MyISAM COMMENT='comments on glossary entries'");
-
-        execute_sql(" INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('glossary', 'add comment', 'glossary', 'name') ");
-        execute_sql(" INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('glossary', 'update comment', 'glossary', 'name') ");
-        execute_sql(" INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('glossary', 'delete comment', 'glossary', 'name') ");
-    }
-
-    if ( $oldversion < 2003101600 ) {
-        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary` " .
-                    "ADD `usedynalink`  TINYINT(2) UNSIGNED NOT NULL DEFAULT '1' AFTER `allowcomments` " );
-
-        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary_entries` " .
-                    "ADD `usedynalink`  TINYINT(2) UNSIGNED NOT NULL DEFAULT '1' AFTER `sourceglossaryid`, ".
-                    "ADD `casesensitive`  TINYINT(2) UNSIGNED NOT NULL DEFAULT '0' AFTER `usedynalink` ");
-    }
-
-    if ( $oldversion < 2003101601 ) {
-        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary_entries` " .
-                    "ADD `fullmatch`  TINYINT(2) UNSIGNED NOT NULL DEFAULT '1' AFTER `casesensitive` ");
-    }
-
-    if ( $oldversion < 2003101800 ) {
-        execute_sql( "UPDATE `{$CFG->prefix}glossary`" .
-                    " SET displayformat = 5 WHERE displayformat = 1");
-    }
-    if ( $oldversion < 2003102000 ) {
-        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary`" .
-                     " ADD `defaultapproval` TINYINT(2) UNSIGNED NOT NULL default '1' AFTER `usedynalink`");
-
-        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary_entries`" .
-                    " ADD `approved` TINYINT(2) UNSIGNED NOT NULL default '1' AFTER `fullmatch`");
-
-        execute_sql(" INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('glossary', 'approve entry', 'glossary', 'name') ");
-    }
-
-    if ( $oldversion < 2003102800 ) {
-        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary`" .
-                     " ADD `globalglossary` TINYINT(2) UNSIGNED NOT NULL default '0' AFTER `defaultapproval`");
-    }
-
-    if ( $oldversion < 2003103100 ) {
-        print_simple_box('This update might take several seconds.<br />The more glossaries, entries and categories you have created, the more it will take so please be patient.','center', '50%', '', '20', 'noticebox');
-        if ( $glossaries = get_records("glossary")) {
-            $gids = "";
-            foreach ( $glossaries as $glossary ) {
-                $gids .= "$glossary->id,";
-            }
-            $gids = substr($gids,0,-1);  // ID's of VALID glossaries
-
-            if ($categories = get_records_select("glossary_categories","glossaryid NOT IN ($gids)") ) {
-                $cids = "";
-                foreach ( $categories as $cat ) {
-                    $cids .= "$cat->id,";
-                }
-                $cids = substr($cids,0,-1);   // ID's of INVALID categories
-                if ($cids) {
-                    delete_records_select("glossary_entries_categories", "categoryid IN ($cids)");
-                    delete_records_select("glossary_categories", "id in ($cids)");
-                }
-            }
-            if ( $entries = get_records_select("glossary_entries") ) {
-                $eids = "";
-                foreach ( $entries as $entry ) {
-                    $eids .= "$entry->id,";
-                }
-                $eids = substr($eids,0,-1);  // ID's of VALID entries
-                if ($eids) {
-                    delete_records_select("glossary_comments", "entryid NOT IN ($eids)");
-                }
-            }
-        }
-    }
-
-    if ( $oldversion < 2003110400 ) {
-        execute_sql("CREATE TABLE `{$CFG->prefix}glossary_alias` (
-                    `id` INT(10) unsigned NOT NULL auto_increment,
-                    `entryid` INT(10) UNSIGNED NOT NULL default '0',
-                    `alias` TEXT NOT NULL default '',
-                    PRIMARY KEY  (`id`)
-                    ) TYPE=MyISAM COMMENT='entries alias'");
-    }
-    
-    if ( $oldversion < 2003111500 ) {
-        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary_categories`
-                     ADD `usedynalink`  TINYINT(2) UNSIGNED NOT NULL DEFAULT '1' AFTER `name`" );
-                     
-        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary`
-                     ADD `entbypage`  TINYINT(3) UNSIGNED NOT NULL DEFAULT '10' AFTER `globalglossary`" );
-                     
-    }
-
-    if ( $oldversion < 2003111800 ) {
-        execute_sql("CREATE TABLE `{$CFG->prefix}glossary_displayformats` (
-                    `id` INT(10) unsigned NOT NULL auto_increment,
-                    `fid` INT(10) UNSIGNED NOT NULL default '0',
-                    `visible` TINYINT(2) UNSIGNED NOT NULL default '1',
-                    `relatedview` TINYINT(3) NOT NULL default '-1',
-                    `showgroup` TINYINT(2) UNSIGNED NOT NULL default '1',
-                    `defaultmode` VARCHAR(50) NOT NULL default '',
-                    `defaulthook` VARCHAR(50) NOT NULL default '',
-                    `sortkey` VARCHAR(50) NOT NULL default '',
-                    `sortorder` VARCHAR(50) NOT NULL default '',
-                    PRIMARY KEY  (`id`)
-                    ) TYPE=MyISAM COMMENT='Setting of the display formats'");
-
-        // Default format
-        execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats 
-                      (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
-                      VALUES (0,0,'letter','ALL','CREATION','asc',1,1)");
-        // Continuous format
-        execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats 
-                      (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
-                      VALUES (1,1,'date','ALL','CREATION','asc',0,1)");
-        // Full w/author View
-        execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats 
-                      (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
-                      VALUES (2,2,'letter','ALL','CREATION','asc',1,1)");
-        // Encyclopedia
-        execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats 
-                      (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
-                      VALUES (3,3,'letter','ALL','CREATION','asc',1,1)");
-        // FAQ View
-        execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats 
-                      (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
-                      VALUES (4,4,'date','ALL','CREATION','asc',0,1)");
-        // Full w/o author View
-        execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats 
-                      (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
-                      VALUES (5,5,'letter','ALL','CREATION','asc',1,1)");
-        // Entry list
-        execute_sql("INSERT INTO {$CFG->prefix}glossary_displayformats 
-                      (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
-                      VALUES (6,0,'letter','ALL','CREATION','asc',1,1)");
-
-    }
-
-    if ($oldversion < 2003112100) {
-        table_column("glossary", "", "assessed", "integer", "10", "unsigned", "0");
-        table_column("glossary", "", "assesstimestart", "integer", "10", "unsigned", "0", "", "assessed");
-        table_column("glossary", "", "assesstimefinish", "integer", "10", "unsigned", "0", "", "assesstimestart");
-        
-        execute_sql("CREATE TABLE {$CFG->prefix}glossary_ratings (
-                      `id` int(10) unsigned NOT NULL auto_increment,
-                      `userid` int(10) unsigned NOT NULL default '0',
-                      `entryid` int(10) unsigned NOT NULL default '0',
-                      `time` int(10) unsigned NOT NULL default '0',
-                      `rating` tinyint(4) NOT NULL default '0',
-                      PRIMARY KEY  (`id`)
-                    ) COMMENT='Contains user ratings for entries'");
-    }
-
-    if ($oldversion < 2003112101) {
-        table_column("glossary", "", "scale", "integer", "10", "", "0", "", "assesstimefinish");
-    }
-    
-    if ($oldversion < 2003112701) {
-        delete_records("glossary_alias","entryid",0);
-    }
-
-    if ($oldversion < 2004022200) {
-        if (!empty($CFG->textfilters)) {
-            $CFG->textfilters = str_replace("dynalink.php", "filter.php", $CFG->textfilters);
-            set_config("textfilters", $CFG->textfilters);
-        }
-    }
-
-  if ($oldversion < 2004050900) {
-      table_column("glossary","","rsstype","tinyint","2", "unsigned", "0", "", "entbypage");
-      table_column("glossary","","rssarticles","tinyint","2", "unsigned", "0", "", "rsstype");
-      set_config("glossary_enablerssfeeds",0);
-  }
-
-  
-  if ( $oldversion < 2004051400 ) {
-        print_simple_box("This update might take several seconds.<p>The more glossaries, entries and aliases you have created, the more it will take so please be patient.","center", "50%", '', "20", "noticebox");
-        if ( $entries = get_records("glossary_entries", '', '', '', 'id,concept')) {
-            foreach($entries as $entry) {
-                set_field("glossary_entries","concept",addslashes(trim($entry->concept)),"id",$entry->id);
-            }
-        }
-        if ( $aliases = get_records("glossary_alias")) {
-            foreach($aliases as $alias) {
-                set_field("glossary_alias","alias",addslashes(trim($alias->alias)),"id",$alias->id);
-            }
-        }
-  }
-
-  if ( $oldversion < 2004072300) {
-      table_column("glossary_alias", "alias", "alias", "VARCHAR", "255", "", "", "NOT NULL");
-  }
-
-  if ( $oldversion < 2004072400) {
-
-      //Create new table glossary_formats to store format info
-      execute_sql("CREATE TABLE `{$CFG->prefix}glossary_formats` (
-                       `id` INT(10) unsigned NOT NULL auto_increment,
-                       `name` VARCHAR(50) NOT NULL,
-                       `popupformatname` VARCHAR(50) NOT NULL, 
-                       `visible` TINYINT(2) UNSIGNED NOT NULL default '1',
-                       `showgroup` TINYINT(2) UNSIGNED NOT NULL default '1',
-                       `defaultmode` VARCHAR(50) NOT NULL default '',
-                       `defaulthook` VARCHAR(50) NOT NULL default '',
-                       `sortkey` VARCHAR(50) NOT NULL default '',
-                       `sortorder` VARCHAR(50) NOT NULL default '',
-                   PRIMARY KEY  (`id`)                    
-                   ) TYPE=MyISAM COMMENT='Setting of the display formats'");
-
-      //Define current 0-6 format names
-      $formatnames = array('dictionary','continuous','fullwithauthor','encyclopedia',
-                           'faq','fullwithoutauthor','entrylist');
-
-      //Fill the new table from the old one (only 'valid', 0-6, formats)
-      if ($formats = get_records('glossary_displayformats')) {
-          foreach ($formats as $format) {
-              //Format names
-              if ($format->fid >= 0 && $format->fid <= 6) {
-                  $format->name = $formatnames[$format->fid];
-              }
-
-              //Format popupformatname
-              $format->popupformatname = 'dictionary';  //Default format
-              if ($format->relatedview >= 0 && $format->relatedview <= 6) {
-                  $format->popupformatname = $formatnames[$format->relatedview];
-              }
-
-              //Insert the new record
-              //Only if $format->name is set (ie. formats 0-6)
-              if ($format->name) {
-                  insert_record('glossary_formats',$format);
-              }
-              
-          }
-      }
-
-      //Drop the old formats table
-      execute_sql("DROP TABLE `{$CFG->prefix}glossary_displayformats`");
-
-      //Modify the glossary->displayformat field
-      table_column('glossary', 'displayformat', 'displayformat', 'VARCHAR', '50', '', 'dictionary', 'NOT NULL');
-
-      //Update glossary->displayformat field
-      if ($glossaries = get_records('glossary')) {
-          foreach($glossaries as $glossary) {
-              $displayformat = 'dictionary';  //Default format
-              if ($glossary->displayformat >= 0 && $glossary->displayformat <= 6) {
-                  $displayformat = $formatnames[$glossary->displayformat];
-              }
-              set_field('glossary','displayformat',$displayformat,'id',$glossary->id);
-          }
-      }
-  }
-
-  if ( $oldversion < 2004080800) {
-      table_column("glossary","","editalways","tinyint","2", "unsigned", "0", "", "entbypage");
-  }
-
-  //Activate editalways in old secondary glossaries (old behaviour)
-  if ( $oldversion < 2004080900) {
-      set_field('glossary','editalways','1','mainglossary','0');
-  }
-
-  if ($oldversion < 2004111200) {
-      execute_sql("ALTER TABLE {$CFG->prefix}glossary DROP INDEX course;",false);
-      execute_sql("ALTER TABLE {$CFG->prefix}glossary_alias DROP INDEX entryid;",false);
-      execute_sql("ALTER TABLE {$CFG->prefix}glossary_categories DROP INDEX glossaryid;",false); 
-      execute_sql("ALTER TABLE {$CFG->prefix}glossary_comments DROP INDEX entryid;",false);
-      execute_sql("ALTER TABLE {$CFG->prefix}glossary_comments DROP INDEX userid;",false); 
-      execute_sql("ALTER TABLE {$CFG->prefix}glossary_entries DROP INDEX glossaryid;",false);
-      execute_sql("ALTER TABLE {$CFG->prefix}glossary_entries DROP INDEX userid;",false); 
-      execute_sql("ALTER TABLE {$CFG->prefix}glossary_entries DROP INDEX concept;",false);
-      execute_sql("ALTER TABLE {$CFG->prefix}glossary_entries_categories DROP INDEX entryid;",false); 
-      execute_sql("ALTER TABLE {$CFG->prefix}glossary_entries_categories DROP INDEX categoryid;",false);
-      execute_sql("ALTER TABLE {$CFG->prefix}glossary_ratings DROP INDEX userid;",false); 
-      execute_sql("ALTER TABLE {$CFG->prefix}glossary_ratings DROP INDEX entryid;",false);
-
-      modify_database('','ALTER TABLE prefix_glossary ADD INDEX course (course);');
-      modify_database('','ALTER TABLE prefix_glossary_alias ADD INDEX entryid (entryid);');
-      modify_database('','ALTER TABLE prefix_glossary_categories ADD INDEX glossaryid (glossaryid);');
-      modify_database('','ALTER TABLE prefix_glossary_comments ADD INDEX entryid (entryid);');
-      modify_database('','ALTER TABLE prefix_glossary_comments ADD INDEX userid (userid);');
-      modify_database('','ALTER TABLE prefix_glossary_entries ADD INDEX glossaryid (glossaryid);');
-      modify_database('','ALTER TABLE prefix_glossary_entries ADD INDEX userid (userid);');
-      modify_database('','ALTER TABLE prefix_glossary_entries ADD INDEX concept (concept);');
-      modify_database('','ALTER TABLE prefix_glossary_entries_categories ADD INDEX entryid (entryid);');
-      modify_database('','ALTER TABLE prefix_glossary_entries_categories ADD INDEX categoryid (categoryid);');
-      modify_database('','ALTER TABLE prefix_glossary_ratings ADD INDEX userid (userid);');
-      modify_database('','ALTER TABLE prefix_glossary_ratings ADD INDEX entryid (entryid);');
-
-  }
-
-  //Delete orphaned categories (bug 2140)
-  if ($oldversion < 2005011100) {
-      $categories = get_records('glossary_categories', '', '', '', 'id, glossaryid');
-      if ($categories) {
-          foreach ($categories as $category) {
-              $glossary = get_record('glossary', 'id', "$category->glossaryid");
-              if (!$glossary) {
-                  delete_records('glossary_categories', 'id', "$category->id");
-              }
-          }
-      }
-  }
-
-  //Allowprintview flag
-  if ($oldversion < 2005011200) {
-      table_column('glossary','','allowprintview','tinyint','2', 'unsigned', '1', '', 'allowcomments');
-      $glossaries = get_records('glossary', '', '', '', 'id, name');
-      if ($glossaries) {
-          foreach ($glossaries as $glossary) { 
-              set_field('glossary', 'allowprintview', '1', 'id', "$glossary->id");
-          }
-      }
-  }
-
-  if ($oldversion < 2005031001) {
-      modify_database('',"INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('glossary', 'view entry', 'glossary_entries', 'concept');");
-  }
-    
-    if ($oldversion < 2005041100) { // replace wiki-like with markdown
-        include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
-        $wtm = new WikiToMarkdown();
-        // update glossary_entries->definition
-        $sql = "select course from {$CFG->prefix}glossary,{$CFG->prefix}glossary_entries ";
-        $sql .= "where {$CFG->prefix}glossary.id = {$CFG->prefix}glossary_entries.glossaryid ";
-        $sql .= "and {$CFG->prefix}glossary_entries.id = ";
-        $wtm->update( 'glossary_entries','definition','format' );
-        // update glossary_comments->text
-        $sql = "select course from {$CFG->prefix}glossary,{$CFG->prefix}glossary_entries,{$CFG->prefix}glossary_comments ";
-        $sql .= "where {$CFG->prefix}glossary.id = {$CFG->prefix}glossary_entries.glossaryid ";
-        $sql .= "and {$CFG->prefix}glossary_entries.id = {$CFG->prefix}glossary_comments.entryid ";
-        $sql .= "and {$CFG->prefix}glossary_comments.id = ";
-        $wtm->update( 'glossary_comments','text','format',$sql );
-    }
-
-    if ($oldversion < 2006082600) {
-        $sql1 = "UPDATE {$CFG->prefix}glossary_entries SET definition = REPLACE(definition, '".TRUSTTEXT."', '');";
-        $sql2 = "UPDATE {$CFG->prefix}glossary_comments SET comment = REPLACE(comment, '".TRUSTTEXT."', '');";
-        $likecond = sql_ilike()." '%".TRUSTTEXT."%'";
-        while (true) {
-            if (!count_records_select('glossary_entries', "definition $likecond")) {
-                break;
-            }
-            execute_sql($sql1);
-        }
-        while (true) {
-            if (!count_records_select('glossary_comments', "comment $likecond")) {
-                break;
-            }
-            execute_sql($sql2);
-        }
-    }
-
-    if ($oldversion < 2006090400) {
-         table_column('glossary_comments', 'comment', 'entrycomment', 'text', '', '', '');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/mod/glossary/db/postgres7.php b/mod/glossary/db/postgres7.php
deleted file mode 100644 (file)
index f56614a..0000000
+++ /dev/null
@@ -1,217 +0,0 @@
-<?php  // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function glossary_upgrade($oldversion) {
-/// This function does anything necessary to upgrade 
-/// older versions to match current functionality 
-
-    global $CFG;
-
-    if ($oldversion < 2004022200) {
-        if (!empty($CFG->textfilters)) {
-            $CFG->textfilters = str_replace("dynalink.php", "filter.php", $CFG->textfilters);
-            set_config("textfilters", $CFG->textfilters);
-        }
-    }
-
-  if ($oldversion < 2004050900) {
-      table_column("glossary","","rsstype","integer","2", "unsigned", "0", "", "entbypage");
-      table_column("glossary","","rssarticles","integer","2", "unsigned", "0", "", "rsstype");
-      set_config("glossary_enablerssfeeds",0);
-  }
-
-  if ( $oldversion < 2004051400 ) {
-        print_simple_box("This update might take several seconds.<p>The more glossaries, entries and aliases you have created, the more it will take so please be patient.","center", "50%", '', "20", "noticebox");
-        if ( $entries = get_records("glossary_entries", '', '', '', 'id,concept')) {
-            foreach($entries as $entry) {
-                set_field("glossary_entries","concept",addslashes(trim($entry->concept)),"id",$entry->id);
-            }
-        }       
-        if ( $aliases = get_records("glossary_alias")) {
-            foreach($aliases as $alias) {
-                set_field("glossary_alias","alias",addslashes(trim($alias->alias)),"id",$alias->id);
-            }
-        }
-  }
-
-  if ( $oldversion < 2004072300) {
-      table_column("glossary_alias", "alias", "alias", "VARCHAR", "255", "", "", "NOT NULL");
-  }
-
-  if ( $oldversion < 2004072400) {
-
-      //Create new table glossary_formats to store format info
-      execute_sql("CREATE TABLE {$CFG->prefix}glossary_formats (
-                       id SERIAL8 PRIMARY KEY,
-                       name VARCHAR(50) NOT NULL,
-                       popupformatname VARCHAR(50) NOT NULL, 
-                       visible int2  NOT NULL default '1',
-                       showgroup int2  NOT NULL default '1',
-                       defaultmode VARCHAR(50) NOT NULL default '',
-                       defaulthook VARCHAR(50) NOT NULL default '',
-                       sortkey VARCHAR(50) NOT NULL default '',
-                       sortorder VARCHAR(50) NOT NULL default ''
-                   ) ");
-
-      //Define current 0-6 format names
-      $formatnames = array('dictionary','continuous','fullwithauthor','encyclopedia',
-                           'faq','fullwithoutauthor','entrylist');
-
-      //Fill the new table from the old one (only 'valid', 0-6, formats)
-      if ($formats = get_records('glossary_displayformats')) {
-          foreach ($formats as $format) {
-              //Format names
-              if ($format->fid >= 0 && $format->fid <= 6) {
-                  $format->name = $formatnames[$format->fid];
-              }
-
-              //Format popupformatname
-              $format->popupformatname = 'dictionary';  //Default format
-              if ($format->relatedview >= 0 && $format->relatedview <= 6) {
-                  $format->popupformatname = $formatnames[$format->relatedview];
-              }
-
-              //Insert the new record
-              //Only if $format->name is set (ie. formats 0-6)
-              if ($format->name) {
-                  insert_record('glossary_formats',$format);
-              }
-              
-          }
-      }
-
-      //Drop the old formats table
-      execute_sql("DROP TABLE {$CFG->prefix}glossary_displayformats");
-
-      //Modify the glossary->displayformat field
-      table_column('glossary', 'displayformat', 'displayformat', 'VARCHAR', '50', '', 'dictionary', 'NOT NULL');
-
-      //Update glossary->displayformat field
-      if ($glossaries = get_records('glossary')) {
-          foreach($glossaries as $glossary) {
-              $displayformat = 'dictionary';  //Default format
-              if ($glossary->displayformat >= 0 && $glossary->displayformat <= 6) {
-                  $displayformat = $formatnames[$glossary->displayformat];
-              }
-              set_field('glossary','displayformat',$displayformat,'id',$glossary->id);
-          }
-      }
-  }
-
-  if ( $oldversion < 2004080800) {
-      table_column("glossary","","editalways","integer","2", "unsigned", "0", "", "entbypage");
-  }
-
-  //Activate editalways in old secondary glossaries (old behaviour)
-  if ( $oldversion < 2004080900) {
-      set_field('glossary','editalways','1','mainglossary','0');
-  }
-
-  if ($oldversion < 2004111200) {
-      execute_sql("DROP INDEX {$CFG->prefix}glossary_course_idx;",false);
-      execute_sql("DROP INDEX {$CFG->prefix}glossary_alias_entryid_idx;",false);
-      execute_sql("DROP INDEX {$CFG->prefix}glossary_categories_glossaryid_idx;",false); 
-      execute_sql("DROP INDEX {$CFG->prefix}glossary_comments_entryid_idx;",false); 
-      execute_sql("DROP INDEX {$CFG->prefix}glossary_comments_userid_idx;",false); 
-      execute_sql("DROP INDEX {$CFG->prefix}glossary_entries_glossaryid_idx;",false);
-      execute_sql("DROP INDEX {$CFG->prefix}glossary_entries_userid_idx;",false); 
-      execute_sql("DROP INDEX {$CFG->prefix}glossary_entries_concept_idx;",false);
-      execute_sql("DROP INDEX {$CFG->prefix}glossary_entries_categories_category_idx;",false);
-      execute_sql("DROP INDEX {$CFG->prefix}glossary_entries_categories_entryid_idx;",false);
-      execute_sql("DROP INDEX {$CFG->prefix}glossary_ratings_userid_idx;",false); 
-      execute_sql("DROP INDEX {$CFG->prefix}glossary_ratings_entryid_idx;",false);
-
-      modify_database('','CREATE INDEX prefix_glossary_course_idx ON prefix_glossary (course);');
-      modify_database('','CREATE INDEX prefix_glossary_alias_entryid_idx ON prefix_glossary_alias (entryid);');
-      modify_database('','CREATE INDEX prefix_glossary_categories_glossaryid_idx ON prefix_glossary_categories (glossaryid);');
-      modify_database('','CREATE INDEX prefix_glossary_comments_entryid_idx ON prefix_glossary_comments (entryid);');
-      modify_database('','CREATE INDEX prefix_glossary_comments_userid_idx ON prefix_glossary_comments (userid);');
-      modify_database('','CREATE INDEX prefix_glossary_entries_glossaryid_idx ON prefix_glossary_entries (glossaryid);');
-      modify_database('','CREATE INDEX prefix_glossary_entries_userid_idx ON prefix_glossary_entries (userid);');
-      modify_database('','CREATE INDEX prefix_glossary_entries_concept_idx ON prefix_glossary_entries (concept);');
-      modify_database('','CREATE INDEX prefix_glossary_entries_categories_category_idx ON prefix_glossary_entries_categories (categoryid);');
-      modify_database('','CREATE INDEX prefix_glossary_entries_categories_entryid_idx ON prefix_glossary_entries_categories (entryid);');
-      modify_database('','CREATE INDEX prefix_glossary_ratings_userid_idx ON prefix_glossary_ratings (userid);');
-      modify_database('','CREATE INDEX prefix_glossary_ratings_entryid_idx ON prefix_glossary_ratings (entryid);');
-  }
-
-  //Delete orphaned categories (bug 2140)
-  if ($oldversion < 2005011100) {
-      $categories = get_records('glossary_categories', '', '', '', 'id, glossaryid');
-      if ($categories) {
-          foreach ($categories as $category) {
-              $glossary = get_record('glossary', 'id', "$category->glossaryid");
-              if (!$glossary) {
-                  delete_records('glossary_categories', 'id', "$category->id");
-              }
-          }
-      }
-  }
-
-  //Allowprintview flag
-  if ($oldversion < 2005011200) {
-      table_column('glossary','','allowprintview','integer','2', 'unsigned', '1', '', 'allowcomments');
-      $glossaries = get_records('glossary', '', '', '', 'id, name');
-      if ($glossaries) {
-          foreach ($glossaries as $glossary) {
-              set_field('glossary', 'allowprintview', '1', 'id', "$glossary->id");
-          }
-      }
-  }
-
-  if ($oldversion < 2005031001) {
-      modify_database('',"INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('glossary', 'view entry', 'glossary_entries', 'concept');");
-  }
-
-    if ($oldversion < 2005041100) { // replace wiki-like with markdown
-        include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
-        $wtm = new WikiToMarkdown();
-        // update glossary_entries->definition
-        $sql = "select course from {$CFG->prefix}glossary,{$CFG->prefix}glossary_entries ";
-        $sql .= "where {$CFG->prefix}glossary.id = {$CFG->prefix}glossary_entries.glossaryid ";
-        $sql .= "and {$CFG->prefix}glossary_entries.id = ";
-        $wtm->update( 'glossary_entries','definition','format' );
-        // update glossary_comments->text
-        $sql = "select course from {$CFG->prefix}glossary,{$CFG->prefix}glossary_entries,{$CFG->prefix}glossary_comments ";
-        $sql .= "where {$CFG->prefix}glossary.id = {$CFG->prefix}glossary_entries.glossaryid ";
-        $sql .= "and {$CFG->prefix}glossary_entries.id = {$CFG->prefix}glossary_comments.entryid ";
-        $sql .= "and {$CFG->prefix}glossary_comments.id = ";
-        $wtm->update( 'glossary_comments','text','format',$sql );
-    }
-
-    if ($oldversion < 2005041901) { // Mass cleanup of bad postgres upgrade scripts
-        table_column('glossary','allowprintview','allowprintview','smallint','4','unsigned','1');
-    }
-
-    if ($oldversion < 2006082600) {
-        $sql1 = "UPDATE {$CFG->prefix}glossary_entries SET definition = REPLACE(definition, '".TRUSTTEXT."', '');";
-        $sql2 = "UPDATE {$CFG->prefix}glossary_comments SET comment = REPLACE(comment, '".TRUSTTEXT."', '');";
-        $likecond = sql_ilike()." '%".TRUSTTEXT."%'";
-        while (true) {
-            if (!count_records_select('glossary_entries', "definition $likecond")) {
-                break;
-            }
-            execute_sql($sql1);
-        }
-        while (true) {
-            if (!count_records_select('glossary_comments', "comment $likecond")) {
-                break;
-            }
-            execute_sql($sql2);
-        }
-    }
-
-    if ($oldversion < 2006090400) {
-        table_column('glossary_comments', 'comment', 'entrycomment', 'text', '', '', '');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/mod/hotpot/db/mysql.php b/mod/hotpot/db/mysql.php
deleted file mode 100644 (file)
index cc7ea3c..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<?PHP
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function hotpot_upgrade($oldversion) {
-    global $CFG;
-    $ok = true;
-
-    // set path to update functions
-    $update_to_v2 = "$CFG->dirroot/mod/hotpot/db/update_to_v2.php";
-
-    // if the version number indicates this could be an early HotPot v2.1 (Moodle 1.6),
-    // check this is not actually HotPot v1 or v2.0 (Moodle 1.5) with an overly advanced version number
-    if ($oldversion>2005031400 && $oldversion<=2006082899) {
-        require_once $update_to_v2;
-        if (hotpot_db_table_exists('hotpot_attempts')) {
-            if (hotpot_db_field_exists('hotpot_attempts', 'details')) {
-                // HotPot v2.0 (Moodle 1.5)
-                $oldversion = 2005031400;
-            }
-        } else {
-            // HotPot v1
-            $oldversion = 2004122000;
-        }
-    }
-
-    if ($oldversion < 2004021400) {
-        execute_sql(" ALTER TABLE `{$CFG->prefix}hotpot_events` ADD `starttime` INT(10) unsigned NOT NULL DEFAULT '0' AFTER `time`");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}hotpot_events` ADD `endtime` INT(10) unsigned NOT NULL DEFAULT '0' AFTER `time`");
-    }
-
-    // update from HotPot v1 to HotPot v2
-    if ($oldversion < 2005031400) {
-        require_once $update_to_v2;
-        $ok = $ok && hotpot_update_to_v2_from_v1();
-    }
-    if ($oldversion < 2005090700) {
-        require_once $update_to_v2;
-        $ok = $ok && hotpot_update_to_v2_1();
-    }
-    if ($oldversion > 2005031419 && $oldversion < 2005090702) {
-        // update to from HotPot v2.1.0 or v2.1.1
-        require_once $update_to_v2;
-        $ok = $ok && hotpot_update_to_v2_1_2();
-    }
-    if ($oldversion < 2006042103) {
-        require_once $update_to_v2;
-        $ok = $ok && hotpot_update_to_v2_1_16();
-    }
-    if ($oldversion < 2006042601) {
-        require_once $update_to_v2;
-        $ok = $ok && hotpot_update_to_v2_1_17();
-    }
-    if ($oldversion < 2006042803) {
-        require_once $update_to_v2;
-        $ok = $ok && hotpot_update_to_v2_1_18();
-    }
-    if ($oldversion < 2006083101) {
-        require_once $update_to_v2;
-        $ok = $ok && hotpot_update_to_v2_2();
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return $ok;
-}
-?>
diff --git a/mod/hotpot/db/postgres7.php b/mod/hotpot/db/postgres7.php
deleted file mode 100644 (file)
index bda3cf9..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-<?PHP
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function hotpot_upgrade($oldversion) {
-    global $CFG;
-    $ok = true;
-
-    // set path to update functions
-    $update_to_v2 = "$CFG->dirroot/mod/hotpot/db/update_to_v2.php";
-
-    // if the version number indicates this could be an early HotPot v2.1 (Moodle 1.6),
-    // check this is not actually HotPot v2.0 (Moodle 1.5) with an overly advanced version number
-    if ($oldversion>2005031400 && $oldversion<=2006082899) {
-        require_once $update_to_v2;
-        if (hotpot_db_field_exists('hotpot_attempts', 'details')) {
-            $oldversion = 2005031400;
-        }
-    }
-
-    // update from HotPot v1 to HotPot v2
-    if ($oldversion < 2005031400) {
-        require_once $update_to_v2;
-        $ok = $ok && hotpot_update_to_v2_from_v1();
-    }
-
-    // update to HotPot v2.1
-    if ($oldversion < 2005090700) {
-        require_once $update_to_v2;
-        $ok = $ok && hotpot_update_to_v2_1();
-    }
-    if ($oldversion > 2005031419 && $oldversion < 2005090702) {
-        require_once $update_to_v2;
-        $ok = $ok && hotpot_update_to_v2_1_2();
-    }
-    if ($oldversion < 2005090706) {
-        require_once $update_to_v2;
-        $ok = $ok && hotpot_update_to_v2_1_6();
-    }
-    if ($oldversion < 2005090708) {
-        require_once $update_to_v2;
-        $ok = $ok && hotpot_update_to_v2_1_8();
-    }
-    if ($oldversion < 2006042103) {
-        require_once $update_to_v2;
-        $ok = $ok && hotpot_update_to_v2_1_16();
-    }
-    if ($oldversion < 2006042602) {
-        require_once $update_to_v2;
-        $ok = $ok && hotpot_update_to_v2_1_17();
-    }
-    if ($oldversion < 2006042803) {
-        require_once $update_to_v2;
-        $ok = $ok && hotpot_update_to_v2_1_18();
-    }
-    if ($oldversion < 2006071600) {
-        require_once $update_to_v2;
-        $ok = $ok && hotpot_update_to_v2_1_21();
-    }
-    if ($oldversion < 2006083101) {
-        require_once $update_to_v2;
-        $ok = $ok && hotpot_update_to_v2_2();
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return $ok;
-}
-?>
diff --git a/mod/hotpot/db/update_to_v2.php b/mod/hotpot/db/update_to_v2.php
deleted file mode 100644 (file)
index 0dd79c5..0000000
+++ /dev/null
@@ -1,1392 +0,0 @@
-<?PHP
-if (file_exists("$CFG->dirroot/lib/ddllib.php")) {
-    // Moodle 1.8+
-    include_once "$CFG->dirroot/lib/ddllib.php";
-}
-
-function hotpot_update_to_v2_2() {
-    global $CFG;
-    $ok = true;
-
-    // remove the index on hotpot_questions.name
-    $table = 'hotpot_questions';
-    $field = 'name';
-    if (strtolower($CFG->dbfamily)=='postgres') {
-        $index = "{$CFG->prefix}{$table}_{$field}_idx";
-    } else {
-        $index = "{$table}_{$field}_idx";
-       }
-    hotpot_db_delete_index("{$CFG->prefix}$table", $index);
-    
-    // add new hotpot_questions.md5key field (and index)
-    $table = 'hotpot_questions';
-    $field = 'md5key';
-    $ok = $ok && hotpot_db_update_field_type($table, '', $field, 'VARCHAR', 32, '', 'NOT NULL', '');
-    $ok = $ok && hotpot_db_add_index($table, $field);
-
-    // add new values hotpot_questions.md5key
-    $table = 'hotpot_questions';
-    if ($records = get_records($table)) {
-        foreach ($records as $record) {
-            $ok = $ok && set_field($table, 'md5key', md5($record->name), 'id', $record->id);
-        }
-    }
-    
-    // remove the index on hotpot_strings.string
-    $table = 'hotpot_strings';
-    $field = 'string';
-    if (strtolower($CFG->dbfamily)=='postgres') {
-        $index = "{$CFG->prefix}{$table}_{$field}_idx";
-    } else {
-        $index = "{$table}_{$field}_idx";
-       }
-    hotpot_db_delete_index("{$CFG->prefix}$table", $index);
-
-    // add new hotpot_strings.md5key field (and index)
-    $table = 'hotpot_strings';
-    $field = 'md5key';
-    $ok = $ok && hotpot_db_update_field_type($table, '', $field, 'VARCHAR', 32, '', 'NOT NULL', '');
-    $ok = $ok && hotpot_db_add_index($table, $field);
-
-    // add new values hotpot_strings.md5key
-    $table = 'hotpot_strings';
-    if ($records = get_records($table)) {
-        foreach ($records as $record) {
-            $ok = $ok && set_field($table, 'md5key', md5($record->string), 'id', $record->id);
-        }
-    }
-    
-    return $ok;
-}
-function hotpot_update_to_v2_1_21() {
-    global $CFG;
-    $ok = true;
-
-    if (strtolower($CFG->dbfamily)=='postgres') {
-        // ensure setting of default values on certain fields
-        // this was originally done in postgres7.php, but was found to be incompatible with PG7 :-(
-        $table="hotpot";
-        execute_sql("UPDATE {$CFG->prefix}$table SET studentfeedbackurl = '' WHERE studentfeedbackurl IS NULL");
-        $ok = $ok && hotpot_db_update_field_type($table, '', 'studentfeedbackurl', 'VARCHAR', 255, '',         'NOT NULL', '');
-        $ok = $ok && hotpot_db_update_field_type($table, '', 'studentfeedback',    'INTEGER', 4,   'UNSIGNED', 'NOT NULL', 0);
-        $ok = $ok && hotpot_db_update_field_type($table, '', 'clickreporting',     'INTEGER', 4,   'UNSIGNED', 'NOT NULL', 0);
-
-        $table="hotpot_attempts";
-        $ok = $ok && hotpot_db_update_field_type($table, '', 'score',     'INTEGER', 4, 'UNSIGNED', 'NOT NULL', 0);
-        $ok = $ok && hotpot_db_update_field_type($table, '', 'penalties', 'INTEGER', 4, 'UNSIGNED', 'NOT NULL', 0);
-        $ok = $ok && hotpot_db_update_field_type($table, '', 'status',    'INTEGER', 4, 'UNSIGNED', 'NOT NULL', 1);
-
-        $table="hotpot_questions";
-        $ok = $ok && hotpot_db_update_field_type($table, '', 'type',      'INTEGER', 4, 'UNSIGNED', 'NOT NULL', 0);
-
-        $table="hotpot_responses";
-        $ok = $ok && hotpot_db_update_field_type($table, '', 'score',     'INTEGER', 4,   'UNSIGNED', 'NOT NULL', 0);
-        $ok = $ok && hotpot_db_update_field_type($table, '', 'weighting', 'INTEGER', 4,   'UNSIGNED', 'NOT NULL', 0);
-        $ok = $ok && hotpot_db_update_field_type($table, '', 'correct',   'VARCHAR', 255, '',         'NOT NULL', '');
-        execute_sql("UPDATE {$CFG->prefix}$table SET wrong = '' WHERE wrong IS NULL");
-        $ok = $ok && hotpot_db_update_field_type($table, '', 'wrong',     'VARCHAR', 255, '',         'NOT NULL', '');
-        execute_sql("UPDATE {$CFG->prefix}$table SET ignored = '' WHERE ignored IS NULL");
-        $ok = $ok && hotpot_db_update_field_type($table, '', 'ignored',   'VARCHAR', 255, '',         'NOT NULL', '');
-        $ok = $ok && hotpot_db_update_field_type($table, '', 'hints',     'INTEGER', 4,   'UNSIGNED', 'NOT NULL', 0);
-        $ok = $ok && hotpot_db_update_field_type($table, '', 'clues',     'INTEGER', 4,   'UNSIGNED', 'NOT NULL', 0);
-        $ok = $ok && hotpot_db_update_field_type($table, '', 'checks',    'INTEGER', 4,   'UNSIGNED', 'NOT NULL', 0);
-
-        $table="hotpot_strings";
-        $ok = $ok && hotpot_db_update_field_type($table, '', 'string', 'TEXT', '', '', 'NOT NULL', '');
-    }
-
-    return $ok;
-}
-function hotpot_update_to_v2_1_18() {
-    $ok = true;
-
-    // remove all orphan records (there shouldn't be any, but if there are they can mess up the utfdbmigrate)
-
-    $ok = $ok && hotpot_remove_orphans('hotpot_attempts', 'hotpot', 'hotpot');
-    $ok = $ok && hotpot_remove_orphans('hotpot_questions', 'hotpot', 'hotpot');
-    $ok = $ok && hotpot_remove_orphans('hotpot_responses', 'attempt', 'hotpot_attempts');
-    $ok = $ok && hotpot_remove_orphans('hotpot_responses', 'question', 'hotpot_questions');
-    $ok = $ok && hotpot_remove_orphans('hotpot_details', 'attempt', 'hotpot_attempts');
-
-    // allow negative weighting and scores
-
-    $ok = $ok && hotpot_denull_int_field('hotpot_responses', 'weighting', '6', false);
-    $ok = $ok && hotpot_denull_int_field('hotpot_responses', 'score', '6', false);
-
-    return $ok;
-}
-function hotpot_remove_orphans($secondarytable, $secondarykeyfield, $primarytable, $primarykeyfield='id') {
-    global $CFG,$db;
-    $ok = true;
-
-    // save and switch off SQL message echo
-    $debug = $db->debug;
-    $db->debug = false;
-
-    $records = get_records_sql("
-        SELECT 
-            t2.$secondarykeyfield, t2.$secondarykeyfield
-        FROM 
-            {$CFG->prefix}$secondarytable t2 LEFT JOIN {$CFG->prefix}$primarytable t1 
-            ON (t2.$secondarykeyfield = t1.id)
-        WHERE 
-            t1.$primarykeyfield IS NULL
-    ");
-
-    // restore SQL message echo setting
-    $db->debug = $debug;
-
-    if ($records) {
-        $keys = implode(',', array_keys($records));
-        print "removing orphan record(s) from {$CFG->prefix}$secondarytable<br/>";
-        $ok = $ok && execute_sql("DELETE FROM {$CFG->prefix}$secondarytable WHERE $secondarykeyfield IN ($keys)");
-    }
-
-    return $ok;
-}
-function hotpot_update_to_v2_1_17() {
-    global $CFG;
-    $ok = true;
-
-    // convert and disable null values on certain numeric fields
-
-    $ok = $ok && hotpot_denull_int_field('hotpot_attempts', 'starttime', '10');
-    $ok = $ok && hotpot_denull_int_field('hotpot_attempts', 'endtime', '10');
-    $ok = $ok && hotpot_denull_int_field('hotpot_attempts', 'score', '6');
-    $ok = $ok && hotpot_denull_int_field('hotpot_attempts', 'penalties',  '6');
-    $ok = $ok && hotpot_denull_int_field('hotpot_attempts', 'timestart', '10');
-    $ok = $ok && hotpot_denull_int_field('hotpot_attempts', 'timefinish', '10');
-    $ok = $ok && hotpot_denull_int_field('hotpot_attempts', 'clickreportid', '10');
-
-    $ok = $ok && hotpot_denull_int_field('hotpot_questions', 'type', '4');
-    $ok = $ok && hotpot_denull_int_field('hotpot_questions', 'text', '10');
-
-    $ok = $ok && hotpot_denull_int_field('hotpot_responses', 'weighting', '6', false);
-    $ok = $ok && hotpot_denull_int_field('hotpot_responses', 'score', '6', false);
-    $ok = $ok && hotpot_denull_int_field('hotpot_responses', 'hints', '6');
-    $ok = $ok && hotpot_denull_int_field('hotpot_responses', 'clues', '6');
-    $ok = $ok && hotpot_denull_int_field('hotpot_responses', 'checks', '6');
-    return $ok;
-}
-function hotpot_denull_int_field($table, $field, $size, $unsigned=true) {
-    global $CFG;
-    $ok = true;
-
-    $ok = $ok && execute_sql("UPDATE {$CFG->prefix}$table SET $field=0 WHERE $field IS NULL", false);
-    if ($unsigned) {
-        $ok = $ok && execute_sql("UPDATE {$CFG->prefix}$table SET $field=0 WHERE $field<0", false);
-    }
-    $ok = $ok && hotpot_db_update_field_type($table, $field, $field, 'INTEGER', $size, $unsigned, 'NOT NULL', 0);
-
-    return $ok;
-}
-function hotpot_update_to_v2_1_16() {
-    global $CFG;
-    $ok = true;
-
-    // remove the questions name index
-    hotpot_db_delete_index("{$CFG->prefix}hotpot_questions", "hotpot_questions_name_idx");
-    hotpot_db_delete_index("{$CFG->prefix}hotpot_questions", "{$CFG->prefix}hotpot_questions_name_idx");
-
-    // make sure type of 'name' is a text field (not varchar 255)
-    $ok = $ok && hotpot_db_update_field_type('hotpot_questions', 'name', 'name', 'TEXT',   '',  '', 'NOT NULL', '');
-
-    if (strtolower($CFG->dbfamily)=='mysql') {
-
-        // set default values on certain VARCHAR(255) fields
-        $fields = array(
-            'hotpot' => 'studentfeedbackurl',
-            'hotpot_responses' => 'correct',
-            'hotpot_responses' => 'wrong',
-            'hotpot_responses' => 'ignored'
-        );
-        foreach ($fields as $table=>$field) {
-            execute_sql("UPDATE {$CFG->prefix}$table SET $field='' WHERE $field IS NULL");
-            $ok = $ok && hotpot_db_update_field_type($table, $field, $field, 'VARCHAR', 255, '', 'NOT NULL', '');
-        }
-
-        // remove $CFG->prefix from all index names
-        $ok = $ok && hotpot_index_remove_prefix('hotpot_attempts', 'hotpot');
-        $ok = $ok && hotpot_index_remove_prefix('hotpot_attempts', 'userid');
-        $ok = $ok && hotpot_index_remove_prefix('hotpot_details', 'attempt');
-        $ok = $ok && hotpot_index_remove_prefix('hotpot_questions', 'hotpot');
-        $ok = $ok && hotpot_index_remove_prefix('hotpot_responses', 'attempt');
-        $ok = $ok && hotpot_index_remove_prefix('hotpot_responses', 'question');
-    }
-    return $ok;
-}
-function hotpot_index_remove_prefix($table, $field) {
-    global $CFG;
-    hotpot_db_delete_index("{$CFG->prefix}$table", "{$CFG->prefix}{$table}_{$field}_idx");
-    hotpot_db_delete_index("{$CFG->prefix}$table", "{$table}_{$field}_idx");
-    return hotpot_db_add_index($table, $field);
-}
-
-function hotpot_update_to_v2_1_8() {
-    global $CFG;
-    $ok = true;
-    if (strtolower($CFG->dbfamily)=='postgres') {
-        // add, delete and rename certain fields and indexes
-        // that were not correctly setup by postgres7.sql
-
-        // hotpot
-        $table = 'hotpot';
-        if (hotpot_db_field_exists($table, 'microreporting')) {
-            $ok = $ok && hotpot_db_update_field_type($table, 'microreporting', 'clickreporting', 'INTEGER', 4, 'UNSIGNED', 'NOT NULL', '0');
-        }
-    }
-    return $ok;
-}
-function hotpot_update_to_v2_1_6() {
-    global $CFG;
-    $ok = true;
-
-    if (strtolower($CFG->dbfamily)=='postgres') {
-        // add, delete and rename certain fields and indexes
-        // that were not correctly setup by postgres7.sql
-
-        // hotpot
-        $table = 'hotpot';
-        if (hotpot_db_field_exists($table, 'studentfeedback') && !hotpot_db_field_exists($table, 'studentfeedbackurl')) {
-            $ok = $ok && hotpot_db_update_field_type($table, 'studentfeedback', 'studentfeedbackurl', 'VARCHAR', 255, '', 'NULL');
-            $ok = $ok && hotpot_db_update_field_type($table, '', 'studentfeedback', 'INTEGER', 4, 'UNSIGNED', 'NOT NULL', '0');
-        }
-
-        // hotpot_attempts
-        $table = 'hotpot_attempts';
-        $ok = $ok && hotpot_db_remove_field($table, 'groupid');
-        if (hotpot_db_field_exists($table, 'microreportid') && !hotpot_db_field_exists($table, 'clickreportid')) {
-            $ok = $ok && hotpot_db_update_field_type($table, 'microreportid', 'clickreportid', 'INTEGER', 10, 'UNSIGNED', 'NULL');
-        }
-    }
-
-    return $ok;
-}
-function hotpot_update_to_v2_1_2() {
-    global $CFG, $db;
-    $ok = true;
-
-    // save and switch off SQL message echo
-    $debug = $db->debug;
-    $db->debug = false;
-
-    // extract info about attempts by each user on each hotpot (cases where 
-    // the user has only one attempt, or no "in progess" attempt are ignored)
-    $rs = $db->Execute("
-        SELECT userid, hotpot, COUNT(*), MIN(status)
-        FROM {$CFG->prefix}hotpot_attempts
-        GROUP BY userid, hotpot
-        HAVING COUNT(*)>1 AND MIN(status)=1
-    ");
-    if ($rs && $rs->RecordCount()) {
-        $records = $rs->GetArray();
-
-        // start message to browser
-        print "adjusting status of ".count($records)." &quot;in progress&quot; attempts ... ";
-
-        // loop through records
-        foreach ($records as $record) {
-
-            // get all attempts by this user at this hotpot
-            $attempts = get_records_sql("
-                SELECT id, userid, hotpot, score, timestart, timefinish, status 
-                FROM {$CFG->prefix}hotpot_attempts 
-                WHERE userid = ".$record['userid']." AND hotpot=".$record['hotpot']."
-                ORDER BY timestart DESC, id DESC
-            ");
-
-            unset($previous_timestart);
-
-            foreach ($attempts as $attempt) {
-                // if this attempt has a status of "in progress" and is not 
-                // the most recent one in the group, set the status to "abandoned"
-                if ($attempt->status==1 && isset($previous_timestart)) {
-                    $values = 'status=3';
-                    if (empty($attempt->score)) {
-                        $values .= ',score=0';
-                    }
-                    if (empty($attempt->timefinish)) {
-                        $values .= ",timefinish=$previous_timestart";
-                    }
-                    execute_sql("UPDATE {$CFG->prefix}hotpot_attempts SET $values WHERE id=$attempt->id", false);
-                    print ".";
-                    hotpot_flush(300);
-                }
-                $previous_timestart = $attempt->timestart;
-            } // end foreach $attempts
-        } // end foreach $records
-
-        // finish message to browser
-        print $ok ? get_string('success') : 'failed';
-        print "<br />\n";
-    }
-
-    // restore SQL message echo setting
-    $db->debug = $debug;
-
-    return $ok;
-}
-function hotpot_update_to_v2_1() {
-    global $CFG, $db;
-    $ok = true;
-    // hotpot_questions: reduce size of "type" field to "4"
-    $ok = $ok && hotpot_db_update_field_type('hotpot_questions', 'type', 'type', 'INTEGER', 4,  'UNSIGNED', 'NULL');
-    // hotpot_questions: change type of "name" field to "text"
-    $ok = $ok && hotpot_db_update_field_type('hotpot_questions', 'name', 'name', 'TEXT',   '',  '', 'NOT NULL', '');
-    // hotpot_questions: nullify empty and non-numeric (shouldn't be any) values in "text" field
-    switch (strtolower($CFG->dbfamily)) {
-        case 'mysql' : 
-            $NOT_REGEXP = 'NOT REGEXP';
-        break;
-        case 'postgres' :
-            $NOT_REGEXP = '!~';
-        break;
-        default:
-            $NOT_REGEXP = '';
-        break;
-    }
-    if ($NOT_REGEXP) {
-        $ok = $ok && execute_sql("UPDATE {$CFG->prefix}hotpot_questions SET text=NULL WHERE text $NOT_REGEXP '^[0-9]+$'");
-    }
-    // hotpot_questions: change type of "text" field to "INT(10)"
-    $ok = $ok && hotpot_db_update_field_type('hotpot_questions', 'text', 'text', 'INTEGER', 10, 'UNSIGNED', 'NULL');
-    // hotpot_attempts
-    // hotpot_attempts: move "details" to separate table
-    $table = 'hotpot_details';
-    if (hotpot_db_table_exists($table)) {
-        // do nothing
-    } else {
-        $ok = $ok && hotpot_create_table($table);
-        switch (strtolower($CFG->dbfamily)) {
-            case 'mysql' : 
-            case 'postgres' :
-                $sql = "
-                    INSERT INTO {$CFG->prefix}$table (attempt, details) 
-                    SELECT a.id AS attempt, a.details AS details
-                        FROM {$CFG->prefix}hotpot_attempts a
-                        WHERE 
-                            a.details IS NOT NULL AND a.details <> ''
-                            AND a.details LIKE '<?xml%' AND a.details LIKE '%</hpjsresult>'
-                ";
-            break;
-            default:
-                $sql = '';
-            break;
-        }
-        if ($sql) {
-            $ok = $ok && execute_sql($sql);
-        }
-    }
-    // hotpot_attempts: remove the "details" field
-    $ok = $ok && hotpot_db_remove_field('hotpot_attempts', 'details');
-    // hotpot_attempts: create and set status field (1=in-progress, 2=timed-out, 3=abandoned, 4=completed)
-    $ok = $ok && hotpot_db_update_field_type('hotpot_attempts', '', 'status', 'INTEGER', 4, 'UNSIGNED', 'NOT NULL', 1);
-    $ok = $ok && execute_sql("UPDATE {$CFG->prefix}hotpot_attempts SET status=1 WHERE timefinish=0 AND SCORE IS NULL");
-    $ok = $ok && execute_sql("UPDATE {$CFG->prefix}hotpot_attempts SET status=3 WHERE timefinish>0 AND SCORE IS NULL");
-    $ok = $ok && execute_sql("UPDATE {$CFG->prefix}hotpot_attempts SET status=4 WHERE timefinish>0 AND SCORE IS NOT NULL");
-    // hotpot_attempts: create and set clickreport fields
-    $ok = $ok && hotpot_db_update_field_type('hotpot', '', 'clickreporting', 'INTEGER', 4, 'UNSIGNED', 'NOT NULL', 0);
-    $ok = $ok && hotpot_db_update_field_type('hotpot_attempts', '', 'clickreportid', 'INTEGER', 10, 'UNSIGNED', 'NULL');
-    $ok = $ok && execute_sql("UPDATE {$CFG->prefix}hotpot_attempts SET clickreportid=id WHERE clickreportid IS NULL");
-    // hotpot_attempts: create and set studentfeedback field (0=none, 1=formmail, 2=moodleforum, 3=moodlemessaging)
-    $ok = $ok && hotpot_db_update_field_type('hotpot', '', 'studentfeedback', 'INTEGER', 4, 'UNSIGNED', 'NOT NULL', '0');
-    $ok = $ok && hotpot_db_update_field_type('hotpot', '', 'studentfeedbackurl', 'VARCHAR', 255, '', 'NULL');
-    // add indexes
-    $ok = $ok && hotpot_db_add_index('hotpot_attempts', 'hotpot');
-    $ok = $ok && hotpot_db_add_index('hotpot_attempts', 'userid');
-    $ok = $ok && hotpot_db_add_index('hotpot_details', 'attempt');
-    $ok = $ok && hotpot_db_add_index('hotpot_questions', 'hotpot');
-    $ok = $ok && hotpot_db_add_index('hotpot_responses', 'attempt');
-    $ok = $ok && hotpot_db_add_index('hotpot_responses', 'question');
-    // hotpot_string: correct double-encoded HTML entities
-    $ok = $ok && execute_sql("
-        UPDATE {$CFG->prefix}hotpot_strings 
-        SET string = REPLACE(string, '&amp;','&') 
-        WHERE string LIKE '%&amp;#%' 
-        AND (string LIKE '<' OR string LIKE '>')
-    ");
-    // hotpot_question: remove questions which refer to deleted hotpots
-    if ($ok) {
-        // try and get all hotpot records
-        if ($records = get_records('hotpot')) {
-            $ids = implode(',', array_keys($records));
-            $sql = "DELETE FROM {$CFG->prefix}hotpot_questions WHERE hotpot NOT IN ($ids)";
-        } else {
-            // remove all question records (because there are no valid hotpot ids)
-            $sql = "TRUNCATE {$CFG->prefix}hotpot_questions";
-        }
-        print "Removing unused question records ...";
-        execute_sql($sql);
-    }
-    if ($ok) {
-        // remove old 'v6' templates folder (replaced by 'template' folder)
-        $ds = DIRECTORY_SEPARATOR;
-        $dir = "mod{$ds}hotpot{$ds}v6";
-        print "removing old templates ($dir) ... ";
-        if (hotpot_rm("$CFG->dirroot{$ds}$dir", false)) {
-            print get_string('success');
-        } else {
-            print "failed<br/>Please remove '$CFG->dirroot{$ds}$dir' manually";
-        }
-        print "<br />\n";
-    }
-    return $ok;
-}
-function hotpot_update_to_v2_from_v1() {
-    global $CFG;
-    $ok = true;
-    // remove, alter and add fields in database
-    $table = 'hotpot';
-    if (hotpot_db_table_exists($table)) {
-        $ok = $ok && hotpot_update_fields($table);
-    } else {
-        $ok = $ok && hotpot_create_table($table);
-    }
-    $table = 'hotpot_attempts';
-    $oldtable = 'hotpot_events';
-    if (hotpot_db_table_exists($oldtable)) {
-        $ok = $ok && hotpot_update_fields($oldtable);
-        $ok = $ok && hotpot_db_append_table($oldtable, $table);
-    } else {
-        $ok = $ok && hotpot_create_table($table);
-    }
-    // create new tables (from mysql.sql)
-    $ok = $ok && hotpot_create_table('hotpot_questions');
-    $ok = $ok && hotpot_create_table('hotpot_responses');
-    $ok = $ok && hotpot_create_table('hotpot_strings');
-    // remove redundant scripts
-    $files = array('coursefiles.php', 'details.php', 'dummy.html', 'hotpot.php', 'hotpot2db.php');
-    foreach ($files as $file) {
-        $filepath = "$CFG->dirroot/mod/hotpot/$file";
-        if (file_exists($filepath)) {
-            @unlink($filepath); // don't worry about errors
-        }
-    }
-    return $ok;
-}
-function hotpot_update_to_v2_from_hotpotatoes() {
-    global $CFG;
-    $ok = true; // hope for the best!
-    // check we have the minimum required hotpot module
-    $minimum = 2005031400; 
-    $module = get_record("modules", "name", "hotpot");
-    if (empty($module) || $module->version<$minimum) {
-        if ($module) {
-            print ("<p>The update to the HotPotatoes module requires at least version $minimum of the HotPot module.</p>");
-            print ("<p>The current version of the HotPot module on this site is $module->version.</p>");
-        }
-        print ("<p>Please install the latest version of the HotPot module and then try the update again.</p>");
-        $ok = false;
-    } else {
-        // arrays to map foreign keys
-        $new = array();
-        $new['hotpot'] = array();
-        $new['attempt'] = array();
-        $new['question'] = array();
-        $new['string'] = array();
-        // save and switch off SQL message echo
-        global $db;
-        $debug = $db->debug;
-        $db->debug = false;
-        // import hotpotatoes (and save old ids)
-        $ok = $ok && hotpot_update_fields('hotpotatoes');
-        $ok = $ok && hotpot_transfer_records('hotpotatoes', 'hotpot', array(), 'hotpot', $new);
-        // update course modules and logs
-        $ok = $ok && hotpot_update_course_modules('hotpotatoes', 'hotpot', $new);
-        // import hotpotatoes_strings (and save old ids)
-        $ok = $ok && hotpot_transfer_records('hotpotatoes_strings', 'hotpot_strings', array(), 'string', $new);
-        // import hotpotatoes_attempts (and save old ids)
-        $ok = $ok && hotpot_transfer_records('hotpotatoes_attempts', 'hotpot_attempts', array('hotpotatoes'=>'hotpot'), 'attempt', $new);
-        // import hotpotatoes_questions (and save old ids)
-        $ok = $ok && hotpot_transfer_records('hotpotatoes_questions', 'hotpot_questions', array('hotpotatoes'=>'hotpot'), 'question', $new);
-        // import hotpotatoes_responses
-        $ok = $ok && hotpot_transfer_records('hotpotatoes_responses', 'hotpot_responses', array('attempt'=>'attempt', 'question'=>'question'), 'response', $new);
-        // restore SQL message echo setting
-        $db->debug = $debug;
-        // remove the hotpotatoes tables, if the update went ok
-        if ($ok) {
-        //  hotpot_db_remove_table('hotpotatoes');
-        //  hotpot_db_remove_table('hotpotatoes_attempts');
-        //  hotpot_db_remove_table('hotpotatoes_questions');
-        //  hotpot_db_remove_table('hotpotatoes_responses');
-        //  hotpot_db_remove_table('hotpotatoes_strings');
-        }
-        // hide the hotpotatoes module (see admin/modules.php))
-        if ($ok && ($module = get_record("modules", "name", "hotpotatoes"))) {
-            set_field("modules", "visible", "0", "id", $module->id);
-            print '<p>All HotPotatoes activities have been imported to the HotPot module.<br />'."\n";
-            print 'The HotPotatoes module has been hidden and can safely be deleted from this Moodle site.<br />'."\n";
-            print ' &nbsp; &nbsp; <a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/modules.php">Configuration -> Modules</A>, then click &quot;Delete&quot; for &quot;Hot Potatoes XML Quiz&quot;</p>'."\n";
-        }
-    }
-    if ($ok) {
-        print '<p align="center">Thank you for using the HotPotatoes module.<br />';
-        print 'The HotPotatoes module has been replaced by<br />version 2 of the HotPot module. Enjoy!</p>';
-    }
-    return $ok;
-}
-function hotpot_create_table($table) {
-    global $CFG;
-
-    static $sql;
-    static $xmldb_file;
-
-    // check table does not already exist
-    if (hotpot_db_table_exists($table)) {
-        return true;
-    }
-
-    if (! isset($xmldb_file)) { // first time only
-        if (class_exists('XMLDBFile')) {
-            $xmldb_file = new XMLDBFile("$CFG->dirroot/mod/hotpot/db/install.xml");
-            if (! $xmldb_file->fileExists() || !$xmldb_file->loadXMLStructure() || !$xmldb_file->isLoaded()) {
-                unset($xmldb_file);
-            }
-        }
-        if (empty($xmldb_file)) {
-            $xmldb_file = false;
-        }
-    }
-
-    if ($xmldb_file) {
-        // Moodle 1.8 (and later)
-        $ok = false;
-        foreach ($xmldb_file->xmldb_structure->tables as $xmldb_table) {
-            if ($xmldb_table->name==$table) {
-                $ok = create_table($xmldb_table);
-                break;
-            }
-        }
-        return $ok;
-    } 
-
-    // Moodle 1.7 (and earlier)
-
-    if (! isset($sql)) { // first time only
-        $sqlfilepath = "$CFG->dirroot/mod/hotpot/db/$CFG->dbtype.sql";
-        if (file_exists($sqlfilepath)) {
-            if (function_exists('file_get_contents')) {
-                $sql = file_get_contents($sqlfilepath);
-            } else { // PHP < 4.3
-                $sql = file($sqlfilepath);
-                if (is_array($sql)) {
-                     $sql = implode('', $sql);
-                }
-            }
-        }
-        if (empty($sql)) {
-            $sql = '';
-        }
-    }
-
-    // extract and execute all CREATE statements relating to this table
-    if (preg_match_all("/CREATE (TABLE|INDEX)(\s[^;]*)? prefix_{$table}(\s[^;]*)?;/s", $sql, $strings)) {
-        $ok = true;
-        foreach ($strings[0] as $string) {
-            $ok = $ok && modify_database('', $string);
-        }
-        return $ok;
-    }
-
-    // table could not be created
-    return false;
-}
-function hotpot_transfer_records($oldtable, $table, $foreignkeys, $primarykey, &$new) {
-    global $db;
-    $ok = true;
-    // get the records, if any
-    if (hotpot_db_table_exists($oldtable) && ($records = get_records($oldtable))) {
-        // start progress report
-        $i = 0;
-        $count = count($records);
-        hotpot_update_print("Transferring $count records from &quot;$oldtable&quot; to &quot;$table&quot; ... ");
-        // transfer all $records
-        foreach ($records as $record) {
-            switch ($table) {
-                case 'hotpot' :
-                    $record->summary = addslashes($record->summary);
-                    break;
-                case 'hotpot_attempts' :
-                    $record->details = addslashes($record->details);
-                    break;
-                case 'hotpot_questions' :
-                    $record->name = addslashes($record->name);
-                    hotpot_update_string_id_list($table, $record, 'TEXT', $new);
-                    break;
-                case 'hotpot_responses' :
-                    hotpot_update_string_id_list($table, $record, 'correct', $new);
-                    hotpot_update_string_id_list($table, $record, 'ignored', $new);
-                    hotpot_update_string_id_list($table, $record, 'wrong', $new);
-                    break;
-                case 'hotpot_strings' :
-                    $record->string = addslashes($record->string);
-                    break;
-            }
-            // update foreign keys, if any
-            foreach ($foreignkeys as $oldkey=>$key) {
-                // transfer (and update) key
-                $value = $record->$oldkey;
-                if (isset($new[$key][$value])) {
-                    $record->$key = $new[$key][$value];
-                } else {
-                    // foreign key could not be updated
-                    $ok = hotpot_update_print_warning($key, $value, $oldtable, $record->id) && $ok;
-                    unset($record->id);
-                }
-            }
-            if ($ok && isset($record->id)) {
-                // store and remove old primary key
-                $id = $record->id;
-                unset($record->id);
-                // add the updated record and store the new id
-                $new[$primarykey][$id] = insert_record($table, $record, true);
-                // check id is numeric
-                if (!is_numeric($new[$primarykey][$id])) {
-                    hotpot_update_print("<li>Record could not added to $table table ($oldtable id=$id)</li>\n");
-                    //$ok = false;
-                }
-            }
-            $i++;
-            hotpot_update_print_progress($i);
-        }
-        // finish progress report
-        hotpot_update_print_ok($ok);
-    }
-    return $ok;
-}
-function hotpot_update_course_modules($oldmodulename, $modulename, &$new) {
-    $ok = true;
-    $oldmoduleid = get_field('modules', 'id', 'name', $oldmodulename);
-    $moduleid = get_field('modules', 'id', 'name', $modulename);
-    if (is_numeric($oldmoduleid) && is_numeric($moduleid)) {
-        // get module records
-        if ($records = get_records('course_modules', 'module', $oldmoduleid)) {
-            // start progress report
-            $count = count($records);
-            hotpot_update_print("Updating $count course modules from &quot;$oldmodulename&quot; to &quot;$modulename&quot; ... ");
-            // update foreign keys in all $records
-            foreach ($records as $record) {
-                // update instance
-                $instance = $record->instance;
-                if (isset($new[$modulename][$instance])) {
-                    $record->instance = $new[$modulename][$instance];
-                } else if ($record->deleted) {
-                    unset($record->id);
-                } else {
-                    // could not find new id of course module
-                    $ok = hotpot_update_print_warning("$modulename instance", $instance, 'course_modules', $record->id) && $ok;
-                    unset($record->id);
-                }
-                // update module id
-                if ($ok && isset($record->id)) {
-                    $record->module = $moduleid;
-                    $ok = update_record('course_modules', $record);
-                }
-            }
-            // finish progress report
-            hotpot_update_print_ok($ok);
-        }
-        // update logs
-        $ok = $ok && hotpot_update_logs($oldmodulename, $modulename, $moduleid, $new);
-    }
-    return $ok;
-}
-function hotpot_update_logs($oldmodulename, $modulename, $moduleid, &$new) {
-    $table = 'log';
-    $ok = true;
-    // get log records for the oldmodule
-    if ($records = get_records($table, 'module', $oldmodulename)) {
-        // start progress report
-        $i = 0;
-        $count = count($records);
-        hotpot_update_print("Updating $count log records ... ");
-        // update foreign keys in all $records
-        foreach ($records as $record) {
-            // update course module name
-            $record->module = $modulename;
-            // check if module id was given (usually it is)
-            if ($record->cmid) {
-                // update course module id, if necessary
-                if (isset($new[$modulename][$record->cmid])) {
-                    $record->cmid = $new[$modulename][$record->cmid];
-                } else {
-                    // could not update course module id
-                    $ok = hotpot_update_print_warning('cmid', $record->cmid, 'log', $record->id) && $ok;
-                    unset($record->id);
-                }
-                // update url and info
-                switch ($record->action) {
-                    case "add":
-                    case "update":
-                    case "view":
-                        $record->url = "view.php?id=".$record->cmid;
-                        $record->info = $moduleid;
-                        break;
-                    case "view all":
-                        // do nothing
-                        break;
-                    case "report":
-                        $record->url = "report.php?id=".$record->cmid;
-                        $record->info = $moduleid;
-                        break;
-                    case "attempt":
-                    case "submit":
-                    case "review": 
-                        $id = substr(strrchr($record->url,"="),1);
-                        if (isset($new->attempt[$id])) { 
-                            $id = $new->attempt[$id];
-                        }
-                        $record->url = "review.php?id=".$record->cmid."&attempt=$id";
-                        $record->info = $moduleid;
-                        break;
-                    default:
-                        // unknown log action
-                        $ok = hotpot_update_print_warning('action', $record->action, 'log', $record->id) && $ok;
-                        unset($record->id);
-                } // end switch
-            }
-            if (isset($record->id)) {
-                $ok = $ok && update_record($table, $record);
-            }
-            $i++;
-            hotpot_update_print_progress($i);
-        } // end foreach
-        // finish progress report
-        hotpot_update_print_ok($ok);
-    }
-    return $ok;
-}
-function hotpot_update_fields($table, $feedback=false) {
-    global $CFG, $db;
-    $ok = true;
-    // check the table exists
-    if (hotpot_db_table_exists($table)) {
-        switch ($table) {
-            case 'hotpot' :
-                // == ADD ==
-                hotpot_db_update_field_type($table, '', 'location',     'INTEGER', 4, 'UNSIGNED', 'NOT NULL', 0);
-                hotpot_db_update_field_type($table, '', 'navigation',   'INTEGER', 4, 'UNSIGNED', 'NOT NULL', 1);
-                hotpot_db_update_field_type($table, '', 'outputformat', 'INTEGER', 4, 'UNSIGNED', 'NOT NULL', 1);
-                hotpot_db_update_field_type($table, '', 'shownextquiz', 'INTEGER', 4, 'UNSIGNED', 'NOT NULL', 0);
-                hotpot_db_update_field_type($table, '', 'forceplugins', 'INTEGER', 4, 'UNSIGNED', 'NOT NULL', 0);
-                hotpot_db_update_field_type($table, '', 'password',     'VARCHAR', 255, '',       'NOT NULL', '');
-                hotpot_db_update_field_type($table, '', 'subnet',       'VARCHAR', 255, '',       'NOT NULL', '');
-                // == ALTER ==
-                hotpot_db_update_field_type($table, 'summary',   'summary',   'TEXT',    '',  '', 'NOT NULL', '');
-                hotpot_db_update_field_type($table, 'reference', 'reference', 'VARCHAR', 255, '', 'NOT NULL', '');
-                // == REMOVE ==
-                hotpot_db_remove_field($table, 'intro');
-                hotpot_db_remove_field($table, 'attemptonlast');
-                hotpot_db_remove_field($table, 'sumgrades');
-                hotpot_db_set_table_comment($table, 'details about Hot Potatoes quizzes');
-            break;
-            case 'hotpot_events' :
-                // == ADD ==
-                hotpot_db_update_field_type($table, '', 'hotpot',     'INTEGER', 10, 'UNSIGNED', 'NOT NULL');
-                hotpot_db_update_field_type($table, '', 'attempt',    'INTEGER', 6,  'UNSIGNED', 'NOT NULL');
-                hotpot_db_update_field_type($table, '', 'details',    'TEXT',    '', '', '', '');
-                hotpot_db_update_field_type($table, '', 'timestart',  'INTEGER', 10, 'UNSIGNED', 'NOT NULL', 0);
-                hotpot_db_update_field_type($table, '', 'timefinish', 'INTEGER', 10, 'UNSIGNED', 'NOT NULL', 0);
-                // == ALTER ==
-                hotpot_db_update_field_type($table, 'score',     'score',      'INTEGER', 6,  'UNSIGNED', 'NULL');
-                hotpot_db_update_field_type($table, 'wrong',     'penalties',  'INTEGER', 6,  'UNSIGNED', 'NULL');
-                hotpot_db_update_field_type($table, 'starttime', 'starttime',  'INTEGER', 10, 'UNSIGNED', 'NULL');
-                hotpot_db_update_field_type($table, 'endtime',   'endtime',    'INTEGER', 10, 'UNSIGNED', 'NULL');
-                // save and switch off SQL message echo
-                $debug = $db->debug;
-                $db->debug = $feedback;
-                // get array mapping course module ids to hotpot ids
-                $hotpotmoduleid = get_field('modules', 'id', 'name', 'hotpot');
-                $coursemodules = get_records('course_modules', 'module', $hotpotmoduleid, 'id', 'id, instance');
-                // get all event records
-                if (hotpot_db_field_exists($table, 'hotpotid')) {
-                    $records = get_records($table, '', '', 'userid,hotpotid,time');
-                } else {
-                    $records = false; // table has already been updated
-                }
-                if ($records) {
-                    $count = count($records);
-                    hotpot_update_print("Updating $count records in $table ... ");
-                    $ids = array_keys($records);
-                    foreach ($ids as $i=>$id) {
-                        // reference to current record
-                        $record = &$records[$id];
-                        // set timestart and timefinish (the times recorded by Moodle)
-                        if (empty($record->timestart) && $record->time) {
-                            $record->timestart = $record->time;
-                        }
-                        if (empty($record->timefinish) && $record->timestart) {
-                            if ($record->starttime && $record->endtime) {
-                                $duration = ($record->endtime - $record->starttime);
-                            } else {
-                                if (($i+1)>=$count) {
-                                    $nextrecord = NULL;
-                                } else {
-                                    $nextrecord = &$records[$ids[$i+1]];
-                                }
-                                if (isset($nextrecord) && $nextrecord->userid==$record->userid && $nextrecord->hotpotid==$record->hotpotid) {
-                                    $duration = $nextrecord->time - $record->time;
-                                } else {
-                                    $duration = NULL;
-                                }
-                            }
-                            if (isset($duration)) {
-                                $record->timefinish = $record->timestart + $duration;
-                            }
-                        }
-                        // unset score and penalties, if quiz was abandoned
-                        if (empty($record->endtime) || (empty($record->penalties) && empty($record->score))) {
-                            unset($record->score);
-                            unset($record->penalties);
-                        }
-                        // get last (=previous) record
-                        if ($i==0) {
-                            $lastrecord = NULL;
-                        } else {
-                            $lastrecord = &$records[$ids[$i-1]];
-                        }
-                        // increment or reset $attempt number
-                        if (isset($lastrecord) && $lastrecord->userid==$record->userid && $lastrecord->hotpotid==$record->hotpotid) {
-                            $attempt++;
-                        } else {
-                            $attempt = 1;
-                        }
-                        // set $record->$attempt, if necessary
-                        if (empty($record->attempt) || $record->attempt<$attempt) {
-                            $record->attempt = $attempt;
-                        } else {
-                            $attempt = $record->attempt;
-                        }
-                        // set hotpot id and update record
-                        if (isset($record->hotpotid) && isset($record->id)) {
-                            if (isset($coursemodules[$record->hotpotid])) {
-                                $record->hotpot = $coursemodules[$record->hotpotid]->instance;
-                                hotpot_db_update_record($table, $record, true);
-                            } else {
-                                // hotpotid is invalid (shouldn't happen)
-                                $ok = hotpot_update_print_warning('hotpotid', $record->hotpotid, $table, $record->id) && $ok;
-                                delete_records($table, 'id', $record->id);
-                            }
-                        } else {
-                                // empty record (shouldn't happen)
-                        }
-                        hotpot_update_print_progress($i);
-                    }
-                    // finish progress report
-                    hotpot_update_print_ok($ok);
-                }
-                // restore SQL message echo setting
-                $db->debug = $debug;
-                // == REMOVE ==
-                hotpot_db_remove_field($table, 'hotpotid');
-                hotpot_db_remove_field($table, 'course');
-                hotpot_db_remove_field($table, 'time');
-                hotpot_db_remove_field($table, 'event');
-                hotpot_db_set_table_comment($table, 'details about Hot Potatoes quiz attempts');
-            break;
-            case 'hotpotatoes' :
-                // == ALTER ==
-                hotpot_db_update_field_type($table, 'intro', 'summary', 'TEXT', '', '', '', 'NULL');
-            break;
-        }
-    }
-    return $ok;
-}
-function hotpot_update_string_id_list($table, &$record, $field, &$new) {
-    $ok = true;
-    if (isset($record->$field)) {
-        $oldids = explode(',', $record->$field);
-        $newids = array();
-        foreach ($oldids as $id) {
-            if (isset($new['string'][$id])) {
-                $newids[] = $new['string'][$id];
-            } else if (is_numeric($id)) {
-                // string id could not be updated
-                $ok = hotpot_update_print_warning("string id in $field", $id, $table, $record->id) && $ok;
-            } else {
-                // ignore non-numeric ids (e.g. blanks)
-            }
-        }
-        if ($ok) {
-            $record->$field = implode(',', $newids);
-        }
-    }
-    return $ok;
-}
-///////////////////////////
-//     print functions
-///////////////////////////
-function hotpot_update_print($msg=false, $n=300) {
-    // this function prints $msg and flush output buffer
-    if ($msg) {
-        if (is_string($msg)) {
-            print $msg;
-        } else {
-            print strftime("%X", time());
-        }
-    }
-    // fill output buffer
-    if ($n) {
-        print str_repeat(" ", $n);
-    }
-    // some browser's require newline to flush
-    print "\n";
-    // flush PHP's output buffer
-    flush();
-}
-function hotpot_update_print_progress($i) {
-    if ($i%10==0) {
-        $msg = '.';
-        hotpot_update_print($msg);
-    }
-}
-function hotpot_update_print_ok($ok) {
-    if ($ok) {
-        hotpot_update_print('<font color="green">'.get_string('success')."</font><br />\n");
-    } else {
-        hotpot_update_print('<font color="red">'.get_string('error')."</font><br />\n");
-    }
-}
-function hotpot_update_print_warning($field, $value, $table, $id) {
-    hotpot_update_print("<li><b>Warning:</b> invalid $field field (value=$value) in $table (id=$id)</li>\n");
-    return true;
-}
-///////////////////////////
-//     database functions
-///////////////////////////
-function hotpot_db_index_exists($table, $index, $feedback=false) {
-    global $CFG, $db;
-    $exists = false;
-    // save and switch off SQL message echo
-    $debug = $db->debug;
-    $db->debug = $feedback;
-    switch (strtolower($CFG->dbfamily)) {
-        case 'mysql' : 
-            $rs = $db->Execute("SHOW INDEX FROM `$table`");
-            if ($rs && $rs->RecordCount()>0) {
-                $records = $rs->GetArray();
-                foreach ($records as $record) {
-                    if (isset($record['Key_name']) && $record['Key_name']==$index) {
-                        $exists = true;
-                        break;
-                    }
-                }
-            }
-        break;
-        case 'postgres' :
-            $rs = $db->Execute("SELECT relname FROM pg_class WHERE relname = '$index' AND relkind='i'");
-            if ($rs && $rs->RecordCount()>0) {
-                $exists = true;
-            }
-        break;
-    }
-    // restore SQL message echo
-    $db->debug = $debug;
-    return $exists;
-}
-function hotpot_db_delete_index($table, $index, $feedback=false) {
-    global $CFG, $db;
-    $ok = true;
-    // check index exists
-    if (hotpot_db_index_exists($table, $index)) {
-        switch (strtolower($CFG->dbfamily)) {
-            case 'mysql' : 
-                $sql = "ALTER TABLE `$table` DROP INDEX `$index`";
-            break;
-            case 'postgres' :
-                $sql = "DROP INDEX $index";
-            break;
-            default: // unknown database type
-                $sql = '';
-            break;
-        }
-        if ($sql) {
-            // save and switch off SQL message echo
-            $debug = $db->debug;
-            $db->debug = $feedback;
-            $ok = $db->Execute($sql) ? true : false;
-            // restore SQL message echo
-            $db->debug = $debug;
-        } else { // unknown database type
-            $ok = false;
-        }
-    }
-    return $ok;
-}
-function hotpot_db_add_index($table, $field, $length='') {
-    global $CFG, $db;
-
-    if (strtolower($CFG->dbfamily)=='postgres') {
-        $index = "{$CFG->prefix}{$table}_{$field}_idx";
-    } else {
-        // mysql (and others)
-        $index = "{$table}_{$field}_idx";
-    }
-    $table = "{$CFG->prefix}$table";
-
-    // delete $index if it already exists
-    $ok = hotpot_db_delete_index($table, $index);
-
-    switch (strtolower($CFG->dbfamily)) {
-        case 'mysql' :
-            $ok = $ok && $db->Execute("ALTER TABLE `$table` ADD INDEX `$index` (`$field`)");
-        break;
-        case 'postgres' :
-            $ok = $ok && $db->Execute("CREATE INDEX $index ON $table (\"$field\")");
-        break;
-        default: // unknown database type
-            $ok = false;
-        break;
-    }
-    return $ok;
-}
-function hotpot_db_table_exists($table, $feedback=false) {
-    return hotpot_db_object_exists($table, '', $feedback);
-}
-function hotpot_db_field_exists($table, $field, $feedback=false) {
-    return 
-        hotpot_db_object_exists($table, '', $feedback) &&
-        hotpot_db_object_exists($table, $field, $feedback)
-    ;
-}
-function hotpot_db_object_exists($table, $field='', $feedback=false) {
-    global $CFG,$db;
-    // expand table name
-    $table = "{$CFG->prefix}$table";
-    // set $sql
-    switch (strtolower($CFG->dbfamily)) {
-        case 'mysql' : 
-            if (empty($field)) {
-                $sql = "SHOW TABLES LIKE '$table'";
-            } else {
-                $sql = "SHOW COLUMNS FROM `$table` LIKE '$field'";
-            }
-        break;
-        case 'postgres' :
-            if (empty($field)) {
-                $sql = "SELECT relname FROM pg_class WHERE relname = '$table' AND relkind='r'";
-            } else {
-                $sql = "
-                    SELECT attname FROM pg_attribute WHERE attname = '$field' 
-                    AND attrelid = (SELECT oid FROM pg_class WHERE relname = '$table')
-                ";
-            }
-        break;
-    }
-    // save and switch off SQL message echo
-    $debug = $db->debug;
-    $db->debug = $feedback;
-    // execute sql
-    $rs = $db->Execute($sql);
-    // restore SQL message echo setting
-    $db->debug = $debug;
-    // report error if required
-    if (empty($rs) && debugging()) {
-        notify($db->ErrorMsg()."<br /><br />$sql");
-    }
-    return ($rs && $rs->RecordCount()>0);
-}
-function hotpot_db_remove_table($table, $feedback=true) {
-    global $CFG;
-    if (hotpot_db_table_exists($table)) {
-        $ok = execute_sql("DROP TABLE {$CFG->prefix}$table", $feedback);
-    } else {
-        $ok = true;
-    }
-    return $ok;
-}
-function hotpot_db_rename_table($oldtable, $table, $feedback=true) {
-    global $CFG;
-    if (hotpot_db_table_exists($oldtable)) {
-        $ok = execute_sql("ALTER TABLE {$CFG->prefix}$oldtable RENAME TO {$CFG->prefix}$table", $feedback);
-    } else {
-        $ok = true;
-    }
-    return $ok;
-}
-function hotpot_db_append_table($oldtable, $table, $feedback=true) {
-    global $CFG, $db;
-    if (hotpot_db_table_exists($oldtable)) {
-        if (hotpot_db_table_exists($table)) {
-            // expand table names
-            $table = "{$CFG->prefix}$table";
-            $oldtable = "{$CFG->prefix}$oldtable";
-            // get field info
-            $fields = $db->MetaColumns($table);
-            $oldfields = $db->MetaColumns($oldtable);
-            $fieldnames = array();
-            if (!empty($fields) || !empty($oldfields)) {
-                foreach ($fields as $field) {
-                    if ($field->name!='id' && isset($oldfields[strtoupper($field->name)])) {
-                        $fieldnames[] = $field->name;
-                    }
-                }
-            }
-            $fieldnames = implode(',', $fieldnames);
-            if (empty($fieldnames)) {
-                $ok = false;
-            } else {
-                switch (strtolower($CFG->dbfamily)) {
-                    case 'mysql':
-                        $ok = execute_sql("INSERT INTO `$table` ($fieldnames) SELECT $fieldnames FROM `$oldtable` WHERE 1");
-                        break;
-                    case 'postgres':
-                        $ok = execute_sql("INSERT INTO $table ($fieldnames) SELECT $fieldnames FROM $oldtable");
-                        break;
-                    default:
-                        $ok = false;
-                        break;
-                }
-            }
-        } else { // $table does not exist
-            $ok = hotpot_db_rename_table($oldtable, $table, $feedback);
-        }
-    } else { // $oldtable does not exist
-        $ok = hotpot_db_table_exists($table, $feedback);
-    }
-    return $ok;
-}
-function hotpot_db_set_table_comment($table, $comment, $feedback=true) {
-    global $CFG;
-    $ok = true;
-    switch (strtolower($CFG->dbfamily)) {
-        case 'mysql' :
-            $ok = execute_sql("ALTER TABLE {$CFG->prefix}$table COMMENT='$comment'");
-            break;
-        case 'postgres' :
-            $ok = execute_sql("COMMENT ON TABLE {$CFG->prefix}$table IS '$comment'");
-            break;
-    }
-    return $ok;
-}
-function hotpot_db_remove_field($table, $field, $feedback=true) {
-    global $CFG;
-    if (hotpot_db_field_exists($table, $field)) {
-        $ok = execute_sql("ALTER TABLE {$CFG->prefix}$table DROP COLUMN $field", $feedback);
-    } else {
-        $ok = true;
-    }
-    return $ok;
-}
-function hotpot_db_update_field_type($table, $oldfield, $field, $type, $size, $unsigned, $notnull, $default=NULL, $after=NULL) {
-    $ok = true;
-    global $CFG,$db;
-    // check validity of arguments, and adjust if necessary
-    if ($oldfield && !hotpot_db_field_exists($table, $oldfield)) {
-        $oldfield = '';
-    }
-    if (empty($oldfield) && hotpot_db_field_exists($table, $field)) {
-        $oldfield = $field;
-    } 
-    if (is_string($unsigned)) {
-        $unsigned = (strtoupper($unsigned)=='UNSIGNED');
-    }
-    if (is_string($notnull)) {
-        $notnull = (strtoupper($notnull)=='NOT NULL');
-    }
-    if (isset($default)) {
-        if (!is_numeric($default) && strtoupper($default)!='NULL' && !preg_match("|^'.*'$|", $default)) {
-            $default = "'$default'";
-        }
-    }
-    // set full table name
-    $table = "{$CFG->prefix}$table";
-    // update the field in the database
-    switch (strtolower($CFG->dbfamily)) {
-        case 'mysql':
-            // optimize integer types
-            switch (strtoupper($type)) {
-                case 'TEXT':
-                    $size = '';
-                    $unsigned = false;
-                break;
-                case 'INTEGER' :
-                    if (!is_numeric($size)) {
-                        $size = '';
-                    } else if ($size <= 4) {
-                        $type = "TINYINT";   // 1 byte
-                    } else if ($size <= 6) {
-                        $type = "SMALLINT";  // 2 bytes
-                    } else if ($size <= 8) {
-                        $type = "MEDIUMINT"; // 3 bytes
-                    } else if ($size <= 10) {
-                        $type = "INTEGER";   // 4 bytes (=INT)
-                    } else if ($size > 10) {
-                        $type = "BIGINT";    // 8 bytes
-                    }
-                break;
-                case 'VARCHAR':
-                    $unsigned = false;
-                break;
-            }
-            // set action
-            if (empty($oldfield)) {
-                $action = "ADD";
-            } else {
-                $action = "CHANGE `$oldfield`";
-            }
-            // set fieldtype
-            $fieldtype = $type;
-            if ($size) {
-                $fieldtype .= "($size)";
-            }
-            if ($unsigned) {
-                $fieldtype .= ' UNSIGNED';
-            }
-            if ($notnull) {
-                $fieldtype .= ' NOT NULL';
-            }
-            if (isset($default)) {
-                $fieldtype .= " DEFAULT $default";
-            }
-            if (!empty($after)) {
-                $fieldtype .= " AFTER `$after`";
-            }
-            $ok = $ok && execute_sql("ALTER TABLE `$table` $action `$field` $fieldtype");
-        break;
-        case 'postgres':
-            // get db version 
-            //    N.B. $db->ServerInfo() usually returns blank 
-            //    (except lib/adodb/drivers/adodb-postgre64-inc.php)
-            $dbversion = '';
-            $rs = $db->Execute("SELECT version()");
-            if ($rs && $rs->RecordCount()>0) {
-                $records = $rs->GetArray();
-                if (preg_match('/\d+\.\d+/', $records[0][0], $matches)) {
-                    $dbversion = $matches[0];
-                }
-            }
-            $tmpfield = 'temporary_'.$field.'_'.time();
-            switch (strtoupper($type)) {
-                case "INTEGER":
-                    if (!is_numeric($size)) {
-                        $fieldtype = "INTEGER";
-                    } else if ($size <= 4) {
-                        $fieldtype = "INT2"; // 2 bytes
-                    } else if ($size <= 10) {
-                        $fieldtype = "INT4"; // 4 bytes (=INTEGER)
-                    } else if ($size > 10) {
-                        $fieldtype = "INT8"; // 8 bytes
-                    }
-                break;
-                case "VARCHAR":
-                    $fieldtype = "VARCHAR($size)";
-                break;
-                default:
-                    $fieldtype = $type;
-            }
-            // start transaction
-            execute_sql('BEGIN');
-            // create temporary field
-            execute_sql('ALTER TABLE '.$table.' ADD COLUMN "'.$tmpfield.'" '.$fieldtype);
-            // set default
-            if (isset($default)) {
-                execute_sql('UPDATE '.$table.' SET "'.$tmpfield.'" = '.$default);
-                execute_sql('ALTER TABLE '.$table.' ALTER COLUMN "'.$tmpfield.'" SET DEFAULT '.$default);
-            } else {
-                execute_sql('ALTER TABLE '.$table.' ALTER COLUMN "'.$tmpfield.'" DROP DEFAULT');
-            }
-            // set not null
-            if ($dbversion=='' || $dbversion >= "7.3") {
-                $notnull = ($notnull ? 'SET NOT NULL' : 'DROP NOT NULL');
-                execute_sql('ALTER TABLE '.$table.' ALTER COLUMN "'.$tmpfield.'" '.$notnull);
-            } else {
-                execute_sql("
-                    UPDATE pg_attribute SET attnotnull=".($notnull ? 'TRUE' : 'FALSE')." 
-                    WHERE attname = '$tmpfield'
-                    AND attrelid = (SELECT oid FROM pg_class WHERE relname = '$table')
-                ");
-            }
-            // transfer $oldfield values, if necessary
-            if ( $oldfield != '' ) {
-                execute_sql('UPDATE '.$table.' SET "'.$tmpfield.'" = CAST ("'.$oldfield.'" AS '.$fieldtype.')');
-                execute_sql('ALTER TABLE '.$table.' DROP COLUMN "'.$oldfield.'"');
-            }
-            // rename $tmpfield to $field
-            execute_sql('ALTER TABLE '.$table.' RENAME COLUMN "'.$tmpfield.'" TO "'.$field.'"');
-            // do the transaction
-            execute_sql('COMMIT');
-            // reclaim disk space (must be done outside transaction)
-            if ($oldfield != '' && $dbversion >= "7.3") {
-                execute_sql('UPDATE '.$table.' SET "'.$field.'" = "'.$field.'"');
-                execute_sql('VACUUM FULL '.$table);
-            }
-        break;
-    } // end switch $CGF->dbfamily
-    return $ok;
-}
-function hotpot_db_update_record($table, $record, $forcenull=false) {
-    global $CFG, $db;
-    $ok = true;
-    // set full table name
-    $table = "{$CFG->prefix}$table";
-    // get field names
-    $fields = $db->MetaColumns($table);
-    if (empty($fields)) {
-        $ok = false;
-    } else {
-        // get values
-        $values = array();
-        foreach ($fields as $field) {
-            $fieldname = $field->name;
-            if ($fieldname!='id' && ($forcenull || isset($record->$fieldname))) {
-                $value = isset($record->$fieldname) ? "'".$record->$fieldname."'" : 'NULL';
-                $values[] = "$fieldname = $value";
-            }
-        }
-        $values = implode(',', $values);
-        // update values (if there are any)
-        if ($values) {
-            $sql = "UPDATE $table SET $values WHERE id='$record->id'";
-            $rs = $db->Execute($sql);
-            if (empty($rs)) {
-                $ok = false;
-                debugging($db->ErrorMsg()."<br /><br />$sql");
-            }
-        }
-    }
-    return $ok;
-}
-function hotpot_rm($target, $output=true) {
-    $ok = true;
-    if (!empty($target)) {
-        if (is_file($target)) {
-            if ($output) {
-                print "removing file: $target ... ";
-            }
-            $ok = @unlink($target);
-        } else if (is_dir($target)) {
-            $dir = dir($target);
-            while(false !== ($entry = $dir->read())) {
-                if ($entry!='.' && $entry!='..') {
-                    $ok = $ok && hotpot_rm($target.DIRECTORY_SEPARATOR.$entry, $output);
-                }
-            }
-            $dir->close();
-            if ($output) {
-                print "removing folder: $target ... ";
-            }
-            $ok = $ok && @rmdir($target);
-        } else { // not a file or directory (probably doesn't exist)
-            $output = false;
-        }
-        if ($output) {
-            if ($ok) {
-                print '<font color="green">OK</font><br />';
-            } else {
-                print '<font color="red">Failed</font><br />';
-            }
-        }
-    }
-    return $ok;
-}
-function hotpot_flush($n=0, $time=false) {
-    if ($time) {
-        $t = strftime("%X",time());
-    } else {
-        $t = "";
-    }
-    echo str_repeat(" ", $n) . $t . "\n";
-    flush();
-}
-?>
diff --git a/mod/hotpot/mod.html b/mod/hotpot/mod.html
deleted file mode 100644 (file)
index c6a0a8f..0000000
+++ /dev/null
@@ -1,432 +0,0 @@
-<!-- This page defines the form to create or edit an instance of this module -->
-<!-- It is used from /course/mod.php.The whole instance is available as $form. -->
-
-<?php 
-
-require_once("$CFG->dirroot/mod/hotpot/lib.php");
-
-// set default values in form fields, if necessary
-set_form_fields($form);
-
-// commonly used array of <select> options
-$yes_no_options = array(
-    HOTPOT_NO => get_string("no"), 
-    HOTPOT_YES => get_string("yes")
-);
-$text_source_options = array(
-    HOTPOT_TEXTSOURCE_QUIZ => get_string("textsourcequiz", "hotpot"), 
-    HOTPOT_TEXTSOURCE_FILENAME => get_string("textsourcefilename", "hotpot"),
-    HOTPOT_TEXTSOURCE_FILEPATH => get_string("textsourcefilepath", "hotpot"),
-    HOTPOT_TEXTSOURCE_SPECIFIC => get_string("textsourcespecific", "hotpot")
-);
-?>
-<script type="text/javascript">
-//<![CDATA[
-    var nameoffvalues = new Array(0,1,2);
-    var namelockitems = new Array('name');
-
-    var timeoffvalues = new Array('0'); // needs to be '0', not just 0
-    var timeopenlockitems = new Array('openday','openmonth','openyear','openhour', 'openminute');
-    var timecloselockitems = new Array('closeday','closemonth','closeyear','closehour','closeminute');
-
-    var feedbackoffvalues = new Array(0,3,4,5);
-    var feedbacklockitems = new Array('studentfeedbackurl');
-
-    function hotpot_lockoptions(form, master, subitems, offvalues) {
-        var disabled = false;
-        var obj = eval("document."+form+"."+master);
-        if (obj) {
-            var v = '';
-            if (obj.type=='select-one') {
-                var v = obj.options[obj.selectedIndex].value;
-                for (i=0; i<offvalues.length; i++) {
-                    if (v==offvalues[i]) {
-                        disabled = true;
-                    }
-                }
-            } else if (obj.type=='checkbox') {
-                if (obj.checked==false) {
-                    disabled = true;
-                }
-            }
-        }
-        if (document.getElementById) {
-            for (i=0; i<subitems.length; i++) {
-                eval("document."+form+"."+subitems[i]+".disabled="+disabled);
-            }
-        }
-        return(true);
-    }
-//]]>
-</script>
-<center>
-<form id="form" method="post" action="mod.php">
-<table cellpadding="5">
-    <tr valign="top">
-        <td align="right"><b><?php print_string("name") ?>:</b></td>
-        <td align="left"><?php
-            if ($form->mode=='add') {
-                choose_from_menu(
-                    $text_source_options, "namesource", "$form->namesource", "", 
-                    "return hotpot_lockoptions('form', 'namesource', namelockitems, nameoffvalues)"
-                );
-            } else {
-                print '<input type="hidden" name="namesource" value="'.HOTPOT_TEXTSOURCE_SPECIFIC.'" />';
-            }
-            print '<input type="text" name="name" size=40 value="'.$form->name.'">';
-        ?></td>
-    </tr>
-    <tr valign="top">
-        <td align="right">
-            <b><?php 
-                print_string("summary") 
-            ?>:</b><br />
-            <font size="1"><?php
-                helpbutton("summary", get_string("summary"), "resource", true, true);
-                print '<br />';
-                helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
-                print '<br />';
-                if (isset($usehtmleditor) && $usehtmleditor) {
-                    helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
-                    print '<br />';
-                } else {
-                    helpbutton("text", get_string("helptext"), "moodle", true, true); 
-                    print '<br />';
-                    emoticonhelpbutton("form", "description");
-                }
-            ?></font>
-            </span>
-        </td>
-        <td align="left"><?php 
-            if ($form->mode=='add') {
-                choose_from_menu($text_source_options, "summarysource", "$form->summarysource", "");
-                print '<br />';
-            } else {
-                print '<input type="hidden" name="summarysource" value="'.HOTPOT_TEXTSOURCE_SPECIFIC.'" />';
-            }
-            if (function_exists("print_textarea") && isset($usehtmleditor)) {
-                print_textarea($usehtmleditor, 10, 65, 680, 400, "summary", $form->summary);
-            } else {
-                // Moodle 1.1.1 (original size was rows="5" cols="50")
-                print '<textarea name="summary" rows="10" cols="65" wrap="virtual">'.$form->summary.'</textarea>';
-            }
-        ?></td>
-    </tr>
-    <tr valign="top">
-        <td align="right"><b><?php print_string("quizopen", "quiz") ?>:</b></td>
-        <td align="left"><?php
-            if (!$form->timeopen && $course->format == "weeks") {
-                $form->timeopen = $course->startdate + (($form->section - 1) * 608400);
-            }
-            print '<input name="enabletimeopen" type="checkbox" value="1" alt="'.get_string("quizopen", "quiz").'" onclick="'."return hotpot_lockoptions('form', 'enabletimeopen', timeopenlockitems)".'" '.(empty($form->timeopen) ? '' : 'checked="checked"').' />';
-            print_date_selector("openday", "openmonth", "openyear", $form->timeopen);
-            print ' - ';
-            print_time_selector("openhour", "openminute", $form->timeopen);
-            helpbutton("timeopen", get_string("quizopen","quiz"), "quiz");
-        ?></td>
-    </tr>
-    <tr valign="top">
-        <td align="right"><b><?php print_string("quizclose", "quiz") ?>:</b></td>
-        <td align="left"><?php
-            if (!$form->timeclose && $course->format == "weeks") {
-                $form->timeclose= $course->startdate + (($form->section) * 608400);
-            }
-            print '<input name="enabletimeclose" type="checkbox" value="1" alt="'.get_string("quizclose", "quiz").'" onclick="'."return hotpot_lockoptions('form', 'enabletimeclose', timecloselockitems)".'" '.(empty($form->timeclose) ? '' : 'checked="checked"').' />';
-            print_date_selector("closeday", "closemonth", "closeyear", $form->timeclose);
-            print ' - ';
-            print_time_selector("closehour", "closeminute", $form->timeclose);
-            helpbutton("timeopen", get_string("quizclose","quiz"), "quiz");
-        ?></td>
-    </tr>
-    <tr valign="top">
-        <td align="right" nowrap>
-            <b><?php print get_string("location","hotpot") ?>:</b>
-        </td>
-        <td align="left"><?php
-
-            if (has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
-                $site = get_site();
-                if ($course->id==$site->id) {
-                    $id = $site->id;
-                    $location = HOTPOT_LOCATION_SITEFILES;
-                } else {
-                    $id = "'+(getObjValue(this.form.location)==".HOTPOT_LOCATION_SITEFILES."?".$site->id.":".$course->id.")+'";
-                    $location = '';
-                }
-            } else { // ordinary teacher or content creator
-                    $id = $course->id;
-                    $location = HOTPOT_LOCATION_COURSEFILES;
-            }
-
-            if (array_key_exists($location, $HOTPOT_LOCATION)) {
-                print '<input type="hidden" name="location" value="'.$location.'" />';
-                print '<i><font size="-1">'.$HOTPOT_LOCATION[$location].'</font></i> &nbsp; ';
-
-            } else { // admin can select from "site" or "course" files
-                choose_from_menu($HOTPOT_LOCATION, "location", "$form->location", "");
-            }
-
-
-            if (function_exists("button_to_popup_window")) {
-
-                // use javascript to extract wdir from the reference field
-                $wdir = "'+getDir(getObjValue(this.form.reference))+'";
-
-                // set button url depending on Moodle version
-                if ($CFG->version < 2004083125) { // version may need refining
-                    // up to and including Moodle 1.4.1
-                    $url = "/mod/resource/coursefiles.php?id=$id&wdir=$wdir";
-                } else {
-                    // Moodle 1.4.2 and beyond
-                    $url = "/files/index.php?id=$id&wdir=$wdir&choose=form.reference";
-                }
-
-                $strchooseafile = get_string("chooseafile", "resource");
-                button_to_popup_window ($url, 'coursefiles', $strchooseafile, 500, 750, $strchooseafile);
-            }
-        ?></td>
-    </tr>
-    <tr valign="top">
-        <td align="right" nowrap>
-            <b><?php print_string("filename", "resource") ?>:</b>
-        </td>
-        <td align="left"><?php
-            if (function_exists("button_to_popup_window")) {
-                print '<input name="reference" size="50" value="'.$form->reference.'">&nbsp;';
-
-            } else if (function_exists("get_directory_list")) {
-                // Moodle 1.1 (and perhaps some others)
-                $dirs = get_directory_list("$CFG->dataroot/$course->id");
-                $options = array();
-                foreach ($dirs as $dir) {
-                    $options["$dir"] = $dir;
-                }
-                choose_from_menu ($options, "reference", $form->reference);
-
-            } else {
-                // a very old Moodle (may be none left :-)
-                print '<input name="reference" size="50" value="'.$form->reference.'">&nbsp;';
-            }
-            print '<br />';
-            hotpot_print_show_links($form->course, $form->location, $form->reference, '', ' &nbsp; ', true);
-        ?></td>
-    </tr>
-    <tr valign="top">
-        <td align="right"><b><?php 
-            $quizchain = "{$form->mode}quizchain";
-            print_string($quizchain, "hotpot"); 
-        ?>:</b></td>
-        <td align="left"><?php
-            choose_from_menu($yes_no_options, "quizchain", $form->quizchain, "");
-            helpbutton($quizchain, get_string($quizchain,"hotpot"), "hotpot");
-        ?></td>
-    </tr>
-    <tr valign="top">
-        <td align="right"><b><?php print_string("outputformat", "hotpot") ?>:</b></td>
-        <td align="left"><?php
-            choose_from_menu($HOTPOT_OUTPUTFORMAT, "outputformat", "$form->outputformat", "");
-            helpbutton("outputformat", get_string("outputformat","hotpot"), "hotpot");
-        ?></td>
-    </tr>
-    <tr valign="top">
-        <td align="right"><b><?php print_string("navigation", "hotpot") ?>:</b></td>
-        <td align="left"><?php
-            choose_from_menu($HOTPOT_NAVIGATION, "navigation", "$form->navigation", "");
-            helpbutton("navigation", get_string("navigation","hotpot"), "hotpot");
-        ?></td>
-    </tr>
-    <tr valign="top">
-        <td align="right"><b><?php print_string("studentfeedback", "hotpot") ?>:</b></td>
-        <td align="left"><?php
-            choose_from_menu(
-                $HOTPOT_FEEDBACK, "studentfeedback", "$form->studentfeedback", "",
-                "return hotpot_lockoptions('form', 'studentfeedback', feedbacklockitems, feedbackoffvalues)"
-            );
-            print '<span id="studentfeedbackurlSPAN">';
-            print "<input name=\"studentfeedbackurl\" size=\"50\" value=\"$form->studentfeedbackurl\">";
-                print '</span>';
-            helpbutton("studentfeedback", get_string("studentfeedback","hotpot"), "hotpot");
-        ?></td>
-    </tr>
-    <tr valign="top">
-        <td align="right"><b><?php print_string("forceplugins", "hotpot") ?>:</b></td>
-        <td align="left"><?php
-            choose_from_menu($yes_no_options, "forceplugins", "$form->forceplugins", "");
-            helpbutton("forceplugins", get_string("forceplugins","hotpot"), "hotpot");
-        ?></td>
-    </tr>
-    <tr valign="top">
-        <td align="right"><b><?php print_string("shownextquiz", "hotpot") ?>:</b></td>
-        <td align="left"><?php
-            choose_from_menu($yes_no_options, "shownextquiz", "$form->shownextquiz", "");
-            helpbutton("shownextquiz", get_string("shownextquiz","hotpot"), "hotpot");
-        ?></td>
-    </tr>
-    <tr valign="top">
-        <td align="right"><b><?php print_string("allowreview", "quiz") ?>:</b></td>
-        <td align="left"><?php
-            choose_from_menu($yes_no_options, "review", "$form->review", "");
-            helpbutton("review", get_string("allowreview","quiz"), "quiz");
-        ?></td>
-    </tr>
-    <tr valign="top">
-        <td align="right"><b><?php print_string("maximumgrade") ?>:</b></td>
-        <td align="left"><?php
-            $options = array();
-            for ($i=100; $i>=1; $i--) {
-                $options[$i] = $i;
-            }
-            $options[0] = get_string("nograde");
-
-            choose_from_menu($options, "grade", "$form->grade", "");
-            helpbutton("maxgrade", get_string("maximumgrade"), "quiz");
-        ?></td>
-    </tr>
-    <tr valign="top">
-        <td align="right"><b><?php print_string("grademethod", "quiz") ?>:</b></td>
-        <td align="left"><?php
-            choose_from_menu($HOTPOT_GRADEMETHOD, "grademethod", "$form->grademethod", "");
-            helpbutton("grademethod", get_string("grademethod","quiz"), "quiz");
-        ?></td>
-    </tr>
-    <tr valign="top">
-        <td align="right"><b><?php print_string("attemptsallowed", "quiz") ?>:</b></td>
-        <td align="left"><?php
-            $options = array(
-                0 => get_string("attemptsunlimited", "quiz"),
-                1 => '1 '.strtolower(get_string("attempt", "quiz"))
-            );
-            for ($i=2; $i<=10; $i++) {
-                $options[$i] = "$i ".strtolower(get_string("attempts", "quiz"));
-            }
-            choose_from_menu($options, "attempts", "$form->attempts", "");
-            helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz");
-        ?></td>
-    </tr>
-    <tr valign="top">
-        <td align="right"><b><?php print_string("requirepassword", "quiz") ?>:</b></td>
-        <td align="left">
-            <input type="text" name="password" size=40 value="<?php p($form->password) ?>">
-            <?php helpbutton("requirepassword", get_string("requirepassword", "quiz"), "quiz"); ?>
-        </td>
-    </tr>
-    <tr valign="top">
-        <td align="right"><b><?php print_string("requiresubnet", "quiz") ?>:</b></td>
-        <td align="left">
-            <input type="text" name="subnet" size=40 value="<?php p($form->subnet) ?>">
-            <?php helpbutton("requiresubnet", get_string("requiresubnet", "quiz"), "quiz"); ?>
-        </td>
-    </tr>
-    <tr valign="top">
-        <td align="right"><b><?php print_string("clickreporting", "hotpot") ?>:</b></td>
-        <td align="left"><?php
-            choose_from_menu($yes_no_options, "clickreporting", "$form->clickreporting", "");
-            helpbutton("clickreporting", get_string("clickreporting","hotpot"), "hotpot");
-        ?></td>
-    </tr>
-<?php 
-    print_standard_coursemodule_settings($form); 
-?>
-    <tr valign="top">
-        <td align="right">&nbsp;</td>
-        <td align="left">
-            <!-- buttons -->
-            <input type="submit" value="<?php print_string("savechanges") ?>"> &nbsp; &nbsp;
-            <input type="submit" name="cancel" value="<?php print_string("cancel") ?>" /><br />
-            <?php
-                if (isset($CFG->release) && substr($CFG->release, 0, 3)>=1.5) {
-                    $options = array(
-                        HOTPOT_DISPLAYNEXT_QUIZ => get_string("displayhotpotnext", "hotpot"),
-                        HOTPOT_DISPLAYNEXT_COURSE => get_string("displaycoursenext", "hotpot"),
-                        HOTPOT_DISPLAYNEXT_INDEX => get_string("displayindexnext", "hotpot")
-                    );
-                    choose_from_menu($options, "displaynext", "$form->displaynext", "");
-                } else {
-                    print '<input type="hidden" name="displaynext" value="'.HOTPOT_NO.'" />'."\n";
-                }
-            ?>
-</table>
-
-<!-- hidden fields -->
-<input type="hidden" name="course"        value="<?php p($form->course) ?>">
-<input type="hidden" name="coursemodule"  value="<?php p($form->coursemodule) ?>">
-<input type="hidden" name="section"       value="<?php p($form->section) ?>">
-<input type="hidden" name="module"        value="<?php p($form->module) ?>">
-<input type="hidden" name="modulename"    value="<?php p($form->modulename) ?>">
-<input type="hidden" name="instance"      value="<?php p($form->instance) ?>">
-<input type="hidden" name="mode"          value="<?php p($form->mode) ?>">
-<?php if (isset($USER->sesskey)) { ?>
-<input type="hidden" name="sesskey"       value="<?php p($USER->sesskey) ?>">
-<?php } ?>
-
-</form>
-</center>
-<script type="text/javascript">
-<!--
-    hotpot_lockoptions('form', 'namesource', namelockitems, nameoffvalues);
-    hotpot_lockoptions('form', 'enabletimeopen', timeopenlockitems, timeoffvalues);
-    hotpot_lockoptions('form', 'enabletimeclose', timecloselockitems, timeoffvalues);
-    hotpot_lockoptions('form', 'studentfeedback', feedbacklockitems, feedbackoffvalues);
-
-    // override the standard Moodle "setfocus" function, 
-    // which gives a js error if the "name" field is hidden
-    function setfocus() {
-        var f = getElementById('form');
-        if (f) {
-            if (canfocus(f, 'namesource')) {
-                f.namesource.focus();
-            } else if (canfocus(f, 'name')) {
-                f.name.focus();
-            }
-        }
-    }
-    function canfocus(f, name) {
-        var obj = eval('f.'+name);
-        return (obj==null || obj.type=='hidden' || obj.focus==null || (obj.style && obj.style.display=='none')) ? false : true;
-    }
-//-->
-</script>
-<?php
-
-// ======================
-//  functions
-// ======================
-
-function set_form_fields(&$form) {
-    set_form_field($form, 'name');
-    set_form_field($form, 'summary');
-    set_form_field($form, 'timeopen', get_user_preferences('hotpot_timeopen', 0));
-    set_form_field($form, 'enabletimeopen', empty($form->timeopen) ? HOTPOT_NO : HOTPOT_YES);
-    set_form_field($form, 'timeclose', get_user_preferences('hotpot_timeclose', 0));
-    set_form_field($form, 'enabletimeclose', empty($form->timeclose) ? HOTPOT_NO : HOTPOT_YES);
-    set_form_field($form, 'location', HOTPOT_LOCATION_COURSEFILES);
-    set_form_field($form, 'reference');
-    set_form_field($form, 'navigation', get_user_preferences('hotpot_navigation', HOTPOT_NAVIGATION_BAR));
-    set_form_field($form, 'outputformat', get_user_preferences('hotpot_outputformat', HOTPOT_OUTPUTFORMAT_BEST));
-    set_form_field($form, 'studentfeedback', get_user_preferences('hotpot_studentfeedback', HOTPOT_FEEDBACK_NONE));
-    set_form_field($form, 'studentfeedbackurl', get_user_preferences('hotpot_studentfeedbackurl', 'http://'));
-    set_form_field($form, 'forceplugins', get_user_preferences('hotpot_forceplugins', HOTPOT_NO));
-    if ($form->mode=='add') {
-        set_form_field($form, 'namesource', get_user_preferences('hotpot_namesource', HOTPOT_TEXTSOURCE_QUIZ));
-        set_form_field($form, 'summarysource', get_user_preferences('hotpot_summarysource', HOTPOT_TEXTSOURCE_QUIZ));
-        $quizchain = get_user_preferences('hotpot_quizchain', HOTPOT_NO);
-    } else {
-        $quizchain = empty($form->quizchain) ? HOTPOT_NO : HOTPOT_YES;
-    }
-    set_form_field($form, 'quizchain', $quizchain);
-    set_form_field($form, 'shownextquiz', get_user_preferences('hotpot_shownextquiz', HOTPOT_NO));
-    set_form_field($form, 'review', get_user_preferences('hotpot_review', HOTPOT_YES));
-    set_form_field($form, 'grade', get_user_preferences('hotpot_grade', 100));
-    set_form_field($form, 'grademethod', get_user_preferences('hotpot_grademethod', HOTPOT_GRADEMETHOD_HIGHEST));
-    set_form_field($form, 'attempts', get_user_preferences('hotpot_attempts', 0)); // 0=unlimited
-    set_form_field($form, 'password');
-    set_form_field($form, 'subnet', get_user_preferences('hotpot_subnet'));
-    set_form_field($form, 'clickreporting', HOTPOT_NO);
-    set_form_field($form, 'displaynext', get_user_preferences('hotpot_displaynext', HOTPOT_DISPLAYNEXT_QUIZ));
-}
-function set_form_field(&$form, $fieldname, $defaultvalue='') {
-    if (!isset($form->$fieldname)) {
-        $form->$fieldname = $defaultvalue;
-    }
-}
-?>
diff --git a/mod/journal/backuplib.php b/mod/journal/backuplib.php
deleted file mode 100644 (file)
index bf47f88..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-<?php //$Id$
-    //This php script contains all the stuff to backup/restore
-    //journal mods
-
-    //This is the "graphical" structure of the journal mod:
-    //
-    //                      journal                                      
-    //                    (CL,pk->id)
-    //                        |
-    //                        |
-    //                        |
-    //                   journal_entries 
-    //               (UL,pk->id, fk->journal)     
-    //
-    // Meaning: pk->primary key field of the table
-    //          fk->foreign key to link with parent
-    //          nt->nested field (recursive data)
-    //          CL->course level info
-    //          UL->user level info
-    //          files->table may have files)
-    //
-    //-----------------------------------------------------------
-
-    function journal_backup_mods($bf,$preferences) {
-
-        global $CFG;
-
-        $status = true;
-
-        //Iterate over journal table
-        $journals = get_records ("journal","course",$preferences->backup_course,"id");
-        if ($journals) {
-            foreach ($journals as $journal) {
-                if (backup_mod_selected($preferences,'journal',$journal->id)) {
-                    $status = journal_backup_one_mod($bf,$preferences,$journal);
-                }
-            }
-        }
-        return $status;
-    }
-
-    function journal_backup_one_mod($bf,$preferences,$journal) {
-
-        global $CFG;
-    
-        if (is_numeric($journal)) {
-            $journal = get_record('journal','id',$journal);
-        }
-    
-        $status = true;
-
-        //Start mod
-        fwrite ($bf,start_tag("MOD",3,true));
-        //Print journal data
-        fwrite ($bf,full_tag("ID",4,false,$journal->id));
-        fwrite ($bf,full_tag("MODTYPE",4,false,"journal"));
-        fwrite ($bf,full_tag("NAME",4,false,$journal->name));
-        fwrite ($bf,full_tag("INTRO",4,false,$journal->intro));
-        fwrite ($bf,full_tag("INTROFORMAT",4,false,$journal->introformat));
-        fwrite ($bf,full_tag("DAYS",4,false,$journal->days));
-        fwrite ($bf,full_tag("ASSESSED",4,false,$journal->assessed));
-        fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$journal->timemodified));
-
-        //if we've selected to backup users info, then execute backup_journal_entries
-        if (backup_userdata_selected($preferences,'journal',$journal->id)) {
-            $status = backup_journal_entries($bf,$preferences,$journal->id);
-        }
-        //End mod
-        $status =fwrite ($bf,end_tag("MOD",3,true));
-
-        return $status;
-    }
-
-    //Backup journal_entries contents (executed from journal_backup_mods)
-    function backup_journal_entries ($bf,$preferences,$journal) {
-
-        global $CFG;
-
-        $status = true;
-
-        $journal_entries = get_records("journal_entries","journal",$journal,"id");
-        //If there is entries
-        if ($journal_entries) {
-            //Write start tag
-            $status =fwrite ($bf,start_tag("ENTRIES",4,true));
-            //Iterate over each entry
-            foreach ($journal_entries as $jou_ent) {
-                //Start entry
-                $status =fwrite ($bf,start_tag("ENTRY",5,true));
-                //Print journal_entries contents
-                fwrite ($bf,full_tag("ID",6,false,$jou_ent->id));
-                fwrite ($bf,full_tag("USERID",6,false,$jou_ent->userid));
-                fwrite ($bf,full_tag("MODIFIED",6,false,$jou_ent->modified));
-                fwrite ($bf,full_tag("TEXT",6,false,$jou_ent->text));
-                fwrite ($bf,full_tag("FORMAT",6,false,$jou_ent->format));
-                fwrite ($bf,full_tag("RATING",6,false,$jou_ent->rating));
-                fwrite ($bf,full_tag("ENTRYCOMMENT",6,false,$jou_ent->entrycomment));
-                fwrite ($bf,full_tag("TEACHER",6,false,$jou_ent->teacher));
-                fwrite ($bf,full_tag("TIMEMARKED",6,false,$jou_ent->timemarked));
-                fwrite ($bf,full_tag("MAILED",6,false,$jou_ent->mailed));
-                //End entry
-                $status =fwrite ($bf,end_tag("ENTRY",5,true));
-            }
-            //Write end tag
-            $status =fwrite ($bf,end_tag("ENTRIES",4,true));
-        }
-        return $status;
-    }
-   ////Return an array of info (name,value)
-   function journal_check_backup_mods($course,$user_data=false,$backup_unique_code, $instances=null) {
-       if (!empty($instances) && is_array($instances) && count($instances)) {
-           $info = array();
-           foreach ($instances as $id => $instance) {
-               $info += journal_check_backup_mods_instances($instance,$backup_unique_code);
-           }
-           return $info;
-       }
-        //First the course data
-        $info[0][0] = get_string("modulenameplural","journal");
-        if ($ids = journal_ids ($course)) {
-            $info[0][1] = count($ids);
-        } else {
-            $info[0][1] = 0;
-        }
-
-        //Now, if requested, the user_data
-        if ($user_data) {
-            $info[1][0] = get_string("entries","journal");
-            if ($ids = journal_entry_ids_by_course ($course)) {
-                $info[1][1] = count($ids);
-            } else {
-                $info[1][1] = 0;
-            }
-        }
-        return $info;
-    }
-
-   ////Return an array of info (name,value)
-   function journal_check_backup_mods_instances($instance,$backup_unique_code) {
-        //First the course data
-        $info[$instance->id.'0'][0] = '<b>'.$instance->name.'</b>';
-        $info[$instance->id.'0'][1] = '';
-
-        //Now, if requested, the user_data
-        if (!empty($instance->userdata)) {
-            $info[$instance->id.'1'][0] = get_string("entries","journal");
-            if ($ids = journal_entry_ids_by_instance ($instance->id)) {
-                $info[$instance->id.'1'][1] = count($ids);
-            } else {
-                $info[$instance->id.'1'][1] = 0;
-            }
-        }
-        return $info;
-    }
-
-
-
-
-
-    // INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE
-
-    //Returns an array of journals id
-    function journal_ids ($course) {
-
-        global $CFG;
-
-        return get_records_sql ("SELECT a.id, a.course
-                                 FROM {$CFG->prefix}journal a
-                                 WHERE a.course = '$course'");
-    }
-   
-    //Returns an array of journal entries id
-    function journal_entry_ids_by_course ($course) {
-
-        global $CFG;
-
-        return get_records_sql ("SELECT s.id , s.journal
-                                 FROM {$CFG->prefix}journal_entries s,
-                                      {$CFG->prefix}journal a
-                                 WHERE a.course = '$course' AND
-                                       s.journal = a.id");
-    }
-
-    //Returns an array of journal entries id
-    function journal_entry_ids_by_instance ($instanceid) {
-
-        global $CFG;
-
-        return get_records_sql ("SELECT s.id , s.journal
-                                 FROM {$CFG->prefix}journal_entries s
-                                 WHERE s.journal = $instanceid");
-    }
-?>
diff --git a/mod/journal/db/install.xml b/mod/journal/db/install.xml
deleted file mode 100644 (file)
index 638739b..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/journal/db" VERSION="20060921" COMMENT="XMLDB file for Moodle mod/journal"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
->
-  <TABLES>
-    <TABLE NAME="journal" COMMENT="data for each journal" NEXT="journal_entries">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="course"/>
-        <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="name"/>
-        <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="course" NEXT="intro"/>
-        <FIELD NAME="intro" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="introformat"/>
-        <FIELD NAME="introformat" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="intro" NEXT="days"/>
-        <FIELD NAME="days" TYPE="int" LENGTH="5" NOTNULL="true" UNSIGNED="true" DEFAULT="7" SEQUENCE="false" ENUM="false" PREVIOUS="introformat" NEXT="assessed"/>
-        <FIELD NAME="assessed" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="days" NEXT="timemodified"/>
-        <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="assessed"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" />
-      </KEYS>
-      <INDEXES>
-        <INDEX NAME="course" UNIQUE="false" FIELDS="course"/>
-      </INDEXES>
-    </TABLE>
-    <TABLE NAME="journal_entries" COMMENT="All the journal entries of all people" PREVIOUS="journal">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="journal"/>
-        <FIELD NAME="journal" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="userid"/>
-        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="journal" NEXT="modified"/>
-        <FIELD NAME="modified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="text"/>
-        <FIELD NAME="text" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="modified" NEXT="format"/>
-        <FIELD NAME="format" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="text" NEXT="rating"/>
-        <FIELD NAME="rating" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="format" NEXT="entrycomment"/>
-        <FIELD NAME="entrycomment" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="rating" NEXT="teacher"/>
-        <FIELD NAME="teacher" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="entrycomment" NEXT="timemarked"/>
-        <FIELD NAME="timemarked" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="teacher" NEXT="mailed"/>
-        <FIELD NAME="mailed" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timemarked"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="journal"/>
-        <KEY NAME="journal" TYPE="foreign" FIELDS="journal" REFTABLE="journal" REFFIELDS="id" PREVIOUS="primary"/>
-      </KEYS>
-      <INDEXES>
-        <INDEX NAME="userid" UNIQUE="false" FIELDS="userid"/>
-      </INDEXES>
-    </TABLE>
-  </TABLES>
-  <STATEMENTS>
-    <STATEMENT NAME="insert log_display" TYPE="insert" TABLE="log_display" COMMENT="Initial insert of records on table log_display">
-      <SENTENCES>
-        <SENTENCE TEXT="(module, action, mtable, field) VALUES ('journal', 'view', 'journal', 'name')" />
-        <SENTENCE TEXT="(module, action, mtable, field) VALUES ('journal', 'add entry', 'journal', 'name')" />
-        <SENTENCE TEXT="(module, action, mtable, field) VALUES ('journal', 'update entry', 'journal', 'name')" />
-        <SENTENCE TEXT="(module, action, mtable, field) VALUES ('journal', 'view responses', 'journal', 'name')" />
-      </SENTENCES>
-    </STATEMENT>
-  </STATEMENTS>
-</XMLDB>
diff --git a/mod/journal/db/mysql.php b/mod/journal/db/mysql.php
deleted file mode 100644 (file)
index 37c34df..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function journal_upgrade($oldversion) {
-// This function does anything necessary to upgrade
-// older versions to match current functionality
-
-    global $CFG;
-
-    $result = true;
-
-    if ($oldversion < 2002081000) {
-        if (! execute_sql("ALTER TABLE `journal_entries` ADD `mailed` TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL")) {
-            $result = false;
-        }
-    }
-    if ($oldversion < 2002101200) {
-        execute_sql(" ALTER TABLE `journal_entries` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `text` ");
-    }
-    if ($oldversion < 2002122300) {
-        execute_sql("ALTER TABLE `journal_entries` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
-    }
-
-    if ($oldversion < 2003081701) {
-        table_column("journal", "assessed", "assessed", "integer", "10", "", "0");
-        table_column("journal_entries", "rating", "rating", "integer", "10", "", "0");
-    }
-
-    if ($oldversion < 2003081705) {
-        $defaultscale = NULL;
-        $defaultscale->courseid = 0;
-        $defaultscale->userid = 0;
-        $defaultscale->timemodified = time();
-        $defaultscale->name  = get_string("journalrating2", "journal");
-        $defaultscale->scale = get_string("journalrating1", "journal").",".
-                               get_string("journalrating2", "journal").",".
-                               get_string("journalrating3", "journal");
-
-        if ($defaultscale->id = insert_record("scale", $defaultscale)) {
-            execute_sql("UPDATE {$CFG->prefix}journal SET assessed = '-$defaultscale->id'", false);
-        } else {
-            notify("An error occurred while inserting the default journal scale");
-            $result = false;
-        }
-    }
-
-    if ($oldversion < 2004011400) {
-        table_column("journal", "", "introformat", "integer", "2", "", "1", "not null", "intro");
-    }
-
-    if ($oldversion < 2004111200) {
-        execute_sql("ALTER TABLE {$CFG->prefix}journal DROP INDEX course;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}journal_entries DROP INDEX journal;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}journal_entries DROP INDEX userid;",false); 
-
-        modify_database('','ALTER TABLE prefix_journal ADD INDEX course (course);');
-        modify_database('','ALTER TABLE prefix_journal_entries ADD INDEX journal (journal);');
-        modify_database('','ALTER TABLE prefix_journal_entries ADD INDEX userid (userid);');
-    }
-    
-    if ($oldversion < 2005041100) { // replace wiki-like with markdown
-        include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
-        $wtm = new WikiToMarkdown();
-        // journal intro
-        $wtm->update( 'journal','intro','introformat' );
-        // journal entries
-        $sql = "select course from {$CFG->prefix}journal, {$CFG->prefix}journal_entries ";
-        $sql .= "where {$CFG->prefix}journal.id = {$CFG->prefix}journal_entries.journal ";
-        $sql .= "and {$CFG->prefix}journal_entries.id = ";
-        $wtm->update( 'journal_entries', 'text', 'format', $sql );
-    }
-
-    if ($oldversion < 2006042800) {
-        execute_sql("UPDATE {$CFG->prefix}journal SET name='' WHERE name IS NULL");
-        table_column('journal','name','name','varchar','255','','','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}journal SET intro='' WHERE intro IS NULL");
-        table_column('journal','intro','intro','text','','','','not null');
-    }
-
-    if ($oldversion < 2006092100) {
-        table_column('journal_entries', 'comment', 'entrycomment', 'text', '', '', '', 'null');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return $result;
-}
-
-?>
diff --git a/mod/journal/db/postgres7.php b/mod/journal/db/postgres7.php
deleted file mode 100644 (file)
index 9064b09..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function journal_upgrade($oldversion) {
-// This function does anything necessary to upgrade
-// older versions to match current functionality
-
-    global $CFG;
-
-    $result = true;
-
-    if ($oldversion < 2003081705) {
-        $defaultscale = NULL;
-        $defaultscale->courseid = 0;
-        $defaultscale->userid = 0;
-        $defaultscale->timemodified = time();
-        $defaultscale->name  = get_string("journalrating2", "journal");
-        $defaultscale->scale = get_string("journalrating1", "journal").",".
-                               get_string("journalrating2", "journal").",".
-                               get_string("journalrating3", "journal");
-
-        if ($defaultscale->id = insert_record("scale", $defaultscale)) {
-            execute_sql("UPDATE {$CFG->prefix}journal SET assessed = '-$defaultscale->id'", false);
-        } else {
-            notify("An error occurred while inserting the default journal scale");
-            $result = false;
-        }
-    }
-
-    if ($oldversion < 2004011400) {
-        table_column("journal", "", "introformat", "integer", "2", "", "1", "not null", "intro");
-    }
-
-    if ($oldversion < 2004111200) {
-        execute_sql("DROP INDEX {$CFG->prefix}journal_course_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}journal_entries_journal_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}journal_entries_userid_idx;",false);
-
-        modify_database('','CREATE INDEX prefix_journal_course_idx ON prefix_journal (course);');
-        modify_database('','CREATE INDEX prefix_journal_entries_journal_idx ON prefix_journal_entries (journal);');
-        modify_database('','CREATE INDEX prefix_journal_entries_userid_idx ON prefix_journal_entries (userid);');
-    }
-
-    if ($oldversion < 2005041100) { // replace wiki-like with markdown
-        include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
-        $wtm = new WikiToMarkdown();
-        // journal intro
-        $wtm->update( 'journal','intro','introformat' );
-        // journal entries
-        $sql = "select course from {$CFG->prefix}journal, {$CFG->prefix}journal_entries ";
-        $sql .= "where {$CFG->prefix}journal.id = {$CFG->prefix}journal_entries.journal ";
-        $sql .= "and {$CFG->prefix}journal_entries.id = ";
-        $wtm->update( 'journal_entries', 'text', 'format', $sql );
-    }
-
-    if ($oldversion < 2006092100) {
-        table_column('journal_entries', 'comment', 'entrycomment', 'text', '', '', '', 'null');
-    } 
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return $result;
-}
diff --git a/mod/journal/db/upgrade.php b/mod/journal/db/upgrade.php
deleted file mode 100644 (file)
index 8169c2b..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php  //$Id$
-
-// This file keeps track of upgrades to 
-// the journal module
-//
-// Sometimes, changes between versions involve
-// alterations to database structures and other
-// major things that may break installations.
-//
-// The upgrade function in this file will attempt
-// to perform all the necessary actions to upgrade
-// your older installtion to the current version.
-//
-// If there's something it cannot do itself, it
-// will tell you what you need to do.
-//
-// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
-
-function xmldb_journal_upgrade($oldversion=0) {
-
-    global $CFG, $THEME, $db;
-
-    $result = true;
-
-/// And upgrade begins here. For each one, you'll need one 
-/// block of code similar to the next one. Please, delete 
-/// this comment lines once this file start handling proper
-/// upgrade code.
-
-/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-///     $result = result of "/lib/ddllib.php" function calls
-/// }
-
-    return $result;
-}
-
-?>
diff --git a/mod/journal/defaults.php b/mod/journal/defaults.php
deleted file mode 100644 (file)
index 05170d9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php 
-    if (empty($CFG->journal_initialdisable)) {
-        if (!count_records('journal')) {
-            set_field('modules', 'visible', 0, 'name', 'journal');  // Disable it by default
-            set_config('journal_initialdisable', 1);
-        }
-    }
-
-?>
diff --git a/mod/journal/edit.html b/mod/journal/edit.html
deleted file mode 100644 (file)
index 3f2bc1f..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<form id="theform" method="post" action="edit.php">
-<table cellpadding="10" cellspacing="0" class="generalbox">
-  <tr><td align="right">
-     <?php
-        helpbutton('reading', get_string('helpreading'), 'moodle', true, true);
-        echo '<br />';
-        helpbutton('writing', get_string('helpwriting'), 'moodle', true, true);
-        echo '<br />';
-        if ($usehtmleditor) {
-           helpbutton('richtext', get_string('helprichtext'), 'moodle', true, true);
-        } else {
-           emoticonhelpbutton('theform', 'text');
-        } 
-        echo '<br />';
-      ?>
-</td></tr>
-<tr><td align="center">
-<?php  print_textarea($usehtmleditor, 20, 60, 630, 400, "text", $entry->text); ?>
-</td></tr>
-<tr><td align="center">
-<?php
-   print_string('formattexttype');
-   echo ':&nbsp;';
-   choose_from_menu(format_text_menu(), 'format', $entry->format, '');
-   helpbutton('textformat', get_string('helpformatting'));
-?>
-</td></tr>
-<tr><td align="center" class="generalboxcontent">
-<input type="hidden" name="id" value="<?php echo $cm->id ?>" />
-<input type="submit" value="<?php  print_string('savechanges') ?>" />
-<input type="reset" value="<?php  print_string('revert') ?>" />
-</td></tr></table>
-</form>
-
diff --git a/mod/journal/edit.php b/mod/journal/edit.php
deleted file mode 100644 (file)
index 136d96f..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-<?php // $Id$
-
-    require_once("../../config.php");
-
-    $id = required_param('id', PARAM_INT);    // Course Module ID
-
-    if (! $cm = get_coursemodule_from_id('journal', $id)) {
-        print_error("Course Module ID was incorrect");
-    }
-
-    if (! $course = get_record("course", "id", $cm->course)) {
-        print_error("Course is misconfigured");
-    }
-
-    require_login($course->id, false, $cm);
-
-    if (isguest()) {
-        print_error("Guests are not allowed to edit journals", '', $_SERVER["HTTP_REFERER"]);
-    }
-
-    if (! $journal = get_record("journal", "id", $cm->instance)) {
-        print_error("Course module is incorrect");
-    }
-
-    $entry = get_record("journal_entries", "userid", $USER->id, "journal", $journal->id);
-
-
-/// If data submitted, then process and store.
-
-    if ($form = data_submitted()) {
-
-        $timenow = time();
-
-        //$form->text = clean_text($form->text, $form->format);
-
-        if ($entry) {
-            $newentry->id = $entry->id;
-            $newentry->text = $form->text;
-            $newentry->format = $form->format;
-            $newentry->modified = $timenow;
-            if (! update_record("journal_entries", $newentry)) {
-                print_error("Could not update your journal");
-            }
-            add_to_log($course->id, "journal", "update entry", "view.php?id=$cm->id", "$newentry->id", $cm->id);
-        } else {
-            $newentry->userid = $USER->id;
-            $newentry->journal = $journal->id;
-            $newentry->text = $form->text;
-            $newentry->format = $form->format;
-            $newentry->modified = $timenow;
-            if (! $newentry->id = insert_record("journal_entries", $newentry)) {
-                print_error("Could not insert a new journal entry");
-            }
-            add_to_log($course->id, "journal", "add entry", "view.php?id=$cm->id", "$newentry->id", $cm->id);
-        }
-
-        redirect("view.php?id=$cm->id");
-        die;
-    }
-
-/// Otherwise fill and print the form.
-
-    $strjournal = get_string("modulename", "journal");
-    $strjournals = get_string("modulenameplural", "journal");
-    $stredit = get_string("edit");
-
-    if ($usehtmleditor = can_use_richtext_editor()) {
-        $defaultformat = FORMAT_HTML;
-    } else {
-        $defaultformat = FORMAT_MOODLE;
-    }
-
-    if (empty($entry)) {
-        $entry->text = "";
-        $entry->format = $defaultformat;
-    }
-
-    $navigation = build_navigation($stredit, $cm);
-    print_header_simple(format_string($journal->name), "", $navigation, "",
-                  "", true, "", navmenu($course, $cm));
-
-    echo "<center>\n";
-
-    print_simple_box( format_text($journal->intro, $journal->introformat) , "center");
-
-    echo "<br />";
-
-    include("edit.html");
-
-    if ($usehtmleditor) {
-        use_html_editor("text");
-    }
-    echo "</center>\n";
-    print_footer($course);
-
-?>
diff --git a/mod/journal/icon.gif b/mod/journal/icon.gif
deleted file mode 100755 (executable)
index a32d346..0000000
Binary files a/mod/journal/icon.gif and /dev/null differ
diff --git a/mod/journal/index.php b/mod/journal/index.php
deleted file mode 100644 (file)
index 4a06991..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php // $Id$
-
-    require_once("../../config.php");
-    require_once("lib.php");
-
-    $id = required_param('id', PARAM_INT);   // course
-
-    if (! $course = get_record("course", "id", $id)) {
-        print_error("Course ID is incorrect");
-    }
-
-    require_course_login($course);
-    add_to_log($course->id, "journal", "view all", "index.php?id=$course->id", "");
-
-    $strjournal = get_string("modulename", "journal");
-    $strjournals = get_string("modulenameplural", "journal");
-    $strweek = get_string("week");
-    $strtopic = get_string("topic");
-
-    $navlinks = array();
-    $navlinks[] = array('name' => $strjournals, 'link' => '', 'type' => 'activity');
-    $navigation = build_navigation($navlinks);
-
-    print_header_simple("$strjournals", "", $navigation,
-                 "", "", true, "", navmenu($course));
-
-
-    if (! $journals = get_all_instances_in_course("journal", $course)) {
-        notice(get_string('thereareno', 'moodle', $strjournals), "../../course/view.php?id=$course->id");
-        die;
-    }
-
-    $timenow = time();
-
-    if ($course->format == "weeks") {
-        $strsection = $strweek;
-    } else if ($course->format == "topics") {
-        $strsection = $strtopic;
-    } else {
-        $strsection = "";
-    }
-
-    foreach ($journals as $journal) {
-
-        $journal->timestart  = $course->startdate + (($journal->section - 1) * 608400);
-        if (!empty($journal->daysopen)) {
-            $journal->timefinish = $journal->timestart + (3600 * 24 * $journal->daysopen);
-        } else {
-            $journal->timefinish = 9999999999;
-        }
-
-        $journalopen = ($journal->timestart < $timenow && $timenow < $journal->timefinish);
-
-        journal_user_complete_index($course, $USER, $journal, $journalopen, "$strsection $journal->section");
-
-    }
-
-    echo "<br />";
-
-    print_footer($course);
-
-?>
diff --git a/mod/journal/lib.php b/mod/journal/lib.php
deleted file mode 100644 (file)
index 47c48f2..0000000
+++ /dev/null
@@ -1,550 +0,0 @@
-<?php // $Id$
-
-
-if (!isset($CFG->journal_showrecentactivity)) {
-    set_config("journal_showrecentactivity", true);
-} 
-
-
-
-// STANDARD MODULE FUNCTIONS /////////////////////////////////////////////////////////
-
-function journal_user_outline($course, $user, $mod, $journal) {
-    if ($entry = get_record("journal_entries", "userid", $user->id, "journal", $journal->id)) {
-
-        $numwords = count(preg_split("/\w\b/", $entry->text)) - 1;
-
-        $result->info = get_string("numwords", "", $numwords);
-        $result->time = $entry->modified;
-        return $result;
-    }
-    return NULL;
-}
-
-
-function journal_user_complete($course, $user, $mod, $journal) {
-
-    if ($entry = get_record("journal_entries", "userid", $user->id, "journal", $journal->id)) {
-
-        print_simple_box_start();
-        if ($entry->modified) {
-            echo "<p><font size=\"1\">".get_string("lastedited").": ".userdate($entry->modified)."</font></p>";
-        }
-        if ($entry->text) {
-            echo format_text($entry->text, $entry->format);
-        }
-        if ($entry->teacher) {
-            $grades = make_grades_menu($journal->assessed);
-            journal_print_feedback($course, $entry, $grades);
-        }
-        print_simple_box_end();
-
-    } else {
-        print_string("noentry", "journal");
-    }
-}
-
-
-function journal_user_complete_index($course, $user, $journal, $journalopen, $heading) {
-/// Prints a journal, entry and feedback ... used on the journal index page.
-
-    if (isteacher($course->id)) {
-        $entrycount = journal_count_entries($journal, get_current_group($course->id));
-        $entryinfo  = "&nbsp;(<a href=\"report.php?id=$journal->coursemodule\">".get_string("viewallentries","journal", $entrycount)."</a>)";
-    } else {
-        $entryinfo = "";
-    }
-
-    $journal->name = "<a href=\"view.php?id=$journal->coursemodule\">".format_string($journal->name,true)."</a>";
-
-    if ($heading) {
-        echo "<h3>$heading - $journal->name$entryinfo</h3>";
-    } else {
-        echo "<h3>$journal->name$entryinfo</h3>";
-    }
-
-    print_simple_box_start("left", "90%");
-    echo format_text($journal->intro,  $journal->introformat);
-    print_simple_box_end();
-    echo "<br clear=\"all\" />";
-    echo "<br />";
-    
-    if (isstudent($course->id) or isteacher($course->id)) {
-
-        print_simple_box_start("right", "90%");
-    
-        if ($journalopen) {
-            echo "<p align=\"right\"><a href=\"edit.php?id=$journal->coursemodule\">";
-            echo get_string("edit")."</a></p>";
-        } else {
-            echo "<p align=\"right\"><a href=\"view.php?id=$journal->coursemodule\">";
-            echo get_string("view")."</a></p>";
-        }
-    
-        if ($entry = get_record("journal_entries", "userid", $user->id, "journal", $journal->id)) {
-            if ($entry->modified) {
-                echo "<p align=\"center\"><font size=\"1\">".get_string("lastedited").": ".userdate($entry->modified)."</font></p>";
-            }
-            if ($entry->text) {
-                echo format_text($entry->text, $entry->format);
-            }
-            if ($entry->teacher) {
-                $grades = make_grades_menu($journal->assessed);
-                journal_print_feedback($course, $entry, $grades);
-            }
-        } else {
-            print_string("noentry", "journal");
-        }
-    
-        print_simple_box_end();
-        echo "<br clear=\"all\" />";
-        echo "<br />";
-    }
-
-}
-
-
-function journal_cron () {
-// Function to be run periodically according to the moodle cron
-// Finds all journal notifications that have yet to be mailed out, and mails them
-
-    global $CFG, $USER;
-
-    $cutofftime = time() - $CFG->maxeditingtime;
-
-    if ($entries = journal_get_unmailed_graded($cutofftime)) {
-        $timenow = time();
-
-        foreach ($entries as $entry) {
-
-            echo "Processing journal entry $entry->id\n";
-
-            if (! $user = get_record("user", "id", "$entry->userid")) {
-                echo "Could not find user $entry->userid\n";
-                continue;
-            }
-
-            $USER->lang = $user->lang;
-
-            if (! $course = get_record("course", "id", "$entry->course")) {
-                echo "Could not find course $entry->course\n";
-                continue;
-            }
-
-            if (! isstudent($course->id, $user->id) and !isteacher($course->id, $user->id)) {
-                continue;  // Not an active participant
-            }
-
-            if (! $teacher = get_record("user", "id", "$entry->teacher")) {
-                echo "Could not find teacher $entry->teacher\n";
-                continue;
-            }
-
-
-            if (! $mod = get_coursemodule_from_instance("journal", $entry->journal, $course->id)) {
-                echo "Could not find course module for journal id $entry->journal\n";
-                continue;
-            }
-
-            unset($journalinfo);
-            $journalinfo->teacher = fullname($teacher);
-            $journalinfo->journal = format_string($entry->name,true);
-            $journalinfo->url = "$CFG->wwwroot/mod/journal/view.php?id=$mod->id";
-            $modnamepl = get_string( 'modulenameplural','journal' );
-            $msubject = get_string( 'mailsubject','journal' );
-
-            $postsubject = "$course->shortname: $msubject: ".format_string($entry->name,true);
-            $posttext  = "$course->shortname -> $modnamepl -> ".format_string($entry->name,true)."\n";
-            $posttext .= "---------------------------------------------------------------------\n";
-            $posttext .= get_string("journalmail", "journal", $journalinfo)."\n";
-            $posttext .= "---------------------------------------------------------------------\n";
-            if ($user->mailformat == 1) {  // HTML
-                $posthtml = "<p><font face=\"sans-serif\">".
-                "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->".
-                "<a href=\"$CFG->wwwroot/mod/journal/index.php?id=$course->id\">journals</a> ->".
-                "<a href=\"$CFG->wwwroot/mod/journal/view.php?id=$mod->id\">".format_string($entry->name,true)."</a></font></p>";
-                $posthtml .= "<hr /><font face=\"sans-serif\">";
-                $posthtml .= "<p>".get_string("journalmailhtml", "journal", $journalinfo)."</p>";
-                $posthtml .= "</font><hr />";
-            } else {
-              $posthtml = "";
-            }
-
-            if (! email_to_user($user, $teacher, $postsubject, $posttext, $posthtml)) {
-                echo "Error: Journal cron: Could not send out mail for id $entry->id to user $user->id ($user->email)\n";
-            }
-            if (! set_field("journal_entries", "mailed", "1", "id", "$entry->id")) {
-                echo "Could not update the mailed field for id $entry->id\n";
-            }
-        }
-    }
-
-    return true;
-}
-
-function journal_print_recent_activity($course, $isteacher, $timestart) {
-    global $CFG;
-
-    if (!empty($CFG->journal_showrecentactivity)) {    // Don't even bother
-        return false;
-    }
-
-    $content = false;
-    $journals = NULL;
-
-    // log table should not be used here
-
-    if (!$logs = get_records_select('log', 'time > \''.$timestart.'\' AND '.
-                                           'course = \''.$course->id.'\' AND '.
-                                           'module = \'journal\' AND '.
-                                           '(action = \'add entry\' OR action = \'update entry\')', 'time ASC')){
-        return false;
-    }
-
-    foreach ($logs as $log) {
-        ///Get journal info.  I'll need it later
-        $j_log_info = journal_log_info($log);
-
-        $cm = $modinfo->instances['journal'][$j_log_info->id];
-        if (!$cm->uservisible) {
-            continue;
-        }
-
-        if (!isset($journals[$log->info])) {
-            $journals[$log->info] = $j_log_info;
-            $journals[$log->info]->time = $log->time;
-            $journals[$log->info]->url = str_replace('&', '&amp;', $log->url);
-        }
-    }
-
-    if ($journals) {
-        $content = true;
-        print_headline(get_string('newjournalentries', 'journal').':');
-        foreach ($journals as $journal) {
-            print_recent_activity_note($journal->time, $journal, $journal->name,
-                                       $CFG->wwwroot.'/mod/journal/'.$journal->url);
-        }
-    }
-    return $content;
-}
-
-function journal_grades($journalid) {
-/// Must return an array of grades, indexed by user, and a max grade.
-
-    if (!$journal = get_record("journal", "id", $journalid)) {
-        return NULL;
-    }
-
-    $grades = get_records_menu("journal_entries", "journal", 
-                               $journal->id, "", "userid,rating");
-
-    if ($journal->assessed > 0) {
-        $return->grades = $grades;
-        $return->maxgrade = $journal->assessed;
-
-    } else if ($journal->assessed == 0) {
-        return NULL;
-
-    } else {
-        if ($scale = get_record("scale", "id", - $journal->assessed)) {
-            $scalegrades = make_menu_from_list($scale->scale);
-            if ($grades) {
-                foreach ($grades as $key => $grade) {
-                    $grades[$key] = $scalegrades[$grade];
-                }
-            }
-        }
-        $return->grades = $grades;
-        $return->maxgrade = "";
-    }
-
-    return $return;
-}
-
-function journal_get_participants($journalid) {
-//Returns the users with data in one journal
-//(users with records in journal_entries, students and teachers)
-
-    global $CFG;
-
-    //Get students
-    $students = get_records_sql("SELECT DISTINCT u.id, u.id
-                                 FROM {$CFG->prefix}user u,
-                                      {$CFG->prefix}journal_entries j
-                                 WHERE j.journal = '$journalid' and
-                                       u.id = j.userid");
-    //Get teachers
-    $teachers = get_records_sql("SELECT DISTINCT u.id, u.id
-                                 FROM {$CFG->prefix}user u,
-                                      {$CFG->prefix}journal_entries j
-                                 WHERE j.journal = '$journalid' and
-                                       u.id = j.teacher");
-
-    //Add teachers to students
-    if ($teachers) {
-        foreach ($teachers as $teacher) {
-            $students[$teacher->id] = $teacher;
-        }
-    }
-    //Return students array (it contains an array of unique users)
-    return ($students);
-}
-
-function journal_scale_used ($journalid,$scaleid) {
-//This function returns if a scale is being used by one journal
-    
-    $return = false;                  
-                                 
-    $rec = get_record("journal","id","$journalid","assessed","-$scaleid");
-
-    if (!empty($rec) && !empty($scaleid)) {
-        $return = true;
-    }
-
-    return $return;
-}
-
-/**
- * Checks if scale is being used by any instance of journal
- *
- * This is used to find out if scale used anywhere
- * @param $scaleid int
- * @return boolean True if the scale is used by any journal
- */
-function journal_scale_used_anywhere($scaleid) {
-    if ($scaleid and record_exists('journal', 'assessed', -$scaleid)) {
-        return true;
-    } else {
-        return false;
-    }
-}
-
-// SQL FUNCTIONS ///////////////////////////////////////////////////////////////////
-
-function journal_get_users_done($journal) {
-    global $CFG;
-
-    $journals = get_records_sql ("SELECT u.*
-                                  FROM {$CFG->prefix}journal_entries j,
-                                       {$CFG->prefix}user u 
-                                 WHERE j.userid = u.id
-                                   AND j.journal = $journal->id
-                              ORDER BY j.modified DESC");
-
-    if (empty($journals)) {
-        return NULL;
-    }
-
-    // remove unenrolled participants
-    foreach ($journals as $key=>$user) {
-        if (!isteacher($journal->course, $user->id) and !isstudent($journal->course, $user->id)) {
-            unset($journals[$key]);
-        } 
-    }
-    return $journals;
-}
-
-function journal_count_entries($journal, $groupid=0) {
-/// Counts all the journal entries (optionally in a given group)
-
-    global $CFG, $db;
-
-    if ($groupid) {     /// How many in a particular group?
-        return count_records_sql("SELECT COUNT(*) 
-                                     FROM {$CFG->prefix}journal_entries j,
-                                          {$CFG->prefix}groups_members g
-                                    WHERE j.journal = $journal->id 
-                                      AND g.groupid = '$groupid' 
-                                      AND j.userid = g.userid");
-
-    } else { /// Count all the entries from the whole course
-    
-        $journals = get_records_sql ("SELECT u.*
-                                      FROM {$CFG->prefix}journal_entries j,
-                                           {$CFG->prefix}user u 
-                                     WHERE j.userid = u.id
-                                       AND j.journal = $journal->id
-                                  ORDER BY j.modified DESC");
-
-        if (empty($journals)) {
-            return 0;
-        }
-
-        // remove unenrolled participants
-        foreach ($journals as $key=>$user) {
-            if (!isteacher($journal->course, $user->id) and !isstudent($journal->course, $user->id)) {
-                unset($journals[$key]);
-            } 
-        }
-        return count($journals);
-    }
-}
-
-
-function journal_get_unmailed_graded($cutofftime) {
-    global $CFG;
-    return get_records_sql("SELECT e.*, j.course, j.name
-                              FROM {$CFG->prefix}journal_entries e, 
-                                   {$CFG->prefix}journal j
-                             WHERE e.mailed = '0' 
-                               AND e.timemarked < '$cutofftime' 
-                               AND e.timemarked > 0
-                               AND e.journal = j.id");
-}
-
-function journal_log_info($log) {
-    global $CFG;
-    return get_record_sql("SELECT j.*, u.firstname, u.lastname
-                             FROM {$CFG->prefix}journal j, 
-                                  {$CFG->prefix}journal_entries e, 
-                                  {$CFG->prefix}user u
-                            WHERE e.id = '$log->info' 
-                              AND e.journal = j.id
-                              AND e.userid = u.id");
-}
-
-// OTHER JOURNAL FUNCTIONS ///////////////////////////////////////////////////////////////////
-
-
-
-function journal_print_user_entry($course, $user, $entry, $teachers, $grades) {
-    global $USER;
-
-    echo "\n<table border=\"1\" cellspacing=\"0\" valign=\"top\" cellpadding=\"10\">";
-        
-    echo "\n<tr>";
-    echo "\n<td rowspan=\"2\" width=\"35\" valign=\"top\">";
-    print_user_picture($user->id, $course->id, $user->picture);
-    echo "</td>";
-    echo "<td nowrap=\"nowrap\" width=\"100%\">".fullname($user);
-    if ($entry) {
-        echo "&nbsp;&nbsp;<font size=\"1\">".get_string("lastedited").": ".userdate($entry->modified)."</font>";
-    }
-    echo "</td>";
-    echo "</tr>";
-
-    echo "\n<tr><td width=\"100%\">";
-    if ($entry) {
-        echo format_text($entry->text, $entry->format);
-    } else {
-        print_string("noentry", "journal");
-    }
-    echo "</td></tr>";
-
-    if ($entry) {
-        echo "\n<tr>";
-        echo "<td width=\"35\" valign=\"top\">";
-        if (!$entry->teacher) {
-            $entry->teacher = $USER->id;
-        }
-        print_user_picture($entry->teacher, $course->id, $teachers[$entry->teacher]->picture);
-        echo "</td>";
-        echo "<td>".get_string("feedback").":";
-        choose_from_menu($grades, "r$entry->id", $entry->rating, get_string("nograde")."...");
-        if ($entry->timemarked) {
-            echo "&nbsp;&nbsp;<font size=\"1\">".userdate($entry->timemarked)."</font>";
-        }
-        echo "<br /><textarea name=\"c$entry->id\" rows=\"12\" cols=\"60\" wrap=\"virtual\">";
-        p($entry->entrycomment);
-        echo "</textarea><br />";
-        echo "</td></tr>";
-    }
-    echo "</table><br clear=\"all\" />\n";
-}
-
-
-function journal_add_instance($journal) {
-// Given an object containing all the necessary data, 
-// (defined by the form in mod.html) this function 
-// will create a new instance and return the id number 
-// of the new instance.
-
-    $journal->timemodified = time();
-
-    return insert_record("journal", $journal);
-}
-
-
-function journal_update_instance($journal) {
-// Given an object containing all the necessary data, 
-// (defined by the form in mod.html) this function 
-// will update an existing instance with new data.
-
-    $journal->timemodified = time();
-    $journal->id = $journal->instance;
-
-    return update_record("journal", $journal);
-}
-
-
-function journal_delete_instance($id) {
-// Given an ID of an instance of this module, 
-// this function will permanently delete the instance 
-// and any data that depends on it.  
-
-    if (! $journal = get_record("journal", "id", $id)) {
-        return false;
-    }
-
-    $result = true;
-
-    if (! delete_records("journal_entries", "journal", $journal->id)) {
-        $result = false;
-    }
-
-    if (! delete_records("journal", "id", $journal->id)) {
-        $result = false;
-    }
-
-    return $result;
-
-}
-
-
-function journal_print_feedback($course, $entry, $grades) {
-    global $CFG;
-
-    if (! $teacher = get_record('user', 'id', $entry->teacher)) {
-        print_error('Weird journal error');
-    }
-
-    echo '<table cellspacing="0" align="center" class="feedbackbox">';
-
-    echo '<tr>';
-    echo '<td class="left picture">';
-    print_user_picture($teacher->id, $course->id, $teacher->picture);
-    echo '</td>';
-    echo '<td class="entryheader">';
-    echo '<span class="author">'.fullname($teacher).'</span>';
-    echo '&nbsp;&nbsp;<span class="time">'.userdate($entry->timemarked).'</span>';
-    echo '</td>';
-    echo '</tr>';
-
-    echo '<tr>';
-    echo '<td class="left side">&nbsp;</td>';
-    echo '<td class="entrycontent">';
-
-    echo '<div class="grade">';
-    
-    if (!empty($entry->rating) and !empty($grades[$entry->rating])) {
-        echo get_string('grade').': ';
-        echo $grades[$entry->rating];
-    } else {
-        print_string('nograde');
-    }
-    echo '</div>';
-
-    echo format_text($entry->entrycomment);
-    echo '</td></tr></table>';
-}
-
-function journal_get_view_actions() {
-    return array('view','view all','view responses');
-}
-
-function journal_get_post_actions() {
-    return array('add entry','update entry','update feedback');
-}
-
-?>
diff --git a/mod/journal/mod_form.php b/mod/journal/mod_form.php
deleted file mode 100644 (file)
index 8ad9112..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-require_once ($CFG->dirroot.'/course/moodleform_mod.php');
-
-class mod_journal_mod_form extends moodleform_mod {
-
-    function definition() {
-
-        global $COURSE;
-        $mform    =& $this->_form;
-
-//-------------------------------------------------------------------------------
-        $mform->addElement('header', 'general', get_string('general', 'form'));
-
-        $mform->addElement('text', 'name', get_string('journalname', 'journal'), array('size'=>'64'));
-        $mform->setType('name', PARAM_TEXT);
-        $mform->addRule('name', null, 'required', null, 'client');
-
-        $mform->addElement('htmleditor', 'intro', get_string('journalquestion', 'journal'));
-        $mform->setType('intro', PARAM_RAW);
-        $mform->addRule('intro', get_string('required'), 'required', null, 'client');
-        $mform->setHelpButton('intro', array('writing', 'questions', 'richtext'), false, 'editorhelpbutton');
-
-        $mform->addElement('format', 'format', get_string('format'));
-
-        $mform->addElement('modgrade', 'assessed', get_string('grade'), false);
-        $mform->setDefault('assessed', 0);
-
-        $options = array();
-        $options[0] = get_string('alwaysopen', 'journal');
-        for ($i=1;$i<=13;$i++) {
-            $options[$i] = get_string('numdays', '', $i);
-        }
-        for ($i=2;$i<=16;$i++) {
-            $days = $i * 7;
-            $options[$days] = get_string('numweeks', '', $i);
-        }
-        $options[365] = get_string('numweeks', '', 52);
-        $mform->addElement('select', 'days', get_string('daysavailable', 'journal'), $options);
-        if ($COURSE->format == 'weeks') {
-            $mform->setDefault('days', '7');
-        } else {
-            $mform->setDefault('days', '0');
-        }
-
-//-------------------------------------------------------------------------------
-        $this->standard_coursemodule_elements();
-//-------------------------------------------------------------------------------
-// buttons
-        $this->add_action_buttons();
-
-    }
-
-
-
-}
-?>
diff --git a/mod/journal/report.php b/mod/journal/report.php
deleted file mode 100644 (file)
index 58762c6..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-<?php // $Id$
-
-    require_once("../../config.php");
-    require_once("lib.php");
-
-    $id = required_param('id', PARAM_INT);   // course module
-
-    if (! $cm = get_coursemodule_from_id('journal', $id)) {
-        print_error("Course Module ID was incorrect");
-    }
-
-    if (! $course = get_record("course", "id", $cm->course)) {
-        print_error("Course module is misconfigured");
-    }
-
-    require_login($course->id, false, $cm);
-
-    if (!isteacher($course->id)) {
-        print_error("Only teachers can look at this page");
-    }
-
-    if (! $journal = get_record("journal", "id", $cm->instance)) {
-        print_error("Course module is incorrect");
-    }
-
-    // make some easy ways to access the entries.
-    if ( $eee = get_records("journal_entries", "journal", $journal->id)) {
-        foreach ($eee as $ee) {
-            $entrybyuser[$ee->userid] = $ee;
-            $entrybyentry[$ee->id]  = $ee;
-        }
-
-    } else {
-        $entrybyuser  = array () ;
-        $entrybyentry = array () ;
-    }
-
-    $strentries = get_string("entries", "journal");
-    $strjournals = get_string("modulenameplural", "journal");
-
-    $navigation = build_navigation($strentries, $cm);
-    print_header_simple("$strjournals", "", $navigation, "", "", true);
-
-/// Check to see if groups are being used in this journal
-    $groupmode = groupmode($course, $cm);
-    $currentgroup = setup_and_print_groups($course, $groupmode, "report.php?id=$cm->id");
-
-/// Process incoming data if there is any
-    if ($data = data_submitted()) {
-
-        $feedback = array();
-        $data = (array)$data;
-
-        // Peel out all the data from variable names.
-        foreach ($data as $key => $val) {
-            if ($key <> "id") {
-                $type = substr($key,0,1);
-                $num  = substr($key,1);
-                $feedback[$num][$type] = $val;
-            }
-        }
-
-        $timenow = time();
-        $count = 0;
-        foreach ($feedback as $num => $vals) {
-            $entry = $entrybyentry[$num];
-            // Only update entries where feedback has actually changed.
-            if (($vals['r'] <> $entry->rating) || ($vals['c'] <> addslashes($entry->entrycomment))) {
-                $newentry->rating     = $vals['r'];
-                $newentry->entrycomment    = $vals['c'];
-                $newentry->teacher    = $USER->id;
-                $newentry->timemarked = $timenow;
-                $newentry->mailed     = 0;           // Make sure mail goes out (again, even)
-                $newentry->id         = $num;
-                if (! update_record("journal_entries", $newentry)) {
-                    notify("Failed to update the journal feedback for user $entry->userid");
-                } else {
-                    $count++;
-                }
-                $entrybyuser[$entry->userid]->rating     = $vals['r'];
-                $entrybyuser[$entry->userid]->entrycomment    = $vals['c'];
-                $entrybyuser[$entry->userid]->teacher    = $USER->id;
-                $entrybyuser[$entry->userid]->timemarked = $timenow;
-            }
-        }
-        add_to_log($course->id, "journal", "update feedback", "report.php?id=$cm->id", "$count users", $cm->id);
-        notify(get_string("feedbackupdated", "journal", "$count"), "green");
-    } else {
-        add_to_log($course->id, "journal", "view responses", "report.php?id=$cm->id", "$journal->id", $cm->id);
-    }
-
-/// Print out the journal entries
-
-    if ($currentgroup) {
-        $users = get_group_users($currentgroup);
-    } else {
-        $users = get_course_students($course->id);
-    }
-
-    if (!$users) {
-        print_heading(get_string("nousersyet"));
-
-    } else {
-
-        $grades = make_grades_menu($journal->assessed);
-        $teachers = get_course_teachers($course->id);
-
-        $allowedtograde = ($groupmode != VISIBLEGROUPS or isteacheredit($course->id) or groups_is_member($currentgroup));
-
-        if ($allowedtograde) {
-            echo '<form action="report.php" method="post">';
-        }
-
-        if ($usersdone = journal_get_users_done($journal)) {
-            foreach ($usersdone as $user) {
-                if ($currentgroup) {
-                    if (!groups_is_member($currentgroup, $user->id)) {    /// Yes, it's inefficient, but this module will die
-                        continue;
-                    }
-                }
-                journal_print_user_entry($course, $user, $entrybyuser[$user->id], $teachers, $grades);
-                unset($users[$user->id]);
-            }
-        }
-
-        foreach ($users as $user) {       // Remaining users
-            journal_print_user_entry($course, $user, NULL, $teachers, $grades);
-        }
-
-        if ($allowedtograde) {
-            echo "<center>";
-            echo "<input type=\"hidden\" name=\"id\" value=\"$cm->id\" />";
-            echo "<input type=\"submit\" value=\"".get_string("saveallfeedback", "journal")."\" />";
-            echo "</center>";
-            echo "</form>";
-        }
-    }
-
-    print_footer($course);
-
-?>
diff --git a/mod/journal/restorelib.php b/mod/journal/restorelib.php
deleted file mode 100644 (file)
index ce8ff0f..0000000
+++ /dev/null
@@ -1,341 +0,0 @@
-<?php //$Id$
-    //This php script contains all the stuff to backup/restore
-    //journal mods
-
-    //This is the "graphical" structure of the journal mod:
-    //
-    //                      journal                                      
-    //                    (CL,pk->id)
-    //                        |
-    //                        |
-    //                        |
-    //                   journal_entries 
-    //               (UL,pk->id, fk->journal)     
-    //
-    // Meaning: pk->primary key field of the table
-    //          fk->foreign key to link with parent
-    //          nt->nested field (recursive data)
-    //          CL->course level info
-    //          UL->user level info
-    //          files->table may have files)
-    //
-    //-----------------------------------------------------------
-
-    //This function executes all the restore procedure about this mod
-    function journal_restore_mods($mod,$restore) {
-
-        global $CFG;
-
-        $status = true;
-
-        //Get record from backup_ids
-        $data = backup_getid($restore->backup_unique_code,$mod->modtype,$mod->id);
-
-        if ($data) {
-            //Now get completed xmlized object
-            $info = $data->info;
-            //if necessary, write to restorelog and adjust date/time fields
-            if ($restore->course_startdateoffset) {
-                restore_log_date_changes('Journal', $restore, $info['MOD']['#'], array('TIMEMODIFIED'));
-            }
-            //traverse_xmlize($info);                                                                     //Debug
-            //print_object ($GLOBALS['traverse_array']);                                                  //Debug
-            //$GLOBALS['traverse_array']="";                                                              //Debug
-
-            //Now, build the JOURNAL record structure
-            $journal->course = $restore->course_id;
-            $journal->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
-            $journal->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']);
-            $journal->introformat = backup_todb($info['MOD']['#']['INTROFORMAT']['0']['#']);
-            $journal->days = backup_todb($info['MOD']['#']['DAYS']['0']['#']);
-            $journal->assessed = backup_todb($info['MOD']['#']['ASSESSED']['0']['#']);
-            $journal->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
-
-            //We have to recode the assessed field if it is <0 (scale)
-            if ($journal->assessed < 0) {
-                $scale = backup_getid($restore->backup_unique_code,"scale",abs($journal->assessed));
-                if ($scale) {
-                    $journal->assessed = -($scale->new_id);
-                }
-            }
-
-            //The structure is equal to the db, so insert the journal
-            $newid = insert_record ("journal",$journal);
-
-            //Do some output
-            if (!defined('RESTORE_SILENTLY')) {
-                echo "<li>".get_string("modulename","journal")." \"".format_string(stripslashes($journal->name),true)."\"</li>";
-            }
-            backup_flush(300);
-
-            if ($newid) {
-                //We have the newid, update backup_ids
-                backup_putid($restore->backup_unique_code,$mod->modtype,
-                             $mod->id, $newid);
-                //Now check if want to restore user data and do it.
-                if (restore_userdata_selected($restore,'journal',$mod->id)) {
-                    //Restore journal_entries
-                    $status = journal_entries_restore_mods ($mod->id, $newid,$info,$restore);
-                }
-            } else {
-                $status = false;
-            }
-        } else {
-            $status = false;
-        }
-
-        return $status;
-    }
-
-
-    //This function restores the journal_entries
-    function journal_entries_restore_mods($old_journal_id, $new_journal_id,$info,$restore) {
-
-        global $CFG;
-
-        $status = true;
-
-        //Get the entries array
-        $entries = $info['MOD']['#']['ENTRIES']['0']['#']['ENTRY'];
-
-        //Iterate over entries
-        for($i = 0; $i < sizeof($entries); $i++) {
-            $entry_info = $entries[$i];
-            //traverse_xmlize($entry_info);                                                               //Debug
-            //print_object ($GLOBALS['traverse_array']);                                                  //Debug
-            //$GLOBALS['traverse_array']="";                                                              //Debug
-
-            //We'll need this later!! $sub_info changed to $entry_info
-            $oldid = backup_todb($entry_info['#']['ID']['0']['#']);
-            $olduserid = backup_todb($entry_info['#']['USERID']['0']['#']);
-
-            //Now, build the JOURNAL_ENTRIES record structure
-            $entry->journal = $new_journal_id;
-            $entry->userid = backup_todb($entry_info['#']['USERID']['0']['#']);
-            $entry->modified = backup_todb($entry_info['#']['MODIFIED']['0']['#']);
-            $entry->modified += $restore->course_startdateoffset;
-            $entry->text = backup_todb($entry_info['#']['TEXT']['0']['#']);
-            $entry->format = backup_todb($entry_info['#']['FORMAT']['0']['#']);
-            $entry->rating = backup_todb($entry_info['#']['RATING']['0']['#']);
-            if (isset($entry_info['#']['COMMENT']['0']['#'])) {
-                $entry->entrycomment = backup_todb($entry_info['#']['COMMENT']['0']['#']);
-            } else {
-                $entry->entrycomment = backup_todb($entry_info['#']['ENTRYCOMMENT']['0']['#']);
-            }
-            $entry->teacher = backup_todb($entry_info['#']['TEACHER']['0']['#']);
-            $entry->timemarked = backup_todb($entry_info['#']['TIMEMARKED']['0']['#']);
-            $entry->timemarked += $restore->course_startdateoffset;
-            $entry->mailed = backup_todb($entry_info['#']['MAILED']['0']['#']);
-
-            //We have to recode the userid field
-            $user = backup_getid($restore->backup_unique_code,"user",$entry->userid);
-            if ($user) {
-                $entry->userid = $user->new_id;
-            }
-
-            //We have to recode the teacher field
-            $user = backup_getid($restore->backup_unique_code,"user",$entry->teacher);
-            if ($user) {
-                $entry->teacher = $user->new_id;
-            }
-
-            //The structure is equal to the db, so insert the journal_entry
-            $newid = insert_record ("journal_entries",$entry);
-
-            //Do some output
-            if (($i+1) % 50 == 0) {
-                if (!defined('RESTORE_SILENTLY')) {
-                    echo ".";
-                    if (($i+1) % 1000 == 0) {
-                        echo "<br />";
-                    }
-                }
-                backup_flush(300);
-            }
-
-            if ($newid) {
-                //We have the newid, update backup_ids
-                backup_putid($restore->backup_unique_code,"journal_entry",$oldid,
-                             $newid);
-            } else {
-                $status = false;
-            }
-        }
-
-        return $status;
-    }
-
-    //This function converts texts in FORMAT_WIKI to FORMAT_MARKDOWN for
-    //some texts in the module
-    function journal_restore_wiki2markdown ($restore) {
-
-        global $CFG;
-
-        $status = true;
-
-        //Convert journal_entries->text
-        if ($records = get_records_sql ("SELECT e.id, e.text, e.format
-                                         FROM {$CFG->prefix}journal_entries e,
-                                              {$CFG->prefix}journal j,
-                                              {$CFG->prefix}backup_ids b
-                                         WHERE j.id = e.journal AND
-                                               j.course = $restore->course_id AND
-                                               e.format = ".FORMAT_WIKI. " AND
-                                               b.backup_code = $restore->backup_unique_code AND
-                                               b.table_name = 'journal_entries' AND
-                                               b.new_id = e.id")) {
-            foreach ($records as $record) {
-                //Rebuild wiki links
-                $record->text = restore_decode_wiki_content($record->text, $restore);
-                //Convert to Markdown
-                $wtm = new WikiToMarkdown();
-                $record->text = $wtm->convert($record->text, $restore->course_id);
-                $record->format = FORMAT_MARKDOWN;
-                $status = update_record('journal_entries', addslashes_object($record));
-                //Do some output
-                $i++;
-                if (($i+1) % 1 == 0) {
-                    if (!defined('RESTORE_SILENTLY')) {
-                        echo ".";
-                        if (($i+1) % 20 == 0) {
-                            echo "<br />";
-                        }
-                    }
-                    backup_flush(300);
-                }
-            }
-
-        }
-
-        //Convert journal->intro
-        if ($records = get_records_sql ("SELECT j.id, j.intro, j.introformat
-                                         FROM {$CFG->prefix}journal j,
-                                              {$CFG->prefix}backup_ids b
-                                         WHERE j.course = $restore->course_id AND
-                                               j.introformat = ".FORMAT_WIKI. " AND
-                                               b.backup_code = $restore->backup_unique_code AND
-                                               b.table_name = 'journal' AND
-                                               b.new_id = j.id")) {
-            foreach ($records as $record) {
-                //Rebuild wiki links
-                $record->intro = restore_decode_wiki_content($record->intro, $restore);
-                //Convert to Markdown
-                $wtm = new WikiToMarkdown();
-                $record->intro = $wtm->convert($record->intro, $restore->course_id);
-                $record->introformat = FORMAT_MARKDOWN;
-                $status = update_record('journal', addslashes_object($record));
-                //Do some output
-                $i++;
-                if (($i+1) % 1 == 0) {
-                    if (!defined('RESTORE_SILENTLY')) {
-                        echo ".";
-                        if (($i+1) % 20 == 0) {
-                            echo "<br />";
-                        }
-                    }
-                    backup_flush(300);
-                }
-            }
-
-        }
-
-        return $status;
-    }
-
-    //This function returns a log record with all the necessay transformations
-    //done. It's used by restore_log_module() to restore modules log.
-    function journal_restore_logs($restore,$log) {
-    
-        $status = false;
-
-        //Depending of the action, we recode different things
-        switch ($log->action) {
-        case "add":
-            if ($log->cmid) {
-                //Get the new_id of the module (to recode the info field)
-                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
-                if ($mod) {
-                    $log->url = "view.php?id=".$log->cmid;
-                    $log->info = $mod->new_id;
-                    $status = true;
-                }
-            }
-            break;
-        case "update":
-            if ($log->cmid) {
-                //Get the new_id of the module (to recode the info field)
-                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
-                if ($mod) {
-                    $log->url = "view.php?id=".$log->cmid;
-                    $log->info = $mod->new_id;
-                    $status = true;
-                }
-            }
-            break;
-        case "view":
-            if ($log->cmid) {
-                //Get the new_id of the module (to recode the info field)
-                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
-                if ($mod) {
-                    $log->url = "view.php?id=".$log->cmid;
-                    $log->info = $mod->new_id;
-                    $status = true;
-                }
-            }
-            break;
-        case "add entry":
-            if ($log->cmid) {
-                //Get the new_id of the module (to recode the info field)
-                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
-                if ($mod) {
-                    $log->url = "view.php?id=".$log->cmid;
-                    $log->info = $mod->new_id;
-                    $status = true;
-                }
-            }
-            break;
-        case "update entry":
-            if ($log->cmid) {
-                //Get the new_id of the module (to recode the info field)
-                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
-                if ($mod) {
-                    $log->url = "view.php?id=".$log->cmid;
-                    $log->info = $mod->new_id;
-                    $status = true;
-                }
-            }
-            break;
-        case "view responses":
-            if ($log->cmid) {
-                //Get the new_id of the module (to recode the info field)
-                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
-                if ($mod) {
-                    $log->url = "report.php?id=".$log->cmid;
-                    $log->info = $mod->new_id;
-                    $status = true;
-                }
-            }
-            break;
-        case "update feedback":
-            if ($log->cmid) {
-                $log->url = "report.php?id=".$log->cmid;
-                $status = true;
-            }
-            break;
-        case "view all":
-            $log->url = "index.php?id=".$log->course;
-            $status = true;
-            break;
-        default:
-            if (!defined('RESTORE_SILENTLY')) {
-                echo "action (".$log->module."-".$log->action.") unknown. Not restored<br />";                 //Debug
-            }
-            break;
-        }
-
-        if ($status) {
-            $status = $log;
-        }
-        return $status;
-    }
-?>
diff --git a/mod/journal/version.php b/mod/journal/version.php
deleted file mode 100644 (file)
index 5b5ec1d..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php // $Id$
-
-////////////////////////////////////////////////////////////////////////////////
-//  Code fragment to define the module version etc.
-//  This fragment is called by /admin/index.php
-////////////////////////////////////////////////////////////////////////////////
-
-$module->version  = 2007101509;
-$module->requires = 2007101509;  // Requires this Moodle version
-$module->cron     = 60;
-
-?>
diff --git a/mod/journal/view.php b/mod/journal/view.php
deleted file mode 100644 (file)
index 0283f5f..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-<?php  // $Id$
-
-    require_once("../../config.php");
-    require_once("lib.php");
-
-    $id = required_param('id', PARAM_INT);    // Course Module ID
-
-    if (! $cm = get_coursemodule_from_id('journal', $id)) {
-        print_error("Course Module ID was incorrect");
-    }
-
-    if (! $course = get_record("course", "id", $cm->course)) {
-        print_error("Course is misconfigured");
-    }
-
-    require_login($course->id, true, $cm);
-
-    if (! $journal = get_record("journal", "id", $cm->instance)) {
-        print_error("Course module is incorrect");
-    }
-
-    add_to_log($course->id, "journal", "view", "view.php?id=$cm->id", $journal->id, $cm->id);
-
-    if (! $cw = get_record("course_sections", "id", $cm->section)) {
-        print_error("Course module is incorrect");
-    }
-
-    $strjournal = get_string("modulename", "journal");
-    $strjournals = get_string("modulenameplural", "journal");
-    
-    $navigation = build_navigation('', $cm);
-    print_header_simple(format_string($journal->name), '', $navigation, '', '', true,
-                  update_module_button($cm->id, $course->id, $strjournal), navmenu($course, $cm));
-
-/// Check to see if groups are being used here
-    $groupmode = groupmode($course, $cm);
-    $currentgroup = setup_and_print_groups($course, $groupmode, "view.php?id=$cm->id");
-
-    if (isteacher($course->id)) {
-        $entrycount = journal_count_entries($journal, $currentgroup);
-
-        echo '<div class="reportlink"><a href="report.php?id='.$cm->id.'">'.
-              get_string('viewallentries','journal', $entrycount).'</a></div>';
-
-    }
-
-    $journal->intro = trim($journal->intro);
-
-    if (!empty($journal->intro)) {
-        print_box( format_text($journal->intro,  $journal->introformat), 'generalbox', 'intro');
-    }
-
-    echo '<br />';
-
-    $timenow = time();
-
-    if ($course->format == 'weeks' and $journal->days) {
-        $timestart = $course->startdate + (($cw->section - 1) * 604800);
-        if ($journal->days) {
-            $timefinish = $timestart + (3600 * 24 * $journal->days);
-        } else {
-            $timefinish = $course->enddate;
-        }
-    } else {  // Have no time limits on the journals
-
-        $timestart = $timenow - 1;
-        $timefinish = $timenow + 1;
-        $journal->days = 0;
-    }
-
-    if ($timenow > $timestart) {
-
-        print_simple_box_start('center');
-
-        if ($timenow < $timefinish) {
-            $options = array ('id' => "$cm->id");
-            echo '<center>';
-            if (!isguest()) {
-                print_single_button('edit.php', $options, get_string('startoredit','journal'));
-            }
-            echo '</center>';
-        }
-
-
-        if ($entry = get_record('journal_entries', 'userid', $USER->id, 'journal', $journal->id)) {
-
-            if (empty($entry->text)) {
-                echo '<p align="center"><b>'.get_string('blankentry','journal').'</b></p>';
-            } else {
-                echo format_text($entry->text, $entry->format);
-            }
-
-        } else {
-            echo '<span class="warning">'.get_string('notstarted','journal').'</span>';
-        }
-
-        print_simple_box_end();
-
-        if ($timenow < $timefinish) {
-            if (!empty($entry->modified)) {
-                echo '<div class="lastedit"><strong>'.get_string('lastedited').':</strong> ';
-                echo userdate($entry->modified);
-                echo ' ('.get_string('numwords', '', count_words($entry->text)).')';
-                echo "</div>";
-            }
-            if (!empty($journal->days)) {
-                echo '<div class="editend"><strong>'.get_string('editingends', 'journal').':</strong> ';
-                echo userdate($timefinish).'</div>';
-            }
-        } else {
-            echo '<div class="editend"><strong>'.get_string('editingended', 'journal').':</strong> ';
-            echo userdate($timefinish).'</div>';
-        }
-
-        if (!empty($entry->entrycomment) or !empty($entry->rating)) {
-            $grades = make_grades_menu($journal->assessed);
-            print_heading(get_string('feedback'));
-            journal_print_feedback($course, $entry, $grades);
-        }
-
-
-    } else {
-        echo '<div class="warning">'.get_string('notopenuntil', 'journal').': ';
-        echo userdate($timestart).'</div>';
-    }
-
-
-    print_footer($course);
-
-?>
diff --git a/mod/label/db/mysql.php b/mod/label/db/mysql.php
deleted file mode 100644 (file)
index 43cce9e..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function label_upgrade($oldversion) {
-
-/// This function does anything necessary to upgrade 
-/// older versions to match current functionality 
-
-    global $CFG;
-
-    if ($oldversion < 2003091400) {
-        table_column("label", "", "course", "integer", "10", "unsigned", "0", "not null", "id");
-    }
-
-    if ($oldversion < 2004021900) {
-        modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('label', 'add', 'quiz', 'name');");
-        modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('label', 'update', 'quiz', 'name');");
-    }
-
-    if ($oldversion < 2004111200) { //DROP first
-        execute_sql("ALTER TABLE {$CFG->prefix}label DROP INDEX course;",false);
-        modify_database('','ALTER TABLE prefix_label ADD INDEX course (course);');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-
-}
-
-?>
diff --git a/mod/label/db/postgres7.php b/mod/label/db/postgres7.php
deleted file mode 100644 (file)
index 91dceab..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function label_upgrade($oldversion) {
-
-/// This function does anything necessary to upgrade 
-
-/// older versions to match current functionality 
-
-
-
-    global $CFG;
-
-
-
-    if ($oldversion < 2003091400) {
-
-        table_column("label", "", "course", "integer", "10", "unsigned", "0", "not null", "id");
-
-    }
-
-
-
-    if ($oldversion < 2004021900) {
-
-        modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('label', 'add', 'quiz', 'name');");
-
-        modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('label', 'update', 'quiz', 'name');");
-
-    }
-
-    if ($oldversion < 2004111200) { //DROP first
-        execute_sql("DROP INDEX {$CFG->prefix}label_course_idx;",false);
-
-        modify_database('','CREATE INDEX prefix_label_course_idx ON prefix_label (course);');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-
-}
-
-
-?>
diff --git a/mod/lams/constants.php b/mod/lams/constants.php
deleted file mode 100644 (file)
index dae5323..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php  /// LAMS constants
-
-$LAMSCONSTANTS = new object();
-
-$LAMSCONSTANTS->login_request   = '/LoginRequest';
-$LAMSCONSTANTS->param_uid       = 'uid';
-$LAMSCONSTANTS->param_serverid  = 'sid';
-$LAMSCONSTANTS->param_timestamp = 'ts';
-$LAMSCONSTANTS->param_hash      = 'hash';
-$LAMSCONSTANTS->param_method    = 'method';
-$LAMSCONSTANTS->param_lsid      = 'lsid';
-$LAMSCONSTANTS->param_ldid      = 'ldid';
-$LAMSCONSTANTS->param_courseid  = 'course_id';
-$LAMSCONSTANTS->author_method   = 'author';
-$LAMSCONSTANTS->monitor_method  = 'monitor';
-$LAMSCONSTANTS->learner_method  = 'learner';
-
-?>
diff --git a/mod/lams/db/access.php b/mod/lams/db/access.php
deleted file mode 100644 (file)
index d229e12..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php // $Id$
-/**
- * Capability definitions for the lams module.
- *
- * For naming conventions, see lib/db/access.php.
- */
-$mod_lams_capabilities = array(
-
-    'mod/lams:participate' => array(
-
-        'captype' => 'write',
-        'contextlevel' => CONTEXT_MODULE,
-        'legacy' => array(
-            'student' => CAP_ALLOW
-        )
-    ),
-
-    'mod/lams:manage' => array(
-
-        'captype' => 'write',
-        'contextlevel' => CONTEXT_MODULE,
-        'legacy' => array(
-            'teacher' => CAP_ALLOW,
-            'editingteacher' => CAP_ALLOW,
-            'admin' => CAP_ALLOW
-        )
-    )
-);
diff --git a/mod/lams/db/install.xml b/mod/lams/db/install.xml
deleted file mode 100644 (file)
index 6e7566d..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/lams/db" VERSION="20060811" COMMENT="XMLDB file for Moodle mod/lams">
-  <TABLES>
-    <TABLE NAME="lams" COMMENT="LAMS activity">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="course"/>
-        <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="name"/>
-        <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="course" NEXT="introduction"/>
-        <FIELD NAME="introduction" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="learning_session_id"/>
-        <FIELD NAME="learning_session_id" TYPE="int" LENGTH="20" NOTNULL="false" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="introduction" NEXT="timemodified"/>
-        <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="learning_session_id"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" />
-      </KEYS>
-      <INDEXES>
-        <INDEX NAME="course" UNIQUE="false" FIELDS="course"/>
-      </INDEXES>
-    </TABLE>
-  </TABLES>
-</XMLDB>
diff --git a/mod/lams/db/mysql.php b/mod/lams/db/mysql.php
deleted file mode 100644 (file)
index dc0ab50..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<?PHP
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function lams_upgrade($oldversion) {
-/// This function does anything necessary to upgrade 
-/// older versions to match current functionality 
-
-    global $CFG;
-
-    if ($oldversion < 2005062800) {
-
-       # Do something ...
-
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/mod/lams/db/postgres7.php b/mod/lams/db/postgres7.php
deleted file mode 100644 (file)
index dc0ab50..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<?PHP
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function lams_upgrade($oldversion) {
-/// This function does anything necessary to upgrade 
-/// older versions to match current functionality 
-
-    global $CFG;
-
-    if ($oldversion < 2005062800) {
-
-       # Do something ...
-
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/mod/lams/db/upgrade.php b/mod/lams/db/upgrade.php
deleted file mode 100644 (file)
index 2c8ae36..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php  //$Id$
-
-// This file keeps track of upgrades to 
-// the lams module
-//
-// Sometimes, changes between versions involve
-// alterations to database structures and other
-// major things that may break installations.
-//
-// The upgrade function in this file will attempt
-// to perform all the necessary actions to upgrade
-// your older installtion to the current version.
-//
-// If there's something it cannot do itself, it
-// will tell you what you need to do.
-//
-// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
-
-function xmldb_lams_upgrade($oldversion=0) {
-
-    global $CFG, $THEME, $db;
-
-    $result = true;
-
-/// And upgrade begins here. For each one, you'll need one 
-/// block of code similar to the next one. Please, delete 
-/// this comment lines once this file start handling proper
-/// upgrade code.
-
-/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-///     $result = result of "/lib/ddllib.php" function calls
-/// }
-
-    return $result;
-}
-
-?>
diff --git a/mod/lams/defaults.php b/mod/lams/defaults.php
deleted file mode 100644 (file)
index 38545d7..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php   // LAMS is disabled by default
-    if (empty($CFG->lams_initialdisable)) {
-        if (!count_records('lams')) {
-            set_field('modules', 'visible', 0, 'name', 'lams');  // Disable it by default
-            set_config('lams_initialdisable', 1);
-        }
-    }
-?>
diff --git a/mod/lams/icon.gif b/mod/lams/icon.gif
deleted file mode 100644 (file)
index 291d29e..0000000
Binary files a/mod/lams/icon.gif and /dev/null differ
diff --git a/mod/lams/index.php b/mod/lams/index.php
deleted file mode 100644 (file)
index 97789e9..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-<?php // $Id$
-
-/// This page lists all the instances of lams in a particular course
-
-    require_once("../../config.php");
-    require_once("lib.php");
-
-    $id = required_param('id', PARAM_INT);   // course
-
-    if (! $course = get_record("course", "id", $id)) {
-        print_error("Course ID is incorrect");
-    }
-
-    require_login($course->id);
-
-    add_to_log($course->id, "lams", "view all", "index.php?id=$course->id", "");
-
-
-/// Get all required strings
-
-    $strlamss = get_string("modulenameplural", "lams");
-    $strlams  = get_string("modulename", "lams");
-
-
-/// Print the header
-
-    $navlinks = array();
-    $navlinks[] = array('name' => $strlamss, 'link' => '', 'type' => 'activity');
-    $navigation = build_navigation($navlinks);
-
-    print_header("$course->shortname: $strlamss", $course->fullname, "$navigation $strlamss", "", "", true, "", navmenu($course));
-
-/// Get all the appropriate data
-
-    if (! $lamss = get_all_instances_in_course("lams", $course)) {
-        notice(get_string('thereareno', 'moodle', $strlamss) , "../../course/view.php?id=$course->id");
-        die;
-    }
-
-/// Print the list of instances (your module will probably extend this)
-
-    $timenow = time();
-    $strname  = get_string("name");
-    $strweek  = get_string("week");
-    $strtopic  = get_string("topic");
-
-    if ($course->format == "weeks") {
-        $table->head  = array ($strweek, $strname);
-        $table->align = array ('center', 'left');
-    } else if ($course->format == "topics") {
-        $table->head  = array ($strtopic, $strname);
-        $table->align = array ('center', 'left', 'left', 'left');
-    } else {
-        $table->head  = array ($strname);
-        $table->align = array ('left', 'left', 'left');
-    }
-
-    foreach ($lamss as $lams) {
-        if (!$lams->visible) {
-            //Show dimmed if the mod is hidden
-            $link = "<a class=\"dimmed\" href=\"view.php?id=$lams->coursemodule\">$lams->name</a>";
-        } else {
-            //Show normal if the mod is visible
-            $link = "<a href=\"view.php?id=$lams->coursemodule\">$lams->name</a>";
-        }
-
-        if ($course->format == 'weeks' or $course->format == 'topics') {
-            $table->data[] = array ($lams->section, $link);
-        } else {
-            $table->data[] = array ($link);
-        }
-    }
-
-    echo '<br />';
-
-    print_table($table);
-
-/// Finish the page
-
-    print_footer($course);
-
-?>
diff --git a/mod/lams/lib.php b/mod/lams/lib.php
deleted file mode 100644 (file)
index 68cf22b..0000000
+++ /dev/null
@@ -1,444 +0,0 @@
-<?PHP  // $Id$
-
-/// Library of functions and constants for module lams
-
-if (!defined('MOODLE_INTERNAL')) {
-    die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
-}
-
-require_once($CFG->dirroot.'/lib/soaplib.php');
-
-
-function lams_add_instance($lams) {
-/// Given an object containing all the necessary data,
-/// (defined by the form in mod.html) this function
-/// will create a new instance and return the id number
-/// of the new instance.
-    global $USER;
-    $lams->timemodified = time();
-    $lams->learning_session_id = lams_get_lesson($USER->username,$lams->sequence,$lams->course,$lams->name,$lams->introduction,"normal");
-  return insert_record("lams", $lams);
-}
-
-
-function lams_update_instance($lams) {
-/// Given an object containing all the necessary data,
-/// (defined by the form in mod.html) this function
-/// will update an existing instance with new data.
-    //echo "enter lams_update_instance<br/>";
-  $lams->timemodified = time();
-  $lams->id = $lams->instance;
-  lams_delete_lesson($USER->username,$lams->learning_session_id);
-    $lams->learning_session_id = lams_get_lesson($USER->username,$lams->sequence,$lams->course,$lams->name,$lams->introduction,"normal");
-    if(!$lams->learning_session_id){
-        return false;
-    }
-    # May have to add extra stuff in here #
-  //echo $lams->id."<br/>";
-    //echo $lams->sequence."<br/>";
-    //echo $lams->course."<br/>";
-    //echo $lams->name."<br/>";
-    //echo $lams->introduction."<br/>";
-    //echo $lams->learning_session_id."<br/>";
-    //echo "exit lams_update_instance<br/>";
-  return update_record("lams", $lams);
-}
-
-
-function lams_delete_instance($id) {
-/// Given an ID of an instance of this module,
-/// this function will permanently delete the instance
-/// and any data that depends on it.
-
-  if (! $lams = get_record("lams", "id", "$id")) {
-      return false;
-  }
-
-  $result = true;
-
-  # Delete any dependent records here #
-    lams_delete_lesson($USER->username,$lams->learning_session_id);
-  if (! delete_records("lams", "id", "$lams->id")) {
-      $result = false;
-  }
-
-  return $result;
-}
-
-function lams_user_outline($course, $user, $mod, $lams) {
-/// Return a small object with summary information about what a
-/// user has done with a given particular instance of this module
-/// Used for user activity reports.
-/// $return->time = the time they did it
-/// $return->info = a short text description
-
-  return $return;
-}
-
-function lams_user_complete($course, $user, $mod, $lams) {
-/// Print a detailed representation of what a  user has done with
-/// a given particular instance of this module, for user activity reports.
-
-  return true;
-}
-
-function lams_cron () {
-/// Function to be run periodically according to the moodle cron
-/// This function searches for things that need to be done, such
-/// as sending out mail, toggling flags etc ...
-
-  global $CFG;
-
-  return true;
-}
-
-function lams_grades($lamsid) {
-/// Must return an array of grades for a given instance of this module,
-/// indexed by user.  It also returns a maximum allowed grade.
-///
-///    $return->grades = array of grades;
-///    $return->maxgrade = maximum allowed grade;
-///
-///    return $return;
-
-  return NULL;
-}
-
-function lams_get_participants($lamsid) {
-//Must return an array of user records (all data) who are participants
-//for a given instance of lams. Must include every user involved
-//in the instance, independient of his role (student, teacher, admin...)
-//See other modules as example.
-
-  return false;
-}
-
-function lams_scale_used ($lamsid,$scaleid) {
-//This function returns if a scale is being used by one lams
-//it it has support for grading and scales. Commented code should be
-//modified if necessary. See forum, glossary or journal modules
-//as reference.
-
-  $return = false;
-
-  //$rec = get_record("lams","id","$lamsid","scale","-$scaleid");
-  //
-  //if (!empty($rec)  && !empty($scaleid)) {
-  //    $return = true;
-  //}
-
-  return $return;
-}
-
-/**
- * Checks if scale is being used by any instance of lams
- *
- * This is used to find out if scale used anywhere
- * @param $scaleid int
- * @return boolean True if the scale is used by any lams
- */
-function lams_scale_used_anywhere($scaleid) {
- return false;
-}
-
-//////////////////////////////////////////////////////////////////////////////////////
-/// Any other lams functions go here.  Each of them must have a name that
-/// starts with lams_
-
-function lams_get_soap_client($relativeurl) {
-    global $CFG;
-    if(!isset($CFG->lams_serverurl))
-    {
-        return NULL;
-    }
-    $wsdl = $CFG->lams_serverurl.$relativeurl;
-    $s = new soap_client($wsdl,true,false,false,false,false,2,3);
-    return $s;
-}
-
-/**
- * Get sequences(learning designs) for the user in LAMS
- *
- * @param string $username The username of the user. Set this to "" if you would just like to get sequences for the currently logged in user.
- * @return Array sequence array
- * @TODO complete the documentation of this function
- */
-function lams_get_sequences($username,$courseid) {
-    global $CFG,$USER;
-    if(!isset($CFG->lams_serverid)||!isset($CFG->lams_serverkey)||!isset($CFG->lams_serverurl))
-    {
-        return get_string("notsetup", "lams");
-    }
-    $relativeurl="/services/LearningDesignService?wsdl";
-    $s = lams_get_soap_client($relativeurl);
-    if(is_null($s)){
-        return NULL;
-    }
-    $datetime =    date("F d,Y g:i a");
-    /*
-    $login = lams_get_user($username,$courseid);
-    if(empty($login)){
-        return NULL;
-    }
-    */
-    if(!isset($username)){
-        $username = $USER->username;
-    }
-    $rawstring = trim($datetime).trim($username).trim($CFG->lams_serverid).trim($CFG->lams_serverkey);
-    $hashvalue = sha1(strtolower($rawstring));
-    $parameters = array($CFG->lams_serverid,$datetime,$hashvalue,$username);
-    $result = $s->call('getAllLearningDesigns',$parameters);//Array of simpleLearningDesign objects
-    if($s->getError()){//if some exception happened
-        $result = $s->getError();//return the string describing the error
-    }
-    unset($s);
-    return $result;
-}
-
-/**
- * Get learning session(lesson) id from LAMS
- *
- * @param string $username The username of the user. Set this to "" if you would just like the currently logged in user to create the lesson
- * @param int $ldid The id of the learning design that the lesson is based on
- * @param int $courseid The id of the course that the lesson is associated with.
- * @param string $title The title of the lesson
- * @param string $desc The description of the lesson
- * @param string $type The type of the lesson. Two types: normal, preview
- * @return int lesson id
- */
-function lams_get_lesson($username,$ldid,$courseid,$title,$desc,$type) {
-    //echo "enter lams_get_lesson<br/>";
-    global $CFG,$USER;
-    if(!isset($CFG->lams_serverid)||!isset($CFG->lams_serverkey))
-    {
-        //echo "serverid or serverkey is not set<br/>";
-        return NULL;
-    }
-    $relativeurl="/services/LearningSessionService?wsdl";
-    $s = lams_get_soap_client($relativeurl);
-    if(is_null($s)){
-        //echo "soap client is null<br/>";
-        return NULL;
-    }
-    $datetime =    date("F d,Y g:i a");
-    if(!isset($username)){
-        $username = $USER->username;
-    }
-    $plaintext = $datetime.$username.$CFG->lams_serverid.$CFG->lams_serverkey;
-    //echo $plaintext;
-    $hashvalue = sha1(strtolower($plaintext));
-    //echo $hashvalue;
-    $parameters = array($CFG->lams_serverid,$datetime,$hashvalue,$username,$ldid,$courseid,$title,$desc,$type);
-    $result = $s->call('createLearningSession',$parameters);
-    //echo "result:".$result."<br/>";
-    //echo "exit lams_get_lesson<br/>";
-    if($s->getError()){
-        $result = $s->getError();
-    }
-    unset($s);
-    return $result;
-}
-
-/**
- * Delete learning session(lesson) from LAMS
- *
- * @param string $username The username of the user. Set this to "" if you would just like the currently logged in user to create the lesson
- * @param int $lsid The id of the learning session(lesson)
- * @return true or false
- */
-function lams_delete_lesson($username,$lsid) {
-    //echo "enter lams_get_lesson<br/>";
-    global $CFG,$USER;
-    if(!isset($CFG->lams_serverid)||!isset($CFG->lams_serverkey))
-    {
-        return "The LAMS serverId and serverKey have not been set up";
-    }
-    $relativeurl="/services/LearningSessionService?wsdl";
-    $s = lams_get_soap_client($relativeurl);
-    if(is_null($s)){
-        return "Failed to get soap client based on:".$relativeurl;
-    }
-    $datetime =    date("F d,Y g:i a");
-    if(!isset($username)){
-        $username = $USER->username;
-    }
-    $plaintext = $datetime.$username.$CFG->lams_serverid.$CFG->lams_serverkey;
-    //echo $plaintext;
-    $hashvalue = sha1(strtolower($plaintext));
-    //echo $hashvalue;
-    $parameters = array($CFG->lams_serverid,$datetime,$hashvalue,$username,$lsid);
-    $result = $s->call('deleteLearningSession',$parameters);
-    if($s->getError()){
-        $result = $s->getError();
-    }
-    unset($s);
-    return $result;
-}
-
-
-/**
- * Get class in LAMS
- * @param int courseid
- * @return int class id
- * @TODO complete the documentation of this function
- */
- /*
-function lams_get_class($courseid) {
-    global $CFG,$USER;
-    //echo "enter lams_get_class"."<br/>";
-    $orgId = lams_get_organisation();
-    if(empty($orgId)){
-        return NULL;
-    }
-  $lams_course = get_record("lams_course","course", $courseid);
-  if(empty($lams_course)){//LAMS class hasn't been created
-       //create LAMS class
-      $relativeurl="/services/UserManagementService?wsdl";
-      $s = lams_get_soap_client($relativeurl);
-      if(is_null($s)){
-          return NULL;
-      }
-      $datetime =    date("F d,Y g:i a");
-      $rawstring = $datetime.$CFG->lams_serverid.$CFG->lams_serverkey;
-      $hashvalue = sha1(strtolower($rawstring));
-      $parameters = array($CFG->lams_serverid,$datetime,$hashvalue);
-      $result = $s->call('createClass',$parameters);
-      //echo "<xmp/>".$s->request."</xmp>";
-      //echo "<xmp/>".$s->response."</xmp>";
-      //echo "result:".$result."<br/>";
-       $lams_course->course = $courseid;
-       $lams_course->classid = $result;
-        insert_record("lams_course",$lams_course);
-        //echo "exit lams_get_class"."<br/>";
-         return $result;
-  }else{
-      //echo "exit lams_get_class"."<br/>";
-      return $lams_course->classid;
-  }
-}
-*/
-/**
- * Get organisation in LAMS
- *
- * @return int organisation id
- * @TODO complete the documentation of this function
- */
- /*
-function lams_get_organisation() {
-    global $CFG,$USER;
-    //echo "enter lams_get_organisaiton"."<br/>";
-    if(!isset($CFG->lams_serverid)||!isset($CFG->lams_serverkey))
-    {
-        return NULL;
-    }
-    if(!isset($CFG->lams_orgid)){
-      $relativeurl="/services/UserManagementService?wsdl";
-      $s = lams_get_soap_client($relativeurl);
-      if(empty($s)){
-          return NULL;
-      }
-      $datetime =    date("F d,Y g:i a");
-      $rawstring = $datetime.$CFG->lams_serverid.$CFG->lams_serverkey;
-      $hashvalue = sha1(strtolower($rawstring));
-      $parameters = array($CFG->lams_serverid,$datetime,$hashvalue);
-      $result = $s->call('createOrganisation',$parameters);
-      //echo "<xmp/>".$s->request."</xmp>";
-      //echo "<xmp/>".$s->response."</xmp>";
-      set_config("lams_orgid",$result);
-      //echo "result:".$result."<br/>";
-      //echo "exit lams_get_organisaiton"."<br/>";
-      return $result;
-    }else{
-        //echo "exit lams_get_organisaiton"."<br/>";
-        return $CFG->lams_orgid;
-    }
-}
-*/
-
-/**
- * Get user in LAMS
- *
- * @param string $username The username of the user. Set this to "" if you would just like to create LAMS user for the currently logged in user
- * @param string $roles The user's roles in LAMS
- * @param int $classid The id of the class that the user belongs to. The class should be already created in LAMS by calling lams_create_class()
- * @param int $orgid The id of the organisation that  the user belongs to. The organisation should be already created in LAMS by calling lams_create_organisation()
- * @return user login in LAMS if the user is successfully created
- * @TODO complete the documentation of this function
- */
- /*
-function lams_get_user($username,$courseid) {
-    global $CFG,$USER;
-    //echo "enter lams_get_user"."<br/>";
-    if(!isset($CFG->lams_serverid)||!isset($CFG->lams_serverkey))
-    {
-        return NULL;
-    }
-    $lams_user = get_record("lams_user","username",$username);
-    if(empty($lams_user)){//LAMS user hasn't been created
-        $classid = lams_get_class($courseid);
-        if(empty($classid)){//Can't get class id from lams_course table. Something wrong!
-            return NULL;
-        }
-        $orgid = lams_get_organisation();//It won't be NULL. See lams_get_class function
-        $user = get_record("user","username",$username);
-        if(empty($user)){//Something wrong
-            return NULL;
-        }
-        $roles = lams_get_user_roles($user->id,$courseid);
-      $relativeurl="/services/UserManagementService?wsdl";
-      $s = lams_get_soap_client($relativeurl);
-      if(empty($s)){
-          return NULL;
-      }
-      $datetime =    date("F d,Y g:i a");
-      $login = $username;
-      $rawstring = $datetime.$login.$CFG->lams_serverid.$CFG->lams_serverkey;
-      $hashvalue = sha1(strtolower($rawstring));
-      $parameters = array($CFG->lams_serverid,$datetime,$hashvalue,$login,"password",$roles,$classid,$orgid);
-      $result = $s->call('createUser',$parameters);
-      //echo "<xmp/>".$s->request."</xmp>";
-      //echo "<xmp/>".$s->response."</xmp>";
-      $lams_user->username = $username;
-      $lams_user->login = $result;
-      insert_record("lams_user",$lams_user);
-      //echo "result:".$result."<br/>";
-      //echo "exit lams_get_user"."<br/>";
-      return $result;
-    }else{
-        //echo "exit lams_get_user"."<br/>";
-        return $lams_user->login;
-    }
-}
-*/
-
-/**
- * Mapping moodle roles to LAMS roles
- *
- * @param int $courseid The id of the course that is being viewed
- * @param int $userid The id of the user that is being tested against. Set this to 0 if you would just like to test against the currently logged in user.
- * @return formatted string describing LAMS roles
- * @TODO fill the gap of roles mapping between moodle and LAMS
- */
- /*
-function lams_get_user_roles($userid=0, $courseid){
-    $roles = "";
-    if(isadmin($userid)){
-        $roles = "administrator"."|"."auhtor"."|"."staff";
-    }else    if(isteacheredit($courseid,$userid)){
-        $roles = "auhtor"."|"."staff";
-    }else if(isteacher($courseid,$userid)){
-        $roles = "staff";
-    }
-    if(isstudent($courseid,$userid)){
-        if(empty($roles)){
-            $roles = "learner";
-        }else{
-            $roles .= "|"."learner";
-        }
-    }
-    //echo $roles."<br/>";
-    return $roles;
-}
-*/
-
-?>
diff --git a/mod/lams/list.php b/mod/lams/list.php
deleted file mode 100644 (file)
index 09cfd67..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php // $Id$
-
-/// send LAMS learning deisgn list as a string seperated by ":" to client
-
-require_once("../../config.php");
-require_once("lib.php");
-
-$result = lams_get_sequences($USER->username,$courseid);
-if(is_string($result)){//some exception happened!
-    $auth_exception = "AuthenticateException";
-    $server_not_found_exception = "ServerNotFoundException";
-    if(strpos($result,$auth_exception)){//found AuthenticationException in the error message
-        header("HTTP/1.1 401 Unauthenticated");
-        die;
-    }else if (strpos($result,$server_not_found_exception)){
-        header("HTTP/1.1 417 Expectation Failed");
-        die;
-    }else if ($result=="NOT_SET_UP"){
-        header("HTTP/1.1 402 Setup Required");
-        die;
-    }else{
-        header("HTTP/1.1 502 Bad Gateway");
-        echo $result;
-        die;
-    }
-}
-$list_str = "";
-foreach($result as $design){
-    $list_str .= $design['sid'].",".$design['workspace'].",".$design['title'].":";
-}
-if (strlen($list_str)==0){
-    header("HTTP/1.1 504 Gateway Timeout");
-}else{
-    echo $list_str;
-}
-
-?>
diff --git a/mod/lams/mod.html b/mod/lams/mod.html
deleted file mode 100644 (file)
index 45e80a7..0000000
+++ /dev/null
@@ -1,781 +0,0 @@
-<!-- This page defines the form to create or edit an instance of this module -->
-<!-- It is used from /course/mod.php.  The whole instance is available as $form. -->
-
-<!--
-TODO: display proper message when no sequences are received
--->
-
-<?php
-
-include_once($CFG->dirroot.'/mod/lams/constants.php');
-
-if (!isset($form->name)) {
-    $form->name = '';
-}
-if (!isset($form->introduction)) {
-    $form->introduction = '';
-}
-if (!isset($form->learning_session_id)) {
-    $form->learning_session_id = '';
-}
-
-if (!isset($form->create_sequence_url)) {
-    $datetime =    date("F d,Y g:i a");
-    $plaintext = trim($datetime).trim($USER->username).trim($LAMSCONSTANTS->author_method).trim($CFG->lams_serverid).trim($CFG->lams_serverkey);
-    $hash = sha1(strtolower($plaintext));
-    $form->create_sequence_url = $CFG->lams_serverurl.$LAMSCONSTANTS->login_request.
-        '?'.$LAMSCONSTANTS->param_uid.'='.$USER->username.
-        '&amp;'.$LAMSCONSTANTS->param_method.'='.$LAMSCONSTANTS->author_method.
-        '&amp;'.$LAMSCONSTANTS->param_timestamp.'='.urlencode($datetime).
-        '&amp;'.$LAMSCONSTANTS->param_serverid.'='.$CFG->lams_serverid.
-        '&amp;'.$LAMSCONSTANTS->param_hash.'='.$hash.
-        '&amp;'.$LAMSCONSTANTS->param_courseid.'='.$form->course;
-}
-?>
-
-<form id="form" method="post" action="mod.php" onSubmit="disableSumbit(this);">
-<center>
-<p id="message">Please wait .......</p>
-<table cellpadding="5">
-<tr valign="top">
-<td align="right"><b><?php print_string("workspace", "lams") ?>:</b></td>
-<td>
-<select id="workspace" name="workspace"></select>
-</td>
-</tr>
-<tr>
-<td align="right"><b><?php  print_string("sequence","lams") ?>:</b></td>
-<td>
-<select id="sequence" name="sequence"></select>
-</td>
-</tr>
-<tr>
-<td align="right"><b><?php  print_string("name") ?>:</b></td>
-<td>
-<input type="text" id="name" name="name" size="30" />
-</td>
-</tr>
-<tr>
-<td align="right"><p><b><?php print_string("introduction", "lams") ?>:</b></p>
-<br />
-<!-- <font size="1"> DEPRECATED, USE CSS -->
-<?php
-if ($usehtmleditor) {
-    helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
-} else {
-    helpbutton("text", get_string("helptext"), "moodle", true, true);
-    echo '<br />';
-    emoticonhelpbutton("form", "introduction");
-    echo '<br />';
-}
-?>
-<br />
-<!-- </font> DEPRECATED, USE CSS -->
-</td>
-<td>
-<?php
-print_textarea($usehtmleditor, 20, 50, 680, 400, "introduction", $form->introduction);
-?>
-</td>
-</tr>
-
-<!-- The following line for Moodle 1.5 prints the visibility setting form element -->
-<!-- <?php print_visible_setting($form); ?> -->
-<!-- and if your module uses groups you would also have -->
-<!-- ?php print_groupmode_setting($form); ? -->
-
-</table>
-<input type="hidden" name="learning_session_id"/>
-<input type="hidden" name="create_sequence_url" id="create_sequence_url"/>
-<input type="submit" id="save" name="save" value="<?php print_string("useSequence","lams") ?>" onClick="return validate();" />
-<input type="button" id="edit" name="edit" value="<?php print_string("editSequence","lams") ?>" onClick="openAuthor(<?php
-    echo "'".$form->create_sequence_url."&amp;".$LAMSCONSTANTS->param_ldid."=".@$form->sequence."'";?>);" />
-<input type="button" id="create" name="create" value="<?php print_string("createSequence","lams") ?>" onClick="openAuthor(<?php
-    echo "'".$form->create_sequence_url."'";?>);" />
-<input type="button" id="refresh" name="refresh" value="<?php print_string("refreshSequenceList","lams")?>" onclick="refreshLists();" />
-<input type="submit" id="cancel" name=cancel value="<?php  print_string("cancel") ?>" />
-
-
-<!-- These hidden variables are always the same -->
-<input type="hidden" name=course        value="<?php  p($form->course) ?>" />
-<input type="hidden" name="sesskey"     value="<?php  p($form->sesskey) ?>" />
-<input type="hidden" name=coursemodule  value="<?php  p($form->coursemodule) ?>" />
-<input type="hidden" name=section       value="<?php  p($form->section) ?>" />
-<input type="hidden" name=module        value="<?php  p($form->module) ?>" />
-<input type="hidden" name=modulename    value="<?php  p($form->modulename) ?>" />
-<input type="hidden" name=instance      value="<?php  p($form->instance) ?>" />
-<input type="hidden" name=mode          value="<?php  p($form->mode) ?>" />
-</center>
-
-</form>
-
-<script type="text/javascript">
-//<![CDATA[
-<!--
-function validate(){
-    workspaceObj = document.getElementById("workspace");
-    if (workspaceObj.options.length == 0){
-        alert("No workspace was returned from LAMS server! You may try refreshing sequence list.\nIf you still get the same problem, probably you have to cancel this activity.");
-        return false;
-    }
-    sequenceObj = document.getElementById("sequence");
-    if(sequenceObj.options.length == 0){
-        alert("No sequence was returned from LAMS server! You may try refreshing sequence list.\nIf you still get the same problem, probably you have to cancel this activity.");
-        return false;
-    }
-    if(trim(document.getElementById("name").value).length==0){
-        alert("You have to specify the activity name to proceed.");
-        return false;
-    }
-    return true;
-}
-
-function trim(trim_value){
-    if(trim_value.length < 1){
-        return"";
-    }
-    trim_value = rTrim(trim_value);
-    trim_value = lTrim(trim_value);
-    return trim_value;
-} //End Function
-
-function rTrim(trim_value){
-    var w_space = String.fromCharCode(32);
-    var v_length = trim_value.length;
-    var strTemp = "";
-    if(v_length < 0){
-        return"";
-    }
-    var iTemp = v_length -1;
-
-    while(iTemp > -1){
-        if(trim_value.charAt(iTemp) != w_space){
-            strTemp = trim_value.substring(0,iTemp +1);
-            break;
-        }
-        iTemp = iTemp-1;
-    } //End While
-    return strTemp;
-} //End Function
-
-function lTrim(trim_value){
-    var w_space = String.fromCharCode(32);
-    if(v_length < 1){
-        return"";
-    }
-    var v_length = trim_value.length;
-    var strTemp = "";
-
-    var iTemp = 0;
-
-    while(iTemp < v_length){
-        if(trim_value.charAt(iTemp) != w_space){
-            strTemp = trim_value.substring(iTemp,v_length);
-            break;
-        }
-        iTemp = iTemp + 1;
-    } //End While
-    return strTemp;
-} //End Function
-
-function disableSubmit(dform) {
-    if (document.getElementById) {
-        for (var sch = 0; sch < dform.length; sch++) {
-            if (dform.elements[sch].type.toLowerCase() == "submit") dform.elements[sch].disabled = true;
-        }
-    }
-    return true;
-}
-
-function enableSubmit(dform) {
-    if (document.getElementById) {
-        for (var sch = 0; sch < dform.length; sch++) {
-            if (dform.elements[sch].type.toLowerCase() == "submit") dform.elements[sch].disabled = false;
-        }
-    }
-    return true;
-}
-
-var authorWin = null;
-function openAuthor(url){
-    //alert(url);
-    if(authorWin && authorWin.open && !authorWin.closed){
-        authorWin.document.location = url;
-        authorWin.focus();
-    }else{
-        authorWin = window.open(url);
-        authorWin.focus();
-    }
-}
-
-
-var req;
-/**
- * This function is to initialize elements' status and refresh workspace and sequence lists
- */
-function refreshLists(){
-    document.getElementById("message").innerHTML = "<p>Please wait .......<" + "/p>";
-    disableSubmit(document.forms[0]);
-    document.getElementById("create").disabled = true;
-    document.getElementById("edit").disabled = true;
-    document.getElementById("refresh").disabled = true;
-
-    wsSelectObj = document.getElementById("workspace");
-    wsSelectObj.options.length = 0; //remove all options
-    wsSelectObj.options[0] = new Option("Loading...", "Loading...");
-    wsSelectObj.disabled = true;
-
-    seqSelectObj = document.getElementById("sequence");
-    seqSelectObj.options.length = 0; //remove all options
-
-    //clear the DynamicOptionList
-    dol = new DynamicOptionList("workspace","sequence");
-    dol.setFormName("form");
-
-    url = "../mod/lams/list.php?courseid="+document.getElementById('form').course.value;
-    if (window.XMLHttpRequest) { // Non-IE browsers
-        req = new XMLHttpRequest();
-        req.onreadystatechange = processStateChange;
-        try {
-            req.open("GET", url, true);
-        } catch (e) {
-            alert(e);
-        }
-        req.send(null);
-    } else if (window.ActiveXObject) { // IE
-        req = new ActiveXObject("Microsoft.XMLHTTP");
-        if (req) {
-            req.onreadystatechange = processStateChange;
-            req.open("GET", url, true);
-            req.send();
-        }
-    }
-}
-
-function processStateChange() {
-    if (req.readyState == 4) { // Complete
-        var wsSelectObj = document.getElementById("workspace");
-        wsSelectObj.options.length = 0; //clear the workspace list
-        wsSelectObj.disabled = false;
-        enableSubmit(document.forms[0]);
-        document.getElementById("create").disabled = false;
-        document.getElementById("edit").disabled = false;
-        document.getElementById("refresh").disabled = false;
-        if (req.status == 200) { // OK response
-            var res = req.responseText.replace(/^\s*|\s*$/g,""); //get trimed result
-            var seqlistStr = res.split(':'); //seperate each set of {sid, workspace,sequence}
-            var seqlist = new Array();
-
-            var workspaceList = new Object();
-
-            //pass the response and construct the list again
-            for(var i=0; i<seqlistStr.length; i++){
-                var sws =  seqlistStr[i].split(',');
-                if(sws.length == 3){
-                    var sid = sws[0];
-                    var workspace = sws[1];
-                    var sequence = sws[2];
-
-                    if(workspaceList[workspace] == null){
-                        //set workspace as keys in workspaceList (kind of like a map)
-                        //therefore duplicated workspaces will be ignored
-                        workspaceList[workspace] = 1; //insert workspace as a key
-
-                        //insert workspace into workspace list
-                        wsSelectObj.options[wsSelectObj.length] = new Option(workspace,workspace);
-                    }
-
-                    //insert sequence dependency into DynamicOptionList
-                    dol.forValue(workspace).addOptionsTextValue(sequence,sid);
-                }
-            }
-            initDynamicOptionLists(); //construct the list
-            document.getElementById("message").innerHTML =
-                "<p>Select an existing sequence or create a new sequence.<" + "/p>";
-        }else if(req.status == 504){//gateway timeout. probabaly LAMS server is not available.
-            document.getElementById("message").innerHTML =
-                '<table align="center" width="57%"  class="noticebox" border="0" cellpadding="15" cellspacing="0"><tr><td bgcolor="#FFAAAA" class="noticeboxcontent"><h4   class="main">It seems the LAMS server is not available!<br/> Please contact your administrator.<'+'/h4><'+'/td><'+'/tr><'+'/table>';
-        }else if(req.status == 401){//AuthenticationException thrown by LAMS server.
-            document.getElementById("message").innerHTML =
-                '<table align="center" width="57%"  class="noticebox" border="0" cellpadding="15" cellspacing="0"><tr><td bgcolor="#FFAAAA" class="noticeboxcontent"><h4   class="main">This moodle server is not authenticated by LAMS!<br/> Please contact your administrator.<'+'/h4><'+'/td><'+'/tr><'+'/table>';
-        }else if(req.status == 502){//Unknow exception thrown by LAMS server
-            document.getElementById("message").innerHTML =
-                '<table align="center" width="57%"  class="noticebox" border="0" cellpadding="15" cellspacing="0"><tr><td bgcolor="#FFAAAA" class="noticeboxcontent"><h4   class="main">An unexpected error returned from LAMS server:'+req.responseText+'! Please contact your administrator.<'+'/h4><'+'/td><'+'/tr><'+'/table>';
-        }else if(req.status == 417){//ServerNotFound exception thrown by LAMS server
-            document.getElementById("message").innerHTML =
-                '<table align="center" width="57%"  class="noticebox" border="0" cellpadding="15" cellspacing="0"><tr><td bgcolor="#FFAAAA" class="noticeboxcontent"><h4   class="main">This moodle server has not registered in LAMS!<br/> Please contact your administrator.<'+'/h4><'+'/td><'+'/tr><'+'/table>';
-        }else if(req.status == 402){//All LAMS module settings have not not been set up
-            document.getElementById("message").innerHTML =
-                '<table align="center" width="57%"  class="noticebox" border="0" cellpadding="15" cellspacing="0"><tr><td bgcolor="#FFAAAA" class="noticeboxcontent"><h4   class="main">All the LAMS module settings have not been set up!<br/> Please contact your administrator.<'+'/h4><'+'/td><'+'/tr><'+'/table>';
-        }else{//this error should come from moodle server itself
-            document.getElementById("message").innerHTML =
-                '<table align="center" width="57%"  class="noticebox" border="0" cellpadding="15" cellspacing="0"><tr><td bgcolor="#FFAAAA" class="noticeboxcontent"><h4   class="main">It should be a moodle server error:'+req.status + ' ' + req.statusText+'! Please contact your administrator.<'+'/h4><'+'/td><'+'/tr><'+'/table>';
-        }
-    }
-}
-
-var dynamicOptionListCount=0;
-var dynamicOptionListObjects = new Array();
-
-// Init call to setup lists after page load. One call to this function sets up all lists.
-function initDynamicOptionLists() {
-    // init each DynamicOptionList object
-    for (var i=0; i<dynamicOptionListObjects.length; i++) {
-        var dol = dynamicOptionListObjects[i];
-
-        // Find the form associated with this list
-        if (dol.formName!=null) {
-            dol.form = document.forms[dol.formName];
-        }
-        else if (dol.formIndex!=null) {
-            dol.form = document.forms[dol.formIndex];
-        }
-        else {
-            // Form wasn't set manually, so go find it!
-            // Search for the first form element name in the lists
-            var name = dol.fieldNames[0][0];
-            for (var f=0; f<document.forms.length; f++) {
-                if (typeof(document.forms[f][name])!="undefined") {
-                    dol.form = document.forms[f];
-                    break;
-                }
-            }
-            if (dol.form==null) {
-                alert("ERROR: Couldn't find form element "+name+" in any form on the page! Init aborted"); return;
-            }
-        }
-
-        // Form is found, now set the onchange attributes of each dependent select box
-        for (var j=0; j<dol.fieldNames.length; j++) {
-            // For each set of field names...
-            for (var k=0; k<dol.fieldNames[j].length-1; k++) {
-                // For each field in the set...
-                var selObj = dol.form[dol.fieldNames[j][k]];
-                if (typeof(selObj)=="undefined") { alert("Select box named "+dol.fieldNames[j][k]+" could not be found in the form. Init aborted"); return; }
-                // Map the HTML options in the first select into the options we created
-                if (k==0) {
-                    if (selObj.options!=null) {
-                        for (l=0; l<selObj.options.length; l++) {
-                            var sopt = selObj.options[l];
-                            var m = dol.findMatchingOptionInArray(dol.options,sopt.text,sopt.value,false);
-                            if (m!=null) {
-                                var reselectForNN6 = sopt.selected;
-                                var m2 = new Option(sopt.text, sopt.value, sopt.defaultSelected, sopt.selected);
-                                m2.selected = sopt.selected; // For some reason I need to do this to make NN4 happy
-                                m2.defaultSelected = sopt.defaultSelected;
-                                m2.DOLOption = m;
-                                selObj.options[l] = m2;
-                                selObj.options[l].selected = reselectForNN6; // Reselect this option for NN6 to be happy. Yuck.
-                            }
-                        }
-                    }
-                }
-                if (selObj.onchange==null) {
-                    // We only modify the onChange attribute if it's empty! Otherwise do it yourself in your source!
-                    selObj.onchange = new Function("dynamicOptionListObjects["+dol.index+"].change(this)");
-                }
-            }
-        }
-    }
-    // Set the preselectd options on page load
-    resetDynamicOptionLists();
-}
-
-// This function populates lists with the preselected values.
-// It's pulled out into a separate function so it can be hooked into a 'reset' button on a form
-// Optionally passed a form object which should be the only form reset
-function resetDynamicOptionLists(theform) {
-    // reset each DynamicOptionList object
-    for (var i=0; i<dynamicOptionListObjects.length; i++) {
-        var dol = dynamicOptionListObjects[i];
-        if (typeof(theform)=="undefined" || theform==null || theform==dol.form) {
-            for (var j=0; j<dol.fieldNames.length; j++) {
-                dol.change(dol.form[dol.fieldNames[j][0]],true); // Second argument says to use preselected values rather than default values
-            }
-        }
-    }
-}
-
-// An object to represent an Option() but just for data-holding
-function DOLOption(text,value,defaultSelected,selected) {
-    this.text = text;
-    this.value = value;
-    this.defaultSelected = defaultSelected;
-    this.selected = selected;
-    this.options = new Array(); // To hold sub-options
-    return this;
-}
-
-// DynamicOptionList CONSTRUCTOR
-function DynamicOptionList() {
-    this.form = null;// The form this list belongs to
-    this.options = new Array();// Holds the options of dependent lists
-    this.longestString = new Array();// Longest string that is currently a potential option (for Netscape)
-    this.numberOfOptions = new Array();// The total number of options that might be displayed, to build dummy options (for Netscape)
-    this.currentNode = null;// The current node that has been selected with forValue() or forText()
-    this.currentField = null;// The current field that is selected to be used for setValue()
-    this.currentNodeDepth = 0;// How far down the tree the currentNode is
-    this.fieldNames = new Array();// Lists of dependent fields which use this object
-    this.formIndex = null;// The index of the form to associate with this list
-    this.formName = null;// The name of the form to associate with this list
-    this.fieldListIndexes = new Object();// Hold the field lists index where fields exist
-    this.fieldIndexes = new Object();// Hold the index within the list where fields exist
-    this.selectFirstOption = true;// Whether or not to select the first option by default if no options are default or preselected, otherwise set the selectedIndex = -1
-    this.numberOfOptions = new Array();// Store the max number of options for a given option list
-    this.longestString = new Array();// Store the longest possible string
-    this.values = new Object(); // Will hold the preselected values for fields, by field name
-
-    // Method mappings
-    this.forValue = DOL_forValue;
-    this.forText = DOL_forText;
-    this.forField = DOL_forField;
-    this.forX = DOL_forX;
-    this.addOptions = DOL_addOptions;
-    this.addOptionsTextValue = DOL_addOptionsTextValue;
-    this.setDefaultOptions = DOL_setDefaultOptions;
-    this.setValues = DOL_setValues;
-    this.setValue = DOL_setValues;
-    this.setFormIndex = DOL_setFormIndex;
-    this.setFormName = DOL_setFormName;
-    this.printOptions = DOL_printOptions;
-    this.addDependentFields = DOL_addDependentFields;
-    this.change = DOL_change;
-    this.child = DOL_child;
-    this.selectChildOptions = DOL_selectChildOptions;
-    this.populateChild = DOL_populateChild;
-    this.change = DOL_change;
-    this.addNewOptionToList = DOL_addNewOptionToList;
-    this.findMatchingOptionInArray = DOL_findMatchingOptionInArray;
-
-    // Optionally pass in the dependent field names
-    if (arguments.length > 0) {
-        // Process arguments and add dependency groups
-        for (var i=0; i<arguments.length; i++) {
-            this.fieldListIndexes[arguments[i].toString()] = this.fieldNames.length;
-            this.fieldIndexes[arguments[i].toString()] = i;
-        }
-        this.fieldNames[this.fieldNames.length] = arguments;
-    }
-
-    // Add this object to the global array of dynamicoptionlist objects
-    this.index = window.dynamicOptionListCount++;
-    window["dynamicOptionListObjects"][this.index] = this;
-}
-
-// Given an array of Option objects, search for an existing option that matches value, text, or both
-function DOL_findMatchingOptionInArray(a,text,value,exactMatchRequired) {
-    if (a==null || typeof(a)=="undefined") { return null; }
-    var value_match = null; // Whether or not a value has been matched
-    var text_match = null; // Whether or not a text has been matched
-    for (var i=0; i<a.length; i++) {
-        var opt = a[i];
-        // If both value and text match, return it right away
-        if (opt.value==value && opt.text==text) { return opt; }
-        if (!exactMatchRequired) {
-            // If value matches, store it until we complete scanning the list
-            if (value_match==null && value!=null && opt.value==value) {
-                value_match = opt;
-            }
-            // If text matches, store it for later
-            if (text_match==null && text!=null && opt.text==text) {
-                text_match = opt;
-            }
-        }
-    }
-    return (value_match!=null)?value_match:text_match;
-}
-
-// Util function used by forValue and forText
-function DOL_forX(s,type) {
-    if (this.currentNode==null) { this.currentNodeDepth=0; }
-    var useNode = (this.currentNode==null)?this:this.currentNode;
-    var o = this.findMatchingOptionInArray(useNode["options"],(type=="text")?s:null,(type=="value")?s:null,false);
-    if (o==null) {
-        o = new DOLOption(null,null,false,false);
-        o[type] = s;
-        useNode.options[useNode.options.length] = o;
-    }
-    this.currentNode = o;
-    this.currentNodeDepth++;
-    return this;
-}
-
-// Set the portion of the list structure that is to be used by a later operation like addOptions
-function DOL_forValue(s) { return this.forX(s,"value"); }
-
-// Set the portion of the list structure that is to be used by a later operation like addOptions
-function DOL_forText(s) { return this.forX(s,"text"); }
-
-// Set the field to be used for setValue() calls
-function DOL_forField(f) { this.currentField = f; return this; }
-
-// Create and add an option to a list, avoiding duplicates
-function DOL_addNewOptionToList(a, text, value, defaultSelected) {
-    var o = new DOLOption(text,value,defaultSelected,false);
-    // Add the option to the array
-    if (a==null) { a = new Array(); }
-    for (var i=0; i<a.length; i++) {
-        if (a[i].text==o.text && a[i].value==o.value) {
-            if (o.selected) {
-                a[i].selected=true;
-            }
-            if (o.defaultSelected) {
-                a[i].defaultSelected = true;
-            }
-            return a;
-        }
-    }
-    a[a.length] = o;
-}
-
-// Add sub-options to the currently-selected node, with the same text and value for each option
-function DOL_addOptions() {
-    if (this.currentNode==null) { this.currentNode = this; }
-    if (this.currentNode["options"] == null) { this.currentNode["options"] = new Array(); }
-    for (var i=0; i<arguments.length; i++) {
-        var text = arguments[i];
-        this.addNewOptionToList(this.currentNode.options,text,text,false);
-        if (typeof(this.numberOfOptions[this.currentNodeDepth])=="undefined") {
-            this.numberOfOptions[this.currentNodeDepth]=0;
-        }
-        if (this.currentNode.options.length > this.numberOfOptions[this.currentNodeDepth]) {
-            this.numberOfOptions[this.currentNodeDepth] = this.currentNode.options.length;
-        }
-        if (typeof(this.longestString[this.currentNodeDepth])=="undefined" || (text.length > this.longestString[this.currentNodeDepth].length)) {
-            this.longestString[this.currentNodeDepth] = text;
-        }
-    }
-    this.currentNode = null;
-    this.currentNodeDepth = 0;
-}
-
-// Add sub-options to the currently-selected node, specifying separate text and values for each option
-function DOL_addOptionsTextValue() {
-    if (this.currentNode==null) { this.currentNode = this; }
-    if (this.currentNode["options"] == null) { this.currentNode["options"] = new Array(); }
-    for (var i=0; i<arguments.length; i++) {
-        var text = arguments[i++];
-        var value = arguments[i];
-        this.addNewOptionToList(this.currentNode.options,text,value,false);
-        if (typeof(this.numberOfOptions[this.currentNodeDepth])=="undefined") {
-            this.numberOfOptions[this.currentNodeDepth]=0;
-        }
-        if (this.currentNode.options.length > this.numberOfOptions[this.currentNodeDepth]) {
-            this.numberOfOptions[this.currentNodeDepth] = this.currentNode.options.length;
-        }
-        if (typeof(this.longestString[this.currentNodeDepth])=="undefined" || (text.length > this.longestString[this.currentNodeDepth].length)) {
-            this.longestString[this.currentNodeDepth] = text;
-        }
-    }
-    this.currentNode = null;
-    this.currentNodeDepth = 0;
-}
-
-// Find the first dependent list of a select box
-// If it's the last list in a chain, return null because there are no children
-function DOL_child(obj) {
-    var listIndex = this.fieldListIndexes[obj.name];
-    var index = this.fieldIndexes[obj.name];
-    if (index < (this.fieldNames[listIndex].length-1)) {
-        return this.form[this.fieldNames[listIndex][index+1]];
-    }
-    return null;
-}
-
-// Set the options which should be selected by default for a certain value in the parent
-function DOL_setDefaultOptions() {
-    if (this.currentNode==null) { this.currentNode = this; }
-    for (var i=0; i<arguments.length; i++) {
-        var o = this.findMatchingOptionInArray(this.currentNode.options,null,arguments[i],false);
-        if (o!=null) {
-            o.defaultSelected = true;
-        }
-    }
-    this.currentNode = null;
-}
-
-// Set the options which should be selected when the page loads. This is different than the default value and ONLY applies when the page LOADS
-function DOL_setValues() {
-    if (this.currentField==null) {
-        alert("Can't call setValues() without using forField() first!");
-        return;
-    }
-    if (typeof(this.values[this.currentField])=="undefined") {
-        this.values[this.currentField] = new Object();
-    }
-    for (var i=0; i<arguments.length; i++) {
-        this.values[this.currentField][arguments[i]] = true;
-    }
-    this.currentField = null;
-}
-
-// Manually set the form for the object using an index
-function DOL_setFormIndex(i) {
-    this.formIndex = i;
-}
-
-// Manually set the form for the object using a form name
-function DOL_setFormName(n) {
-    this.formName = n;
-}
-
-// Print blank <option> objects for Netscape4, since it refuses to grow or shrink select boxes for new options
-function DOL_printOptions(name) {
-    // Only need to write out "dummy" options for Netscape4
-    if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) <= 4)){
-        var index = this.fieldIndexes[name];
-        var ret = "";
-        if (typeof(this.numberOfOptions[index])!="undefined") {
-            for (var i=0; i<this.numberOfOptions[index]; i++) {
-                ret += "<OPTION>";
-            }
-        }
-        ret += "<OPTION>";
-        if (typeof(this.longestString[index])!="undefined") {
-            for (var i=0; i<this.longestString[index].length; i++) {
-                ret += "_";
-            }
-        }
-        document.writeln(ret);
-    }
-}
-
-// Add a list of field names which use this option-mapping object.
-// A single mapping object may be used by multiple sets of fields
-function DOL_addDependentFields() {
-    for (var i=0; i<arguments.length; i++) {
-        this.fieldListIndexes[arguments[i].toString()] = this.fieldNames.length;
-        this.fieldIndexes[arguments[i].toString()] = i;
-    }
-    this.fieldNames[this.fieldNames.length] = arguments;
-}
-
-// Called when a parent select box is changed. It populates its direct child, then calls change on the child object to continue the population.
-function DOL_change(obj, usePreselected) {
-    if (usePreselected==null || typeof(usePreselected)=="undefined") { usePreselected = false; }
-    var changedListIndex = this.fieldListIndexes[obj.name];
-    var changedIndex = this.fieldIndexes[obj.name];
-    var child = this.child(obj);
-    if (child == null) { return; } // No child, no need to continue
-    if (obj.type == "select-one") {
-        // Treat single-select differently so we don't have to scan the entire select list, which could potentially speed things up
-        if (child.options!=null) {
-            child.options.length=0; // Erase all the options from the child so we can re-populate
-        }
-        if (obj.options!=null && obj.options.length>0 && obj.selectedIndex>=0) {
-            var o = obj.options[obj.selectedIndex];
-            this.populateChild(o.DOLOption,child,usePreselected);
-            this.selectChildOptions(child,usePreselected);
-        }
-    }
-    else if (obj.type == "select-multiple") {
-        // For each selected value in the parent, find the options to fill in for this list
-        // Loop through the child list and keep track of options that are currently selected
-        var currentlySelectedOptions = new Array();
-        if (!usePreselected) {
-            for (var i=0; i<child.options.length; i++) {
-                var co = child.options[i];
-                if (co.selected) {
-                    this.addNewOptionToList(currentlySelectedOptions, co.text, co.value, co.defaultSelected);
-                }
-            }
-        }
-        child.options.length=0;
-        if (obj.options!=null) {
-            var obj_o = obj.options;
-            // For each selected option in the parent...
-            for (var i=0; i<obj_o.length; i++) {
-                if (obj_o[i].selected) {
-                    // if option is selected, add its children to the list
-                    this.populateChild(obj_o[i].DOLOption,child,usePreselected);
-                }
-            }
-            // Now go through and re-select any options which were selected before
-            var atLeastOneSelected = false;
-            if (!usePreselected) {
-                for (var i=0; i<child.options.length; i++) {
-                    var m = this.findMatchingOptionInArray(currentlySelectedOptions,child.options[i].text,child.options[i].value,true);
-                    if (m!=null) {
-                        child.options[i].selected = true;
-                        atLeastOneSelected = true;
-                    }
-                }
-            }
-            if (!atLeastOneSelected) {
-                this.selectChildOptions(child,usePreselected);
-            }
-        }
-    }
-    // Change all the way down the chain
-    this.change(child,usePreselected);
-}
-function DOL_populateChild(dolOption,childSelectObj,usePreselected) {
-    // If this opton has sub-options, populate the child list with them
-    if (dolOption!=null && dolOption.options!=null) {
-        for (var j=0; j<dolOption.options.length; j++) {
-            var srcOpt = dolOption.options[j];
-            if (childSelectObj.options==null) { childSelectObj.options = new Array(); }
-            // Put option into select list
-            var duplicate = false;
-            var preSelectedExists = false;
-            for (var k=0; k<childSelectObj.options.length; k++) {
-                var csi = childSelectObj.options[k];
-                if (csi.text==srcOpt.text && csi.value==srcOpt.value) {
-                    duplicate = true;
-                    break;
-                }
-            }
-            if (!duplicate) {
-                var newopt = new Option(srcOpt.text, srcOpt.value, false, false);
-                newopt.selected = false; // Again, we have to do these two statements for NN4 to work
-                newopt.defaultSelected = false;
-                newopt.DOLOption = srcOpt;
-                childSelectObj.options[childSelectObj.options.length] = newopt;
-            }
-        }
-    }
-}
-
-// Once a child select is populated, go back over it to select options which should be selected
-function DOL_selectChildOptions(obj,usePreselected) {
-    // Look to see if any options are preselected=true. If so, then set then selected if usePreselected=true, otherwise set defaults
-    var values = this.values[obj.name];
-    var preselectedExists = false;
-    if (usePreselected && values!=null && typeof(values)!="undefined") {
-        for (var i=0; i<obj.options.length; i++) {
-            var v = obj.options[i].value;
-            if (v!=null && values[v]!=null && typeof(values[v])!="undefined") {
-                preselectedExists = true;
-                break;
-            }
-        }
-    }
-    // Go back over all the options to do the selection
-    var atLeastOneSelected = false;
-    for (var i=0; i<obj.options.length; i++) {
-        var o = obj.options[i];
-        if (preselectedExists && o.value!=null && values[o.value]!=null && typeof(values[o.value])!="undefined") {
-            o.selected = true;
-            atLeastOneSelected = true;
-        }
-        else if (!preselectedExists && o.DOLOption!=null && o.DOLOption.defaultSelected) {
-            o.selected = true;
-            atLeastOneSelected = true;
-        }
-        else {
-            o.selected = false;
-        }
-    }
-    // If nothing else was selected, select the first one by default
-    if (this.selectFirstOption && !atLeastOneSelected && obj.options.length>0) {
-        obj.options[0].selected = true;
-    }
-    else if (!atLeastOneSelected &&  obj.type=="select-one") {
-        obj.selectedIndex = -1;
-    }
-}
-
-refreshLists();//refresh the lists when form is displayed.
--->
-//]]>
-</script>
diff --git a/mod/lams/settings.php b/mod/lams/settings.php
deleted file mode 100644 (file)
index aae695f..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php  //$Id$
-
-$settings->add(new admin_setting_configtext('lams_serverurl', get_string('server_url', 'lams'), 
-                    get_string('serverurl', 'lams'), '') );
-
-$settings->add(new admin_setting_configtext('lams_serverid', get_string('server_id', 'lams'), 
-                    get_string('serverid', 'lams'), '') );
-
-$settings->add(new admin_setting_configtext('lams_serverkey', get_string('server_key', 'lams'), 
-                    get_string('serverkey', 'lams'), '') );
-
-?>
diff --git a/mod/lams/userinfo.php b/mod/lams/userinfo.php
deleted file mode 100644 (file)
index 2a34ed8..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-<?PHP
-
-/**
- * This page return user info in CSV format to LAMS server.
- * The pass-in parameters are un, ts and hs.
- * un means username, ts means timestamp and hs means hash.
- * The plain text of the hash should be lower case string of
- * ts.trim()+un.trim()+serverId+serverKey. The hash algorithm
- * is sha1.
- * If the hash is not matched to the result calculated, then a
- * http error code should be returned.
- * Moodle's admin should be responsible for correctly setting
- * serverId and serverKey
- */
-  include_once("../../config.php");
-
-    if(!isset($CFG->lams_serverid)||!isset($CFG->lams_serverkey))
-    {
-        header("HTTP/1.1 401 Unauthenticated");
-        exit(1);
-    }
-    $plaintext = trim($_GET["ts"]).trim($_GET["un"]).trim($CFG->lams_serverid).trim($CFG->lams_serverkey);
-    $hash = sha1(strtolower($plaintext));
-    if($hash!=$_GET["hs"]){
-        header("HTTP/1.1 401 Unauthenticated");
-        exit(1);
-    }
-
-    //OK, the caller is authenticated. Now let's fulfill its request.
-    //What it needs is user info in CSV format. It should be like this:
-    //username,first name,last name,job title, department, organisation,
-    //address,phone,fax,mobile,email
-    $user = get_record('user', 'username', $_GET["un"]);//return false if none found
-    if(!$user){
-        header("HTTP/1.1 401 Unauthenticated");//which status code is appropriate?
-        exit(1);
-    }
-    $array = array($user->username,$user->firstname,$user->lastname,'','','','','','','',$user->email);
-    $comma_separated = implode(",", $array);//need more sophiscated algorithm to generate CSV formatted string
-    echo $comma_separated;
-?>
diff --git a/mod/lams/version.php b/mod/lams/version.php
deleted file mode 100644 (file)
index d3bb67e..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<?PHP // $Id$
-
-/////////////////////////////////////////////////////////////////////////////////
-///  Code fragment to define the version of lams
-///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
-/////////////////////////////////////////////////////////////////////////////////
-
-$module->version  = 2007101509;  // The current module version (Date: YYYYMMDDXX)
-$module->requires = 2007101509;  // Requires this Moodle version
-$module->cron     = 0;           // Period for cron to check this module (secs)
-
-?>
diff --git a/mod/lams/view.php b/mod/lams/view.php
deleted file mode 100644 (file)
index c3755a1..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-<?php  // $Id$
-
-/// This page prints a particular instance of lams
-/// (Replace lams with the name of your module)
-
-require_once("../../config.php");
-require_once("lib.php");
-require_once("constants.php");
-
-$id = optional_param('id', 0, PARAM_INT);    // Course Module ID, or
-
-if (! $cm = get_coursemodule_from_id('lams', $id)) {
-    print_error("Course Module ID was incorrect");
-}
-
-if (! $course = get_record("course", "id", $cm->course)) {
-    print_error("Course is misconfigured");
-}
-
-if (! $lams = get_record("lams", "id", $cm->instance)) {
-    print_error("Course module is incorrect");
-}
-
-require_login($course, true, $cm);
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
-add_to_log($course->id, "lams", "view", "view.php?id=$cm->id", "$lams->id");
-
-/// Print the page header
-$navigation = build_navigation('', $cm);
-print_header_simple(format_string($lams->name), "", $navigation, "", "", true,
-        update_module_button($cm->id, $course->id, get_string("lesson","lams")), navmenu($course, $cm));
-
-echo '<table id="layout-table"><tr>';
-echo '<td id="middle-column">';
-print_heading(format_string($lams->name));
-
-//$strlamss = get_string("modulenameplural", "lams");
-//$strlams  = get_string("modulename", "lams");
-
-//print_header("$course->shortname: $lams->name", "$course->fullname",
-//             "$navigation <A HREF=index.php?id=$course->id>$strlamss</A> -> $lams->name",
-//              "", "", true, update_module_button($cm->id, $course->id, $strlams),
-//              navmenu($course, $cm));
-
-/// Print the main part of the page
-if(has_capability('mod/lams:manage', $context)){
-    $datetime =    date("F d,Y g:i a");
-    $plaintext = trim($datetime).trim($USER->username).trim($LAMSCONSTANTS->monitor_method).trim($CFG->lams_serverid).trim($CFG->lams_serverkey);
-    $hash = sha1(strtolower($plaintext));
-    $url = $CFG->lams_serverurl.$LAMSCONSTANTS->login_request.
-        '?'.$LAMSCONSTANTS->param_uid.'='.$USER->username.
-        '&'.$LAMSCONSTANTS->param_method.'='.$LAMSCONSTANTS->monitor_method.
-        '&'.$LAMSCONSTANTS->param_timestamp.'='.urlencode($datetime).
-        '&'.$LAMSCONSTANTS->param_serverid.'='.$CFG->lams_serverid.
-        '&'.$LAMSCONSTANTS->param_hash.'='.$hash.
-        '&'.$LAMSCONSTANTS->param_lsid.'='.$lams->learning_session_id.
-        '&'.$LAMSCONSTANTS->param_courseid.'='.$lams->course;
-    print_simple_box_start('center');
-    echo '<a target="LAMS Monitor" title="LAMS Monitor" href="'.$url.'">'.get_string("openmonitor", "lams").'</a>';
-    print_simple_box_end();
-
-    $plaintext = trim($datetime).trim($USER->username).trim($LAMSCONSTANTS->learner_method).trim($CFG->lams_serverid).trim($CFG->lams_serverkey);
-    $hash = sha1(strtolower($plaintext));
-    $url = $CFG->lams_serverurl.$LAMSCONSTANTS->login_request.
-        '?'.$LAMSCONSTANTS->param_uid.'='.$USER->username.
-        '&'.$LAMSCONSTANTS->param_method.'='.$LAMSCONSTANTS->learner_method.
-        '&'.$LAMSCONSTANTS->param_timestamp.'='.urlencode($datetime).
-        '&'.$LAMSCONSTANTS->param_serverid.'='.$CFG->lams_serverid.
-        '&'.$LAMSCONSTANTS->param_hash.'='.$hash.
-        '&'.$LAMSCONSTANTS->param_lsid.'='.$lams->learning_session_id.
-        '&'.$LAMSCONSTANTS->param_courseid.'='.$lams->course;
-    print_simple_box_start('center');
-    echo '<a target="LAMS Learner" title="LAMS Learner" href="'.$url.'">'.get_string("openlearner", "lams").'</a>';
-    print_simple_box_end();
-}else if(has_capability('mod/lams:participate', $context)){
-    $datetime =    date("F d,Y g:i a");
-    $plaintext = trim($datetime).trim($USER->username).trim($LAMSCONSTANTS->learner_method).trim($CFG->lams_serverid).trim($CFG->lams_serverkey);
-    $hash = sha1(strtolower($plaintext));
-    $url = $CFG->lams_serverurl.$LAMSCONSTANTS->login_request.
-        '?'.$LAMSCONSTANTS->param_uid.'='.$USER->username.
-        '&'.$LAMSCONSTANTS->param_method.'='.$LAMSCONSTANTS->learner_method.
-        '&'.$LAMSCONSTANTS->param_timestamp.'='.urlencode($datetime).
-        '&'.$LAMSCONSTANTS->param_serverid.'='.$CFG->lams_serverid.
-        '&'.$LAMSCONSTANTS->param_hash.'='.$hash.
-        '&'.$LAMSCONSTANTS->param_lsid.'='.$lams->learning_session_id.
-        '&'.$LAMSCONSTANTS->param_courseid.'='.$lams->course;
-    print_simple_box_start('center');
-    echo '<a target="LAMS Learner" title="LAMS Learner" href="'.$url.'">'.get_string("openlearner", "lams").'</a>';
-    print_simple_box_end();
-}
-
-if ($lams->introduction) {
-    print_box(format_text($lams->introduction), 'generalbox', 'intro');
-}
-
-
-/// Finish the page
-echo '</td></tr></table>';
-
-
-
-/// Finish the page
-print_footer($course);
-
-?>
diff --git a/mod/lesson/db/mysql.php b/mod/lesson/db/mysql.php
deleted file mode 100644 (file)
index 7fae252..0000000
+++ /dev/null
@@ -1,249 +0,0 @@
-<?PHP
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function lesson_upgrade($oldversion) {
-/// This function does anything necessary to upgrade 
-/// older versions to match current functionality 
-
-    global $CFG;
-
-    if ($oldversion < 2004021600) {
-
-       delete_records("log_display", "module", "lesson");
-
-       modify_database ("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('lesson', 'start', 'lesson', 'name');");
-       modify_database ("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('lesson', 'end', 'lesson', 'name');");
-       modify_database ("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('lesson', 'view', 'lesson_pages', 'title');");
-
-    }
-
-    if ($oldversion < 2004022200) {
-
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `maxattempts` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER maxanswers");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `nextpagedefault` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER maxattempts");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `maxpages` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER nextpagedefault");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson_pages` ADD `qtype` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER lessonid");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson_pages` ADD `qoption` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER qtype");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson_answers` ADD `grade` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER jumpto");
-
-    }
-
-    if ($oldversion < 2004032000) {           // Upgrade some old beta lessons
-        execute_sql(" UPDATE `{$CFG->prefix}lesson_pages` SET qtype = 3 WHERE qtype = 0");
-    }
-    
-    if ($oldversion < 2004032400) {
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `usemaxgrade` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER grade");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `minquestions` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER nextpagedefault");
-    }
-    if ($oldversion < 2004032700) {
-        table_column("lesson_answers", "", "flags", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "grade");
-    }
-
-    if ($oldversion < 2004060501) {
-        // matching questions need 2 records for responses and the
-        // 2 records must appear before the old ones.  So, delete the old ones,
-        // create the 2 needed, then re-insert the old ones for each matching question.
-        if ($matchingquestions = get_records('lesson_pages', 'qtype', 5)) {  // get our matching questions
-            foreach ($matchingquestions as $matchingquestion) {
-                if ($answers = get_records('lesson_answers', 'pageid', $matchingquestion->id)) { // get answers
-                    if (delete_records('lesson_answers',  'pageid', $matchingquestion->id)) {  // delete them
-                        $time = time();
-                        // make our 2 response answers
-                        $newanswer->lessonid = $matchingquestion->lessonid;
-                        $newanswer->pageid = $matchingquestion->id;
-                        $newanswer->timecreated = $time;
-                        $newanswer->timemodified = 0;
-                        insert_record('lesson_answers', $newanswer);
-                        insert_record('lesson_answers', $newanswer);
-                        // insert our old answers
-                        foreach ($answers as $answer) {
-                            $answer->timecreated = $time;
-                            $answer->timemodified = 0;
-                            insert_record('lesson_answers', (object) array_map('addslashes', (array)$answer));
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    if ($oldversion < 2004072100) {
-        execute_sql(" create table ".$CFG->prefix."lesson_high_scores
-                    ( id int(10) unsigned not null auto_increment,
-                      lessonid int(10) unsigned not null default '0',
-                      userid int(10) unsigned not null default '0',
-                      gradeid int(10) unsigned not null default '0',
-                      nickname varchar(5) not null default '',
-                      PRIMARY KEY  (`id`)
-                    )");
-
-        execute_sql(" create table ".$CFG->prefix."lesson_branch
-                    ( id int(10) unsigned not null auto_increment,
-                      lessonid int(10) unsigned not null default '0',
-                      userid int(10) unsigned not null default '0',
-                      pageid int(10) unsigned not null default '0',
-                      retry int(10) unsigned not null default '0',
-                      flag  tinyint(3) unsigned not null default '0',
-                      timeseen int(10) unsigned not null default '0',
-                      PRIMARY KEY  (`id`)
-                    )");
-
-        
-        execute_sql(" create table ".$CFG->prefix."lesson_timer
-                    ( id int(10) unsigned not null auto_increment,
-                      lessonid int(10) unsigned not null default '0',
-                    userid int(10) unsigned not null default '0',
-                    starttime int(10) unsigned not null default '0',
-                      lessontime int(10) unsigned not null default '0',
-                      PRIMARY KEY  (`id`)
-                    )");
-
-    
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson_pages` ADD `layout` TINYINT(3) UNSIGNED NOT NULL DEFAULT '1' AFTER qoption");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson_pages` ADD `display` TINYINT(3) UNSIGNED NOT NULL DEFAULT '1' AFTER layout");
-
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson_answers` ADD `score` INT(10) NOT NULL DEFAULT '0' AFTER grade");
-    
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `usepassword` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER name");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `password` VARCHAR(32) NOT NULL DEFAULT '' AFTER usepassword");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `custom` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER grade");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `ongoing` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER custom");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `timed` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER maxpages");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `maxtime` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER timed");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `tree` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER retake");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `slideshow` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER tree");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `width` INT(10) UNSIGNED NOT NULL DEFAULT '640' AFTER slideshow");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `height` INT(10) UNSIGNED NOT NULL DEFAULT '480' AFTER width");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `bgcolor` CHAR(7) NOT NULL DEFAULT '#FFFFFF' AFTER height");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `displayleft` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER bgcolor");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `highscores` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER displayleft");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `maxhighscores` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER highscores");
-
-    }
-
-    if ($oldversion < 2004081100) {
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `practice` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER name");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `review` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER maxattempts");
-    }    
-    
-    if ($oldversion < 2004081700) {
-        execute_sql("CREATE TABLE `{$CFG->prefix}lesson_default` 
-        ( `id` int(10) unsigned NOT NULL auto_increment,
-          `course` int(10) unsigned NOT NULL default '0',
-          `practice` tinyint(3) unsigned NOT NULL default '0',
-          `password` varchar(32) NOT NULL default '',
-          `usepassword` int(3) unsigned NOT NULL default '0',
-          `grade` tinyint(3) NOT NULL default '0',
-          `custom` int(3) unsigned NOT NULL default '0',
-          `ongoing` int(3) unsigned NOT NULL default '0',
-          `usemaxgrade` tinyint(3) unsigned NOT NULL default '0',
-          `maxanswers` int(3) unsigned NOT NULL default '4',
-          `maxattempts` int(3) unsigned NOT NULL default '5',
-          `review` tinyint(3) unsigned NOT NULL default '0',
-          `nextpagedefault` int(3) unsigned NOT NULL default '0',
-          `minquestions` tinyint(3) unsigned NOT NULL default '0',
-          `maxpages` int(3) unsigned NOT NULL default '0',
-          `timed` int(3) unsigned NOT NULL default '0',
-          `maxtime` int(10) unsigned NOT NULL default '0',
-          `retake` int(3) unsigned NOT NULL default '1',
-          `tree` int(3) unsigned NOT NULL default '0',
-          `slideshow` int(3) unsigned NOT NULL default '0',
-          `width` int(10) unsigned NOT NULL default '640',
-          `height` int(10) unsigned NOT NULL default '480',
-          `bgcolor` varchar(7) default '#FFFFFF',
-          `displayleft` int(3) unsigned NOT NULL default '0',
-          `highscores` int(3) unsigned NOT NULL default '0',
-          `maxhighscores` int(10) NOT NULL default '0',
-          PRIMARY KEY  (`id`)
-        ) COMMENT = 'Defines lesson_default'");
-    }
-
-    if ($oldversion < 2004100400) {
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson_attempts` ADD `useranswer` text NOT NULL AFTER correct");
-    }
-    
-    if ($oldversion < 2004100700) {
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `modattempts` tinyint(3) unsigned NOT NULL default '0' AFTER practice");
-    }
-
-    if ($oldversion < 2004102600) {
-        execute_sql(" ALTER TABLE `{$CFG->prefix}lesson_default` ADD `modattempts` tinyint(3) unsigned NOT NULL default '0' AFTER practice");
-    }
-
-    if ($oldversion < 2004111200) {
-        execute_sql("ALTER TABLE {$CFG->prefix}lesson DROP INDEX course;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}lesson_answers DROP INDEX lessonid;",false); 
-        execute_sql("ALTER TABLE {$CFG->prefix}lesson_attempts DROP INDEX lessonid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}lesson_attempts DROP INDEX pageid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}lesson_grades DROP INDEX lessonid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}lesson_grades DROP INDEX userid;",false); 
-        execute_sql("ALTER TABLE {$CFG->prefix}lesson_pages DROP INDEX lessonid;",false);
-
-        modify_database('','ALTER TABLE prefix_lesson ADD INDEX course (course);');
-        modify_database('','ALTER TABLE prefix_lesson_answers ADD INDEX lessonid (lessonid);');
-        modify_database('','ALTER TABLE prefix_lesson_attempts ADD INDEX lessonid (lessonid);');
-        modify_database('','ALTER TABLE prefix_lesson_attempts ADD INDEX pageid (pageid);');
-        modify_database('','ALTER TABLE prefix_lesson_grades ADD INDEX lessonid (lessonid);');
-        modify_database('','ALTER TABLE prefix_lesson_grades ADD INDEX userid (userid);');
-        modify_database('','ALTER TABLE prefix_lesson_pages ADD INDEX lessonid (lessonid);');
-    }
-   
-    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');
-    }
-    
-    if ($oldversion < 2005063000) {
-        table_column('lesson', '', 'dependency', 'int', '10', 'unsigned', '0', 'not null', 'usepassword');
-        table_column('lesson', '', 'conditions', 'text', '', '', '', 'not null', 'dependency');
-    }
-    
-    if ($oldversion < 2005101900) {
-        table_column('lesson', '', 'progressbar', 'tinyint', '3', 'unsigned', '0', 'not null', 'displayleft');
-        table_column('lesson', '', 'displayleftif', 'int', '3', 'unsigned', '0', 'not null', 'displayleft');
-    }
-    
-    if ($oldversion < 2005102800) {
-        table_column('lesson', '', 'mediaclose', 'tinyint', '3', 'unsigned', '0', 'not null', 'mediafile');
-        table_column('lesson', '', 'mediaheight', 'int', '10', 'unsigned', '100', 'not null', 'mediafile');
-        table_column('lesson', '', 'mediawidth', 'int', '10', 'unsigned', '650', 'not null', 'mediafile');
-    }
-
-    if ($oldversion < 2005110200) {
-        table_column('lesson', '', 'activitylink', 'int', '10', 'unsigned', '0', 'not null', 'tree');
-    }
-    
-    if ($oldversion < 2006031900) {
-        execute_sql('ALTER TABLE  '. $CFG->prefix . 'lesson DROP COLUMN tree');
-        execute_sql('ALTER TABLE  '. $CFG->prefix . 'lesson_default DROP COLUMN tree');
-    }
-    
-    if ($oldversion < 2006050100) {   
-        table_column('lesson_default', '', 'conditions', 'text', '', '', '', 'not null', 'password');
-        table_column('lesson_default', '', 'progressbar', 'tinyint', '3', 'unsigned', '0', 'not null', 'displayleft');
-        table_column('lesson_default', '', 'displayleftif', 'int', '3', 'unsigned', '0', 'not null', 'displayleft'); 
-        table_column('lesson_default', '', 'mediaclose', 'tinyint', '3', 'unsigned', '0', 'not null', 'retake');
-        table_column('lesson_default', '', 'mediaheight', 'int', '10', 'unsigned', '100', 'not null', 'retake');
-        table_column('lesson_default', '', 'mediawidth', 'int', '10', 'unsigned', '650', 'not null', 'retake');
-    }
-    
-    if ($oldversion < 2006091202) {
-        table_column('lesson', '', 'feedback', 'int', '3', 'unsigned', '1', 'not null', 'nextpagedefault'); 
-        table_column('lesson_default', '', 'feedback', 'int', '3', 'unsigned', '1', 'not null', 'nextpagedefault'); 
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/mod/lesson/db/postgres7.php b/mod/lesson/db/postgres7.php
deleted file mode 100644 (file)
index c644e7a..0000000
+++ /dev/null
@@ -1,371 +0,0 @@
-<?PHP
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function lesson_upgrade($oldversion) {
-/// This function does anything necessary to upgrade 
-/// older versions to match current functionality 
-
-    global $CFG;
-
-    if ($oldversion < 2004021600) {
-
-       delete_records("log_display", "module", "lesson");
-
-       modify_database ("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('lesson', 'start', 'lesson', 'name');");
-       modify_database ("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('lesson', 'end', 'lesson', 'name');");
-       modify_database ("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('lesson', 'view', 'lesson_pages', 'title');");
-
-    }
-
-    if ($oldversion < 2004022200) {
-
-        table_column("lesson", "", "maxattempts", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "maxanswers");
-        table_column("lesson", "", "nextpagedefault", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "maxattempts");
-        table_column("lesson", "", "maxpages", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "nextpagedefault");
-        table_column("lesson_pages", "", "qtype", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "lessonid");
-        table_column("lesson_pages", "", "qoption", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "qtype");
-        table_column("lesson_answers", "", "grade", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "jumpto");
-
-    }
-
-    if ($oldversion < 2004032000) {           // Upgrade some old beta lessons
-        execute_sql(" UPDATE \"{$CFG->prefix}lesson_pages\" SET qtype = 3 WHERE qtype = 0");
-    }
-    
-    if ($oldversion < 2004032400) {
-        table_column("lesson", "", "usemaxgrade", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "grade");
-        table_column("lesson", "", "minquestions", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "nextpagedefault");
-    }
-    if ($oldversion < 2004032700) {
-        table_column("lesson_answers", "", "flags", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "grade");
-    }
-    
-    if ($oldversion < 2004060501) {
-        // matching questions need 2 records for responses and the
-        // 2 records must appear before the old ones.  So, delete the old ones,
-        // create the 2 needed, then re-insert the old ones for each matching question.
-        if ($matchingquestions = get_records('lesson_pages', 'qtype', 5)) {  // get our matching questions
-            foreach ($matchingquestions as $matchingquestion) {
-                if ($answers = get_records('lesson_answers', 'pageid', $matchingquestion->id)) { // get answers
-                    if (delete_records('lesson_answers',  'pageid', $matchingquestion->id)) {  // delete them
-                        $time = time();
-                        // make our 2 response answers
-                        $newanswer->lessonid = $matchingquestion->lessonid;
-                        $newanswer->pageid = $matchingquestion->id;
-                        $newanswer->timecreated = $time;
-                        $newanswer->timemodified = 0;
-                        insert_record('lesson_answers', $newanswer);
-                        insert_record('lesson_answers', $newanswer);
-                        // insert our old answers
-                        foreach ($answers as $answer) {
-                            $answer->timecreated = $time;
-                            $answer->timemodified = 0;
-                            insert_record('lesson_answers', (object) array_map('addslashes', (array)$answer));
-                        }
-                    }
-                }
-            }
-        }
-    }
-    
-    if ($oldversion < 2004072100) {
-        execute_sql(" create table ".$CFG->prefix."lesson_high_scores
-                    ( id serial8 primary key,
-                      lessonid int8 not null default '0',
-                      userid int8 not null default '0',
-                      gradeid int8 not null default '0',
-                      nickname varchar(5) not null default ''
-                    )");
-
-        execute_sql(" create table ".$CFG->prefix."lesson_essay
-                    ( id serial8 primary key,
-                      lessonid int8 not null default '0',
-                      userid int8 not null default '0',
-                      pageid int8 not null default '0',
-                      answerid int8 not null default '0',
-                      try int8 not null default '0',
-                      answer text not null default '',
-                      graded int4 not null default 0,
-                      score int8 not null default 0,
-                      response text not null default '',
-                      sent int4 not null default 0,
-                      timesubmitted int8 not null default '0'
-                    )");
-
-        execute_sql(" create table ".$CFG->prefix."lesson_branch
-                    ( id serial8 primary key,
-                      lessonid int8 not null default '0',
-                      userid int8 not null default '0',
-                      pageid int8 not null default '0',
-                      retry int8 not null default '0',
-                      flag  int4 not null default '0',
-                      timeseen int8 not null default '0'
-                    )");
-
-        
-        execute_sql(" create table ".$CFG->prefix."lesson_timer
-                    ( id serial8 primary key,
-                      lessonid int8 not null default '0',
-                    userid int8 not null default '0',
-                    starttime int8 not null default '0',
-                      lessontime int8 not nul default '0'l
-                    )");
-
-    
-
-        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson_pages ADD layout TINYINT(3) UNSIGNED NOT NULL DEFAULT '1' AFTER qoption");
-        table_column('lesson_pages','','layout','int','3','unsigned', '1', 'not null', 'qoption');
-        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson_pages ADD display TINYINT(3) UNSIGNED NOT NULL DEFAULT '1' AFTER layout");
-        table_column('lesson_pages','','display','int','3','unsigned',  '1',  'not null', 'layout');
-
-        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson_answers ADD score INT(10) NOT NULL DEFAULT '0' AFTER grade");
-        table_column('lesson_answers','','score','int','10','unsigned',  '1',  'not null', 'grade');
-        
-        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD usepassword TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER name");
-        table_column('lesson','','usepassword','int','3','unsigned',  '0',  'not null', 'name');
-        
-        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD password VARCHAR(32) NOT NULL DEFAULT '' AFTER usepassword");
-        table_column('lesson','','password','varchar','32','',  '',  'not null', 'usepassword');
-        
-        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD custom TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER grade");
-        table_column('lesson','','custom','int','3','unsigned',  '0',  'not null', 'grade');
-        
-        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD ongoing TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER custom");
-        table_column('lesson','','ongoing','int','3','unsigned',  '0',  'not null', 'custom');
-        
-        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD timed TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER maxpages");
-        table_column('lesson','','timed','int','3','unsigned',  '0',  'not null', 'maxpages');
-        
-        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD maxtime INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER timed");
-        table_column('lesson','','maxtime','int','10','unsigned',  '0',  'not null', 'timed');
-        
-        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD tree TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER retake");
-        table_column('lesson','','tree','int','3','unsigned',  '0',  'not null', 'retake');
-        
-        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD slideshow TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER tree");
-        table_column('lesson','','slideshow','int','3','unsigned',  '0',  'not null', 'tree');
-        
-        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD width INT(10) UNSIGNED NOT NULL DEFAULT '640' AFTER slideshow");
-        table_column('lesson','','width','int','10','unsigned',  '640',  'not null', 'slideshow');
-        
-        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD height INT(10) UNSIGNED NOT NULL DEFAULT '480' AFTER width");
-        table_column('lesson','','height','int','10','unsigned',  '480',  'not null', 'width');
-        
-        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD bgcolor CHAR(7) NOT NULL DEFAULT '#FFFFFF' AFTER height");
-        table_column('lesson','','bgcolor','varchar','7','unsigned',  '#FFFFFF',  'not null', 'height');
-        
-        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD displayleft TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER bgcolor");
-        table_column('lesson','','displayleft','int','3','unsigned',  '0',  'not null', 'bgcolor');
-        
-        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD highscores TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER displayleft");
-        table_column('lesson','','highscores','int','3','unsigned',  '0',  'not null', 'displayleft');
-        
-        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD maxhighscores INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER highscores");
-        table_column('lesson','','maxhighscores','int','10','unsigned',  '0',  'not null', 'highscores');
-
-    }
-
-    if ($oldversion < 2004081100) {
-        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD practice TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER name");
-        table_column('lesson','','practice','int','3','unsigned',  '0',  'not null', 'name');
-        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD review TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER maxattempts");
-        table_column('lesson','','review','int','3','unsigned',  '0',  'not null', 'maxattempts');
-    }    
-    
-    if ($oldversion < 2004081700) {
-        execute_sql("CREATE TABLE {$CFG->prefix}lesson_default 
-        ( id serial8 primary key,
-          course int8 NOT NULL default '0',
-          practice int4 NOT NULL default '0',
-          password varchar(32) NOT NULL default '',
-          usepassword int4 NOT NULL default '0',
-          grade int4 NOT NULL default '0',
-          custom int4 NOT NULL default '0',
-          ongoing int4 NOT NULL default '0',
-          usemaxgrade int4 NOT NULL default '0',
-          maxanswers int4 NOT NULL default '4',
-          maxattempts int4 NOT NULL default '5',
-          review int4 NOT NULL default '0',
-          nextpagedefault int4 NOT NULL default '0',
-          minquestions int4 NOT NULL default '0',
-          maxpages int4 NOT NULL default '0',
-          timed int4 NOT NULL default '0',
-          maxtime int8 NOT NULL default '0',
-          retake int4 NOT NULL default '1',
-          tree int4 NOT NULL default '0',
-          slideshow int4 NOT NULL default '0',
-          width int8 NOT NULL default '640',
-          height int8 NOT NULL default '480',
-          bgcolor varchar(7) default '#FFFFFF',
-          displayleft int4 NOT NULL default '0',
-          highscores int4 NOT NULL default '0',
-          maxhighscores int8 NOT NULL default '0'
-        )");
-    }
-    
-    if ($oldversion < 2004100400) {
-        //execute_sql(" ALTER TABLE `{$CFG->prefix}lesson_attempts` ADD `useranswer` text NOT NULL AFTER correct");
-        table_column('lesson_attempts', '', 'useranswer', 'text', '', '', '', 'NOT NULL', 'correct');
-    }
-    
-    if ($oldversion < 2004100700) {
-        //execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `modattempts` tinyint(3) unsigned NOT NULL default '0' AFTER practice");
-        table_column('lesson', '', 'modattempts', 'INT', '4', 'unsigned', '0', 'NOT NULL', 'practice');
-    }
-
-    if ($oldversion < 2004102600) {
-        //execute_sql(" ALTER TABLE `{$CFG->prefix}lesson_default` ADD `modattempts` tinyint(3) unsigned NOT NULL default '0' AFTER practice");
-        table_column('lesson_default', '', 'modattempts', 'INT', '4', 'unsigned', '0', 'NOT NULL', 'practice');
-    }
-
-    if ($oldversion < 2004111200) {
-        execute_sql("DROP INDEX {$CFG->prefix}lesson_course_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}lesson_answers_lessonid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}lesson_answers_pageid_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}lesson_attempts_lessonid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}lesson_attempts_pageid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}lesson_attempts_userid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}lesson_grades_lessonid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}lesson_grades_userid_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}lesson_pages_lessonid_idx;",false);
-
-        modify_database('','CREATE INDEX prefix_lesson_course_idx ON prefix_lesson (course);');
-        modify_database('','CREATE INDEX prefix_lesson_answers_lessonid_idx ON prefix_lesson_answers (lessonid);');
-        modify_database('','CREATE INDEX prefix_lesson_answers_pageid_idx ON prefix_lesson_answers (pageid);');
-        modify_database('','CREATE INDEX prefix_lesson_attempts_lessonid_idx ON prefix_lesson_attempts (lessonid);');
-        modify_database('','CREATE INDEX prefix_lesson_attempts_pageid_idx ON prefix_lesson_attempts (pageid);');
-        modify_database('','CREATE INDEX prefix_lesson_attempts_userid_idx ON prefix_lesson_attempts (userid);');
-        modify_database('','CREATE INDEX prefix_lesson_grades_lessonid_idx ON prefix_lesson_grades (lessonid);');
-        modify_database('','CREATE INDEX prefix_lesson_grades_userid_idx ON prefix_lesson_grades (userid);');
-        modify_database('','CREATE INDEX prefix_lesson_pages_lessonid_idx ON prefix_lesson_pages (lessonid);');
-   }
-   
-    if ($oldversion < 2005060900) {
-        table_column('lesson_grades', 'grade', 'grade', 'real', '', 'unsigned', '0', 'not null');
-    }
-    
-    if ($oldversion < 2005060901) { // Mass cleanup of bad postgres upgrade scripts
-        modify_database('','ALTER TABLE prefix_lesson ALTER bgcolor SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_lesson ALTER custom SET NOT NULL');
-        table_column('lesson','height','height','integer','16','unsigned','480');
-        modify_database('','ALTER TABLE prefix_lesson ALTER highscores SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_lesson ALTER maxattempts SET DEFAULT 5');
-        table_column('lesson','maxhighscores','maxhighscores','integer','16');
-        modify_database('','ALTER TABLE prefix_lesson ALTER displayleft SET NOT NULL');
-        table_column('lesson','','minquestions','integer','8');
-        notify('The above error can be ignored if the column already exists, its possible that it was cleaned up already before running this upgrade');
-        table_column('lesson','maxtime','maxtime','integer','16');
-        modify_database('','ALTER TABLE prefix_lesson ALTER ongoing SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_lesson ALTER password SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_lesson ALTER practice SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_lesson ALTER review SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_lesson ALTER slideshow SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_lesson ALTER timed SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_lesson ALTER tree SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_lesson ALTER usepassword SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_lesson ALTER width SET NOT NULL');
-        table_column('lesson','width','width','integer','16','unsigned','640');
-        table_column('lesson_answers','flags','flags','integer','8');
-        table_column('lesson_answers','grade','grade','integer','8');
-        table_column('lesson_answers','score','score','integer','16');
-        modify_database('','ALTER TABLE prefix_lesson_grades ALTER grade SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_lesson_pages ALTER display SET NOT NULL');
-        modify_database('','ALTER TABLE prefix_lesson_pages ALTER layout SET NOT NULL');
-        table_column('lesson_pages','qoption','qoption','integer','8');
-        table_column('lesson_pages','qtype','qtype','integer','8');
-    }
-
-    if ($oldversion < 2005061500) {
-        table_column('lesson', '', 'mediafile', 'varchar', '255', '', '', 'not null', 'tree');
-    }
-    
-    if ($oldversion < 2005063000) {
-        table_column('lesson', '', 'dependency', 'INT', '8', 'unsigned', '0', 'not null', 'usepassword');
-        table_column('lesson', '', 'conditions', 'text', '', '', '', 'not null', 'dependency');
-    }
-    
-    if ($oldversion < 2005101900) {
-        table_column('lesson', '', 'progressbar', 'INT', '3', 'unsigned', '0', 'not null', 'displayleft');
-        table_column('lesson', '', 'displayleftif', 'INT', '3', 'unsigned', '0', 'not null', 'displayleft');
-    }
-    
-    if ($oldversion < 2005102800) {
-        table_column('lesson', '', 'mediaclose', 'INT', '3', 'unsigned', '0', 'not null', 'mediafile');
-        table_column('lesson', '', 'mediaheight', 'INT', '10', 'unsigned', '100', 'not null', 'mediafile');
-        table_column('lesson', '', 'mediawidth', 'INT', '10', 'unsigned', '650', 'not null', 'mediafile');
-    }
-
-    if ($oldversion < 2005110200) {
-        table_column('lesson', '', 'activitylink', 'INT', '10', 'unsigned', '0', 'not null', 'tree');
-    }
-    
-    if ($oldversion < 2006031900) {
-        execute_sql('ALTER TABLE  '. $CFG->prefix . 'lesson DROP COLUMN tree');
-        execute_sql('ALTER TABLE  '. $CFG->prefix . 'lesson_default DROP COLUMN tree');
-    }
-    
-    if ($oldversion < 2006050100) {   
-        table_column('lesson_default', '', 'conditions', 'text', '', '', '', 'not null', 'password');
-        table_column('lesson_default', '', 'progressbar', 'tinyint', '3', 'unsigned', '0', 'not null', 'displayleft');
-        table_column('lesson_default', '', 'displayleftif', 'int', '3', 'unsigned', '0', 'not null', 'displayleft'); 
-        table_column('lesson_default', '', 'mediaclose', 'tinyint', '3', 'unsigned', '0', 'not null', 'retake');
-        table_column('lesson_default', '', 'mediaheight', 'int', '10', 'unsigned', '100', 'not null', 'retake');
-        table_column('lesson_default', '', 'mediawidth', 'int', '10', 'unsigned', '650', 'not null', 'retake');
-    }
-
-    if ($oldversion < 2006050101) {
-        // drop the unused table
-        execute_sql('DROP TABLE '.$CFG->prefix.'lesson_essay', false);
-
-        // properly set the correct default values
-        table_column('lesson', 'activitylink', 'activitylink', 'integer', '8', '', '0');
-        table_column('lesson', 'dependency', 'dependency', 'integer', '8', '', '0');
-
-        modify_database('', 'ALTER TABLE prefix_lesson_timer
-            ALTER COLUMN lessontime SET DEFAULT 0');
-        modify_database('', 'ALTER TABLE prefix_lesson_timer
-            ALTER COLUMN lessonid SET DEFAULT 0');
-        modify_database('', 'ALTER TABLE prefix_lesson_timer
-            ALTER COLUMN userid SET DEFAULT 0');
-        modify_database('', 'ALTER TABLE prefix_lesson_timer
-            ALTER COLUMN starttime SET DEFAULT 0');
-
-        modify_database('', 'ALTER TABLE prefix_lesson_branch
-            ALTER COLUMN lessonid SET DEFAULT 0');
-        modify_database('', 'ALTER TABLE prefix_lesson_branch
-            ALTER COLUMN timeseen SET DEFAULT 0');
-        modify_database('', 'ALTER TABLE prefix_lesson_branch
-            ALTER COLUMN userid SET DEFAULT 0');
-        modify_database('', 'ALTER TABLE prefix_lesson_branch
-            ALTER COLUMN retry SET DEFAULT 0');
-        modify_database('', 'ALTER TABLE prefix_lesson_branch
-            ALTER COLUMN pageid SET DEFAULT 0');
-        modify_database('', 'ALTER TABLE prefix_lesson_branch
-            ALTER COLUMN flag SET DEFAULT 0');
-
-        modify_database('', 'ALTER TABLE prefix_lesson_high_scores
-            ALTER COLUMN nickname SET DEFAULT \'\'');
-        modify_database('', 'ALTER TABLE prefix_lesson_high_scores
-            ALTER COLUMN lessonid SET DEFAULT 0');
-        modify_database('', 'ALTER TABLE prefix_lesson_high_scores
-            ALTER COLUMN gradeid SET DEFAULT 0');
-        modify_database('', 'ALTER TABLE prefix_lesson_high_scores
-            ALTER COLUMN userid SET DEFAULT 0');
-    }
-    
-    if ($oldversion < 2006091202) {
-        table_column('lesson', '', 'feedback', 'int', '3', 'unsigned', '1', 'not null', 'nextpagedefault'); 
-        table_column('lesson_default', '', 'feedback', 'int', '3', 'unsigned', '1', 'not null', 'nextpagedefault'); 
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-   return true;
-}
-
-?>
index fdd6ef995ca5c6cf5abc6d97c6ec18212bf70e6d..91e0896aadecd4edca02a7c16deeed8ad62ec229 100644 (file)
@@ -672,12 +672,13 @@ class securewindow_access_rule extends quiz_access_rule_base {
      * before the button submits.
      */
     public function print_start_attempt_button($buttontext, $strconfirmstartattempt) {
-        global $CFG;
+        global $CFG, $SESSION;
+
         $attempturl = $CFG->wwwroot . '/mod/quiz/attempt.php?q=' . $this->_quiz->id;
         $window = 'quizpopup';
 
         if (!empty($CFG->usesid) && !isset($_COOKIE[session_name()])) {
-            $attempturl = sid_process_url($attempturl);
+            $attempturl = $SESSION->sid_process_url($attempturl);
         }
 
         echo '<input type="button" value="' . s($buttontext) . '" onclick="javascript:';
diff --git a/mod/quiz/db/mysql.php b/mod/quiz/db/mysql.php
deleted file mode 100644 (file)
index 65dc510..0000000
+++ /dev/null
@@ -1,1163 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function quiz_upgrade($oldversion) {
-// This function does anything necessary to upgrade
-// older versions to match current functionality
-
-    global $CFG, $QTYPES, $db;
-    $success = true;
-
-    require_once("$CFG->dirroot/mod/quiz/locallib.php");
-
-    if ($success && $oldversion < 2002101800) {
-        $success = $success && execute_sql(" ALTER TABLE `quiz_attempts` ".
-                    " ADD `timestart` INT(10) UNSIGNED DEFAULT '0' NOT NULL AFTER `sumgrades` , ".
-                    " ADD `timefinish` INT(10) UNSIGNED DEFAULT '0' NOT NULL AFTER `timestart` ");
-        $success = $success && execute_sql(" UPDATE `quiz_attempts` SET timestart = timemodified ");
-        $success = $success && execute_sql(" UPDATE `quiz_attempts` SET timefinish = timemodified ");
-    }
-    if ($success && $oldversion < 2002102101) {
-        $success = $success && execute_sql(" DELETE FROM log_display WHERE module = 'quiz' ");
-        $success = $success && execute_sql(" INSERT INTO log_display (module, action, mtable, field) VALUES ('quiz', 'view', 'quiz', 'name') ");
-        $success = $success && execute_sql(" INSERT INTO log_display (module, action, mtable, field) VALUES ('quiz', 'report', 'quiz', 'name') ");
-        $success = $success && execute_sql(" INSERT INTO log_display (module, action, mtable, field) VALUES ('quiz', 'attempt', 'quiz', 'name') ");
-        $success = $success && execute_sql(" INSERT INTO log_display (module, action, mtable, field) VALUES ('quiz', 'submit', 'quiz', 'name') ");
-    }
-    if ($success && $oldversion < 2002102600) {
-        $success = $success && execute_sql(" ALTER TABLE `quiz_answers` CHANGE `feedback` `feedback` TEXT NOT NULL ");
-    }
-
-    if ($success && $oldversion < 2002122300) {
-        $success = $success && execute_sql("ALTER TABLE `quiz_grades` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
-        $success = $success && execute_sql("ALTER TABLE `quiz_attempts` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
-    }
-
-    // prefixes required from here on, or use table_column()
-
-    if ($success && $oldversion < 2003010100) {
-        $success = $success && execute_sql(" ALTER TABLE {$CFG->prefix}quiz ADD review TINYINT(4) UNSIGNED DEFAULT '0' NOT NULL AFTER `grademethod` ");
-    }
-
-    if ($success && $oldversion < 2003010301) {
-        $success = $success && table_column("quiz_truefalse", "true", "trueanswer", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "");
-        $success = $success && table_column("quiz_truefalse", "false", "falseanswer", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "");
-        $success = $success && table_column("quiz_questions", "type", "qtype", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "");
-    }
-
-    if ($success && $oldversion < 2003022303) {
-        $success = $success && modify_database ("", "CREATE TABLE `prefix_quiz_randommatch` (
-                             `id` int(10) unsigned NOT NULL auto_increment,
-                             `question` int(10) unsigned NOT NULL default '0',
-                             `choose` INT UNSIGNED DEFAULT '4' NOT NULL,
-                             PRIMARY KEY ( `id` )
-                          );");
-    }
-
-    if ($success && $oldversion < 2003030303) {
-        $success = $success && table_column("quiz_questions", "", "defaultgrade", "INTEGER", "6", "UNSIGNED", "1", "NOT NULL", "image");
-    }
-
-    if ($success && $oldversion < 2003032601) {
-        $success = $success && execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_answers` ADD INDEX(question) ");
-        $success = $success && execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_attempts` ADD INDEX(quiz) ");
-        $success = $success && execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_attempts` ADD INDEX(userid) ");
-        $success = $success && execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_grades` ADD INDEX(quiz) ");
-        $success = $success && execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_grades` ADD INDEX(userid) ");
-        $success = $success && execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_question_grades` ADD INDEX(quiz) ");
-        $success = $success && execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_question_grades` ADD INDEX(question) ");
-        $success = $success && execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_randommatch` ADD INDEX(question) ");
-        $success = $success && execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_responses` ADD INDEX(attempt) ");
-        $success = $success && execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_responses` ADD INDEX(question) ");
-    }
-
-    if ($success && $oldversion < 2003033100) {
-        $success = $success && modify_database ("", "ALTER TABLE prefix_quiz_randommatch RENAME prefix_quiz_randomsamatch ");
-        $success = $success && modify_database ("", "CREATE TABLE `prefix_quiz_match` (
-                             `id` int(10) unsigned NOT NULL auto_increment,
-                             `question` int(10) unsigned NOT NULL default '0',
-                             `subquestions` varchar(255) NOT NULL default '',
-                             PRIMARY KEY  (`id`),
-                             KEY `question` (`question`)
-                           );");
-
-        $success = $success && modify_database ("", "CREATE TABLE `prefix_quiz_match_sub` (
-                             `id` int(10) unsigned NOT NULL auto_increment,
-                             `question` int(10) unsigned NOT NULL default '0',
-                             `questiontext` text NOT NULL,
-                             `answertext` varchar(255) NOT NULL default '',
-                             PRIMARY KEY  (`id`),
-                             KEY `question` (`question`)
-                           );");
-    }
-
-    if ($success && $oldversion < 2003040901) {
-        $success = $success && table_column("quiz", "", "shufflequestions", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "review");
-        $success = $success && table_column("quiz", "", "shuffleanswers", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "shufflequestions");
-    }
-
-    if ($success && $oldversion < 2003071001) {
-
-        $success = $success && modify_database ("", " CREATE TABLE `prefix_quiz_numerical` (
-                               `id` int(10) unsigned NOT NULL auto_increment,
-                               `question` int(10) unsigned NOT NULL default '0',
-                               `answer` int(10) unsigned NOT NULL default '0',
-                               `min` varchar(255) NOT NULL default '',
-                               `max` varchar(255) NOT NULL default '',
-                               PRIMARY KEY  (`id`),
-                               KEY `answer` (`answer`)
-                             ) TYPE=MyISAM COMMENT='Options for numerical questions'; ");
-    }
-
-    if ($success && $oldversion < 2003072400) {
-        $success = $success && execute_sql(" INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('quiz', 'review', 'quiz', 'name') ");
-    }
-
-    if ($success && $oldversion < 2003072901) {
-        $success = $success && modify_database ("", " CREATE TABLE `prefix_quiz_multianswers` (
-                               `id` int(10) unsigned NOT NULL auto_increment,
-                                `question` int(10) unsigned NOT NULL default '0',
-                                `answers` varchar(255) NOT NULL default '',
-                                `positionkey` varchar(255) NOT NULL default '',
-                                `answertype` smallint(6) NOT NULL default '0',
-                                `norm` int(10) unsigned NOT NULL default '1',
-                                PRIMARY KEY  (`id`),
-                                KEY `question` (`question`)
-                              ) TYPE=MyISAM COMMENT='Options for multianswer questions'; ");
-    }
-
-    if ($success && $oldversion < 2003080301) {
-        $success = $success && execute_sql(" ALTER TABLE {$CFG->prefix}quiz ADD eachattemptbuildsonthelast TINYINT(4) DEFAULT '0' NOT NULL AFTER `attempts` ");
-    }
-
-    if ($success && $oldversion < 2003080400) {
-        $success = $success && table_column("quiz", "eachattemptbuildsonthelast", "attemptonlast", "TINYINT", "4", "UNSIGNED", "0", "NOT NULL", "");
-    }
-
-    if ($success && $oldversion < 2003082300) {
-        $success = $success && table_column("quiz_questions", "", "stamp", "varchar", "255", "", "", "not null", "qtype");
-    }
-
-    if ($success && $oldversion < 2003082301) {
-        $success = $success && table_column("quiz_questions", "stamp", "stamp", "varchar", "255", "", "", "not null");
-        $success = $success && table_column("quiz_questions", "", "version", "integer", "10", "", "1", "not null", "stamp");
-        if ($questions = get_records("quiz_questions")) {
-            foreach ($questions as $question) {
-                $stamp = make_unique_id_code();
-                if (!($success = $success && set_field("quiz_questions", "stamp", $stamp, "id", $question->id))) {
-                    notify("Error while adding stamp to question id = $question->id");
-                    break;
-                }
-            }
-        }
-    }
-
-    if ($success && $oldversion < 2003082700) {
-        $success = $success && table_column("quiz_categories", "", "stamp", "varchar", "255", "", "", "not null");
-        if ($categories = get_records("quiz_categories")) {
-            foreach ($categories as $category) {
-                $stamp = make_unique_id_code();
-                if (!($success = $success && set_field("quiz_categories", "stamp", $stamp, "id", $category->id))) {
-                    notify("Error while adding stamp to category id = $category->id");
-                    break;
-                }
-            }
-        }
-    }
-
-    if ($success && $oldversion < 2003111100) {
-        $duplicates = get_records_sql("SELECT stamp as id,count(*) as cuenta
-                                       FROM {$CFG->prefix}quiz_questions
-                                       GROUP BY stamp
-                                       HAVING count(*)>1");
-
-        if ($duplicates) {
-            notify("You have some quiz questions with duplicate stamps IDs.  Cleaning these up.");
-            foreach ($duplicates as $duplicate) {
-                $questions = get_records("quiz_questions","stamp",$duplicate->id);
-                $add = 1;
-                foreach ($questions as $question) {
-                    echo "Changing question id $question->id stamp to ".$duplicate->id.$add."<br />";
-                    $success = $success && set_field("quiz_questions","stamp",$duplicate->id.$add,"id",$question->id);
-                    $add++;
-                }
-            }
-        } else {
-            notify("Checked your quiz questions for stamp duplication errors, but no problems were found.", "green");
-        }
-    }
-
-    if ($success && $oldversion < 2004021300) {
-        $success = $success && table_column("quiz_questions", "", "questiontextformat", "integer", "2", "", "0", "not null", "questiontext");
-    }
-
-    if ($success && $oldversion < 2004021900) {
-        $success = $success && modify_database("","INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('quiz', 'add', 'quiz', 'name');");
-        $success = $success && modify_database("","INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('quiz', 'update', 'quiz', 'name');");
-    }
-
-    if ($success && $oldversion < 2004051700) {
-        include_once("$CFG->dirroot/mod/quiz/lib.php");
-        $success = $success && quiz_refresh_events();
-    }
-
-    if ($success && $oldversion < 2004060200) {
-        $success = $success && execute_sql(" ALTER TABLE {$CFG->prefix}quiz ADD timelimit INT(2) UNSIGNED DEFAULT '0' NOT NULL ");
-    }
-
-    if ($success && $oldversion < 2004070700) {
-        $success = $success && table_column("quiz", "", "password", "varchar", "255", "", "", "not null", "");
-        $success = $success && table_column("quiz", "", "subnet", "varchar", "255", "", "", "not null", "");
-    }
-
-    if ($success && $oldversion < 2004073001) {
-        // Six new tables:
-
-        // One table for handling units for numerical questions
-        $success = $success && modify_database ("", " CREATE TABLE `prefix_quiz_numerical_units` (
-                               `id` int(10) unsigned NOT NULL auto_increment,
-                               `question` int(10) unsigned NOT NULL default '0',
-                               `multiplier` decimal(40,20) NOT NULL default '1.00000000000000000000',
-                               `unit` varchar(50) NOT NULL default '',
-                               PRIMARY KEY  (`id`)
-                ) TYPE=MyISAM COMMENT='Optional unit options for numerical questions'; ");
-
-        // Four tables for handling distribution and storage of
-        // individual data for dataset dependent question types
-        $success = $success && modify_database ("", " CREATE TABLE `prefix_quiz_attemptonlast_datasets` (
-                               `id` int(10) unsigned NOT NULL auto_increment,
-                               `category` int(10) unsigned NOT NULL default '0',
-                               `userid` int(10) unsigned NOT NULL default '0',
-                               `datasetnumber` int(10) unsigned NOT NULL default '0',
-                               PRIMARY KEY  (`id`),
-                               UNIQUE KEY `category` (`category`,`userid`)
-            ) TYPE=MyISAM COMMENT='Dataset number for attemptonlast attempts per user'; ");
-        $success = $success && modify_database ("", " CREATE TABLE `prefix_quiz_dataset_definitions` (
-                               `id` int(10) unsigned NOT NULL auto_increment,
-                               `category` int(10) unsigned NOT NULL default '0',
-                               `name` varchar(255) NOT NULL default '',
-                               `type` int(10) NOT NULL default '0',
-                               `options` varchar(255) NOT NULL default '',
-                               `itemcount` int(10) unsigned NOT NULL default '0',
-                               PRIMARY KEY  (`id`)
-            ) TYPE=MyISAM COMMENT='Organises and stores properties for dataset items'; ");
-        $success = $success && modify_database ("", " CREATE TABLE `prefix_quiz_dataset_items` (
-                               `id` int(10) unsigned NOT NULL auto_increment,
-                               `definition` int(10) unsigned NOT NULL default '0',
-                               `number` int(10) unsigned NOT NULL default '0',
-                               `value` varchar(255) NOT NULL default '',
-                               PRIMARY KEY  (`id`),
-                               KEY `definition` (`definition`)
-                             ) TYPE=MyISAM COMMENT='Individual dataset items'; ");
-        $success = $success && modify_database ("", " CREATE TABLE `prefix_quiz_question_datasets` (
-                               `id` int(10) unsigned NOT NULL auto_increment,
-                               `question` int(10) unsigned NOT NULL default '0',
-                               `datasetdefinition` int(10) unsigned NOT NULL default '0',
-                               PRIMARY KEY  (`id`),
-                               KEY `question` (`question`,`datasetdefinition`)
-            ) TYPE=MyISAM COMMENT='Many-many relation between questions and dataset definitions'; ");
-
-        // One table for new question type calculated
-        //  - the first dataset dependent question type
-        $success = $success && modify_database ("", " CREATE TABLE `prefix_quiz_calculated` (
-                               `id` int(10) unsigned NOT NULL auto_increment,
-                               `question` int(10) unsigned NOT NULL default '0',
-                               `answer` int(10) unsigned NOT NULL default '0',
-                               `tolerance` varchar(20) NOT NULL default '0.0',
-                               `tolerancetype` int(10) NOT NULL default '1',
-                               `correctanswerlength` int(10) NOT NULL default '2',
-                               PRIMARY KEY  (`id`),
-                               KEY `question` (`question`)
-                ) TYPE=MyISAM COMMENT='Options for questions of type calculated'; ");
-    }
-
-    if ($success && $oldversion < 2004111400) {
-        $success = $success && table_column("quiz_responses", "answer", "answer", "text", "", "", "", "not null");
-    }
-
-    if ($success && $oldversion < 2004111700) {
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz DROP INDEX course;",false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_calculated DROP INDEX answer;",false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_categories DROP INDEX course;",false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_dataset_definitions DROP INDEX category;",false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_numerical DROP INDEX question;",false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_numerical_units DROP INDEX question;",false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_questions DROP INDEX category;",false);
-
-        $success = $success && modify_database('','ALTER TABLE prefix_quiz ADD INDEX course (course);');
-        $success = $success && modify_database('','ALTER TABLE prefix_quiz_calculated ADD INDEX answer (answer);');
-        $success = $success && modify_database('','ALTER TABLE prefix_quiz_categories ADD INDEX course (course);');
-        $success = $success && modify_database('','ALTER TABLE prefix_quiz_dataset_definitions ADD INDEX category (category);');
-        $success = $success && modify_database('','ALTER TABLE prefix_quiz_numerical ADD INDEX question (question);');
-        $success = $success && modify_database('','ALTER TABLE prefix_quiz_numerical_units ADD INDEX question (question);');
-        $success = $success && modify_database('','ALTER TABLE prefix_quiz_questions ADD INDEX category (category);');
-    }
-
-    if ($success && $oldversion < 2004120501) {
-        $success = $success && table_column("quiz_calculated", "", "correctanswerformat", "integer", "10", "", "2", "not null", "correctanswerlength");
-    }
-
-    if ($success && $oldversion < 2004121400) {  // New field to determine popup window behaviour
-        $success = $success && table_column("quiz", "", "popup", "integer", "4", "", "0", "not null", "subnet");
-    }
-
-    if ($success && $oldversion < 2005010201) {
-        $success = $success && table_column('quiz_categories', '', 'parent');
-        $success = $success && table_column('quiz_categories', '', 'sortorder', 'integer', '10', '', '999');
-    }
-
-    if ($success && $oldversion < 2005010300) {
-        $success = $success && table_column("quiz", "", "questionsperpage", "integer", "10", "", "0", "not null", "review");
-    }
-
-    if ($success && $oldversion < 2005012700) {
-        $success = $success && table_column('quiz_grades', 'grade', 'grade', 'real', 2, '');
-    }
-
-    if ($success && $oldversion < 2005021400) {
-        $success = $success && table_column("quiz", "", "decimalpoints", "integer", "4", "", "2", "not null", "grademethod");
-    }
-
-    if($success && $oldversion < 2005022800) {
-        $success = $success && table_column('quiz_questions', '', 'hidden', 'integer', '1', 'unsigned', '0', 'not null', 'version');
-        $success = $success && table_column('quiz_responses', '', 'originalquestion', 'integer', '10', 'unsigned', '0', 'not null', 'question');
-        $success = $success && modify_database ('', "CREATE TABLE `prefix_quiz_question_version` (
-                              `id` int(10) unsigned NOT NULL auto_increment,
-                              `quiz` int(10) unsigned NOT NULL default '0',
-                              `oldquestion` int(10) unsigned NOT NULL default '0',
-                              `newquestion` int(10) unsigned NOT NULL default '0',
-                              `userid` int(10) unsigned NOT NULL default '0',
-                              `timestamp` int(10) unsigned NOT NULL default '0',
-                              PRIMARY KEY  (`id`)
-                            ) TYPE=MyISAM COMMENT='The mapping between old and new versions of a question';");
-    }
-
-    if ($success && $oldversion < 2005032000) {
-        $success = $success && execute_sql(" INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('quiz', 'editquestions', 'quiz', 'name') ");
-    }
-
-    if ($success && $oldversion < 2005032300) {
-        $success = $success && modify_database ('', 'ALTER TABLE prefix_quiz_question_version RENAME prefix_quiz_question_versions;');
-    }
-
-    if ($success && $oldversion < 2005041200) { // replace wiki-like with markdown
-        include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
-        $wtm = new WikiToMarkdown();
-        $sql = "select course from {$CFG->prefix}quiz_categories c, {$CFG->prefix}quiz_questions q ";
-        $sql .= "where c.id = q.category ";
-        $sql .= "and q.id = ";
-        $wtm->update( 'quiz_questions', 'questiontext', 'questiontextformat', $sql );
-    }
-
-    if ($success && $oldversion < 2005041304) {
-        // make random questions hidden
-        $success = $success && modify_database('', "UPDATE prefix_quiz_questions SET hidden = '1' WHERE qtype ='".RANDOM."';");
-    }
-
-    if ($success && $oldversion < 2005042002) {
-        $success = $success && table_column('quiz_answers', 'answer', 'answer', 'text', '', '', '', 'not null', '');
-    }
-
-    if ($success && $oldversion < 2005042400) {
-
-    // Changes to quiz table
-
-        // The bits of the optionflags field will hold various option flags
-        $success = $success && table_column('quiz', '', 'optionflags', 'integer', '10', 'unsigned', '0', 'not null', 'timeclose');
-
-        // The penalty scheme
-        $success = $success && table_column('quiz', '', 'penaltyscheme', 'integer', '4', 'unsigned', '0', 'not null', 'optionflags');
-
-        // The review options are now all stored in the bits of the review field
-        $success = $success && table_column('quiz', 'review', 'review', 'integer', 10, 'unsigned', 0, 'not null', '');
-
-    /// Changes to quiz_attempts table
-
-        // The preview flag marks teacher previews
-        $success = $success && table_column('quiz_attempts', '', 'preview', 'tinyint', '2', 'unsigned', '0', 'not null', 'timemodified');
-
-        // The layout is the list of questions with inserted page breaks.
-        $success = $success && table_column('quiz_attempts', '', 'layout', 'text', '', '', '', 'not null', 'timemodified');
-        // For old quiz attempts we will set this to the repaginated question list from $quiz->questions
-
-    /// The following updates of field values require a loop through all quizzes
-        // This is because earlier versions of mysql don't allow joins in UPDATE
-        if ($quizzes = get_records('quiz')) {
-
-            // turn reporting off temporarily to avoid one line output per set_field
-            $olddebug = $db->debug;
-            $db->debug = false;
-            echo 'Now updating '.count($quizzes).' quizzes';
-            foreach ($quizzes as $quiz) {
-
-                // repaginate
-                if ($quiz->questionsperpage) {
-                    $quiz->questions = quiz_repaginate($quiz->questions, $quiz->questionsperpage);
-                    $success = $success && set_field('quiz', 'questions', $quiz->questions, 'id', $quiz->id);
-                }
-                $success = $success && set_field('quiz_attempts', 'layout', $quiz->questions, 'quiz', $quiz->id);
-
-                // set preview flag
-                if ($teachers = get_course_teachers($quiz->course)) {
-                    $teacherids = implode(',', array_keys($teachers));
-                    $success = $success && execute_sql("UPDATE {$CFG->prefix}quiz_attempts SET preview = 1 WHERE userid IN ($teacherids)");
-                }
-
-                // set review flags in quiz table
-                $review = (QUIZ_REVIEW_IMMEDIATELY & (QUIZ_REVIEW_RESPONSES + QUIZ_REVIEW_SCORES));
-                if ($quiz->feedback) {
-                    $review += (QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_FEEDBACK);
-                }
-                if ($quiz->correctanswers) {
-                    $review += (QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_ANSWERS);
-                }
-                if ($quiz->review & 1) {
-                    $review += QUIZ_REVIEW_CLOSED;
-                }
-                if ($quiz->review & 2) {
-                    $review += QUIZ_REVIEW_OPEN;
-                }
-                $success = $success && set_field('quiz', 'review', $review, 'id', $quiz->id);
-            }
-            $db->debug = $olddebug;
-        }
-
-        // We can now drop the fields whose data has been moved to the review field
-        $success = $success && execute_sql(" ALTER TABLE `{$CFG->prefix}quiz` DROP feedback");
-        $success = $success && execute_sql(" ALTER TABLE `{$CFG->prefix}quiz` DROP correctanswers");
-
-    /// Renaming tables
-
-        // rename the quiz_question_grades table to quiz_question_instances
-        $success = $success && modify_database ('', 'ALTER TABLE prefix_quiz_question_grades RENAME prefix_quiz_question_instances;');
-
-        // rename the quiz_responses table quiz_states
-        $success = $success && modify_database ('', 'ALTER TABLE prefix_quiz_responses RENAME prefix_quiz_states;');
-
-    /// add columns to quiz_states table
-
-        // The sequence number of the state.
-        $success = $success && table_column('quiz_states', '', 'seq_number', 'integer', '6', 'unsigned', '0', 'not null', 'originalquestion');
-        // For existing states we leave this at 0 because in the old quiz code there was only one response allowed
-
-        // The time the state was created.
-        $success = $success && table_column('quiz_states', '', 'timestamp', 'integer', '10', 'unsigned', '0', 'not null', 'answer');
-        // For existing states we will below set this to the timemodified field of the attempt
-
-        // The type of event that led to the creation of the state
-        $success = $success && table_column('quiz_states', '', 'event', 'integer', '4', 'unsigned', '0', 'not null', 'timestamp');
-
-        // The raw grade
-        $success = $success && table_column('quiz_states', '', 'raw_grade', 'varchar', '10', '', '', 'not null', 'grade');
-        // For existing states (no penalties) this is equal to the grade
-        $success = $success && execute_sql("UPDATE {$CFG->prefix}quiz_states SET raw_grade = grade");
-
-        // The penalty that the response attracted
-        $success = $success && table_column('quiz_states', '', 'penalty', 'varchar', '10', '', '0.0', 'not null', 'raw_grade');
-        // For existing states this can stay at 0 because penalties did not exist previously.
-
-    /// New table for pointers to newest and newest graded states
-
-        $success = $success && modify_database('', "CREATE TABLE `prefix_quiz_newest_states` (
-                             `id` int(10) unsigned NOT NULL auto_increment,
-                             `attemptid` int(10) unsigned NOT NULL default '0',
-                             `questionid` int(10) unsigned NOT NULL default '0',
-                             `new` int(10) unsigned NOT NULL default '0',
-                             `newgraded` int(10) unsigned NOT NULL default '0',
-                             `sumpenalty` varchar(10) NOT NULL default '0.0',
-                             PRIMARY KEY  (`id`),
-                             UNIQUE KEY `attemptid` (`attemptid`,`questionid`)
-                           ) TYPE=MyISAM COMMENT='Gives ids of the newest open and newest graded states';");
-
-    /// Now upgrade some fields in states and newest_states tables where necessary
-        // to save time on large sites only do this for attempts that have not yet been finished.
-        if ($attempts = get_records_select('quiz_attempts', 'timefinish = 0')) {
-            echo 'Update the states for the '.count($attempts).' open attempts';
-            // turn reporting off temporarily to avoid one line output per set_field
-            $olddebug = $db->debug;
-            $db->debug = false;
-            foreach ($attempts as $attempt) {
-                quiz_upgrade_states($attempt);
-            }
-            $db->debug = $olddebug;
-        }
-
-    /// Entries for the log_display table
-
-        $success = $success && modify_database('', " INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('quiz', 'preview', 'quiz', 'name');");
-        $success = $success && modify_database('', " INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('quiz', 'start attempt', 'quiz', 'name');");
-        $success = $success && modify_database('', " INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('quiz', 'close attempt', 'quiz', 'name');");
-
-    /// update the default settings in $CFG
-        $review = (QUIZ_REVIEW_IMMEDIATELY & (QUIZ_REVIEW_RESPONSES + QUIZ_REVIEW_SCORES));
-        if (!empty($CFG->quiz_feedback)) {
-            $review += (QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_FEEDBACK);
-        }
-        if (!empty($CFG->quiz_correctanswers)) {
-            $review += (QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_ANSWERS);
-        }
-        if (isset($CFG->quiz_review) and ($CFG->quiz_review & 1)) {
-            $review += QUIZ_REVIEW_CLOSED;
-        }
-        if (isset($CFG->quiz_review) and ($CFG->quiz_review & 2)) {
-            $review += QUIZ_REVIEW_OPEN;
-        }
-        $success = $success && set_config('quiz_review', $review);
-
-    /// Use tolerance instead of min and max in numerical question type
-        $success = $success && table_column('quiz_numerical', '', 'tolerance', 'varchar', '255', '', '0.0', 'not null', 'answer');
-        $success = $success && execute_sql("UPDATE {$CFG->prefix}quiz_numerical SET tolerance = (max-min)/2");
-        $success = $success && modify_database('', 'ALTER TABLE `prefix_quiz_numerical` DROP `min`'); // Replaced by tolerance
-        $success = $success && modify_database('', 'ALTER TABLE `prefix_quiz_numerical` DROP `max`'); // Replaced by tolerance
-
-    /// Tables for Remote Questions
-        $success = $success && modify_database ('', "CREATE TABLE `prefix_quiz_rqp` (
-                              `id` int(10) unsigned NOT NULL auto_increment,
-                              `question` int(10) unsigned NOT NULL default '0',
-                              `type` int(10) unsigned NOT NULL default '0',
-                              `source` longblob NOT NULL default '',
-                              `format` varchar(255) NOT NULL default '',
-                              `flags` tinyint(3) unsigned NOT NULL default '0',
-                              `maxscore` int(10) unsigned NOT NULL default '1',
-                              PRIMARY KEY  (`id`),
-                              KEY `question` (`question`)
-                              ) TYPE=MyISAM COMMENT='Options for RQP questions';");
-
-        $success = $success && modify_database ('', "CREATE TABLE `prefix_quiz_rqp_type` (
-                              `id` int(10) unsigned NOT NULL auto_increment,
-                              `name` varchar(255) NOT NULL default '',
-                              `rendering_server` varchar(255) NOT NULL default '',
-                              `cloning_server` varchar(255) NOT NULL default '',
-                              `flags` tinyint(3) NOT NULL default '0',
-                              PRIMARY KEY  (`id`),
-                              UNIQUE KEY `name` (`name`)
-                              ) TYPE=MyISAM COMMENT='RQP question types and the servers to be used to process them';");
-
-        $success = $success && modify_database ('', "CREATE TABLE `prefix_quiz_rqp_states` (
-                              `id` int(10) unsigned NOT NULL auto_increment,
-                              `stateid` int(10) unsigned NOT NULL default '0',
-                              `responses` text NOT NULL default '',
-                              `persistent_data` text NOT NULL default '',
-                              `template_vars` text NOT NULL default '',
-                              PRIMARY KEY  (`id`)
-                              ) TYPE=MyISAM COMMENT='RQP question type specific state information';");
-    }
-
-    if ($success && $oldversion < 2005050300) {
-        // length of question determines question numbering. Currently all questions require one
-        // question number except for DESCRIPTION questions.
-        $success = $success && table_column('quiz_questions', '', 'length', 'integer', '10', 'unsigned', '1', 'not null', 'qtype');
-        $success = $success && execute_sql("UPDATE {$CFG->prefix}quiz_questions SET length = 0 WHERE qtype ='7'");
-    }
-
-    if ($success && $oldversion < 2005050408) {
-        $success = $success && table_column('quiz_questions', '', 'penalty', 'float', '', '', '0.1', 'not null', 'defaultgrade');
-        $success = $success && table_column('quiz_newest_states', 'new', 'newest', 'integer', '10', 'unsigned', '0', 'not null');
-    }
-
-    if ($success && $oldversion < 2005051400) {
-        $success = $success && modify_database('', 'ALTER TABLE prefix_quiz_rqp_type RENAME prefix_quiz_rqp_types;');
-        $success = $success && modify_database('', "CREATE TABLE `prefix_quiz_rqp_servers` (
-                      id int(10) unsigned NOT NULL auto_increment,
-                      typeid int(10) unsigned NOT NULL default '0',
-                      url varchar(255) NOT NULL default '',
-                      can_render tinyint(2) unsigned NOT NULL default '0',
-                      can_author tinyint(2) unsigned NOT NULL default '0',
-                      PRIMARY KEY  (id)
-                    ) TYPE=MyISAM COMMENT='Information about RQP servers';");
-        if ($types = get_records('quiz_rqp_types')) {
-            foreach($types as $type) {
-                $server = new stdClass;
-                $server->typeid = $type->id;
-                $server->url = $type->rendering_server;
-                $server->can_render = 1;
-                $success = $success && insert_record('quiz_rqp_servers', $server);
-            }
-        }
-        $success = $success && modify_database('', 'ALTER TABLE prefix_quiz_rqp_types DROP rendering_server');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_quiz_rqp_types DROP cloning_server');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_quiz_rqp_types DROP flags');
-    }
-
-    if ($success && $oldversion < 2005051401) {
-        // Some earlier changes are undone here, so we need another condition
-        if ($oldversion >= 2005042900) {
-            // Restore the answer field
-            $success = $success && table_column('quiz_numerical', '', 'answer', 'integer', '10', 'unsigned', '0', 'not null', 'answers');
-            $singleanswer = array();
-            if ($numericals = get_records('quiz_numerical')) {
-                $numericals = array_values($numericals);
-                $n = count($numericals);
-                for ($i = 0; $i < $n; $i++) {
-                    $numerical =& $numericals[$i];
-                    if (strpos($numerical->answers, ',')) { // comma separated list?
-                        // Back this up to delete the record after the new ones are created
-                        $id = $numerical->id;
-                        unset($numerical->id);
-                        // We need to create a record for each answer id
-                        $answers = explode(',', $numerical->answers);
-                        foreach ($answers as $answer) {
-                            $numerical->answer = $answer;
-                            $success = $success && insert_record('quiz_numerical', $numerical);
-                        }
-                        // ... and get rid of the old record
-                        $success = $success && delete_records('quiz_numerical', 'id', $id);
-                    } else {
-                        $singleanswer[] = $numerical->id;
-                    }
-                }
-            }
-
-            // Do all of these at once
-            if (!empty($singleanswer)) {
-                $singleanswer = implode(',', $singleanswer);
-                $success = $success && modify_database('', "UPDATE prefix_quiz_numerical SET answer = answers WHERE id IN ($singleanswer);");
-            }
-
-            // All answer fields are set, so we can delete the answers field
-            $success = $success && modify_database('', 'ALTER TABLE `prefix_quiz_numerical` DROP `answers`');
-
-        // If the earlier changes weren't made we can safely do only the
-        // bits here.
-        } else {
-            // Comma separated questionids will be stored as sequence
-            $success = $success && table_column('quiz_multianswers', '', 'sequence',  'varchar', '255', '', '', 'not null', 'question');
-            // Change the type of positionkey to int, so that the sorting works!
-            $success = $success && table_column('quiz_multianswers', 'positionkey', 'positionkey',  'integer', '10', 'unsigned', '0', 'not null', '');
-            $success = $success && table_column('quiz_questions', '', 'parent', 'integer', '10', 'unsigned', '0', 'not null', 'category');
-            $success = $success && modify_database('', "UPDATE prefix_quiz_questions SET parent = id WHERE qtype ='".RANDOM."';");
-
-            // Each multianswer record is converted to a question object and then
-            // inserted as a new question into the quiz_questions table.
-            // After that the question fields in the quiz_answers table and the
-            // qtype specific tables are updated to point to the new question id.
-            // Note: The quiz_numerical table is different as it stores one record
-            //       per defined answer (to allow different tolerance values for
-            //       different possible answers. (Currently multiple answers are
-            //       not supported by the numerical editing interface, but
-            //       all processing code does support that possibility.
-            if ($multianswers = get_records_sql("SELECT m.id, q.category, " .
-                                            "q.id AS parent, " . // question id (of multianswer question) as parent
-                                            "q.name, q.questiontextformat, " .
-                                            "m.norm AS defaultgrade, " . // norm is snow stored as defaultgrade
-                                            "m.answertype AS qtype, " .  // just rename this
-                                            "q.version, q.hidden, m.answers, " .
-                                            "m.positionkey " .
-                                            "FROM {$CFG->prefix}quiz_questions q, " .
-                                            "     {$CFG->prefix}quiz_multianswers m " .
-                                            "WHERE q.qtype = '".MULTIANSWER."' " .
-                                            "AND   q.id = m.question " .
-                                            "ORDER BY q.id ASC, m.positionkey ASC")) { // ordered by positionkey
-                $multianswers = array_values($multianswers);
-                $n        = count($multianswers);
-                $parent   = $multianswers[0]->parent;
-                $sequence = array();
-                $positions = array();
-
-                // Turn reporting off temporarily to avoid one line output per set_field
-                global $db;
-                $olddebug = $db->debug;
-                $db->debug = false;
-                echo 'Now updating '.$n.' cloze questions.';
-                for ($i = 0; $i < $n; $i++) {
-                    // Backup these two values before unsetting the object fields
-                    $answers = $multianswers[$i]->answers; unset($multianswers[$i]->answers);
-                    $pos = $multianswers[$i]->positionkey; unset($multianswers[$i]->positionkey);
-
-                    // Needed for substituting multianswer ids with position keys in the $state->answer field
-                    $positions[$multianswers[$i]->id] = $pos;
-
-                // Create questions for all the multianswer victims
-                    unset($multianswers[$i]->id);
-                    $multianswers[$i]->length = 0;
-                    $multianswers[$i]->questiontext = '';
-                    $multianswers[$i]->stamp = make_unique_id_code();
-                    $multianswers[$i]->name = addslashes($multianswers[$i]->name);
-                    // $multianswers[$i]->parent is set in the query
-                    // $multianswers[$i]->defaultgrade is set in the query
-                    // $multianswers[$i]->qtype is set in the query
-                    $id = insert_record('quiz_questions', $multianswers[$i]);
-                    $success = $success && $id;
-                    $sequence[$pos] = $id;
-
-                // Update the quiz_answers table to point to these new questions
-                $success = $success && execute_sql("UPDATE {$CFG->prefix}quiz_answers SET question = '$id' WHERE id IN ($answers)", false);
-                // Update the questiontype tables to point to these new questions
-
-                    if (SHORTANSWER == $multianswers[$i]->qtype) {
-                        $success = $success && execute_sql("UPDATE {$CFG->prefix}quiz_shortanswer SET question = '$id' WHERE answers = '$answers'", false);
-                    } else if (MULTICHOICE == $multianswers[$i]->qtype) {
-                        $success = $success && execute_sql("UPDATE {$CFG->prefix}quiz_multichoice SET question = '$id' WHERE answers = '$answers'", false);
-                    } else if (NUMERICAL == $multianswers[$i]->qtype) {
-                        $success = $success && execute_sql("UPDATE {$CFG->prefix}quiz_numerical SET question = '$id' WHERE answer IN ($answers)", false);
-                    }
-
-                    // Whenever we're through with the subquestions of one multianswer
-                    // question we delete the old records in the multianswers table,
-                    // store a new record with the sequence in the multianswers table
-                    // and point $parent to the next multianswer question.
-                    if (!isset($multianswers[$i+1]) || $parent != $multianswers[$i+1]->parent) {
-
-                        // Substituting multianswer ids with position keys in the $state->answer field
-                        if ($states = get_records('quiz_states', 'question', $parent)) {
-                            foreach ($states as $state) {
-                                $reg = array();
-                                preg_match_all('/(?:^|,)([0-9]+)-([^,]*)/', $state->answer, $reg);
-                                $state->answer = '';
-                                $m = count($reg[1]);
-                                for ($j = 0; $j < $m; $j++) {
-                                    if (isset($positions[$reg[1][$j]])) {
-                                        $state->answer .= $positions[$reg[1][$j]] . '-' . $reg[2][$j] . ',';
-                                    } else {
-                                        notify("Undefined multianswer id ({$reg[1][$j]}) used in state #{$state->id}!");
-                                        $state->answer .= $j+1 . '-' . $reg[2][$j] . ',';
-                                    }
-                                }
-                                $state->answer = rtrim($state->answer, ','); // strip trailing comma
-                                $success = $success && update_record('quiz_states', $state);
-                            }
-                        }
-
-                        $success = $success && delete_records('quiz_multianswers', 'question', $parent);
-                        $multi = new stdClass;
-                        $multi->question = $parent;
-                        $multi->sequence = implode(',', $sequence);
-                        $success = $success && insert_record('quiz_multianswers', $multi);
-
-                        if (isset($multianswers[$i+1])) {
-                            $parent    = $multianswers[$i+1]->parent;
-                            $sequence  = array();
-                            $positions = array();
-                        }
-                    }
-                }
-                $db->debug = $olddebug;
-            }
-
-            // Remove redundant fields from quiz_multianswers
-            $success = $success && modify_database('', 'ALTER TABLE `prefix_quiz_multianswers` DROP `answers`');
-            $success = $success && modify_database('', 'ALTER TABLE `prefix_quiz_multianswers` DROP `positionkey`');
-            $success = $success && modify_database('', 'ALTER TABLE `prefix_quiz_multianswers` DROP `answertype`');
-            $success = $success && modify_database('', 'ALTER TABLE `prefix_quiz_multianswers` DROP `norm`');
-        }
-    }
-
-    if ($success && $oldversion < 2005052004) {
-        // We need to remove some duplicate entries that may be present in some databases
-        // due to a faulty restore script
-
-        // Remove duplicate entries from quiz_numerical
-        if ($dups = get_records_sql("
-                SELECT question, answer, count(*) as num
-                FROM {$CFG->prefix}quiz_numerical
-                GROUP BY question, answer
-                HAVING count(*) > 1"
-            )) {
-            foreach ($dups as $dup) {
-                $ids = get_records_sql("
-                    SELECT id, id
-                    FROM {$CFG->prefix}quiz_numerical
-                    WHERE question = '$dup->question'
-                    AND answer = '$dup->answer'"
-                );
-                $skip = true;
-                foreach ($ids as $id) {
-                    if ($skip) {
-                        $skip = false;
-                    } else {
-                        $success = $success && delete_records('quiz_numerical','id', $id->id);
-                    }
-                }
-            }
-        }
-
-        // Remove duplicate entries from quiz_shortanswer
-        if ($dups = get_records_sql("
-                SELECT question, answers, count(*) as num
-                FROM {$CFG->prefix}quiz_shortanswer
-                GROUP BY question, answers
-                HAVING count(*) > 1"
-            )) {
-            foreach ($dups as $dup) {
-                $ids = get_records_sql("
-                    SELECT id, id
-                    FROM {$CFG->prefix}quiz_shortanswer
-                    WHERE question = '$dup->question'
-                    AND answers = '$dup->answers'"
-                );
-                $skip = true;
-                foreach ($ids as $id) {
-                    if ($skip) {
-                        $skip = false;
-                    } else {
-                        $success = $success && delete_records('quiz_shortanswer','id', $id->id);
-                    }
-                }
-            }
-        }
-
-        // Remove duplicate entries from quiz_multichoice
-        if ($dups = get_records_sql("
-                SELECT question, answers, count(*) as num
-                FROM {$CFG->prefix}quiz_multichoice
-                GROUP BY question, answers
-                HAVING count(*) > 1"
-            )) {
-            foreach ($dups as $dup) {
-                $ids = get_records_sql("
-                    SELECT id, id
-                    FROM {$CFG->prefix}quiz_multichoice
-                    WHERE question = '$dup->question'
-                    AND answers = '$dup->answers'"
-                );
-                $skip = true;
-                foreach ($ids as $id) {
-                    if ($skip) {
-                        $skip = false;
-                    } else {
-                        $success = $success && delete_records('quiz_multichoice','id', $id->id);
-                    }
-                }
-            }
-        }
-    }
-
-    if ($success && $oldversion < 2005060300) {
-        //Search all the orphan categories (those whose course doesn't exist)
-        //and process them, deleting or moving them to site course - Bug 2459
-
-        //Set debug to false
-        $olddebug = $db->debug;
-        $db->debug = false;
-
-        //Iterate over all the quiz_categories records to get their course id
-        if ($courses = get_records_sql ("SELECT DISTINCT course as id, course
-                                         FROM {$CFG->prefix}quiz_categories")) {
-            //Iterate over courses
-            foreach ($courses as $course) {
-                //If the course doesn't exist, orphan category found!
-                //Process it with question_delete_course(). It will do all the hard work.
-                if (!record_exists('course', 'id', $course->id)) {
-                    require_once("$CFG->libdir/questionlib.php");
-                    $success = $success && question_delete_course($course);
-                }
-            }
-        }
-        //Reset rebug to its original state
-        $db->debug = $olddebug;
-    }
-
-    if ($success && $oldversion < 2005062600) {
-        $success = $success && modify_database ('', "
-            CREATE TABLE `prefix_quiz_essay` (
-                `id` int(10) unsigned NOT NULL auto_increment,
-                `question` int(10) unsigned NOT NULL default '0',
-                `answer` varchar(255) NOT NULL default '',
-                PRIMARY KEY  (`id`),
-                KEY `question` (`question`)
-           ) TYPE=MyISAM COMMENT='Options for essay questions'");
-    
-        $success = $success && modify_database ('', "
-            CREATE TABLE `prefix_quiz_essay_states` (
-              `id` int(10) unsigned NOT NULL auto_increment,
-              `stateid` int(10) unsigned NOT NULL default '0',
-              `graded` tinyint(4) unsigned NOT NULL default '0',
-              `fraction` varchar(10) NOT NULL default '0.0',
-              `response` text NOT NULL,
-              PRIMARY KEY  (`id`)
-            ) TYPE=MyISAM COMMENT='essay question type specific state information'");
-    }
-
-    if ($success && $oldversion < 2005070202) {
-        // add new unique id to prepare the way for lesson module to have its own attempts table
-        $success = $success && table_column('quiz_attempts', '', 'uniqueid', 'integer', '10', 'unsigned', '0', 'not null', 'id');
-        // initially we can use the id as the unique id because no other modules use attempts yet.
-        $success = $success && execute_sql("UPDATE {$CFG->prefix}quiz_attempts SET uniqueid = id", false);
-        // we set $CFG->attemptuniqueid to the next available id
-        $record = get_record_sql("SELECT max(id)+1 AS nextid FROM {$CFG->prefix}quiz_attempts");
-        $success = $success && set_config('attemptuniqueid', empty($record->nextid) ? 1 : $record->nextid);
-    }
-    
-    if ($success && $oldversion < 2006020801) {
-        // add new field to store time delay between the first and second quiz attempt
-        $success = $success && table_column('quiz', '', 'delay1', 'integer', '10', 'unsigned', '0', 'not null', 'popup');
-        // add new field to store time delay between the second and any additional quizes
-        $success = $success && table_column('quiz', '', 'delay2', 'integer', '10', 'unsigned', '0', 'not null', 'delay1');
-    }
-
-    if ($success && $oldversion < 2006021101) {
-        // set defaultgrade field properly (probably not necessary, but better make sure)
-        $success = $success && execute_sql("UPDATE {$CFG->prefix}quiz_questions SET defaultgrade = '1' WHERE defaultgrade = '0'", false);
-        $success = $success && execute_sql("UPDATE {$CFG->prefix}quiz_questions SET defaultgrade = '0' WHERE qtype = '7'", false);
-    }
-
-    if ($success && $oldversion < 2006021103) {
-        // add new field to store the question-level shuffleanswers option
-        $success = $success && table_column('quiz_match', '', 'shuffleanswers', 'tinyint', '4', 'unsigned', '1', 'not null', 'subquestions');
-        $success = $success && table_column('quiz_multichoice', '', 'shuffleanswers', 'tinyint', '4', 'unsigned', '1', 'not null', 'single');
-        $success = $success && table_column('quiz_randomsamatch', '', 'shuffleanswers', 'tinyint', '4', 'unsigned', '1', 'not null', 'choose');
-    }
-
-    if ($success && $oldversion < 2006021104) {
-        // add originalversion field for the new versioning mechanism
-        $success = $success && table_column('quiz_question_versions', '', 'originalquestion', 'int', '10', 'unsigned', '0', 'not null', 'newquestion');
-    }
-
-    if ($success && $oldversion < 2006021301) {
-        $success = $success && modify_database('','ALTER TABLE prefix_quiz_attempts ADD UNIQUE INDEX uniqueid (uniqueid);');
-    }
-
-    if ($success && $oldversion < 2006021302) {
-        $success = $success && table_column('quiz_match_sub', '', 'code', 'int', '10', 'unsigned', '0', 'not null', 'id');
-        $success = $success && execute_sql("UPDATE {$CFG->prefix}quiz_match_sub SET code = id", false);
-    }
-    if ($success && $oldversion < 2006021304) {
-        // convert sequence field to text to accomodate very long sequences, see bug 4257
-        $success = $success && table_column('quiz_multianswers', 'sequence', 'sequence',  'text', '', '', '', 'not null', 'question');
-    }
-
-    if ($success && $oldversion < 2006021501) {
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_newest_states RENAME {$CFG->prefix}question_sessions", false);
-    }
-
-    if ($success && $oldversion < 2006022200) {
-        // convert grade fields to float
-        $success = $success && set_field('quiz_attempts', 'sumgrades', 0, 'sumgrades', '');
-        $success = $success && table_column('quiz_attempts', 'sumgrades', 'sumgrades',  'float', '', '', '0', 'not null');
-
-        $success = $success && set_field('quiz_answers', 'fraction', 0, 'fraction', '');
-        $success = $success && table_column('quiz_answers', 'fraction', 'fraction',  'float', '', '', '0', 'not null');
-
-        $success = $success && set_field('quiz_essay_states', 'fraction', 0, 'fraction', '');
-        $success = $success && table_column('quiz_essay_states', 'fraction', 'fraction',  'float', '', '', '0', 'not null');
-
-        $success = $success && set_field('quiz_states', 'grade', 0, 'grade', '');
-        $success = $success && table_column('quiz_states', 'grade', 'grade',  'float', '', '', '0', 'not null');
-
-        $success = $success && set_field('quiz_states', 'raw_grade', 0, 'raw_grade', '');
-        $success = $success && table_column('quiz_states', 'raw_grade', 'raw_grade',  'float', '', '', '0', 'not null');
-
-        $success = $success && set_field('quiz_states', 'penalty', 0, 'penalty', '');
-        $success = $success && table_column('quiz_states', 'penalty', 'penalty',  'float', '', '', '0', 'not null');
-
-        $success = $success && set_field('question_sessions', 'sumpenalty', 0, 'sumpenalty', '');
-        $success = $success && table_column('question_sessions', 'sumpenalty', 'sumpenalty',  'float', '', '', '0', 'not null');
-    }
-
-    if ($success && $oldversion < 2006022400) {
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_questions RENAME {$CFG->prefix}question", false);
-    }
-
-    if ($success && $oldversion < 2006022402) {
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_states RENAME {$CFG->prefix}question_states", false);
-    }
-
-    if ($success && $oldversion < 2006022800) {
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_answers RENAME {$CFG->prefix}question_answers", false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_categories RENAME {$CFG->prefix}question_categories", false);
-    }
-
-    if ($success && $oldversion < 2006031202) {
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_truefalse RENAME {$CFG->prefix}question_truefalse", false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_shortanswer RENAME {$CFG->prefix}question_shortanswer", false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_multianswers RENAME {$CFG->prefix}question_multianswer", false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_multichoice RENAME {$CFG->prefix}question_multichoice", false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_numerical RENAME {$CFG->prefix}question_numerical", false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_numerical_units RENAME {$CFG->prefix}question_numerical_units", false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_randomsamatch RENAME {$CFG->prefix}question_randomsamatch", false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_match RENAME {$CFG->prefix}question_match", false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_match_sub RENAME {$CFG->prefix}question_match_sub", false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_calculated RENAME {$CFG->prefix}question_calculated", false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_dataset_definitions RENAME {$CFG->prefix}question_dataset_definitions", false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_dataset_items RENAME {$CFG->prefix}question_dataset_items", false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_question_datasets RENAME {$CFG->prefix}question_datasets", false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_rqp RENAME {$CFG->prefix}question_rqp", false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_rqp_servers RENAME {$CFG->prefix}question_rqp_servers", false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_rqp_states RENAME {$CFG->prefix}question_rqp_states", false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_rqp_types RENAME {$CFG->prefix}question_rqp_types", false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_essay RENAME {$CFG->prefix}question_essay", false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_essay_states RENAME {$CFG->prefix}question_essay_states", false);
-    }
-
-    if ($success && $oldversion < 2006032100) {
-        // change from the old questiontype numbers to using the questiontype names
-        $success = $success && table_column('question', 'qtype', 'qtype',  'varchar', 20, '', '', 'not null');
-        $success = $success && set_field('question', 'qtype', 'shortanswer', 'qtype', 1);
-        $success = $success && set_field('question', 'qtype', 'truefalse', 'qtype', 2);
-        $success = $success && set_field('question', 'qtype', 'multichoice', 'qtype', 3);
-        $success = $success && set_field('question', 'qtype', 'random', 'qtype', 4);
-        $success = $success && set_field('question', 'qtype', 'match', 'qtype', 5);
-        $success = $success && set_field('question', 'qtype', 'randomsamatch', 'qtype', 6);
-        $success = $success && set_field('question', 'qtype', 'description', 'qtype', 7);
-        $success = $success && set_field('question', 'qtype', 'numerical', 'qtype', 8);
-        $success = $success && set_field('question', 'qtype', 'multianswer', 'qtype', 9);
-        $success = $success && set_field('question', 'qtype', 'calculated', 'qtype', 10);
-        $success = $success && set_field('question', 'qtype', 'rqp', 'qtype', 11);
-        $success = $success && set_field('question', 'qtype', 'essay', 'qtype', 12);
-    }
-
-    if ($success && $oldversion < 2006032200) {
-        // set version for all questiontypes that already have their tables installed
-        $success = $success && set_config('qtype_calculated_version', 2006032100);
-        $success = $success && set_config('qtype_essay_version', 2006032100);
-        $success = $success && set_config('qtype_match_version', 2006032100);
-        $success = $success && set_config('qtype_multianswer_version', 2006032100);
-        $success = $success && set_config('qtype_multichoice_version', 2006032100);
-        $success = $success && set_config('qtype_numerical_version', 2006032100);
-        $success = $success && set_config('qtype_randomsamatch_version', 2006032100);
-        $success = $success && set_config('qtype_rqp_version', 2006032100);
-        $success = $success && set_config('qtype_shortanswer_version', 2006032100);
-        $success = $success && set_config('qtype_truefalse_version', 2006032100);
-    }
-
-    if ($success && $oldversion < 2006040600) {
-        $success = $success && table_column('question_sessions', '', 'comment', 'text', '', '', '', 'not null', 'sumpenalty');
-    }
-
-    if ($success && $oldversion < 2006040900) {
-        $success = $success && modify_database('', "UPDATE prefix_question SET parent = id WHERE qtype ='random';");
-    }
-
-    if ($success && $oldversion < 2006041000) {
-        $success = $success && modify_database('', " INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('quiz', 'continue attempt', 'quiz', 'name');");
-    }
-
-    if ($success && $oldversion < 2006041001) {
-        $success = $success && table_column('question', 'version', 'version', 'varchar', 255);
-    }
-
-    if ($success && $oldversion < 2006042800) {
-        // Check we have some un-renamed tables (verified in some servers)
-        if ($tables = $db->MetaTables('TABLES')) {
-            if (in_array($CFG->prefix.'quiz_randommatch', $tables) &&
-                !in_array($CFG->prefix.'question_randomsamatch', $tables)) {
-                $success = $success && modify_database ("", "ALTER TABLE prefix_quiz_randommatch RENAME prefix_question_randomsamatch ");
-            }
-            // Check for one possible missing field in one table
-            if ($columns = $db->MetaColumnNames($CFG->prefix.'question_randomsamatch')) {
-                if (!in_array('shuffleanswers', $columns)) {
-                    $success = $success && table_column('question_randomsamatch', '', 'shuffleanswers', 'tinyint', '4', 'unsigned', '1', 'not null', 'choose');
-                }
-            }
-        }
-    }
-
-    if ($oldversion < 2006051300) {
-        // The newgraded field must always point to a valid state
-        $success = $success && modify_database("","UPDATE prefix_question_sessions SET newgraded = newest where newgraded = '0'");
-
-        // Only perform this if hasn't been performed before (in MOODLE_16_STABLE branch - bug 5717)
-        $tables = $db->MetaTables('TABLES');
-        if (!in_array($CFG->prefix . 'question_attempts', $tables)) {
-            // The following table is discussed in bug 5468
-            $success = $success && modify_database ("", "CREATE TABLE prefix_question_attempts (
-                                      id int(10) unsigned NOT NULL auto_increment,
-                                      modulename varchar(20) NOT NULL default 'quiz',
-                                      PRIMARY KEY  (id)
-                                    ) TYPE=MyISAM COMMENT='Student attempts. This table gets extended by the modules';");
-            // create one entry for all the existing quiz attempts
-            $success = $success && modify_database ("", "INSERT INTO prefix_question_attempts (id)
-                                       SELECT uniqueid
-                                       FROM prefix_quiz_attempts;");
-        }
-    }
-
-    if ($success && $oldversion < 2006060700) { // fix for 5720
-
-        // Copy the teacher comments from the question_essay_states table to the new
-        // question_sessions table.
-
-        // Get the attempt unique ID, teacher comment, graded flag, state ID, and question ID
-        // based on the quesiont_essay_states
-        if ($results = get_records_sql("SELECT a.uniqueid, es.response AS essaycomment, es.graded AS isgraded, 
-                                               qs.id AS stateid, qs.question AS questionid 
-                                        FROM {$CFG->prefix}question_states as qs,
-                                             {$CFG->prefix}question_essay_states es, 
-                                             {$CFG->prefix}quiz_attempts a 
-                                        WHERE es.stateid = qs.id AND a.uniqueid = qs.attempt")) {
-            foreach ($results as $result) {
-                // Create a state object to be used for updating
-                $state = new stdClass;
-                $state->id = $result->stateid;
-
-                if ($result->isgraded) {
-                    // Graded - save comment to the sessions and change state event to QUESTION_EVENTMANUALGRADE
-                    if (!($success = $success && set_field('question_sessions', 'comment', $result->essaycomment, 'attemptid', $result->uniqueid, 'questionid', $result->questionid))) {
-                        notify("Essay Table Migration: Cannot save comment");
-                        break;
-                    }
-                    $state->event = 9; //QUESTION_EVENTMANUALGRADE;
-                } else {
-                    // Not graded
-                    $state->event = 7; //QUESTION_EVENTSUBMIT;
-                }
-
-                // Save the event
-                if (!($success = $success && update_record('question_states', $state))) {
-                    notify("Essay Table Migration: Cannot update state");
-                    break;
-                }
-            }
-        }
-        
-        // dropping unused tables
-        $success = $success && execute_sql('DROP TABLE '.$CFG->prefix.'question_essay_states');
-        $success = $success && execute_sql('DROP TABLE '.$CFG->prefix.'question_essay');
-        $success = $success && execute_sql('DROP TABLE '.$CFG->prefix.'quiz_attemptonlast_datasets', false);
-    }
-
-    if ($oldversion < 2006081000) {
-        // Add a column to the the question table to store the question general feedback.
-        $success = $success && table_column('question', '', 'commentarytext', 'text', '', '', '', 'not null', 'image');
-
-        // Adjust the quiz review options so that general feedback is displayed whenever feedback is.
-        $success = $success && execute_sql('UPDATE ' . $CFG->prefix . 'quiz SET review = ' .
-                '(review & ~' . QUIZ_REVIEW_GENERALFEEDBACK . ') | ' . // Clear any existing junk from the commenary bits.
-                '((review & ' . QUIZ_REVIEW_FEEDBACK . ') * 8)'); // Set the general feedback bits to be the same as the feedback ones.
-
-        // Same adjustment to the defaults for new quizzes.
-        $success = $success && set_config('quiz_review', ($CFG->quiz_review & ~QUIZ_REVIEW_GENERALFEEDBACK) |
-                (($CFG->quiz_review & QUIZ_REVIEW_FEEDBACK) << 3));
-    }
-    
-    if ($success && $oldversion < 2006081400) {
-        $success = $success && modify_database('', "
-            CREATE TABLE prefix_quiz_feedback (
-                id int(10) unsigned NOT NULL auto_increment,
-                quizid int(10) unsigned NOT NULL default '0',
-                feedbacktext text NOT NULL default '',
-                mingrade double NOT NULL default '0',
-                maxgrade double NOT NULL default '0',
-                PRIMARY KEY (id),
-                KEY quizid (quizid)
-            ) TYPE=MyISAM COMMENT='Feedback given to students based on their overall score on the test';
-        ");
-    
-        $success = $success && execute_sql("
-            INSERT INTO {$CFG->prefix}quiz_feedback (quizid, feedbacktext, maxgrade, mingrade)
-            SELECT id, '', grade + 1, 0 FROM {$CFG->prefix}quiz;
-        ");
-    }
-
-    if ($success && $oldversion < 2006082400) {
-        $success = $success && table_column('question_sessions', 'comment', 'manualcomment', 'text', '', '', '');
-    }
-
-    if ($success && $oldversion < 2006091900) {
-        $success = $success && table_column('question_dataset_items', 'number', 'itemnumber', 'integer');
-    }
-
-    if ($success && $oldversion < 2006091901) {
-        $success = $success && table_column('question', 'commentarytext', 'generalfeedback', 'text', '', '', '');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return $success;
-}
-
-?>
diff --git a/mod/quiz/db/postgres7.php b/mod/quiz/db/postgres7.php
deleted file mode 100644 (file)
index 8e9ead5..0000000
+++ /dev/null
@@ -1,1497 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function quiz_upgrade($oldversion) {
-// This function does anything necessary to upgrade
-// older versions to match current functionality
-
-    global $CFG, $db;
-    $success = true;
-
-    include_once("$CFG->dirroot/mod/quiz/locallib.php");
-
-    if ($success && $oldversion < 2003010100) {
-        $success = $success && execute_sql(" ALTER TABLE {$CFG->prefix}quiz ADD review integer DEFAULT '0' NOT NULL AFTER `grademethod` ");
-    }
-
-    if ($success && $oldversion < 2003010301) {
-        $success = $success && table_column("quiz_truefalse", "true", "trueanswer", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "");
-        $success = $success && table_column("quiz_truefalse", "false", "falseanswer", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "");
-        $success = $success && table_column("quiz_questions", "type", "qtype", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "");
-    }
-
-    if ($success && $oldversion < 2003022303) {
-        $success = $success && modify_database ("", "CREATE TABLE prefix_quiz_randommatch (
-                                  id SERIAL PRIMARY KEY,
-                                  question integer NOT NULL default '0',
-                                  choose integer NOT NULL default '4'
-                              );");
-    }
-    if ($success && $oldversion < 2003030303) {
-        $success = $success && table_column("quiz_questions", "", "defaultgrade", "INTEGER", "6", "UNSIGNED", "1", "NOT NULL", "image");
-    }
-
-    if ($success && $oldversion < 2003033100) {
-        $success = $success && modify_database ("", "ALTER TABLE prefix_quiz_randommatch RENAME prefix_quiz_randomsamatch ");
-        $success = $success && modify_database ("", "CREATE TABLE prefix_quiz_match_sub (
-                                 id SERIAL PRIMARY KEY,
-                                 question integer NOT NULL default '0',
-                                 questiontext text NOT NULL default '',
-                                 answertext varchar(255) NOT NULL default ''
-                              );");
-        $success = $success && modify_database ("", "CREATE INDEX prefix_quiz_match_sub_question_idx ON prefix_quiz_match_sub (question);");
-
-        $success = $success && modify_database ("", "CREATE TABLE prefix_quiz_multichoice (
-                                 id SERIAL PRIMARY KEY,
-                                 question integer NOT NULL default '0',
-                                 layout integer NOT NULL default '0',
-                                 answers varchar(255) NOT NULL default '',
-                                 single integer NOT NULL default '0'
-                               );");
-        $success = $success && modify_database ("", "CREATE INDEX prefix_quiz_multichoice_question_idx ON prefix_quiz_multichoice (question);");
-    }
-
-    if ($success && $oldversion < 2003040901) {
-        $success = $success && table_column("quiz", "", "shufflequestions", "INTEGER", "5", "UNSIGNED", "0", "NOT NULL", "review");
-        $success = $success && table_column("quiz", "", "shuffleanswers", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "shufflequestions");
-    }
-    if ($success && $oldversion < 2003042702) {
-        $success = $success && modify_database ("", "CREATE TABLE prefix_quiz_match (
-                                 id SERIAL PRIMARY KEY,
-                                 question integer NOT NULL default '0',
-                                 subquestions varchar(255) NOT NULL default ''
-                               );");
-        $success = $success && modify_database ("", "CREATE INDEX prefix_quiz_match_question_idx ON prefix_quiz_match (question);");
-    }
-    if ($success && $oldversion < 2003071001) {
-        $success = $success && modify_database ("", " CREATE TABLE prefix_quiz_numerical (
-                               id SERIAL PRIMARY KEY,
-                               question integer NOT NULL default '0',
-                               answer integer NOT NULL default '0',
-                               min varchar(255) NOT NULL default '',
-                               max varchar(255) NOT NULL default ''
-                               ); ");
-        $success = $success && modify_database ("", "CREATE INDEX prefix_quiz_numerical_answer_idx ON prefix_quiz_numerical (answer);");
-    }
-
-    if ($success && $oldversion < 2003072400) {
-        $success = $success && execute_sql(" INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('quiz', 'review', 'quiz', 'name') ");
-    }
-
-    if ($success && $oldversion < 2003082300) {
-        $success = $success && modify_database ("", " CREATE TABLE prefix_quiz_multianswers (
-                               id SERIAL PRIMARY KEY,
-                               question integer NOT NULL default '0',
-                               answers varchar(255) NOT NULL default '',
-                               positionkey varchar(255) NOT NULL default '',
-                               answertype integer NOT NULL default '0',
-                               norm integer NOT NULL default '1'
-                              ); ");
-        $success = $success && modify_database ("", "CREATE INDEX prefix_quiz_multianswers_question_idx ON prefix_quiz_multianswers (question);");
-
-        $success = $success && table_column("quiz", "", "attemptonlast", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "attempts");
-
-        $success = $success && table_column("quiz_questions", "", "stamp", "varchar", "255", "", "qtype");
-    }
-
-    if ($success && $oldversion < 2003082301) {
-        $success = $success && table_column("quiz_questions", "", "version", "integer", "10", "", "1", "not null", "stamp");
-        if ($questions = get_records("quiz_questions")) {
-            foreach ($questions as $question) {
-                $stamp = make_unique_id_code();
-                if (!($success = $success && set_field("quiz_questions", "stamp", $stamp, "id", $question->id))) {
-                    notify("Error while adding stamp to question id = $question->id");
-                    break;
-                }
-            }
-        }
-    }
-
-    if ($success && $oldversion < 2003082700) {
-        table_column("quiz_categories", "", "stamp", "varchar", "255", "", "", "not null");
-        if ($categories = get_records("quiz_categories")) {
-            foreach ($categories as $category) {
-                $stamp = make_unique_id_code();
-                if (!($success = $success && set_field("quiz_categories", "stamp", $stamp, "id", $category->id))) {
-                    notify("Error while adding stamp to category id = $category->id");
-                    break;
-                }
-            }
-        }
-    }
-
-    if ($success && $oldversion < 2003111100) {
-        $duplicates = get_records_sql("SELECT stamp as id,count(*) as cuenta
-                                       FROM {$CFG->prefix}quiz_questions
-                                       GROUP BY stamp
-                                       HAVING count(*)>1");
-
-        if ($duplicates) {
-            notify("You have some quiz questions with duplicate stamps IDs.  Cleaning these up.");
-            foreach ($duplicates as $duplicate) {
-                $questions = get_records("quiz_questions","stamp",$duplicate->id);
-                $add = 1;
-                foreach ($questions as $question) {
-                    echo "Changing question id $question->id stamp to ".$duplicate->id.$add."<br />";
-                    $success = $success && set_field("quiz_questions","stamp",$duplicate->id.$add,"id",$question->id);
-                    $add++;
-                }
-            }
-        } else {
-            notify("Checked your quiz questions for stamp duplication errors, but no problems were found.", "green");
-        }
-    }
-
-    if ($success && $oldversion < 2004021300) {
-        $success = $success && table_column("quiz_questions", "", "questiontextformat", "integer", "2", "", "0", "not null", "questiontext");
-    }
-
-    if ($success && $oldversion < 2004021900) {
-        $success = $success && modify_database("","INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('quiz', 'add', 'quiz', 'name');");
-        $success = $success && modify_database("","INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('quiz', 'update', 'quiz', 'name');");
-    }
-
-    if ($success && $oldversion < 2004051700) {
-        include_once("$CFG->dirroot/mod/quiz/lib.php");
-        $success = $success && quiz_refresh_events();
-    }
-    if ($success && $oldversion < 2004060200) {
-        $success = $success && table_column("quiz", "", "timelimit", "integer", "", "", "0", "NOT NULL", "");
-    }
-
-    if ($success && $oldversion < 2004070700) {
-        $success = $success && table_column("quiz", "", "password", "varchar", "255", "", "", "not null", "");
-        $success = $success && table_column("quiz", "", "subnet", "varchar", "255", "", "", "not null", "");
-    }
-
-    if ($success && $oldversion < 2004073001) {
-        // Six new tables:
-
-
-        $success = $success && modify_database ( "", "BEGIN;");
-
-        // One table for handling units for numerical questions
-        $success = $success && modify_database ("", " CREATE TABLE prefix_quiz_numerical_units (
-                               id SERIAL8 PRIMARY KEY,
-                               question INT8  NOT NULL default '0',
-                               multiplier decimal(40,20) NOT NULL default '1.00000000000000000000',
-                               unit varchar(50) NOT NULL default ''
-                );" );
-
-
-        // Four tables for handling distribution and storage of
-        // individual data for dataset dependent question types
-        $success = $success && modify_database ("", " CREATE TABLE prefix_quiz_attemptonlast_datasets (
-                               id SERIAL8 PRIMARY KEY,
-                               category INT8  NOT NULL default '0',
-                               userid INT8  NOT NULL default '0',
-                               datasetnumber INT8  NOT NULL default '0',
-                               CONSTRAINT prefix_quiz_attemptonlast_datasets_category_userid UNIQUE (category,userid)
-            ) ;");
-
-        $success = $success && modify_database ("", " CREATE TABLE prefix_quiz_dataset_definitions (
-                               id SERIAL8 PRIMARY KEY,
-                               category INT8  NOT NULL default '0',
-                               name varchar(255) NOT NULL default '',
-                               type INT8 NOT NULL default '0',
-                               options varchar(255) NOT NULL default '',
-                               itemcount INT8  NOT NULL default '0'
-            ) ; ");
-
-        $success = $success && modify_database ("", " CREATE TABLE prefix_quiz_dataset_items (
-                               id SERIAL8 PRIMARY KEY,
-                               definition INT8  NOT NULL default '0',
-                               number INT8  NOT NULL default '0',
-                               value varchar(255) NOT NULL default ''
-                             ) ; ");
-
-        $success = $success && modify_database ("", "CREATE INDEX prefix_quiz_dataset_items_definition_idx ON prefix_quiz_dataset_items (definition);");
-
-        $success = $success && modify_database ("", " CREATE TABLE prefix_quiz_question_datasets (
-                               id SERIAL8 PRIMARY KEY,
-                               question INT8  NOT NULL default '0',
-                               datasetdefinition INT8  NOT NULL default '0'
-            ) ; ");
-
-        $success = $success && modify_database ("", "CREATE INDEX prefix_quiz_question_datasets_question_datasetdefinition_idx ON prefix_quiz_question_datasets (question,datasetdefinition);");
-
-        // One table for new question type calculated
-        //  - the first dataset dependent question type
-        $success = $success && modify_database ("", " CREATE TABLE prefix_quiz_calculated (
-                               id SERIAL8 PRIMARY KEY,
-                               question INT8  NOT NULL default '0',
-                               answer INT8  NOT NULL default '0',
-                               tolerance varchar(20) NOT NULL default '0.0',
-                               tolerancetype INT8 NOT NULL default '1',
-                               correctanswerlength INT8 NOT NULL default '2'
-                ) ; ");
-
-        $success = $success && modify_database ("", "CREATE INDEX prefix_quiz_calculated_question_idx ON  prefix_quiz_calculated (question);");
-
-        $success = $success && modify_database ( "", "COMMIT;");
-    }
-
-    if ($success && $oldversion < 2004111400) {
-        $success = $success && table_column("quiz_responses", "answer", "answer", "text", "", "", "", "not null");
-    }
-
-    if ($success && $oldversion < 2004111700) {
-        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_course_idx;",false);
-        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_answers_question_idx;",false);
-        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_attempts_quiz_idx;",false);
-        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_attempts_userid_idx;",false);
-        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_calculated_answer_idx;",false);
-        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_categories_course_idx;",false);
-        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_dataset_definitions_category_idx;",false);
-        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_grades_quiz_idx;",false);
-        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_grades_userid_idx;",false);
-        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_numerical_question_idx;",false);
-        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_numerical_units_question_idx;",false);
-        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_question_grades_quiz_idx;",false);
-        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_question_grades_question_idx;",false);
-        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_questions_category_idx;",false);
-        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_randomsamatch_question_idx;",false);
-        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_responses_attempt_idx;",false);
-        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_responses_question_idx;",false);
-
-        $success = $success && modify_database('','CREATE INDEX prefix_quiz_course_idx ON prefix_quiz (course);');
-        $success = $success && modify_database('','CREATE INDEX prefix_quiz_answers_question_idx ON prefix_quiz_answers (question);');
-        $success = $success && modify_database('','CREATE INDEX prefix_quiz_attempts_quiz_idx ON prefix_quiz_attempts (quiz);');
-        $success = $success && modify_database('','CREATE INDEX prefix_quiz_attempts_userid_idx ON prefix_quiz_attempts (userid);');
-        $success = $success && modify_database('','CREATE INDEX prefix_quiz_calculated_answer_idx ON prefix_quiz_calculated (answer);');
-        $success = $success && modify_database('','CREATE INDEX prefix_quiz_categories_course_idx ON prefix_quiz_categories (course);');
-        $success = $success && modify_database('','CREATE INDEX prefix_quiz_dataset_definitions_category_idx ON prefix_quiz_dataset_definitions (category);');
-        $success = $success && modify_database('','CREATE INDEX prefix_quiz_grades_quiz_idx ON prefix_quiz_grades (quiz);');
-        $success = $success && modify_database('','CREATE INDEX prefix_quiz_grades_userid_idx ON prefix_quiz_grades (userid);');
-        $success = $success && modify_database('','CREATE INDEX prefix_quiz_numerical_question_idx ON prefix_quiz_numerical (question);');
-        $success = $success && modify_database('','CREATE INDEX prefix_quiz_numerical_units_question_idx ON prefix_quiz_numerical_units (question);');
-        $success = $success && modify_database('','CREATE INDEX prefix_quiz_question_grades_quiz_idx ON prefix_quiz_question_grades (quiz);');
-        $success = $success && modify_database('','CREATE INDEX prefix_quiz_question_grades_question_idx ON prefix_quiz_question_grades (question);');
-        $success = $success && modify_database('','CREATE INDEX prefix_quiz_questions_category_idx ON prefix_quiz_questions (category);');
-        $success = $success && modify_database('','CREATE INDEX prefix_quiz_randomsamatch_question_idx ON prefix_quiz_randomsamatch (question);');
-        $success = $success && modify_database('','CREATE INDEX prefix_quiz_responses_attempt_idx ON prefix_quiz_responses (attempt);');
-        $success = $success && modify_database('','CREATE INDEX prefix_quiz_responses_question_idx ON prefix_quiz_responses (question);');
-    }
-
-    if ($success && $oldversion < 2004112300) { //try and clean up an old mistake - try and bring us up to what is in postgres7.sql today.
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_attemptonlast_datasets DROP CONSTRAINT category;",false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_attemptonlast_datasets DROP CONSTRAINT {$CFG->prefix}quiz_attemptonlast_datasets_category_userid;",false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_attemptonlast_datasets DROP CONSTRAINT {$CFG->prefix}quiz_category_userid_unique;",false);
-        $success = $success && modify_database('','ALTER TABLE prefix_quiz_attemptonlast_datasets ADD CONSTRAINT prefix_quiz_category_userid_unique UNIQUE (category,userid);');
-    }
-
-    if ($success && $oldversion < 2004120501) {
-        $success = $success && table_column("quiz_calculated", "", "correctanswerformat", "integer", "10", "", "0", "not null", "correctanswerlength");
-    }
-
-    if ($success && $oldversion < 2004121400) {  // New field to determine popup window behaviour
-        $success = $success && table_column("quiz", "", "popup", "integer", "4", "", "0", "not null", "subnet");
-    }
-
-    if ($success && $oldversion < 2005010201) {
-        $success = $success && table_column('quiz_categories', '', 'parent');
-        $success = $success && table_column('quiz_categories', '', 'sortorder', 'integer', '10', '', '999');
-    }
-
-    if ($success && $oldversion < 2005010300) {
-        $success = $success && table_column("quiz", "", "questionsperpage", "integer", "10", "", "0", "not null", "review");
-    }
-
-    if ($success && $oldversion < 2005012700) {
-        $success = $success && table_column('quiz_grades', 'grade', 'grade', 'real', 2, '');
-    }
-
-    if ($success && $oldversion < 2005021400) {
-        $success = $success && table_column("quiz", "", "decimalpoints", "integer", "4", "", "2", "not null", "grademethod");
-    }
-
-    if($success && $oldversion < 2005022800) {
-        $success = $success && table_column('quiz_questions', '', 'hidden', 'integer', '1', 'unsigned', '0', 'not null', 'version');
-        $success = $success && table_column('quiz_responses', '', 'originalquestion', 'integer', '10', 'unsigned', '0', 'not null', 'question');
-        $success = $success && modify_database ('', "CREATE TABLE prefix_quiz_question_version (
-                              id SERIAL PRIMARY KEY,
-                              quiz integer NOT NULL default '0',
-                              oldquestion integer NOT NULL default '0',
-                              newquestion integer NOT NULL default '0',
-                              userid integer NOT NULL default '0',
-                              timestamp integer NOT NULL default '0');");
-    }
-
-    if ($success && $oldversion < 2005032000) {
-        $success = $success && execute_sql(" INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('quiz', 'editquestions', 'quiz', 'name') ");
-    }
-
-    if ($success && $oldversion < 2005032300) {
-        $success = $success && modify_database ('', 'ALTER TABLE prefix_quiz_question_version RENAME TO prefix_quiz_question_versions;');
-    }
-
-    if ($success && $oldversion < 2005041200) { // replace wiki-like with markdown
-        include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
-        $wtm = new WikiToMarkdown();
-        $sql = "select course from {$CFG->prefix}quiz_categories, {$CFG->prefix}quiz_questions ";
-        $sql .= "where {$CFG->prefix}quiz_category.id = {$CFG->prefix}quiz_questions.category ";
-        $sql .= "and {$CFG->prefix}quiz_questions.id = ";
-        $wtm->update( 'quiz_questions', 'questiontext', 'questiontextformat', $sql );
-    }
-
-    if ($success && $oldversion < 2005041300) {
-        $success = $success && modify_database('', "UPDATE prefix_quiz_questions SET hidden = '1' WHERE qtype ='".RANDOM."';");
-    }
-
-    if ($success && $oldversion < 2005042002) {
-        $success = $success && table_column('quiz_answers', 'answer', 'answer', 'text', '', '', '', 'not null', '');
-    }
-
-
-    if ($success && $oldversion < 2005042400) {
-        begin_sql();
-
-        // Changes to quiz table
-
-        // The bits of the optionflags field will hold various option flags
-        $success = $success && table_column('quiz', '', 'optionflags', 'integer', '10', 'unsigned', '0', 'not null', 'timeclose');
-
-        // The penalty scheme
-        $success = $success && table_column('quiz', '', 'penaltyscheme', 'integer', '4', 'unsigned', '0', 'not null', 'optionflags');
-
-        // The review options are now all stored in the bits of the review field
-        $success = $success && table_column('quiz', 'review', 'review', 'integer', 10, 'unsigned', 0, 'not null', '');
-
-        /// Changes to quiz_attempts table
-
-        // The preview flag marks teacher previews
-        $success = $success && table_column('quiz_attempts', '', 'preview', 'tinyint', '2', 'unsigned', '0', 'not null', 'timemodified');
-
-        // The layout is the list of questions with inserted page breaks.
-        $success = $success && table_column('quiz_attempts', '', 'layout', 'text', '', '', '', 'not null', 'timemodified');
-        // For old quiz attempts we will set this to the repaginated question list from $quiz->questions
-
-        /// The following updates of field values require a loop through all quizzes
-        // This is because earlier versions of mysql don't allow joins in UPDATE
-        if ($quizzes = get_records('quiz')) {
-
-            // turn reporting off temporarily to avoid one line output per set_field
-            $olddebug = $db->debug;
-            $db->debug = false;
-            foreach ($quizzes as $quiz) {
-
-                // repaginate
-                $quiz->questions = ($quiz->questionsperpage) ? quiz_repaginate($quiz->questions, $quiz->questionsperpage) : $quiz->questions;
-                if ($quiz->questionsperpage) {
-                    $quiz->questions = quiz_repaginate($quiz->questions, $quiz->questionsperpage);
-                    $success = $success && set_field('quiz', 'questions', $quiz->questions, 'id', $quiz->id);
-                }
-                set_field('quiz_attempts', 'layout', $quiz->questions, 'quiz', $quiz->id);
-
-                // set preview flag
-                if ($teachers = get_course_teachers($quiz->course)) {
-                    $teacherids = implode(',', array_keys($teachers));
-                    $success = $success && execute_sql("UPDATE {$CFG->prefix}quiz_attempts SET preview = 1 WHERE userid IN ($teacherids)");
-                }
-
-                // set review flags in quiz table
-                $review = (QUIZ_REVIEW_IMMEDIATELY & (QUIZ_REVIEW_RESPONSES + QUIZ_REVIEW_SCORES));
-                if ($quiz->feedback) {
-                    $review += (QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_FEEDBACK);
-                }
-                if ($quiz->correctanswers) {
-                    $review += (QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_ANSWERS);
-                }
-                if ($quiz->review & 1) {
-                    $review += QUIZ_REVIEW_CLOSED;
-                }
-                if ($quiz->review & 2) {
-                    $review += QUIZ_REVIEW_OPEN;
-                }
-                $success = $success && set_field('quiz', 'review', $review, 'id', $quiz->id);
-            }
-            $db->debug = $olddebug;
-        }
-
-        // We can now drop the fields whose data has been moved to the review field
-        $success = $success && execute_sql(" ALTER TABLE {$CFG->prefix}quiz DROP COLUMN feedback");
-        $success = $success && execute_sql(" ALTER TABLE {$CFG->prefix}quiz DROP COLUMN correctanswers");
-
-        /// Renaming tables
-
-        // rename the quiz_question_grades table to quiz_question_instances
-        $success = $success && modify_database ('', 'ALTER TABLE prefix_quiz_question_grades RENAME TO prefix_quiz_question_instances;');
-        $success = $success && modify_database ('', 'ALTER TABLE prefix_quiz_question_grades_id_seq RENAME TO prefix_quiz_question_instances_id_seq;');
-        $success = $success && modify_database ('', 'ALTER TABLE prefix_quiz_question_instances ALTER COLUMN id SET DEFAULT nextval(\'prefix_quiz_question_instances_id_seq\');');
-        $success = $success && modify_database ('', 'DROP INDEX prefix_quiz_question_grades_quiz_idx');
-        $success = $success && modify_database ('', 'DROP INDEX prefix_quiz_question_grades_question_idx;');
-        $success = $success && modify_database ('', 'CREATE INDEX prefix_quiz_question_instances_quiz_idx ON prefix_quiz_question_instances (quiz);');
-        $success = $success && modify_database ('', 'CREATE INDEX prefix_quiz_question_instances_question_idx ON prefix_quiz_question_instances (question);');
-
-        // rename the quiz_responses table quiz_states
-        $success = $success && modify_database ('', 'ALTER TABLE prefix_quiz_responses RENAME TO prefix_quiz_states;');
-        $success = $success && modify_database ('', 'ALTER TABLE prefix_quiz_responses_id_seq RENAME TO prefix_quiz_states_id_seq;');
-        $success = $success && modify_database ('', 'ALTER TABLE prefix_quiz_states ALTER COLUMN id SET DEFAULT nextval(\'prefix_quiz_states_id_seq\');');
-        $success = $success && modify_database ('', 'DROP INDEX prefix_quiz_responses_attempt_idx;');
-        $success = $success && modify_database ('', 'DROP INDEX prefix_quiz_responses_question_idx;');
-        $success = $success && modify_database ('', 'CREATE INDEX prefix_quiz_states_attempt_idx ON prefix_quiz_states (attempt);');
-        $success = $success && modify_database ('', 'CREATE INDEX prefix_quiz_states_question_idx ON prefix_quiz_states (question);');
-
-
-        /// add columns to quiz_states table
-
-        // The sequence number of the state.
-        $success = $success && table_column('quiz_states', '', 'seq_number', 'integer', '6', 'unsigned', '0', 'not null', 'originalquestion');
-        // For existing states we leave this at 0 because in the old quiz code there was only one response allowed
-
-        // The time the state was created.
-        $success = $success && table_column('quiz_states', '', 'timestamp', 'integer', '10', 'unsigned', '0', 'not null', 'answer');
-        // For existing states we will below set this to the timemodified field of the attempt
-
-        // The type of event that led to the creation of the state
-        $success = $success && table_column('quiz_states', '', 'event', 'integer', '4', 'unsigned', '0', 'not null', 'timestamp');
-
-        // The raw grade
-        $success = $success && table_column('quiz_states', '', 'raw_grade', 'varchar', '10', '', '', 'not null', 'grade');
-        // For existing states (no penalties) this is equal to the grade
-        $success = $success && execute_sql("UPDATE {$CFG->prefix}quiz_states SET raw_grade = grade");
-
-        // The penalty that the response attracted
-        $success = $success && table_column('quiz_states', '', 'penalty', 'varchar', '10', '', '0.0', 'not null', 'raw_grade');
-        // For existing states this can stay at 0 because penalties did not exist previously.
-
-        /// New table for pointers to newest and newest graded states
-
-        $success = $success && modify_database('', "CREATE TABLE prefix_quiz_newest_states (
-                               id SERIAL PRIMARY KEY,
-                               attemptid integer NOT NULL default '0',
-                               questionid integer NOT NULL default '0',
-                               newest integer NOT NULL default '0',
-                               newgraded integer NOT NULL default '0',
-                               sumpenalty varchar(10) NOT NULL default '0.0'
-                             );");
-        $success = $success && modify_database('CREATE UNIQUE INDEX prefix_quiz_newest_states_attempt_idx ON prefix_quiz_newest_states (attemptid,questionid);');
-
-        /// Now upgrade some fields in states and newest_states tables where necessary
-        // to save time on large sites only do this for attempts that have not yet been finished.
-        if ($attempts = get_records_select('quiz_attempts', 'timefinish = 0')) {
-            // turn reporting off temporarily to avoid one line output per set_field
-            $olddebug = $db->debug;
-            $db->debug = false;
-            foreach ($attempts as $attempt) {
-                quiz_upgrade_states($attempt);
-            }
-            $db->debug = $olddebug;
-        }
-
-        /// Entries for the log_display table
-
-        $success = $success && modify_database('', " INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('quiz', 'preview', 'quiz', 'name');");
-        $success = $success && modify_database('', " INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('quiz', 'start attempt', 'quiz', 'name');");
-        $success = $success && modify_database('', " INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('quiz', 'close attempt', 'quiz', 'name');");
-
-        /// update the default settings in $CFG
-        $review = (QUIZ_REVIEW_IMMEDIATELY & (QUIZ_REVIEW_RESPONSES + QUIZ_REVIEW_SCORES));
-        if (!empty($CFG->quiz_feedback)) {
-            $review += (QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_FEEDBACK);
-        }
-        if (!empty($CFG->quiz_correctanswers)) {
-            $review += (QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_ANSWERS);
-        }
-        if (isset($CFG->quiz_review) and ($CFG->quiz_review & 1)) {
-            $review += QUIZ_REVIEW_CLOSED;
-        }
-        if (isset($CFG->quiz_review) and ($CFG->quiz_review & 2)) {
-            $review += QUIZ_REVIEW_OPEN;
-        }
-        $success = $success && set_config('quiz_review', $review);
-
-        /// Use tolerance instead of min and max in numerical question type
-        $success = $success && table_column('quiz_numerical', '', 'tolerance', 'varchar', '255', '', '0.0', 'not null', 'question');
-        $success = $success && execute_sql("UPDATE {$CFG->prefix}quiz_numerical SET tolerance = (max::text::real-min::text::real)/2");
-        $success = $success && modify_database('', 'ALTER TABLE prefix_quiz_numerical DROP COLUMN min'); // Replaced by tolerance
-        $success = $success && modify_database('', 'ALTER TABLE prefix_quiz_numerical DROP COLUMN max'); // Replaced by tolerance
-
-        /// Tables for Remote Questions
-        $success = $success && modify_database ('', "CREATE TABLE prefix_quiz_rqp (
-                                 id SERIAL PRIMARY KEY,
-                                 question integer NOT NULL default '0',
-                                 type integer NOT NULL default '0',
-                                 source text NOT NULL,
-                                 format varchar(255) NOT NULL default '',
-                                 flags integer NOT NULL default '0',
-                                 maxscore integer NOT NULL default '1'
-                               );");
-
-        $success = $success && modify_database ('', "CREATE INDEX prefix_quiz_rqp_question_idx ON prefix_quiz_rqp (question);");
-
-        $success = $success && modify_database ('', "CREATE TABLE prefix_quiz_rqp_states (
-                                 id SERIAL PRIMARY KEY,
-                                 stateid integer NOT NULL default '0',
-                                 responses text NOT NULL,
-                                 persistent_data text NOT NULL,
-                                 template_vars text NOT NULL
-                               );");
-
-        $success = $success && modify_database ('', "CREATE TABLE prefix_quiz_rqp_types (
-                                id SERIAL PRIMARY KEY,
-                                name varchar(255) NOT NULL default '',
-                                rendering_server varchar(255) NOT NULL default '',
-                                cloning_server varchar(255) NOT NULL default '',
-                                flags integer NOT NULL default '0'
-                              );");
-
-        $success = $success && modify_database ('', "CREATE UNIQUE INDEX prefix_quiz_rqp_types_name_uk ON prefix_quiz_rqp_types (name);");
-
-        if ($success) {
-            $success = $success && commit_sql();
-        } else {
-            rollback_sql();
-        }
-    }
-
-    if ($success && $oldversion < 2005042900 && false) { // We don't want this to be executed any more!!!
-
-        begin_sql();
-
-        $success = $success && table_column('quiz_multianswers', '', 'sequence',  'varchar', '255', '', '', 'not null', 'question');
-        $success = $success && table_column('quiz_numerical', '', 'answers', 'varchar', '255', '', '', 'not null', 'answer');
-        $success = $success && modify_database('', 'UPDATE prefix_quiz_numerical SET answers = answer');
-        $success = $success && table_column('quiz_questions', '', 'parent', 'integer', '10', 'unsigned', '0', 'not null', 'category');
-        $success = $success && modify_database('', "UPDATE prefix_quiz_questions SET parent = id WHERE qtype ='".RANDOM."';");
-
-        // convert multianswer questions to the new model
-        if ($multianswers = get_records_sql("SELECT m.id, q.category, q.id AS parent,
-                                        q.name, q.questiontextformat, m.norm AS
-                                        defaultgrade, m.answertype AS qtype,
-                                        q.version, q.hidden, m.answers,
-                                        m.positionkey
-                                        FROM {$CFG->prefix}quiz_questions q,
-                                             {$CFG->prefix}quiz_multianswers m
-                                        WHERE q.qtype = '".MULTIANSWER."'
-                                        AND   q.id = m.question
-                                        ORDER BY q.id ASC, m.positionkey ASC")) {
-            $multianswers = array_values($multianswers);
-            $n        = count($multianswers);
-            $parent   = $multianswers[0]->parent;
-            $sequence = array();
-
-            // turn reporting off temporarily to avoid one line output per set_field
-            $olddebug = $db->debug;
-            $db->debug = false;
-            for ($i = 0; $i < $n; $i++) {
-                $answers = $multianswers[$i]->answers; unset($multianswers[$i]->answers);
-                $pos = $multianswers[$i]->positionkey; unset($multianswers[$i]->positionkey);
-
-                // create questions for all the multianswer victims
-                unset($multianswers[$i]->id);
-                $multianswers[$i]->length = 0;
-                $multianswers[$i]->questiontext = '';
-                $multianswers[$i]->stamp = make_unique_id_code();
-                $id = insert_record('quiz_questions', $multianswers[$i]);
-                $success = $success && $id;
-                $sequence[$pos] = $id;
-
-                // update the answers table to point to these new questions
-                $success = $success && modify_database('', "UPDATE prefix_quiz_answers SET question = '$id' WHERE id IN ($answers);");
-                // update the questiontype tables to point to these new questions
-                if (SHORTANSWER == $multianswers[$i]->qtype) {
-                    $success = $success && modify_database('', "UPDATE prefix_quiz_shortanswer SET question = '$id' WHERE answers = '$answers';");
-                } else if (NUMERICAL == $multianswers[$i]->qtype) {
-                    if (strpos($answers, ',')) {
-                        $numerical = get_records_list('quiz_numerical', 'answer', $answers);
-                        // Get the biggest tolerance value
-                        $tolerance = 0;
-                        foreach ($numerical as $num) {
-                            $tolerance = ($tolerance < $num->tolerance ? $num->tolerance : $tolerance);
-                        }
-                        $success = $success && delete_records_select('quiz_numerical', "answer IN ($answers)");
-                        $new = new stdClass;
-                        $new->question  = $id;
-                        $new->tolerance = $tolerance;
-                        $new->answers   = $answers;
-                        $success = $success && insert_record('quiz_numerical', $new);
-                        unset($numerical, $new, $tolerance);
-                    } else {
-                        $success = $success && modify_database('', "UPDATE prefix_quiz_numerical SET question = '$id', answers = '$answers' WHERE answer IN ($answers);");
-                    }
-                } else if (MULTICHOICE == $multianswers[$i]->qtype) {
-                    $success = $success && modify_database('', "UPDATE prefix_quiz_multichoice SET question = '$id' WHERE answers = '$answers';");
-                }
-
-                if (!isset($multianswers[$i+1]) || $parent != $multianswers[$i+1]->parent) {
-                    $success = $success && delete_records('quiz_multianswers', 'question', $parent);
-                    $multi = new stdClass;
-                    $multi->question = $parent;
-                    $multi->sequence = implode(',', $sequence);
-                    $success = $success && insert_record('quiz_multianswers', $multi);
-                    if (isset($multianswers[$i+1])) {
-                        $parent   = $multianswers[$i+1]->parent;
-                        $sequence = array();
-                    }
-                }
-            }
-            $db->debug = $olddebug;
-        }
-
-        // Remove redundant fields from quiz_multianswers
-        $success = $success && modify_database('', 'ALTER TABLE prefix_quiz_multianswers DROP COLUMN answers');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_quiz_multianswers DROP COLUMN positionkey');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_quiz_multianswers DROP COLUMN answertype');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_quiz_multianswers DROP COLUMN norm');
-
-        // Change numerical from answer to answers
-        $success = $success && modify_database('', 'ALTER TABLE prefix_quiz_numerical DROP COLUMN answer');
-
-        if ($success) {
-            $success = $success && commit_sql();
-        } else {
-            rollback_sql();
-        }
-    }
-
-    if ($success && $oldversion < 2005050300) {
-        // length of question determines question numbering. Currently all questions require one
-        // question number except for DESCRIPTION questions.
-        $success = $success && table_column('quiz_questions', '', 'length', 'integer', '10', 'unsigned', '1', 'not null', 'qtype');
-        $success = $success && execute_sql("UPDATE {$CFG->prefix}quiz_questions SET length = 0 WHERE qtype = '7'");
-    }
-
-    if ($success && $oldversion < 2005050408) {
-        $success = $success && table_column('quiz_questions', '', 'penalty', 'float', '', '', '0.1', 'not null', 'defaultgrade');
-    }
-
-    if ($success && $oldversion < 2005051401) {
-        // Some earlier changes are undone here, so we need another condition
-        if ($oldversion >= 2005042900) {
-            // Restore the answer field
-            $success = $success && table_column('quiz_numerical', '', 'answer', 'integer', '10', 'unsigned', '0', 'not null', 'answers');
-            $singleanswer = array();
-            if ($numericals = get_records('quiz_numerical')) {
-                $numericals = array_values($numericals);
-                $n = count($numericals);
-                for ($i = 0; $i < $n; $i++) {
-                    $numerical =& $numericals[$i];
-                    if (strpos($numerical->answers, ',')) { // comma separated list?
-                        // Back this up to delete the record after the new ones are created
-                        $id = $numerical->id;
-                        unset($numerical->id);
-                        // We need to create a record for each answer id
-                        $answers = explode(',', $numerical->answers);
-                        foreach ($answers as $answer) {
-                            $numerical->answer = $answer;
-                            $success = $success && insert_record('quiz_numerical', $numerical);
-                        }
-                        // ... and get rid of the old record
-                        $success = $success && delete_records('quiz_numerical', 'id', $id);
-                    } else {
-                        $singleanswer[] = $numerical->id;
-                    }
-                }
-            }
-
-            // Do all of these at once
-            if (!empty($singleanswer)) {
-                $singleanswer = implode(',', $singleanswer);
-                $success = $success && modify_database('', "UPDATE prefix_quiz_numerical SET answer = answers WHERE id IN ($singleanswer);");
-            }
-
-            // All answer fields are set, so we can delete the answers field
-            $success = $success && modify_database('', 'ALTER TABLE prefix_quiz_numerical DROP answers');
-
-        // If the earlier changes weren't made we can safely do only the
-        // bits here.
-        } else {
-            // Comma separated questionids will be stored as sequence
-            $success = $success && table_column('quiz_multianswers', '', 'sequence',  'varchar', '255', '', '', 'not null', 'question');
-            // Change the type of positionkey to int, so that the sorting works!
-            $success = $success && table_column('quiz_multianswers', 'positionkey', 'positionkey',  'integer', '10', 'unsigned', '0', 'not null', '');
-            $success = $success && table_column('quiz_questions', '', 'parent', 'integer', '10', 'unsigned', '0', 'not null', 'category');
-            $success = $success && modify_database('', "UPDATE prefix_quiz_questions SET parent = id WHERE qtype ='".RANDOM."';");
-
-            // Each multianswer record is converted to a question object and then
-            // inserted as a new question into the quiz_questions table.
-            // After that the question fields in the quiz_answers table and the
-            // qtype specific tables are updated to point to the new question id.
-            // Note: The quiz_numerical table is different as it stores one record
-            //       per defined answer (to allow different tolerance values for
-            //       different possible answers. (Currently multiple answers are
-            //       not supported by the numerical editing interface, but all
-            //       all processing code does support that possibility.
-            if ($multianswers = get_records_sql("SELECT m.id, q.category, " .
-                                            "q.id AS parent, " . // question id (of multianswer question) as parent
-                                            "q.name, q.questiontextformat, " .
-                                            "m.norm AS defaultgrade, " . // norm is snow stored as defaultgrade
-                                            "m.answertype AS qtype, " .  // just rename this
-                                            "q.version, q.hidden, m.answers, " .
-                                            "m.positionkey " .
-                                            "FROM {$CFG->prefix}quiz_questions q, " .
-                                            "     {$CFG->prefix}quiz_multianswers m " .
-                                            "WHERE q.qtype = '".MULTIANSWER."' " .
-                                            "AND   q.id = m.question " .
-                                            "ORDER BY q.id ASC, m.positionkey ASC")) { // ordered by positionkey
-                $multianswers = array_values($multianswers);
-                $n        = count($multianswers);
-                $parent   = $multianswers[0]->parent;
-                $sequence = array();
-                $positions = array();
-
-                // Turn reporting off temporarily to avoid one line output per set_field
-                global $db;
-                $olddebug = $db->debug;
-                // $db->debug = false;
-                for ($i = 0; $i < $n; $i++) {
-                    // Backup these two values before unsetting the object fields
-                    $answers = $multianswers[$i]->answers; unset($multianswers[$i]->answers);
-                    $pos = $multianswers[$i]->positionkey; unset($multianswers[$i]->positionkey);
-
-                    // Needed for substituting multianswer ids with position keys in the $state->answer field
-                    $positions[$multianswers[$i]->id] = $pos;
-
-                // Create questions for all the multianswer victims
-                    unset($multianswers[$i]->id);
-                    $multianswers[$i]->length = 0;
-                    $multianswers[$i]->questiontext = '';
-                    $multianswers[$i]->stamp = make_unique_id_code();
-                    // $multianswers[$i]->parent is set in the query
-                    // $multianswers[$i]->defaultgrade is set in the query
-                    // $multianswers[$i]->qtype is set in the query
-                    $id = insert_record('quiz_questions', $multianswers[$i]);
-                    $success = $success && $id;
-                    $sequence[$pos] = $id;
-
-                // Update the quiz_answers table to point to these new questions
-                    $success = $success && modify_database('', "UPDATE prefix_quiz_answers SET question = '$id' WHERE id IN ($answers);");
-                // Update the questiontype tables to point to these new questions
-
-                    if (SHORTANSWER == $multianswers[$i]->qtype) {
-                        $success = $success && modify_database('', "UPDATE prefix_quiz_shortanswer SET question = '$id' WHERE answers = '$answers';");
-                    } else if (MULTICHOICE == $multianswers[$i]->qtype) {
-                        $success = $success && modify_database('', "UPDATE prefix_quiz_multichoice SET question = '$id' WHERE answers = '$answers';");
-                    } else if (NUMERICAL == $multianswers[$i]->qtype) {
-                        $success = $success && modify_database('', "UPDATE prefix_quiz_numerical SET question = '$id' WHERE answer IN ($answers);");
-                    }
-
-                    // Whenever we're through with the subquestions of one multianswer
-                    // question we delete the old records in the multianswers table,
-                    // store a new record with the sequence in the multianswers table
-                    // and point $parent to the next multianswer question.
-                    if (!isset($multianswers[$i+1]) || $parent != $multianswers[$i+1]->parent) {
-
-                        // Substituting multianswer ids with position keys in the $state->answer field
-                        if ($states = get_records('quiz_states', 'question', $parent)) {
-                            foreach ($states as $state) {
-                                $reg = array();
-                                preg_match_all('/(?:^|,)([0-9]+)-([^,]*)/', $state->answer, $reg);
-                                $state->answer = '';
-                                $m = count($reg[1]);
-                                for ($j = 0; $j < $m; $j++) {
-                                    if (isset($positions[$reg[1][$j]])) {
-                                        $state->answer .= $positions[$reg[1][$j]] . '-' . $reg[2][$j] . ',';
-                                    } else {
-                                        notify("Undefined multianswer id ({$reg[1][$j]}) used in state #{$state->id}!");
-                                        $state->answer .= $j+1 . '-' . $reg[2][$j] . ',';
-                                    }
-                                }
-                                $state->answer = rtrim($state->answer, ','); // strip trailing comma
-                                $success = $success && update_record('quiz_states', $state);
-                            }
-                        }
-
-                        $success = $success && delete_records('quiz_multianswers', 'question', $parent);
-                        $multi = new stdClass;
-                        $multi->question = $parent;
-                        $multi->sequence = implode(',', $sequence);
-                        $success = $success && insert_record('quiz_multianswers', $multi);
-
-                        if (isset($multianswers[$i+1])) {
-                            $parent    = $multianswers[$i+1]->parent;
-                            $sequence  = array();
-                            $positions = array();
-                        }
-                    }
-                }
-                $db->debug = $olddebug;
-            }
-
-            // Remove redundant fields from quiz_multianswers
-            $success = $success && modify_database('', 'ALTER TABLE prefix_quiz_multianswers DROP answers');
-            $success = $success && modify_database('', 'ALTER TABLE prefix_quiz_multianswers DROP positionkey');
-            $success = $success && modify_database('', 'ALTER TABLE prefix_quiz_multianswers DROP answertype');
-            $success = $success && modify_database('', 'ALTER TABLE prefix_quiz_multianswers DROP norm');
-        }
-    }
-
-    if ($success && $oldversion < 2005051402) {
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_attemptonlast_datasets DROP CONSTRAINT category;",false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_attemptonlast_datasets DROP CONSTRAINT {$CFG->prefix}attemptonlast_datasets_category_userid;",false);
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_attemptonlast_datasets DROP CONSTRAINT {$CFG->prefix}quiz_category_userid_unique;",false);
-        $success = $success && modify_database('','ALTER TABLE prefix_quiz_attemptonlast_datasets ADD CONSTRAINT prefix_quiz_category_userid_unique UNIQUE (category,userid);');
-    }
-
-    if ($success && $oldversion < 2005060300) {
-        // We need to remove some duplicate entries that may be present in some databases
-        // due to a faulty restore script
-
-        // Remove duplicate entries from quiz_numerical
-        if ($dups = get_records_sql("
-                SELECT question, answer, count(*) as num
-                FROM {$CFG->prefix}quiz_numerical
-                GROUP BY question, answer
-                HAVING count(*) > 1"
-            )) {
-            foreach ($dups as $dup) {
-                $ids = get_records_sql("
-                    SELECT id, id
-                    FROM {$CFG->prefix}quiz_numerical
-                    WHERE question = '$dup->question'
-                    AND answer = '$dup->answer'"
-                );
-                $skip = true;
-                foreach ($ids as $id) {
-                    if ($skip) {
-                        $skip = false;
-                    } else {
-                        $success = $success && delete_records('quiz_numerical','id', $id->id);
-                    }
-                }
-            }
-        }
-
-        // Remove duplicate entries from quiz_shortanswer
-        if ($dups = get_records_sql("
-                SELECT question, answers, count(*) as num
-                FROM {$CFG->prefix}quiz_shortanswer
-                GROUP BY question, answers
-                HAVING count(*) > 1"
-            )) {
-            foreach ($dups as $dup) {
-                $ids = get_records_sql("
-                    SELECT id, id
-                    FROM {$CFG->prefix}quiz_shortanswer
-                    WHERE question = '$dup->question'
-                    AND answers = '$dup->answers'"
-                );
-                $skip = true;
-                foreach ($ids as $id) {
-                    if ($skip) {
-                        $skip = false;
-                    } else {
-                        $success = $success && delete_records('quiz_shortanswer','id', $id->id);
-                    }
-                }
-            }
-        }
-
-        // Remove duplicate entries from quiz_multichoice
-        if ($dups = get_records_sql("
-                SELECT question, answers, count(*) as num
-                FROM {$CFG->prefix}quiz_multichoice
-                GROUP BY question, answers
-                HAVING count(*) > 1"
-            )) {
-            foreach ($dups as $dup) {
-                $ids = get_records_sql("
-                    SELECT id, id
-                    FROM {$CFG->prefix}quiz_multichoice
-                    WHERE question = '$dup->question'
-                    AND answers = '$dup->answers'"
-                );
-                $skip = true;
-                foreach ($ids as $id) {
-                    if ($skip) {
-                        $skip = false;
-                    } else {
-                        $success = $success && delete_records('quiz_multichoice','id', $id->id);
-                    }
-                }
-            }
-        }
-
-        //Search all the orphan categories (those whose course doesn't exist)
-        //and process them, deleting or moving them to site course - Bug 2459
-
-        //Set debug to false
-        $olddebug = $db->debug;
-        $db->debug = false;
-
-        //Iterate over all the quiz_categories records to get their course id
-        if ($courses = get_records_sql ("SELECT DISTINCT course as id, course
-                                         FROM {$CFG->prefix}quiz_categories")) {
-            //Iterate over courses
-            foreach ($courses as $course) {
-                //If the course doesn't exist, orphan category found!
-                //Process it with question_delete_course(). It will do all the hard work.
-                if (!record_exists('course', 'id', $course->id)) {
-                    require_once("$CFG->libdir/questionlib.php");
-                    $success = $success && question_delete_course($course);
-                }
-            }
-        }
-        //Reset rebug to its original state
-        $db->debug = $olddebug;
-    }
-
-    if ($success && $oldversion < 2005060301) {
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_rqp_type RENAME TO '.$CFG->prefix.'quiz_rqp_types');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_rqp_type_id_seq RENAME TO '.$CFG->prefix.'rqp_types_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_rqp_types ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'quiz_rqp_types_id_seq\')');
-        $success = $success && execute_sql('DROP INDEX '.$CFG->prefix.'quiz_rqp_type_name_uk');
-        $success = $success && execute_sql('CREATE UNIQUE INDEX '.$CFG->prefix.'quiz_rqp_types_name_uk ON '.$CFG->prefix.'quiz_rqp_types (name);');
-    }
-    
-    if ($success && $oldversion < 2005060302) { // Mass cleanup of bad postgres upgrade scripts
-        $success = $success && execute_sql('CREATE UNIQUE INDEX '.$CFG->prefix.'quiz_newest_states_attempt_idx ON '.$CFG->prefix.'quiz_newest_states (attemptid, questionid)',false);
-        $success = $success && execute_sql('ALTER TABLE ONLY '.$CFG->prefix.'quiz_attemptonlast_datasets DROP CONSTRAINT '.$CFG->prefix.'quiz_category_userid_unique',false);
-        $success = $success && execute_sql('ALTER TABLE ONLY '.$CFG->prefix.'quiz_attemptonlast_datasets ADD CONSTRAINT '.$CFG->prefix.'quiz_attemptonlast_datasets_category_userid UNIQUE (category, userid)',false);
-        $success = $success && execute_sql('ALTER TABLE ONLY '.$CFG->prefix.'quiz_question_instances DROP CONSTRAINT '.$CFG->prefix.'quiz_question_grades_pkey',false);
-        $success = $success && execute_sql('ALTER TABLE ONLY '.$CFG->prefix.'quiz_question_instances ADD CONSTRAINT '.$CFG->prefix.'quiz_question_instances_pkey PRIMARY KEY (id)',false);
-        $success = $success && execute_sql('ALTER TABLE ONLY '.$CFG->prefix.'quiz_question_versions DROP CONSTRAINT '.$CFG->prefix.'quiz_question_version_pkey',false);
-        $success = $success && execute_sql('ALTER TABLE ONLY '.$CFG->prefix.'quiz_question_versions ADD CONSTRAINT '.$CFG->prefix.'quiz_question_versions_pkey PRIMARY KEY (id)',false);
-        $success = $success && execute_sql('ALTER TABLE ONLY '.$CFG->prefix.'quiz_states DROP CONSTRAINT '.$CFG->prefix.'quiz_responses_pkey',false);
-        $success = $success && execute_sql('ALTER TABLE ONLY '.$CFG->prefix.'quiz_states ADD CONSTRAINT '.$CFG->prefix.'quiz_states_pkey PRIMARY KEY (id)',false);
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz ALTER decimalpoints SET NOT NULL',false);
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz ALTER optionflags SET NOT NULL',false);
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz ALTER penaltyscheme SET NOT NULL',false);
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz ALTER popup SET NOT NULL',false);
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz ALTER questionsperpage SET NOT NULL',false);
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz ALTER review SET NOT NULL',false);
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_answers ALTER answer SET NOT NULL',false);
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_attempts ALTER layout SET NOT NULL',false);
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_attempts ALTER preview SET NOT NULL',false);
-
-        $success = $success && table_column('quiz_calculated','correctanswerformat','correctanswerformat','integer','16','unsigned','2');
-
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_categories ALTER parent SET NOT NULL',false);
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_categories ALTER sortorder SET NOT NULL',false);
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_grades ALTER grade SET NOT NULL',false);
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_multianswers ALTER sequence SET NOT NULL',false);
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_numerical ALTER tolerance SET NOT NULL',false);
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_questions ALTER hidden SET NOT NULL',false);
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_questions ALTER length SET NOT NULL',false);
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_questions ALTER parent SET NOT NULL',false);
-
-        $success = $success && table_column('quiz_questions','penalty','penalty','real','','UNSIGNED','0.1');
-
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_states ALTER answer SET NOT NULL',false);
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_states ALTER event SET NOT NULL',false);
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_states ALTER originalquestion SET NOT NULL',false);
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_states ALTER penalty SET NOT NULL',false);
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_states ALTER raw_grade SET NOT NULL',false);
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_states ALTER seq_number SET NOT NULL',false);
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_states ALTER timestamp SET NOT NULL',false);
-    }
-
-    if ($success && $oldversion < 2005100500) {
-        // clean up an old mistake. This mistake may not have been made, so don't worry about failures.
-        $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_question_version_id_seq RENAME TO '.$CFG->prefix.'quiz_question_versions_id_seq',false);
-        $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_question_versions ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'quiz_question_versions_id_seq\')',false);
-    }
-    if ($success && $oldversion < 2006020801) {
-        $success = $success && table_column("quiz", "", "delay1", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "popup");
-        $success = $success && table_column("quiz", "", "delay2", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "delay1");
-    }
-
-    if ($success && $oldversion < 2006021101) {
-        // set defaultgrade field properly (probably not necessary, but better make sure)
-        $success && execute_sql("UPDATE {$CFG->prefix}quiz_questions SET defaultgrade = '1' WHERE defaultgrade = '0'", false);
-        $success && execute_sql("UPDATE {$CFG->prefix}quiz_questions SET defaultgrade = '0' WHERE qtype = '7'", false);
-    }
-
-    if ($success && $oldversion < 2006021103) {
-        // add new field to store the question-level shuffleanswers option
-        $success = $success && table_column('quiz_match', '', 'shuffleanswers', 'tinyint', '4', 'unsigned', '1', 'not null', 'subquestions');
-        $success = $success && table_column('quiz_multichoice', '', 'shuffleanswers', 'tinyint', '4', 'unsigned', '1', 'not null', 'single');
-        $success = $success && table_column('quiz_randomsamatch', '', 'shuffleanswers', 'tinyint', '4', 'unsigned', '1', 'not null', 'choose');
-    }
-
-    if ($success && $oldversion < 2006021104) {
-        // add originalversion field for the new versioning mechanism
-        $success = $success && table_column('quiz_question_versions', '', 'originalquestion', 'int', '10', 'unsigned', '0', 'not null', 'newquestion');
-    }
-
-    if ($success && $oldversion < 2006021302) {
-        $success = $success && table_column('quiz_match_sub', '', 'code', 'int', '10', 'unsigned', '0', 'not null', 'id');
-        $success = $success && execute_sql("UPDATE {$CFG->prefix}quiz_match_sub SET code = id", false);
-    }
-
-    if ($success && $oldversion < 2006021304) {
-        // convert sequence field to text to accomodate very long sequences, see bug 4257
-        $success = $success && table_column('quiz_multianswers', 'sequence', 'sequence',  'text', '', '', '', 'not null', 'question');
-    }
-
-    if ($success && $oldversion < 2006021400) {
-        // modify_database('','CREATE UNIQUE INDEX prefix_quiz_attempts_uniqueid_uk ON prefix_quiz_attempts (uniqueid);');
-        // this index will not be created since uniqueid was not added, proper upgrade will be on 2006042801
-    }
-
-    if ($success && $oldversion < 2006021501) {
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_newest_states RENAME TO {$CFG->prefix}question_sessions", false);
-    }
-
-    if ($success && $oldversion < 2006021900) {
-        
-        $success = $success && modify_database ('', "
-            CREATE TABLE prefix_quiz_essay (
-                id SERIAL PRIMARY KEY,
-                question integer NOT NULL default '0',
-                answer varchar(255) NOT NULL default ''
-            ) ");
-
-        $success = $success && modify_database ('', "
-            CREATE TABLE prefix_quiz_essay_states (
-                id SERIAL PRIMARY KEY,
-                stateid integer NOT NULL default '0',
-                graded integer NOT NULL default '0',
-                fraction varchar(10) NOT NULL default '0.0',
-                response text NOT NULL default ''
-            );");
-
-        // convert grade fields to real
-        $success = $success && table_column('quiz_attempts', 'sumgrades', 'sumgrades',  'real', '', '', '0', 'not null');
-        $success = $success && table_column('quiz_answers', 'fraction', 'fraction',  'real', '', '', '0', 'not null');
-        $success = $success && table_column('quiz_essay_states', 'fraction', 'fraction',  'real', '', '', '0', 'not null');
-        $success = $success && set_field('quiz_states', 'grade', 0, 'grade', ''); // Some values may be wrong, which caused errors in the following table_column calls.
-        $success = $success && set_field('quiz_states', 'raw_grade', 0, 'raw_grade', '');
-        $success = $success && set_field('quiz_states', 'penalty', 0, 'penalty', '');
-        $success = $success && table_column('quiz_states', 'grade', 'grade',  'real', '', '', '0', 'not null');
-        $success = $success && table_column('quiz_states', 'raw_grade', 'raw_grade',  'real', '', '', '0', 'not null');
-        $success = $success && table_column('quiz_states', 'penalty', 'penalty',  'real', '', '', '0', 'not null');
-        $success = $success && table_column('question_sessions', 'sumpenalty', 'sumpenalty',  'real', '', '', '0', 'not null');
-    }
-
-    if ($success && $oldversion < 2006030100) {
-        // Fix up another table rename :(
-        // THIS caused the mistake: execute_sql("ALTER TABLE {$CFG->prefix}quiz_newest_states RENAME TO {$CFG->prefix}question_sessions", false);
-        $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_newest_states_id_seq RENAME TO '.$CFG->prefix.'question_sessions_id_seq',false);
-        $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_sessions ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_sessions_id_seq\')',false);
-    }
-
-    if ($success && $oldversion < 2006030101) {
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_questions RENAME TO {$CFG->prefix}question");
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_questions_id_seq RENAME TO '.$CFG->prefix.'question_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_id_seq\')');
-
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_states RENAME TO {$CFG->prefix}question_states");
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_states_id_seq RENAME TO '.$CFG->prefix.'question_states_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_states ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_states_id_seq\')');
-    
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_answers RENAME TO {$CFG->prefix}question_answers");
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_answers_id_seq RENAME TO '.$CFG->prefix.'question_answers_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_answers ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_answers_id_seq\')');
-    
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_categories RENAME TO {$CFG->prefix}question_categories");
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_categories_id_seq RENAME TO '.$CFG->prefix.'question_categories_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_categories ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_categories_id_seq\')');
-    }
-
-    if ($success && $oldversion < 2006031202) {
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_truefalse RENAME TO {$CFG->prefix}question_truefalse");
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_truefalse_id_seq RENAME TO '.$CFG->prefix.'question_truefalse_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_truefalse ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_truefalse_id_seq\')');
-
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_shortanswer RENAME TO {$CFG->prefix}question_shortanswer");
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_shortanswer_id_seq RENAME TO '.$CFG->prefix.'question_shortanswer_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_shortanswer ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_shortanswer_id_seq\')');
-
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_multianswers RENAME TO {$CFG->prefix}question_multianswer");
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_multianswers_id_seq RENAME TO '.$CFG->prefix.'question_multianswer_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_multianswer ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_multianswer_id_seq\')');
-
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_multichoice RENAME TO {$CFG->prefix}question_multichoice");
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_multichoice_id_seq RENAME TO '.$CFG->prefix.'question_multichoice_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_multichoice ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_multichoice_id_seq\')');
-
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_numerical RENAME TO {$CFG->prefix}question_numerical");
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_numerical_id_seq RENAME TO '.$CFG->prefix.'question_numerical_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_numerical ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_numerical_id_seq\')');
-
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_numerical_units RENAME TO {$CFG->prefix}question_numerical_units");
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_numerical_units_id_seq RENAME TO '.$CFG->prefix.'question_numerical_units_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_numerical_units ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_numerical_units_id_seq\')');
-
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_randomsamatch RENAME TO {$CFG->prefix}question_randomsamatch");
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_randomsamatch_id_seq RENAME TO '.$CFG->prefix.'question_randomsamatch_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_randomsamatch ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_randomsamatch_id_seq\')');
-
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_match RENAME TO {$CFG->prefix}question_match");
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_match_id_seq RENAME TO '.$CFG->prefix.'question_match_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_match ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_match_id_seq\')');
-
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_match_sub RENAME TO {$CFG->prefix}question_match_sub");
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_match_sub_id_seq RENAME TO '.$CFG->prefix.'question_match_sub_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_match_sub ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_match_sub_id_seq\')');
-
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_calculated RENAME TO {$CFG->prefix}question_calculated");
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_calculated_id_seq RENAME TO '.$CFG->prefix.'question_calculated_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_calculated ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_calculated_id_seq\')');
-
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_dataset_definitions RENAME TO {$CFG->prefix}question_dataset_definitions");
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_dataset_definitions_id_seq RENAME TO '.$CFG->prefix.'question_dataset_definitions_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_dataset_definitions ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_dataset_definitions_id_seq\')');
-
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_dataset_items RENAME TO {$CFG->prefix}question_dataset_items");
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_dataset_items_id_seq RENAME TO '.$CFG->prefix.'question_dataset_items_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_dataset_items ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_dataset_items_id_seq\')');
-
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_question_datasets RENAME TO {$CFG->prefix}question_datasets");
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_question_datasets_id_seq RENAME TO '.$CFG->prefix.'question_datasets_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_datasets ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_datasets_id_seq\')');
-
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_rqp RENAME TO {$CFG->prefix}question_rqp");
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_rqp_id_seq RENAME TO '.$CFG->prefix.'question_rqp_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_rqp ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_rqp_id_seq\')');
-
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_rqp_states RENAME TO {$CFG->prefix}question_rqp_states");
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_rqp_states_id_seq RENAME TO '.$CFG->prefix.'question_rqp_states_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_rqp_states ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_rqp_states_id_seq\')');
-
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_rqp_types RENAME TO {$CFG->prefix}question_rqp_types");
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_rqp_types_id_seq RENAME TO '.$CFG->prefix.'question_rqp_types_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_rqp_types ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_rqp_types_id_seq\')');
-
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_essay RENAME TO {$CFG->prefix}question_essay");
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_essay_id_seq RENAME TO '.$CFG->prefix.'question_essay_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_essay ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_essay_id_seq\')');
-
-        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_essay_states RENAME TO {$CFG->prefix}question_essay_states");
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_essay_states_id_seq RENAME TO '.$CFG->prefix.'question_essay_states_id_seq');
-        $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_essay_states ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_essay_states_id_seq\')');
-
-    }
-
-    if ($success && $oldversion < 2006032100) {
-        // change from the old questiontype numbers to using the questiontype names
-        $success = $success && table_column('question', 'qtype', 'qtype',  'varchar', 20, '', '', 'not null');
-        $success = $success && set_field('question', 'qtype', 'shortanswer', 'qtype', 1);
-        $success = $success && set_field('question', 'qtype', 'truefalse', 'qtype', 2);
-        $success = $success && set_field('question', 'qtype', 'multichoice', 'qtype', 3);
-        $success = $success && set_field('question', 'qtype', 'random', 'qtype', 4);
-        $success = $success && set_field('question', 'qtype', 'match', 'qtype', 5);
-        $success = $success && set_field('question', 'qtype', 'randomsamatch', 'qtype', 6);
-        $success = $success && set_field('question', 'qtype', 'description', 'qtype', 7);
-        $success = $success && set_field('question', 'qtype', 'numerical', 'qtype', 8);
-        $success = $success && set_field('question', 'qtype', 'multianswer', 'qtype', 9);
-        $success = $success && set_field('question', 'qtype', 'calculated', 'qtype', 10);
-        $success = $success && set_field('question', 'qtype', 'rqp', 'qtype', 11);
-        $success = $success && set_field('question', 'qtype', 'essay', 'qtype', 12);
-    }
-
-    if ($success && $oldversion < 2006032200) {
-        // set version for all questiontypes that already have their tables installed
-        $success = $success && set_config('qtype_calculated_version', 2006032100);
-        $success = $success && set_config('qtype_essay_version', 2006032100);
-        $success = $success && set_config('qtype_match_version', 2006032100);
-        $success = $success && set_config('qtype_multianswer_version', 2006032100);
-        $success = $success && set_config('qtype_multichoice_version', 2006032100);
-        $success = $success && set_config('qtype_numerical_version', 2006032100);
-        $success = $success && set_config('qtype_randomsamatch_version', 2006032100);
-        $success = $success && set_config('qtype_rqp_version', 2006032100);
-        $success = $success && set_config('qtype_shortanswer_version', 2006032100);
-        $success = $success && set_config('qtype_truefalse_version', 2006032100);
-    }
-
-    if ($success && $oldversion < 2006040600) {
-        $success = $success && table_column('question_sessions', '', 'comment', 'text', '', '', '', 'not null', 'sumpenalty');
-    }
-
-    if ($success && $oldversion < 2006040900) {
-        $success = $success && modify_database('', "UPDATE prefix_question SET parent = id WHERE qtype ='random';");
-    }
-
-    if ($success && $oldversion < 2006041000) {
-        $success = $success && modify_database('', " INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('quiz', 'continue attempt', 'quiz', 'name');");
-    }
-
-    if ($success && $oldversion < 2006041001) {
-        $success = $success && table_column('question', 'version', 'version', 'varchar', 255);
-    }
-
-    if ($success && $oldversion < 2006042800) {
-        // Check we have some un-renamed tables (verified in some servers)
-        if ($tables = $db->MetaTables('TABLES')) {
-            if (in_array($CFG->prefix.'quiz_randommatch', $tables) &&
-                !in_array($CFG->prefix.'question_randomsamatch', $tables)) {
-                $success = $success && modify_database ("", "ALTER TABLE prefix_quiz_randommatch RENAME prefix_question_randomsamatch ");
-                $success = $success && modify_database ("", "ALTER TABLE prefix_quiz_randommatch_id_seq RENAME prefix_question_randomsamatch_id_seq ");
-                $success = $success && execute_sql('ALTER TABLE '.$CFG->prefix.'question_randomsamatch ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_randomsamatch_id_seq\')');
-            }
-            // Check for one possible missing field in one table
-            if ($columns = $db->MetaColumnNames($CFG->prefix.'question_randomsamatch')) {
-                if (!in_array('shuffleanswers', $columns)) {
-                    $success = $success && table_column('question_randomsamatch', '', 'shuffleanswers', 'tinyint', '4', 'unsigned', '1', 'not null', 'choose');
-                }
-            }
-        }
-    }
-
-    if ($success && $oldversion < 2006051300) {  // this block also exec'ed by 2006042801 on MOODLE_16_STABLE
-        // The newgraded field must always point to a valid state
-        $success = $success && modify_database("","UPDATE prefix_question_sessions SET newgraded = newest where newgraded = '0'");
-
-        // Only perform this if hasn't been performed before (in MOODLE_16_STABLE branch - bug 5717)
-        $tables = $db->MetaTables('TABLES');
-        if (!in_array($CFG->prefix . 'question_attempts', $tables)) {
-            // The following table is discussed in bug 5468
-            $success = $success && modify_database ("", "CREATE TABLE prefix_question_attempts (
-                                     id SERIAL PRIMARY KEY,
-                                     modulename varchar(20) NOT NULL default 'quiz'
-                                  );");
-        }
-    }
-
-    if ($success && $oldversion < 2006051700) { // this block also exec'd by 2006042802 on MOODLE_16_STABLE
-
-        notify("The next set of upgrade operations may report an 
-                error if you are upgrading from v1.6. 
-                This error mesage is normal, and can be ignored.");
-        // this block is taken from mysql.php 2005070202
-        // add new unique id to prepare the way for lesson module to have its own attempts table
-        table_column('quiz_attempts', '', 'uniqueid', 'integer', '10', 'unsigned', '0', 'not null', 'id');
-        // create one entry for all the existing quiz attempts
-        // initially we can use the id as the unique id because no other modules use attempts yet.
-        $success = $success && execute_sql("UPDATE {$CFG->prefix}quiz_attempts SET uniqueid = id");
-        // we set $CFG->attemptuniqueid to the next available id
-        $record = get_record_sql("SELECT nextval('{$CFG->prefix}quiz_attempts_id_seq')");
-        $success = $success && set_config('attemptuniqueid', empty($record->nextid) ? 1 : $record->nextid);
-        // the above will be a race condition, see bug 5468
-
-        modify_database('','CREATE UNIQUE INDEX prefix_quiz_attempts_uniqueid_uk ON prefix_quiz_attempts (uniqueid);');
-
-        // create one entry for all the existing quiz attempts
-        $success = $success && modify_database ("", "INSERT INTO prefix_question_attempts (id)
-                                   SELECT uniqueid
-                                   FROM prefix_quiz_attempts;");
-    }
-
-    if ($success && $oldversion < 2006042802) {
-
-        // Copy the teacher comments from the question_essay_states table to the new
-        // question_sessions table.
-
-        // Get the attempt unique ID, teacher comment, graded flag, state ID, and question ID
-        // based on the quesiont_essay_states
-        if ($results = get_records_sql("SELECT a.uniqueid, es.response AS essaycomment, es.graded AS isgraded, 
-                                               qs.id AS stateid, qs.question AS questionid 
-                                        FROM {$CFG->prefix}question_states as qs,
-                                             {$CFG->prefix}question_essay_states es, 
-                                             {$CFG->prefix}quiz_attempts a 
-                                        WHERE es.stateid = qs.id AND a.uniqueid = qs.attempt")) {
-            foreach ($results as $result) {
-                // Create a state object to be used for updating
-                $state = new stdClass;
-                $state->id = $result->stateid;
-
-                if ($result->isgraded) {
-                    // Graded - save comment to the sessions and change state event to QUESTION_EVENTMANUALGRADE
-                    if (!($success = $success && set_field('question_sessions', 'comment', $result->essaycomment, 'attemptid', $result->uniqueid, 'questionid', $result->questionid))) {
-                        notify("Essay Table Migration: Cannot save comment");
-                        break;
-                    }
-                    $state->event = 9; //QUESTION_EVENTMANUALGRADE;
-                } else {
-                    // Not graded
-                    $state->event = 7; //QUESTION_EVENTSUBMIT;
-                }
-
-                // Save the event
-                if (!($success = $success && update_record('question_states', $state))) {
-                    notify("Essay Table Migration: Cannot update state");
-                    break;
-                }
-            }
-        }
-    
-        // dropping unused tables
-        $success = $success && execute_sql('DROP TABLE '.$CFG->prefix.'question_essay_states');
-        $success = $success && execute_sql('DROP TABLE '.$CFG->prefix.'question_essay');
-        $success = $success && execute_sql('DROP TABLE '.$CFG->prefix.'quiz_attemptonlast_datasets');
-
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question
-            ALTER COLUMN qtype SET DEFAULT \'0\'');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question
-            ALTER COLUMN version SET DEFAULT \'\'');
-
-        // recreate the indexes that was not moved while quiz was transitioning to question lib
-        $success && notify('Errors on indexes not being able to drop or already exists can be ignored as they may have been properly upgraded previously');
-        $success && modify_database('','DROP INDEX prefix_quiz_numerical_answer_idx');
-        $success && modify_database('','DROP INDEX prefix_quiz_numerical_question_idx');
-        $success = $success && modify_database('','CREATE INDEX prefix_question_numerical_question_idx ON prefix_question_numerical (question)');
-        $success = $success && modify_database('','CREATE INDEX prefix_question_numerical_answer_idx ON prefix_question_numerical (answer)');
-        $success && modify_database('','DROP INDEX prefix_quiz_question_datasets_question_datasetdefinition_idx');
-        $success = $success && modify_database('','CREATE INDEX prefix_question_datasets_question_datasetdefinition_idx ON prefix_question_datasets (question, datasetdefinition)');
-
-        $success && modify_database('','DROP INDEX prefix_quiz_multichoice_question_idx');
-        $success = $success && modify_database('','CREATE INDEX prefix_question_multichoice_question_idx ON prefix_question_multichoice (question)');
-
-        $success && modify_database('','DROP INDEX prefix_quiz_categories_course_idx');
-        $success = $success && modify_database('','CREATE INDEX prefix_question_categories_course_idx ON prefix_question_categories (course)');
-
-        $success && modify_database('','DROP INDEX prefix_quiz_shortanswer_question_idx');
-        $success = $success && modify_database('','CREATE INDEX prefix_question_shortanswer_question_idx ON prefix_question_shortanswer (question)');
-
-        $success && modify_database('','DROP INDEX prefix_quiz_questions_category_idx');
-        $success = $success && modify_database('','CREATE INDEX prefix_question_category_idx ON prefix_question (category)');
-
-        $success && modify_database('','DROP INDEX prefix_quiz_calculated_answer_idx');
-        $success && modify_database('','DROP INDEX prefix_quiz_calculated_question_idx');
-        $success = $success && modify_database('','CREATE INDEX prefix_question_calculated_question_idx ON prefix_question_calculated (question)');
-        $success = $success && modify_database('','CREATE INDEX prefix_question_calculated_answer_idx ON prefix_question_calculated (answer)');
-
-        $success && modify_database('','DROP INDEX prefix_quiz_answers_question_idx');
-        $success = $success && modify_database('','CREATE INDEX prefix_question_answers_question_idx ON prefix_question_answers (question)');
-
-        $success && modify_database('','DROP INDEX prefix_quiz_dataset_items_definition_idx');
-        $success = $success && modify_database('','CREATE INDEX prefix_question_dataset_items_definition_idx ON prefix_question_dataset_items (definition)');
-
-        $success && modify_database('','DROP INDEX prefix_quiz_numerical_units_question_idx');
-        $success = $success && modify_database('','CREATE INDEX prefix_question_numerical_units_question_idx ON prefix_question_numerical_units (question)');
-
-        $success && modify_database('','DROP INDEX prefix_quiz_randomsamatch_question_idx');
-        $success = $success && modify_database('','CREATE INDEX prefix_question_randomsamatch_question_idx ON prefix_question_randomsamatch (question)');
-
-        $success && modify_database('','DROP INDEX prefix_quiz_states_question_idx');
-        $success && modify_database('','DROP INDEX prefix_quiz_states_attempt_idx');
-        $success = $success && modify_database('','CREATE INDEX prefix_question_states_question_idx ON prefix_question_states (question)');
-        $success = $success && modify_database('','CREATE INDEX prefix_question_states_attempt_idx ON prefix_question_states (attempt)');
-
-        $success && modify_database('','DROP INDEX prefix_quiz_match_question_idx');
-        $success = $success && modify_database('','CREATE INDEX prefix_question_match_question_idx ON prefix_question_match (question)');
-
-        $success && modify_database('','DROP INDEX prefix_quiz_match_sub_question_idx');
-        $success = $success && modify_database('','CREATE INDEX prefix_question_match_sub_question_idx ON prefix_question_match_sub (question)');
-
-        $success && modify_database('','DROP INDEX prefix_quiz_multianswers_question_idx');
-        $success = $success && modify_database('','CREATE INDEX prefix_question_multianswer_question_idx ON prefix_question_multianswer (question)');
-
-        $success && modify_database('','DROP INDEX prefix_quiz_dataset_definitions_category_idx');
-        $success = $success && modify_database('','CREATE INDEX prefix_question_dataset_definitions_category_idx ON prefix_question_dataset_definitions (category)');
-
-        $success = $success && modify_database('','CREATE INDEX prefix_log_timecoursemoduleaction_idx ON prefix_log ("time", course, module, "action")');
-        $success = $success && modify_database('','CREATE INDEX prefix_log_coursemoduleaction_idx ON prefix_log (course, module, "action")');
-
-        $success && modify_database('','DROP INDEX prefix_quiz_rqp_question_idx');
-        $success = $success && modify_database('','CREATE INDEX prefix_question_rqp_question_idx ON prefix_question_rqp (question)');
-
-        $success && modify_database('','DROP INDEX prefix_quiz_truefalse_question_idx');
-        $success = $success && modify_database('','CREATE INDEX prefix_question_truefalse_question_idx ON prefix_question_truefalse (question)');
-        $success && notify('End of upgrading of indexes');
-
-
-        $success && notify('Renaming primary key names');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_numerical DROP CONSTRAINT prefix_quiz_numerical_pkey');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_numerical ADD CONSTRAINT prefix_question_numerical_pkey PRIMARY KEY (id)');
-
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_datasets DROP CONSTRAINT prefix_quiz_question_datasets_pkey');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_datasets ADD CONSTRAINT prefix_question_datasets_pkey PRIMARY KEY (id)');
-
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_multichoice DROP CONSTRAINT prefix_quiz_multichoice_pkey');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_multichoice ADD CONSTRAINT prefix_question_multichoice_pkey PRIMARY KEY (id)');
-
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_rqp_states DROP CONSTRAINT prefix_quiz_rqp_states_pkey');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_rqp_states ADD CONSTRAINT prefix_question_rqp_states_pkey PRIMARY KEY (id)');
-
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_categories DROP CONSTRAINT prefix_quiz_categories_pkey');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_categories ADD CONSTRAINT prefix_question_categories_pkey PRIMARY KEY (id)');
-
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_shortanswer DROP CONSTRAINT prefix_quiz_shortanswer_pkey');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_shortanswer ADD CONSTRAINT prefix_question_shortanswer_pkey PRIMARY KEY (id)');
-
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question DROP CONSTRAINT prefix_quiz_questions_pkey');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question ADD CONSTRAINT prefix_question_pkey PRIMARY KEY (id)');
-
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_sessions DROP CONSTRAINT prefix_quiz_newest_states_pkey');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_sessions ADD CONSTRAINT prefix_question_sessions_pkey PRIMARY KEY (id)');
-
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_calculated DROP CONSTRAINT prefix_quiz_calculated_pkey');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_calculated ADD CONSTRAINT prefix_question_calculated_pkey PRIMARY KEY (id)');
-
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_answers DROP CONSTRAINT prefix_quiz_answers_pkey');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_answers ADD CONSTRAINT prefix_question_answers_pkey PRIMARY KEY (id)');
-
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_dataset_items DROP CONSTRAINT prefix_quiz_dataset_items_pkey');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_dataset_items ADD CONSTRAINT prefix_question_dataset_items_pkey PRIMARY KEY (id)');
-
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_numerical_units DROP CONSTRAINT prefix_quiz_numerical_units_pkey');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_numerical_units ADD CONSTRAINT prefix_question_numerical_units_pkey PRIMARY KEY (id)');
-
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_randomsamatch DROP CONSTRAINT prefix_quiz_randomsamatch_pkey');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_randomsamatch ADD CONSTRAINT prefix_question_randomsamatch_pkey PRIMARY KEY (id)');
-
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_rqp_types DROP CONSTRAINT prefix_quiz_rqp_types_pkey');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_rqp_types ADD CONSTRAINT prefix_question_rqp_types_pkey PRIMARY KEY (id)');
-
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_states DROP CONSTRAINT prefix_quiz_states_pkey');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_states ADD CONSTRAINT prefix_question_states_pkey PRIMARY KEY (id)');
-
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_match DROP CONSTRAINT prefix_quiz_match_pkey');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_match ADD CONSTRAINT prefix_question_match_pkey PRIMARY KEY (id)');
-
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_match_sub DROP CONSTRAINT prefix_quiz_match_sub_pkey');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_match_sub ADD CONSTRAINT prefix_question_match_sub_pkey PRIMARY KEY (id)');
-
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_multianswer DROP CONSTRAINT prefix_quiz_multianswers_pkey');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_multianswer ADD CONSTRAINT prefix_question_multianswer_pkey PRIMARY KEY (id)');
-
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_dataset_definitions DROP CONSTRAINT prefix_quiz_dataset_definitions_pkey');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_dataset_definitions ADD CONSTRAINT prefix_question_dataset_definitions_pkey PRIMARY KEY (id)');
-
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_rqp DROP CONSTRAINT prefix_quiz_rqp_pkey');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_rqp ADD CONSTRAINT prefix_question_rqp_pkey PRIMARY KEY (id)');
-
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_truefalse DROP CONSTRAINT prefix_quiz_truefalse_pkey');
-        $success = $success && modify_database('', 'ALTER TABLE prefix_question_truefalse ADD CONSTRAINT prefix_question_truefalse_pkey PRIMARY KEY (id)');
-        $success && notify('End of renaming primary keys');
-
-    }
-
-    if ($oldversion < 2006081000) {
-        // Add a column to the the question table to store the question general feedback.
-        $success = $success && table_column('question', '', 'commentarytext', 'text', '', '', '', 'not null', 'image');
-
-        // Adjust the quiz review options so that general feedback is displayed whenever feedback is.
-        $success = $success && execute_sql('UPDATE ' . $CFG->prefix . 'quiz SET review = ' .
-                '(review & ~' . QUIZ_REVIEW_GENERALFEEDBACK . ') | ' . // Clear any existing junk from the commenary bits.
-                '((review & ' . QUIZ_REVIEW_FEEDBACK . ') * 8)'); // Set the general feedback bits to be the same as the feedback ones.
-
-        // Same adjustment to the defaults for new quizzes.
-        $success = $success && set_config('quiz_review', ($CFG->quiz_review & ~QUIZ_REVIEW_GENERALFEEDBACK) |
-                (($CFG->quiz_review & QUIZ_REVIEW_FEEDBACK) << 3));
-    }
-    
-    if ($success && $oldversion < 2006081400) {
-        $success = $success && modify_database('', "
-            CREATE TABLE prefix_quiz_feedback (
-                id SERIAL PRIMARY KEY,
-                quizid integer NOT NULL default '0',
-                feedbacktext text NOT NULL default '',
-                maxgrade real NOT NULL default '0',
-                mingrade real NOT NULL default '0'
-            );
-        ");
-        $success = $success && modify_database('',
-            "CREATE INDEX prefix_quiz_feedback_quizid_idx ON prefix_quiz_feedback (quizid);");
-            
-        $success = $success && execute_sql("
-            INSERT INTO {$CFG->prefix}quiz_feedback (quizid, feedbacktext, maxgrade, mingrade)
-            SELECT id, '', grade + 1, 0 FROM {$CFG->prefix}quiz;
-        ");
-    }
-    
-    if ($success && $oldversion < 2006082400) {
-        $success = $success && table_column('question_sessions', 'comment', 'manualcomment', 'text', '', '', '');
-    }
-
-    if ($success && $oldversion < 2006091900) {
-        $success = $success && table_column('question_dataset_items', 'number', 'itemnumber', 'integer');
-    }
-
-    if ($success && $oldversion < 2006091901) {
-        $success = $success && table_column('question', 'commentarytext', 'generalfeedback', 'text', '', '', '');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return $success;
-}
-
-?>
diff --git a/mod/quiz/jstimer.php b/mod/quiz/jstimer.php
deleted file mode 100644 (file)
index dc3183b..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php // $Id$
-// QuizTimer main routines.
-// This will produce a floating timer that counts
-// how much time is left to answer the quiz.
-//
-defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
-?>
-
-<script type="text/javascript">
-//<![CDATA[
-var timesup = "<?php print_string("timesup","quiz");?>";
-var quizclose = <?php echo ($quiz->timeclose - time()) - $timerstartvalue; ?>; // in seconds
-var quizTimerValue = <?php echo $timerstartvalue; ?>; // in seconds
-parseInt(quizTimerValue);
-
-// @EC PF : client time when page was opened
-var ec_page_start = new Date().getTime();
-// @EC PF : client time when quiz should end
-var ec_quiz_finish = ec_page_start + <?php echo ($timerstartvalue * 1000); ?>;
-
-//]]>
-</script>
-<div id="timer">
-<!--EDIT BELOW CODE TO YOUR OWN MENU-->
-<table class="generalbox" border="0" cellpadding="0" cellspacing="0" style="width:150px;">
-<tr>
-    <td class="generalboxcontent" bgcolor="#ffffff" width="100%">
-    <table class="generaltable" border="0" width="150" cellspacing="0" cellpadding="0">
-    <tr>
-        <th class="generaltableheader" width="100%" scope="col"><?php print_string("timeleft","quiz");?></th>
-    </tr>
-    <tr>
-        <td id="QuizTimer" class="generaltablecell" align="center" width="100%">
-        <form id="clock"><div><input onfocus="blur()" type="text" id="time"
-        style="background-color: transparent; border: none; width: 70%; font-family: sans-serif; font-size: 14pt; font-weight: bold; text-align: center;" />
-        </div>
-        </form>
-        </td>
-    </tr>
-    </table>
-    </td>
-</tr>
-</table>
-<!--END OF EDIT-->
-</div>
-<script type="text/javascript">
-//<![CDATA[
-
-var timerbox = document.getElementById('timer');
-var theTimer = document.getElementById('QuizTimer');
-var theTop = 100;
-var old = theTop;
-
-movecounter(timerbox);
-
-document.onload = countdown_clock(theTimer);
-//]]>
-</script>
diff --git a/mod/quiz/protect_js.php b/mod/quiz/protect_js.php
deleted file mode 100644 (file)
index a6f9c47..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.'); 
-
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Copyright (C) 2004  Education Promoting Center, Yamaguchi University  //
-//                     http://www.epc.yamaguchi-u.ac.jp                  //
-//                                                                       //
-// This program is free software; you can redistribute it and/or modify  //
-// it under the terms of the GNU General Public License as published by  //
-// the Free Software Foundation; either version 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program is distributed in the hope that it will be useful,       //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
-// GNU General Public License for more details:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-?>
-
-<style media="print">body {display:none}</style>
-
-<script type="text/javascript">
-//<![CDATA[
-
-var message = "<?php print_string('functiondisabled'); ?>";
-
-function click(e) {
-    if (document.all) {
-        if (event.button==1) {
-           return false;
-        }
-        if (event.button==2) {
-           alert(message);
-           return false;
-        }
-    }
-    if (document.layers) {
-        if (e.which > 1) {
-           alert(message);
-           return false;
-        }
-    }
-}
-if (document.layers) {
-    document.captureEvents(Event.MOUSEDOWN);
-}
-document.onmousedown=click;
-document.oncontextmenu=new Function("alert(message);return false")
-
-document.write(unescape("%3C%53%43%52%49%50%54%20%4C%41%4E%47%55%41%47%45%3D%22%4A%61%76%61%53%63%72%69%70%74%22%3E%3C%21%2D%2D%0D%0A%68%70%5F%6F%6B%3D%74%72%75%65%3B%66%75%6E%63%74%69%6F%6E%20%68%70%5F%64%30%30%28%73%29%7B%69%66%28%21%68%70%5F%6F%6B%29%72%65%74%75%72%6E%3B%64%6F%63%75%6D%65%6E%74%2E%77%72%69%74%65%28%73%29%7D%2F%2F%2D%2D%3E%3C%2F%53%43%52%49%50%54%3E"));
-
-hp_d00(unescape("%3C%53%43%52%49%50%54%20%4C%41%4E%47%55%41%47%45%3D%22%4A%61%76%61%53%63%72%69%70%74%22%3E%3C%21%2D%2D%0D%0A%66%75%6E%63%74%69%6F%6E%20%68%70%5F%6E%65%28%29%7B%72%65%74%75%72%6E%20%74%72%75%65%7D%6F%6E%65%72%72%6F%72%3D%68%70%5F%6E%65%3B%66%75%6E%63%74%69%6F%6E%20%68%70%5F%64%6E%28%61%29%7B%72%65%74%75%72%6E%20%66%61%6C%73%65%7D%3B%66%75%6E%63%74%69%6F%6E%20%68%70%5F%64%65%28%65%29%7B%72%65%74%75%72%6E%28%65%2E%74%61%72%67%65%74%2E%74%61%67%4E%61%6D%65%21%3D%6E%75%6C%6C%26%26%65%2E%74%61%72%67%65%74%2E%74%61%67%4E%61%6D%65%2E%73%65%61%72%63%68%28%27%5E%28%49%4E%50%55%54%7C%54%45%58%54%41%52%45%41%7C%42%55%54%54%4F%4E%7C%53%45%4C%45%43%54%29%24%27%29%21%3D%2D%31%29%7D%3B%66%75%6E%63%74%69%6F%6E%20%68%70%5F%6D%64%28%65%29%7B%69%66%28%65%2E%77%68%69%63%68%3D%3D%31%29%7B%77%69%6E%64%6F%77%2E%63%61%70%74%75%72%65%45%76%65%6E%74%73%28%45%76%65%6E%74%2E%4D%4F%55%53%45%4D%4F%56%45%29%3B%77%69%6E%64%6F%77%2E%6F%6E%6D%6F%75%73%65%6D%6F%76%65%3D%68%70%5F%64%6E%7D%7D%66%75%6E%63%74%69%6F%6E%20%68%70%5F%6D%75%28%65%29%7B%69%66%28%65%2E%77%68%69%63%68%3D%3D%31%29%7B%77%69%6E%64%6F%77%2E%72%65%6C%65%61%73%65%45%76%65%6E%74%73%28%45%76%65%6E%74%2E%4D%4F%55%53%45%4D%4F%56%45%29%3B%77%69%6E%64%6F%77%2E%6F%6E%6D%6F%75%73%65%6D%6F%76%65%3D%6E%75%6C%6C%7D%7D%69%66%28%6E%61%76%69%67%61%74%6F%72%2E%61%70%70%4E%61%6D%65%2E%69%6E%64%65%78%4F%66%28%27%49%6E%74%65%72%6E%65%74%20%45%78%70%6C%6F%72%65%72%27%29%3D%3D%2D%31%7C%7C%28%6E%61%76%69%67%61%74%6F%72%2E%75%73%65%72%41%67%65%6E%74%2E%69%6E%64%65%78%4F%66%28%27%4D%53%49%45%27%29%21%3D%2D%31%26%26%64%6F%63%75%6D%65%6E%74%2E%61%6C%6C%2E%6C%65%6E%67%74%68%21%3D%30%29%29%7B%69%66%28%64%6F%63%75%6D%65%6E%74%2E%61%6C%6C%29%7B%64%6F%63%75%6D%65%6E%74%2E%6F%6E%73%65%6C%65%63%74%73%74%61%72%74%3D%68%70%5F%64%6E%7D%65%6C%73%65%20%69%66%28%64%6F%63%75%6D%65%6E%74%2E%6C%61%79%65%72%73%29%7B%77%69%6E%64%6F%77%2E%63%61%70%74%75%72%65%45%76%65%6E%74%73%28%45%76%65%6E%74%2E%4D%4F%55%53%45%55%50%7C%45%76%65%6E%74%2E%4D%4F%55%53%45%44%4F%57%4E%29%3B%77%69%6E%64%6F%77%2E%6F%6E%6D%6F%75%73%65%64%6F%77%6E%3D%68%70%5F%6D%64%3B%77%69%6E%64%6F%77%2E%6F%6E%6D%6F%75%73%65%75%70%3D%68%70%5F%6D%75%7D%65%6C%73%65%20%69%66%28%64%6F%63%75%6D%65%6E%74%2E%67%65%74%45%6C%65%6D%65%6E%74%42%79%49%64%26%26%21%64%6F%63%75%6D%65%6E%74%2E%61%6C%6C%29%7B%64%6F%63%75%6D%65%6E%74%2E%6F%6E%6D%6F%75%73%65%64%6F%77%6E%3D%68%70%5F%64%65%7D%7D%69%66%28%77%69%6E%64%6F%77%2E%6C%6F%63%61%74%69%6F%6E%2E%68%72%65%66%2E%73%75%62%73%74%72%69%6E%67%28%30%2C%34%29%3D%3D%22%66%69%6C%65%22%29%77%69%6E%64%6F%77%2E%6C%6F%63%61%74%69%6F%6E%3D%22%61%62%6F%75%74%3A%62%6C%61%6E%6B%22%3B%66%75%6E%63%74%69%6F%6E%20%68%70%5F%6E%6C%73%28%29%7B%77%69%6E%64%6F%77%2E%73%74%61%74%75%73%3D%22%22%3B%73%65%74%54%69%6D%65%6F%75%74%28%22%68%70%5F%6E%6C%73%28%29%22%2C%31%30%29%7D%68%70%5F%6E%6C%73%28%29%3B%66%75%6E%63%74%69%6F%6E%20%68%70%5F%64%70%31%28%29%7B%66%6F%72%28%69%3D%30%3B%69%3C%64%6F%63%75%6D%65%6E%74%2E%61%6C%6C%2E%6C%65%6E%67%74%68%3B%69%2B%2B%29%7B%69%66%28%64%6F%63%75%6D%65%6E%74%2E%61%6C%6C%5B%69%5D%2E%73%74%79%6C%65%2E%76%69%73%69%62%69%6C%69%74%79%21%3D%22%68%69%64%64%65%6E%22%29%7B%64%6F%63%75%6D%65%6E%74%2E%61%6C%6C%5B%69%5D%2E%73%74%79%6C%65%2E%76%69%73%69%62%69%6C%69%74%79%3D%22%68%69%64%64%65%6E%22%3B%64%6F%63%75%6D%65%6E%74%2E%61%6C%6C%5B%69%5D%2E%69%64%3D%22%68%70%5F%69%64%22%7D%7D%7D%3B%66%75%6E%63%74%69%6F%6E%20%68%70%5F%64%70%32%28%29%7B%66%6F%72%28%69%3D%30%3B%69%3C%64%6F%63%75%6D%65%6E%74%2E%61%6C%6C%2E%6C%65%6E%67%74%68%3B%69%2B%2B%29%7B%69%66%28%64%6F%63%75%6D%65%6E%74%2E%61%6C%6C%5B%69%5D%2E%69%64%3D%3D%22%68%70%5F%69%64%22%29%64%6F%63%75%6D%65%6E%74%2E%61%6C%6C%5B%69%5D%2E%73%74%79%6C%65%2E%76%69%73%69%62%69%6C%69%74%79%3D%22%22%7D%7D%3B%77%69%6E%64%6F%77%2E%6F%6E%62%65%66%6F%72%65%70%72%69%6E%74%3D%68%70%5F%64%70%31%3B%77%69%6E%64%6F%77%2E%6F%6E%61%66%74%65%72%70%72%69%6E%74%3D%68%70%5F%64%70%32%3B%64%6F%63%75%6D%65%6E%74%2E%77%72%69%74%65%28%27%3C%73%74%79%6C%65%20%74%79%70%65%3D%22%74%65%78%74%2F%63%73%73%22%20%6D%65%64%69%61%3D%22%70%72%69%6E%74%22%3E%3C%21%2D%2D%62%6F%64%79%7B%64%69%73%70%6C%61%79%3A%6E%6F%6E%65%7D%2D%2D%3E%3C%2F%73%74%79%6C%65%3E%27%29%3B%66%75%6E%63%74%69%6F%6E%20%68%70%5F%64%63%28%29%7B%68%70%5F%74%61%2E%63%72%65%61%74%65%54%65%78%74%52%61%6E%67%65%28%29%2E%65%78%65%63%43%6F%6D%6D%61%6E%64%28%22%43%6F%70%79%22%29%3B%73%65%74%54%69%6D%65%6F%75%74%28%22%68%70%5F%64%63%28%29%22%2C%33%30%30%29%7D%69%66%28%6E%61%76%69%67%61%74%6F%72%2E%61%70%70%4E%61%6D%65%2E%69%6E%64%65%78%4F%66%28%27%49%6E%74%65%72%6E%65%74%20%45%78%70%6C%6F%72%65%72%27%29%3D%3D%2D%31%7C%7C%28%6E%61%76%69%67%61%74%6F%72%2E%75%73%65%72%41%67%65%6E%74%2E%69%6E%64%65%78%4F%66%28%27%4D%53%49%45%27%29%21%3D%2D%31%26%26%64%6F%63%75%6D%65%6E%74%2E%61%6C%6C%2E%6C%65%6E%67%74%68%21%3D%30%29%29%7B%69%66%28%64%6F%63%75%6D%65%6E%74%2E%61%6C%6C%26%26%6E%61%76%69%67%61%74%6F%72%2E%75%73%65%72%41%67%65%6E%74%2E%69%6E%64%65%78%4F%66%28%27%4F%70%65%72%61%27%29%3D%3D%2D%31%29%7B%64%6F%63%75%6D%65%6E%74%2E%77%72%69%74%65%28%27%3C%64%69%76%20%73%74%79%6C%65%3D%22%70%6F%73%69%74%69%6F%6E%3A%61%62%73%6F%6C%75%74%65%3B%6C%65%66%74%3A%2D%31%30%30%30%70%78%3B%74%6F%70%3A%2D%31%30%30%30%70%78%22%3E%3C%69%6E%70%75%74%20%74%79%70%65%3D%22%74%65%78%74%61%72%65%61%22%20%6E%61%6D%65%3D%22%68%70%5F%74%61%22%20%76%61%6C%75%65%3D%22%20%22%20%73%74%79%6C%65%3D%22%76%69%73%69%62%69%6C%69%74%79%3A%68%69%64%64%65%6E%22%3E%3C%2F%64%69%76%3E%27%29%3B%68%70%5F%64%63%28%29%7D%7D%66%75%6E%63%74%69%6F%6E%20%68%70%5F%6E%64%64%28%29%7B%72%65%74%75%72%6E%20%66%61%6C%73%65%7D%64%6F%63%75%6D%65%6E%74%2E%6F%6E%64%72%61%67%73%74%61%72%74%3D%68%70%5F%6E%64%64%3B%2F%2F%2D%2D%3E%3C%2F%53%43%52%49%50%54%3E"));
-
-//]]>
-</script>
diff --git a/mod/resource/db/mysql.php b/mod/resource/db/mysql.php
deleted file mode 100644 (file)
index a68a22d..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function resource_upgrade($oldversion) {
-// This function does anything necessary to upgrade
-// older versions to match current functionality
-
-    global $CFG;
-
-    if ($oldversion < 2003082000) {
-        table_column("resource", "course", "course", "integer", "10", "unsigned", "0");
-    }
-
-    if ($oldversion < 2004013101) {
-        modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('resource', 'update', 'resource', 'name');");
-        modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('resource', 'add', 'resource', 'name');");
-    }
-
-    if ($oldversion < 2004071000) {
-        table_column("resource", "", "popup", "text", "", "", "", "", "alltext");
-        if ($resources = get_records_select("resource", "type='3' OR type='5'", "", "id, alltext")) {
-            foreach ($resources as $resource) {
-                $resource->popup = addslashes($resource->alltext);
-                $resource->alltext = "";
-                if (!update_record("resource", $resource)) {
-                    notify("Error updating popup field for resource id = $resource->id");
-                }                
-            }
-        }
-        require_once("$CFG->dirroot/course/lib.php");
-        rebuild_course_cache();
-    }
-
-    if ($oldversion < 2004071300) {
-        table_column("resource", "", "options", "varchar", "255", "", "", "", "popup");
-    }
-
-    if ($oldversion < 2004071303) {
-        table_column("resource", "type", "type", "varchar", "30", "", "", "", "");
-
-        modify_database("", "UPDATE prefix_resource SET type='reference' WHERE type='1';");
-        modify_database("", "UPDATE prefix_resource SET type='file', options='frame' WHERE type='2';");
-        modify_database("", "UPDATE prefix_resource SET type='file' WHERE type='3';");
-        modify_database("", "UPDATE prefix_resource SET type='text', options='0' WHERE type='4';");
-        modify_database("", "UPDATE prefix_resource SET type='file' WHERE type='5';");
-        modify_database("", "UPDATE prefix_resource SET type='html' WHERE type='6';");
-        modify_database("", "UPDATE prefix_resource SET type='file' WHERE type='7';");
-        modify_database("", "UPDATE prefix_resource SET type='text', options='3' WHERE type='8';");
-        modify_database("", "UPDATE prefix_resource SET type='directory' WHERE type='9';");
-    }
-
-    if ($oldversion < 2004080801) {
-        modify_database("", "UPDATE prefix_resource SET alltext=reference,type='html' WHERE type='reference';");
-        rebuild_course_cache();
-    }
-
-    if ($oldversion < 2004111200) { //drop first to avoid conflicts when upgrading
-        execute_sql("ALTER TABLE {$CFG->prefix}resource DROP INDEX course;",false);
-
-        modify_database('','ALTER TABLE prefix_resource ADD INDEX course (course);');
-    }
-
-    if ($oldversion < 2005041100) { // replace wiki-like with markdown
-        include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
-        $wtm = new WikiToMarkdown();
-        $wtm->update( 'resource','alltext','options' );
-    }
-    
-    if ($oldversion < 2006042800) {
-        execute_sql("UPDATE {$CFG->prefix}resource SET reference='' WHERE reference IS NULL");
-        table_column('resource','reference','reference','varchar','255','','','not null');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-
-?>
diff --git a/mod/resource/db/postgres7.php b/mod/resource/db/postgres7.php
deleted file mode 100644 (file)
index 1a9ca38..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function resource_upgrade($oldversion) {
-// This function does anything necessary to upgrade
-// older versions to match current functionality
-    
-    global $CFG ;
-
-    if ($oldversion < 2004013101) {
-        modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('resource', 'update', 'resource', 'name');");
-        modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('resource', 'add', 'resource', 'name');");
-    }
-
-    if ($oldversion < 2004071000) {
-        table_column("resource", "", "popup", "text", "", "", "", "", "alltext");
-        if ($resources = get_records_select("resource", "type='3' OR type='5'", "", "id, alltext")) {
-            foreach ($resources as $resource) {
-                $resource->popup = addslashes($resource->alltext);
-                $resource->alltext = "";
-                if (!update_record("resource", $resource)) {
-                    notify("Error updating popup field for resource id = $resource->id");
-                }                
-            }
-        }
-        require_once("$CFG->dirroot/course/lib.php");
-        rebuild_course_cache();
-    }
-    
-    if ($oldversion < 2004071300) {
-        table_column("resource", "", "options", "varchar", "255", "", "", "", "popup");
-    }
-
-    if ($oldversion < 2004071303) {
-        table_column("resource", "type", "type", "varchar", "30", "", "", "", "");
-
-        modify_database("", "UPDATE prefix_resource SET type='reference' WHERE type='1';");
-        modify_database("", "UPDATE prefix_resource SET type='file', options='frame' WHERE type='2';");
-        modify_database("", "UPDATE prefix_resource SET type='file' WHERE type='3';");
-        modify_database("", "UPDATE prefix_resource SET type='text', options='0' WHERE type='4';");
-        modify_database("", "UPDATE prefix_resource SET type='file' WHERE type='5';");
-        modify_database("", "UPDATE prefix_resource SET type='html' WHERE type='6';");
-        modify_database("", "UPDATE prefix_resource SET type='file' WHERE type='7';");
-        modify_database("", "UPDATE prefix_resource SET type='text', options='3' WHERE type='8';");
-        modify_database("", "UPDATE prefix_resource SET type='directory' WHERE type='9';");
-    }
-
-    if ($oldversion < 2004080801) {
-        modify_database("", "UPDATE prefix_resource SET alltext=reference,type='html' WHERE type='reference';");
-        rebuild_course_cache();
-    }
-
-    if ($oldversion < 2004111200) {//drop first to avoid conflicts when upgrading
-        execute_sql("DROP INDEX {$CFG->prefix}resource_course_idx;",false);
-
-        modify_database('','CREATE INDEX prefix_resource_course_idx ON prefix_resource (course);');
-    }
-    
-    if ($oldversion < 2005041100) { // replace wiki-like with markdown
-        include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
-        $wtm = new WikiToMarkdown();
-        $wtm->update( 'resource','alltext','options' );
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-
-?>
diff --git a/mod/scorm/db/mysql.php b/mod/scorm/db/mysql.php
deleted file mode 100755 (executable)
index b9c6668..0000000
+++ /dev/null
@@ -1,238 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function scorm_upgrade($oldversion) {
-/// This function does anything necessary to upgrade
-/// older versions to match current functionality
-    global $CFG;
-    if ($oldversion < 2004033000) {
-        table_column("scorm", "", "auto", "TINYINT", "1", "UNSIGNED", "0", "NOT NULL", "summary"); 
-    }
-    if ($oldversion < 2004040900) {
-        table_column("scorm_sco_users", "", "cmi_core_score_raw", "FLOAT", "3", "", "0", "NOT NULL", "cmi_core_session_time");
-    }
-    if ($oldversion < 2004061800) {
-        table_column("scorm", "", "popup", "VARCHAR", "255", "", "", "NOT NULL", "auto");
-        table_column("scorm", "reference", "reference", "VARCHAR", "255", "", "", "NOT NULL");
-    }
-    if ($oldversion < 2004070800) {
-        table_column("scorm_scoes", "", "datafromlms", "TEXT", "", "", "", "NOT NULL", "title");
-        modify_database("", "ALTER TABLE `{$CFG->prefix}scorm_sco_users` DROP `cmi_launch_data`;");
-    }
-    if ($oldversion < 2004071700) {
-        table_column("scorm_scoes", "", "manifest", "VARCHAR", "255", "", "", "NOT NULL", "scorm");
-        table_column("scorm_scoes", "", "organization", "VARCHAR", "255", "", "", "NOT NULL", "manifest");
-    }
-    if ($oldversion < 2004071900) {
-        table_column("scorm", "", "maxgrade", "FLOAT", "3", "", "0", "NOT NULL", "reference");
-        table_column("scorm", "", "grademethod", "TINYINT", "2", "", "0", "NOT NULL", "maxgrade");
-    }
-
-    if ($oldversion < 2004111200) {
-        execute_sql("ALTER TABLE {$CFG->prefix}scorm DROP INDEX course;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}scorm_scoes DROP INDEX scorm;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}scorm_sco_users DROP INDEX scormid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}scorm_sco_users DROP INDEX userid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}scorm_sco_users DROP INDEX scoid;",false);
-
-        modify_database('','ALTER TABLE prefix_scorm ADD INDEX course (course);');
-        modify_database('','ALTER TABLE prefix_scorm_scoes ADD INDEX scorm (scorm);');
-        modify_database('','ALTER TABLE prefix_scorm_sco_users ADD INDEX scormid (scormid);');
-        modify_database('','ALTER TABLE prefix_scorm_sco_users ADD INDEX userid (userid);');
-        modify_database('','ALTER TABLE prefix_scorm_sco_users ADD INDEX scoid (scoid);');
-    }
-    
-    if ($oldversion < 2005031300) {
-        table_column("scorm_scoes", "", "prerequisites", "VARCHAR", "200", "", "", "NOT NULL", "title");
-        table_column("scorm_scoes", "", "maxtimeallowed", "VARCHAR", "13", "", "", "NOT NULL", "prerequisites");
-        table_column("scorm_scoes", "", "timelimitaction", "VARCHAR", "19", "", "", "NOT NULL", "maxtimeallowed");
-        table_column("scorm_scoes", "", "masteryscore", "VARCHAR", "200", "", "", "NOT NULL", "datafromlms");
-
-        $oldscoes = get_records_select("scorm_scoes","1","id ASC");
-        table_column("scorm_scoes", "type", "scormtype", "VARCHAR", "5", "", "", "NOT NULL");
-        if(!empty($oldscoes)) {
-            foreach ($oldscoes as $sco) {
-                $sco->scormtype = $sco->type;
-                unset($sco->type);
-                update_record("scorm_scoes",$sco);
-            }
-        }
-
-        execute_sql("CREATE TABLE {$CFG->prefix}scorm_scoes_track (
-                        id int(10) unsigned NOT NULL auto_increment,
-                        userid int(10) unsigned NOT NULL default '0',
-                        scormid int(10) NOT NULL default '0',
-                        scoid int(10) unsigned NOT NULL default '0',
-                        element varchar(255) NOT NULL default '',
-                        value longtext NOT NULL default '',
-                        PRIMARY KEY  (userid, scormid, scoid, element),
-                        UNIQUE (userid, scormid, scoid, element),
-                        KEY userdata (userid, scormid, scoid),
-                        KEY id (id)
-                    ) TYPE=MyISAM;",false); 
-    
-        $oldtrackingdata = get_records_select("scorm_sco_users","1","id ASC");
-        $oldelements = array ('cmi_core_lesson_location',
-                              'cmi_core_lesson_status',
-                              'cmi_core_exit',
-                              'cmi_core_total_time',
-                              'cmi_core_score_raw',
-                              'cmi_suspend_data');
-
-        if(!empty($oldtrackingdata)) {
-            foreach ($oldtrackingdata as $oldtrack) {
-                $newtrack = '';
-                $newtrack->userid = $oldtrack->userid;
-                $newtrack->scormid = $oldtrack->scormid;
-                $newtrack->scoid = $oldtrack->scoid;
-
-                foreach ( $oldelements as $element) {
-                    $newtrack->element = $element;
-                    $newtrack->value = $oldtrack->$element;
-                    if ($newtrack->value == NULL) {
-                        $newtrack->value = '';
-                    }
-                    insert_record("scorm_scoes_track",$newtrack,false);
-                }
-            }
-        }
-
-        modify_database('',"DROP TABLE prefix_scorm_sco_users");
-        modify_database('',"INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('scorm', 'review', 'resource', 'name')");
-    }
-    
-    if ($oldversion < 2005040200) {
-        execute_sql('ALTER TABLE `'.$CFG->prefix.'scorm` DROP `popup`');    // Old field
-    }
-
-    if ($oldversion < 2005040400) {
-       table_column("scorm_scoes", "", "parameters", "VARCHAR", "255", "", "", "NOT NULL", "launch");
-    }
-    
-    if ($oldversion < 2005040700) {
-        execute_sql("ALTER TABLE {$CFG->prefix}scorm_scoes_track DROP PRIMARY KEY;");
-        execute_sql("ALTER TABLE {$CFG->prefix}scorm_scoes_track DROP KEY userdata;");
-        execute_sql("ALTER TABLE {$CFG->prefix}scorm_scoes_track DROP INDEX userid");
-        modify_database('','ALTER TABLE prefix_scorm_scoes_track ADD UNIQUE track (userid,scormid,scoid,element);');
-        modify_database('','ALTER TABLE prefix_scorm_scoes_track ADD PRIMARY KEY id (id);');
-        modify_database('','ALTER TABLE prefix_scorm_scoes_track ADD INDEX scormid (scormid);');
-        modify_database('','ALTER TABLE prefix_scorm_scoes_track ADD INDEX userid (userid);');
-        modify_database('','ALTER TABLE prefix_scorm_scoes_track ADD INDEX scoid (scoid);');
-        modify_database('','ALTER TABLE prefix_scorm_scoes_track ADD INDEX element (element);');
-        execute_sql("ALTER TABLE {$CFG->prefix}scorm_scoes_track DROP INDEX id;");
-        table_column("scorm_scoes", "timelimitaction", "timelimitaction", "VARCHAR", "19", "", "", "NOT NULL");
-        table_column("scorm_scoes", "scormtype", "scormtype", "VARCHAR", "5", "", "", "NOT NULL");
-    }
-    
-    if ($oldversion < 2005041500) {
-        if ($scorms = get_records_select("scorm","1","id ASC")) {
-            foreach ($scorms as $scorm) {
-                if (strlen($scorm->datadir) == 14) {
-                    $basedir = $CFG->dataroot.'/'.$scorm->course;
-                    $scormdir = '/moddata/scorm';
-                    rename($basedir.$scormdir.$scorm->datadir,$basedir.$scormdir.'/'.$scorm->id);
-                }
-            }
-        }
-        execute_sql('ALTER TABLE `'.$CFG->prefix.'scorm` DROP `datadir`');    // Old field
-    }
-
-    if ($oldversion < 2005041600) {
-       table_column("scorm", "", "version", "VARCHAR", "9", "", "SCORM_1.2", "NOT NULL", "reference");
-    }
-
-    if ($oldversion < 2005042700) {
-        $trackingdata = get_records_select("scorm_scoes_track","1","id ASC");
-        if (!empty($trackingdata)) {
-            $oldelements = array ('cmi_core_lesson_location',
-                                  'cmi_core_lesson_status',
-                                  'cmi_core_exit',
-                                  'cmi_core_total_time',
-                                  'cmi_core_score_raw',
-                                  'cmi_suspend_data');
-            $newelements = array ('cmi.core.lesson_location',
-                                  'cmi.core.lesson_status',
-                                  'cmi.core.exit',
-                                  'cmi.core.total_time',
-                                  'cmi.core.score.raw',
-                                  'cmi.suspend_data');
-            foreach ($trackingdata as $track) {
-                if (($pos = array_search($track->element,$oldelements)) !== false) {
-                    $track->element = $newelements[$pos];
-                    update_record('scorm_scoes_track',$track);
-                }
-            }
-        }
-    }
-
-    if ($oldversion < 2005042800) {
-       table_column("scorm", "", "browsemode", "TINYINT", "2", "", "1", "NOT NULL", "summary");
-    }
-
-    if ($oldversion < 2005050800) {
-       table_column("scorm", "", "width", "INT", "10", "", "800", "NOT NULL", "auto");
-       table_column("scorm", "", "height", "INT", "10", "", "600", "NOT NULL", "width");
-    }
-
-    if ($oldversion < 2005052200) {
-       table_column("scorm_scoes_track", "", "timemodified", "INT", "10", "UNSIGNED", "0", "NOT NULL", "value");
-    }
-    
-    if ($oldversion < 2005052700) {
-       table_column("scorm", "", "popup", "TINYINT", "1", "UNSIGNED", "0", "NOT NULL", "auto");
-    }
-    
-    if ($oldversion < 2005070600) {
-        table_column("scorm", "", "hidetoc", "TINYINT", "1", "UNSIGNED", "0", "NOT NULL", "browsemode"); 
-        $scorms = get_records_select("scorm","1","id ASC");
-        table_column("scorm", "browsemode", "hidebrowse", "TINYINT", "1", "UNSIGNED", "0", "NOT NULL", "");
-        if (!empty($scorms)) {
-            foreach($scorms as $scorm) {
-                if ($scorm->browsemode = 1) {
-                    $scorm->hidebrowse = 0;
-                } else {
-                    $scorm->hidebrowse = 1;
-                }
-                update_record('scorm',$scorm);
-            }
-        }
-    }
-
-    if ($oldversion < 2005092500) {
-        table_column("scorm", "", "hidenav", "TINYINT", "1", "UNSIGNED", "0", "NOT NULL", "hidetoc"); 
-        table_column("scorm", "", "options", "VARCHAR", "255", "", "", "NOT NULL","popup");
-    }
-
-    if ($oldversion < 2005092600) {
-        table_column("scorm_scoes_track", "", "attempt", "INT", "10", "UNSIGNED", "1", "NOT NULL", "scoid"); 
-        execute_sql("ALTER TABLE {$CFG->prefix}scorm_scoes_track DROP INDEX track");
-        modify_database('','ALTER TABLE prefix_scorm_scoes_track ADD UNIQUE track (userid,scormid,scoid,attempt,element);');
-    }
-
-    if ($oldversion < 2005102800) {
-        table_column("scorm", "", "maxattempt", "INT", "10", "UNSIGNED", "1", "NOT NULL", "maxgrade"); 
-    }
-
-    if ($oldversion < 2006021400) {    //some people have this werid key - see bug 4742
-        execute_sql("ALTER TABLE {$CFG->prefix}scorm_scoes_track DROP INDEX elemeny;",false);  // do it silently
-        execute_sql("ALTER TABLE {$CFG->prefix}scorm_scoes_track ADD INDEX element(element(255));",false);
-    }
-
-    if ($oldversion < 2006102600) {
-        table_column("scorm", "", "skipview", "TINYINT", "1", "UNSIGNED", "1", "NOT NULL", "launch"); 
-    }
-
-    if ($oldversion < 2006102702) {   /// A month in advance!
-        execute_sql("DELETE FROM {$CFG->prefix}log_display WHERE module = 'scorm' AND action = 'review' AND mtable = 'resource' AND field = 'name';", false);  // MDL-6516
-        execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('scorm', 'review', 'scorm', 'name');", false);
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-?>
diff --git a/mod/scorm/db/postgres7.php b/mod/scorm/db/postgres7.php
deleted file mode 100755 (executable)
index 9398ad7..0000000
+++ /dev/null
@@ -1,261 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function scorm_upgrade($oldversion) {
-// This function does anything necessary to upgrade
-// older versions to match current functionality
-    global $CFG;
-    if ($oldversion < 2004033000) {
-        table_column("scorm", "", "auto", "integer", "1", "", "0", "NOT NULL", "summary"); 
-    }
-    if ($oldversion < 2004040900) {
-        table_column("scorm_sco_users", "", "cmi_core_score_raw", "real", "3", "", "0", "NOT NULL", "cmi_core_session_time");
-    }
-    if ($oldversion < 2004061800) {
-        table_column("scorm", "", "popup", "varchar", "255", "", "", "NOT NULL", "auto");
-        table_column("scorm", "reference", "reference", "varchar", "255", "", "", "NOT NULL");
-    }
-    if ($oldversion < 2004070800) {
-        table_column("scorm_scoes", "", "datafromlms", "TEXT", "", "", "", "NOT NULL", "title");
-        modify_database("", "ALTER TABLE {$CFG->prefix}scorm_sco_users DROP cmi_launch_data;");
-    }
-    if ($oldversion < 2004071700) {
-        table_column("scorm_scoes", "", "manifest", "VARCHAR", "255", "", "", "NOT NULL", "scorm");
-        table_column("scorm_scoes", "", "organization", "VARCHAR", "255", "", "", "NOT NULL", "manifest");
-    }
-    if ($oldversion < 2004071900) {
-        table_column("scorm", "", "maxgrade", "real", "3", "", "0", "NOT NULL", "reference");
-        table_column("scorm", "", "grademethod", "integer", "", "", "0", "NOT NULL", "maxgrade");
-    }
-    
-    if ($oldversion < 2004111200) {
-        execute_sql("DROP INDEX {$CFG->prefix}scorm_course_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}scorm_scoes_scorm_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}scorm_sco_users_userid_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}scorm_sco_users_scormid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}scorm_sco_users_scoid_idx;",false);
-
-        modify_database('','CREATE INDEX prefix_scorm_course_idx ON prefix_scorm (course);');
-        modify_database('','CREATE INDEX prefix_scorm_scoes_scorm_idx ON prefix_scorm_scoes (scorm);');
-        modify_database('','CREATE INDEX prefix_scorm_sco_users_userid_idx ON  prefix_scorm_sco_users (userid);');
-        modify_database('','CREATE INDEX prefix_scorm_sco_users_scormid_idx ON  prefix_scorm_sco_users (scormid);');
-        modify_database('','CREATE INDEX prefix_scorm_sco_users_scoid_idx ON  prefix_scorm_sco_users (scoid);');
-    }
-    
-    if ($oldversion < 2005031300) {
-        table_column("scorm_scoes", "", "prerequisites", "VARCHAR", "200", "", "", "NOT NULL", "title");
-        table_column("scorm_scoes", "", "maxtimeallowed", "VARCHAR", "13", "", "", "NOT NULL", "prerequisites");
-        table_column("scorm_scoes", "", "timelimitaction", "VARCHAR", "19", "", "", "NOT NULL", "maxtimeallowed");
-        table_column("scorm_scoes", "", "masteryscore", "VARCHAR", "200", "", "", "NOT NULL", "datafromlms");
-
-        $oldscoes = get_records_select("scorm_scoes",null,"id ASC");
-        table_column("scorm_scoes", "type", "scormtype", "VARCHAR", "5", "", "", "NOT NULL");
-        if(!empty($oldscoes)) {
-            foreach ($oldscoes as $sco) {
-                $sco->scormtype = $sco->type;
-                unset($sco->type);
-                update_record("scorm_scoes",$sco);
-            }
-        }
-
-        execute_sql("CREATE TABLE {$CFG->prefix}scorm_scoes_track (
-                        id SERIAL,
-                        userid integer NOT NULL default '0',
-                        scormid integer NOT NULL default '0',
-                        scoid integer NOT NULL default '0',
-                        element varchar(255) NOT NULL default '',
-                        value text NOT NULL default '',
-                        PRIMARY KEY (userid, scormid, scoid, element),
-                        UNIQUE (userid, scormid, scoid, element)
-                   );",true); 
-        modify_database('','CREATE INDEX prefix_scorm_scoes_track_userdata_idx ON  prefix_scorm_scoes_track (userid, scormid, scoid);');
-    
-        $oldtracking = get_records_select('scorm_sco_users',null,'id ASC');
-        $oldelements = array ('cmi_core_lesson_location',
-                              'cmi_core_lesson_status',
-                              'cmi_core_exit',
-                              'cmi_core_total_time',
-                              'cmi_core_score_raw',
-                              'cmi_suspend_data');
-
-        if(!empty($oldtrackings)) {
-            foreach ($oldtrackings as $oldtrack) {
-                $newtrack = '';
-                $newtrack->userid = $oldtrack->userid;
-                $newtrack->scormid = $oldtrack->scormid;
-                $newtrack->scoid = $oldtrack->scoid;
-
-                foreach ( $oldelements as $element) {
-                    $newtrack->element = $element;
-                    $newtrack->value = $oldtrack->$element;
-                    if ($newtrack->value == NULL) {
-                        $newtrack->value = '';
-                    }
-                    insert_record('scorm_scoes_track',$newtrack,false);
-                }
-            }
-        }
-
-        modify_database('',"DROP TABLE prefix_scorm_sco_users");
-        modify_database('',"INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('resource', 'review', 'resource', 'name')");   // Wrong line!   See MDL-6516
-    }
-
-    if ($oldversion < 2005040200) {
-        execute_sql('ALTER TABLE '.$CFG->prefix.'scorm DROP popup');    // Old field
-    }
-    
-    if ($oldversion < 2005040400) {
-        table_column('scorm_scoes', '', 'parameters', 'VARCHAR', '255', '', '', 'NOT NULL', 'launch');
-    }
-    
-    if ($oldversion < 2005040700) {
-        //execute_sql('DROP PRIMARY KEY '.$CFG->prefix.'scorm_scoes_track_pkey;',false);
-        execute_sql('DROP INDEX '.$CFG->prefix.'scorm_scoes_track_userdata_idx;',false);
-        execute_sql('DROP INDEX '.$CFG->prefix.'scorm_scoes_track_userid_key;',false);
-        modify_database('','CREATE UNIQUE INDEX prefix_scorm_scoes_track_track_idx ON  prefix_scorm_scoes_track (userid, scormid, scoid, element);');
-        execute_sql('ALTER TABLE '.$CFG->prefix.'scorm_scoes_track ADD PRIMARY KEY ("id");',false);
-        modify_database('','CREATE INDEX prefix_scorm_scoes_track_scormid_idx ON  prefix_scorm_scoes_track (scormid);');
-        modify_database('','CREATE INDEX prefix_scorm_scoes_track_userid_idx ON  prefix_scorm_scoes_track (userid);');
-        modify_database('','CREATE INDEX prefix_scorm_scoes_track_scoid_idx ON  prefix_scorm_scoes_track (scoid);');
-        modify_database('','CREATE INDEX prefix_scorm_scoes_track_element_idx ON  prefix_scorm_scoes_track (element);');
-    }
-    
-    if ($oldversion < 2005041500) {
-        if ($scorms = get_records_select('scorm',null,'id ASC')) {
-            foreach ($scorms as $scorm) {
-                if (strlen($scorm->datadir) == 14) {
-                    $basedir = $CFG->dataroot.'/'.$scorm->course;
-                    $scormdir = '/moddata/scorm';
-                    rename($basedir.$scormdir.$scorm->datadir,$basedir.$scormdir.'/'.$scorm->id);
-                }
-            }
-        }
-        execute_sql('ALTER TABLE '.$CFG->prefix.'scorm DROP datadir');    // Old field
-    }
-    
-    if ($oldversion < 2005041600) {
-       table_column("scorm", "", "version", "VARCHAR", "9", "", "SCORM_1.2", "NOT NULL", "reference");
-    }
-
-    if ($oldversion < 2005042700) {
-        $trackingdata = get_records_select("scorm_scoes_track",null,"id ASC");
-        if (!empty($trackingdata)) {
-            $oldelements = array ('cmi_core_lesson_location',
-                                  'cmi_core_lesson_status',
-                                  'cmi_core_exit',
-                                  'cmi_core_total_time',
-                                  'cmi_core_score_raw',
-                                  'cmi_suspend_data');
-            $newelements = array ('cmi.core.lesson_location',
-                                  'cmi.core.lesson_status',
-                                  'cmi.core.exit',
-                                  'cmi.core.total_time',
-                                  'cmi.core.score.raw',
-                                  'cmi.suspend_data');
-            foreach ($trackingdata as $track) {
-                if (($pos = array_search($track->element,$oldelements)) !== false) {
-                    $track->element = $newelements[$pos];
-                    update_record('scorm_scoes_track',$track);
-                }
-            }
-        }
-    }
-
-    if ($oldversion < 2005042800) {
-       table_column("scorm", "", "browsemode", "integer", "", "", "1", "NOT NULL", "summary");
-    }
-
-    if ($oldversion < 2005050800) {
-       table_column("scorm", "", "width", "integer", "", "", "800", "NOT NULL", "auto");
-       table_column("scorm", "", "height", "integer", "", "", "600", "NOT NULL", "width");
-    }
-
-     if ($oldversion < 2005052200) {
-       table_column("scorm_scoes_track", "", "timemodified", "integer", "", "", "0", "NOT NULL", "value");
-    }
-    
-    if ($oldversion < 2005052301) { // Mass cleanup of bad upgrade scripts
-        execute_sql("DROP INDEX {$CFG->prefix}scorm_scoes_track_scormid_idx", false);
-        execute_sql("DROP INDEX {$CFG->prefix}scorm_scoes_track_userid_idx", false);
-        execute_sql("DROP INDEX {$CFG->prefix}scorm_scoes_track_scoid_idx", false);
-        modify_database('','CREATE INDEX prefix_scorm_scoes_track_scorm_idx ON  prefix_scorm_scoes_track (scormid);');
-        modify_database('','CREATE INDEX prefix_scorm_scoes_track_user_idx ON  prefix_scorm_scoes_track (userid);');
-        modify_database('','CREATE INDEX prefix_scorm_scoes_track_sco_idx ON  prefix_scorm_scoes_track (scoid);');
-        notify('The above errors can be ignored if the indexes already exists, its possible that it was cleaned up already before running this upgrade');
-        execute_sql("DROP INDEX {$CFG->prefix}scorm_scoes_track_track_idx", false);
-        modify_database('','ALTER TABLE ONLY prefix_scorm_scoes_track DROP CONSTRAINT prefix_scorm_scoes_track_pkey');
-        modify_database('','ALTER TABLE ONLY prefix_scorm_scoes_track ADD CONSTRAINT prefix_scorm_scoes_track_pkey PRIMARY KEY (id)');
-        modify_database('','ALTER TABLE ONLY prefix_scorm_scoes_track ADD UNIQUE (userid, scormid, scoid, element)');
-        modify_database('','ALTER TABLE prefix_scorm ALTER browsemode SET DEFAULT 0');
-        modify_database('','ALTER TABLE prefix_scorm DROP version');
-        notify('You can ignore the error above as version column does not exists, this will be properly upgraded later');
-        table_column('scorm_scoes','datafromlms','datafromlms','VARCHAR','255','','');
-        table_column('scorm_scoes','maxtimeallowed','maxtimeallowed','VARCHAR','19','','');
-    }
-
-    if ($oldversion < 2005062700) {
-       table_column("scorm", "", "popup", "integer", "", "", "0", "NOT NULL", "auto");
-    }
-    
-    if ($oldversion < 2005070600) {
-        table_column("scorm", "", "hidetoc", "integer", "", "", "0", "NOT NULL", "browsemode");
-        $scorms = get_records_select("scorm","","id ASC");
-        table_column("scorm", "browsemode", "hidebrowse", "integer", "", "", "0", "NOT NULL", "");
-        if (!empty($scorms)) {
-            foreach($scorms as $scorm) {
-                if ($scorm->browsemode = 1) {
-                    $scorm->hidebrowse = 0;
-                } else {
-                    $scorm->hidebrowse = 1;
-                }
-                update_record('scorm',$scorm);
-            }
-        }
-    }
-
-    if ($oldversion < 2005092500) {
-        table_column("scorm", "", "hidenav", "integer", "", "", "0", "NOT NULL", "hidetoc");
-        table_column("scorm", "", "options", "varchar", "255", "", "", "NOT NULL","popup");
-    }
-    
-    if ($oldversion < 2005092600) {
-        table_column("scorm_scoes_track", "", "attempt", "integer", "", "", "1", "NOT NULL", "scoid"); 
-        execute_sql("DROP INDEX {$CFG->prefix}scorm_scoes_track_scormid_idx", false);
-        modify_database('',"CREATE UNIQUE INDEX prefix_scorm_scoes_track_uk ON prefix_scorm_scoes_track(userid,scormid,scoid,attempt,element);");
-    }
-
-    if ($oldversion < 2005102800) {
-        table_column("scorm", "", "maxattempt", "integer", "", "UNSIGNED", "1", "NOT NULL", "maxgrade"); 
-    }
-
-
-    if ($oldversion < 2006021401) {
-       table_column("scorm", "", "version", "VARCHAR", "9", "", "", "NOT NULL", "reference");
-
-       modify_database('', 'ALTER TABLE prefix_scorm ALTER COLUMN width SET DEFAULT 100');
-       modify_database('', 'ALTER TABLE prefix_scorm ALTER COLUMN height SET DEFAULT 500');
-       // there is an extra constraint key1, we should drop this
-       modify_database('', 'ALTER TABLE prefix_scorm_scoes_track DROP CONSTRAINT prefix_scorm_scoes_track_userid_key1');
-       modify_database('', 'ALTER TABLE prefix_scorm_scoes_track DROP CONSTRAINT prefix_scorm_scoes_track_userid_key');
-       modify_database('', 'ALTER TABLE prefix_scorm_scoes_track ADD CONSTRAINT prefix_scorm_scoes_track_userid_key UNIQUE (userid, scormid, scoid, attempt, element)');
-    }
-
-    if ($oldversion < 2006102600) {
-        table_column("scorm", "", "skipview", "integer", "", "", "1", "NOT NULL"); 
-    }
-
-    if ($oldversion < 2006102702) {   // This is a month in advance!!!!!
-        execute_sql("DELETE FROM {$CFG->prefix}log_display WHERE module = 'resource' AND action = 'review' AND mtable = 'resource' AND field = 'name';", false);      // See MDL-6516
-        execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('scorm', 'review', 'scorm', 'name');", false);
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-?>
diff --git a/mod/survey/db/mysql.php b/mod/survey/db/mysql.php
deleted file mode 100644 (file)
index 9518aa4..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function survey_upgrade($oldversion) {
-// This function does anything necessary to upgrade
-// older versions to match current functionality
-
-    global $CFG;
-
-    if ($oldversion < 2002081400) {
-
-        execute_sql("  ALTER TABLE `survey_questions` DROP `owner` ");
-        execute_sql("  ALTER TABLE `survey_questions` ADD `shorttext` VARCHAR(30) NOT NULL AFTER `text` ");
-
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'focus on interesting issues' WHERE id = 1 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'important to my practice' WHERE id = 2 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'improve my practice' WHERE id = 3 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'connects with my practice' WHERE id = 4 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'I\'m critical of my learning' WHERE id = 5 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'I\'m critical of my own ideas' WHERE id = 6 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'I\'m critical of other students' WHERE id = 7 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'I\'m critical of readings' WHERE id = 8 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'I explain my ideas' WHERE id = 9 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'I ask for explanations' WHERE id =10 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'I\'m asked to explain' WHERE id =11 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'students respond to me' WHERE id =12 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'tutor stimulates thinking' WHERE id =13 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'tutor encourages me' WHERE id =14 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'tutor models discourse' WHERE id =15 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'tutor models self-reflection' WHERE id =16 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'students encourage me' WHERE id =17 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'students praise me' WHERE id =18 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'students value me' WHERE id =19 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'student empathise' WHERE id =20 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'I understand other students' WHERE id =21 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'students understand me' WHERE id =22 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'I understand the tutor' WHERE id =23 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'tutor understands me' WHERE id =24 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'Relevance' WHERE id =25 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'Reflective Thinking' WHERE id =26 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'Interactivity' WHERE id =27 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'Tutor Support' WHERE id =28 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'Peer Support' WHERE id =29 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'Interpretation' WHERE id =30 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'Relevance' WHERE id =31 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'Reflective Thinking' WHERE id =32 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'Interactivity' WHERE id =33 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'Tutor Support' WHERE id =34 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = '' WHERE id =35 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = '' WHERE id =36 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = '' WHERE id =37 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = '' WHERE id =38 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = '' WHERE id =39 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = '' WHERE id =40 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = '' WHERE id =41 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = '' WHERE id =42 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = '' WHERE id =43 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = '' WHERE id =44 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'focus quality of argument' WHERE id =45 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'play devil\'s advocate' WHERE id =46 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'where people come from' WHERE id =47 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'understand different people' WHERE id =48 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'interact with variety' WHERE id =49 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'enjoy hearing opinions' WHERE id =50 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'strengthen by argue' WHERE id =51 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'know why people do' WHERE id =52 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'argue with authors' WHERE id =53 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'remain objective' WHERE id =54 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'think WITH people' WHERE id =55 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'use criteria to evaluate' WHERE id =56 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'try to understand' WHERE id =57 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'point out weaknesses' WHERE id =58 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'put myself in their shoes' WHERE id =59 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'putting on trial' WHERE id =60 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'i value logic most' WHERE id =61 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'insight from empathy' WHERE id =62 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'make effort to extend' WHERE id =63 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = 'what\'s wrong\?' WHERE id =64 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = '' WHERE id =65 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = '' WHERE id =66 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = '' WHERE id =67 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = '' WHERE id =68 ");
-        execute_sql("  UPDATE `survey_questions` SET `shorttext` = '' WHERE id =69 ");
-
-    }
-
-    if ($oldversion < 2002110903) {
-        if (! execute_sql("ALTER TABLE `survey_questions` ADD `shorttext` VARCHAR(30) NOT NULL AFTER `text` ")) {
-            notify("If you get an error above, don't worry, just ignore it.  Everything is OK.");
-        }
-
-        execute_sql("UPDATE `survey` SET `name` = 'collesaname', `intro` = 'collesaintro' WHERE name = 'COLLES (Actual)' AND template = 0 ");
-        execute_sql("UPDATE `survey` SET `name` = 'collespname', `intro` = 'collespintro' WHERE name = 'COLLES (Preferred)' AND template = 0");
-        execute_sql("UPDATE `survey` SET `name` = 'collesapname', `intro` = 'collesapintro' WHERE name = 'COLLES (Preferred and Actual)' AND template = 0");
-        execute_sql("UPDATE `survey` SET `name` = 'attlsname', `intro` = 'attlsintro' WHERE name = 'ATTLS (20 item version)' AND template = 0");
-
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles1', `shorttext` = 'colles1short', `options` = 'scaletimes5' WHERE `shorttext` = 'focus on interesting issues'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles2', `shorttext` = 'colles2short', `options` = 'scaletimes5' WHERE `shorttext` = 'important to my practice'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles3', `shorttext` = 'colles3short', `options` = 'scaletimes5' WHERE `shorttext` = 'improve my practice'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles4', `shorttext` = 'colles4short', `options` = 'scaletimes5' WHERE `shorttext` = 'connects with my practice'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles5', `shorttext` = 'colles5short', `options` = 'scaletimes5' WHERE `shorttext` = 'I\'m critical of my learning'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles6', `shorttext` = 'colles6short', `options` = 'scaletimes5' WHERE `shorttext` = 'I\'m critical of my own ideas'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles7', `shorttext` = 'colles7short', `options` = 'scaletimes5' WHERE `shorttext` = 'I\'m critical of other students'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles8', `shorttext` = 'colles8short', `options` = 'scaletimes5' WHERE `shorttext` = 'I\'m critical of readings'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles9', `shorttext` = 'colles9short', `options` = 'scaletimes5' WHERE `shorttext` = 'I explain my ideas'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles10', `shorttext` = 'colles10short', `options` = 'scaletimes5' WHERE `shorttext` = 'I ask for explanations'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles11', `shorttext` = 'colles11short', `options` = 'scaletimes5' WHERE `shorttext` = 'I\'m asked to explain'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles12', `shorttext` = 'colles12short', `options` = 'scaletimes5' WHERE `shorttext` = 'students respond to me'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles13', `shorttext` = 'colles13short', `options` = 'scaletimes5' WHERE `shorttext` = 'tutor stimulates thinking'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles14', `shorttext` = 'colles14short', `options` = 'scaletimes5' WHERE `shorttext` = 'tutor encourages me'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles15', `shorttext` = 'colles15short', `options` = 'scaletimes5' WHERE `shorttext` = 'tutor models discourse'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles16', `shorttext` = 'colles16short', `options` = 'scaletimes5' WHERE `shorttext` = 'tutor models self-reflection'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles17', `shorttext` = 'colles17short', `options` = 'scaletimes5' WHERE `shorttext` = 'students encourage me'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles18', `shorttext` = 'colles18short', `options` = 'scaletimes5' WHERE `shorttext` = 'students praise me'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles19', `shorttext` = 'colles19short', `options` = 'scaletimes5' WHERE `shorttext` = 'students value me'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles20', `shorttext` = 'colles20short', `options` = 'scaletimes5' WHERE `shorttext` = 'student empathise'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles21', `shorttext` = 'colles21short', `options` = 'scaletimes5' WHERE `shorttext` = 'I understand other students'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles22', `shorttext` = 'colles22short', `options` = 'scaletimes5' WHERE `shorttext` = 'students understand me'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles23', `shorttext` = 'colles23short', `options` = 'scaletimes5' WHERE `shorttext` = 'I understand the tutor'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'colles24', `shorttext` = 'colles24short', `options` = 'scaletimes5' WHERE `shorttext` = 'tutor understands me'");
-
-        execute_sql("UPDATE `survey_questions` SET `text` = 'collesm1', `shorttext` = 'collesm1short', `intro` = 'collesmintro', `options` = 'scaletimes5' WHERE `text` = 'Relevance'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'collesm2', `shorttext` = 'collesm2short', `intro` = 'collesmintro', `options` = 'scaletimes5' WHERE `text` = 'Reflective Thinking'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'collesm3', `shorttext` = 'collesm3short', `intro` = 'collesmintro', `options` = 'scaletimes5' WHERE `text` = 'Interactivity'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'collesm4', `shorttext` = 'collesm4short', `intro` = 'collesmintro', `options` = 'scaletimes5' WHERE `text` = 'Tutor Support'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'collesm5', `shorttext` = 'collesm5short', `intro` = 'collesmintro', `options` = 'scaletimes5' WHERE `text` = 'Peer Support'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'collesm6', `shorttext` = 'collesm6short', `intro` = 'collesmintro', `options` = 'scaletimes5' WHERE `text` = 'Interpretation'");
-
-        execute_sql("UPDATE `survey_questions` SET `text` = 'howlong', `options` = 'howlongoptions' WHERE `text` = 'How long did this survey take you to complete\?'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'othercomments' WHERE `text` = 'Do you have any other comments\?'");
-
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attls1', `shorttext` = 'attls1short', `options` = 'scaleagree5' WHERE `shorttext` = 'focus quality of argument'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attls2', `shorttext` = 'attls2short', `options` = 'scaleagree5' WHERE `shorttext` = 'play devil\'s advocate'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attls3', `shorttext` = 'attls3short', `options` = 'scaleagree5' WHERE `shorttext` = 'where people come from'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attls4', `shorttext` = 'attls4short', `options` = 'scaleagree5' WHERE `shorttext` = 'understand different people'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attls5', `shorttext` = 'attls5short', `options` = 'scaleagree5' WHERE `shorttext` = 'interact with variety'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attls6', `shorttext` = 'attls6short', `options` = 'scaleagree5' WHERE `shorttext` = 'enjoy hearing opinions'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attls7', `shorttext` = 'attls7short', `options` = 'scaleagree5' WHERE `shorttext` = 'strengthen by argue'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attls8', `shorttext` = 'attls8short', `options` = 'scaleagree5' WHERE `shorttext` = 'know why people do'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attls9', `shorttext` = 'attls9short', `options` = 'scaleagree5' WHERE `shorttext` = 'argue with authors'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attls10', `shorttext` = 'attls10short', `options` = 'scaleagree5' WHERE `shorttext` = 'remain objective'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attls11', `shorttext` = 'attls11short', `options` = 'scaleagree5' WHERE `shorttext` = 'think WITH people'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attls12', `shorttext` = 'attls12short', `options` = 'scaleagree5' WHERE `shorttext` = 'use criteria to evaluate'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attls13', `shorttext` = 'attls13short', `options` = 'scaleagree5' WHERE `shorttext` = 'try to understand'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attls14', `shorttext` = 'attls14short', `options` = 'scaleagree5' WHERE `shorttext` = 'point out weaknesses'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attls15', `shorttext` = 'attls15short', `options` = 'scaleagree5' WHERE `shorttext` = 'put myself in their shoes'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attls16', `shorttext` = 'attls16short', `options` = 'scaleagree5' WHERE `shorttext` = 'putting on trial'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attls17', `shorttext` = 'attls17short', `options` = 'scaleagree5' WHERE `shorttext` = 'i value logic most'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attls18', `shorttext` = 'attls18short', `options` = 'scaleagree5' WHERE `shorttext` = 'insight from empathy'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attls19', `shorttext` = 'attls19short', `options` = 'scaleagree5' WHERE `shorttext` = 'make effort to extend'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attls20', `shorttext` = 'attls20short', `options` = 'scaleagree5' WHERE `shorttext` = 'what\'s wrong\?'");
-
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attlsm1', `shorttext` = 'attlsm1', `options` = 'scaleagree5', `intro` = 'attlsmintro' WHERE `text` = 'Attitudes Towards Thinking and Learning'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attlsm2', `shorttext` = 'attlsm2', `options` = 'scaleagree5', `intro` = 'attlsmintro' WHERE `text` = 'Connected Learning'");
-        execute_sql("UPDATE `survey_questions` SET `text` = 'attlsm3', `shorttext` = 'attlsm3', `options` = 'scaleagree5', `intro` = 'attlsmintro' WHERE `text` = 'Separate Learning'");
-    }
-    if ($oldversion < 2002122300) {
-        execute_sql("ALTER TABLE `survey_analysis` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
-        execute_sql("ALTER TABLE `survey_answers` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
-    }
-
-    if ($oldversion < 2004021601) {
-        execute_sql("INSERT INTO `{$CFG->prefix}survey` (`course`, `template`, `days`, `timecreated`, `timemodified`, `name`, `intro`, `questions`) VALUES (0, 0, 0, 985017600, 985017600, 'ciqname', 'ciqintro', '69,70,71,72,73')");
-        execute_sql("INSERT INTO `{$CFG->prefix}survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (69, 'ciq1', 'ciq1short', '', '', 0, '')");
-        execute_sql("INSERT INTO `{$CFG->prefix}survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (70, 'ciq2', 'ciq2short', '', '', 0, '')");
-        execute_sql("INSERT INTO `{$CFG->prefix}survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (71, 'ciq3', 'ciq3short', '', '', 0, '')");
-        execute_sql("INSERT INTO `{$CFG->prefix}survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (72, 'ciq4', 'ciq4short', '', '', 0, '')");
-        execute_sql("INSERT INTO `{$CFG->prefix}survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (73, 'ciq5', 'ciq5short', '', '', 0, '')");
-    }
-
-    if ($oldversion < 2004021602) {
-        table_column("survey_answers", "answer1", "answer1", "text", "", "", "");
-        table_column("survey_answers", "answer2", "answer2", "text", "", "", "");
-    }
-
-    if ($oldversion < 2004021900) {
-        modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('survey', 'add', 'survey', 'name');");
-        modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('survey', 'update', 'survey', 'name');");
-    }
-
-    if ($oldversion < 2004111200) {
-        execute_sql("ALTER TABLE {$CFG->prefix}survey DROP INDEX course;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}survey_analysis DROP INDEX survey;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}survey_analysis DROP INDEX userid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}survey_answers DROP INDEX userid;",false); 
-        execute_sql("ALTER TABLE {$CFG->prefix}survey_answers DROP INDEX survey;",false); 
-        execute_sql("ALTER TABLE {$CFG->prefix}survey_answers DROP INDEX question;",false);
-
-        modify_database('','ALTER TABLE prefix_survey ADD INDEX course (course);');
-        modify_database('','ALTER TABLE prefix_survey_analysis ADD INDEX survey (survey);');
-        modify_database('','ALTER TABLE prefix_survey_analysis ADD INDEX userid (userid);');
-        modify_database('','ALTER TABLE prefix_survey_answers ADD INDEX userid (userid);');
-        modify_database('','ALTER TABLE prefix_survey_answers ADD INDEX survey (survey);');
-        modify_database('','ALTER TABLE prefix_survey_answers ADD INDEX question (question);');
-    }
-    
-    if ($oldversion < 2006042800) {
-
-        execute_sql("UPDATE {$CFG->prefix}survey SET questions='' WHERE questions IS NULL");
-        table_column('survey','questions','questions','varchar','255','','','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}survey SET intro='' WHERE intro IS NULL");
-        table_column('survey','intro','intro','text','','','','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}survey_answers SET time='0' WHERE time IS NULL");
-        table_column('survey_answers','time','time','int','10','unsigned','0','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}survey_answers SET answer1='' WHERE answer1 IS NULL");
-        table_column('survey_answers','answer1','answer1','text','','','','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}survey_answers SET answer2='' WHERE answer2 IS NULL");
-        table_column('survey_answers','answer2','answer2','text','','','','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}survey_questions SET intro='' WHERE intro IS NULL");
-        table_column('survey_questions','intro','intro','varchar','50','','','not null');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-
-?>
diff --git a/mod/survey/db/postgres7.php b/mod/survey/db/postgres7.php
deleted file mode 100644 (file)
index c700f50..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function survey_upgrade($oldversion) {
-// This function does anything necessary to upgrade
-// older versions to match current functionality
-
-    global $CFG;
-
-    if ($oldversion < 2004021601) {
-        modify_database("", "INSERT INTO `prefix_survey` (`course`, `template`, `days`, `timecreated`, `timemodified`, `name`, `intro`, `questions`) VALUES (0, 0, 0, 985017600, 985017600, 'ciqname', 'ciqintro', '69,70,71,72,73')");
-        modify_database("", "INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (69, 'ciq1', 'ciq1short', '', '', 0, '')");
-        modify_database("", "INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (70, 'ciq2', 'ciq2short', '', '', 0, '')");
-        modify_database("", "INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (71, 'ciq3', 'ciq3short', '', '', 0, '')");
-        modify_database("", "INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (72, 'ciq4', 'ciq4short', '', '', 0, '')");
-        modify_database("", "INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (73, 'ciq5', 'ciq5short', '', '', 0, '')");
-    }
-
-    if ($oldversion < 2004021602) {
-        table_column("survey_answers", "answer1", "answer1", "text", "", "", "");
-        table_column("survey_answers", "answer2", "answer2", "text", "", "", "");
-    }
-    if ($oldversion < 2004021900) {
-        modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('survey', 'add', 'survey', 'name');");
-        modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('survey', 'update', 'survey', 'name');");
-    }
-
-    if ($oldversion < 2004111200) { 
-        execute_sql("DROP INDEX {$CFG->prefix}survey_course_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}survey_analysis_survey_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}survey_analysis_userid_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}survey_answers_userid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}survey_answers_survey_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}survey_answers_question_idx;",false);
-
-        modify_database('','CREATE INDEX prefix_survey_course_idx ON prefix_survey (course);');
-        modify_database('','CREATE INDEX prefix_survey_analysis_survey_idx ON prefix_survey_analysis (survey);');
-        modify_database('','CREATE INDEX prefix_survey_analysis_userid_idx ON prefix_survey_analysis (userid);');
-        modify_database('','CREATE INDEX prefix_survey_answers_userid_idx ON prefix_survey_answers (userid);');
-        modify_database('','CREATE INDEX prefix_survey_answers_survey_idx ON prefix_survey_answers (survey);');
-        modify_database('','CREATE INDEX prefix_survey_answers_question_idx ON prefix_survey_answers (question);');
-    }
-
-    if ($oldversion < 2005031600) {
-        execute_sql('SELECT setval(\''.$CFG->prefix.'survey_id_seq\', (select max(id) from '.$CFG->prefix.'survey))');
-        execute_sql('SELECT setval(\''.$CFG->prefix.'survey_questions_id_seq\', (select max(id) from '.$CFG->prefix.'survey_questions))');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-
-?>
diff --git a/mod/wiki/db/mysql.php b/mod/wiki/db/mysql.php
deleted file mode 100644 (file)
index 512230a..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-<?PHP
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function wiki_upgrade($oldversion) {
-/// This function does anything necessary to upgrade 
-/// older versions to match current functionality 
-
-    global $CFG, $db;
-
-    if ($oldversion < 2004040200) {
-        execute_sql('ALTER TABLE `'.$CFG->prefix.'wiki` DROP `allowstudentstowiki`');
-    }
-
-    if ($oldversion < 2004040700) {
-        execute_sql('ALTER TABLE `'.$CFG->prefix.'wiki` CHANGE `ewikiallowsafehtml` `htmlmode` TINYINT( 4 ) DEFAULT \'0\' NOT NULL');
-    }
-
-    if ($oldversion < 2004042100) {
-        execute_sql('ALTER TABLE `'.$CFG->prefix.'wiki` ADD `pagename` VARCHAR( 255 ) AFTER `summary`');
-        execute_sql('ALTER TABLE `'.$CFG->prefix.'wiki_entries` CHANGE `name` `pagename` VARCHAR( 255 ) NOT NULL');
-        if ($wikis = get_records('wiki')) {
-            foreach ($wikis as $wiki) {
-                if (empty($wiki->pagename)) {
-                    set_field('wiki', 'pagename', $wiki->name, 'id', $wiki->id);
-                }
-            }
-        }
-    }
-
-    if ($oldversion < 2004053100) {
-        execute_sql('ALTER TABLE `'.$CFG->prefix.'wiki` CHANGE `initialcontent` `initialcontent` VARCHAR( 255 ) NOT NULL DEFAULT \'\'');
-//      Remove obsolete 'initialcontent' values.
-        if ($wikis = get_records('wiki')) {
-            foreach ($wikis as $wiki) {
-                if (!empty($wiki->initialcontent)) {
-                    set_field('wiki', 'initialcontent', null, 'id', $wiki->id);
-                }
-            }
-        }
-    }
-
-    if ($oldversion < 2004061300) {
-        execute_sql('ALTER TABLE `'.$CFG->prefix.'wiki`'
-                    .' ADD `setpageflags` TINYINT DEFAULT \'1\' NOT NULL AFTER `ewikiacceptbinary`,'
-                    .' ADD `strippages` TINYINT DEFAULT \'1\' NOT NULL AFTER `setpageflags`,'
-                    .' ADD `removepages` TINYINT DEFAULT \'1\' NOT NULL AFTER `strippages`,'
-                    .' ADD `revertchanges` TINYINT DEFAULT \'1\' NOT NULL AFTER `removepages`');
-    }
-
-    if ($oldversion < 2004062400) {
-        execute_sql('ALTER TABLE `'.$CFG->prefix.'wiki`'
-                    .' ADD `disablecamelcase` TINYINT DEFAULT \'0\' NOT NULL AFTER `ewikiacceptbinary`');
-    }
-
-    if ($oldversion < 2004082200) {
-        table_column('wiki_pages', '', 'userid', "integer", "10", "unsigned", "0", "not null", "author");
-    }
-
-    if ($oldversion < 2004082303) {  // Try to update userid for old records
-        if ($pages = get_records('wiki_pages', 'userid', 0, 'pagename', 'lastmodified,author,pagename,version')) {
-            foreach ($pages as $page) {
-                $name = explode('(', $page->author);
-                $name = trim($name[0]);
-                $name = explode(' ', $name);
-                $firstname = $name[0];
-                unset($name[0]);
-                $lastname = trim(implode(' ', $name));
-                if ($user = get_record('user', 'firstname', $firstname, 'lastname', $lastname)) {
-                    set_field('wiki_pages', 'userid', $user->id,                                                                                      'pagename', addslashes($page->pagename), 'version', $page->version);
-                }
-            }
-        }
-    }
-
-    if ($oldversion < 2004111200) {
-        execute_sql("ALTER TABLE {$CFG->prefix}wiki DROP INDEX course;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}wiki_entries DROP INDEX course;",false); 
-        execute_sql("ALTER TABLE {$CFG->prefix}wiki_entries DROP INDEX userid;",false); 
-        execute_sql("ALTER TABLE {$CFG->prefix}wiki_entries DROP INDEX groupid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}wiki_entries DROP INDEX wikiid;",false); 
-        execute_sql("ALTER TABLE {$CFG->prefix}wiki_entries DROP INDEX pagename;",false);
-
-        modify_database('','ALTER TABLE prefix_wiki ADD INDEX course (course);');
-        modify_database('','ALTER TABLE prefix_wiki_entries ADD INDEX course (course);');
-        modify_database('','ALTER TABLE prefix_wiki_entries ADD INDEX userid (userid);');
-        modify_database('','ALTER TABLE prefix_wiki_entries ADD INDEX groupid (groupid);');
-        modify_database('','ALTER TABLE prefix_wiki_entries ADD INDEX wikiid (wikiid);');
-        modify_database('','ALTER TABLE prefix_wiki_entries ADD INDEX pagename (pagename);');
-    }
-
-    if ($oldversion < 2005022000) {
-        // recreating the wiki_pages table completelly (missing id, bug 2608)
-        if ($rows = count_records("wiki_pages")) {
-            // we need to use the temp stuff
-            modify_database("","CREATE TABLE `prefix_wiki_pages_tmp` (
-                `pagename` VARCHAR(160) NOT NULL,
-                `version` INT(10) UNSIGNED NOT NULL DEFAULT 0,
-                `flags` INT(10) UNSIGNED DEFAULT 0,
-                `content` MEDIUMTEXT,
-                `author` VARCHAR(100) DEFAULT 'ewiki',
-                `userid` INT(10) UNSIGNED NOT NULL DEFAULT 0,
-                `created` INT(10) UNSIGNED DEFAULT 0,
-                `lastmodified` INT(10) UNSIGNED DEFAULT 0,
-                `refs` MEDIUMTEXT,
-                `meta` MEDIUMTEXT,
-                `hits` INT(10) UNSIGNED DEFAULT 0,
-                `wiki` INT(10) UNSIGNED NOT NULL);");
-            
-            execute_sql("INSERT INTO {$CFG->prefix}wiki_pages_tmp (pagename, version, flags, content,
-                                                                   author, userid, created, lastmodified,
-                                                                   refs, meta, hits, wiki) 
-                         SELECT pagename, version, flags, content,
-                                author, userid, created, lastmodified,
-                                refs, meta, hits, wiki
-                         FROM {$CFG->prefix}wiki_pages");
-
-            $insertafter = true;
-        }
-
-        execute_sql("DROP TABLE {$CFG->prefix}wiki_pages");
-
-        modify_database("","CREATE TABLE `prefix_wiki_pages` (
-            `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
-            `pagename` VARCHAR(160) NOT NULL,
-            `version` INT(10) UNSIGNED NOT NULL DEFAULT 0,
-            `flags` INT(10) UNSIGNED DEFAULT 0,
-            `content` MEDIUMTEXT,
-            `author` VARCHAR(100) DEFAULT 'ewiki',
-            `userid` INT(10) UNSIGNED NOT NULL DEFAULT 0,
-            `created` INT(10) UNSIGNED DEFAULT 0,
-            `lastmodified` INT(10) UNSIGNED DEFAULT 0,
-            `refs` MEDIUMTEXT,
-            `meta` MEDIUMTEXT,
-            `hits` INT(10) UNSIGNED DEFAULT 0,
-            `wiki` INT(10) UNSIGNED NOT NULL,
-            PRIMARY KEY (`id`),
-            UNIQUE KEY `wiki_pages_uk` (`pagename`,`version`,`wiki`))
-            TYPE=MyISAM COMMENT='Holds the Wiki-Pages';");
-        
-        if (!empty($insertafter)) {
-            execute_sql("INSERT INTO {$CFG->prefix}wiki_pages (pagename, version, flags, content,
-                                                               author, userid, created, lastmodified,
-                                                               refs, meta, hits, wiki) 
-                         SELECT pagename, version, flags, content,
-                                author, userid, created, lastmodified,
-                                refs, meta, hits, wiki
-                         FROM {$CFG->prefix}wiki_pages_tmp");
-
-            execute_sql("DROP TABLE {$CFG->prefix}wiki_pages_tmp");
-        }
-    }
-
-    if ($oldversion < 2006042800) {
-
-        execute_sql("UPDATE {$CFG->prefix}wiki SET summary='' WHERE summary IS NULL");
-        table_column('wiki','summary','summary','text','','','','not null');
-
-        execute_sql("UPDATE {$CFG->prefix}wiki SET pagename='' WHERE pagename IS NULL");
-        table_column('wiki','pagename','pagename','varchar','255','','','not null');
-        
-        execute_sql("UPDATE {$CFG->prefix}wiki SET initialcontent='' WHERE initialcontent IS NULL");
-        table_column('wiki','initialcontent','initialcontent','varchar','255','','','not null');
-    }
-    if ($oldversion < 2006092502) {
-        modify_database("","
-CREATE TABLE prefix_wiki_locks
-(
-  id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
-  wikiid INT(10) UNSIGNED NOT NULL,
-  pagename VARCHAR(160) NOT NULL DEFAULT '',
-  lockedby INT(10) NOT NULL DEFAULT 0,
-  lockedsince INT(10) NOT NULL DEFAULT 0,
-  lockedseen INT(10) NOT NULL DEFAULT 0,
-  PRIMARY KEY(id),
-  UNIQUE INDEX wiki_locks_uk(wikiid,pagename),
-  INDEX wiki_locks_ix(lockedseen)  
-);"); 
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/mod/wiki/db/postgres7.php b/mod/wiki/db/postgres7.php
deleted file mode 100644 (file)
index ffd0508..0000000
+++ /dev/null
@@ -1,209 +0,0 @@
-<?PHP
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function wiki_upgrade($oldversion) {
-/// This function does anything necessary to upgrade 
-/// older versions to match current functionality 
-
-    global $CFG;
-
-    if ($oldversion < 2004073000) {
-
-       modify_database("", "ALTER TABLE prefix_wiki_pages DROP COLUMN id;"); 
-       modify_database("", "ALTER TABLE ONLY prefix_wiki_pages 
-                            ADD CONSTRAINT id PRIMARY KEY (pagename, \"version\");"); 
-    }    
-    if ($oldversion < 2004073001) {
-
-       modify_database("", "ALTER TABLE prefix_wiki_pages DROP CONSTRAINT id;"); 
-       modify_database("", "ALTER TABLE ONLY prefix_wiki_pages 
-                            ADD CONSTRAINT id PRIMARY KEY (pagename, \"version\", wiki);"); 
-    }
-    if ($oldversion < 2004082200) {
-        table_column('wiki_pages', '', 'userid', "integer", "10", "unsigned", "0", "not null", "author");
-    }
-    if ($oldversion < 2004082303) {  // Try to update userid for old records
-        if ($pages = get_records('wiki_pages', 'userid', 0, 'pagename', 'lastmodified,author,pagename,version')) {
-            foreach ($pages as $page) {
-                $name = explode('(', $page->author);
-                $name = trim($name[0]);
-                $name = explode(' ', $name);
-                $firstname = $name[0];
-                unset($name[0]);
-                $lastname = trim(implode(' ', $name));
-                if ($user = get_record('user', 'firstname', $firstname, 'lastname', $lastname)) {
-                    set_field('wiki_pages', 'userid', $user->id,                                                                                      'pagename', addslashes($page->pagename), 'version', $page->version);
-                }
-            }
-        }
-    }
-    
-    if ($oldversion < 2004111200) {
-        execute_sql("DROP INDEX {$CFG->prefix}wiki_course_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}wiki_entries_wikiid_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}wiki_entries_userid_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}wiki_entries_groupid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}wiki_entries_course_idx;",false); 
-        execute_sql("DROP INDEX {$CFG->prefix}wiki_entries_pagename_idx;",false);
-
-        modify_database('','CREATE INDEX prefix_wiki_course_idx ON prefix_wiki (course);');
-        modify_database('','CREATE INDEX prefix_wiki_entries_wikiid_idx ON prefix_wiki_entries (wikiid);');
-        modify_database('','CREATE INDEX prefix_wiki_entries_userid_idx ON prefix_wiki_entries (userid);');
-        modify_database('','CREATE INDEX prefix_wiki_entries_groupid_idx ON prefix_wiki_entries (groupid);');
-        modify_database('','CREATE INDEX prefix_wiki_entries_course_idx ON prefix_wiki_entries (course);');
-        modify_database('','CREATE INDEX prefix_wiki_entries_pagename_idx ON prefix_wiki_entries (pagename);');
-    }
-
-
-    if ($oldversion < 2004112400) {
-        execute_sql("ALTER TABLE {$CFG->prefix}wiki_pages DROP CONSTRAINT id;",false); 
-        execute_sql("ALTER TABLE {$CFG->prefix}wiki_pages DROP CONSTRAINT {$CFG->prefix}wiki_pages_id;",false); 
-        execute_sql("ALTER TABLE {$CFG->prefix}wiki_pages DROP CONSTRAINT {$CFG->prefix}wiki_pages_pagename_version_wiki_unique;",false);
-        modify_database("", "ALTER TABLE ONLY prefix_wiki_pages 
-                            ADD CONSTRAINT prefix_wiki_pages_pagename_version_wiki_unique PRIMARY KEY (pagename, \"version\", wiki);"); 
-    }
-
-    if ($oldversion < 2005022000) {
-        // recreating the wiki_pages table completelly (missing id, bug 2608)
-        if ($rows = count_records("wiki_pages")) {
-            // we need to use the temp stuff
-            modify_database("","CREATE TABLE prefix_wiki_pages_tmp (
-                id SERIAL8 PRIMARY KEY, 
-                pagename VARCHAR(160) NOT NULL,
-                version INTEGER  NOT NULL DEFAULT 0,
-                flags INTEGER  DEFAULT 0,
-                content TEXT,
-                author VARCHAR(100) DEFAULT 'ewiki',
-                userid INTEGER  NOT NULL DEFAULT 0,
-                created INTEGER  DEFAULT 0,
-                lastmodified INTEGER  DEFAULT 0,
-                refs TEXT,
-                meta TEXT,
-                hits INTEGER  DEFAULT 0,
-                wiki INT8  NOT NULL);");
-            
-            execute_sql("INSERT INTO {$CFG->prefix}wiki_pages_tmp (pagename, version, flags, content,
-                                                                   author, userid, created, lastmodified,
-                                                                   refs, meta, hits, wiki) 
-                         SELECT pagename, version, flags, content,
-                                author, userid, created, lastmodified,
-                                refs, meta, hits, wiki
-                         FROM {$CFG->prefix}wiki_pages");
-
-            $insertafter = true;
-        }
-
-        execute_sql("DROP TABLE {$CFG->prefix}wiki_pages");
-
-        modify_database("","CREATE TABLE prefix_wiki_pages (
-            id SERIAL8 PRIMARY KEY, 
-            pagename VARCHAR(160) NOT NULL,
-            version INTEGER  NOT NULL DEFAULT 0,
-            flags INTEGER  DEFAULT 0,
-            content TEXT,
-            author VARCHAR(100) DEFAULT 'ewiki',
-            userid INTEGER  NOT NULL DEFAULT 0,
-            created INTEGER  DEFAULT 0,
-            lastmodified INTEGER  DEFAULT 0,
-            refs TEXT,
-            meta TEXT,
-            hits INTEGER  DEFAULT 0,
-            wiki INT8  NOT NULL);");
-
-        modify_database("","CREATE UNIQUE INDEX prefix_wiki_pages_pagename_version_wiki_uk 
-                            ON prefix_wiki_pages (pagename, version, wiki);");
-        
-        if (!empty($insertafter)) {
-            execute_sql("INSERT INTO {$CFG->prefix}wiki_pages (pagename, version, flags, content,
-                                                               author, userid, created, lastmodified,
-                                                               refs, meta, hits, wiki) 
-                         SELECT pagename, version, flags, content,
-                                author, userid, created, lastmodified,
-                                refs, meta, hits, wiki
-                         FROM {$CFG->prefix}wiki_pages_tmp");
-
-            execute_sql("DROP TABLE {$CFG->prefix}wiki_pages_tmp");
-        }
-    }
-    
-    if ($oldversion < 2006032900) {
-        global $db;
-        table_column("wiki_pages",'','content_base64','text');
-        table_column("wiki_pages",'','refs_base64','text');
-        $olddebug = $db->debug;
-        $db->debug = false;
-        $data = $db->GetAll("SELECT id,content,refs FROM {$CFG->prefix}wiki_pages");
-        foreach ($data as $d) {
-            $db->AutoExecute("{$CFG->prefix}wiki_pages", array('refs_base64' => base64_encode($d['refs']), 'content_base64' => base64_encode($d['content'])), 'UPDATE', 'id = '.$d['id']);
-        }
-        $db->debug = $olddebug;
-        execute_sql("ALTER TABLE {$CFG->prefix}wiki_pages DROP COLUMN content");
-        execute_sql("ALTER TABLE {$CFG->prefix}wiki_pages DROP COLUMN refs");
-        table_column("wiki_pages",'','content','bytea');
-        table_column("wiki_pages",'','refs','bytea');
-        execute_sql("UPDATE {$CFG->prefix}wiki_pages SET refs = decode(refs_base64, 'base64'), content = decode(content_base64, 'base64')");
-        execute_sql("ALTER TABLE {$CFG->prefix}wiki_pages DROP COLUMN content_base64");
-        execute_sql("ALTER TABLE {$CFG->prefix}wiki_pages DROP COLUMN refs_base64");
-    }
-
-    if ($oldversion < 2006042801) {
-        modify_database('', 'ALTER TABLE prefix_wiki_pages 
-            ALTER COLUMN content SET DEFAULT \'\'');
-        modify_database('', 'ALTER TABLE prefix_wiki_pages 
-            ALTER COLUMN refs SET DEFAULT \'\'');
-        modify_database('', 'ALTER TABLE prefix_wiki_pages 
-            ALTER COLUMN content DROP NOT NULL');
-        modify_database('', 'ALTER TABLE prefix_wiki_pages 
-            ALTER COLUMN refs DROP NOT NULL');
-    }
-    
-    if ($oldversion < 2006092502) {
-        modify_database("","
-CREATE TABLE prefix_wiki_locks
-(
-  id SERIAL PRIMARY KEY,
-  wikiid INTEGER NOT NULL,
-  pagename VARCHAR(160) NOT NULL DEFAULT '',
-  lockedby INTEGER NOT NULL DEFAULT 0,
-  lockedsince INTEGER NOT NULL DEFAULT 0,
-  lockedseen INTEGER NOT NULL DEFAULT 0
-);"); 
-        modify_database("","CREATE INDEX prefix_wikilock_loc_ix ON prefix_wiki_locks (lockedseen);"); 
-        modify_database("","CREATE UNIQUE INDEX prefix_wikilock_wikpag_uix ON prefix_wiki_locks (wikiid, pagename);");  
-    }
-    
-    if($oldversion < 2006092602) {
-/*
-    // This used to be a BYTEA type for no apparent reason, which caused various queries to fail. The new
-    // install.xml uses TEXT so I figure it's safe to change it in upgrade too. This one broke the links page...
-    modify_database('',"ALTER TABLE prefix_wiki_pages ALTER COLUMN refs DROP DEFAULT;");
-modify_database('',"ALTER TABLE prefix_wiki_pages ALTER COLUMN refs TYPE TEXT USING ENCODE(refs,'escape');");
-modify_database('',"ALTER TABLE prefix_wiki_pages ALTER COLUMN refs SET DEFAULT '';");
-// ...and this one broke the search page.
-modify_database('',"ALTER TABLE prefix_wiki_pages ALTER COLUMN content DROP DEFAULT;");
-modify_database('',"ALTER TABLE prefix_wiki_pages ALTER COLUMN content TYPE TEXT USING ENCODE(content,'escape');");
-modify_database('',"ALTER TABLE prefix_wiki_pages ALTER COLUMN content SET DEFAULT '';");
-*/
-            // following code should be compatible with both pg 8.x and 7.4
-            table_column('wiki_pages', '', 'tempcontent', 'TEXT', '', '', '', '');
-            execute_sql("UPDATE {$CFG->prefix}wiki_pages SET tempcontent = ENCODE(content,'escape')");
-            execute_sql("ALTER TABLE {$CFG->prefix}wiki_pages DROP COLUMN content");
-            execute_sql("ALTER TABLE {$CFG->prefix}wiki_pages RENAME COLUMN tempcontent TO content");
-            
-            table_column('wiki_pages', '', 'temprefs', 'TEXT', '', '', '', '');
-            execute_sql("UPDATE {$CFG->prefix}wiki_pages SET temprefs = ENCODE(refs,'escape')");
-            execute_sql("ALTER TABLE {$CFG->prefix}wiki_pages DROP COLUMN refs");
-            execute_sql("ALTER TABLE {$CFG->prefix}wiki_pages RENAME COLUMN temprefs TO refs");
-
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/mod/workshop/assess.php b/mod/workshop/assess.php
deleted file mode 100644 (file)
index 7275ed3..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-<?php  // $Id$
-
-    require("../../config.php");
-    require("lib.php");
-    require("locallib.php");
-
-    $id            = required_param('id', PARAM_INT);   // Submission ID
-    $allowcomments = optional_param('allowcomments', 0, PARAM_BOOL);
-    $redirect      = optional_param('redirect', '', PARAM_URL);
-    $frameset      = optional_param('frameset', '', PARAM_ALPHA);
-    $sid           = optional_param('sid', 0, PARAM_INT);
-
-    if (! $submission = get_record('workshop_submissions', 'id', $sid)) {
-        print_error("Incorrect submission id");
-    }
-    if (! $workshop = get_record("workshop", "id", $submission->workshopid)) {
-        print_error("Submission is incorrect");
-    }
-    if (! $course = get_record("course", "id", $workshop->course)) {
-        print_error("Workshop is misconfigured");
-    }
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
-        print_error("No coursemodule found");
-    }
-
-    require_login($course->id, false, $cm);
-
-
-    if (!$redirect) {
-        //seems not to work properly
-        $redirect = htmlentities($_SERVER["HTTP_REFERER"].'#sid='.$submission->id);
-    }
-
-
-    $strworkshops = get_string("modulenameplural", "workshop");
-    $strworkshop  = get_string("modulename", "workshop");
-    $strassess = get_string("assess", "workshop");
-
-    /// Now check whether we need to display a frameset
-
-    if (empty($frameset)) {
-        if ( get_string('thisdirection') == 'rtl' ) {
-            $direction = ' dir="rtl"';
-        } else {
-            $direction = ' dir="ltr"';
-        }
-        echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n";
-        echo "<html $direction>\n";
-        echo "<head><meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n";
-        echo "<title>" . format_string($course->shortname) . ": ".format_string($workshop->name,true)."</title></head>\n";
-        echo "<frameset rows=\"50%,*\" border=\"10\">";
-        echo "  <frame src=\"assess.php?id=$id&amp;sid=$sid&amp;frameset=top&amp;redirect=$redirect\" border=\"10\" />";
-        echo "  <frame src=\"assess.php?id=$id&amp;sid=$sid&amp;frameset=bottom&amp;redirect=$redirect\" />";
-        echo "</frameset>";
-        echo "</html>";
-        exit;
-    }
-
-    /// top frame with the navigation bar and the assessment form
-
-    if ($frameset == "top") {
-        $navigation = build_navigation($strassess, $cm);
-        print_header_simple(format_string($workshop->name), "",$navigation,
-                      "", '', true);
-
-        // there can be an assessment record (for teacher submissions), if there isn't...
-        if (!$assessment = get_record("workshop_assessments", "submissionid", $submission->id, "userid",
-                    $USER->id)) {
-            // if it's the teacher see if the user has done a self assessment if so copy it
-            if (workshop_is_teacher($workshop) and  ($assessment = get_record("workshop_assessments", "submissionid",
-                            $submission->id, "userid", $submission->userid))) {
-                $assessment = workshop_copy_assessment($assessment, $submission, true);
-                // need to set owner of assessment
-                set_field("workshop_assessments", "userid", $USER->id, "id", $assessment->id);
-                $assessment->resubmission = 0; // not set by workshop_copy_assessment
-                $assessment->timegraded = 0; // not set by workshop_copy_assessment
-                $assessment->timeagreed = 0; // not set by workshop_copy_assessment
-            } else {
-                $yearfromnow = time() + 365 * 86400;
-                // ...create one and set timecreated way in the future, this is reset when record is updated
-                $assessment->workshopid = $workshop->id;
-                $assessment->submissionid = $submission->id;
-                $assessment->userid = $USER->id;
-                $assessment->timecreated = $yearfromnow;
-                $assessment->grade = -1; // set impossible grade
-                $assessment->timegraded = 0;
-                $assessment->timeagreed = 0;
-                $assessment->resubmission = 0;
-                $assessment->generalcomment = '';
-                $assessment->teachercomment = '';
-                if (!$assessment->id = insert_record("workshop_assessments", $assessment)) {
-                    print_error("Could not insert workshop assessment!");
-                }
-                // if it's the teacher and the workshop is error banded set all the elements to Yes
-                if (workshop_is_teacher($workshop) and ($workshop->gradingstrategy == 2)) {
-                    for ($i =0; $i < $workshop->nelements; $i++) {
-                        unset($element);
-                        $element->workshopid = $workshop->id;
-                        $element->assessmentid = $assessment->id;
-                        $element->elementno = $i;
-                        $element->feedback = '';
-                        $element->grade = 1;
-                        if (!$element->id = insert_record("workshop_grades", $element)) {
-                            print_error("Could not insert workshop grade!");
-                        }
-                    }
-                    // now set the adjustment
-                    unset($element);
-                    $i = $workshop->nelements;
-                    $element->workshopid = $workshop->id;
-                    $element->assessmentid = $assessment->id;
-                    $element->elementno = $i;
-                    $element->grade = 0;
-                    if (!$element->id = insert_record("workshop_grades", $element)) {
-                        print_error("Could not insert workshop grade!");
-                    }
-                }
-            }
-        }
-
-        print_heading_with_help(get_string("assessthissubmission", "workshop"), "grading", "workshop");
-
-        // show assessment and allow changes
-        workshop_print_assessment($workshop, $assessment, true, $allowcomments, $redirect);
-
-        print_heading("<a $CFG->frametarget href=\"$redirect\">".get_string("cancel")."</a>");
-        print_footer($course);
-        exit;
-    }
-
-    /// print bottom frame with the submission
-    // removed <base target="_parent" /> as it does not validate MDL-7861
-    print_header('', '', '', '', '');
-    $title = '"'.$submission->title.'" ';
-    if (workshop_is_teacher($workshop)) {
-        $title .= ' '.get_string('by', 'workshop').' '.workshop_fullname($submission->userid, $course->id);
-    }
-    print_heading($title);
-    workshop_print_submission($workshop, $submission);
-
-    if (workshop_is_teacher($workshop)) {
-        echo '<br /><div style="text-align:center"><b>'.get_string('assessments', 'workshop').': </b><br />';
-        echo workshop_print_submission_assessments($workshop, $submission, "all");
-        echo '</div>';
-    }
-
-
-    print_footer('none');
-
-?>
diff --git a/mod/workshop/assessment_grading_form.html b/mod/workshop/assessment_grading_form.html
deleted file mode 100644 (file)
index b2d17aa..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-    if (!isset($assessment->teachercomment)) {
-        $assessment->teachercomment = '';
-    }
-?>
-<form id="gradingform" action="assessments.php" method="post">
-<fieldset class="invisiblefieldset">
-  <input type="hidden" name="action" value="updategrading" />
-  <input type="hidden" name="id" value="<?php echo $cm->id ?>" />
-  <input type="hidden" name="redirect" value="<?php echo $redirect ?>" />
-  <input type="hidden" name="aid" value="<?php echo $aid ?>" />
-  <div class="boxaligncenter">
-    <table cellpadding="5" border="1">
-      <tr valign="top">
-        <td align="right"><b><?php print_string("teacherscomment", "workshop") ?>:</b></td>
-        <td>
-          <textarea name="teachercomment" rows="5" cols="75"><?php echo $assessment->teachercomment; ?></textarea>
-        </td>
-      </tr>
-      <tr>
-        <td align="right">
-          <b><?php print_string("gradeforstudentsassessment", "workshop") ?></td>
-        <td>
-          <input type="text" name="gradinggrade" size="3" value="<?php p($assessment->gradinggrade) ?>" />%
-        </td>
-      </tr>
-    </table>
-    <input type="submit" value="<?php print_string("savemygrading", "workshop") ?>" />
-  </div>
-</fieldset>
-</form> 
\ No newline at end of file
diff --git a/mod/workshop/assessments.php b/mod/workshop/assessments.php
deleted file mode 100644 (file)
index db1c8d0..0000000
+++ /dev/null
@@ -1,1360 +0,0 @@
-<?php  // $Id$
-
-/*************************************************
-    ACTIONS handled are:
-
-    addcomment
-    addstockcomment
-    confirmdelete
-    delete
-    adminlist
-    agreeassessment
-    displaygradingform
-    editcomment
-    editelements (teachers only)
-    gradeallassessments (teachers only)
-    gradeassessment (teachers only)
-    insertcomment
-    insertelements (for teachers)
-    listungradedstudentsubmissions (for teachers)
-    listungradedteachersubmissions (for teachers)
-    listteachersubmissions
-    regradestudentassessments (for teachers)
-    updateassessment
-    updatecomment
-    updategrading
-
-************************************************/
-
-    require("../../config.php");
-    require("lib.php");
-    require("locallib.php");
-
-    $action         = required_param('action', PARAM_ALPHA);
-    $id             = optional_param('id', 0, PARAM_INT);    // Course Module ID
-    $wid            = optional_param('wid', 0, PARAM_INT);    // Workshop ID
-    $aid            = optional_param('aid', 0, PARAM_INT); 
-    $userid         = optional_param('userid', 0, PARAM_INT);
-    $cid            = optional_param('cid', 0, PARAM_INT ); // comment id
-    $sid            = optional_param('sid', 0, PARAM_INT); // submission id
-    $elementno      = optional_param('elementno', -1, PARAM_INT);
-    $stockcommentid = optional_param('stockcommentid', 0, PARAM_INT);
-
-    // get some useful stuff...
-    if ($id) {
-        if (! $cm = get_coursemodule_from_id('workshop', $id)) {
-            print_error("Course Module ID was incorrect");
-        }
-        if (! $workshop = get_record("workshop", "id", $cm->instance)) {
-            print_error("Course module is incorrect");
-        }
-    } else if ($wid) {
-        if (! $workshop = get_record("workshop", "id", $wid)) {
-            print_error("Workshop id is incorrect");
-        }
-        if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-            print_error("No coursemodule found");
-        }
-    } else {
-        print_error("No id given");
-    }
-    if (! $course = get_record("course", "id", $cm->course)) {
-        print_error("Course is misconfigured");
-    }
-
-    require_login($course->id, false, $cm);
-    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
-    $strworkshops = get_string("modulenameplural", "workshop");
-    $strworkshop  = get_string("modulename", "workshop");
-    $strassessments = get_string("assessments", "workshop");
-
-    // ... print the header and...
-    $navigation = build_navigation($strassessments, $cm);
-    print_header_simple(format_string($workshop->name), "", $navigation,
-                  "", "", true);
-
-    /*************** add comment to assessment (by author, assessor or teacher) ***************************/
-    if ($action == 'addcomment') {
-
-        print_heading_with_help(get_string("addacomment", "workshop"), "addingacomment", "workshop");
-        // get assessment record
-        if (!$assessmentid = $aid) { // comes from link or hidden form variable
-            print_error("Assessment id not given");
-        }
-        $assessment = get_record("workshop_assessments", "id", $assessmentid);
-        if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
-            print_error("Submission not found");
-        }
-        ?>
-        <form id="commentform" action="assessments.php" method="post">
-        <input type="hidden" name="action" value="insertcomment" />
-        <input type="hidden" name="id" value="<?php echo $cm->id ?>" />
-        <input type="hidden" name="aid" value="<?php echo $aid ?>" />
-        <div class="boxaligncenter">
-        <table cellpadding="5" border="1">
-        <?php
-
-        // now get the comment
-        echo "<tr valign=\"top\">\n";
-
-        echo "  <td align=\"right\"><b>". get_string("comment", "workshop").":</b></td>\n";
-
-        echo "  <td>\n";
-
-        echo "      <textarea name=\"comments\" rows=\"5\" cols=\"75\">\n";
-        echo "</textarea>\n";
-
-        echo "  </td></tr></table>\n";
-        echo "<input type=\"submit\" value=\"".get_string("savemycomment", "workshop")."\" />\n";
-        echo "</div></form>\n";
-        echo "<div style=\"text-align:center\"><b>".get_string("assessment", "workshop"). "</b></div>\n";
-        workshop_print_assessment($workshop, $assessment);
-    }
-
-
-    /*************** add stock comment (by teacher ) ***************************/
-    elseif ($action == 'addstockcomment') {
-
-        if (empty($aid) or ($elementno<0)) {
-            print_error("Workshop Assessment ID and/or Element Number missing");
-        }
-
-        require_capability('mod/workshop:manage', $context);
-
-        if (!$assessment = get_record("workshop_assessments", "id", $aid)) {
-            print_error("workshop assessment is misconfigured");
-        }
-        $form = data_submitted('nomatch'); //Nomatch because we can come from assess.php
-
-        // store the comment in the stock comments table
-        if ($elementno == 99) { // it's the general comment
-            $form->feedback_99 = $form->generalcomment;
-        }
-        $comment->workshopid = $workshop->id;
-        $comment->elementno = $elementno;
-        $comment->comments = clean_param($form->{"feedback_$elementno"}, PARAM_CLEAN);
-        if (!(trim($comment->comments))) {
-            // no comment given - just redisplay assessment form
-            workshop_print_assessment($workshop, $assessment, true, true, $form->returnto);
-            print_footer($course);
-            exit();
-        }
-
-        if (!$element->id = insert_record("workshop_stockcomments", $comment)) {
-            print_error("Could not insert comment into comment bank");
-        }
-
-        // now upate the assessment (just the elements, the assessment itself is not updated)
-
-        // first get the assignment elements for maxscores and weights...
-        $elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC");
-        if (count($elementsraw) < $workshop->nelements) {
-            print_string("noteonassignmentelements", "workshop");
-        }
-        if ($elementsraw) {
-            foreach ($elementsraw as $element) {
-                $elements[] = $element;   // to renumber index 0,1,2...
-            }
-        } else {
-            $elements = null;
-        }
-
-        $timenow = time();
-        // don't fiddle about, delete all the old and add the new!
-        delete_records("workshop_grades", "assessmentid",  $assessment->id);
-
-
-        //determine what kind of grading we have
-        switch ($workshop->gradingstrategy) {
-            case 0: // no grading
-                // Insert all the elements that contain something
-                for ($i = 0; $i < $workshop->nelements; $i++) {
-                    unset($element);
-                    $element->workshopid = $workshop->id;
-                    $element->assessmentid = $assessment->id;
-                    $element->elementno = $i;
-                    $element->feedback   = clean_param($form->{"feedback_$i"}, PARAM_CLEAN);
-                    if (!$element->id = insert_record("workshop_grades", $element)) {
-                        print_error("Could not insert workshop grade!");
-                    }
-                }
-                $grade = 0; // set to satisfy save to db
-                break;
-
-            case 1: // accumulative grading
-                // Insert all the elements that contain something
-                foreach ($form->grade as $key => $thegrade) {
-                    unset($element);
-                    $element->workshopid = $workshop->id;
-                    $element->assessmentid = $assessment->id;
-                    $element->elementno = clean_param($key, PARAM_INT);
-                    $element->feedback   = clean_param($form->{"feedback_$key"}, PARAM_CLEAN);
-                    $element->grade = $thegrade;
-                    if (!$element->id = insert_record("workshop_grades", $element)) {
-                        print_error("Could not insert workshop grade!");
-                        }
-                    }
-                // now work out the grade...
-                $rawgrade=0;
-                $totalweight=0;
-                foreach ($form->grade as $key => $grade) {
-                    $maxscore = $elements[$key]->maxscore;
-                    $weight = $WORKSHOP_EWEIGHTS[$elements[$key]->weight];
-                    if ($weight > 0) {
-                        $totalweight += $weight;
-                    }
-                    $rawgrade += ($grade / $maxscore) * $weight;
-                    // echo "\$key, \$maxscore, \$weight, \$totalweight, \$grade, \$rawgrade : $key, $maxscore, $weight, $totalweight, $grade, $rawgrade<br />";
-                }
-                $grade = 100.0 * ($rawgrade / $totalweight);
-                break;
-
-            case 2: // error banded graded
-                // Insert all the elements that contain something
-                $error = 0.0;
-                for ($i =0; $i < $workshop->nelements; $i++) {
-                    unset($element);
-                    $element->workshopid = $workshop->id;
-                    $element->assessmentid = $assessment->id;
-                    $element->elementno = $i;
-                    $element->feedback   = clean_param($form->{"feedback_$i"}, PARAM_CLEAN);
-                    $element->grade = $form->grade[$i];
-                    if (!$element->id = insert_record("workshop_grades", $element)) {
-                        print_error("Could not insert workshop grade!");
-                    }
-                    if (empty($form->grade[$i])){
-                        $error += $WORKSHOP_EWEIGHTS[$elements[$i]->weight];
-                    }
-                }
-                // now save the adjustment
-                unset($element);
-                $i = $workshop->nelements;
-                $element->workshopid = $workshop->id;
-                $element->assessmentid = $assessment->id;
-                $element->elementno = $i;
-                $element->grade = $form->grade[$i];
-                if (!$element->id = insert_record("workshop_grades", $element)) {
-                    print_error("Could not insert workshop grade!");
-                }
-                $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i]) * 100 / $workshop->grade;
-                // do sanity check
-                if ($grade < 0) {
-                    $grade = 0;
-                } elseif ($grade > 100) {
-                    $grade = 100;
-                }
-                echo "<b>".get_string("weightederrorcount", "workshop", intval($error + 0.5))."</b>\n";
-                break;
-
-            case 3: // criteria grading
-                // save in the selected criteria value in element zero,
-                unset($element);
-                $element->workshopid = $workshop->id;
-                $element->assessmentid = $assessment->id;
-                $element->elementno = 0;
-                $element->grade = $form->grade[0];
-                if (!$element->id = insert_record("workshop_grades", $element)) {
-                    print_error("Could not insert workshop grade!");
-                }
-                // now save the adjustment in element one
-                unset($element);
-                $element->workshopid = $workshop->id;
-                $element->assessmentid = $assessment->id;
-                $element->elementno = 1;
-                $element->grade = $form->grade[1];
-                if (!$element->id = insert_record("workshop_grades", $element)) {
-                    print_error("Could not insert workshop grade!");
-                }
-                $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]);
-                break;
-
-            case 4: // rubric grading (identical to accumulative grading)
-                // Insert all the elements that contain something
-                foreach ($form->grade as $key => $thegrade) {
-                    unset($element);
-                    $element->workshopid = $workshop->id;
-                    $element->assessmentid = $assessment->id;
-                    $element->elementno = clean_param($key, PARAM_INT);
-                    $element->feedback   = clean_param($form->{"feedback_$key"}, PARAM_CLEAN);
-                    $element->grade = $thegrade;
-                    if (!$element->id = insert_record("workshop_grades", $element)) {
-                        print_error("Could not insert workshop grade!");
-                    }
-                }
-                // now work out the grade...
-                $rawgrade=0;
-                $totalweight=0;
-                foreach ($form->grade as $key => $grade) {
-                    $maxscore = $elements[$key]->maxscore;
-                    $weight = $WORKSHOP_EWEIGHTS[$elements[$key]->weight];
-                    if ($weight > 0) {
-                        $totalweight += $weight;
-                    }
-                    $rawgrade += ($grade / $maxscore) * $weight;
-                }
-                $grade = 100.0 * ($rawgrade / $totalweight);
-                break;
-
-        } // end of switch
-
-
-        // any comment?
-        if (!empty($form->generalcomment)) { // update the object (no need to update the db record)
-            $assessment->generalcomment = clean_param($form->generalcomment, PARAM_CLEAN);
-        }
-
-        // redisplay form, going back to original returnto address
-        workshop_print_assessment($workshop, $assessment, true, true, $form->returnto);
-
-        // add_to_log($course->id, "workshop", "assess", "viewassessment.php?id=$cm->id&amp;aid=$assessment->id", "$assessment->id", "$cm->id");
-
-    }
-
-
-    /******************* confirm delete ************************************/
-    elseif ($action == 'confirmdelete' ) {
-
-        if (empty($aid)) {
-            print_error("Confirm delete: assessment id missing");
-            }
-
-        notice_yesno(get_string("confirmdeletionofthisitem","workshop", get_string("assessment", "workshop")),
-             "assessments.php?action=delete&amp;id=$cm->id&amp;aid=$aid", "submissions.php?action=adminlist&amp;id=$cm->id");
-        }
-
-
-    /******************* delete ************************************/
-    elseif ($action == 'delete' ) {
-
-        if (empty($aid)) {
-            print_error("Delete: submission id missing");
-            }
-
-        print_string("deleting", "workshop");
-        // first delete all the associated records...
-        delete_records("workshop_comments", "assessmentid", $aid);
-        delete_records("workshop_grades", "assessmentid", $aid);
-        // ...now delete the assessment...
-        delete_records("workshop_assessments", "id", $aid);
-
-        print_continue("view.php?id=$cm->id");
-        }
-
-
-    /*********************** admin list of asssessments (of a submission) (by teachers)**************/
-    elseif ($action == 'adminlist') {
-
-        require_capability('mod/workshop:manage', $context);
-
-        if (empty($sid)) {
-            error ("Workshop asssessments: adminlist called with no sid");
-            }
-        $submission = get_record("workshop_submissions", "id", $sid);
-        workshop_print_assessments_for_admin($workshop, $submission);
-        print_continue("submissions.php?action=adminlist&amp;id=$cm->id");
-        }
-
-
-    /*********************** admin list of asssessments by a student (used by teachers only )******************/
-    elseif ($action == 'adminlistbystudent') {
-
-        require_capability('mod/workshop:manage', $context);
-
-        if (empty($userid)) {
-            error ("Workshop asssessments: adminlistbystudent called with no userid");
-            }
-        $user = get_record("user", "id", $userid);
-        workshop_print_assessments_by_user_for_admin($workshop, $user);
-        print_continue("submissions.php?action=adminlist&amp;id=$cm->id");
-        }
-
-
-    /*************** agree (to) assessment (by student) ***************************/
-    elseif ($action == 'agreeassessment') {
-        $timenow = time();
-        // assessment id comes from link or hidden form variable
-        if (!$assessment = get_record("workshop_assessments", "id", $aid)) {
-            print_error("Assessment : agree assessment failed");
-            }
-        //save time of agreement
-        set_field("workshop_assessments", "timeagreed", $timenow, "id", $assessment->id);
-        echo "<div style=\"text-align:center\"><b>".get_string("savedok", "workshop")."</b></div><br />\n";
-
-        add_to_log($course->id, "workshop", "agree", "viewassessment.php?id=$cm->id&amp;aid=$assessment->id", "$assessment->id");
-        print_continue("view.php?id=$cm->id");
-        }
-
-
-
-    /*************** display grading form (viewed by student) *********************************/
-    elseif ($action == 'displaygradingform') {
-
-        print_heading_with_help(get_string("specimenassessmentform", "workshop"), "specimen", "workshop");
-
-        workshop_print_assessment($workshop); // called with no assessment
-        print_continue("view.php?id=$cm->id");
-    }
-
-
-    /*************** edit comment on assessment (by author, assessor or teacher) ***************************/
-    elseif ($action == 'editcomment') {
-
-        print_heading_with_help(get_string("editacomment", "workshop"), "editingacomment", "workshop");
-        // get the comment record...
-        if (!$comment = get_record("workshop_comments", "id", $cid)) {
-            print_error("Edit Comment: Comment not found");
-            }
-        if (!$assessment = get_record("workshop_assessments", "id", $comment->assessmentid)) {
-            print_error("Edit Comment: Assessment not found");
-            }
-        if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
-            print_error("Edit Comment: Submission not found");
-            }
-        ?>
-        <form id="gradingform" action="assessments.php" method="post">
-        <input type="hidden" name="action" value="updatecomment" />
-        <input type="hidden" name="id" value="<?php echo $cm->id ?>" />
-        <input type="hidden" name="cid" value="<?php echo $cid ?>" />
-        <div class="boxaligncenter">
-        <table cellpadding="5" border="1">
-        <?php
-
-        // now show the comment
-        echo "<tr valign=\"top\">\n";
-        echo "  <td align=\"right\"><b>". get_string("comment", "workshop").":</b></td>\n";
-        echo "  <td>\n";
-        echo "      <textarea name=\"comments\" rows=\"5\" cols=\"75\">\n";
-        if (isset($comment->comments)) {
-            echo $comment->comments;
-            }
-        echo "      </textarea>\n";
-        echo "  </td></tr></table>\n";
-        echo "<input type=\"submit\" value=\"".get_string("savemycomment", "workshop")."\" />\n";
-        echo "</div></form>\n";
-        workshop_print_assessment($workshop, $assessment);
-        }
-
-
-    /*********************** edit assessment elements (for teachers) ***********************/
-    elseif ($action == 'editelements') {
-
-        require_capability('mod/workshop:manage', $context);
-
-        $count = count_records("workshop_grades", "workshopid", $workshop->id);
-        if ($count) {
-            notify(get_string("warningonamendingelements", "workshop"));
-        }
-        // set up heading, form and table
-        print_heading_with_help(get_string("editingassessmentelements", "workshop"), "elements", "workshop");
-        ?>
-        <form id="form" method="post" action="assessments.php">
-        <input type="hidden" name="id" value="<?php echo $cm->id ?>" />
-        <input type="hidden" name="action" value="insertelements" />
-        <div class="boxaligncenter"><table cellpadding="5" border="1">
-        <?php
-
-        // get existing elements, if none set up appropriate default ones
-        if ($elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC" )) {
-            foreach ($elementsraw as $element) {
-                $elements[] = $element;   // to renumber index 0,1,2...
-            }
-        }
-        // check for missing elements (this happens either the first time round or when the number of elements is icreased)
-        for ($i=0; $i<$workshop->nelements; $i++) {
-            if (!isset($elements[$i])) {
-                $elements[$i]->description = '';
-                $elements[$i]->scale =0;
-                $elements[$i]->maxscore = 0;
-                $elements[$i]->weight = 11;
-            }
-        }
-
-        switch ($workshop->gradingstrategy) {
-            case 0: // no grading
-                for ($i=0; $i<$workshop->nelements; $i++) {
-                    $iplus1 = $i+1;
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td align=\"right\"><b>". get_string("element","workshop")." $iplus1:</b></td>\n";
-                    echo "<td><textarea name=\"description[]\" rows=\"3\" cols=\"75\">".$elements[$i]->description."</textarea>\n";
-                    echo "  </td></tr>\n";
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td colspan=\"2\" class=\"workshopassessmentheading\">&nbsp;</td>\n";
-                    echo "</tr>\n";
-                }
-                break;
-
-            case 1: // accumulative grading
-                // set up scales name
-                foreach ($WORKSHOP_SCALES as $KEY => $SCALE) {
-                    $SCALES[] = $SCALE['name'];
-                }
-                for ($i=0; $i<$workshop->nelements; $i++) {
-                    $iplus1 = $i+1;
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td align=\"right\"><b>". get_string("element","workshop")." $iplus1:</b></td>\n";
-                    echo "<td><textarea name=\"description[]\" rows=\"3\" cols=\"75\">".$elements[$i]->description."</textarea>\n";
-                    echo "  </td></tr>\n";
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td align=\"right\"><b>". get_string("typeofscale", "workshop"). ":</b></td>\n";
-                    echo "<td valign=\"top\">\n";
-                    choose_from_menu($SCALES, "scale[]", $elements[$i]->scale, "");
-                    if ($elements[$i]->weight == '') { // not set
-                        $elements[$i]->weight = 11; // unity
-                    }
-                    echo "</td></tr>\n";
-                    echo "<tr valign=\"top\"><td align=\"right\"><b>".get_string("elementweight", "workshop").":</b></td><td>\n";
-                    workshop_choose_from_menu($WORKSHOP_EWEIGHTS, "weight[]", $elements[$i]->weight, "");
-                    echo "      </td>\n";
-                    echo "</tr>\n";
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td colspan=\"2\" class=\"workshopassessmentheading\">&nbsp;</td>\n";
-                    echo "</tr>\n";
-                }
-                break;
-
-            case 2: // error banded grading
-                for ($i=0; $i<$workshop->nelements; $i++) {
-                    $iplus1 = $i+1;
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td align=\"right\"><b>". get_string("element","workshop")." $iplus1:</b></td>\n";
-                    echo "<td><textarea name=\"description[$i]\" rows=\"3\" cols=\"75\">".$elements[$i]->description."</textarea>\n";
-                    echo "  </td></tr>\n";
-                    if ($elements[$i]->weight == '') { // not set
-                        $elements[$i]->weight = 11; // unity
-                        }
-                    echo "</tr>\n";
-                    echo "<tr valign=\"top\"><td align=\"right\"><b>".get_string("elementweight", "workshop").":</b></td><td>\n";
-                    workshop_choose_from_menu($WORKSHOP_EWEIGHTS, "weight[]", $elements[$i]->weight, "");
-                    echo "      </td>\n";
-                    echo "</tr>\n";
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td colspan=\"2\" class=\"workshopassessmentheading\">&nbsp;</td>\n";
-                    echo "</tr>\n";
-                }
-                echo "</div></table><br />\n";
-                echo "<div style=\"text-align:center\"><b>".get_string("gradetable","workshop")."</b></div>\n";
-                echo "<div class=\"boxaligncenter\"><table cellpadding=\"5\" border=\"1\"><tr><td align=\"CENTER\">".
-                    get_string("numberofnegativeresponses", "workshop");
-                echo "</td><td>". get_string("suggestedgrade", "workshop")."</td></tr>\n";
-                for ($j = $workshop->grade; $j >= 0; $j--) {
-                    $numbers[$j] = $j;
-                }
-                for ($i=0; $i<=$workshop->nelements; $i++) {
-                    echo "<tr><td align=\"CENTER\">$i</td><td align=\"CENTER\">";
-                    if (!isset($elements[$i])) {  // the "last one" will be!
-                        $elements[$i]->description = "";
-                        $elements[$i]->maxscore = 0;
-                    }
-                    choose_from_menu($numbers, "maxscore[$i]", $elements[$i]->maxscore, "");
-                    echo "</td></tr>\n";
-                }
-                echo "</table></div>\n";
-                break;
-
-            case 3: // criterion grading
-                for ($j = 100; $j >= 0; $j--) {
-                    $numbers[$j] = $j;
-                }
-                for ($i=0; $i<$workshop->nelements; $i++) {
-                    $iplus1 = $i+1;
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td align=\"right\"><b>". get_string("criterion","workshop")." $iplus1:</b></td>\n";
-                    echo "<td><textarea name=\"description[$i]\" rows=\"3\" cols=\"75\">".$elements[$i]->description."</textarea>\n";
-                    echo "  </td></tr>\n";
-                    echo "<tr><td><b>". get_string("suggestedgrade", "workshop").":</b></td><td>\n";
-                    choose_from_menu($numbers, "maxscore[$i]", $elements[$i]->maxscore, "");
-                    echo "</td></tr>\n";
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td colspan=\"2\" class=\"workshopassessmentheading\">&nbsp;</td>\n";
-                    echo "</tr>\n";
-                }
-                break;
-
-            case 4: // rubric
-                for ($j = 100; $j >= 0; $j--) {
-                    $numbers[$j] = $j;
-                }
-                if ($rubricsraw = get_records("workshop_rubrics", "workshopid", $workshop->id)) {
-                    foreach ($rubricsraw as $rubric) {
-                        $rubrics[$rubric->elementno][$rubric->rubricno] = $rubric->description;   // reindex 0,1,2...
-                    }
-                }
-                for ($i=0; $i<$workshop->nelements; $i++) {
-                    $iplus1 = $i+1;
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td align=\"right\"><b>". get_string("element","workshop")." $iplus1:</b></td>\n";
-                    echo "<td><textarea name=\"description[$i]\" rows=\"3\" cols=\"75\">".$elements[$i]->description."</textarea>\n";
-                    echo "  </td></tr>\n";
-                    echo "<tr valign=\"top\"><td align=\"right\"><b>".get_string("elementweight", "workshop").":</b></td><td>\n";
-                    workshop_choose_from_menu($WORKSHOP_EWEIGHTS, "weight[]", $elements[$i]->weight, "");
-                    echo "      </td>\n";
-                    echo "</tr>\n";
-
-                    for ($j=0; $j<5; $j++) {
-                        $jplus1 = $j+1;
-                        if (empty($rubrics[$i][$j])) {
-                            $rubrics[$i][$j] = "";
-                        }
-                        echo "<tr valign=\"top\">\n";
-                        echo "  <td align=\"right\"><b>". get_string("grade","workshop")." $j:</b></td>\n";
-                        echo "<td><textarea name=\"rubric[$i][$j]\" rows=\"3\" cols=\"75\">".$rubrics[$i][$j]."</textarea>\n";
-                        echo "  </td></tr>\n";
-                        }
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td colspan=\"2\" class=\"workshopassessmentheading\">&nbsp;</td>\n";
-                    echo "</tr>\n";
-                    }
-                break;
-            }
-        // close table and form
-
-        ?>
-        </table><br />
-        <input type="submit" value="<?php  print_string("savechanges") ?>" />
-        <input type="submit" name="cancel" value="<?php  print_string("cancel") ?>" />
-        </div>
-        </form>
-        <?php
-    }
-
-
-    /*************** grade all assessments (by teacher) ***************************/
-    elseif ($action == 'gradeallassessments') {
-
-        require_capability('mod/workshop:manage', $context);
-
-        print_heading(get_string("gradingallassessments", "workshop"));
-        workshop_grade_assessments($workshop);
-        print_continue("view.php?id=$cm->id");
-    }
-
-
-    /*************** grade (student's) assessment (by teacher) ***************************/
-    elseif ($action == 'gradeassessment') {
-
-        require_capability('mod/workshop:manage', $context);
-
-        print_heading_with_help(get_string("gradeassessment", "workshop"), "gradingassessments", "workshop");
-        // get assessment record
-        if (!$assessmentid = $aid) {
-            print_error("Assessment id not given");
-        }
-        $assessment = get_record("workshop_assessments", "id", $assessmentid);
-        if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
-            print_error("Submission not found");
-        }
-        // get the teacher's assessment first
-        if ($teachersassessment = workshop_get_submission_assessment($submission, $USER)) {
-            echo "<div style=\"text-align:center\"><b>".get_string("teacherassessments", "workshop", $course->teacher)."</b></div>\n";
-            workshop_print_assessment($workshop, $teachersassessment);
-        }
-        // now the student's assessment (don't allow changes)
-        $user = get_record("user", "id", $assessment->userid);
-        echo "<div style=\"text-align:center\"><b>".get_string("assessmentby", "workshop", $user->firstname." ".$user->lastname)."</b></div>\n";
-        workshop_print_assessment($workshop, $assessment);
-
-        include('assessment_grading_form.html');
-        die;
-    }
-
-
-    /*************** insert (new) comment (by author, assessor or teacher) ***************************/
-    elseif ($action == 'insertcomment') {
-        $timenow = time();
-
-        $form = (object)$_POST;
-
-        if (!$assessment = get_record("workshop_assessments", "id", $aid)) {
-            print_error("Unable to insert comment");
-            }
-        // save the comment...
-        $comment->workshopid = $workshop->id;
-        $comment->assessmentid   = $assessment->id;
-        $comment->userid   = $USER->id;
-        $comment->timecreated   = $timenow;
-        $comment->comments   = clean_param($form->comments, PARAM_CLEAN);
-        if (!$comment->id = insert_record("workshop_comments", $comment)) {
-            print_error("Could not insert workshop comment!");
-            }
-
-        add_to_log($course->id, "workshop", "comment", "view.php?id=$cm->id", "$comment->id");
-
-        print_continue("viewassessment.php?id=$cm->id&amp;aid=$assessment->id");
-        }
-
-
-    /*********************** insert/update assignment elements (for teachers)***********************/
-    elseif ($action == 'insertelements') {
-
-        require_capability('mod/workshop:manage', $context);
-
-        $form = data_submitted();
-
-        // let's not fool around here, dump the junk!
-        delete_records("workshop_elements", "workshopid", $workshop->id);
-
-        // determine wich type of grading
-        switch ($workshop->gradingstrategy) {
-            case 0: // no grading
-                // Insert all the elements that contain something
-                foreach ($form->description as $key => $description) {
-                    if ($description) {
-                        unset($element);
-                        $element->description   = $description;
-                        $element->workshopid = $workshop->id;
-                        $element->elementno = $key;
-                        if (!$element->id = insert_record("workshop_elements", $element)) {
-                            print_error("Could not insert workshop element!");
-                        }
-                    }
-                }
-                break;
-
-            case 1: // accumulative grading
-                // Insert all the elements that contain something
-                foreach ($form->description as $key => $description) {
-                    if ($description) {
-                        unset($element);
-                        $element->description   = $description;
-                        $element->workshopid = $workshop->id;
-                        $element->elementno = clean_param($key, PARAM_INT);
-                        if (isset($form->scale[$key])) {
-                            $element->scale = $form->scale[$key];
-                            switch ($WORKSHOP_SCALES[$form->scale[$key]]['type']) {
-                                case 'radio' :  $element->maxscore = $WORKSHOP_SCALES[$form->scale[$key]]['size'] - 1;
-                                                        break;
-                                case 'selection' :  $element->maxscore = $WORKSHOP_SCALES[$form->scale[$key]]['size'];
-                                                        break;
-                            }
-                        }
-                        if (isset($form->weight[$key])) {
-                            $element->weight = $form->weight[$key];
-                        }
-                        if (!$element->id = insert_record("workshop_elements", $element)) {
-                            print_error("Could not insert workshop element!");
-                        }
-                    }
-                }
-                break;
-
-            case 2: // error banded grading...
-            case 3: // ...and criterion grading
-                // Insert all the elements that contain something, the number of descriptions is one less than the number of grades
-                foreach ($form->maxscore as $key => $themaxscore) {
-                    unset($element);
-                    $element->workshopid = $workshop->id;
-                    $element->elementno = clean_param($key, PARAM_INT);
-                    $element->maxscore = $themaxscore;
-                    if (isset($form->description[$key])) {
-                        $element->description   = $form->description[$key];
-                    }
-                    if (isset($form->weight[$key])) {
-                        $element->weight = $form->weight[$key];
-                    }
-                    if (!$element->id = insert_record("workshop_elements", $element)) {
-                        print_error("Could not insert workshop element!");
-                    }
-                }
-                break;
-
-            case 4: // ...and criteria grading
-                // Insert all the elements that contain something
-                foreach ($form->description as $key => $description) {
-                    unset($element);
-                    $element->workshopid = $workshop->id;
-                    $element->elementno = clean_param($key, PARAM_INT);
-                    $element->description   = $description;
-                    $element->weight = $form->weight[$key];
-                    for ($j=0;$j<5;$j++) {
-                        if (empty($form->rubric[$key][$j]))
-                            break;
-                    }
-                    $element->maxscore = $j - 1;
-                    if (!$element->id = insert_record("workshop_elements", $element)) {
-                        print_error("Could not insert workshop element!");
-                    }
-                }
-                // let's not fool around here, dump the junk!
-                delete_records("workshop_rubrics", "workshopid", $workshop->id);
-                for ($i=0;$i<$workshop->nelements;$i++) {
-                    for ($j=0;$j<5;$j++) {
-                        unset($element);
-                        if (empty($form->rubric[$i][$j])) {  // OK to have an element with fewer than 5 items
-                             break;
-                         }
-                        $element->workshopid = $workshop->id;
-                        $element->elementno = $i;
-                        $element->rubricno = $j;
-                        $element->description   = $form->rubric[$i][$j];
-                        if (!$element->id = insert_record("workshop_rubrics", $element)) {
-                            print_error("Could not insert workshop element!");
-                        }
-                    }
-                }
-                break;
-        } // end of switch
-        echo "</div>"; // not sure where this one came from MDL-7861
-        redirect("view.php?id=$cm->id", get_string("savedok","workshop"));
-    }
-
-
-    /*********************** list assessments for grading (Student submissions)(by teachers)***********************/
-    elseif ($action == 'listungradedstudentsubmissions') {
-
-        require_capability('mod/workshop:manage', $context);
-
-        workshop_list_ungraded_assessments($workshop, "student");
-        print_continue("view.php?id=$cm->id");
-        }
-
-
-    /*********************** list assessments for grading (Teacher submissions) (by teachers)***********************/
-    elseif ($action == 'listungradedteachersubmissions') {
-
-        require_capability('mod/workshop:manage', $context);
-
-        workshop_list_ungraded_assessments($workshop, "teacher");
-        print_continue("view.php?id=$cm->id");
-        }
-
-
-    /****************** list teacher submissions ***********************/
-    elseif ($action == 'listteachersubmissions') {
-
-        workshop_list_teacher_submissions($workshop, $USER);
-        print_continue("view.php?id=$cm->id");
-    }
-
-
-    /******************* regrade student assessments ************************************/
-    elseif ($action == 'regradestudentassessments' ) {
-
-        $timenow = time();
-        require_capability('mod/workshop:manage', $context);
-        // get all the submissions...
-        if ($submissions = get_records("workshop_submissions", "workshopid", $workshop->id)) {
-            foreach ($submissions as $submission) {
-                // ...if cold...
-                if (($submission->timecreated + $CFG->maxeditingtime) < $timenow) {
-                    // ...clear assessment count so workshop_grade_assessments() can do its thing
-                    set_field("workshop_submissions", "nassessments", 0, "id", $submission->id);
-                }
-            }
-        }
-        echo "<pre>";
-        workshop_grade_assessments($workshop);
-        echo '</pre>';
-        print_continue("submissions.php?id=$cm->id&action=adminlist");
-    }
-
-
-    /*************** remove stock comment (by teacher ) ***************************/
-    elseif ($action == 'removestockcomment') {
-
-        if (empty($aid) or empty($stockcommentid)) {
-            print_error("Workshop Assessment id and/or Stock Comment id missing");
-        }
-
-        require_capability('mod/workshop:manage', $context);
-
-        if (!$assessment = get_record("workshop_assessments", "id", $aid)) {
-            print_error("workshop assessment is misconfigured");
-        }
-        $form = data_submitted('nomatch'); //Nomatch because we can come from assess.php
-
-        // delete the comment from the stock comments table
-        if (!delete_records("workshop_stockcomments", "id", $stockcommentid)) {
-            print_error("Could not remove comment from the comment bank");
-        }
-
-        // now upate the assessment (just the elements, the assessment itself is not updated)
-
-        // first get the assignment elements for maxscores and weights...
-        $elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC");
-        if (count($elementsraw) < $workshop->nelements) {
-            print_string("noteonassignmentelements", "workshop");
-        }
-        if ($elementsraw) {
-            foreach ($elementsraw as $element) {
-                $elements[] = $element;   // to renumber index 0,1,2...
-            }
-        } else {
-            $elements = null;
-        }
-
-        $timenow = time();
-        // don't fiddle about, delete all the old and add the new!
-        delete_records("workshop_grades", "assessmentid",  $assessment->id);
-
-
-        //determine what kind of grading we have
-        switch ($workshop->gradingstrategy) {
-            case 0: // no grading
-                // Insert all the elements that contain something
-                for ($i =0; $i < $workshop->nelements; $i++) {
-                    unset($element);
-                    $element->workshopid = $workshop->id;
-                    $element->assessmentid = $assessment->id;
-                    $element->elementno = $i;
-                    $element->feedback   = clean_param($form->{"feedback_$i"}, PARAM_CLEAN);
-                    if (!$element->id = insert_record("workshop_grades", $element)) {
-                        print_error("Could not insert workshop grade!");
-                    }
-                }
-                $grade = 0; // set to satisfy save to db
-                break;
-
-            case 1: // accumulative grading
-                // Insert all the elements that contain something
-                foreach ($form->grade as $key => $thegrade) {
-                    unset($element);
-                    $element->workshopid = $workshop->id;
-                    $element->assessmentid = $assessment->id;
-                    $element->elementno = clean_param($key, PARAM_INT);
-                    $element->feedback   = clean_param($form->{"feedback_$key"}, PARAM_CLEAN);
-                    $element->grade = $thegrade;
-                    if (!$element->id = insert_record("workshop_grades", $element)) {
-                        print_error("Could not insert workshop grade!");
-                        }
-                    }
-                // now work out the grade...
-                $rawgrade=0;
-                $totalweight=0;
-                foreach ($form->grade as $key => $grade) {
-                    $maxscore = $elements[$key]->maxscore;
-                    $weight = $WORKSHOP_EWEIGHTS[$elements[$key]->weight];
-                    if ($weight > 0) {
-                        $totalweight += $weight;
-                    }
-                    $rawgrade += ($grade / $maxscore) * $weight;
-                    // echo "\$key, \$maxscore, \$weight, \$totalweight, \$grade, \$rawgrade : $key, $maxscore, $weight, $totalweight, $grade, $rawgrade<br />";
-                }
-                $grade = 100.0 * ($rawgrade / $totalweight);
-                break;
-
-            case 2: // error banded graded
-                // Insert all the elements that contain something
-                $error = 0.0;
-                for ($i =0; $i < $workshop->nelements; $i++) {
-                    unset($element);
-                    $element->workshopid = $workshop->id;
-                    $element->assessmentid = $assessment->id;
-                    $element->elementno = $i;
-                    $element->feedback   = clean_param($form->{"feedback_$i"}, PARAM_CLEAN);
-                    $element->grade = $form->grade[$i];
-                    if (!$element->id = insert_record("workshop_grades", $element)) {
-                        print_error("Could not insert workshop grade!");
-                    }
-                    if (empty($form->grade[$i])){
-                        $error += $WORKSHOP_EWEIGHTS[$elements[$i]->weight];
-                    }
-                }
-                // now save the adjustment
-                unset($element);
-                $i = $workshop->nelements;
-                $element->workshopid = $workshop->id;
-                $element->assessmentid = $assessment->id;
-                $element->elementno = $i;
-                $element->grade = $form->grade[$i];
-                if (!$element->id = insert_record("workshop_grades", $element)) {
-                    print_error("Could not insert workshop grade!");
-                }
-                $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i]) * 100 / $workshop->grade;
-                // do sanity check
-                if ($grade < 0) {
-                    $grade = 0;
-                } elseif ($grade > 100) {
-                    $grade = 100;
-                }
-                echo "<b>".get_string("weightederrorcount", "workshop", intval($error + 0.5))."</b>\n";
-                break;
-
-            case 3: // criteria grading
-                // save in the selected criteria value in element zero,
-                unset($element);
-                $element->workshopid = $workshop->id;
-                $element->assessmentid = $assessment->id;
-                $element->elementno = 0;
-                $element->grade = $form->grade[0];
-                if (!$element->id = insert_record("workshop_grades", $element)) {
-                    print_error("Could not insert workshop grade!");
-                }
-                // now save the adjustment in element one
-                unset($element);
-                $element->workshopid = $workshop->id;
-                $element->assessmentid = $assessment->id;
-                $element->elementno = 1;
-                $element->grade = $form->grade[1];
-                if (!$element->id = insert_record("workshop_grades", $element)) {
-                    print_error("Could not insert workshop grade!");
-                }
-                $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]);
-                break;
-
-            case 4: // rubric grading (identical to accumulative grading)
-                // Insert all the elements that contain something
-                foreach ($form->grade as $key => $thegrade) {
-                    unset($element);
-                    $element->workshopid = $workshop->id;
-                    $element->assessmentid = $assessment->id;
-                    $element->elementno = clean_param($key, PARAM_INT);
-                    $element->feedback   = clean_param($form->{"feedback_$key"}, PARAM_CLEAN);
-                    $element->grade = $thegrade;
-                    if (!$element->id = insert_record("workshop_grades", $element)) {
-                        print_error("Could not insert workshop grade!");
-                    }
-                }
-                // now work out the grade...
-                $rawgrade=0;
-                $totalweight=0;
-                foreach ($form->grade as $key => $grade) {
-                    $maxscore = $elements[$key]->maxscore;
-                    $weight = $WORKSHOP_EWEIGHTS[$elements[$key]->weight];
-                    if ($weight > 0) {
-                        $totalweight += $weight;
-                    }
-                    $rawgrade += ($grade / $maxscore) * $weight;
-                }
-                $grade = 100.0 * ($rawgrade / $totalweight);
-                break;
-
-        } // end of switch
-
-
-        // any comment?
-        if (!empty($form->generalcomment)) { // update the object (no need to update the db record)
-            $assessment->generalcomment = clean_param($form->generalcomment, PARAM_CLEAN);
-        }
-
-        // redisplay form, going back to original returnto address
-        workshop_print_assessment($workshop, $assessment, true, true, $form->returnto);
-
-        // add_to_log($course->id, "workshop", "assess", "viewassessment.php?id=$cm->id&amp;aid=$assessment->id", "$assessment->id", "$cm->id");
-
-    }
-
-
-    /*************** update assessment (by teacher or student) ***************************/
-    elseif ($action == 'updateassessment') {
-
-        if (empty($aid)) {
-            print_error("Workshop Assessment id missing");
-        }
-
-        if (! $assessment = get_record("workshop_assessments", "id", $aid)) {
-            print_error("workshop assessment is misconfigured");
-        }
-
-        // first get the assignment elements for maxscores and weights...
-        $elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC");
-        if (count($elementsraw) < $workshop->nelements) {
-            print_string("noteonassignmentelements", "workshop");
-        }
-        if ($elementsraw) {
-            foreach ($elementsraw as $element) {
-                $elements[] = $element;   // to renumber index 0,1,2...
-            }
-        } else {
-            $elements = null;
-        }
-
-        $timenow = time();
-        // don't fiddle about, delete all the old and add the new!
-        delete_records("workshop_grades", "assessmentid",  $assessment->id);
-
-        $form = data_submitted('nomatch'); //Nomatch because we can come from assess.php
-
-        //determine what kind of grading we have
-        switch ($workshop->gradingstrategy) {
-            case 0: // no grading
-                // Insert all the elements that contain something
-                for ($i = 0; $i < $workshop->nelements; $i++) {
-                    unset($element);
-                    $element->workshopid = $workshop->id;
-                    $element->assessmentid = $assessment->id;
-                    $element->elementno = $i;
-                    $element->feedback = clean_param($form->{"feedback_$i"}, PARAM_CLEAN);
-                    if (!$element->id = insert_record("workshop_grades", $element)) {
-                        print_error("Could not insert workshop grade!");
-                    }
-                }
-                $grade = 0; // set to satisfy save to db
-                break;
-
-            case 1: // accumulative grading
-                // Insert all the elements that contain something
-                foreach ($form->grade as $key => $thegrade) {
-                    unset($element);
-                    $element->workshopid = $workshop->id;
-                    $element->assessmentid = $assessment->id;
-                    $element->elementno = $key;
-                    $element->feedback   = clean_param($form->{"feedback_$key"}, PARAM_CLEAN);
-                    $element->grade = $thegrade;
-                    if (!$element->id = insert_record("workshop_grades", $element)) {
-                        print_error("Could not insert workshop grade!");
-                        }
-                    }
-                // now work out the grade...
-                $rawgrade=0;
-                $totalweight=0;
-                foreach ($form->grade as $key => $grade) {
-                    $maxscore = $elements[$key]->maxscore;
-                    $weight = $WORKSHOP_EWEIGHTS[$elements[$key]->weight];
-                    if ($weight > 0) {
-                        $totalweight += $weight;
-                    }
-                    $rawgrade += ($grade / $maxscore) * $weight;
-                    // echo "\$key, \$maxscore, \$weight, \$totalweight, \$grade, \$rawgrade : $key, $maxscore, $weight, $totalweight, $grade, $rawgrade<br />";
-                }
-                $grade = 100.0 * ($rawgrade / $totalweight);
-                break;
-
-            case 2: // error banded graded
-                // Insert all the elements that contain something
-                $error = 0.0;
-                for ($i =0; $i < $workshop->nelements; $i++) {
-                    unset($element);
-                    $element->workshopid = $workshop->id;
-                    $element->assessmentid = $assessment->id;
-                    $element->elementno = $i;
-                    $element->feedback   = $form->{"feedback_$i"};
-                    $element->grade = clean_param($form->grade[$i], PARAM_CLEAN);
-                    if (!$element->id = insert_record("workshop_grades", $element)) {
-                        print_error("Could not insert workshop grade!");
-                    }
-                    if (empty($form->grade[$i])){
-                        $error += $WORKSHOP_EWEIGHTS[$elements[$i]->weight];
-                    }
-                }
-                // now save the adjustment
-                unset($element);
-                $i = $workshop->nelements;
-                $element->workshopid = $workshop->id;
-                $element->assessmentid = $assessment->id;
-                $element->elementno = $i;
-                $element->grade = $form->grade[$i];
-                if (!$element->id = insert_record("workshop_grades", $element)) {
-                    print_error("Could not insert workshop grade!");
-                }
-                $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i]) * 100 / $workshop->grade;
-                // do sanity check
-                if ($grade < 0) {
-                    $grade = 0;
-                } elseif ($grade > 100) {
-                    $grade = 100;
-                }
-                echo "<b>".get_string("weightederrorcount", "workshop", intval($error + 0.5))."</b>\n";
-                break;
-
-            case 3: // criteria grading
-                // save in the selected criteria value in element zero,
-                unset($element);
-                $element->workshopid = $workshop->id;
-                $element->assessmentid = $assessment->id;
-                $element->elementno = 0;
-                $element->grade = $form->grade[0];
-                if (!$element->id = insert_record("workshop_grades", $element)) {
-                    print_error("Could not insert workshop grade!");
-                }
-                // now save the adjustment in element one
-                unset($element);
-                $element->workshopid = $workshop->id;
-                $element->assessmentid = $assessment->id;
-                $element->elementno = 1;
-                $element->grade = $form->grade[1];
-                if (!$element->id = insert_record("workshop_grades", $element)) {
-                    print_error("Could not insert workshop grade!");
-                }
-                $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]);
-                break;
-
-            case 4: // rubric grading (identical to accumulative grading)
-                // Insert all the elements that contain something
-                foreach ($form->grade as $key => $thegrade) {
-                    unset($element);
-                    $element->workshopid = $workshop->id;
-                    $element->assessmentid = $assessment->id;
-                    $element->elementno = clean_param($key, PARAM_INT);
-                    $element->feedback = clean_param($form->{"feedback_$key"}, PARAM_CLEAN);
-                    $element->grade = $thegrade;
-                    if (!$element->id = insert_record("workshop_grades", $element)) {
-                        print_error("Could not insert workshop grade!");
-                    }
-                }
-                // now work out the grade...
-                $rawgrade=0;
-                $totalweight=0;
-                foreach ($form->grade as $key => $grade) {
-                    $maxscore = $elements[$key]->maxscore;
-                    $weight = $WORKSHOP_EWEIGHTS[$elements[$key]->weight];
-                    if ($weight > 0) {
-                        $totalweight += $weight;
-                    }
-                    $rawgrade += ($grade / $maxscore) * $weight;
-                }
-                $grade = 100.0 * ($rawgrade / $totalweight);
-                break;
-
-        } // end of switch
-
-        // update the time of the assessment record (may be re-edited)...
-        set_field("workshop_assessments", "timecreated", $timenow, "id", $assessment->id);
-
-        if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
-            error ("Updateassessment: submission record not found");
-        }
-
-        // if the workshop does need peer agreement AND it's self assessment then set timeagreed
-        if ($workshop->agreeassessments and ($submission->userid == $assessment->userid)) {
-            set_field("workshop_assessments", "timeagreed", $timenow, "id", $assessment->id);
-        }
-
-        // set grade...
-        set_field("workshop_assessments", "grade", $grade, "id", $assessment->id);
-        // ...and clear the timegraded but set the graddinggrade to maximum, may be reduced subsequently...
-        set_field("workshop_assessments", "timegraded", 0, "id", $assessment->id);
-        set_field("workshop_assessments", "gradinggrade", 100, "id", $assessment->id);
-        // ...and the resubmission flag
-        set_field("workshop_assessments", "resubmission", 0, "id", $assessment->id);
-
-        // if there's examples or peer assessments clear the counter in the submission so that
-        // all assessments for this submission will be regraded
-        if ($workshop->ntassessments or $workshop->nsassessments) {
-            set_field("workshop_submissions", "nassessments", 0, "id", $submission->id);
-            workshop_grade_assessments($workshop);
-        } else { // it could be self assessment....
-            // now see if there's a corresponding assessment so that the gradinggrade can be set
-            if (workshop_is_teacher($workshop)) {
-                // see if there's are student assessments, if so set their gradinggrade
-                if ($assessments = workshop_get_assessments($submission)) {
-                    foreach($assessments as $studentassessment) {
-                        // skip if it's not a student assessment
-                        if (!workshop_is_student($workshop, $studentassessment->userid)) {
-                            continue;
-                        }
-                        $gradinggrade = workshop_compare_assessments($workshop, $assessment, $studentassessment);
-                        set_field("workshop_assessments", "timegraded", $timenow, "id", $studentassessment->id);
-                        set_field("workshop_assessments", "gradinggrade", $gradinggrade, "id", $studentassessment->id);
-                    }
-                }
-            } else { //it's a student assessment, see if there's a corresponding teacher's assessment
-                if ($assessments = workshop_get_assessments($submission)) {
-                    foreach($assessments as $teacherassessment) {
-                        if (workshop_is_teacher($workshop, $teacherassessment->userid)) {
-                            $gradinggrade = workshop_compare_assessments($workshop, $assessment, $teacherassessment);
-                            set_field("workshop_assessments", "timegraded", $timenow, "id", $assessment->id);
-                            set_field("workshop_assessments", "gradinggrade", $gradinggrade, "id", $assessment->id);
-                            break; // only look for the first teacher assessment
-                        }
-                    }
-                }
-            }
-        }
-
-        // any comment?
-        if (!empty($form->generalcomment)) {
-            set_field("workshop_assessments", "generalcomment", clean_param($form->generalcomment, PARAM_CLEAN), "id", $assessment->id);
-        }
-
-        add_to_log($course->id, "workshop", "assess",
-                "viewassessment.php?id=$cm->id&amp;aid=$assessment->id", "$assessment->id", "$cm->id");
-
-        // set up return address
-        if (!$returnto = $form->returnto) {
-            $returnto = "view.php?id=$cm->id";
-        }
-
-        // show grade if grading strategy is not zero
-        if ($workshop->gradingstrategy) {
-            echo "</div>"; // MDL-7861, this is from <div id=page>
-            redirect($returnto, get_string("thegradeis", "workshop").": ".
-                    number_format($grade * $workshop->grade / 100, 2).
-                    " (".get_string("maximumgrade")." ".number_format($workshop->grade).")");
-        }
-        else {
-            redirect($returnto);
-        }
-        
-    }
-
-
-    /****************** update comment (by author, assessor or teacher) ********************/
-    elseif ($action == 'updatecomment') {
-        $timenow = time();
-
-        $form = (object)$_POST;
-
-        // get the comment record...
-        if (!$comment = get_record("workshop_comments", "id", $_POST['cid'])) {
-            print_error("Update to Comment failed");
-        }
-        if (!$assessment = get_record("workshop_assessments", "id", $comment->assessmentid)) {
-            print_error("Update Comment: Assessment not found");
-        }
-        //save the comment for the assessment...
-        if (isset($form->comments)) {
-            set_field("workshop_comments", "comments", $form->comments, "id", $comment->id);
-            set_field("workshop_comments", "timecreated", $timenow, "id", $comment->id);
-            // ..and kick to comment into life (probably not needed but just in case)
-            set_field("workshop_comments", "mailed", 0, "id", $comment->id);
-            echo "<centre><b>".get_string("savedok", "workshop")."</b></div><br />\n";
-
-            add_to_log($course->id, "workshop", "comment",
-                    "viewassessment.php?id=$cm->id&amp;aid=$assessment->id", "$comment->id");
-        }
-
-        print_continue("viewassessment.php?id=$cm->id&amp;aid=$assessment->id");
-    }
-
-
-    /****************** update grading (by teacher) ***************************/
-    elseif ($action == 'updategrading') {
-        $timenow = time();
-
-        require_capability('mod/workshop:manage', $context);
-
-        $form = (object)$_POST;
-
-        if (!$assessment = get_record("workshop_assessments", "id", $_POST['aid'])) {
-            print_error("Update Grading failed");
-        }
-        //save the comment and grade for the assessment
-        if (isset($form->teachercomment)) {
-            set_field("workshop_assessments", "teachercomment", $form->teachercomment, "id", $assessment->id);
-            set_field("workshop_assessments", "gradinggrade", $form->gradinggrade, "id", $assessment->id);
-            set_field("workshop_assessments", "timegraded", $timenow, "id", $assessment->id);
-            set_field("workshop_assessments", "mailed", 0, "id", $assessment->id);
-            set_field("workshop_assessments", "teachergraded", 1, "id", $assessment->id);
-            echo "<centre><b>".get_string("savedok", "workshop")."</b></centre><br />\n";
-
-            add_to_log($course->id, "workshop", "grade",
-                 "viewassessment.php?id=$cm->id&amp;aid=$assessment->id", "$assessment->id", "$cm->id");
-        }
-        redirect($form->redirect);
-    }
-
-
-    /****************** view all assessments ***********************/
-    elseif ($action == 'viewallassessments') {
-
-        if (!$submission = get_record("workshop_submissions", "id", $sid)) {
-            print_error("View All Assessments: submission record not found");
-        }
-
-        if ($assessments = workshop_get_assessments($submission)) {
-            foreach ($assessments as $assessment) {
-                workshop_print_assessment($workshop, $assessment);
-            }
-        }
-        // only called from list all submissions
-        print_continue("submissions.php?action=listallsubmissions&amp;id=$cm->id");
-    }
-
-    /*************** no man's land **************************************/
-    else {
-        print_error("Fatal Error: Unknown Action: ".$action."\n");
-    }
-    print_footer($course);
-
-?>
diff --git a/mod/workshop/backuplib.php b/mod/workshop/backuplib.php
deleted file mode 100644 (file)
index ed4b37b..0000000
+++ /dev/null
@@ -1,512 +0,0 @@
-<?php //$Id$
-    //This php script contains all the stuff to backup/restore
-    //workshop mods
-
-    //This is the "graphical" structure of the workshop mod:
-    //
-    //                                          workshop
-    //                                         (CL,pk->id)             
-    //                                             |
-    //                                             |
-    //                                             |
-    //              |------------------------------|-----------------------------------------------------|
-    //              |                                                                                    |
-    //              |                                                                                    |
-    //              |                                                                                    |
-    //              |                                                                            workshop_submissions
-    //              |                                                                        (UL,pk->id,fk->workshopid,files)
-    //              |                                                                                    |
-    //              |        |-------------------------------------|      |----------------------|       |
-    //              |        |                                     |      |                      |       |
-    //             workshop_elements                           workshop_grades                  workshop_assessments
-    //         (CL,pk->id,fk->workshopid)                (UL,pk->id,fk->assessmentid)       (UL,pk->id,fk->submissionid)
-    //              |                  |                 (          fk->elementno   )                    |
-    //              |                  |                                                                 |
-    //              |                  |                                                                 |
-    //      workshop_rubrics          workshop_stockcomments                                        workshop_comments
-    // (CL,pk->id,fk->elementno)   (CL, pk->id, fk->elementno)                             (UL,pk->id,fk->assessmentid)
-    //
-    // Meaning: pk->primary key field of the table
-    //          fk->foreign key to link with parent
-    //          nt->nested field (recursive data)
-    //          CL->course level info
-    //          UL->user level info
-    //          files->table may have files)
-    //
-    //-----------------------------------------------------------
-
-    //This function executes all the backup procedure about this mod
-    function workshop_backup_mods($bf,$preferences) {
-
-        global $CFG;
-
-        $status = true;
-
-        //Iterate over workshop table
-        $workshops = get_records ("workshop","course",$preferences->backup_course,"id");
-        if ($workshops) {
-            foreach ($workshops as $workshop) {
-                if (backup_mod_selected($preferences,'workshop',$workshop->id)) {
-                    $status = workshop_backup_one_mod($bf,$preferences,$workshop);
-                }
-            }
-        }
-        return $status;  
-    }
-
-    function workshop_backup_one_mod($bf,$preferences,$workshop) {
-
-        $status = true;
-
-        if (is_numeric($workshop)) {
-            $workshop = get_record('workshop','id',$workshop);
-        }
-        $instanceid = $workshop->id;
-
-        //Start mod
-        fwrite ($bf,start_tag("MOD",3,true));
-        //Print workshop data
-        fwrite ($bf,full_tag("ID",4,false,$workshop->id));
-        fwrite ($bf,full_tag("MODTYPE",4,false,"workshop"));
-        fwrite ($bf,full_tag("NAME",4,false,$workshop->name));
-        fwrite ($bf,full_tag("DESCRIPTION",4,false,$workshop->description));
-        fwrite ($bf,full_tag("WTYPE",4,false,$workshop->wtype));
-        fwrite ($bf,full_tag("NELEMENTS",4,false,$workshop->nelements));
-        fwrite ($bf,full_tag("NATTACHMENTS",4,false,$workshop->nattachments));
-        fwrite ($bf,full_tag("FORMAT",4,false,$workshop->format));
-        fwrite ($bf,full_tag("GRADINGSTRATEGY",4,false,$workshop->gradingstrategy));
-        fwrite ($bf,full_tag("RESUBMIT",4,false,$workshop->resubmit));
-        fwrite ($bf,full_tag("AGREEASSESSMENTS",4,false,$workshop->agreeassessments));
-        fwrite ($bf,full_tag("HIDEGRADES",4,false,$workshop->hidegrades));
-        fwrite ($bf,full_tag("ANONYMOUS",4,false,$workshop->anonymous));
-        fwrite ($bf,full_tag("INCLUDESELF",4,false,$workshop->includeself));
-        fwrite ($bf,full_tag("MAXBYTES",4,false,$workshop->maxbytes));
-        fwrite ($bf,full_tag("SUBMISSIONSTART",4,false,$workshop->submissionstart));
-        fwrite ($bf,full_tag("ASSESSMENTSTART",4,false,$workshop->assessmentstart));
-        fwrite ($bf,full_tag("SUBMISSIONEND",4,false,$workshop->submissionend));
-        fwrite ($bf,full_tag("ASSESSMENTEND",4,false,$workshop->assessmentend));
-        fwrite ($bf,full_tag("RELEASEGRADES",4,false,$workshop->releasegrades));
-        fwrite ($bf,full_tag("GRADE",4,false,$workshop->grade));
-        fwrite ($bf,full_tag("GRADINGGRADE",4,false,$workshop->gradinggrade));
-        fwrite ($bf,full_tag("NTASSESSMENTS",4,false,$workshop->ntassessments));
-        fwrite ($bf,full_tag("ASSESSMENTCOMPS",4,false,$workshop->assessmentcomps));
-        fwrite ($bf,full_tag("NSASSESSMENTS",4,false,$workshop->nsassessments));
-        fwrite ($bf,full_tag("OVERALLOCATION",4,false,$workshop->overallocation));
-        fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$workshop->timemodified));
-        fwrite ($bf,full_tag("TEACHERWEIGHT",4,false,$workshop->teacherweight));
-        fwrite ($bf,full_tag("SHOWLEAGUETABLE",4,false,$workshop->showleaguetable));
-        fwrite ($bf,full_tag("USEPASSWORD",4,false,$workshop->usepassword));
-        fwrite ($bf,full_tag("PASSWORD",4,false,$workshop->password));
-        //Now we backup workshop elements
-        $status = backup_workshop_elements($bf,$preferences,$workshop->id);
-
-        //if we've selected to backup users info, then execute backup_workshop_submisions
-        if (backup_userdata_selected($preferences,'workshop',$workshop->id)) {
-            $ws = array();
-            $status = backup_workshop_submissions($bf,$preferences,$workshop->id,$ws);
-            $status = backup_workshop_files_instance($bf,$preferences,$workshop->id,$ws);
-        }
-        
-        //End mod
-        $status =fwrite ($bf,end_tag("MOD",3,true));
-
-        return $status;
-    }
-
-    //Backup workshop_elements contents (executed from workshop_backup_mods)
-    function backup_workshop_elements ($bf,$preferences,$workshop) {
-
-        global $CFG;
-
-        $status = true;
-
-        $workshop_elements = get_records("workshop_elements","workshopid",$workshop,"id");
-        //If there is workshop_elements
-        if ($workshop_elements) {
-            //Write start tag
-            $status =fwrite ($bf,start_tag("ELEMENTS",4,true));
-            //Iterate over each element
-            foreach ($workshop_elements as $wor_ele) {
-                //Start element
-                $status =fwrite ($bf,start_tag("ELEMENT",5,true));
-                //Print element contents
-                fwrite ($bf,full_tag("ELEMENTNO",6,false,$wor_ele->elementno));
-                fwrite ($bf,full_tag("DESCRIPTION",6,false,$wor_ele->description));
-                fwrite ($bf,full_tag("SCALE",6,false,$wor_ele->scale));
-                fwrite ($bf,full_tag("MAXSCORE",6,false,$wor_ele->maxscore));
-                fwrite ($bf,full_tag("WEIGHT",6,false,$wor_ele->weight));
-                fwrite ($bf,full_tag("STDDEV",6,false,$wor_ele->stddev));
-                fwrite ($bf,full_tag("TOTALASSESSMENTS",6,false,$wor_ele->totalassessments));
-                //Now we backup workshop rubrics
-                $status = backup_workshop_rubrics($bf,$preferences,$workshop,$wor_ele->elementno);
-                //Now we backup element's stock comments
-                $status = backup_workshop_stockcomments($bf,$preferences,$workshop,$wor_ele->elementno);
-                //End element
-                $status =fwrite ($bf,end_tag("ELEMENT",5,true));
-            }
-            //Write end tag
-            $status =fwrite ($bf,end_tag("ELEMENTS",4,true));
-        }
-        return $status;
-    }
-
-    //Backup workshop_rubrics contents (executed from backup_workshop_elements)
-    function backup_workshop_rubrics ($bf,$preferences,$workshop,$elementno) {
-
-        global $CFG;
-
-        $status = true;
-
-        $workshop_rubrics = get_records_sql("SELECT * from {$CFG->prefix}workshop_rubrics r
-                                             WHERE r.workshopid = '$workshop' and r.elementno = '$elementno'
-                                             ORDER BY r.elementno");
-
-        //If there is workshop_rubrics
-        if ($workshop_rubrics) {
-            //Write start tag
-            $status =fwrite ($bf,start_tag("RUBRICS",6,true));
-            //Iterate over each element
-            foreach ($workshop_rubrics as $wor_rub) {
-                //Start rubric
-                $status =fwrite ($bf,start_tag("RUBRIC",7,true));
-                //Print rubric contents
-                fwrite ($bf,full_tag("RUBRICNO",8,false,$wor_rub->rubricno));
-                fwrite ($bf,full_tag("DESCRIPTION",8,false,$wor_rub->description));
-                //End rubric
-                $status =fwrite ($bf,end_tag("RUBRIC",7,true));
-            }
-            //Write end tag
-            $status =fwrite ($bf,end_tag("RUBRICS",6,true));
-        }
-        return $status;
-    }
-
-    //Backup workshop_stockcomments contents (executed from backup_workshop_elements)
-    function backup_workshop_stockcomments ($bf,$preferences,$workshop,$elementno) {
-
-        global $CFG;
-
-        $status = true;
-
-        $workshop_stockcomments = get_records_sql("SELECT * from {$CFG->prefix}workshop_stockcomments c
-                                              WHERE c.workshopid = '$workshop' and c.elementno = '$elementno'
-                                              ORDER BY c.id");
-
-        //If there is workshop_stockcomments
-        if ($workshop_stockcomments) {
-            //Write start tag
-            $status =fwrite ($bf,start_tag("STOCKCOMMENTS",6,true));
-            //Iterate over each comment
-            foreach ($workshop_stockcomments as $wor_com) {
-                //Start comment
-                $status =fwrite ($bf,start_tag("STOCKCOMMENT",7,true));
-                //Print comment contents
-                fwrite ($bf,full_tag("COMMENT_TEXT",8,false,$wor_com->comments));
-                //End comment
-                $status =fwrite ($bf,end_tag("STOCKCOMMENT",7,true));
-            }
-            //Write end tag
-            $status =fwrite ($bf,end_tag("STOCKCOMMENTS",6,true));
-        }
-        return $status;
-    }
-
-    //Backup workshop_submissions contents (executed from workshop_backup_mods)
-    function backup_workshop_submissions ($bf,$preferences,$workshop,&$workshop_submissions) {
-
-        global $CFG;
-
-        $status = true;
-
-        $workshop_submissions = get_records("workshop_submissions","workshopid",$workshop,"id");
-        //If there is submissions
-        if ($workshop_submissions) {
-            //Write start tag
-            $status =fwrite ($bf,start_tag("SUBMISSIONS",4,true));
-            //Iterate over each submission
-            foreach ($workshop_submissions as $wor_sub) {
-                //Start submission
-                $status =fwrite ($bf,start_tag("SUBMISSION",5,true));
-                //Print submission contents
-                fwrite ($bf,full_tag("ID",6,false,$wor_sub->id));       
-                fwrite ($bf,full_tag("USERID",6,false,$wor_sub->userid));       
-                fwrite ($bf,full_tag("TITLE",6,false,$wor_sub->title));       
-                fwrite ($bf,full_tag("TIMECREATED",6,false,$wor_sub->timecreated));       
-                fwrite ($bf,full_tag("MAILED",6,false,$wor_sub->mailed));       
-                fwrite ($bf,full_tag("DESCRIPTION",6,false,$wor_sub->description));       
-                fwrite ($bf,full_tag("GRADINGGRADE",6,false,$wor_sub->gradinggrade));       
-                fwrite ($bf,full_tag("FINALGRADE",6,false,$wor_sub->finalgrade));       
-                fwrite ($bf,full_tag("LATE",6,false,$wor_sub->late));       
-                fwrite ($bf,full_tag("NASSESSMENTS",6,false,$wor_sub->nassessments));       
-                //Now we backup workshop assessments
-                $status = backup_workshop_assessments($bf,$preferences,$workshop,$wor_sub->id);
-                //End submission
-                $status =fwrite ($bf,end_tag("SUBMISSION",5,true));
-            }
-            //Write end tag
-            $status =fwrite ($bf,end_tag("SUBMISSIONS",4,true));
-        }
-        return $status;
-    }
-
-    //Backup workshop_assessments contents (executed from backup_workshop_submissions)
-    function backup_workshop_assessments ($bf,$preferences,$workshop,$submission) {
-
-        global $CFG;
-
-        $status = true;
-
-        //NOTE: I think that the workshopid can go out (submissionid is a good unique fk), but mantain it, as is in db !!
-        $workshop_assessments = get_records_sql("SELECT * from {$CFG->prefix}workshop_assessments a
-                                                 WHERE a.workshopid = '$workshop' and a.submissionid = '$submission'
-                                                 ORDER BY a.id");
-
-        //If there is workshop_assessments
-        if ($workshop_assessments) {
-            //Write start tag
-            $status =fwrite ($bf,start_tag("ASSESSMENTS",6,true));
-            //Iterate over each assessment
-            foreach ($workshop_assessments as $wor_ass) {
-                //Start assessment
-                $status =fwrite ($bf,start_tag("ASSESSMENT",7,true));
-                //Print assessment contents
-                fwrite ($bf,full_tag("ID",8,false,$wor_ass->id));
-                fwrite ($bf,full_tag("USERID",8,false,$wor_ass->userid));
-                fwrite ($bf,full_tag("TIMECREATED",8,false,$wor_ass->timecreated));
-                fwrite ($bf,full_tag("TIMEGRADED",8,false,$wor_ass->timegraded));
-                fwrite ($bf,full_tag("TIMEAGREED",8,false,$wor_ass->timeagreed));
-                fwrite ($bf,full_tag("GRADE",8,false,$wor_ass->grade));
-                fwrite ($bf,full_tag("GRADINGGRADE",8,false,$wor_ass->gradinggrade));
-                fwrite ($bf,full_tag("TEACHERGRADED",8,false,$wor_ass->teachergraded));
-                fwrite ($bf,full_tag("MAILED",8,false,$wor_ass->mailed));
-                fwrite ($bf,full_tag("RESUBMISSION",8,false,$wor_ass->resubmission));
-                fwrite ($bf,full_tag("DONOTUSE",8,false,$wor_ass->donotuse));
-                fwrite ($bf,full_tag("GENERALCOMMENT",8,false,$wor_ass->generalcomment));
-                fwrite ($bf,full_tag("TEACHERCOMMENT",8,false,$wor_ass->teachercomment));
-                //Now we backup workshop comments
-                $status = backup_workshop_comments($bf,$preferences,$workshop,$wor_ass->id);
-                //Now we backup workshop grades
-                $status = backup_workshop_grades($bf,$preferences,$workshop,$wor_ass->id);
-                //End assessment
-                $status =fwrite ($bf,end_tag("ASSESSMENT",7,true));
-            }
-            //Write end tag
-            $status =fwrite ($bf,end_tag("ASSESSMENTS",6,true));
-        }
-        return $status;
-    }
-
-    //Backup workshop_comments contents (executed from backup_workshop_assessments)
-    function backup_workshop_comments ($bf,$preferences,$workshop,$assessmentid) {
-
-        global $CFG;
-
-        $status = true;
-
-        //NOTE: I think that the workshopid can go out (assessmentid is a good unique fk), but mantain it, as is in db !!
-        $workshop_comments = get_records_sql("SELECT * from {$CFG->prefix}workshop_comments c
-                                              WHERE c.workshopid = '$workshop' and c.assessmentid = '$assessmentid'
-                                              ORDER BY c.id");
-
-        //If there is workshop_comments
-        if ($workshop_comments) {
-            //Write start tag
-            $status =fwrite ($bf,start_tag("COMMENTS",8,true));
-            //Iterate over each comment
-            foreach ($workshop_comments as $wor_com) {
-                //Start comment
-                $status =fwrite ($bf,start_tag("COMMENT",9,true));
-                //Print comment contents
-                fwrite ($bf,full_tag("USERID",10,false,$wor_com->userid));
-                fwrite ($bf,full_tag("TIMECREATED",10,false,$wor_com->timecreated));
-                fwrite ($bf,full_tag("MAILED",10,false,$wor_com->mailed));
-                fwrite ($bf,full_tag("COMMENT_TEXT",10,false,$wor_com->comments));
-                //End comment
-                $status =fwrite ($bf,end_tag("COMMENT",9,true));
-            }
-            //Write end tag
-            $status =fwrite ($bf,end_tag("COMMENTS",8,true));
-        }
-        return $status;
-    }
-
-    //Backup workshop_grades contents (executed from backup_workshop_assessments)
-    function backup_workshop_grades ($bf,$preferences,$workshop,$assessmentid) {
-
-        global $CFG;
-
-        $status = true;
-
-        //NOTE: I think that the workshopid can go out (assessmentid is a good unique fk), but mantain it, as is in db !!
-        $workshop_grades = get_records_sql("SELECT * from {$CFG->prefix}workshop_grades g
-                                              WHERE g.workshopid = '$workshop' and g.assessmentid = '$assessmentid'
-                                              ORDER BY g.elementno");
-
-        //If there is workshop_grades
-        if ($workshop_grades) {
-            //Write start tag
-            $status =fwrite ($bf,start_tag("GRADES",8,true));
-            //Iterate over each grade
-            foreach ($workshop_grades as $wor_gra) {
-                //Start grade
-                $status =fwrite ($bf,start_tag("GRADE",9,true));
-                //Print grade contents
-                fwrite ($bf,full_tag("ELEMENTNO",10,false,$wor_gra->elementno));
-                fwrite ($bf,full_tag("FEEDBACK",10,false,$wor_gra->feedback));
-                fwrite ($bf,full_tag("GRADE_VALUE",10,false,$wor_gra->grade));
-                //End comment
-                $status =fwrite ($bf,end_tag("GRADE",9,true));
-            }
-            //Write end tag
-            $status =fwrite ($bf,end_tag("GRADES",8,true));
-        }
-        return $status;
-    }
-
-
-    //Backup workshop files because we've selected to backup user info
-    //and files are user info's level
-    function backup_workshop_files($bf,$preferences) {
-
-        global $CFG;
-       
-        $status = true;
-
-        //First we check to moddata exists and create it as necessary
-        //in temp/backup/$backup_code  dir
-        $status = check_and_create_moddata_dir($preferences->backup_unique_code);
-        //Now copy the workshop dir
-        if ($status) {
-            //Only if it exists !! Thanks to Daniel Miksik.
-            if (is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/workshop")) {
-                $status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/workshop/",
-                                           $CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/workshop/");
-            }
-        }
-
-        return $status;
-
-    } 
-
-    function backup_workshop_files_instance($bf,$preferences,$instanceid,$ws) {
-        global $CFG;
-        
-        $status = true;
-        
-        //First we check to moddata exists and create it as necessary
-        //in temp/backup/$backup_code  dir
-        $status = check_and_create_moddata_dir($preferences->backup_unique_code);
-        $status = check_dir_exists($CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/workshop/",true);
-        //Now copy the forum dir
-        if ($status) {
-            foreach ($ws as $submission) {
-                //Only if it exists !! Thanks to Daniel Miksik.
-                if (is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/workshop/".$submission->id)) {
-                    $status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/workshop/".$submission->id,
-                                               $CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/workshop/".$submission->id);
-                }
-            }
-        }
-
-        return $status;
-    }
-
-function workshop_check_backup_mods_instances($instance,$backup_unique_code) {
-    //First the course data
-    $info[$instance->id.'0'][0] = $instance->name;
-    $info[$instance->id.'0'][1] = '';
-    //Now, if requested, the user_data
-    if (!empty($instance->userdata)) {
-        $info[$instance->id.'1'][0] = get_string("submissions","workshop");
-        if ($ids = workshop_submission_ids_by_instance ($instance->id)) { 
-            $info[$instance->id.'1'][1] = count($ids);
-        } else {
-            $info[$instance->id.'1'][1] = 0;
-        }
-    }
-    return $info;
-}
-
-
-    //Return an array of info (name,value)
-    function workshop_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
-        if (!empty($instances) && is_array($instances) && count($instances)) {
-            $info = array();
-            foreach ($instances as $id => $instance) {
-                $info += workshop_check_backup_mods_instances($instance,$backup_unique_code);
-            }
-            return $info;
-        }
-        //First the course data
-        $info[0][0] = get_string("modulenameplural","workshop");
-        if ($ids = workshop_ids ($course)) {
-            $info[0][1] = count($ids);
-        } else {
-            $info[0][1] = 0;
-        }
-
-        //Now, if requested, the user_data
-        if ($user_data) {
-            $info[1][0] = get_string("submissions","workshop");
-            if ($ids = workshop_submission_ids_by_course ($course)) { 
-                $info[1][1] = count($ids);
-            } else {
-                $info[1][1] = 0;
-            }
-        }
-        return $info;
-    }
-
-    //Return a content encoded to support interactivities linking. Every module
-    //should have its own. They are called automatically from the backup procedure.
-    function workshop_encode_content_links ($content,$preferences) {
-
-        global $CFG;
-
-        $base = preg_quote($CFG->wwwroot,"/");
-
-        //Link to the list of workshops
-        $buscar="/(".$base."\/mod\/workshop\/index.php\?id\=)([0-9]+)/";
-        $result= preg_replace($buscar,'$@WORKSHOPINDEX*$2@$',$content);
-
-        //Link to workshop view by moduleid
-        $buscar="/(".$base."\/mod\/workshop\/view.php\?id\=)([0-9]+)/";
-        $result= preg_replace($buscar,'$@WORKSHOPVIEWBYID*$2@$',$result);
-
-        return $result;
-    }
-
-    // INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE
-
-    //Returns an array of workshop id 
-    function workshop_ids ($course) {
-
-        global $CFG;
-
-        return get_records_sql ("SELECT w.id, w.course
-                                 FROM {$CFG->prefix}workshop w
-                                 WHERE w.course = '$course'");
-    }
-    
-    //Returns an array of workshop_submissions id
-    function workshop_submission_ids_by_course ($course) {
-
-        global $CFG;
-
-        return get_records_sql ("SELECT s.id , s.workshopid
-                                 FROM {$CFG->prefix}workshop_submissions s,
-                                      {$CFG->prefix}workshop w
-                                 WHERE w.course = '$course' AND
-                                       s.workshopid = w.id");
-    }
-
-    function workshop_submission_ids_by_instance ($instanceid) {
-
-        global $CFG;
-
-        return get_records_sql ("SELECT s.id , s.workshopid
-                                 FROM {$CFG->prefix}workshop_submissions s
-                                 WHERE s.workshopid = $instanceid");
-    }
-?>
diff --git a/mod/workshop/db/access.php b/mod/workshop/db/access.php
deleted file mode 100644 (file)
index 0518d09..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php // $Id$
-/**
- * Capability definitions for the workshop module.
- *
- * For naming conventions, see lib/db/access.php.
- */
-$mod_workshop_capabilities = array(
-
-    'mod/workshop:participate' => array(
-
-        'riskbitmask' => RISK_SPAM,
-
-        'captype' => 'write',
-        'contextlevel' => CONTEXT_MODULE,
-        'legacy' => array(
-            'student' => CAP_ALLOW
-        )
-    ),
-
-    'mod/workshop:manage' => array(
-
-        'riskbitmask' => RISK_SPAM,
-
-        'captype' => 'write',
-        'contextlevel' => CONTEXT_MODULE,
-        'legacy' => array(
-            'teacher' => CAP_ALLOW,
-            'editingteacher' => CAP_ALLOW,
-            'admin' => CAP_ALLOW
-        )
-    )
-);
diff --git a/mod/workshop/db/install.xml b/mod/workshop/db/install.xml
deleted file mode 100644 (file)
index 3fb3b35..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/workshop/db" VERSION="20070206" COMMENT="XMLDB file for Moodle mod/workshop"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
->
-  <TABLES>
-    <TABLE NAME="workshop" COMMENT="Defines workshop" NEXT="workshop_elements">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="course"/>
-        <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="name"/>
-        <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="course" NEXT="description"/>
-        <FIELD NAME="description" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="wtype"/>
-        <FIELD NAME="wtype" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="description" NEXT="nelements"/>
-        <FIELD NAME="nelements" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="wtype" NEXT="nattachments"/>
-        <FIELD NAME="nattachments" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="nelements" NEXT="phase"/>
-        <FIELD NAME="phase" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="nattachments" NEXT="format"/>
-        <FIELD NAME="format" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="phase" NEXT="gradingstrategy"/>
-        <FIELD NAME="gradingstrategy" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="format" NEXT="resubmit"/>
-        <FIELD NAME="resubmit" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="gradingstrategy" NEXT="agreeassessments"/>
-        <FIELD NAME="agreeassessments" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="resubmit" NEXT="hidegrades"/>
-        <FIELD NAME="hidegrades" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="agreeassessments" NEXT="anonymous"/>
-        <FIELD NAME="anonymous" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="hidegrades" NEXT="includeself"/>
-        <FIELD NAME="includeself" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="anonymous" NEXT="maxbytes"/>
-        <FIELD NAME="maxbytes" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="100000" SEQUENCE="false" ENUM="false" PREVIOUS="includeself" NEXT="submissionstart"/>
-        <FIELD NAME="submissionstart" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="maxbytes" NEXT="assessmentstart"/>
-        <FIELD NAME="assessmentstart" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="submissionstart" NEXT="submissionend"/>
-        <FIELD NAME="submissionend" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="assessmentstart" NEXT="assessmentend"/>
-        <FIELD NAME="assessmentend" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="submissionend" NEXT="releasegrades"/>
-        <FIELD NAME="releasegrades" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="assessmentend" NEXT="grade"/>
-        <FIELD NAME="grade" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="releasegrades" NEXT="gradinggrade"/>
-        <FIELD NAME="gradinggrade" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="grade" NEXT="ntassessments"/>
-        <FIELD NAME="ntassessments" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="gradinggrade" NEXT="assessmentcomps"/>
-        <FIELD NAME="assessmentcomps" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="2" SEQUENCE="false" ENUM="false" PREVIOUS="ntassessments" NEXT="nsassessments"/>
-        <FIELD NAME="nsassessments" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="assessmentcomps" NEXT="overallocation"/>
-        <FIELD NAME="overallocation" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="nsassessments" NEXT="timemodified"/>
-        <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="overallocation" NEXT="teacherweight"/>
-        <FIELD NAME="teacherweight" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="timemodified" NEXT="showleaguetable"/>
-        <FIELD NAME="showleaguetable" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="teacherweight" NEXT="usepassword"/>
-        <FIELD NAME="usepassword" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="showleaguetable" NEXT="password"/>
-        <FIELD NAME="password" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="usepassword"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" />
-      </KEYS>
-      <INDEXES>
-        <INDEX NAME="course" UNIQUE="false" FIELDS="course"/>
-      </INDEXES>
-    </TABLE>
-    <TABLE NAME="workshop_elements" COMMENT="Info about marking scheme of assignment" PREVIOUS="workshop" NEXT="workshop_rubrics">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="workshopid"/>
-        <FIELD NAME="workshopid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="elementno"/>
-        <FIELD NAME="elementno" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="workshopid" NEXT="description"/>
-        <FIELD NAME="description" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="elementno" NEXT="scale"/>
-        <FIELD NAME="scale" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="description" NEXT="maxscore"/>
-        <FIELD NAME="maxscore" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="scale" NEXT="weight"/>
-        <FIELD NAME="weight" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="11" SEQUENCE="false" ENUM="false" PREVIOUS="maxscore" NEXT="stddev"/>
-        <FIELD NAME="stddev" TYPE="float" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="weight" NEXT="totalassessments"/>
-        <FIELD NAME="totalassessments" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="stddev"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="workshopid"/>
-        <KEY NAME="workshopid" TYPE="foreign" FIELDS="workshopid" REFTABLE="workshop" REFFIELDS="id" PREVIOUS="primary"/>
-      </KEYS>
-    </TABLE>
-    <TABLE NAME="workshop_rubrics" COMMENT="Info about the rubrics marking scheme" PREVIOUS="workshop_elements" NEXT="workshop_submissions">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="workshopid"/>
-        <FIELD NAME="workshopid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="elementno"/>
-        <FIELD NAME="elementno" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="workshopid" NEXT="rubricno"/>
-        <FIELD NAME="rubricno" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="elementno" NEXT="description"/>
-        <FIELD NAME="description" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="rubricno"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="workshopid"/>
-        <KEY NAME="workshopid" TYPE="foreign" FIELDS="workshopid" REFTABLE="workshop" REFFIELDS="id" PREVIOUS="primary"/>
-      </KEYS>
-    </TABLE>
-    <TABLE NAME="workshop_submissions" COMMENT="Info about submitted work from teacher and students" PREVIOUS="workshop_rubrics" NEXT="workshop_assessments">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="workshopid"/>
-        <FIELD NAME="workshopid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="userid"/>
-        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="workshopid" NEXT="title"/>
-        <FIELD NAME="title" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="timecreated"/>
-        <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="title" NEXT="mailed"/>
-        <FIELD NAME="mailed" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timecreated" NEXT="description"/>
-        <FIELD NAME="description" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="mailed" NEXT="gradinggrade"/>
-        <FIELD NAME="gradinggrade" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="description" NEXT="finalgrade"/>
-        <FIELD NAME="finalgrade" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="gradinggrade" NEXT="late"/>
-        <FIELD NAME="late" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="finalgrade" NEXT="nassessments"/>
-        <FIELD NAME="nassessments" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="late"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="workshopid"/>
-        <KEY NAME="workshopid" TYPE="foreign" FIELDS="workshopid" REFTABLE="workshop" REFFIELDS="id" PREVIOUS="primary"/>
-      </KEYS>
-      <INDEXES>
-        <INDEX NAME="userid" UNIQUE="false" FIELDS="userid" NEXT="mailed"/>
-        <INDEX NAME="mailed" UNIQUE="false" FIELDS="mailed" PREVIOUS="userid"/>
-      </INDEXES>
-    </TABLE>
-    <TABLE NAME="workshop_assessments" COMMENT="Info about assessments by teacher and students" PREVIOUS="workshop_submissions" NEXT="workshop_grades">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="workshopid"/>
-        <FIELD NAME="workshopid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="submissionid"/>
-        <FIELD NAME="submissionid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="workshopid" NEXT="userid"/>
-        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="submissionid" NEXT="timecreated"/>
-        <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="timegraded"/>
-        <FIELD NAME="timegraded" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timecreated" NEXT="timeagreed"/>
-        <FIELD NAME="timeagreed" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timegraded" NEXT="grade"/>
-        <FIELD NAME="grade" TYPE="float" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timeagreed" NEXT="gradinggrade"/>
-        <FIELD NAME="gradinggrade" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="grade" NEXT="teachergraded"/>
-        <FIELD NAME="teachergraded" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="gradinggrade" NEXT="mailed"/>
-        <FIELD NAME="mailed" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="teachergraded" NEXT="resubmission"/>
-        <FIELD NAME="resubmission" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="mailed" NEXT="donotuse"/>
-        <FIELD NAME="donotuse" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="resubmission" NEXT="generalcomment"/>
-        <FIELD NAME="generalcomment" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="donotuse" NEXT="teachercomment"/>
-        <FIELD NAME="teachercomment" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="generalcomment"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="workshopid"/>
-        <KEY NAME="workshopid" TYPE="foreign" FIELDS="workshopid" REFTABLE="workshop" REFFIELDS="id" PREVIOUS="primary" NEXT="submissionid"/>
-        <KEY NAME="submissionid" TYPE="foreign" FIELDS="submissionid" REFTABLE="workshop_submissions" REFFIELDS="id" PREVIOUS="workshopid"/>
-      </KEYS>
-      <INDEXES>
-        <INDEX NAME="userid" UNIQUE="false" FIELDS="userid" NEXT="mailed"/>
-        <INDEX NAME="mailed" UNIQUE="false" FIELDS="mailed" PREVIOUS="userid"/>
-      </INDEXES>
-    </TABLE>
-    <TABLE NAME="workshop_grades" COMMENT="Info about individual grades given to each element" PREVIOUS="workshop_assessments" NEXT="workshop_stockcomments">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="workshopid"/>
-        <FIELD NAME="workshopid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="assessmentid"/>
-        <FIELD NAME="assessmentid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="workshopid" NEXT="elementno"/>
-        <FIELD NAME="elementno" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="assessmentid" NEXT="feedback"/>
-        <FIELD NAME="feedback" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="elementno" NEXT="grade"/>
-        <FIELD NAME="grade" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="feedback"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="workshopid"/>
-        <KEY NAME="workshopid" TYPE="foreign" FIELDS="workshopid" REFTABLE="workshop" REFFIELDS="id" PREVIOUS="primary" NEXT="assessmentid"/>
-        <KEY NAME="assessmentid" TYPE="foreign" FIELDS="assessmentid" REFTABLE="workshop_assessments" REFFIELDS="id" PREVIOUS="workshopid"/>
-      </KEYS>
-    </TABLE>
-    <TABLE NAME="workshop_stockcomments" COMMENT="Info about the teacher comment bank" PREVIOUS="workshop_grades" NEXT="workshop_comments">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="workshopid"/>
-        <FIELD NAME="workshopid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="elementno"/>
-        <FIELD NAME="elementno" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="workshopid" NEXT="comments"/>
-        <FIELD NAME="comments" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="elementno"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="workshopid"/>
-        <KEY NAME="workshopid" TYPE="foreign" FIELDS="workshopid" REFTABLE="workshop" REFFIELDS="id" PREVIOUS="primary"/>
-      </KEYS>
-    </TABLE>
-    <TABLE NAME="workshop_comments" COMMENT="Defines comments" PREVIOUS="workshop_stockcomments">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="workshopid"/>
-        <FIELD NAME="workshopid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="assessmentid"/>
-        <FIELD NAME="assessmentid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="workshopid" NEXT="userid"/>
-        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="assessmentid" NEXT="timecreated"/>
-        <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="mailed"/>
-        <FIELD NAME="mailed" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timecreated" NEXT="comments"/>
-        <FIELD NAME="comments" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="mailed"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="workshopid"/>
-        <KEY NAME="workshopid" TYPE="foreign" FIELDS="workshopid" REFTABLE="workshop" REFFIELDS="id" PREVIOUS="primary" NEXT="assessmentid"/>
-        <KEY NAME="assessmentid" TYPE="foreign" FIELDS="assessmentid" REFTABLE="workshop_assessments" REFFIELDS="id" PREVIOUS="workshopid"/>
-      </KEYS>
-      <INDEXES>
-        <INDEX NAME="userid" UNIQUE="false" FIELDS="userid" NEXT="mailed"/>
-        <INDEX NAME="mailed" UNIQUE="false" FIELDS="mailed" PREVIOUS="userid"/>
-      </INDEXES>
-    </TABLE>
-  </TABLES>
-  <STATEMENTS>
-    <STATEMENT NAME="insert log_display" TYPE="insert" TABLE="log_display" COMMENT="Initial insert of records on table log_display">
-      <SENTENCES>
-        <SENTENCE TEXT="(module, action, mtable, field) VALUES ('workshop', 'assessments', 'workshop', 'name')" />
-        <SENTENCE TEXT="(module, action, mtable, field) VALUES ('workshop', 'close', 'workshop', 'name')" />
-        <SENTENCE TEXT="(module, action, mtable, field) VALUES ('workshop', 'display', 'workshop', 'name')" />
-        <SENTENCE TEXT="(module, action, mtable, field) VALUES ('workshop', 'resubmit', 'workshop', 'name')" />
-        <SENTENCE TEXT="(module, action, mtable, field) VALUES ('workshop', 'set up', 'workshop', 'name')" />
-        <SENTENCE TEXT="(module, action, mtable, field) VALUES ('workshop', 'submissions', 'workshop', 'name')" />
-        <SENTENCE TEXT="(module, action, mtable, field) VALUES ('workshop', 'view', 'workshop', 'name')" />
-        <SENTENCE TEXT="(module, action, mtable, field) VALUES ('workshop', 'update', 'workshop', 'name')" />
-      </SENTENCES>
-    </STATEMENT>
-  </STATEMENTS>
-</XMLDB>
diff --git a/mod/workshop/db/mysql.php b/mod/workshop/db/mysql.php
deleted file mode 100644 (file)
index 22c1767..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function workshop_upgrade($oldversion) {
-// This function does anything necessary to upgrade
-// older versions to match current functionality
-
-    global $CFG, $db;
-
-    if ($oldversion < 2003050400) {
-        execute_sql(" ALTER TABLE `{$CFG->prefix}workshop` CHANGE `graded` `agreeassessments` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}workshop` CHANGE `showgrades` `hidegrades` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}workshop_assessments` ADD `timeagreed` INT(10) UNSIGNED DEFAULT '0' NOT NULL AFTER `timecreated`");
-        execute_sql("
-        CREATE TABLE `{$CFG->prefix}workshop_comments` (
-          `id` int(10) unsigned NOT NULL auto_increment,
-          # workshopid not necessary just makes deleting instance easier
-          `workshopid` int(10) unsigned NOT NULL default '0',
-          `assessmentid` int(10) unsigned NOT NULL default '0',
-          `userid` int(10) unsigned NOT NULL default '0',
-          `timecreated` int(10) unsigned NOT NULL default '0',
-          `mailed` tinyint(2) unsigned NOT NULL default '0',
-          `comments` text NOT NULL,
-          PRIMARY KEY  (`id`)
-        ) COMMENT='Defines comments'
-        ");
-    }
-
-    if ($oldversion < 2003051400) {
-        execute_sql(" ALTER TABLE `{$CFG->prefix}workshop` ADD `showleaguetable` TINYINT(3) UNSIGNED NOT NULL  DEFAULT '0' AFTER `gradingweight`");
-        execute_sql("
-        CREATE TABLE `{$CFG->prefix}workshop_rubrics` (
-          `id` int(10) unsigned NOT NULL auto_increment,
-          `workshopid` int(10) unsigned NOT NULL default '0',
-          `elementid` int(10) unsigned NOT NULL default '0',
-          `rubricno` tinyint(3) unsigned NOT NULL default '0',
-          `description` text NOT NULL,
-          PRIMARY KEY  (`id`)
-        ) COMMENT='Info about the rubrics marking scheme'
-        ");
-    }
-
-    if ($oldversion < 2003082200) {
-
-        execute_sql(" ALTER TABLE `{$CFG->prefix}workshop_rubrics` CHANGE `elementid` `elementno` INT(10) UNSIGNED NOT NULL DEFAULT '0'");
-    }
-
-    if ($oldversion < 2003092500) {
-        execute_sql(" ALTER TABLE `{$CFG->prefix}workshop` ADD `overallocation` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `nsassessments`");
-    }
-
-    if ($oldversion < 2003100200) {
-
-        execute_sql(" ALTER TABLE `{$CFG->prefix}workshop_assessments` ADD `resubmission` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `mailed`");
-    }
-
-    if ($oldversion < 2003100800) {
-        // tidy up log_display entries
-        execute_sql("DELETE FROM `{$CFG->prefix}log_display` WHERE `module` = 'workshop'");
-        execute_sql("INSERT INTO `{$CFG->prefix}log_display` VALUES('workshop', 'assessments', 'workshop', 'name')");
-        execute_sql("INSERT INTO `{$CFG->prefix}log_display` VALUES ('workshop', 'close', 'workshop', 'name')");
-        execute_sql("INSERT INTO `{$CFG->prefix}log_display` VALUES ('workshop', 'display', 'workshop', 'name')");
-        execute_sql("INSERT INTO `{$CFG->prefix}log_display` VALUES ('workshop', 'resubmit', 'workshop', 'name')");
-        execute_sql("INSERT INTO `{$CFG->prefix}log_display` VALUES ('workshop', 'set up', 'workshop', 'name')");
-        execute_sql("INSERT INTO `{$CFG->prefix}log_display` VALUES ('workshop', 'submissions', 'workshop', 'name')");
-        execute_sql("INSERT INTO `{$CFG->prefix}log_display` VALUES ('workshop', 'view', 'workshop', 'name')");
-        execute_sql("INSERT INTO `{$CFG->prefix}log_display` VALUES ('workshop', 'update', 'workshop', 'name')");
-    }
-
-    if ($oldversion < 2003113000) {
-        execute_sql("ALTER TABLE `{$CFG->prefix}workshop` ADD `teacherloading` tinyint(3) unsigned
-                NOT NULL default '5'");
-        execute_sql("ALTER TABLE `{$CFG->prefix}workshop` ADD `assessmentstodrop` tinyint(3) unsigned
-                NOT NULL default '0'");
-        execute_sql("ALTER TABLE `{$CFG->prefix}workshop_assessments` ADD `donotuse` tinyint(3) unsigned
-                NOT NULL default '0' AFTER `resubmission`");
-        execute_sql("ALTER TABLE `{$CFG->prefix}workshop_grades` ADD INDEX (`assessmentid`)");
-    }
-
-    if ($oldversion < 2004052100) {
-        include_once("$CFG->dirroot/mod/workshop/lib.php");
-        workshop_refresh_events();
-    }
-
-    if ($oldversion < 2004081100) {
-        table_column("workshop", "", "gradinggrade", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "grade");
-        table_column("workshop", "", "assessmentcomps", "INTEGER", "4", "UNSIGNED", "2", "NOT NULL", "ntassessments");
-        execute_sql("ALTER TABLE `{$CFG->prefix}workshop` DROP COLUMN `gradingweight`");
-        execute_sql("ALTER TABLE `{$CFG->prefix}workshop` DROP COLUMN `mergegrades`");
-        execute_sql("ALTER TABLE `{$CFG->prefix}workshop` DROP COLUMN `peerweight`");
-        execute_sql("ALTER TABLE `{$CFG->prefix}workshop` DROP COLUMN `includeteachersgrade`");
-        execute_sql("ALTER TABLE `{$CFG->prefix}workshop` DROP COLUMN `biasweight`");
-        execute_sql("ALTER TABLE `{$CFG->prefix}workshop` DROP COLUMN `reliabilityweight`");
-        execute_sql("ALTER TABLE `{$CFG->prefix}workshop` DROP COLUMN `teacherloading`");
-        execute_sql("ALTER TABLE `{$CFG->prefix}workshop` DROP COLUMN `assessmentstodrop`");
-    }
-
-    if ($oldversion < 2004092400) {
-        table_column("workshop", "", "nattachments", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "nelements");
-        table_column("workshop_submissions", "", "description", "TEXT", "", "", "", "", "mailed");
-        execute_sql("ALTER TABLE `{$CFG->prefix}workshop_submissions` ADD INDEX (`userid`)");
-        execute_sql("ALTER TABLE `{$CFG->prefix}workshop_assessments` ADD INDEX (`submissionid`)");
-        execute_sql("ALTER TABLE `{$CFG->prefix}workshop_assessments` ADD INDEX (`userid`)");
-    }
-
-    if ($oldversion < 2004092700) {
-        table_column("workshop", "", "wtype", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "description");
-        table_column("workshop", "", "usepassword", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL");
-        table_column("workshop", "", "password", "VARCHAR", "32", "", "", "NOT NULL");
-        table_column("workshop_submissions", "", "late", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL");
-
-        // update wkey value
-        if ($workshops = get_records("workshop")) {
-            foreach ($workshops as $workshop) {
-                $wtype = 0; // 3 phases, no grading grades
-                if ($workshop->includeself or $workshop->ntassessments) $wtype = 1; // 3 phases with grading grades
-                if ($workshop->nsassessments) $wtype = 2; // 5 phases with grading grades
-                set_field("workshop", "wtype", $wtype, "id", $workshop->id);
-            }
-        }
-    }
-
-    if ($oldversion < 2004102800) {
-        table_column("workshop", "", "releasegrades", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "deadline");
-        execute_sql("
-        CREATE TABLE `{$CFG->prefix}workshop_stockcomments` (
-          `id` int(10) unsigned NOT NULL auto_increment,
-          `workshopid` int(10) unsigned NOT NULL default '0',
-          `elementno` int(10) unsigned NOT NULL default '0',
-          `comments` text NOT NULL,
-          PRIMARY KEY  (`id`)
-        ) COMMENT='Defines stockcomments, the teacher comment bank'
-        ");
-    }
-
-    if ($oldversion < 2004111000) {
-        table_column("workshop_elements", "", "stddev", "FLOAT", "", "", "0", "NOT NULL");
-        table_column("workshop_elements", "", "totalassessments", "INTEGER", "10", "", "0", "NOT NULL");
-        execute_sql(" ALTER TABLE `{$CFG->prefix}workshop_elements` CHANGE `weight` `weight` INT(4) UNSIGNED NOT NULL DEFAULT '11'");
-        table_column("workshop_submissions", "", "nassessments", "INTEGER", "10", "", "0", "NOT NULL");
-        execute_sql("ALTER TABLE `{$CFG->prefix}workshop_submissions` DROP COLUMN `teachergrade`");
-        execute_sql("ALTER TABLE `{$CFG->prefix}workshop_submissions` DROP COLUMN `peergrade`");
-        execute_sql("ALTER TABLE `{$CFG->prefix}workshop_submissions` DROP COLUMN `biasgrade`");
-        execute_sql("ALTER TABLE `{$CFG->prefix}workshop_submissions` DROP COLUMN `reliabilitygrade`");
-    }
-
-    if ($oldversion < 2004111200) {
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop DROP INDEX course;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop_assessments DROP INDEX userid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop_assessments DROP INDEX workshopid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop_assessments DROP INDEX submissionid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop_assessments DROP INDEX mailed;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop_comments DROP INDEX workshopid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop_comments DROP INDEX assessmentid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop_comments DROP INDEX userid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop_comments DROP INDEX mailed;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop_elements DROP INDEX workshopid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop_grades DROP INDEX workshopid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop_grades DROP INDEX assessmentid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop_submissions DROP INDEX workshopid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop_submissions DROP INDEX userid;",false);
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop_submissions DROP INDEX mailed;",false);
-
-        modify_database('','ALTER TABLE prefix_workshop ADD INDEX course (course);');
-        modify_database('','ALTER TABLE prefix_workshop_assessments ADD INDEX userid (userid);');
-        modify_database('','ALTER TABLE prefix_workshop_assessments ADD INDEX workshopid (workshopid);');
-        modify_database('','ALTER TABLE prefix_workshop_assessments ADD INDEX submissionid (submissionid);');
-        modify_database('','ALTER TABLE prefix_workshop_assessments ADD INDEX mailed (mailed);');
-        modify_database('','ALTER TABLE prefix_workshop_comments ADD INDEX workshopid (workshopid);');
-        modify_database('','ALTER TABLE prefix_workshop_comments ADD INDEX assessmentid (assessmentid);');
-        modify_database('','ALTER TABLE prefix_workshop_comments ADD INDEX userid (userid);');
-        modify_database('','ALTER TABLE prefix_workshop_comments ADD INDEX mailed (mailed);');
-        modify_database('','ALTER TABLE prefix_workshop_elements ADD INDEX workshopid (workshopid);');
-        modify_database('','ALTER TABLE prefix_workshop_grades ADD INDEX workshopid (workshopid);');
-        modify_database('','ALTER TABLE prefix_workshop_grades ADD INDEX assessmentid (assessmentid);');
-        modify_database('','ALTER TABLE prefix_workshop_submissions ADD INDEX workshopid (workshopid);');
-        modify_database('','ALTER TABLE prefix_workshop_submissions ADD INDEX userid (userid);');
-        modify_database('','ALTER TABLE prefix_workshop_submissions ADD INDEX mailed (mailed);');
-    }
-
-    if ($oldversion < 2004120402) {
-        table_column('workshop', '', 'submissionstart', 'INTEGER', '10', 'UNSIGNED', '0', 'NOT NULL', 'maxbytes');
-        table_column('workshop', '', 'assessmentstart', 'INTEGER', '10', 'UNSIGNED', '0', 'NOT NULL', 'submissionstart');
-        table_column('workshop', 'deadline', 'submissionend', 'INTEGER', '10', 'UNSIGNED', '0', 'NOT NULL');
-        table_column('workshop', '', 'assessmentend', 'INTEGER', '10', 'UNSIGNED', '0', 'NOT NULL', 'submissionend');
-
-        $workshops = get_records('workshop');
-        if(!empty($workshops)) {
-            foreach ($workshops as $workshop) {
-                $early = (time() < $workshop->submissionend) ? 0 : $workshop->submissionend;
-                $late = (time() > $workshop->submissionend) ? 0 : $workshop->submissionend;
-                set_field('workshop', 'submissionstart', ($workshop->phase > 1) ? $early : $late, 'id', $workshop->id);
-                set_field('workshop', 'assessmentstart', ($workshop->phase > 2) ? $early : $late, 'id', $workshop->id);
-                set_field('workshop', 'submissionend', ($workshop->phase > 3) ? $early : $late, 'id', $workshop->id);
-                set_field('workshop', 'assessmentend', ($workshop->phase > 4) ? $early : $late, 'id', $workshop->id);
-            }
-        }
-        execute_sql('ALTER TABLE  '. $CFG->prefix .'workshop DROP COLUMN phase');
-
-        execute_sql("UPDATE {$CFG->prefix}event SET eventtype = 'submissionend' WHERE eventtype = 'deadline' AND modulename = 'workshop'", false);
-    }
-
-    if ($oldversion < 2004120900) {
-        table_column('workshop_assessments', '', 'teachergraded', 'INTEGER', '4', 'UNSIGNED', '0', 'NOT NULL', 'gradinggrade');
-    }
-
-    if ($oldversion < 2005041200) { // replace wiki-like with markdown
-        include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
-        $wtm = new WikiToMarkdown();
-        $wtm->update( 'workshop','description','format' );
-    }
-
-    if ($oldversion < 2006090500) {
-        $columns = $db->MetaColumns($CFG->prefix.'workshop_assessments');
-        $columns = array_change_key_case($columns, CASE_LOWER);
-        if (!isset($columns['teachergraded'])) {
-            table_column('workshop_assessments', '', 'teachergraded', 'INTEGER', '4', 'UNSIGNED', '0', 'NOT NULL', 'gradinggrade');
-        }
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-
-?>
diff --git a/mod/workshop/db/postgres7.php b/mod/workshop/db/postgres7.php
deleted file mode 100644 (file)
index a6372f5..0000000
+++ /dev/null
@@ -1,260 +0,0 @@
-<?php // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-function workshop_upgrade($oldversion) {
-// This function does anything necessary to upgrade
-// older versions to match current functionality
-
-    global $CFG, $db;
-
-    if ($oldversion < 2003050400) {
-    table_column("workshop","graded", "agreeassessments", "INT","2", "", "0" ,"NOT NULL");
-    table_column("workshop", "showgrades","hidegrades", "INT","2", "","0", "NOT NULL");
-    table_column("workshop_assessments","","timeagreed", "INT","8", "UNSIGNED", "0", "NOT NULL" );
-
-    execute_sql("
-            CREATE TABLE {$CFG->prefix}workshop_comments (
-            id SERIAL8 PRIMARY KEY  ,
-            workshopid int8 NOT NULL default '0',
-            assessmentid int8  NOT NULL default '0',
-            userid int8 NOT NULL default '0',
-            timecreated int8  NOT NULL default '0',
-            mailed int2  NOT NULL default '0',
-            comments text NOT NULL
-        )
-        ");
-    }
-
-    if ($oldversion < 2003051400) {
-        table_column("workshop","","showleaguetable", "INTEGER", "4", "unsigned", "0", "not null", "gradingweight");
-        execute_sql("
-        CREATE TABLE {$CFG->prefix}workshop_rubrics (
-          id SERIAL8 PRIMARY KEY,
-          workshopid int8 NOT NULL default '0',
-          elementid int8 NOT NULL default '0',
-          rubricno int4  NOT NULL default '0',
-          description text NOT NULL,
-        )
-        ");
-    }
-
-    if ($oldversion < 2003082200) {
-        table_column("workshop_rubrics", "elementid", "elementno", "INTEGER", "10", "unsigned", "0", "not null", "id");
-    }
-
-    if ($oldversion < 2003092500) {
-        table_column("workshop", "", "overallocation", "INTEGER", "4", "unsigned", "0", "not null", "nsassesments");
-    }
-
-    if ($oldversion < 2003100200) {
-
-        table_column("workshop_assesments", "", "resubmission", "INTEGER", "4", "unsigned", "0", "not null", "mailed");
-    }
-
-    if ($oldversion < 2003100800) {
-        // tidy up log_display entries
-        execute_sql("DELETE FROM {$CFG->prefix}log_display WHERE module = 'workshop'");
-        execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES('workshop', 'assessments', 'workshop', 'name')");
-        execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('workshop', 'close', 'workshop', 'name')");
-        execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('workshop', 'display', 'workshop', 'name')");
-        execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('workshop', 'resubmit', 'workshop', 'name')");
-        execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('workshop', 'set up', 'workshop', 'name')");
-        execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('workshop', 'submissions', 'workshop', 'name')");
-        execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('workshop', 'view', 'workshop', 'name')");
-        execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('workshop', 'update', 'workshop', 'name')");
-    }
-
-    if ($oldversion < 2003113000) {
-        table_column("workshop", "", "teacherloading", "INTEGER", "4", "unsigned", "5", "NOT NULL", "mailed");
-        table_column("workshop", "", "assessmentstodrop", "INTEGER", "4", "unsigned", "0", "NOT NULL", "");
-        table_column("workshop_assessments", "", "donotuse", "INTEGER", "4", "unsigned", "0", "NOT NULL", "resubmission");
-        execute_sql("CREATE INDEX {$CFG->prefix}workshop_grades_assesmentid_idx ON {$CFG->prefix}workshop_grades (assessmentid)");
-    }
-
-    if ($oldversion < 2004052100) {
-        include_once("$CFG->dirroot/mod/workshop/lib.php");
-        workshop_refresh_events();
-    }
-
-    if ($oldversion < 2004081100) {
-        table_column("workshop", "", "gradinggrade", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "grade");
-        table_column("workshop", "", "assessmentcomps", "INTEGER", "4", "UNSIGNED", "2", "NOT NULL", "ntassessments");
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop DROP COLUMN gradingweight");
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop DROP COLUMN mergegrades");
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop DROP COLUMN peerweight");
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop DROP COLUMN includeteachersgrade");
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop DROP COLUMN biasweight");
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop DROP COLUMN reliabilityweight");
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop DROP COLUMN teacherloading",false); //silent
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop DROP COLUMN assessmentstodrop",false); //silent
-    }
-
-    if ($oldversion < 2004092400) {
-        table_column("workshop", "", "nattachments", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "nelements");
-        table_column("workshop_submissions", "", "description", "TEXT", "", "", "", "", "mailed");
-        // these need to be dropped first in case we're upgrading from 1.4.3 and they already exist
-        execute_sql("DROP INDEX {$CFG->prefix}workshop_submissions_userid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}workshop_assessments_submissionid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}workshop_assessments_userid_idx;",false);
-
-        execute_sql("CREATE INDEX {$CFG->prefix}workshop_submissions_userid_idx ON {$CFG->prefix}workshop_submissions (userid)");
-        execute_sql("CREATE INDEX {$CFG->prefix}workshop_assessments_submissionid_idx ON {$CFG->prefix}workshop_assessments (submissionid)");
-        execute_sql("CREATE INDEX {$CFG->prefix}workshop_assessments_userid_idx ON {$CFG->prefix}workshop_assessments (userid)");
-    }
-
-    if ($oldversion < 2004092700) {
-        table_column("workshop", "", "wtype", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "description");
-        table_column("workshop", "", "usepassword", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL");
-        table_column("workshop", "", "password", "VARCHAR", "32", "", "", "NOT NULL");
-        table_column("workshop_submissions", "", "late", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL");
-
-        // update wkey value
-        if ($workshops = get_records("workshop")) {
-            foreach ($workshops as $workshop) {
-                $wtype = 0; // 3 phases, no grading grades
-                if ($workshop->includeself or $workshop->ntassessments) $wtype = 1; // 3 phases with grading grades
-                if ($workshop->nsassessments) $wtype = 2; // 5 phases with grading grades
-                set_field("workshop", "wtype", $wtype, "id", $workshop->id);
-            }
-        }
-    }
-
-    if ($oldversion < 2004102800) {
-        table_column("workshop", "", "releasegrades", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "deadline");
-        execute_sql("
-        CREATE TABLE {$CFG->prefix}workshop_stockcomments (
-          id SERIAL PRIMARY KEY,
-          workshopid INT8 NOT NULL default '0',
-          elementno INT8 NOT NULL default '0',
-          comments text NOT NULL
-        )
-        ");
-    }
-
-    if ($oldversion < 2004111000) {
-        table_column("workshop_elements", "", "stddev", "FLOAT", "", "", "0", "NOT NULL");
-        table_column("workshop_elements", "", "totalassessments", "INTEGER", "10", "", "0", "NOT NULL");
-        table_column("workshop_elements", "weight", "weight", "INTEGER", "4", "UNSIGNED", "11",  "NOT NULL");
-        table_column("workshop_submissions", "", "nassessments", "INTEGER", "10", "", "0", "NOT NULL");
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop_submissions DROP COLUMN teachergrade");
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop_submissions DROP COLUMN peergrade");
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop_submissions DROP COLUMN biasgrade");
-        execute_sql("ALTER TABLE {$CFG->prefix}workshop_submissions DROP COLUMN reliabilitygrade");
-    }
-
-    if ($oldversion < 2004111200) {
-        execute_sql("DROP INDEX {$CFG->prefix}workshop_course_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}workshop_assessments_workshopid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}workshop_assessments_submissionid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}workshop_assessments_userid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}workshop_assessments_mailed_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}workshop_comments_workshopid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}workshop_comments_assessmentid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}workshop_comments_userid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}workshop_comments_mailed_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}workshop_elements_workshopid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}workshop_grades_workshopid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}workshop_grades_assessmentid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}workshop_submissions_workshopid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}workshop_submissions_userid_idx;",false);
-        execute_sql("DROP INDEX {$CFG->prefix}workshop_submissions_mailed_idx;",false);
-
-        modify_database('','CREATE INDEX prefix_workshop_course_idx ON prefix_workshop (course);');
-        modify_database('','CREATE INDEX prefix_workshop_assessments_workshopid_idx ON prefix_workshop_assessments (workshopid);');
-        modify_database('','CREATE INDEX prefix_workshop_assessments_submissionid_idx ON prefix_workshop_assessments (submissionid);');
-        modify_database('','CREATE INDEX prefix_workshop_assessments_userid_idx ON prefix_workshop_assessments (userid);');
-        modify_database('','CREATE INDEX prefix_workshop_assessments_mailed_idx ON prefix_workshop_assessments (mailed);');
-        modify_database('','CREATE INDEX prefix_workshop_comments_workshopid_idx ON prefix_workshop_comments (workshopid);');
-        modify_database('','CREATE INDEX prefix_workshop_comments_assessmentid_idx ON prefix_workshop_comments (assessmentid);');
-        modify_database('','CREATE INDEX prefix_workshop_comments_userid_idx ON prefix_workshop_comments (userid);');
-        modify_database('','CREATE INDEX prefix_workshop_comments_mailed_idx ON prefix_workshop_comments (mailed);');
-        modify_database('','CREATE INDEX prefix_workshop_elements_workshopid_idx ON prefix_workshop_elements (workshopid);');
-        modify_database('','CREATE INDEX prefix_workshop_grades_workshopid_idx ON prefix_workshop_grades (workshopid);');
-        modify_database('','CREATE INDEX prefix_workshop_grades_assessmentid_idx ON prefix_workshop_grades (assessmentid);');
-        modify_database('','CREATE INDEX prefix_workshop_submissions_workshopid_idx ON prefix_workshop_submissions (workshopid);');
-        modify_database('','CREATE INDEX prefix_workshop_submissions_userid_idx ON prefix_workshop_submissions (userid);');
-        modify_database('','CREATE INDEX prefix_workshop_submissions_mailed_idx ON prefix_workshop_submissions (mailed);');
-    }
-
-    if ($oldversion < 2004120402) {
-        table_column('workshop', '', 'submissionstart', 'INTEGER', '10', 'UNSIGNED', '0', 'NOT NULL', 'maxbytes');
-        table_column('workshop', '', 'assessmentstart', 'INTEGER', '10', 'UNSIGNED', '0', 'NOT NULL', 'submissionstart');
-        table_column('workshop', 'deadline', 'submissionend', 'INTEGER', '10', 'UNSIGNED', '0', 'NOT NULL');
-        table_column('workshop', '', 'assessmentend', 'INTEGER', '10', 'UNSIGNED', '0', 'NOT NULL', 'submissionend');
-
-        $workshops = get_records('workshop');
-        if(!empty($workshops)) {
-            foreach ($workshops as $workshop) {
-                $early = (time() < $workshop->submissionend) ? 0 : $workshop->submissionend;
-                $late = (time() > $workshop->submissionend) ? 0 : $workshop->submissionend;
-                set_field('workshop', 'submissionstart', ($workshop->phase > 1) ? $early : $late, 'id', $workshop->id);
-                set_field('workshop', 'assessmentstart', ($workshop->phase > 2) ? $early : $late, 'id', $workshop->id);
-                set_field('workshop', 'submissionend', ($workshop->phase > 3) ? $early : $late, 'id', $workshop->id);
-                set_field('workshop', 'assessmentend', ($workshop->phase > 4) ? $early : $late, 'id', $workshop->id);
-            }
-        }
-        execute_sql('ALTER TABLE  '. $CFG->prefix .'workshop DROP COLUMN phase');
-
-        execute_sql("UPDATE {$CFG->prefix}event SET eventtype = 'submissionend' WHERE eventtype = 'deadline' AND modulename = 'workshop'", false);
-    }
-
-    if ($oldversion < 2004120900) {
-        table_column('workshop_assessments', '', 'teachergraded', 'INTEGER', '4', 'UNSIGNED', '0', 'NOT NULL', 'gradinggrade');
-    }
-
-    if ($oldversion < 2005041200) { // replace wiki-like with markdown
-        include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
-        $wtm = new WikiToMarkdown();
-        $wtm->update( 'workshop','description','format' );
-    }
-
-    if ($oldversion < 2005041201) { // Mass cleanup of bad upgrade scripts
-        // Some of those steps might fail, it is normal.
-        table_column('workshop','assessmentend','assessmentend','integer','16');
-        table_column('workshop','assessmentstart','assessmentstart','integer','16');
-        table_column('workshop','','phase','integer','4');
-        table_column('workshop','','showleaguetable','integer','8');
-        table_column('workshop','releasegrades','releasegrades','integer','16');
-        table_column('workshop','submissionend','submissionend','integer','16');
-        table_column('workshop','submissionstart','submissionstart','integer','16');
-        modify_database('','ALTER TABLE prefix_workshop ALTER teacherweight SET DEFAULT 1');
-        modify_database('','ALTER TABLE prefix_workshop DROP timeagreed');
-        modify_database('','ALTER TABLE prefix_workshop RENAME inalgrade TO finalgrade');
-        table_column('workshop_assessments','','donotuse','integer','8');
-        table_column('workshop_assessments','','timeagreed','integer','16');
-        modify_database('','ALTER TABLE prefix_workshop_assessments DROP teachergraded');
-        modify_database('','ALTER TABLE prefix_workshop_elements RENAME totalrassesments TO totalassessments');
-        modify_database('','ALTER TABLE prefix_workshop_submissions ALTER description DROP DEFAULT');
-        table_column('workshop_submissions','nassessments','nassessments','integer','16');
-        table_column('workshop_elements','totalassessments','totalassessments','integer','16');
-        execute_sql("
-        CREATE TABLE {$CFG->prefix}workshop_rubrics (
-          id SERIAL PRIMARY KEY,
-          workshopid int8 NOT NULL default '0',
-          elementno int8  NOT NULL default '0',
-          rubricno int4  NOT NULL default '0',
-          description text NOT NULL
-        )
-        ");
-    }
-
-    if ($oldversion < 2006090500) {
-        $columns = $db->MetaColumns($CFG->prefix.'workshop_assessments');
-        $columns = array_change_key_case($columns, CASE_LOWER);
-        if (!isset($columns['teachergraded'])) {
-            table_column('workshop_assessments', '', 'teachergraded', 'INTEGER', '4', 'UNSIGNED', '0', 'NOT NULL', 'gradinggrade');
-        }
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-
-}
-
-
-?>
diff --git a/mod/workshop/db/upgrade.php b/mod/workshop/db/upgrade.php
deleted file mode 100644 (file)
index db8ef76..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php  //$Id$
-
-// This file keeps track of upgrades to 
-// the workshop module
-//
-// Sometimes, changes between versions involve
-// alterations to database structures and other
-// major things that may break installations.
-//
-// The upgrade function in this file will attempt
-// to perform all the necessary actions to upgrade
-// your older installtion to the current version.
-//
-// If there's something it cannot do itself, it
-// will tell you what you need to do.
-//
-// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
-
-function xmldb_workshop_upgrade($oldversion=0) {
-
-    global $CFG, $THEME, $db;
-
-    $result = true;
-
-/// And upgrade begins here. For each one, you'll need one 
-/// block of code similar to the next one. Please, delete 
-/// this comment lines once this file start handling proper
-/// upgrade code.
-
-/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-///     $result = result of "/lib/ddllib.php" function calls
-/// }
-
-    return $result;
-}
-
-?>
diff --git a/mod/workshop/defaults.php b/mod/workshop/defaults.php
deleted file mode 100644 (file)
index 95b8965..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php  // $Id$
-    if (empty($CFG->workshop_initialdisable)) {
-        if (!count_records('workshop')) {
-            set_field('modules', 'visible', 0, 'name', 'workshop');  // Disable it by default
-            set_config('workshop_initialdisable', 1);
-        }
-    }
-
-?>
diff --git a/mod/workshop/icon.gif b/mod/workshop/icon.gif
deleted file mode 100644 (file)
index d9ffc4d..0000000
Binary files a/mod/workshop/icon.gif and /dev/null differ
diff --git a/mod/workshop/index.php b/mod/workshop/index.php
deleted file mode 100644 (file)
index 04ae72f..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-<?php // $Id$
-
-    require("../../config.php");
-    require("lib.php");
-    require("locallib.php");
-
-    $id = required_param('id',PARAM_INT);   // course
-
-    if (! $course = get_record("course", "id", $id)) {
-        print_error("Course ID is incorrect");
-    }
-
-    require_course_login($course);
-
-    add_to_log($course->id, "workshop", "view all", "index.php?id=$course->id", "");
-
-    $strworkshops = get_string("modulenameplural", "workshop");
-    $strworkshop = get_string("modulename", "workshop");
-    $strweek = get_string("week");
-    $strtopic = get_string("topic");
-    $strname = get_string("name");
-    $strinfo = get_string("grade")."/".$strinfo = get_string("phase", "workshop");
-    $strdeadline = get_string("deadline", "workshop");
-    $strsubmitted = get_string("submitted", "assignment");
-
-    $navlinks = array();
-    $navlinks[] = array('name' => $strworkshops, 'link' => '', 'type' => 'activity');
-    $navigation = build_navigation($navlinks);
-
-    print_header_simple("$strworkshops", "", $navigation, "", "", true, "", navmenu($course));
-
-    if (! $workshops = get_all_instances_in_course("workshop", $course)) {
-        notice(get_string('thereareno', 'moodle', $strworkshops), "../../course/view.php?id=$course->id");
-        die;
-    }
-
-    $timenow = time();
-
-    if ($course->format == "weeks") {
-        $table->head  = array ($strweek, $strname, $strinfo, $strsubmitted, $strdeadline);
-        $table->align = array ("CENTER", "LEFT", "LEFT", "LEFT", "LEFT");
-    } elseif ($course->format == "topics") {
-        $table->head  = array ($strtopic, $strname, $strinfo, $strsubmitted, $strdeadline);
-        $table->align = array ("CENTER", "LEFT", "left", "LEFT", "LEFT");
-    } else {
-        $table->head  = array ($strname, $strinfo, $strsubmitted, $strdeadline);
-        $table->align = array ("LEFT", "LEFT", "LEFT", "LEFT");
-    }
-
-    foreach ($workshops as $workshop) {
-        if (workshop_is_teacher($workshop, $USER->id)) { // teacher see info (students see grade)
-            $info = workshop_phase($workshop, 'short');
-            if (time() > $workshop->submissionstart) {
-                if ($num = workshop_count_student_submissions_for_assessment($workshop, $USER)) {
-                    $info .= " [".get_string("unassessed", "workshop", $num)."]";
-                }
-            }
-        }
-
-        $due = userdate($workshop->submissionend);
-
-        if ($submissions = workshop_get_user_submissions($workshop, $USER)) {
-            foreach ($submissions as $submission) {
-                if ($submission->timecreated <= $workshop->submissionend) {
-                    $submitted = userdate($submission->timecreated);
-                }
-                else {
-                    $submitted = "<span class=\"redfont\">".userdate($submission->timecreated)."</span>";
-                }
-                if (!$workshop->visible) {
-                    //Show dimmed if the mod is hidden
-                    $link = "<a class=\"dimmed\" href=\"view.php?id=$workshop->coursemodule\">".format_string($workshop->name,true)."</a><br />";
-                } else {
-                    //Show normal if the mod is visible
-                    $link = "<a href=\"view.php?id=$workshop->coursemodule\">".format_string($workshop->name,true)."</a><br />";
-                }
-                if (workshop_is_student($workshop)) {
-                    $link .= " ($submission->title)"; // show students the title of their submission(s)
-                    $gradinggrade = workshop_gradinggrade($workshop, $USER);
-                    $grade = workshop_submission_grade($workshop, $submission);
-                    if ($workshop->wtype) {
-                        if (workshop_count_assessments($submission)) {
-                            $info = get_string("gradeforassessments", "workshop").
-                                ": $gradinggrade/$workshop->gradinggrade; ".get_string("gradeforsubmission",
-                                "workshop").": $grade/$workshop->grade";
-                        } else {
-                            $info = get_string("gradeforassessments", "workshop").
-                                ": $gradinggrade/$workshop->gradinggrade; ".get_string("gradeforsubmission",
-                                "workshop").": ".get_string("noassessments", "workshop");
-                        }
-                     } else { // simple assignemnt, don't show grading grade
-                        $info = get_string("gradeforsubmission", "workshop").": $grade/$workshop->grade";
-                    }
-                    if ($workshop->releasegrades > $timenow) {
-                        $info = get_string("notavailable", "workshop");
-                    }
-                }
-                if ($course->format == "weeks" or $course->format == "topics") {
-                    $table->data[] = array ($workshop->section, $link, $info, $submitted, $due);
-                }
-                else {
-                    $table->data[] = array ($link, $info, $submitted, $due);
-                }
-                if (workshop_is_teacher($workshop)) {
-                    // teacher only needs to see one "submission"
-                    break;
-                }
-            }
-        }
-        else { // no submission
-            $submitted = get_string("no");
-            if (!$workshop->visible) {
-                //Show dimmed if the mod is hidden
-                $link = "<a class=\"dimmed\" href=\"view.php?id=$workshop->coursemodule\">".format_string($workshop->name,true)."</a>";
-            } else {
-                //Show normal if the mod is visible
-                $link = "<a href=\"view.php?id=$workshop->coursemodule\">".format_string($workshop->name,true)."</a>";
-            }
-            if (workshop_is_student($workshop)) {
-                $info = '0';
-            }
-            if ($course->format == "weeks" or $course->format == "topics") {
-                    $table->data[] = array ($workshop->section, $link, $info, $submitted, $due);
-            }
-            else {
-                $table->data[] = array ($link, $info, $submitted, $due);
-            }
-        }
-    }
-    echo "<br />";
-
-    print_table($table);
-
-    print_footer($course);
-?>
diff --git a/mod/workshop/lib.php b/mod/workshop/lib.php
deleted file mode 100644 (file)
index 86a90b1..0000000
+++ /dev/null
@@ -1,1857 +0,0 @@
-<?php  // $Id$
-
-// workshop constants and standard Moodle functions plus the workshop functions 
-// called by the standard functions
-
-// see also locallib.php for other non-standard workshop functions
-
-require_once($CFG->libdir.'/filelib.php');
-
-/*** Constants **********************************/
-
-
-$WORKSHOP_EWEIGHTS = array(  0 => -4.0, 1 => -2.0, 2 => -1.5, 3 => -1.0, 4 => -0.75, 5 => -0.5,  6 => -0.25, 
-                             7 => 0.0, 8 => 0.25, 9 => 0.5, 10 => 0.75, 11=> 1.0, 12 => 1.5, 13=> 2.0, 
-                             14 => 4.0); 
-
-$WORKSHOP_FWEIGHTS = array(  0 => 0, 1 => 0.1, 2 => 0.25, 3 => 0.5, 4 => 0.75, 5 => 1.0,  6 => 1.5, 
-                             7 => 2.0, 8 => 3.0, 9 => 5.0, 10 => 7.5, 11=> 10.0, 12=>50.0); 
-
-
-$WORKSHOP_ASSESSMENT_COMPS = array (
-                          0 => array('name' => get_string('verylax', 'workshop'), 'value' => 1),
-                          1 => array('name' => get_string('lax', 'workshop'), 'value' => 0.6),
-                          2 => array('name' => get_string('fair', 'workshop'), 'value' => 0.4),
-                          3 => array('name' => get_string('strict', 'workshop'), 'value' => 0.33),
-                          4 => array('name' => get_string('verystrict', 'workshop'), 'value' => 0.2) );
-
-
-/*** Moodle 1.7 compatibility functions *****
- *
- ********************************************/
-function workshop_context($workshop) {
-    //TODO: add some $cm caching if needed
-    if (is_object($workshop)) {
-        $workshop = $workshop->id;
-    }
-    if (! $cm = get_coursemodule_from_instance('workshop', $workshop)) {
-        print_error('Course Module ID was incorrect');
-    }
-
-    return get_context_instance(CONTEXT_MODULE, $cm->id);
-}
-
-function workshop_is_teacher($workshop, $userid=NULL) {
-    return has_capability('mod/workshop:manage', workshop_context($workshop), $userid);
-}
-function workshop_is_teacheredit($workshop, $userid=NULL) {
-    return has_capability('mod/workshop:manage', workshop_context($workshop), $userid)
-       and has_capability('moodle/site:accessallgroups', workshop_context($workshop), $userid);
-}
-
-function workshop_is_student($workshop, $userid=NULL) {
-    return has_capability('mod/workshop:participate', workshop_context($workshop), $userid);
-}
-
-function workshop_get_students($workshop, $sort='u.lastaccess', $fields='u.*') {
-    return $users = get_users_by_capability(workshop_context($workshop), 'mod/workshop:participate', $fields, $sort);
-}
-
-function workshop_get_teachers($workshop, $sort='u.lastaccess', $fields='u.*') {
-    return $users = get_users_by_capability(workshop_context($workshop), 'mod/workshop:manage', $fields, $sort);
-}
-
-
-/*** Standard Moodle functions ******************
-workshop_add_instance($workshop) 
-workshop_check_dates($workshop)
-workshop_cron () 
-workshop_delete_instance($id) 
-workshop_grades($workshopid) 
-workshop_print_recent_activity(&$logs, $isteacher=false) 
-workshop_refresh_events($workshop) 
-workshop_update_instance($workshop) 
-workshop_user_complete($course, $user, $mod, $workshop) 
-workshop_user_outline($course, $user, $mod, $workshop) 
-**********************************************/
-
-///////////////////////////////////////////////////////////////////////////////
-function workshop_add_instance($workshop) {
-// Given an object containing all the necessary data, 
-// (defined by the form in mod.html) this function 
-// will create a new instance and return the id number 
-// of the new instance.
-
-    $workshop->timemodified = time();
-
-    $workshop->submissionstart = make_timestamp($workshop->submissionstartyear, 
-            $workshop->submissionstartmonth, $workshop->submissionstartday, $workshop->submissionstarthour, 
-            $workshop->submissionstartminute);
-
-    $workshop->assessmentstart = make_timestamp($workshop->assessmentstartyear, 
-            $workshop->assessmentstartmonth, $workshop->assessmentstartday, $workshop->assessmentstarthour, 
-            $workshop->assessmentstartminute);
-
-    $workshop->submissionend = make_timestamp($workshop->submissionendyear, 
-            $workshop->submissionendmonth, $workshop->submissionendday, $workshop->submissionendhour, 
-            $workshop->submissionendminute);
-
-    $workshop->assessmentend = make_timestamp($workshop->assessmentendyear, 
-            $workshop->assessmentendmonth, $workshop->assessmentendday, $workshop->assessmentendhour, 
-            $workshop->assessmentendminute);
-
-    $workshop->releasegrades = make_timestamp($workshop->releaseyear, 
-            $workshop->releasemonth, $workshop->releaseday, $workshop->releasehour, 
-            $workshop->releaseminute);
-    
-    if (!workshop_check_dates($workshop)) {
-        return get_string('invaliddates', 'workshop');
-    }
-
-    if ($returnid = insert_record("workshop", $workshop)) {
-
-        $event = NULL;
-        $event->name        = get_string('submissionstartevent','workshop', $workshop->name);
-        $event->description = $workshop->description;
-        $event->courseid    = $workshop->course;
-        $event->groupid     = 0;
-        $event->userid      = 0;
-        $event->modulename  = 'workshop';
-        $event->instance    = $returnid;
-        $event->eventtype   = 'submissionstart';
-        $event->timestart   = $workshop->submissionstart;
-        $event->timeduration = 0;
-        add_event($event);
-
-        $event->name        = get_string('submissionendevent','workshop', $workshop->name);
-        $event->eventtype   = 'submissionend';
-        $event->timestart   = $workshop->submissionend;
-        add_event($event);
-
-        $event->name        = get_string('assessmentstartevent','workshop', $workshop->name);
-        $event->eventtype   = 'assessmentstart';
-        $event->timestart   = $workshop->assessmentstart;
-        add_event($event);
-
-        $event->name        = get_string('assessmentendevent','workshop', $workshop->name);
-        $event->eventtype   = 'assessmentend';
-        $event->timestart   = $workshop->assessmentend;
-        add_event($event);
-    }
-
-    return $returnid;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// returns true if the dates are valid, false otherwise
-function workshop_check_dates($workshop) {
-    // allow submission and assessment to start on the same date and to end on the same date
-    // but enforce non-empty submission period and non-empty assessment period.
-    return ($workshop->submissionstart < $workshop->submissionend and
-            $workshop->submissionstart <= $workshop->assessmentstart and
-            $workshop->assessmentstart < $workshop->assessmentend and
-            $workshop->submissionend <= $workshop->assessmentend);
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-function workshop_cron () {
-// Function to be run periodically according to the moodle cron
-
-    global $CFG, $USER;
-    
-    // if there any ungraded assessments run the grading routine
-    if ($workshops = get_records("workshop")) {
-        foreach ($workshops as $workshop) {
-            // automatically grade assessments if workshop has examples and/or peer assessments
-            if ($workshop->gradingstrategy and ($workshop->ntassessments or $workshop->nsassessments)) {
-                workshop_grade_assessments($workshop);
-            }
-        }
-    }
-    $timenow = time();
-    
-    // Find all workshop notifications that have yet to be mailed out, and mails them
-    $cutofftime = $timenow - $CFG->maxeditingtime;
-
-    // look for new assessments
-    if ($assessments = workshop_get_unmailed_assessments($cutofftime)) {
-        foreach ($assessments as $assessment) {
-
-            echo "Processing workshop assessment $assessment->id\n";
-            
-            // only process the entry once
-            if (! set_field("workshop_assessments", "mailed", "1", "id", "$assessment->id")) {
-                echo "Could not update the mailed field for id $assessment->id\n";
-            }
-            
-            if (! $submission = get_record("workshop_submissions", "id", "$assessment->submissionid")) {
-                echo "Could not find submission $assessment->submissionid\n";
-                continue;
-            }
-            if (! $workshop = get_record("workshop", "id", $submission->workshopid)) {
-                echo "Could not find workshop id $submission->workshopid\n";
-                continue;
-            }
-            if (! $course = get_record("course", "id", $workshop->course)) {
-                print_error("Could not find course id $workshop->course");
-                continue;
-            }
-            if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
-                print_error("Course Module ID was incorrect");
-                continue;
-            }
-            if (! $submissionowner = get_record("user", "id", "$submission->userid")) {
-                echo "Could not find user $submission->userid\n";
-                continue;
-            }
-            if (! $assessmentowner = get_record("user", "id", "$assessment->userid")) {
-                echo "Could not find user $assessment->userid\n";
-                continue;
-            }
-            if (! workshop_is_student($workshop, $submissionowner->id) and !workshop_is_teacher($workshop, 
-                        $submissionowner->id)) {
-                continue;  // Not an active participant
-            }
-            if (! workshop_is_student($workshop, $assessmentowner->id) and !workshop_is_teacher($workshop, 
-                        $assessmentowner->id)) {
-                continue;  // Not an active participant
-            }
-            // don't sent self assessment
-            if ($submissionowner->id == $assessmentowner->id) {
-                continue;
-            }
-            $strworkshops = get_string("modulenameplural", "workshop");
-            $strworkshop  = get_string("modulename", "workshop");
-    
-            // it's an assessment, tell the submission owner
-            $USER->lang = $submissionowner->lang;
-            $sendto = $submissionowner;
-            // "Your assignment \"$submission->title\" has been assessed by"
-            if (workshop_is_student($workshop, $assessmentowner->id)) {
-                $msg = get_string("mail1", "workshop", $submission->title)." a $course->student.\n";
-            }
-            else {
-                $msg = get_string("mail1", "workshop", $submission->title).
-                    " ".fullname($assessmentowner)."\n";
-            }
-            // "The comments and grade can be seen in the workshop assignment '$workshop->name'
-            // I have taken the following line out because the info is repeated below.
-            // $msg .= get_string("mail2", "workshop", $workshop->name)."\n\n";
-    
-            $postsubject = "$course->shortname: $strworkshops: ".format_string($workshop->name,true);
-            $posttext  = "$course->shortname -> $strworkshops -> ".format_string($workshop->name,true)."\n";
-            $posttext .= "---------------------------------------------------------------------\n";
-            $posttext .= $msg;
-            // "The comments and grade can be seen in ..."
-            $posttext .= get_string("mail2", "workshop", 
-                format_string($workshop->name,true).",   $CFG->wwwroot/mod/workshop/view.php?id=$cm->id")."\n";
-            $posttext .= "---------------------------------------------------------------------\n";
-            if ($sendto->mailformat == 1) {  // HTML
-                $posthtml = "<p><font face=\"sans-serif\">".
-                    "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->".
-                    "<a href=\"$CFG->wwwroot/mod/workshop/index.php?id=$course->id\">$strworkshops</a> ->".
-                    "<a href=\"$CFG->wwwroot/mod/workshop/view.php?id=$cm->id\">".format_string($workshop->name,true)."</a></font></p>";
-                $posthtml .= "<hr><font face=\"sans-serif\">";
-                $posthtml .= "<p>$msg</p>";
-                $posthtml .= "<p>".get_string("mail2", "workshop",
-                    " <a href=\"$CFG->wwwroot/mod/workshop/view.php?id=$cm->id\">".format_string($workshop->name,true)."</a>")."</p></font><hr>";
-            } else {
-                $posthtml = "";
-            }
-    
-            if (!$teacher = get_teacher($course->id)) {
-                echo "Error: can not find teacher for course $course->id!\n";
-            }
-                
-            if (! email_to_user($sendto, $teacher, $postsubject, $posttext, $posthtml)) {
-                echo "Error: workshop cron: Could not send out mail for id $submission->id to 
-                    user $sendto->id ($sendto->email)\n";
-            }
-        }
-    }
-        
-    // look for new assessments of resubmissions
-    if ($assessments = workshop_get_unmailed_resubmissions($cutofftime)) {
-        $timenow = time();
-
-        foreach ($assessments as $assessment) {
-
-            echo "Processing workshop assessment $assessment->id\n";
-            
-            // only process the entry once
-            if (! set_field("workshop_assessments", "mailed", "1", "id", "$assessment->id")) {
-                echo "Could not update the mailed field for id $assessment->id\n";
-            }
-            
-            if (! $submission = get_record("workshop_submissions", "id", "$assessment->submissionid")) {
-                echo "Could not find submission $assessment->submissionid\n";
-                continue;
-            }
-            if (! $workshop = get_record("workshop", "id", $submission->workshopid)) {
-                echo "Could not find workshop id $submission->workshopid\n";
-                continue;
-            }
-            if (! $course = get_record("course", "id", $workshop->course)) {
-                print_error("Could not find course id $workshop->course");
-                continue;
-            }
-            if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
-                print_error("Course Module ID was incorrect");
-                continue;
-            }
-            if (! $submissionowner = get_record("user", "id", "$submission->userid")) {
-                echo "Could not find user $submission->userid\n";
-                continue;
-            }
-            if (! $assessmentowner = get_record("user", "id", "$assessment->userid")) {
-                echo "Could not find user $assessment->userid\n";
-                continue;
-            }
-            if (! workshop_is_student($workshop, $submissionowner->id) and !workshop_is_teacher($workshop, 
-                        $submissionowner->id)) {
-                continue;  // Not an active participant
-            }
-            if (! workshop_is_student($workshop, $assessmentowner->id) and !workshop_is_teacher($workshop, 
-                        $assessmentowner->id)) {
-                continue;  // Not an active participant
-            }
-    
-            $strworkshops = get_string("modulenameplural", "workshop");
-            $strworkshop  = get_string("modulename", "workshop");
-    
-            // it's a resubission assessment, tell the assessment owner to (re)assess
-            $USER->lang = $assessmentowner->lang;
-            $sendto = $assessmentowner;
-            // "The assignment \"$submission->title\" is a revised piece of work. "
-            $msg = get_string("mail8", "workshop", $submission->title)."\n";
-            // "Please assess it in the workshop assignment '$workshop->name'
-            // $msg .= get_string("mail9", "workshop", $workshop->name)."\n\n";
-    
-            $postsubject = "$course->shortname: $strworkshops: ".format_string($workshop->name,true);
-            $posttext  = "$course->shortname -> $strworkshops -> ".format_string($workshop->name,true)."\n";
-            $posttext .= "---------------------------------------------------------------------\n";
-            $posttext .= $msg;
-            // "Please assess it in ..."
-            $posttext .= get_string("mail9", "workshop", 
-                           format_string($workshop->name,true).", $CFG->wwwroot/mod/workshop/view.php?id=$cm->id")."\n";
-            $posttext .= "---------------------------------------------------------------------\n";
-            if ($sendto->mailformat == 1) {  // HTML
-                $posthtml = "<p><font face=\"sans-serif\">".
-                  "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->".
-                  "<a href=\"$CFG->wwwroot/mod/workshop/index.php?id=$course->id\">$strworkshops</a> ->".
-                  "<a href=\"$CFG->wwwroot/mod/workshop/view.php?id=$cm->id\">".format_string($workshop->name,true)."</a></font></p>";
-                $posthtml .= "<hr><font face=\"sans-serif\">";
-                $posthtml .= "<p>$msg</p>";
-                $posthtml .= "<p>".get_string("mail9", "workshop",
-                  " <a href=\"$CFG->wwwroot/mod/workshop/view.php?id=$cm->id\">".format_string($workshop->name,true)."</a>").'</p></font><hr>';
-            } 
-            else {
-              $posthtml = "";
-            }
-    
-            if (!$teacher = get_teacher($course->id)) {
-                echo "Error: can not find teacher for course $course->id!\n";
-            }
-                
-            if (! email_to_user($sendto, $teacher, $postsubject, $posttext, $posthtml)) {
-                echo "Error: workshop cron: Could not send out mail for id $submission->id to 
-                    user $sendto->id ($sendto->email)\n";
-            }
-        }
-    }
-    
-    // look for new comments
-    if ($comments = workshop_get_unmailed_comments($cutofftime)) {
-        $timenow = time();
-
-        foreach ($comments as $comment) {
-
-            echo "Processing workshop comment $comment->id\n";
-            
-            // only process the entry once
-            if (! set_field("workshop_comments", "mailed", "1", "id", "$comment->id")) {
-                echo "Could not update the mailed field for comment id $comment->id\n";
-            }
-            
-            if (! $assessment = get_record("workshop_assessments", "id", "$comment->assessmentid")) {
-                echo "Could not find assessment $comment->assessmentid\n";
-                continue;
-            }
-            if (! $submission = get_record("workshop_submissions", "id", "$assessment->submissionid")) {
-                echo "Could not find submission $assessment->submissionid\n";
-                continue;
-            }
-            if (! $workshop = get_record("workshop", "id", $submission->workshopid)) {
-                echo "Could not find workshop id $submission->workshopid\n";
-                continue;
-            }
-            if (! $course = get_record("course", "id", $workshop->course)) {
-                print_error("Could not find course id $workshop->course");
-                continue;
-            }
-            if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
-                print_error("Course Module ID was incorrect");
-                continue;
-            }
-            if (! $submissionowner = get_record("user", "id", "$submission->userid")) {
-                echo "Could not find user $submission->userid\n";
-                continue;
-            }
-            if (! $assessmentowner = get_record("user", "id", "$assessment->userid")) {
-                echo "Could not find user $assessment->userid\n";
-                continue;
-            }
-            if (! workshop_is_student($workshop, $submissionowner->id) and !workshop_is_teacher($workshop, 
-                        $submissionowner->id)) {
-                continue;  // Not an active participant
-            }
-            if (! workshop_is_student($workshop, $assessmentowner->id) and !workshop_is_teacher($workshop, 
-                        $assessmentowner->id)) {
-                continue;  // Not an active participant
-            }
-    
-            $strworkshops = get_string("modulenameplural", "workshop");
-            $strworkshop  = get_string("modulename", "workshop");
-    
-            // see if the submission owner needs to be told
-            if ($comment->userid != $submission->userid) {
-                $USER->lang = $submissionowner->lang;
-                $sendto = $submissionowner;
-                // "A comment has been added to the assignment \"$submission->title\" by
-                if (workshop_is_student($workshop, $assessmentowner->id)) {
-                    $msg = get_string("mail4", "workshop", $submission->title)." a $course->student.\n";
-                }
-                else {
-                    $msg = get_string("mail4", "workshop", $submission->title)." ".fullname($assessmentowner)."\n";
-                }
-                // "The new comment can be seen in the workshop assignment '$workshop->name'
-                // $msg .= get_string("mail5", "workshop", $workshop->name)."\n\n";
-    
-                $postsubject = "$course->shortname: $strworkshops: ".format_string($workshop->name,true);
-                $posttext  = "$course->shortname -> $strworkshops -> ".format_string($workshop->name,true)."\n";
-                $posttext .= "---------------------------------------------------------------------\n";
-                $posttext .= $msg;
-                // "The new comment can be seen in ..."
-                $posttext .= get_string("mail5", "workshop",
-                    format_string($workshop->name,true).",   $CFG->wwwroot/mod/workshop/view.php?id=$cm->id")."\n";
-                $posttext .= "---------------------------------------------------------------------\n";
-                if ($sendto->mailformat == 1) {  // HTML
-                    $posthtml = "<p><font face=\"sans-serif\">".
-                    "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->".
-                    "<a href=\"$CFG->wwwroot/mod/workshop/index.php?id=$course->id\">$strworkshops</a> ->".
-                    "<a href=\"$CFG->wwwroot/mod/workshop/view.php?id=$cm->id\">".format_string($workshop->name,true)."</a></font></p>";
-                    $posthtml .= "<hr><font face=\"sans-serif\">";
-                    $posthtml .= "<p>$msg</p>";
-                    $posthtml .= "<p>".get_string("mail5", "workshop",
-                        " <a href=\"$CFG->wwwroot/mod/workshop/view.php?id=$cm->id\">".format_string($workshop->name,true)."</a>")
-                        ."</p></font><hr>";
-                } 
-                else {
-                    $posthtml = "";
-                }
-    
-                if (!$teacher = get_teacher($course->id)) {
-                    echo "Error: can not find teacher for course $course->id!\n";
-                }
-                    
-                if (! email_to_user($sendto, $teacher, $postsubject, $posttext, $posthtml)) {
-                    echo "Error: workshop cron: Could not send out mail for id $submission->id to user 
-                        $sendto->id ($sendto->email)\n";
-                }
-            }
-            // see if the assessor needs to to told
-            if ($comment->userid != $assessment->userid) {
-                $USER->lang = $assessmentowner->lang;
-                $sendto = $assessmentowner;
-                // "A comment has been added to the assignment \"$submission->title\" by
-                if (workshop_is_student($workshop, $submissionowner->id)) {
-                    $msg = get_string("mail4", "workshop", $submission->title)." a $course->student.\n";
-                }
-                else {
-                    $msg = get_string("mail4", "workshop", $submission->title).
-                        " ".fullname($submissionowner)."\n";
-                }
-                // "The new comment can be seen in the workshop assignment '$workshop->name'
-                // $msg .= get_string("mail5", "workshop", $workshop->name)."\n\n";
-    
-                $postsubject = "$course->shortname: $strworkshops: ".format_string($workshop->name,true);
-                $posttext  = "$course->shortname -> $strworkshops -> ".format_string($workshop->name,true)."\n";
-                $posttext .= "---------------------------------------------------------------------\n";
-                $posttext .= $msg;
-                // "The new comment can be seen in ..."
-                $posttext .= get_string("mail5", "workshop",
-                    format_string($workshop->name,true).",  $CFG->wwwroot/mod/workshop/view.php?id=$cm->id")."\n";
-                $posttext .= "---------------------------------------------------------------------\n";
-                if ($sendto->mailformat == 1) {  // HTML
-                    $posthtml = "<p><font face=\"sans-serif\">".
-                    "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->".
-                    "<a href=\"$CFG->wwwroot/mod/workshop/index.php?id=$course->id\">$strworkshops</a> ->".
-                    "<a href=\"$CFG->wwwroot/mod/workshop/view.php?id=$cm->id\">".format_string($workshop->name,true)."</a></font></p>";
-                    $posthtml .= "<hr><font face=\"sans-serif\">";
-                    $posthtml .= "<p>$msg</p>";
-                    $posthtml .= "<p>".get_string("mail5", "workshop",
-                        " <a href=\"$CFG->wwwroot/mod/workshop/view.php?id=$cm->id\">".format_string($workshop->name,true)."</a>")
-                        ."</p></font><hr>";
-                } 
-                else {
-                    $posthtml = "";
-                }
-    
-                if (!$teacher = get_teacher($course->id)) {
-                    echo "Error: can not find teacher for course $course->id!\n";
-                }
-                    
-                if (! email_to_user($sendto, $teacher, $postsubject, $posttext, $posthtml)) {
-                    echo "Error: workshop cron: Could not send out mail for id $submission->id to user 
-                        $sendto->id ($sendto->email)\n";
-                }
-                if (! set_field("workshop_comments", "mailed", "1", "id", "$comment->id")) {
-                    echo "Could not update the mailed field for comment id $comment->id\n";
-                }
-            }
-        }
-    }
-    return true;
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-function workshop_delete_instance($id) {
-// Given an ID of an instance of this module, 
-// this function will permanently delete the instance 
-// and any data that depends on it.  
-
-    if (! $workshop = get_record("workshop", "id", "$id")) {
-        return false;
-    }
-    
-    // delete all the associated records in the workshop tables, start positive...
-    $result = true;
-
-    if (! delete_records("workshop_comments", "workshopid", "$workshop->id")) {
-        $result = false;
-    }
-
-    if (! delete_records("workshop_stockcomments", "workshopid", "$workshop->id")) {
-        $result = false;
-    }
-
-    if (! delete_records("workshop_grades", "workshopid", "$workshop->id")) {
-        $result = false;
-    }
-
-    if (! delete_records("workshop_elements", "workshopid", "$workshop->id")) {
-        $result = false;
-    }
-
-    if (! delete_records("workshop_assessments", "workshopid", "$workshop->id")) {
-        $result = false;
-    }
-
-    if (! delete_records("workshop_submissions", "workshopid", "$workshop->id")) {
-        $result = false;
-    }
-
-    if (! delete_records("workshop", "id", "$workshop->id")) {
-        $result = false;
-    }
-
-    if (! delete_records('event', 'modulename', 'workshop', 'instance', $workshop->id)) {
-        $result = false;    
-    }   
-
-    return $result;
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-function workshop_grades($workshopid) {
-/// Must return an array of grades, indexed by user, and a max grade.
-/// only returns grades once assessment has started
-/// returns nothing if workshop is not graded
-    global $CFG;
-
-    $return = null;
-    if ($workshop = get_record("workshop", "id", $workshopid)) {
-        if (($workshop->assessmentstart < time()) and $workshop->gradingstrategy) {
-            if ($students = workshop_get_students($workshop)) {
-                foreach ($students as $student) {
-                    if ($workshop->wtype) {
-                        $gradinggrade = workshop_gradinggrade($workshop, $student);
-                    } else { // ignore grading grades for simple assignments
-                        $gradinggrade = 0;
-                    }
-                    $bestgrade = 0;
-                    if ($submissions = workshop_get_user_submissions($workshop, $student)) {
-                        foreach ($submissions as $submission) {
-                            if (!$submission->late) {
-                                $grade = workshop_submission_grade($workshop, $submission);
-                            } else {
-                                $grade = 0.01;
-                            }
-                            if ($grade > $bestgrade) {
-                                $bestgrade = $grade;
-                            }
-                        }
-                    }
-                    $return->grades[$student->id] = $gradinggrade + $bestgrade;
-                }
-            }
-        }
-        // set maximum grade if graded
-        if ($workshop->gradingstrategy) {
-            if ($workshop->wtype) {
-                $return->maxgrade = $workshop->grade + $workshop->gradinggrade;
-            } else { // ignore grading grades for simple assignemnts
-                $return->maxgrade = $workshop->grade;
-            }
-        }
-    }
-    return $return;
-}
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_is_recent_activity($course, $isteacher, $timestart) {//jlw1 added for adding mark to courses with activity in My Moodle
-    global $CFG;
-
-    // have a look for agreed assessments for this user (agree) 
-    $agreecontent = false;
-    if (!$isteacher) { // teachers only need to see submissions
-        if ($logs = workshop_get_agree_logs($course, $timestart)) {
-            // got some, see if any belong to a visible module
-            foreach ($logs as $log) {
-                // Create a temp valid module structure (only need courseid, moduleid)
-                $tempmod->course = $course->id;
-                $tempmod->id = $log->workshopid;
-                //Obtain the visible property from the instance
-                if (instance_is_visible("workshop",$tempmod)) {
-                    $agreecontent = true;
-                    break;
-                }
-            }
-        }
-    }
-    return false;
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-//
-// NOTE: $isteacher usage should be converted to use roles.
-// TODO: Fix this function.
-//
-function workshop_print_recent_activity($course, $viewfullanmes, $timestart) {
-    global $CFG;
-
-    $isteacher = has_capability('mod/workshop:manage', get_context_instance(CONTEXT_COURSE, $course->id));
-
-    $modinfo = get_fast_modinfo($course);
-
-    // have a look for agreed assessments for this user (agree) 
-    $agreecontent = false;
-    if (!$isteacher) { // teachers only need to see submissions
-        if ($logs = workshop_get_agree_logs($course, $timestart)) {
-            $agreecontent = true;
-            print_headline(get_string("workshopagreedassessments", "workshop").":");
-            foreach ($logs as $log) {
-                if (!workshop_is_teacher($workshop, $log->userid)) {  // don't break anonymous rule
-                    $log->firstname = $course->student;
-                    $log->lastname = '';
-                }
-                print_recent_activity_note($log->time, $log, $log->name,
-                                           $CFG->wwwroot.'/mod/workshop/'.$log->url);
-            }
-        }
-    }
-
-    // have a look for new assessments for this user (assess) 
-    $assesscontent = false;
-    if (!$isteacher) { // teachers only need to see submissions
-        if ($logs = workshop_get_assess_logs($course, $timestart)) {
-            // got some, see if any belong to a visible module
-            foreach ($logs as $id=>$log) {
-                $cm = $modinfo->instances['workshop'][$log->workshopid];
-                if (!$cm->uservisible) {
-                    unset($logs[$id]);
-                    continue;
-                }
-            }
-            // if we got some "live" ones then output them
-            if ($logs) {
-                $assesscontent = true;
-                print_headline(get_string("workshopassessments", "workshop").":");
-                foreach ($logs as $log) {
-                    if (!workshop_is_teacher($tempmod->id, $log->userid)) {  // don't break anonymous rule
-                        $log->firstname = $course->student;    // Keep anonymous
-                        $log->lastname = '';
-                    }
-                    print_recent_activity_note($log->time, $log, $log->name,
-                                               $CFG->wwwroot.'/mod/workshop/'.$log->url);
-                }
-            }
-        }
-    }
-    // have a look for new comments for this user (comment) 
-    $commentcontent = false;
-    if (!$isteacher) { // teachers only need to see submissions
-        if ($logs = workshop_get_comment_logs($course, $timestart)) {
-            // got some, see if any belong to a visible module
-            foreach ($logs as $id=>$log) {
-                $cm = $modinfo->instances['workshop'][$log->workshopid];
-                if (!$cm->uservisible) {
-                    unset($logs[$id]);
-                    continue;
-                }
-            }
-            // if we got some "live" ones then output them
-            if ($logs) {
-                $commentcontent = true;
-                print_headline(get_string("workshopcomments", "workshop").":");
-                foreach ($logs as $log) {
-                    $log->firstname = $course->student;    // Keep anonymous
-                    $log->lastname = '';
-                    print_recent_activity_note($log->time, $log, $log->name,
-                                               $CFG->wwwroot.'/mod/workshop/'.$log->url);
-                }
-            }
-        }
-    }
-
-    // have a look for new assessment gradings for this user (grade)
-    $gradecontent = false;
-    if ($logs = workshop_get_grade_logs($course, $timestart)) {
-        // got some, see if any belong to a visible module
-        foreach ($logs as $id=>$log) {
-            $cm = $modinfo->instances['workshop'][$log->workshopid];
-            if (!$cm->uservisible) {
-                unset($logs[$id]);
-                continue;
-            }
-        }
-        // if we got some "live" ones then output them
-        if ($logs) {
-            $gradecontent = true;
-            print_headline(get_string("workshopfeedback", "workshop").":");
-            foreach ($logs as $log) {
-                $log->firstname = $course->teacher;    // Keep anonymous
-                $log->lastname = '';
-                print_recent_activity_note($log->time, $log, $log->name,
-                                           $CFG->wwwroot.'/mod/workshop/'.$log->url);
-            }
-        }
-    }
-
-    // have a look for new submissions (only show to teachers) (submit)
-    $submitcontent = false;
-    if ($isteacher) {
-        if ($logs = workshop_get_submit_logs($course, $timestart)) {
-            // got some, see if any belong to a visible module
-            foreach ($logs as $id=>$log) {
-                $cm = $modinfo->instances['workshop'][$log->workshopid];
-                if (!$cm->uservisible) {
-                    unset($logs[$id]);
-                    continue;
-                }
-            }
-            // if we got some "live" ones then output them
-            if ($logs) {
-                $submitcontent = true;
-                print_headline(get_string("workshopsubmissions", "workshop").":");
-                foreach ($logs as $log) {
-                    print_recent_activity_note($log->time, $log, $log->name,
-                                               $CFG->wwwroot.'/mod/workshop/'.$log->url);
-                }
-            }
-        }
-    }
-
-    return $agreecontent or $assesscontent or $commentcontent or $gradecontent or $submitcontent;
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-function workshop_refresh_events($courseid = 0) {
-// This standard function will check all instances of this module
-// and make sure there are up-to-date events created for each of them.
-// If courseid = 0, then every workshop event in the site is checked, else
-// only workshop events belonging to the course specified are checked.
-// This function is used, in its new format, by restore_refresh_events()
-
-    if ($courseid == 0) {
-        if (! $workshops = get_records("workshop")) {
-            return true;        
-        }   
-    } else {
-        if (! $workshops = get_records("workshop", "course", $courseid)) {
-            return true;
-        }
-    }
-    $moduleid = get_field('modules', 'id', 'name', 'workshop');
-    
-    foreach ($workshops as $workshop) {
-    
-        $dates = array(
-            'submissionstart' => $workshop->submissionstart,
-            'submissionend' => $workshop->submissionend,
-            'assessmentstart' => $workshop->assessmentstart,
-            'assessmentend' => $workshop->assessmentend
-        );
-        
-        foreach ($dates as $type => $date) {
-        
-            if ($date) {
-                if ($event = get_record('event', 'modulename', 'workshop', 'instance', $workshop->id, 'eventtype', $type)) {
-                    $event->name        = addslashes(get_string($type.'event','workshop', $workshop->name));
-                    $event->description = addslashes($workshop->description);
-                    $event->eventtype   = $type;
-                    $event->timestart   = $date;
-                    update_event($event);
-                } else {
-                    $event->courseid    = $workshop->course;
-                    $event->modulename  = 'workshop';
-                    $event->instance    = $workshop->id; 
-                    $event->name        = addslashes(get_string($type.'event','workshop', $workshop->name));
-                    $event->description = addslashes($workshop->description);
-                    $event->eventtype   = $type;
-                    $event->timestart   = $date;
-                    $event->timeduration = 0;
-                    $event->visible     = get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $workshop->id); 
-                    add_event($event);
-                }
-            }
-        }
-    }
-    return true;
-}   
-
-
-///////////////////////////////////////////////////////////////////////////////
-function workshop_update_instance($workshop) {
-// Given an object containing all the necessary data, 
-// (defined by the form in mod.html) this function 
-// will update an existing instance with new data.
-    global $CFG;
-
-    $workshop->timemodified = time();
-
-    $workshop->submissionstart = make_timestamp($workshop->submissionstartyear, 
-            $workshop->submissionstartmonth, $workshop->submissionstartday, $workshop->submissionstarthour, 
-            $workshop->submissionstartminute);
-
-    $workshop->assessmentstart = make_timestamp($workshop->assessmentstartyear, 
-            $workshop->assessmentstartmonth, $workshop->assessmentstartday, $workshop->assessmentstarthour, 
-            $workshop->assessmentstartminute);
-
-    $workshop->submissionend = make_timestamp($workshop->submissionendyear, 
-            $workshop->submissionendmonth, $workshop->submissionendday, $workshop->submissionendhour, 
-            $workshop->submissionendminute);
-
-    $workshop->assessmentend = make_timestamp($workshop->assessmentendyear, 
-            $workshop->assessmentendmonth, $workshop->assessmentendday, $workshop->assessmentendhour, 
-            $workshop->assessmentendminute);
-
-    $workshop->releasegrades = make_timestamp($workshop->releaseyear, 
-            $workshop->releasemonth, $workshop->releaseday, $workshop->releasehour, 
-            $workshop->releaseminute);
-            
-    if (!workshop_check_dates($workshop)) {
-        return get_string('invaliddates', 'workshop');
-    }
-
-    // set the workshop's type
-    $wtype = 0; // 3 phases, no grading grades
-    if ($workshop->includeself or $workshop->ntassessments) $wtype = 1; // 3 phases with grading grades
-    if ($workshop->nsassessments) $wtype = 2; // 5 phases with grading grades 
-    $workshop->wtype = $wtype;
-    
-    // encode password if necessary
-    if (!empty($workshop->password)) {
-        $workshop->password = md5($workshop->password);
-    } else {
-        unset($workshop->password);
-    }
-
-    $workshop->id = $workshop->instance;
-
-    if ($returnid = update_record("workshop", $workshop)) {
-
-        $dates = array(
-            'submissionstart' => $workshop->submissionstart,
-            'submissionend' => $workshop->submissionend,
-            'assessmentstart' => $workshop->assessmentstart,
-            'assessmentend' => $workshop->assessmentend
-        );
-        $moduleid = get_field('modules', 'id', 'name', 'workshop');
-        
-        foreach ($dates as $type => $date) {
-            if ($event = get_record('event', 'modulename', 'workshop', 'instance', $workshop->id, 'eventtype', $type)) {
-                $event->name        = get_string($type.'event','workshop', $workshop->name);
-                $event->description = $workshop->description;
-                $event->eventtype   = $type;
-                $event->timestart   = $date;
-                update_event($event);
-            } else if ($date) {
-                $event = NULL;
-                $event->name        = get_string($type.'event','workshop', $workshop->name);
-                $event->description = $workshop->description;
-                $event->courseid    = $workshop->course;
-                $event->groupid     = 0;
-                $event->userid      = 0;
-                $event->modulename  = 'workshop';
-                $event->instance    = $workshop->instance;
-                $event->eventtype   = $type;
-                $event->timestart   = $date;
-                $event->timeduration = 0;
-                $event->visible     = get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $workshop->id); 
-                add_event($event);
-            }
-        }
-    }
-
-    if (time() > $workshop->assessmentstart) {
-        // regrade all the submissions...
-        set_field("workshop_submissions", "nassessments", 0, "workshopid", $workshop->id);
-        workshop_grade_assessments($workshop);
-    }
-
-    return $returnid;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-function workshop_user_complete($course, $user, $mod, $workshop) {
-    if ($submission = workshop_get_student_submission($workshop, $user)) {
-        if ($basedir = workshop_file_area($workshop, $user)) {
-            if ($files = get_directory_list($basedir)) {
-                $countfiles = count($files).' '.get_string('submissions', 'workshop');
-                foreach ($files as $file) {
-                    $countfiles .= "; $file";
-                }
-            }
-        }
-
-        print_simple_box_start();
-
-        echo $submission->description.'<br />';
-
-        if (!empty($countfiles)) {
-            echo $countfiles,'<br />';
-        }
-        
-        workshop_print_feedback($course, $submission);
-
-        print_simple_box_end();
-
-    } else {
-        print_string('notsubmittedyet', 'workshop');
-    }
-}
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_print_feedback($course, $submission) {
-    global $CFG, $RATING;
-
-    if (! $feedbacks = get_records('workshop_assessments', 'submissionid', $submission->id)) {
-        return;
-    }
-
-    $strgrade = get_string('grade');
-    $strnograde = get_string('nograde');
-
-    foreach ($feedbacks as $feedback) {
-        if (! $user = get_record('user', 'id', $feedback->userid)) {
-            /// Weird error but we'll just ignore it and continue with other feedback
-            continue;
-        }
-
-        echo '<table cellspacing="0" class="workshop_feedbackbox">';
-
-        echo '<tr>';
-        echo '<td class="picture left">';
-        print_user_picture($user->id, $course->id, $user->picture);
-        echo '</td>';
-        echo '<td><span class="author">'.fullname($user).'</span>';
-        echo '<span class="time">'.userdate($feedback->timegraded).'</span>';
-        echo '</tr>';
-
-        echo '<tr><td class="left side">&nbsp;</td>';
-        echo '<td class="content">';
-
-        if ($feedback->grade) {
-            echo $strgrade.': '.$feedback->grade;
-        } else {
-            echo $strnograde;
-        }
-
-        echo '<span class="comment">'.format_text($feedback->generalcomment).'</span>';
-        echo '<span class="teachercomment">'.format_text($feedback->teachercomment).'</span>';
-        echo '</td></tr></table>';
-
-    }
-}
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////
-function workshop_user_outline($course, $user, $mod, $workshop) {
-    if ($submissions = workshop_get_user_submissions($workshop, $user)) {
-        $result->info = count($submissions)." ".get_string("submissions", "workshop");
-        // workshop_get_user_submissions returns the newest one first
-        foreach ($submissions as $submission) {
-            $result->time = $submission->timecreated;
-            break;
-            }
-        return $result;
-    }
-    return NULL;
-}
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_participants($workshopid) {      
-//Returns the users with data in one workshop
-//(users with records in workshop_submissions, workshop_assessments and workshop_comments, students)
-
-    global $CFG;
-
-    //Get students from workshop_submissions
-    $st_submissions = get_records_sql("SELECT DISTINCT u.id, u.id
-                                       FROM {$CFG->prefix}user u,
-                                            {$CFG->prefix}workshop_submissions s
-                                       WHERE s.workshopid = '$workshopid' and
-                                             u.id = s.userid");
-    //Get students from workshop_assessments
-    $st_assessments = get_records_sql("SELECT DISTINCT u.id, u.id
-                                 FROM {$CFG->prefix}user u,
-                                      {$CFG->prefix}workshop_assessments a
-                                 WHERE a.workshopid = '$workshopid' and
-                                       u.id = a.userid");
-
-    //Get students from workshop_comments
-    $st_comments = get_records_sql("SELECT DISTINCT u.id, u.id
-                                   FROM {$CFG->prefix}user u,
-                                        {$CFG->prefix}workshop_comments c
-                                   WHERE c.workshopid = '$workshopid' and
-                                         u.id = c.userid");
-
-    //Add st_assessments to st_submissions
-    if ($st_assessments) {
-        foreach ($st_assessments as $st_assessment) {
-            $st_submissions[$st_assessment->id] = $st_assessment;
-        }
-    }
-    //Add st_comments to st_submissions
-    if ($st_comments) {
-        foreach ($st_comments as $st_comment) {
-            $st_submissions[$st_comment->id] = $st_comment;
-        }
-    }
-    //Return st_submissions array (it contains an array of unique users)
-    return ($st_submissions);
-}
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_recent_mod_activity(&$activities, &$index, $sincetime, $courseid, 
-                                           $workshop="0", $user="", $groupid="") {
-    // Returns all workshop posts since a given time.  If workshop is specified then
-    // this restricts the results
-
-    global $CFG;
-
-    if ($workshop) {
-        $workshopselect = " AND cm.id = '$workshop'";
-    } else {
-        $workshopselect = "";
-    }
-
-    if ($user) {
-        $userselect = " AND u.id = '$user'";
-    } else {
-        $userselect = "";
-    }
-
-    $posts = get_records_sql("SELECT s.*, u.firstname, u.lastname,
-            u.picture, cm.instance, w.name, cm.section, cm.groupmode,
-            cm.course, cm.groupingid, cm.groupmembersonly
-            FROM {$CFG->prefix}workshop_submissions s,
-            {$CFG->prefix}user u,
-            {$CFG->prefix}course_modules cm,
-            {$CFG->prefix}workshop w
-            WHERE s.timecreated  > '$sincetime' $workshopselect
-            AND s.userid = u.id $userselect
-            AND w.course = '$courseid' 
-            AND cm.instance = w.id
-            AND cm.course = w.course
-            AND s.workshopid = w.id
-            ORDER BY s.id");
-
-
-    if (empty($posts)) {
-        return;
-    }
-
-    foreach ($posts as $post) {
-        if ((empty($groupid) || groups_is_member($groupid, $post->userid)) && groups_course_module_visible($post)) {
-
-            $tmpactivity = new Object;
-
-            $tmpactivity->type = "workshop";
-            $tmpactivity->defaultindex = $index;
-            $tmpactivity->instance = $post->instance;
-            $tmpactivity->name = $post->name;
-            $tmpactivity->section = $post->section;
-
-            $tmpactivity->content->id = $post->id;
-            $tmpactivity->content->title = $post->title;
-
-            $tmpactivity->user->userid = $post->userid;
-            $tmpactivity->user->fullname = fullname($post);
-            $tmpactivity->user->picture = $post->picture;
-
-            $tmpactivity->timestamp = $post->timecreated;
-            $activities[] = $tmpactivity;
-
-            $index++;
-        }
-    }
-
-    return;
-}
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_print_recent_mod_activity($activity, $course, $detail=false) {
-
-    global $CFG;
-
-    echo '<table border="0" cellpadding="3" cellspacing="0">';
-
-    if (!empty($activity->content->parent)) {
-        $openformat = "<font size=\"2\"><i>";
-        $closeformat = "</i></font>";
-    } else {
-        $openformat = "<b>";
-        $closeformat = "</b>";
-    }
-
-    echo "<tr><td class=\"workshoppostpicture\" width=\"35\" valign=\"top\">";
-    print_user_picture($activity->user->userid, $course, $activity->user->picture);
-    echo "</td><td>$openformat";
-
-    if ($detail) {
-        echo "<img src=\"$CFG->modpixpath/$activity->type/icon.gif\" ".
-            "class=\"icon\" alt=\"".strip_tags(format_string($activity->name,true))."\" />  ";
-    }
-    echo "<a href=\"$CFG->wwwroot/mod/workshop/view.php?" 
-        . "#" . $activity->content->id . "\">".$activity->content->title;
-
-    echo "</a>$closeformat";
-
-    echo "<br /><font size=\"2\">";
-    echo "<a href=\"$CFG->wwwroot/user/view.php?id=" . $activity->user->userid . "&amp;course=" . "$course\">"
-        . $activity->user->fullname . "</a>";
-    echo " - " . userdate($activity->timestamp) . "</font></td></tr>";
-    echo "</table>";
-
-    return;
-
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-// Non-standard workshop functions
-///////////////////////////////////////////////////////////////////////////////////////////////
-function workshop_compare_assessments($workshop, $assessment1, $assessment2) {
-    global $WORKSHOP_ASSESSMENT_COMPS, $WORKSHOP_EWEIGHTS;
-    // first get the assignment elements for maxscores...
-    $elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC");
-    foreach ($elementsraw as $element) {
-        $maxscore[] = $element->maxscore;   // to renumber index 0,1,2...
-        $weight[] = $WORKSHOP_EWEIGHTS[$element->weight];   // get real value and renumber index 0,1,2...
-    }
-
-    $grades = array();
-    for ($i = 0; $i < 2; $i++) {
-        if ($i) {
-            $rawgrades = get_records("workshop_grades", "assessmentid", $assessment1->id, "elementno ASC");
-        } else {
-            $rawgrades = get_records("workshop_grades", "assessmentid", $assessment2->id, "elementno ASC");
-        }
-        if ($rawgrades) {
-            foreach ($rawgrades as $grade) {
-                $grades[$i][] = $grade->grade;
-            }
-        }
-    }
-    $sumdiffs = 0;
-    $sumweights = 0;
-    switch ($workshop->gradingstrategy) {
-        case 1 : // accumulative grading and...
-        case 4 : // ...rubic grading
-            for ($i=0; $i < $workshop->nelements; $i++) {
-                $diff = ($grades[0][$i] - $grades[1][$i]) * $weight[$i] / $maxscore[$i];
-                $sumdiffs += $diff * $diff; // use squared distances
-                $sumweights += $weight[$i];
-                }
-            break;
-        case 2 :  // error banded grading
-            // ignore maxscores here, the grades are either 0 or 1,
-            for ($i=0; $i < $workshop->nelements; $i++) {
-                $diff = ($grades[0][$i] - $grades[1][$i]) * $weight[$i];
-                $sumdiffs += $diff * $diff; // use squared distances
-                $sumweights += $weight[$i];
-                }
-            break;
-        case 3 : // criterion grading
-            // here we only need to look at the difference between the "zero" grade elements
-            $diff = ($grades[0][0] - $grades[1][0]) / (count($elementsraw) - 1);
-            $sumdiffs = $diff * $diff;
-            $sumweights = 1;
-            break;
-    }            
-    // convert to a sensible grade (always out of 100)
-    $COMP = (object)$WORKSHOP_ASSESSMENT_COMPS[$workshop->assessmentcomps];
-    $factor = $COMP->value;
-    $gradinggrade = (($factor - ($sumdiffs / $sumweights)) / $factor) * 100;
-    if ($gradinggrade < 0) {
-        $gradinggrade = 0;
-    }
-    return $gradinggrade;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_count_assessments($submission) {
-    // Return the (real) assessments for this submission, 
-    $timenow = time();
-   return count_records_select("workshop_assessments", 
-           "submissionid = $submission->id AND timecreated < $timenow");
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_count_ungraded_assessments($workshop) {
-    // function returns the number of ungraded assessments by students
-    global $CFG;
-    
-    $timenow = time();
-    $n = 0;
-    // get all the cold assessments that have not been graded
-    if ($assessments = get_records_select("workshop_assessments", "workshopid = $workshop->id AND 
-            (timecreated + $CFG->maxeditingtime) < $timenow AND timegraded = 0")) {
-        foreach ($assessments as $assessment) {
-            if (workshop_is_student($workshop, $assessment->userid)) {
-                $n++;
-            }
-        }
-    }
-    return $n;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_file_area($workshop, $submission) {
-    return make_upload_directory( workshop_file_area_name($workshop, $submission) );
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_file_area_name($workshop, $submission) {
-//  Creates a directory file name, suitable for make_upload_directory()
-    global $CFG;
-
-    return "$workshop->course/$CFG->moddata/workshop/$submission->id";
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_agree_logs($course, $timestart) {
-    // get the "agree" entries for this user (the assessment owner) and add the first and last names 
-    // the last two probably wont be used...
-    global $CFG, $USER;
-    if (empty($USER->id)) {
-        return false;
-    }
-    
-    $timethen = time() - $CFG->maxeditingtime;
-    return get_records_sql("SELECT l.time, l.url, u.firstname, u.lastname, a.workshopid, a.userid, e.name
-                             FROM {$CFG->prefix}log l,
-                                {$CFG->prefix}workshop e, 
-                                {$CFG->prefix}workshop_submissions s, 
-                                {$CFG->prefix}workshop_assessments a, 
-                                {$CFG->prefix}user u
-                            WHERE l.time > $timestart AND l.time < $timethen 
-                                AND l.course = $course->id AND l.module = 'workshop' AND l.action = 'agree'
-                                AND a.id = l.info AND s.id = a.submissionid AND a.userid = $USER->id
-                                AND u.id = s.userid AND e.id = a.workshopid");
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_assess_logs($course, $timestart) {
-    // get the "assess" entries for this user and add the first and last names...
-    global $CFG, $USER;
-    if (empty($USER->id)) {
-        return false;
-    }
-    
-    $timethen = time() - $CFG->maxeditingtime;
-    return get_records_sql("SELECT l.time, l.url, u.firstname, u.lastname, a.workshopid, a.userid, e.name
-                             FROM {$CFG->prefix}log l,
-                                {$CFG->prefix}workshop e, 
-                                {$CFG->prefix}workshop_submissions s, 
-                                {$CFG->prefix}workshop_assessments a, 
-                                {$CFG->prefix}user u
-                            WHERE l.time > $timestart AND l.time < $timethen 
-                                AND l.course = $course->id AND l.module = 'workshop' AND l.action = 'assess'
-                                AND a.id = l.info AND s.id = a.submissionid AND s.userid = $USER->id
-                                AND u.id = a.userid AND e.id = a.workshopid");
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_assessments($submission, $all = '', $order = '') {
-    // Return assessments for this submission ordered oldest first, newest last
-    // new assessments made within the editing time are NOT returned unless they
-    // belong to the user or the second argument is set to ALL
-    global $CFG, $USER;
-
-    $timenow = time();
-    if (!$order) {
-        $order = "timecreated DESC";
-    }
-    if ($all != 'ALL') {
-        return get_records_select("workshop_assessments", "(submissionid = $submission->id) AND 
-            ((timecreated < $timenow - $CFG->maxeditingtime) or 
-                ((timecreated < $timenow) AND (userid = $USER->id)))", $order);
-    } else {
-        return get_records_select("workshop_assessments", "submissionid = $submission->id AND 
-            (timecreated < $timenow)", $order);
-    }
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_comment_logs($course, $timestart) {
-    // get the "comment" entries for this user and add the first and last names (which may not be used)...
-    global $CFG, $USER;
-    if (empty($USER->id)) {
-        return false;
-    }
-    
-    $timethen = time() - $CFG->maxeditingtime;
-    return get_records_sql("SELECT l.time, l.url, u.firstname, u.lastname, a.workshopid, e.name
-                             FROM {$CFG->prefix}log l,
-                                {$CFG->prefix}workshop e, 
-                                {$CFG->prefix}workshop_submissions s, 
-                                {$CFG->prefix}workshop_assessments a, 
-                                {$CFG->prefix}workshop_comments c, 
-                                {$CFG->prefix}user u
-                            WHERE l.time > $timestart AND l.time < $timethen 
-                                AND l.course = $course->id AND l.module = 'workshop' AND l.action = 'comment'
-                                AND c.id = l.info AND c.userid != $USER->id AND a.id = c.assessmentid
-                                AND s.id = a.submissionid AND (s.userid = $USER->id OR a.userid = $USER->id)
-                                AND u.id = a.userid AND e.id = a.workshopid");
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_grade_logs($course, $timestart) {
-    // get the "grade" entries for this user and add the first and last names (of submission owner, 
-    // better to get name of teacher...
-    // ...but not available in assessment record...)
-    global $CFG, $USER;
-    if (empty($USER->id)) {
-        return false;
-    }
-    
-    $timethen = time() - $CFG->maxeditingtime;
-    return get_records_sql("SELECT l.time, l.url, u.firstname, u.lastname, a.workshopid, e.name
-                             FROM {$CFG->prefix}log l,
-                                {$CFG->prefix}workshop e, 
-                                {$CFG->prefix}workshop_submissions s, 
-                                {$CFG->prefix}workshop_assessments a, 
-                                {$CFG->prefix}user u
-                            WHERE l.time > $timestart AND l.time < $timethen 
-                                AND l.course = $course->id AND l.module = 'workshop'    AND l.action = 'grade'
-                                AND a.id = l.info AND s.id = a.submissionid AND a.userid = $USER->id
-                                AND u.id = s.userid AND e.id = a.workshopid");
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_student_submission($workshop, $user) {
-// Return a submission for a particular user
-    global $CFG;
-
-    $submission = get_record("workshop_submissions", "workshopid", $workshop->id, "userid", $user->id);
-    if (!empty($submission->timecreated)) {
-        return $submission;
-    }
-    return NULL;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_student_submissions($workshop, $order = "title") {
-// Return all  ENROLLED student submissions
-    global $CFG;
-    
-    if ($order == "title") {
-        $order = "s.title";
-        }
-    if ($order == "name") {
-        $order = "a.lastname, a.firstname";
-        }
-    if ($order == "time") {
-        $order = "s.timecreated ASC";
-    }
-
-    if (!$students = workshop_get_students($workshop)) {
-        return false;
-    }
-    $list = "(";
-    foreach ($students as $student) {
-        $list .= "$student->id,";
-    }
-    $list = rtrim($list, ',').")";
-
-    return get_records_sql("SELECT s.* FROM {$CFG->prefix}workshop_submissions s, {$CFG->prefix}user a 
-                            WHERE s.userid IN $list
-                              AND s.workshopid = $workshop->id
-                              AND s.timecreated > 0
-                              AND s.userid = a.id
-                            ORDER BY $order");
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_submit_logs($course, $timestart) {
-    // get the "submit" entries and add the first and last names...
-    global $CFG, $USER;
-    
-    $timethen = time() - $CFG->maxeditingtime;
-    return get_records_sql("SELECT l.time, l.url, u.firstname, u.lastname, l.info as workshopid, e.name
-                             FROM {$CFG->prefix}log l,
-                                {$CFG->prefix}workshop e, 
-                                {$CFG->prefix}user u
-                            WHERE l.time > $timestart AND l.time < $timethen 
-                                AND l.course = $course->id AND l.module = 'workshop'
-                                AND l.action = 'submit'
-                                AND e.id = l.info 
-                                AND u.id = l.userid");
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_unmailed_assessments($cutofftime) {
-    /// Return list of assessments that have not been mailed out
-    global $CFG;
-    return get_records_sql("SELECT a.*, g.course, g.name
-                              FROM {$CFG->prefix}workshop_assessments a, {$CFG->prefix}workshop g
-                             WHERE a.mailed = 0 
-                               AND a.timecreated < $cutofftime 
-                               AND g.id = a.workshopid
-                               AND g.releasegrades < $cutofftime");
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_unmailed_comments($cutofftime) {
-    /// Return list of comments that have not been mailed out
-    global $CFG;
-    return get_records_sql("SELECT c.*, g.course, g.name
-                              FROM {$CFG->prefix}workshop_comments c, {$CFG->prefix}workshop g
-                             WHERE c.mailed = 0 
-                               AND c.timecreated < $cutofftime 
-                               AND g.id = c.workshopid");
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_unmailed_graded_assessments($cutofftime) {
-    /// Return list of graded assessments that have not been mailed out
-    global $CFG;
-    return get_records_sql("SELECT a.*, g.course, g.name
-                              FROM {$CFG->prefix}workshop_assessments a, {$CFG->prefix}workshop g
-                             WHERE a.mailed = 0 
-                               AND a.timegraded < $cutofftime 
-                               AND a.timegraded > 0
-                               AND g.id = a.workshopid");
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_unmailed_resubmissions($cutofftime) {
-    /// Return list of assessments of resubmissions that have not been mailed out
-    global $CFG;
-    return get_records_sql("SELECT a.*, w.course, w.name
-                              FROM {$CFG->prefix}workshop_assessments a, {$CFG->prefix}workshop w
-                             WHERE a.mailed = 0 
-                               AND a.resubmission = 1
-                               AND w.id = a.workshopid");
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_user_assessments($workshop, $user) {
-// Return all the  user's assessments, newest first, oldest last (hot, warm and cold ones)
-    return get_records_select("workshop_assessments", "workshopid = $workshop->id AND userid = $user->id", 
-                "timecreated DESC");
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_user_submissions($workshop, $user) {
-    // return real submissions of user newest first, oldest last. Ignores the dummy submissions
-    // which get created to hold the final grades for users that make no submissions
-    return get_records_select("workshop_submissions", "workshopid = $workshop->id AND 
-        userid = $user->id AND timecreated > 0", "timecreated DESC" );
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_grade_assessments($workshop, $verbose=false) {
-    global $WORKSHOP_EWEIGHTS;
-    
-    // timeout after 10 minutes
-    @set_time_limit(600);
-
-    $timenow = time();
-    
-    // set minumim value for the variance (of the elements)
-    $minvar = 0.05;
-
-    // check when the standard deviations were calculated
-    $oldtotalassessments = get_field("workshop_elements", "totalassessments", "workshopid", $workshop->id, 
-                "elementno", 0);
-    $totalassessments = count_records("workshop_assessments", "workshopid", $workshop->id);
-    // calculate the std. devs every 10 assessments for low numbers of assessments, thereafter every 100 new assessments
-    if ((($totalassessments < 100) and (($totalassessments - $oldtotalassessments) > 10)) or 
-            (($totalassessments - $oldtotalassessments) > 100)) {
-        // calculate the means for each submission using just the "good" assessments 
-        if ($submissions = get_records("workshop_submissions", "workshopid", $workshop->id)) {
-            foreach ($submissions as $submission) {
-                $nassessments[$submission->id] = 0;
-                if ($assessments = workshop_get_assessments($submission)) {
-                    foreach ($assessments as $assessment) {
-                        // test if assessment is "good", a teacher assessment always "good", but may be weighted out 
-                        if (workshop_is_teacher($workshop, $assessment->userid)) {
-                            if (!$workshop->teacherweight) {
-                                // drop teacher's assessment as weight is zero
-                                continue;
-                            }
-                        } elseif ((!$assessment->gradinggrade and $assessment->timegraded) or 
-                                ($workshop->agreeassessments and !$assessment->timeagreed)) {
-                            // it's a duff assessment, or it's not been agreed
-                            continue;
-                        }
-                        if (isset($num[$submission->id])) {
-                            if (workshop_is_teacher($workshop, $assessment->userid)) {
-                                $num[$submission->id] += $workshop->teacherweight; // weight teacher's assessment
-                            } else {
-                                $num[$submission->id]++; // number of assessments
-                            }
-                            $nassessments[$submission->id]++;
-                        } else {
-                            if (workshop_is_teacher($workshop, $assessment->userid)) {
-                                $num[$submission->id] = $workshop->teacherweight;
-                            } else {
-                                $num[$submission->id] = 1;
-                            }
-                            $nassessments[$submission->id] = 1;
-                        }
-                        for ($i = 0; $i < $workshop->nelements; $i++) {
-                            $grade =  get_field("workshop_grades", "grade",
-                                    "assessmentid", $assessment->id, "elementno", $i);
-                            if (isset($sum[$submission->id][$i])) {
-                                if (workshop_is_teacher($workshop, $assessment->userid)) {
-                                    $sum[$submission->id][$i] += $workshop->teacherweight * $grade; // teacher's grade
-                                } else {
-                                    $sum[$submission->id][$i] += $grade; // student's grade
-                                }
-                            } else { 
-                                if (workshop_is_teacher($workshop, $assessment->userid)) {
-                                    $sum[$submission->id][$i] = $workshop->teacherweight * $grade; // teacher's grade
-                                } else {
-                                    $sum[$submission->id][$i] = $grade; // students's grade
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-
-            if (!isset($num)) { 
-                // no assessments yet
-                return;
-            }
-            reset($num);
-            // calculate the means for each submission
-            $total = 0;
-            foreach ($num as $submissionid => $n) {
-                if ($n) { // stop division by zero
-                    for ($i = 0; $i < $workshop->nelements; $i++) {
-                        $mean[$submissionid][$i] = $sum[$submissionid][$i] / $n;
-                        // echo "Submission: $submissionid; Element: $i; Mean: {$mean[$submissionid][$i]}<br />\n";
-                    }
-                    $total += $n; // weighted total
-                }
-            }
-            if ($verbose) {
-                echo "<p style=\"text-align:center\">".get_string("numberofsubmissions", "workshop", count($num))."<br />\n";
-                echo get_string("numberofassessmentsweighted", "workshop", $total)."</p>\n";
-            }
-
-            // now get an estimate of the standard deviation of each element in the assessment
-            // this is just a rough measure, all assessments are included and teacher's assesments are not weighted
-            $n = 0;
-            for ($i = 0; $i < $workshop->nelements; $i++) {
-                $var[$i] = 0;
-            }
-            foreach ($submissions as $submission) {
-                if ($assessments = workshop_get_assessments($submission)) {
-                    foreach ($assessments as $assessment) {
-                        $n++;
-                        for ($i = 0; $i < $workshop->nelements; $i++) {
-                            $grade =  get_field("workshop_grades", "grade",
-                                    "assessmentid", $assessment->id, "elementno", $i);
-                            $temp = $mean[$submission->id][$i] - $grade;
-                            $var[$i] += $temp * $temp;
-                        }
-                    }
-                }
-            }
-            for ($i = 0; $i < $workshop->nelements; $i++) {
-                if ($n > 1) {
-                    $sd[$i] = sqrt($var[$i] / ($n - 1));
-                } else {
-                    $sd[$i] = 0;
-                }
-                set_field("workshop_elements", "stddev", $sd[$i], "workshopid", $workshop->id, "elementno", $i);
-                set_field("workshop_elements", "totalassessments", $totalassessments, "workshopid", $workshop->id,
-                        "elementno", $i);
-                if ($verbose) {
-                    echo get_string("standarddeviationofelement", "workshop", $i+1)." $sd[$i]<br />";
-                    if ($sd[$i] <= $minvar) {
-                        print_string("standarddeviationnote", "workshop")."<br />\n";
-                    }
-                }
-            }
-        } 
-    }
-
-    // this section looks at each submission if the number of assessments made has increased it recalculates the
-    // grading grades for those assessments
-    // first get the assignment elements for the weights and the stddevs...
-    if ($elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC")) {
-        foreach ($elementsraw as $element) {
-            $weight[] = $element->weight;   // to renumber index 0,1,2...
-            $sd[] = $element->stddev;   // to renumber index 0,1,2...
-        }
-    }
-
-    unset($num); // may have been used in calculating stddevs
-    unset($sum); // ditto
-    if ($submissions = get_records("workshop_submissions", "workshopid", $workshop->id)) {
-        foreach ($submissions as $submission) {
-            // see if the number of assessments has changed
-            $nassessments = workshop_count_assessments($submission);
-            if ($submission->nassessments <> $nassessments) {
-                // ...if there are three or more assessments calculate the variance of each assessment.
-                // Use the variance to find the "best" assessment. (When there is only one or two assessments they 
-                // are not altered by this routine.)
-                if ($verbose) {
-                    echo "Processing submission $submission->id ($nassessments asessments)...\n"; 
-                }
-                if ($nassessments > 2) {
-                    $num = 0; // weighted number of assessments
-                    for ($i = 0; $i < $workshop->nelements; $i++) {
-                        $sum[$i] = 0; // weighted sum of grades
-                    }
-                    if ($assessments = workshop_get_assessments($submission)) {
-                        // first calculate the mean grades for each element
-                        foreach ($assessments as $assessment) {
-                            // test if assessment is "good", a teacher assessment always "good", but may be weighted out 
-                            if (workshop_is_teacher($workshop, $assessment->userid)) {
-                                if (!$workshop->teacherweight) {
-                                    // drop teacher's assessment as weight is zero
-                                    continue;
-                                }
-                            } else if ((!$assessment->gradinggrade and $assessment->timegraded) or 
-                                    ($workshop->agreeassessments and !$assessment->timeagreed)) {
-                                // it's a duff assessment, or it's not been agreed
-                                continue;
-                            }
-                            if (workshop_is_teacher($workshop, $assessment->userid)) {
-                                $num += $workshop->teacherweight; // weight teacher's assessment
-                            } else {
-                                $num++; // student assessment just add one
-                            }
-                            for ($i = 0; $i < $workshop->nelements; $i++) {
-                                $grade =  get_field("workshop_grades", "grade",
-                                        "assessmentid", $assessment->id, "elementno", $i);
-                                if (workshop_is_teacher($workshop, $assessment->userid)) {
-                                    $sum[$i] += $workshop->teacherweight * $grade; // teacher's grade
-                                } else {
-                                    $sum[$i] += $grade; // student's grade
-                                }
-                            }
-                        }
-                        if ($num) { // could all the assessments be duff? 
-                            for ($i = 0; $i < $workshop->nelements; $i++) {
-                                $mean[$i] = $sum[$i] / $num;
-                                if ($verbose) echo "Submission: $submission->id; Element: $i; Mean: {$mean[$i]}\n";
-                            }
-                        } else {
-                            continue; // move to the next submission
-                        }
-                        // run through the assessments again to see which is the "best" one (the one
-                        // closest to the mean)
-                        $lowest = 10e9;
-                        foreach ($assessments as $assessment) {
-                            if ($workshop->agreeassessments and !$assessment->timeagreed) {
-                                // ignore assessments that have not been agreed
-                                continue;
-                            }
-                            $var = 0;
-                            for ($i = 0; $i < $workshop->nelements; $i++) {
-                                $grade =  get_field("workshop_grades", "grade",
-                                        "assessmentid", $assessment->id, "elementno", $i);
-                                if ($sd[$i] > $minvar) {
-                                    $temp = ($mean[$i] - $grade) * 
-                                        $WORKSHOP_EWEIGHTS[$weight[$i]] / $sd[$i];
-                                } else {
-                                    $temp = 0;
-                                }
-                                $var += $temp * $temp;
-                            }
-                            // find the "best" assessment of this submission
-                            if ($lowest > $var) {
-                                $lowest = $var;
-                                $bestassessmentid = $assessment->id;
-                            }
-                        }
-
-                        if (!$best = get_record("workshop_assessments", "id", $bestassessmentid)) {
-                            notify("Workshop grade assessments: cannot find best assessment");
-                            continue;
-                        }
-                        if ($verbose) {
-                            echo "Best assessment is $bestassessmentid;\n";
-                        }
-                        foreach ($assessments as $assessment) {
-                            // don't overwrite teacher's grade
-                            if ($assessment->teachergraded) {
-                                continue;
-                            }
-                            if ($assessment->id == $bestassessmentid) { 
-                                // it's the best one, set the grading grade to the maximum 
-                                set_field("workshop_assessments", "gradinggrade", 100, "id", $assessment->id);
-                                set_field("workshop_assessments", "timegraded", $timenow, "id", $assessment->id);
-                            } else {
-                                // it's one of the pack, compare with the best...
-                                $gradinggrade = workshop_compare_assessments($workshop, $best, $assessment);
-                                // ...and save the grade for the assessment 
-                                set_field("workshop_assessments", "gradinggrade", $gradinggrade, "id", $assessment->id);
-                                set_field("workshop_assessments", "timegraded", $timenow, "id", $assessment->id);
-                            }
-                        }
-                    }
-                } else {
-                    // there are less than 3 assessments for this submission
-                    if ($assessments = workshop_get_assessments($submission)) {
-                        foreach ($assessments as $assessment) {
-                            if (!$assessment->timegraded and !$assessment->teachergraded) {
-                                // set the grading grade to the maximum and say it's been graded 
-                                set_field("workshop_assessments", "gradinggrade", 100, "id", $assessment->id);
-                                set_field("workshop_assessments", "timegraded", $timenow, "id", $assessment->id);
-                            }
-                        }
-                    }
-                }       
-                // set the number of assessments for this submission
-                set_field("workshop_submissions", "nassessments", $nassessments, "id", $submission->id);    
-            }
-        }
-    }
-    return;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_gradinggrade($workshop, $student) {
-    // returns the current (external) grading grade of the based on their (cold) assessments
-    // (needed as it's called by grade)
-    
-    $gradinggrade = 0;
-    if ($assessments = workshop_get_user_assessments($workshop, $student)) {
-        $n = 0;
-        foreach ($assessments as $assessment) {
-            $gradinggrade += $assessment->gradinggrade;
-            $n++;
-        }
-        if ($n < ($workshop->ntassessments + $workshop->nsassessments)) { // the minimum students should do
-            $n = $workshop->ntassessments + $workshop->nsassessments;
-        }
-        $gradinggrade = $gradinggrade / $n;
-    }
-    return number_format($gradinggrade * $workshop->gradinggrade / 100, 1);
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_submission_grade($workshop, $submission) {
-    // returns the current (external) grade of the submission based on the "good" (cold) assessments
-    // (needed as it's called by grade)
-    
-    $grade = 0;
-    if ($assessments = workshop_get_assessments($submission)) {
-        $n = 0;
-        foreach ($assessments as $assessment) {
-            if ($workshop->agreeassessments and !$assessment->timeagreed) {
-                // ignore assessments which have not been agreed
-                continue;
-            }
-            if ($assessment->gradinggrade or !$assessment->timegraded) { 
-                // a good assessment (or one that has not been graded yet)
-                if (workshop_is_teacher($workshop, $assessment->userid)) {
-                    $timenow = time();
-                    if ($timenow > $workshop->releasegrades) {
-                        // teacher's grade is available
-                        $grade += $workshop->teacherweight * $assessment->grade;
-                        $n += $workshop->teacherweight;
-                    }
-                } else {
-                    $grade += $assessment->grade;
-                    $n++;
-                }
-            }
-        }
-        if ($n) { // stop division by zero
-            $grade = $grade / $n;
-        }
-    }
-    return number_format($grade * $workshop->grade / 100, 1);
-}
-
-
-/////////////////////////////////////////////////////////////////////////////
-function workshop_fullname($userid, $courseid) {
-    global $CFG;
-    if (!$user = get_record('user', 'id', $userid)) {
-        return '';
-    }
-    return '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$courseid.'">'.
-        fullname($user).'</a>';
-}
-
-function workshop_get_view_actions() {
-    return array('view','view all');
-}
-
-function workshop_get_post_actions() {
-    return array('agree','assess','comment','grade','newattachment','removeattachments','resubmit','submit');
-}
-
-?>
diff --git a/mod/workshop/locallib.php b/mod/workshop/locallib.php
deleted file mode 100644 (file)
index 7ad7ff1..0000000
+++ /dev/null
@@ -1,3092 +0,0 @@
-<?php  // $Id$
-
-/// Library of extra functions and module workshop 
-
-$WORKSHOP_TYPE = array (0 => get_string('notgraded', 'workshop'),
-                          1 => get_string('accumulative', 'workshop'),
-                          2 => get_string('errorbanded', 'workshop'),
-                          3 => get_string('criterion', 'workshop'),
-                          4 => get_string('rubric', 'workshop') );
-
-$WORKSHOP_SHOWGRADES = array (0 => get_string('dontshowgrades', 'workshop'),
-                          1 => get_string('showgrades', 'workshop') );
-
-$WORKSHOP_SCALES = array( 
-                    0 => array( 'name' => get_string('scaleyes', 'workshop'), 'type' => 'radio', 
-                        'size' => 2, 'start' => get_string('yes'), 'end' => get_string('no')),
-                    1 => array( 'name' => get_string('scalepresent', 'workshop'), 'type' => 'radio', 
-                        'size' => 2, 'start' => get_string('present', 'workshop'), 
-                        'end' => get_string('absent', 'workshop')),
-                    2 => array( 'name' => get_string('scalecorrect', 'workshop'), 'type' => 'radio', 
-                        'size' => 2, 'start' => get_string('correct', 'workshop'), 
-                        'end' => get_string('incorrect', 'workshop')), 
-                    3 => array( 'name' => get_string('scalegood3', 'workshop'), 'type' => 'radio', 
-                        'size' => 3, 'start' => get_string('good', 'workshop'), 
-                        'end' => get_string('poor', 'workshop')), 
-                    4 => array( 'name' => get_string('scaleexcellent4', 'workshop'), 'type' => 'radio', 
-                        'size' => 4, 'start' => get_string('excellent', 'workshop'), 
-                        'end' => get_string('verypoor', 'workshop')),
-                    5 => array( 'name' => get_string('scaleexcellent5', 'workshop'), 'type' => 'radio', 
-                        'size' => 5, 'start' => get_string('excellent', 'workshop'), 
-                        'end' => get_string('verypoor', 'workshop')),
-                    6 => array( 'name' => get_string('scaleexcellent7', 'workshop'), 'type' => 'radio', 
-                        'size' => 7, 'start' => get_string('excellent', 'workshop'), 
-                        'end' => get_string('verypoor', 'workshop')),
-                    7 => array( 'name' => get_string('scale10', 'workshop'), 'type' => 'selection', 
-                        'size' => 10),
-                    8 => array( 'name' => get_string('scale20', 'workshop'), 'type' => 'selection', 
-                            'size' => 20),
-                    9 => array( 'name' => get_string('scale100', 'workshop'), 'type' => 'selection', 
-                            'size' => 100)); 
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-
-/*** Functions for the workshop module ******
-
-workshop_choose_from_menu ($options, $name, $selected="", $nothing="choose", $script="", 
-    $nothingvalue="0", $return=false) {
-
-workshop_compare_assessments($workshop, $assessment1, $assessment2) { ---> in lib.php
-workshop_count_all_submissions_for_assessment($workshop, $user) {
-workshop_count_assessments($submission) { ---> in lib.php
-workshop_count_comments($assessment) {
-workshop_count_peer_assessments($workshop, $user) {
-workshop_count_self_assessments($workshop, $user) {
-workshop_count_student_submissions($workshop) {
-workshop_count_student_submissions_for_assessment($workshop, $user) {
-workshop_count_teacher_assessments($courseid, $submission) {
-workshop_count_teacher_assessments_by_user($workshop, $user) {
-workshop_count_teacher_submissions($workshop) {
-workshop_count_teacher_submissions_for_assessment($workshop, $user) {
-workshop_count_ungraded_assessments($workshop) { --->in lib.php
-workshop_count_ungraded_assessments_student($workshop) {
-workshop_count_ungraded_assessments_teacher($workshop) {
-workshop_count_user_assessments($worshop, $user, $type = "all") { $type is all, student or teacher
-workshop_count_user_submissions($workshop, $user) {
-
-workshop_delete_submitted_files($workshop, $submission) {
-workshop_delete_user_files($workshop, $user, $exception) {
-
-workshop_file_area($workshop, $submission) { ---> in lib.php
-workshop_file_area_name($workshop, $submission) { ---> in lib.php
-
-workshop_get_all_teacher_assessments($workshop) {
-workshop_get_assessments($submission, $all = '') { ---> in lib.php
-workshop_get_comments($assessment) {
-workshop_get_participants($workshopid) {
-workshop_get_student_assessments($workshop, $user) {
-workshop_get_student_submission($workshop, $user) { ---> in lib.php
-workshop_get_student_submission_assessments($workshop) {
-workshop_get_student_submissions($workshop) { ---> in lib.php
-workshop_get_submission_assessment($submission, $user) {
-workshop_get_teacher_assessments($courseid, $submission) {
-workshop_get_teacher_submission_assessments($workshop) {
-workshop_get_teacher_submissions($workshop) {
-workshop_get_ungraded_assessments($workshop) {
-workshop_get_unmailed_assessments($cutofftime) {
-workshop_get_unmailed_marked_assessments($cutofftime) {
-workshop_get_user_assessments($workshop, $user) { ---> in lib.php
-workshop_get_user_submissions($workshop, $user) { ---> in lib.php
-workshop_get_users_done($workshop) {
-
-workshop_grade_assessments($workshop) { ---> in lib.php
-
-workshop_list_all_submissions($workshop) {
-workshop_list_all_ungraded_assessments($workshop) {
-workshop_list_assessed_submissions($workshop, $user) {
-workshop_list_peer_assessments($workshop, $user) {
-workshop_list_student_submissions($workshop, $user) {
-workshop_list_submissions_for_admin($workshop, $order) {
-workshop_list_teacher_assessments_by_user($workshop, $user) {
-workshop_list_teacher_submissions($workshop) {
-workshop_list_unassessed_student_submissions($workshop, $user) {
-workshop_list_unassessed_teacher_submissions($workshop, $user) {
-workshop_list_ungraded_assessments($workshop, $stype) {
-workshop_list_user_submissions($workshop, $user) {
-
-workshop_calculate_phase($workshop, $style='') {
-
-workshop_print_assessment($workshop, $assessment, $allowchanges, $showcommentlinks, $returnto)
-workshop_print_assessments_by_user_for_admin($workshop, $user) {
-workshop_print_assessments_for_admin($workshop, $submission) {
-workshop_print_assignment_info($cm, $workshop) {
-workshop_print_difference($time) {
-workshop_print_feedback($course, $submission) {
-workshop_print_league_table($workshop) {
-workshop_print_submission_assessments($workshop, $submission, $type) {
-workshop_print_submission_title($workshop, $user) {
-workshop_print_time_to_deadline($time) {
-workshop_print_upload_form($workshop) {
-workshop_print_user_assessments($workshop, $user) {
-
-workshop_submission_grade($submission) { ---> in lib.php
-    
-workshop_test_user_assessments($workshop, $user) {
-***************************************/
-
-
-///////////////////////////////////////////////////////////////////////////////
-function workshop_choose_from_menu ($options, $name, $selected="", $nothing="choose", $script="", 
-        $nothingvalue="0", $return=false) {
-/// Given an array of value, creates a popup menu to be part of a form
-/// $options["value"]["label"]
-    
-    if ($nothing == "choose") {
-        $nothing = get_string("choose")."...";
-    }
-
-    if ($script) {
-        $javascript = "onChange=\"$script\"";
-    } else {
-        $javascript = "";
-    }
-
-    $output = "<select name=\"$name\" $javascript>\n";
-    if ($nothing) {
-        $output .= "   <option value=\"$nothingvalue\"\n";
-        if ($nothingvalue == $selected) {
-            $output .= " selected=\"selected\"";
-        }
-        $output .= ">$nothing</option>\n";
-    }
-    if (!empty($options)) {
-        foreach ($options as $value => $label) {
-            $output .= "   <option value=\"$value\"";
-            if ($value == $selected) {
-                $output .= " selected=\"selected\"";
-            }
-            // stop zero label being replaced by array index value
-            // if ($label) {
-            //    $output .= ">$label</option>\n";
-            // } else {
-            //     $output .= ">$value</option>\n";
-            //  }
-            $output .= ">$label</option>\n";
-            
-        }
-    }
-    $output .= "</select>\n";
-
-    if ($return) {
-        return $output;
-    } else {
-        echo $output;
-    }
-}   
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function workshop_copy_assessment($assessment, $submission, $withfeedback = false) {
-    // adds a copy of the given assessment for the submission specified to the workshop_assessments table. 
-    // The grades and optionally the comments are added to the workshop_grades table. Returns the new
-    // assessment object. The owner of the assessment is not changed.
-    
-    $yearfromnow = time() + 365 * 86400;
-    $newassessment->workshopid = $assessment->workshopid;
-    $newassessment->submissionid = $submission->id;
-    $newassessment->userid = $assessment->userid;
-    $newassessment->timecreated = $yearfromnow;
-    $newassessment->grade = $assessment->grade;
-    if ($withfeedback) {
-        $newassessment->generalcomment = addslashes($assessment->generalcomment);
-        $newassessment->teachercomment = addslashes($assessment->teachercomment);
-    }
-    if (!$newassessment->id = insert_record("workshop_assessments", $newassessment)) {
-        print_error("Copy Assessment: Could not insert workshop assessment!");
-    }
-    
-    if ($grades = get_records("workshop_grades", "assessmentid", $assessment->id)) {
-        foreach ($grades as $grade) {
-            unset($grade->id); // clear id, insert record now seems to believe it!
-            if (!$withfeedback) {
-                $grade->feedback = '';
-            }
-            else {
-                $grade->feedback = addslashes($grade->feedback);
-            }
-            $grade->assessmentid = $newassessment->id;
-            if (!$grade->id = insert_record("workshop_grades", $grade)) {
-                print_error("Copy Assessment: Could not insert workshop grade!");
-            }
-        }
-    }
-    if ($withfeedback) {
-        // remove the slashes from comments as the new assessment record might be used, 
-        // currently this function is only called in upload which does not!
-        $newassessment->generalcomment = stripslashes($assessment->generalcomment);
-        $newassessment->teachercomment = stripslashes($assessment->teachercomment);
-    }
-    return $newassessment;
-}
-
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_count_all_submissions_for_assessment($workshop, $user) {
-    // looks at all submissions and deducts the number which has been assessed by this user
-    $n = 0;
-    if ($submissions = get_records_select("workshop_submissions", "workshopid = $workshop->id AND 
-                timecreated > 0")) {
-        $n =count($submissions);
-        foreach ($submissions as $submission) {
-            $n -= count_records("workshop_assessments", "submissionid", $submission->id, "userid", $user->id);
-            }
-        }
-    return $n;
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_count_comments($assessment) {
-    // Return the number of comments for this assessment provided they are newer than the assessment, 
-   return count_records_select("workshop_comments", "(assessmentid = $assessment->id) AND 
-        timecreated > $assessment->timecreated");
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_count_peer_assessments($workshop, $user) {
-    // returns the number of assessments made by students on user's submissions
-    
-    $n = 0;
-    if ($submissions = workshop_get_user_submissions($workshop, $user)) {
-        foreach ($submissions as $submission) {
-            if ($assessments = workshop_get_assessments($submission)) {
-                foreach ($assessments as $assessment) {
-                    // ignore teacher assessments
-                    if (!workshop_is_teacher($workshop, $assessment->userid)) {
-                        $n++;
-                        }
-                    }
-                }
-            }
-        }
-    return $n;
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_count_self_assessments($workshop, $user) {
-    // returns the number of assessments made by user on their own submissions
-    
-    $n = 0;
-    if ($submissions = workshop_get_user_submissions($workshop, $user)) {
-        foreach ($submissions as $submission) {
-            if ($assessment = get_record_select("workshop_assessments", "userid = $user->id AND 
-                    submissionid = $submission->id")) {
-                $n++;
-                }
-            }
-        }
-    return $n;
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_count_student_submissions($workshop) {
-    global $CFG;
-
-    // make sure it works on the site course
-    $select = "s.course = '$workshop->course' AND";
-    if ($workshop->course == SITEID) {
-        $select = '';
-    }
-    if (!$students = workshop_get_students($workshop)) {
-        return 0;
-    }
-    $list = "(";
-    foreach ($students as $student) {
-        $list .= "$student->id,";
-    }
-    $list = rtrim($list, ',').")";
-
-    return count_records_sql("SELECT count(*) FROM {$CFG->prefix}workshop_submissions s
-                              WHERE $select s.userid IN $list
-                                AND s.workshopid = $workshop->id
-                                AND timecreated > 0");
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_count_student_submissions_for_assessment($workshop, $user) {
-    global $CFG;
-
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        print_error("Course Module ID was incorrect");
-    }
-    if (! $course = get_record("course", "id", $workshop->course)) {
-        print_error("Course is misconfigured");
-        }
-    
-    $timenow = time();
-    if (groupmode($course, $cm) == SEPARATEGROUPS) {
-        $groupid = get_current_group($course->id);
-    } else {
-        $groupid = 0;
-    }
-    
-    $n = 0;
-    if ($submissions = workshop_get_student_submissions($workshop)) {
-        foreach ($submissions as $submission) {
-            // check group membership, if necessary
-            if ($groupid) {
-                // check user's group
-                if (!groups_is_member($groupid, $submission->userid)) {
-                    continue; // skip this user
-                }
-            }
-            // check if submission is cold
-            if (($submission->timecreated + $CFG->maxeditingtime) > $timenow) {
-                continue; // skip this submission
-            }
-            // has any teacher assessed this submission?
-            if (!workshop_count_teacher_assessments($course->id, $submission)) {
-                $n++;
-            }
-        }
-    }
-    return $n;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_count_teacher_assessments($courseid, $submission) {
-// Return count of (cold) teacher assessments of a submission
-    global $CFG;
-    
-    if (!$teachers = workshop_get_teachers($submission->workshopid)) {
-        return 0;
-    }
-    $list = "(";
-    foreach ($teachers as $teacher) {
-        $list .= "$teacher->id,";
-    }
-    $list = rtrim($list, ',').")";
-    $timenow = time();
-    return count_records_sql("SELECT count(*) FROM {$CFG->prefix}workshop_assessments a
-                              WHERE a.userid IN $list
-                                AND a.submissionid = $submission->id
-                                AND $timenow > (a.timecreated + $CFG->maxeditingtime)");
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_count_teacher_assessments_by_user($workshop, $user) {
-    // returns the number of assessments made by teachers on user's submissions
-    
-    $n = 0;
-    if ($submissions = workshop_get_user_submissions($workshop, $user)) {
-        foreach ($submissions as $submission) {
-            if ($assessments = workshop_get_assessments($submission)) {
-                foreach ($assessments as $assessment) {
-                    // count only teacher assessments
-                    if (workshop_is_teacher($workshop, $assessment->userid)) {
-                        $n++;
-                        }
-                    }
-                }
-            }
-        }
-    return $n;
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_count_teacher_submissions($workshop) {
-    global $CFG;
-    if (!$teachers = workshop_get_teachers($workshop)) {
-        return 0;
-    }
-    $list = "(";
-    foreach ($teachers as $teacher) {
-        $list .= "$teacher->id,";
-    }
-    $list = rtrim($list, ',').")";
-    $timenow = time();
-    
-    return count_records_sql("SELECT count(*)
-                              FROM {$CFG->prefix}workshop_submissions s
-                              WHERE s.userid IN $list
-                                AND s.workshopid = $workshop->id");
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_count_teacher_submissions_for_assessment($workshop, $user) {
-
-    $n = 0;
-    if ($submissions = workshop_get_teacher_submissions($workshop)) {
-        $n =count($submissions);
-        foreach ($submissions as $submission) {
-            $n -= count_records("workshop_assessments", "submissionid", $submission->id, "userid", $user->id);
-            }
-        }
-    return $n;
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_count_ungraded_assessments_student($workshop) {
-    // function returns the number of ungraded assessments by students of STUDENT submissions
-    $n = 0;
-    if ($submissions = workshop_get_student_submissions($workshop)) {
-        foreach ($submissions as $submission) {
-            if ($assessments = workshop_get_assessments($submission)) {
-                foreach ($assessments as $assessment) {
-                    if ($assessment->timegraded == 0) {
-                        // ignore teacher assessments
-                        if (!workshop_is_teacher($workshop, $assessment->userid)) {
-                            $n++;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    return $n;
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_count_ungraded_assessments_teacher($workshop) {
-    // function returns the number of ungraded assessments by students of TEACHER submissions
-    global $CFG;
-
-    $timenow = time();
-    $n = 0;
-    if ($submissions = workshop_get_teacher_submissions($workshop)) {
-        foreach ($submissions as $submission) {
-            if ($assessments = workshop_get_assessments($submission)) {
-                foreach ($assessments as $assessment) {
-                    if ($assessment->timegraded == 0) {
-                        // ignore teacher assessments
-                        if (!workshop_is_teacher($workshop, $assessment->userid)) {
-                            // must have created a little time ago
-                            if (($timenow - $assessment->timecreated) > $CFG->maxeditingtime) {
-                                $n++;
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    return $n;
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_count_user_assessments($workshop, $user, $stype = "all") {
-    // returns the number of assessments allocated/made by a user, all of them, or just those 
-    // for the student or teacher submissions. The student's self assessments are included in the count.
-    // The maxeditingtime is NOT taken into account here also, allocated assessments which have not yet
-    // been done are counted as well
-    
-    $n = 0;
-    if ($assessments = workshop_get_user_assessments($workshop, $user)) {
-         foreach ($assessments as $assessment) {
-            switch ($stype) {
-                case "all" :
-                    $n++;
-                    break;
-                case "student" :
-                     $submission = get_record("workshop_submissions", "id", $assessment->submissionid);
-                    if (workshop_is_student($workshop, $submission->userid)) {
-                        $n++;
-                        }
-                    break;
-                case "teacher" :
-                     $submission = get_record("workshop_submissions", "id", $assessment->submissionid);
-                    if (workshop_is_teacher($workshop, $submission->userid)) {
-                        $n++;
-                        }
-                    break;
-                }
-            }
-        }
-    return $n;
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_count_user_assessments_done($workshop, $user) {
-    // returns the number of assessments actually done by a user
-    // the student's self assessments are included in the count
-    // the maxeditingtime is NOT taken into account here 
-    
-    $n = 0;
-    $timenow = time();
-    if ($assessments = workshop_get_user_assessments($workshop, $user)) {
-         foreach ($assessments as $assessment) {
-            if ($assessment->timecreated < $timenow) {
-                $n++;
-                }
-            }
-        }
-    return $n;
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_count_user_submissions($workshop, $user) {
-    // returns the number of (real) submissions make by this user
-    return count_records_select("workshop_submissions", "workshopid = $workshop->id AND 
-        userid = $user->id AND timecreated > 0");
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_delete_submitted_files($workshop, $submission) {
-// Deletes the files in the workshop area for this submission
-
-    if ($basedir = workshop_file_area($workshop, $submission)) {
-        if ($files = get_directory_list($basedir)) {
-            foreach ($files as $file) {
-                if (unlink("$basedir/$file")) {
-                    notify("Existing file '$file' has been deleted!");
-                    }
-                else {
-                    notify("Attempt to delete file $basedir/$file has failed!");
-                    }
-                }
-            }
-        }
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_delete_user_files($workshop, $user, $exception) {
-// Deletes all the user files in the workshop area for a user
-// EXCEPT for any file named $exception
-
-    if (!$submissions = workshop_get_submissions($workshop, $user)) {
-        notify("No submissions!");
-        return;
-        }
-    foreach ($submissions as $submission) {
-        if ($basedir = workshop_file_area($workshop, $submission)) {
-            if ($files = get_directory_list($basedir)) {
-                foreach ($files as $file) {
-                    if ($file != $exception) {
-                        unlink("$basedir/$file");
-                        notify("Existing file '$file' has been deleted!");
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_all_teacher_assessments($workshop) {
-// Return all teacher assessments, ordered by timecreated, oldest first
-    global $CFG;
-    if (!$teachers = workshop_get_teachers($workshop)) {
-        return false;
-    }
-    $list = "(";
-    foreach ($teachers as $teacher) {
-        $list .= "$teacher->id,";
-    }
-    $list = rtrim($list, ',').")";
-    
-    return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_assessments a
-                            WHERE a.userid IN $list
-                              AND a.workshopid = $workshop->id 
-                            ORDER BY a.timecreated");
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_comments($assessment) {
-    // Return all comments for this assessment provided they are newer than the assessment, 
-    // and ordered oldest first, newest last
-   return get_records_select("workshop_comments", "(assessmentid = $assessment->id) AND 
-        timecreated > $assessment->timecreated",
-        "timecreated DESC");
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_student_assessments($workshop, $user) {
-// Return all assessments on the student submissions by a user, order by youngest first, oldest last
-    global $CFG;
-
-    if (!workshop_is_student($workshop, $user->id)) {
-        return false;
-    }
-
-    return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s, {$CFG->prefix}workshop_assessments a
-                            WHERE s.workshopid = $workshop->id
-                              AND a.submissionid = s.id
-                              AND a.userid = $user->id
-                            ORDER BY a.timecreated DESC");
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_student_submission_assessments($workshop) {
-// Return all assessments on the student submissions, order by youngest first, oldest last
-    global $CFG;
-
-
-    if (!$students = workshop_get_students($workshop)) {
-        return false;
-    }
-    $list = "(";
-    foreach ($students as $student) {
-        $list .= "$student->id,";
-    }
-    $list = rtrim($list, ',').")";
-
-    return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s, {$CFG->prefix}workshop_assessments a
-                            WHERE s.userid IN $list
-                              AND s.workshopid = $workshop->id
-                              AND a.submissionid = s.id
-                              ORDER BY a.timecreated DESC");
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_submission_assessment($submission, $user) {
-    // Return the user's assessment for this submission (cold or warm, not hot)
-    
-    $timenow = time();
-    return get_record_select("workshop_assessments", "submissionid = $submission->id AND 
-            userid = $user->id AND timecreated < $timenow");
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_teacher_assessments($courseid, $submission) {
-// Return teacher assessments of a submission, ordered by timecreated, oldest first
-    global $CFG;
-    
-    if (!$teachers = workshop_get_teachers($submission->workshopid)) {
-        return false;
-    }
-    $list = "(";
-    foreach ($teachers as $teacher) {
-        $list .= "$teacher->id,";
-    }
-    $list = rtrim($list, ',').")";
-    return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_assessments a
-                            WHERE a.userid IN $list
-                              AND a.submissionid = $submission->id 
-                            ORDER BY a.timecreated");
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_teacher_submission_assessments($workshop) {
-// Return all assessments on the teacher submissions, order by youngest first, oldest last
-    global $CFG;
-    
-    if (!$teachers = workshop_get_teachers($workshop)) {
-        return false;
-    }
-    $list = "(";
-    foreach ($teachers as $teacher) {
-        $list .= "$teacher->id,";
-    }
-    $list = rtrim($list, ',').")";
-    return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s, {$CFG->prefix}workshop_assessments a
-                            WHERE s.userid IN $list
-                              AND s.workshopid = $workshop->id
-                              AND a.submissionid = s.id
-                            ORDER BY a.timecreated DESC");
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_teacher_submissions($workshop) {
-// Return all  teacher submissions, ordered by title
-    global $CFG;
-    
-    if (!$teachers = workshop_get_teachers($workshop)) {
-        return false;
-    }
-    $list = "(";
-    foreach ($teachers as $teacher) {
-        $list .= "$teacher->id,";
-    }
-    $list = rtrim($list, ',').")";
-    return get_records_sql("SELECT s.* FROM {$CFG->prefix}workshop_submissions s
-                            WHERE s.userid IN $list
-                              AND s.workshopid = $workshop->id 
-                            ORDER BY s.title");
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_ungraded_assessments($workshop) {
-    global $CFG;
-    // Return all assessments which have not been graded or just graded
-    $cutofftime = time() - $CFG->maxeditingtime;
-    return get_records_select("workshop_assessments", "workshopid = $workshop->id AND (timegraded = 0 OR 
-                timegraded > $cutofftime)", "timecreated"); 
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_ungraded_assessments_student($workshop) {
-    global $CFG;
-    // Return all assessments which have not been graded or just graded of student's submissions
-
-    $cutofftime = time() - $CFG->maxeditingtime;
-
-    if (!$students = workshop_get_students($workshop)) {
-        return false;
-    }
-    $list = "(";
-    foreach ($students as $student) {
-        $list .= "$student->id,";
-    }
-    $list = rtrim($list, ',').")";
-    return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s, {$CFG->prefix}workshop_assessments a
-                            WHERE s.userid IN $list
-                              AND s.workshopid = $workshop->id
-                              AND a.submissionid = s.id
-                              AND (a.timegraded = 0 OR a.timegraded > $cutofftime)
-                              AND a.timecreated < $cutofftime
-                              ORDER BY a.timecreated ASC"); 
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_ungraded_assessments_teacher($workshop) {
-    global $CFG;
-    // Return all assessments which have not been graded or just graded of teacher's submissions
-    
-    $cutofftime =time() - $CFG->maxeditingtime;
-    if (!$teachers = workshop_get_teachers($workshop)) {
-        return false;
-    }
-    $list = "(";
-    foreach ($teachers as $teacher) {
-        $list .= "$teacher->id,";
-    }
-    $list = rtrim($list, ',').")";
-    return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s, {$CFG->prefix}workshop_assessments a
-                            WHERE s.userid IN $list
-                              AND s.workshopid = $workshop->id
-                              AND a.submissionid = s.id
-                              AND (a.timegraded = 0 OR a.timegraded > $cutofftime)
-                              AND a.timecreated < $cutofftime
-                              ORDER BY a.timecreated ASC"); 
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_user_assessments_done($workshop, $user) {
-// Return all the  user's assessments, oldest first, newest last (warm and cold ones only)
-// ignores maxeditingtime
-    $timenow = time();
-    return get_records_select("workshop_assessments", "workshopid = $workshop->id AND userid = $user->id
-                AND timecreated < $timenow", 
-                "timecreated ASC");
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_users_done($workshop) {
-    global $CFG;
-
-    // make sure it works on the site course
-    $select = "s.course = '$workshop->course' AND";
-    if ($workshop->course == SITEID) {
-        $select = '';
-    }
-
-    if (!$students = workshop_get_students($workshop)) {
-        return false;
-    }
-    $list = "(";
-    foreach ($students as $student) {
-        $list .= "$student->id,";
-    }
-    $list = rtrim($list, ',').")";
-
-    return get_records_sql("SELECT u.* FROM {$CFG->prefix}user u, {$CFG->prefix}workshop_submissions a
-                            WHERE $select u.user IN $list
-                              AND u.id = a.user AND a.workshop = '$workshop->id'
-                            ORDER BY a.timemodified DESC");
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_list_all_submissions($workshop, $user) {
-    // list the teacher sublmissions first
-    global $CFG;
-    
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        print_error("Course Module ID was incorrect");
-    }
-    if (! $course = get_record("course", "id", $workshop->course)) {
-        print_error("Course is misconfigured");
-        }
-    $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), 
-                        get_string("comment", "workshop"));
-    $table->align = array ("left", "left", "left");
-    $table->size = array ("*", "*", "*");
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-
-    if ($submissions = workshop_get_teacher_submissions($workshop)) {
-        foreach ($submissions as $submission) {
-            if ($submission->userid == $user->id) {
-                $comment = get_string("ownwork", "workshop")."; ";
-                }
-            else {
-                $comment = "";
-                }
-            // has user already assessed this submission
-            if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id
-                    AND userid = $user->id")) {
-                $curtime = time();
-                if (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) {
-                    $action = "<a href=\"viewassessment.php?id=$cm->id&amp;aid=$assessment->id\">"
-                        .get_string("view", "workshop")."</a>";
-                    // has teacher graded user's assessment?
-                    if ($assessment->timegraded) {
-                        if (($curtime - $assessment->timegraded) > $CFG->maxeditingtime) {
-                            $comment .= get_string("gradedbyteacher", "workshop", $course->teacher);
-                            }
-                        }
-                    }
-                else { // there's still time left to edit...
-                    $action = "<a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">".
-                        get_string("edit", "workshop")."</a>";
-                    }
-                }
-            else { // user has not graded this submission
-                $action = "<a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">".
-                    get_string("assess", "workshop")."</a>";
-                }
-            $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, 
-                                $comment);
-            }
-        print_table($table);
-        }
-
-    echo "<div style=\"text-align:center;\"><p><b>".get_string("studentsubmissions", "workshop", $course->student).
-        "</b></div><br />\n";
-    unset($table);
-    $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), 
-                        get_string("comment", "workshop"));
-    $table->align = array ("left", "left", "left");
-    $table->size = array ("*", "*", "*");
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-
-    if ($submissions = workshop_get_student_submissions($workshop)) {
-        foreach ($submissions as $submission) {
-            if ($submission->userid == $user->id) {
-                $comment = get_string("ownwork", "workshop")."; ";
-                }
-            else {
-                $comment = "";
-                }
-            // has user already assessed this submission
-            if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id
-                    AND userid = $user->id")) {
-                $curtime = time();
-                if (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) {
-                    $action = "<a href=\"viewassessment.php?id=$cm->id&amp;aid=$assessment->id\">".
-                        get_string("view", "workshop")."</a>";
-                    // has teacher graded on user's assessment?
-                    if ($assessment->timegraded) {
-                        if (($curtime - $assessment->timegraded) > $CFG->maxeditingtime) {
-                            $comment .= get_string("gradedbyteacher", "workshop", $course->teacher)."; ";
-                            }
-                        }
-                    $otherassessments = workshop_get_assessments($submission);
-                    if (count($otherassessments) > 1) {
-                        $comment .= "<a href=\"assessments.php?action=viewallassessments&amp;id=$cm->id&amp;sid=$submission->id\">".
-                        get_string("viewotherassessments", "workshop")."</a>";
-                        }
-                    }
-                else { // there's still time left to edit...
-                    $action = "<a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">".
-                        get_string("edit", "workshop")."</a>";
-                    }
-                }
-            else { // user has not assessed this submission
-                $action = "<a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">".
-                    get_string("assess", "workshop")."</a>";
-                }
-            $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, 
-                                $comment);
-            }
-        print_table($table);
-        }
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_list_all_ungraded_assessments($workshop) {
-    // lists all the assessments for comment by teacher
-    global $CFG;
-
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        print_error("Course Module ID was incorrect");
-    }
-    
-    $table->head = array (get_string("title", "workshop"), get_string("timeassessed", "workshop"), get_string("action", "workshop"));
-    $table->align = array ("left", "left", "left");
-    $table->size = array ("*", "*", "*");
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-    $timenow = time();
-    
-    if ($assessments = workshop_get_ungraded_assessments($workshop)) {
-        foreach ($assessments as $assessment) {
-            if (!workshop_is_teacher($workshop, $assessment->userid)) {
-                if (($timenow - $assessment->timegraded) < $CFG->maxeditingtime) {
-                    $action = "<a href=\"viewassessment.php?&amp;id=$cm->id&amp;aid=$assessment->id\">".
-                        get_string("edit", "workshop")."</a>";
-                    }
-                else {
-                    $action = "<a href=\"viewassessment.php?&amp;id=$cm->id&amp;aid=$assessment->id\">".
-                        get_string("gradeassessment", "workshop")."</a>";
-                    }
-                $submission = get_record("workshop_submissions", "id", $assessment->submissionid);
-                $table->data[] = array(workshop_print_submission_title($workshop, $submission), 
-                    userdate($assessment->timecreated), $action);
-                }
-            }
-        if (isset($table->data)) {
-            print_table($table);
-            }
-        }
-    }
-    
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_list_assessed_submissions($workshop, $user) {
-    // list the submissions that have been assessed by this user and are COLD
-    global $CFG, $USER;
-    
-    $timenow = time();
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        print_error("Course Module ID was incorrect");
-    }
-    if (! $course = get_record("course", "id", $workshop->course)) {
-        print_error("Course is misconfigured");
-        }
-    $table->head = array (get_string("title","workshop"), get_string("action","workshop"), 
-                    get_string("comment","workshop"));
-    $table->align = array ("left", "left", "left");
-    $table->size = array ("*", "*", "*");
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-
-    if ($assessments = workshop_get_student_assessments($workshop, $user)) {
-        foreach ($assessments as $assessment) {
-            $comment = "";
-            $submission = get_record("workshop_submissions", "id", $assessment->submissionid);
-            // the assessment may be in three states: 
-            // 1. "hot", just created but not completed (timecreated is in the future)
-            // 2. "warm" just created and still capable of being edited, and 
-            // 3. "cold" after the editing time
-                
-            if ($assessment->timecreated < ($timenow - $CFG->maxeditingtime)) { // it's cold
-                if ($workshop->agreeassessments) {
-                    if (!$assessment->timeagreed) {
-                        $action = "<a href=\"viewassessment.php?id=$cm->id&amp;aid=$assessment->id&".
-                            "allowcomments=$workshop->agreeassessments\">".
-                            get_string("view", "workshop")."</a>";
-                        $action .= " | <a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">".
-                            get_string("reassess", "workshop")."</a>";
-                    } else {
-                        $action = "<a href=\"viewassessment.php?id=$cm->id&amp;aid=$assessment->id&".
-                            "allowcomments=false\">".get_string("view", "workshop")."</a>";
-                    }
-                } else {
-                    // if it been graded allow student to re-assess, except if it's a self assessment
-                    if ($assessment->timegraded and !($USER->id == $assessment->userid)) {
-                        $action = "<a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">".
-                            get_string("reassess", "workshop")."</a>";
-                    } else {
-                        $action = "<a href=\"viewassessment.php?id=$cm->id&amp;aid=$assessment->id\">".
-                            get_string("view", "workshop")."</a>";
-                    }
-                }          
-                if ($assessment->timecreated < $timenow) { // only show the date if it's in the past (future dates cause confusion)
-                    $comment = get_string("assessedon", "workshop", userdate($assessment->timecreated));
-                }
-                else {
-                    $comment = '';
-                }
-                if ($submission->userid == $user->id) { // self assessment?
-                    $comment .= "; ".get_string("ownwork", "workshop"); // just in case they don't know!
-                }
-                // has assessment been graded?
-                if ($assessment->timegraded and ($timenow - $assessment->timegraded > $CFG->maxeditingtime)) {
-                    if ($workshop->gradingstrategy) { // supress grading grade if not graded
-                        $comment .= "; ".get_string("thegradeforthisassessmentis", "workshop", 
-                            number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0)).
-                            " / $workshop->gradinggrade";
-                    }
-                }
-                // if peer agreements show whether agreement has been reached
-                if ($workshop->agreeassessments) {
-                    if ($assessment->timeagreed) {
-                        $comment .= "; ".get_string("assessmentwasagreedon", "workshop", 
-                                userdate($assessment->timeagreed));
-                    }
-                    else {
-                        $comment .= "; ".get_string("assessmentnotyetagreed", "workshop");
-                    }
-                }
-                $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, 
-                                    $comment);
-            }
-        }
-    }
-    if (isset($table->data)) {
-        print_table($table);
-    }
-    else {
-        echo "<div style=\"text-align:center;\">".get_string("noassessmentsdone", "workshop")."</div>\n";
-    }
-}
-
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_list_peer_assessments($workshop, $user) {
-    global $CFG;
-    
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        print_error("Course Module ID was incorrect");
-    }
-    if (! $course = get_record("course", "id", $workshop->course)) {
-        print_error("Course is misconfigured");
-        }
-    $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), 
-                    get_string("comment", "workshop"));
-    $table->align = array ("left", "left", "left");
-    $table->size = array ("*", "*", "*");
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-
-    // get user's submissions
-    if ($submissions = workshop_get_user_submissions($workshop, $user)) {
-        foreach ($submissions as $submission) {
-            // get the assessments
-            if ($assessments = workshop_get_assessments($submission)) {
-                foreach ($assessments as $assessment) {
-                    // assessments by students only and exclude any self assessments
-                    if (workshop_is_student($workshop, $assessment->userid) and 
-                            ($assessment->userid != $user->id)) { 
-                        $timenow = time();
-                        if (($timenow - $assessment->timecreated) > $CFG->maxeditingtime) {
-                            $action = "<a href=\"viewassessment.php?id=$cm->id&amp;aid=$assessment->id&".
-                                "allowcomments=$workshop->agreeassessments\">".
-                                get_string("view", "workshop")."</a>";
-                            $comment = get_string("assessedon", "workshop", userdate($assessment->timecreated));
-                            $grade = number_format($assessment->grade * $workshop->grade / 100, 1);
-                            if ($workshop->gradingstrategy) { // supress grade if not graded
-                                $comment .= "; ".get_string("gradeforsubmission", "workshop").
-                                    ": $grade / $workshop->grade"; 
-                            }
-                            if ($assessment->timegraded) {
-                                if (!$assessment->gradinggrade) {
-                                    // it's a bad assessment
-                                    $comment .= "; ".get_string("thisisadroppedassessment", "workshop");
-                                }
-                            }
-                            if (workshop_is_teacher($workshop, $assessment->userid) and $workshop->teacherweight) {
-                                $comment .= "; ".get_string("thisisadroppedassessment", "workshop");
-                            }
-                            // if peer agreements show whether agreement has been reached
-                            if ($workshop->agreeassessments) {
-                                if ($assessment->timeagreed) {
-                                    $comment .= "; ".get_string("assessmentwasagreedon", "workshop", 
-                                                        userdate($assessment->timeagreed));
-                                    }
-                                else {
-                                    $comment .= "; ".get_string("assessmentnotyetagreed", "workshop");
-                                    }
-                                }
-                            $table->data[] = array(workshop_print_submission_title($workshop, $submission), 
-                                                $action, $comment);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    if (isset($table->data)) {
-        print_table($table);
-        }
-    else {
-        echo "<div style=\"text-align:center;\">".get_string("noassessmentsdone", "workshop")."</div>\n";
-        }
-    }
-
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_list_self_assessments($workshop, $user) {
-    // list  user's submissions for the user to assess
-    global $CFG;
-    
-    $timenow = time();
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        print_error("Course Module ID was incorrect");
-    }
-    if (! $course = get_record("course", "id", $workshop->course)) {
-        print_error("Course is misconfigured");
-        }
-    $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), 
-                       get_string("comment", "workshop"));
-    $table->align = array ("left", "left", "left");
-    $table->size = array ("*", "*", "*");
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-
-    // get the user's submissions 
-    if ($submissions = workshop_get_user_submissions($workshop, $user)) {
-        foreach ($submissions as $submission) {
-            $comment = get_string("ownwork", "workshop"); // just in case they don't know!
-            if (!$assessment = get_record_select("workshop_assessments", "submissionid = $submission->id AND
-                    userid = $user->id")) {
-                $action = "<a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">".
-                    get_string("assess", "workshop")."</a>";
-                $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
-            } else {
-                // may still be warm
-                if (($assessment->timecreated + $CFG->maxeditingtime) > $timenow) {
-                    $action = "<a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">".
-                        get_string("reassess", "workshop")."</a>";
-                    $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
-                }
-            }
-        
-        }
-    }
-    if (isset($table->data)) {
-        echo "<p><div style=\"text-align:center;\"><b>".get_string("pleaseassessyoursubmissions", "workshop", $course->student).
-            "</b></div><br />\n";
-        print_table($table);
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_list_student_submissions($workshop, $user) {
-    // list available submissions for this user to assess, submissions with the least number 
-    // of assessments are show first
-    global $CFG;
-    
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        print_error("Course Module ID was incorrect");
-    }
-    if (! $course = get_record("course", "id", $workshop->course)) {
-        print_error("Course is misconfigured");
-        }
-
-    $timenow = time();
-
-    // set student's group if workshop is in SEPARATEGROUPS mode
-    if (groupmode($course, $cm) == SEPARATEGROUPS) {
-        $groupid = get_current_group($course->id);
-    } else {
-        $groupid = 0;
-    }
-    
-    $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop"));
-    $table->align = array ("left", "left", "left");
-    $table->size = array ("*", "*", "*");
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-
-    // get the number of assessments this user has done on student submission, deduct self assessments
-    $nassessed = workshop_count_user_assessments($workshop, $user, "student") - 
-        workshop_count_self_assessments($workshop, $user);
-    // user hasn't been allocated enough, try and get some more
-    if ($nassessed < $workshop->nsassessments) {
-        // count the number of assessments for each student submission
-        if ($submissions = workshop_get_student_submissions($workshop)) {
-            // srand ((float)microtime()*1000000); // now done automatically in PHP 4.2.0->
-            foreach ($submissions as $submission) {
-                // check group membership, if necessary
-                if ($groupid) {
-                    // check user's group
-                    if (!groups_is_member($groupid, $submission->userid)) {
-                        continue; // skip this submission
-                  }
-                }
-                // process only cold submissions
-                if (($submission->timecreated + $CFG->maxeditingtime) > $timenow) {
-                    continue;
-                }
-                $n = count_records("workshop_assessments", "submissionid", $submission->id);
-                // ...OK to have zero, we add a small random number to randomise things
-                $nassessments[$submission->id] = $n + rand(0, 98) / 100;
-                }
-                
-            if (isset($nassessments)) { // make sure we end up with something to play with
-                // put the submissions with the lowest number of assessments first
-                asort($nassessments);
-                reset($nassessments);
-                $nsassessments = $workshop->nsassessments;
-                foreach ($nassessments as $submissionid =>$n) {
-                    // only use those submissions which fall below the allocation threshold
-                    if ($n < ($workshop->nsassessments + $workshop->overallocation)) {
-                        $comment = "";
-                        $submission = get_record("workshop_submissions", "id", $submissionid);
-                        // skip submission if it belongs to this user
-                        if ($submission->userid != $user->id) {
-                            // add a "hot" assessment record if user has NOT already assessed this submission
-                            if (!get_record("workshop_assessments", "submissionid", $submission->id, "userid",
-                                        $user->id)) {
-                                $yearfromnow = time() + 365 * 86400;
-                                // ...create one and set timecreated way in the future, this is reset when record is updated
-                                unset($assessment); // clear previous version object (if any)
-                                $assessment->workshopid = $workshop->id;
-                                $assessment->submissionid = $submission->id;
-                                $assessment->userid = $user->id;
-                                $assessment->grade = -1; // set impossible grade
-                                $assessment->timecreated = $yearfromnow;
-                                if (!$assessment->id = insert_record("workshop_assessments", $assessment)) {
-                                    print_error("List Student submissions: Could not insert workshop assessment!");
-                                }
-                                $nassessed++;
-                                // is user up to quota?
-                                if ($nassessed == $nsassessments) {
-                                    break;
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-    // now list the student submissions this user has been allocated, list only the hot and warm ones, 
-    // the cold ones are listed in the "your assessments list" (_list_assessed submissions)
-    if ($assessments = workshop_get_user_assessments($workshop, $user)) {
-        $timenow = time();
-        foreach ($assessments as $assessment) {
-            if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
-                error ("workshop_list_student_submissions: unable to get submission");
-                }
-            // submission from a student?
-            if (workshop_is_student($workshop, $submission->userid)) {
-                $comment = '';
-                // user assessment has three states: record created but not assessed (date created in the future) [hot]; 
-                // just assessed but still editable [warm]; and "static" (may or may not have been graded by teacher, that
-                // is shown in the comment) [cold] 
-                if ($assessment->timecreated > $timenow) { // user needs to assess this submission
-                    $action = "<a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">".
-                        get_string("assess", "workshop")."</a>";
-                    $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
-                    }
-                elseif ($assessment->timecreated > ($timenow - $CFG->maxeditingtime)) { // there's still time left to edit...
-                    $action = "<a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">".
-                        get_string("edit", "workshop")."</a>";
-                    $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
-                    }
-                }
-            }
-        }
-    
-    if (isset($table->data)) {
-        echo "<p><div style=\"text-align:center;\"><b>".get_string("pleaseassessthesestudentsubmissions", "workshop", $course->student).
-            "</b></div><br />\n";
-        print_table($table);
-        }
-    else {
-        echo "<p><div style=\"text-align:center;\"><b>".get_string("nosubmissionsavailableforassessment", "workshop")."</b></div><br />\n";
-        }
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_list_submissions_for_admin($workshop, $order) {
-    // list the teacher sublmissions first
-    global $CFG, $USER;
-    
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        print_error("Course Module ID was incorrect");
-    }
-    if (! $course = get_record("course", "id", $workshop->course)) {
-        print_error("Course is misconfigured");
-        }
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
-        print_error("Course Module ID was incorrect");
-    }
-    if (groupmode($course, $cm) == SEPARATEGROUPS) {
-        $groupid = get_current_group($course->id);
-    } else {
-        $groupid = 0;
-    }
-    
-    workshop_print_assignment_info($workshop);
-
-    if (workshop_is_teacheredit($workshop)) {
-        // list any teacher submissions
-        $table->head = array (get_string("title", "workshop"), get_string("submittedby", "workshop"), 
-                get_string("action", "workshop"));
-        $table->align = array ("left", "left", "left");
-        $table->size = array ("*", "*", "*");
-        $table->cellpadding = 2;
-        $table->cellspacing = 0;
-
-        if ($submissions = workshop_get_teacher_submissions($workshop)) {
-            foreach ($submissions as $submission) {
-                $action = "<a href=\"submissions.php?action=adminamendtitle&amp;id=$cm->id&amp;sid=$submission->id\">".
-                    get_string("amendtitle", "workshop")."</a>";
-                // has user already assessed this submission
-                if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id
-                            AND userid = $USER->id")) {
-                    $curtime = time();
-                if ($assessment->timecreated > $curtime) { // it's a "hanging" assessment 
-                    $action .= " | <a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">".
-                        get_string("assess", "workshop")."</a>";
-                }
-                elseif (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) {
-                    $action .= " | <a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">"
-                        .get_string("reassess", "workshop")."</a>";
-                }
-                else { // there's still time left to edit...
-                    $action .= " | <a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">".
-                        get_string("edit", "workshop")."</a>";
-                }
-            }
-                else { // user has not graded this submission
-                    $action .= " | <a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">".
-                        get_string("assess", "workshop")."</a>";
-                }
-                if ($assessments = workshop_get_assessments($submission)) {
-                    $action .= " | <a href=\"assessments.php?action=adminlist&amp;id=$cm->id&amp;sid=$submission->id\">".
-                        get_string("listassessments", "workshop")."</a>";
-                }
-                if (workshop_is_teacheredit($workshop)) {
-                    $action .= " | <a href=\"submissions.php?action=confirmdelete&amp;id=$cm->id&amp;sid=$submission->id\">".
-                        get_string("delete", "workshop")."</a>";
-                }
-                $table->data[] = array("<a href=\"submissions.php?action=editsubmission&amp;id=$cm->id&amp;sid=$submission->id\">$submission->title</a>", $course->teacher, $action);
-            }
-            print_heading(get_string("studentsubmissions", "workshop", $course->teacher), "center");
-            print_table($table);
-        }
-    }
-
-    // list student assessments
-    // Get all the students...
-    if ($users = workshop_get_students($workshop, "u.lastname, u.firstname")) {
-        $timenow = time();
-        unset($table);
-        $table->head = array(get_string("name"), get_string("title", "workshop"), get_string("action", "workshop"));
-        $table->align = array ("left", "left", "left");
-        $table->size = array ("*", "*", "*");
-        $table->cellpadding = 2;
-        $table->cellspacing = 0;
-        $nassessments = 0;
-        foreach ($users as $user) {
-            // check group membership, if necessary
-            if ($groupid) {
-                // check user's group
-                if (!groups_is_member($groupid, $user->id)) {
-                    continue; // skip this user
-                }
-            }
-            // list the assessments which have been done (exclude the hot ones)
-            if ($assessments = workshop_get_user_assessments_done($workshop, $user)) {
-                $title ='';
-                foreach ($assessments as $assessment) {
-                    if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
-                        print_error("Workshop_list_submissions_for_admin: Submission $assessment->submissionid not found!");
-                    }
-                    $title .= $submission->title;
-                    if ($workshop->agreeassessments and !$assessment->timeagreed and 
-                            workshop_is_student($workshop, $submission->userid)) { // agreements for student work only
-                        $title .= " &lt;&lt;".number_format($assessment->grade * $workshop->grade / 100, 0)." (".
-                            number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0).")&gt;&gt; ";
-                    } elseif ($assessment->timegraded) {
-                        if ($assessment->gradinggrade) {
-                            // a good assessment
-                            $title .= " {".number_format($assessment->grade * $workshop->grade / 100, 0)." (".
-                                number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0).")} ";
-                        } else { 
-                            // a poor assessment
-                            $title .= " &lt;".number_format($assessment->grade * $workshop->grade / 100, 0)." (".
-                                number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0).")&gt; ";
-                        }
-                    } else {
-                        // not yet graded
-                        $title .= " {".number_format($assessment->grade * $workshop->grade / 100, 0)." ((".
-                            number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0)."))} ";
-                    }
-                    if ($realassessments = workshop_count_user_assessments_done($workshop, $user)) {
-                        $action = "<a href=\"assessments.php?action=adminlistbystudent&amp;id=$cm->id&amp;userid=$user->id\">".
-                            get_string("liststudentsassessments", "workshop")." ($realassessments)</a>";
-                    } else {
-                        $action ="";
-                    }
-                }
-                $nassessments++;
-                $table->data[] = array(fullname($user), $title, $action);
-            }
-        }
-        if (isset($table->data)) {
-            print_heading(get_string("studentassessments", "workshop", $course->student)." [$nassessments]");
-            print_table($table);
-            workshop_print_key($workshop);
-            // grading grade analysis
-            unset($table);
-            $table->head = array (get_string("count", "workshop"), get_string("mean", "workshop"),
-                get_string("standarddeviation", "workshop"), get_string("maximum", "workshop"), 
-                get_string("minimum", "workshop"));
-            $table->align = array ("center", "center", "center", "center", "center");
-            $table->size = array ("*", "*", "*", "*", "*");
-            $table->cellpadding = 2;
-            $table->cellspacing = 0;
-            if ($groupid) {
-                $stats = get_record_sql("SELECT COUNT(*) as count, AVG(gradinggrade) AS mean, 
-                        STDDEV(gradinggrade) AS stddev, MIN(gradinggrade) AS min, MAX(gradinggrade) AS max 
-                        FROM {$CFG->prefix}groups_members g, {$CFG->prefix}workshop_assessments a 
-                        WHERE g.groupid = $groupid AND a.userid = g.userid AND a.timegraded > 0 
-                        AND a.workshopid = $workshop->id");
-            } else { // no group/all participants
-                $stats = get_record_sql("SELECT COUNT(*) as count, AVG(gradinggrade) AS mean, 
-                        STDDEV(gradinggrade) AS stddev, MIN(gradinggrade) AS min, MAX(gradinggrade) AS max 
-                        FROM {$CFG->prefix}workshop_assessments a 
-                        WHERE a.timegraded > 0 AND a.workshopid = $workshop->id");
-            }   
-            $table->data[] = array($stats->count, number_format($stats->mean * $workshop->gradinggrade / 100, 1), 
-                    number_format($stats->stddev * $workshop->gradinggrade /100, 1), 
-                    number_format($stats->max * $workshop->gradinggrade / 100, 1), 
-                    number_format($stats->min* $workshop->gradinggrade / 100, 1));
-            print_heading(get_string("gradinggrade", "workshop")." ".get_string("analysis", "workshop"));
-            print_table($table);
-            echo "<p style=\"text-align:center\"><a href=\"assessments.php?id=$cm->id&amp;action=regradestudentassessments\">".
-                    get_string("regradestudentassessments", "workshop")."</a> ";
-            helpbutton("regrading", get_string("regradestudentassessments", "workshop"), "workshop");
-            echo "</p>\n";
-        }
-    }
-
-    // now the sudent submissions
-    unset($table);
-    switch ($order) {
-        case "title" :
-            $table->head = array("<a href=\"submissions.php?action=adminlist&amp;id=$cm->id&amp;order=name\">".
-                 get_string("submittedby", "workshop")."</a>", get_string("title", "workshop"), 
-                 get_string("submitted", "workshop"), get_string("action", "workshop"));
-            break;
-        case "name" :
-            $table->head = array (get_string("submittedby", "workshop"), 
-                "<a href=\"submissions.php?action=adminlist&amp;id=$cm->id&amp;order=title\">".
-                get_string("title", "workshop")."</a>", get_string("submitted", "workshop"), 
-                get_string("action", "workshop"));
-            break;
-    }
-    $table->align = array ("left", "left", "left", "left");
-    $table->size = array ("*", "*", "*", "*");
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-    
-    $nsubmissions = 0;
-    if ($submissions = workshop_get_student_submissions($workshop, $order)) {
-        foreach ($submissions as $submission) {
-            if (!$user = get_record("user", "id", $submission->userid)) {
-                print_error("workshop_list_submissions_for_admin: failure to get user record");
-            }
-            // check group membership, if necessary
-            if ($groupid) {
-                // check user's group
-                if (!groups_is_member($groupid, $user->id)) {
-                    continue; // skip this user
-                }
-            }
-            $datesubmitted = userdate($submission->timecreated);
-            if ($submission->late) {
-                $datesubmitted = "<span class=\"redfont\">".$datesubmitted."</span>";
-            }
-            $action = "<a href=\"submissions.php?action=adminamendtitle&amp;id=$cm->id&amp;sid=$submission->id\">".
-                get_string("amendtitle", "workshop")."</a>";
-            // has teacher already assessed this submission
-            if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id
-                    AND userid = $USER->id")) {
-                $curtime = time();
-                if (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) {
-                    $action .= " | <a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">".
-                        get_string("reassess", "workshop")."</a>";
-                }
-                else { // there's still time left to edit...
-                    $action .= " | <a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">".
-                        get_string("edit", "workshop")."</a>";
-                }
-            }
-            else { // user has not assessed this submission
-                $action .= " | <a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">".
-                    get_string("assess", "workshop")."</a>";
-            }
-            if ($nassessments = workshop_count_assessments($submission)) {
-                $action .= " | <a href=\"assessments.php?action=adminlist&amp;id=$cm->id&amp;sid=$submission->id\">".
-                    get_string("listassessments", "workshop")." ($nassessments)</a>";
-            }
-            if ($submission->late) {
-                $action .= " | <a href=\"submissions.php?action=adminlateflag&amp;id=$cm->id&amp;sid=$submission->id\">".
-                    get_string("clearlateflag", "workshop")."</a>";
-            }
-            $action .= " | <a href=\"submissions.php?action=confirmdelete&amp;id=$cm->id&amp;sid=$submission->id\">".
-                get_string("delete", "workshop")."</a>";
-            $nsubmissions++;
-            $table->data[] = array("$user->firstname $user->lastname", $submission->title.
-                " (".get_string("grade").": ".workshop_submission_grade($workshop, $submission)." ".
-                workshop_print_submission_assessments($workshop, $submission, "teacher").
-                " ".workshop_print_submission_assessments($workshop, $submission, "student").")", $datesubmitted, 
-                $action);
-        }
-        print_heading(get_string("studentsubmissions", "workshop", $course->student)." [$nsubmissions]", "center");
-        print_table($table);
-        workshop_print_key($workshop);
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_list_teacher_assessments_by_user($workshop, $user) {
-    global $CFG;
-    
-    $timenow = time();
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        print_error("Course Module ID was incorrect");
-    }
-    if (! $course = get_record("course", "id", $workshop->course)) {
-        print_error("Course is misconfigured");
-    }
-
-    $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop"));
-    $table->align = array ("left", "left", "left");
-    $table->size = array ("*", "*", "*");
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-
-    // get user's submissions
-    if ($submissions = workshop_get_user_submissions($workshop, $user)) {
-        foreach ($submissions as $submission) {
-            // get the assessments
-            if ($assessments = workshop_get_assessments($submission)) {
-                foreach ($assessments as $assessment) {
-                    if (workshop_is_teacher($workshop, $assessment->userid)) { // assessments by teachers only
-                        $action = "<a href=\"viewassessment.php?id=$cm->id&amp;aid=$assessment->id\">".
-                            get_string("view", "workshop")."</a>";
-                        // has teacher commented on teacher's assessment? shouldn't happen but leave test in
-                        if ($assessment->timegraded and ($timenow - $assessment->timegraded > $CFG->maxeditingtime)) {
-                            $comment = get_string("gradedbyteacher", "workshop", $course->teacher);
-                            }
-                        else {
-                            $comment = userdate($assessment->timecreated);
-                            }
-                        $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
-                        }
-                    }
-                }
-            }
-        }
-    if (isset($table->data)) {
-        print_table($table);
-        }
-    else {
-        echo "<div style=\"text-align:center;\">".get_string("noassessmentsdone", "workshop")."</div>\n";
-        }
-    }
-
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_list_teacher_submissions($workshop, $user) {
-    global $CFG;
-
-    // set threshold on re-assessments
-    $reassessthreshold = 80;
-    
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        print_error("Course Module ID was incorrect");
-    }
-    if (! $course = get_record("course", "id", $workshop->course)) {
-        print_error("Course is misconfigured");
-    }
-    $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop"));
-    $table->align = array ("left", "left", "left");
-    $table->size = array ("*", "*", "*");
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-
-    // get the number of assessments this user has done
-    $nassessed = count_records_select("workshop_assessments", "workshopid = $workshop->id
-                    AND userid = $user->id");
-    if ($nassessed < $workshop->ntassessments) { 
-        // if user has not assessed enough, set up "future" assessment records for this user for the teacher submissions...
-        // ... first count the number of assessments for each teacher submission...
-        if ($submissions = workshop_get_teacher_submissions($workshop)) {
-            srand ((float)microtime()*1000000); // initialise random number generator
-            foreach ($submissions as $submission) {
-                $n = count_records("workshop_assessments", "submissionid", $submission->id);
-                // ...OK to have zero, we add a small random number to randomise things...
-                $nassessments[$submission->id] = $n + rand(0, 99) / 100;
-            }
-            // ...put the submissions with the lowest number of assessments first...
-            asort($nassessments);
-            reset($nassessments);
-            foreach ($nassessments as $submissionid => $n) { // break out of loop when we allocated enough assessments...
-                $submission = get_record("workshop_submissions", "id", $submissionid);
-                // ... provided the user has NOT already assessed that submission...
-                if (!get_record("workshop_assessments", "submissionid", $submission->id, "userid",
-                                    $user->id)) {
-                    $yearfromnow = time() + 365 * 86400;
-                    // ...create one and set timecreated way in the future, this is reset when record is updated
-                    unset($assessment); // clear previous version of object (if any)
-                    $assessment->workshopid = $workshop->id;
-                    $assessment->submissionid = $submission->id;
-                    $assessment->userid = $user->id;
-                    $assessment->grade = -1; // set impossible grade
-                    $assessment->timecreated = $yearfromnow;
-                    if (!$assessment->id = insert_record("workshop_assessments", $assessment)) {
-                        print_error("Could not insert workshop assessment!");
-                    }
-                    $nassessed++;
-                    if ($nassessed >= $workshop->ntassessments) {
-                        break;
-                    }
-                }
-            }
-        }
-    }
-    // now list user's assessments (but only list those which come from teacher submissions)
-    if ($assessments = workshop_get_user_assessments($workshop, $user)) {
-        $timenow = time();
-        foreach ($assessments as $assessment) {
-            if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
-                error ("workshop_list_teacher_submissions: unable to get submission");
-            }
-            // submission from a teacher?
-            if (workshop_is_teacher($workshop, $submission->userid)) {
-                $comment = '';
-                // user assessment has two states: record created but not assessed (date created in the future); 
-                // assessed but always available for re-assessment 
-                if ($assessment->timecreated > $timenow) { // user needs to assess this submission
-                    $action = "<a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">".
-                        get_string("assess", "workshop")."</a>";
-                }
-                elseif ($assessment->timegraded and ($assessment->gradinggrade < $reassessthreshold)) { 
-                    // allow student to improve on their assessment once it's been graded and is below threshold
-                    $action = "<a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">".
-                        get_string("reassess", "workshop")."</a>";
-                } else {
-                    // allow student  just to see their assessment if it hasn't been graded (or above threshold)
-                    $action = "<a href=\"viewassessment.php?id=$cm->id&amp;aid=$assessment->id\">".
-                        get_string("view", "workshop")."</a>";
-                }
-                // see if the assessment is graded
-                if ($assessment->timegraded) {
-                    // show grading grade (supressed if workshop not graded)
-                    if ($workshop->gradingstrategy) {
-                        $comment = get_string("thegradeforthisassessmentis", "workshop", 
-                            number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 1))." / ".
-                            $workshop->gradinggrade;
-                    }
-                } elseif ($assessment->timecreated < $timenow) {
-                    $comment = get_string("awaitinggradingbyteacher", "workshop", $course->teacher);
-                }
-                $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
-            }
-        }
-    }
-    print_table($table);
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_list_unassessed_student_submissions($workshop, $user) {
-    // list the student submissions not assessed by this user
-    global $CFG;
-    
-    $timenow = time();
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        print_error("Course Module ID was incorrect");
-    }
-    if (! $course = get_record("course", "id", $workshop->course)) {
-        print_error("Course is misconfigured");
-        }
-
-    if (groupmode($course, $cm) == SEPARATEGROUPS) {
-        $groupid = get_current_group($course->id);
-    } else {
-        $groupid = 0;
-    }
-
-    $table->head = array (get_string("title", "workshop"), get_string("submittedby", "workshop"),
-        get_string("submitted", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop"));
-    $table->align = array ("left", "left", "left", "left", "left");
-    $table->size = array ("*", "*", "*", "*", "*");
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-
-    if ($submissions = workshop_get_student_submissions($workshop, 'time')) { // oldest first 
-        foreach ($submissions as $submission) {
-            // check group membership, if necessary
-            if ($groupid) {
-                // check user's group
-                if (!groups_is_member($groupid, $submission->userid)) {
-                    continue; // skip this user
-                }
-            }
-            // see if submission is cold
-            if (($submission->timecreated +$CFG->maxeditingtime) > $timenow) {
-                continue; // skip this submission
-            }
-            $comment = "";
-            $timegap = get_string("ago", "workshop", format_time($submission->timecreated - $timenow));
-            // see if user already graded this assessment
-            if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id
-                    AND userid = $user->id")) {
-                if (($timenow - $assessment->timecreated < $CFG->maxeditingtime)) {
-                    // last chance salon
-                    $submissionowner = get_record("user", "id", $submission->userid);
-                    $action = "<a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">".
-                        get_string("edit", "workshop")."</a>";
-                    $table->data[] = array(workshop_print_submission_title($workshop, $submission), 
-                        fullname($submissionowner), $timegap, $action, $comment);
-                    }
-                }
-            else { 
-                // no assessment by this user, if no other teacher has assessed submission then list it
-                if (!workshop_count_teacher_assessments($course->id, $submission)) {
-                    $submissionowner = get_record("user", "id", $submission->userid);
-                    $action = "<a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">".
-                        get_string("assess", "workshop")."</a>";
-                    $table->data[] = array(workshop_print_submission_title($workshop, $submission), 
-                        fullname($submissionowner), $timegap, $action, $comment);
-                }
-                }
-            }
-        if (isset($table->data)) {
-            print_table($table);
-            }
-        }
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_list_unassessed_teacher_submissions($workshop, $user) {
-    // list the teacher submissions not assessed by this user
-    global $CFG;
-    
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        print_error("Course Module ID was incorrect");
-    }
-
-    $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), 
-            get_string("comment", "workshop"));
-    $table->align = array ("left", "left", "left");
-    $table->size = array ("*", "*", "*");
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-
-    if ($submissions = workshop_get_teacher_submissions($workshop)) {
-        foreach ($submissions as $submission) {
-            $comment = "";
-            // see if user already graded this assessment
-            if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id
-                    AND userid = $user->id")) {
-                $timenow = time();
-                if (($timenow - $assessment->timecreated < $CFG->maxeditingtime)) {
-                    // last chance salon
-                    $action = "<a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">".
-                        get_string("edit", "workshop")."</a>";
-                    $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
-                    }
-                }
-            else { // no assessment
-                $action = "<a href=\"assess.php?id=$cm->id&amp;sid=$submission->id\">".
-                    get_string("assess", "workshop")."</a>";
-                $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
-                }
-            }
-        if (isset($table->data)) {
-            print_table($table);
-            }
-        }
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_list_ungraded_assessments($workshop, $stype) {
-    // lists all the assessments of student submissions for grading by teacher
-    global $CFG;
-    
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        print_error("Course Module ID was incorrect");
-    }
-
-    $table->head = array (get_string("title", "workshop"), get_string("submittedby", "workshop"),
-    get_string("assessor", "workshop"), get_string("timeassessed", "workshop"), get_string("action", "workshop"));
-    $table->align = array ("left", "left", "left", "left");
-    $table->size = array ("*", "*", "*", "*");
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-    $timenow = time();
-    
-    switch ($stype) {
-        case "student" :
-            $assessments = workshop_get_ungraded_assessments_student($workshop);
-            break;
-        case "teacher" :
-            $assessments = workshop_get_ungraded_assessments_teacher($workshop);
-            break;
-        }
-    if ($assessments) {
-        foreach ($assessments as $assessment) {
-            if (!workshop_is_teacher($workshop, $assessment->userid)) { // don't let teacher grade their own assessments
-                if (($timenow - $assessment->timegraded) < $CFG->maxeditingtime) {
-                    $action = "<a href=\"viewassessment.php?&amp;id=$cm->id&amp;stype=$stype&amp;aid=$assessment->id\">".
-                        get_string("edit", "workshop")."</a>";
-                    }
-                else {
-                    $action = "<a href=\"viewassessment.php?&amp;id=$cm->id&amp;stype=$stype&amp;aid=$assessment->id\">".
-                        get_string("grade", "workshop")."</a>";
-                    }
-                $submission = get_record("workshop_submissions", "id", $assessment->submissionid);
-                $submissionowner = get_record("user", "id", $submission->userid);
-                $assessor = get_record("user", "id", $assessment->userid);
-                $table->data[] = array(workshop_print_submission_title($workshop, $submission), 
-                    fullname($submissionowner), fullname($assessor), userdate($assessment->timecreated), $action);
-                }
-            }
-        if (isset($table->data)) {
-            print_table($table);
-            }
-        }
-    }
-    
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_list_user_submissions($workshop, $user) {
-    global $CFG;
-
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        print_error("Course Module ID was incorrect");
-    }
-
-    $timenow = time();
-    $table->head = array (get_string("title", "workshop"),  get_string("action", "workshop"),
-        get_string("submitted", "assignment"),  get_string("assessments", "workshop"));
-    $table->align = array ("left", "left", "left", "left");
-    $table->size = array ("*", "*", "*", "*");
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-
-    if ($submissions = workshop_get_user_submissions($workshop, $user)) {
-        foreach ($submissions as $submission) {
-            // allow user to edit or delete a submission if it's warm OR if assessment period has not started
-            if (($submission->timecreated > ($timenow - $CFG->maxeditingtime)) or ($workshop->assessmentstart > time())) {
-                $action = "<a href=\"submissions.php?action=editsubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
-                    get_string("edit", "workshop")."</a> | ".
-                    "<a href=\"submissions.php?action=confirmdelete&amp;id=$cm->id&amp;sid=$submission->id\">".
-                    get_string("delete", "workshop")."</a>";
-            }
-            else {
-                $action = '';
-            }
-            $datesubmitted = userdate($submission->timecreated);
-            if ($submission->late) {
-                $datesubmitted = "<span class=\"redfont\">".$datesubmitted."</span>";
-            }
-            $n = count_records_select("workshop_assessments", "submissionid = $submission->id AND
-                    timecreated < ($timenow - $CFG->maxeditingtime)");
-            $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action,
-                $datesubmitted, $n);
-        }
-        print_table($table);
-    }
-}
-
-
-
-///////////////////////////////////////////////////////////////////////////////
-function workshop_phase($workshop, $style='') {
-    $time = time();
-    if ($time < $workshop->submissionstart) {
-        return get_string('phase1'.$style, 'workshop');
-    } 
-    else if ($time < $workshop->submissionend) {
-        if ($time < $workshop->assessmentstart) {
-            return get_string('phase2'.$style, 'workshop');
-        } else {
-            return get_string('phase3'.$style, 'workshop');
-        }
-    } 
-    else if ($time < $workshop->assessmentstart) {
-        return  get_string('phase0'.$style, 'workshop');
-    }
-    else if ($time < $workshop->assessmentend) {
-        return  get_string('phase4'.$style, 'workshop');
-    }
-    else {
-        return  get_string('phase5'.$style, 'workshop');
-    }    
-    print_error('Something is wrong with the workshop dates');
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_print_assessment($workshop, $assessment = false, $allowchanges = false, 
-    $showcommentlinks = false, $returnto = '') {
-    // $allowchanges added 14/7/03. The form is inactive unless allowchanges = true
-    // $returnto added 28/8/03. The page to go to after the assessment has been submitted
-    global $CFG, $USER, $WORKSHOP_SCALES, $WORKSHOP_EWEIGHTS;
-    
-    if (! $course = get_record("course", "id", $workshop->course)) {
-        print_error("Course is misconfigured");
-    }
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
-        print_error("Course Module ID was incorrect");
-    }
-    if ($assessment) {
-        if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
-            error ("Workshop_print_assessment: Submission record not found");
-        }
-        
-        // removed target=\"submission\" as it does not validate
-        // MDL-7861
-        print_heading(get_string('assessmentof', 'workshop', 
-            "<a href=\"submissions.php?id=$cm->id&amp;action=showsubmission&amp;sid=$submission->id\" >".
-            $submission->title.'</a>'));
-    }
-    
-    $timenow = time();
-
-    // reset the internal flags
-    if ($assessment) {
-        $showgrades = false;
-    }
-    else { // if no assessment, i.e. specimen grade form always show grading scales
-        $showgrades = true;
-    }
-    
-    if ($assessment) {
-        // set the internal flag if necessary
-        if ($allowchanges or !$workshop->agreeassessments or !$workshop->hidegrades or 
-                $assessment->timeagreed) {
-            $showgrades = true;
-        }
-        
-        echo "<div class=\"boxaligncenter\">\n";
-    
-        // see if this is a pre-filled assessment for a re-submission...
-        if ($assessment->resubmission) {
-            // ...and print an explaination
-            print_heading(get_string("assessmentofresubmission", "workshop"));
-        }
-        
-        // print agreement time if the workshop requires peer agreement
-        if ($workshop->agreeassessments and $assessment->timeagreed) {
-            echo "<p>".get_string("assessmentwasagreedon", "workshop", userdate($assessment->timeagreed));
-        }
-
-        // first print any comments on this assessment
-        if ($comments = workshop_get_comments($assessment)) {
-            echo "<table cellpadding=\"2\" border=\"1\">\n";
-            $firstcomment = TRUE;
-            foreach ($comments as $comment) {
-                echo "<tr valign=\"top\"><td class=\"workshopassessmentheading\"><p><b>".
-                    get_string("commentby","workshop")." ";
-                if (workshop_is_teacher($workshop, $comment->userid)) {
-                    echo $course->teacher;
-                }
-                elseif ($assessment->userid == $comment->userid) {
-                    print_string("assessor", "workshop");
-                }
-                else {
-                    print_string("authorofsubmission", "workshop");
-                }
-                echo " ".get_string("on", "workshop", userdate($comment->timecreated))."</b></p></td></tr><tr><td>\n";
-                echo format_text($comment->comments)."&nbsp;\n";
-                // add the links if needed
-                if ($firstcomment and $showcommentlinks and !$assessment->timeagreed) {
-                    // show links depending on who doing the viewing
-                    $firstcomment = FALSE;
-                    if (workshop_is_teacher($workshop, $USER->id) and ($comment->userid != $USER->id)) {
-                        echo "<p style=\"text-align:right\"><a href=\"assessments.php?action=addcomment&amp;id=$cm->id&amp;aid=$assessment->id\">".
-                            get_string("reply", "workshop")."</a></p>\n";
-                    }
-                    elseif (($comment->userid ==$USER->id) and (($timenow - $comment->timecreated) < $CFG->maxeditingtime)) {
-                        echo "<p style=\"text-align:right\"><a href=\"assessments.php?action=editcomment&amp;id=$cm->id&amp;cid=$comment->id\">".
-                            get_string("edit", "workshop")."</a>\n";
-                        if ($USER->id == $submission->userid) {
-                            echo " | <a href=\"assessments.php?action=agreeassessment&amp;id=$cm->id&amp;aid=$assessment->id\">".
-                                get_string("agreetothisassessment", "workshop")."</a>\n";
-                        }
-                        echo '</p>';
-                    }
-                    elseif (($comment->userid != $USER->id) and (($USER->id == $assessment->userid) or 
-                        ($USER->id == $submission->userid))) {
-                        echo "<p style=\"text-align:right\"><a href=\"assessments.php?action=addcomment&amp;id=$cm->id&amp;aid=$assessment->id\">".
-                            get_string("reply", "workshop")."</a>\n";
-                        if ($USER->id == $submission->userid) {
-                            echo " | <a href=\"assessments.php?action=agreeassessment&amp;id=$cm->id&amp;aid=$assessment->id\">".
-                                get_string("agreetothisassessment", "workshop")."</a>\n";
-                        }
-                        echo '</p>';
-                    }
-                }
-                echo '</td></tr>';
-            }
-            echo '</table>';
-        }
-        echo '</div>';
-    }
-        
-    // now print the grading form with the grading grade if any
-    // FORM is needed for Mozilla browsers, else radio bttons are not checked
-        ?>
-    <form id="assessmentform" method="post" action="assessments.php">
-    <div>
-    <input type="hidden" name="id" value="<?php echo $cm->id ?>" />
-    <input type="hidden" name="aid" value="<?php echo @$assessment->id ?>" />
-    <input type="hidden" name="action" value="updateassessment" />
-    <input type="hidden" name="returnto" value="<?php echo $returnto ?>" />
-    <input type="hidden" name="elementno" value="" />
-    <input type="hidden" name="stockcommentid" value="" />
-    <div class="boxaligncenter">
-    <table cellpadding="2" border="1" class="boxaligncenter">
-    <?php
-    echo "<tr valign=\"top\">\n";
-    echo "  <td colspan=\"2\" class=\"workshopassessmentheading\"><div style=\"text-align:center;\"><b>";
-    if ($assessment and workshop_is_teacher($workshop)) {
-        $user = get_record('user', 'id', $assessment->userid);
-        print_string("assessmentby", "workshop", fullname($user));
-    } else {
-        print_string('assessment', 'workshop');
-    }
-    echo '</b><br />'.userdate(@$assessment->timecreated)."</div></td>\n";
-    echo "</tr>\n";
-    
-    // only show the grade if grading strategy > 0 and the grade is positive
-    if ($assessment and $showgrades and $workshop->gradingstrategy and $assessment->grade >= 0) { 
-        echo "<tr valign=\"top\">\n
-            <td colspan=\"2\" align=\"center\">
-            <b>".get_string("thegradeis", "workshop").": ".
-            number_format($assessment->grade * $workshop->grade / 100, 2)." (".
-            get_string("maximumgrade")." ".number_format($workshop->grade, 0).")</b>
-            </td></tr><tr><td colspan=\"2\" class=\"workshopassessmentheading\">&nbsp;</td></tr>\n";
-    }
-    
-    // get the assignment elements...
-    $elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC");
-    if (count($elementsraw) < $workshop->nelements) {
-        print_string("noteonassignmentelements", "workshop");
-    }
-    if ($elementsraw) {
-        foreach ($elementsraw as $element) {
-            $elements[] = $element;   // to renumber index 0,1,2...
-        }
-    } else {
-        $elements = null;
-    }
-
-    if ($assessment) {
-        // get any previous grades...
-        if ($gradesraw = get_records_select("workshop_grades", "assessmentid = $assessment->id", "elementno")) {
-            foreach ($gradesraw as $grade) {
-                $grades[] = $grade;   // to renumber index 0,1,2...
-                }
-            }
-        }
-    else {
-        // setup dummy grades array
-        for($i = 0; $i < count($elementsraw); $i++) { // gives a suitable sized loop
-            $grades[$i]->feedback = get_string("yourfeedbackgoeshere", "workshop");
-            $grades[$i]->grade = 0;
-            }
-        }
-                
-    // determine what sort of grading
-    switch ($workshop->gradingstrategy) {
-        case 0:  // no grading
-            // now print the form
-            for ($i=0; $i < count($elements); $i++) {
-                $iplus1 = $i+1;
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"right\"><p><b>". get_string("element","workshop")." $iplus1:</b></p></td>\n";
-                echo "  <td>".format_text($elements[$i]->description);
-                echo "</td></tr>\n";
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"right\"><p><b>". get_string("feedback").":</b></p></td>\n";
-                echo "  <td>\n";
-                if ($allowchanges) {
-                    echo "      <textarea name=\"feedback_$i\" rows=\"3\" cols=\"75\" >\n";
-                    if (isset($grades[$i]->feedback)) {
-                        echo $grades[$i]->feedback;
-                        }
-                    echo "</textarea>\n";
-                    }
-                else {
-                    echo format_text($grades[$i]->feedback);
-                    }
-                echo "  </td>\n";
-                echo "</tr>\n";
-
-                // if active and the teacher show stock comments...
-                if ($allowchanges and workshop_is_teacher($workshop, $USER->id)) {
-                    echo "<tr><td valign=\"top\" align=\"right\"><input type=\"button\" value=\"".
-                        get_string("addcomment", "workshop")."\" 
-                        onclick=\"getElementById('assessmentform').action.value='addstockcomment';
-                        getElementById('assessmentform').elementno.value=$i;getElementById('assessmentform').submit();\" /> \n";
-                    helpbutton("addcommenttobank", get_string("addcomment", "workshop"), "workshop");
-                    echo "</td><td>\n";
-                    if ($stockcomments = get_records_select("workshop_stockcomments", "workshopid = $workshop->id
-                            AND elementno = $i", "id")) { // show comments in fixed order (oldest first)
-                        foreach ($stockcomments as $stockcomment) {
-                            echo "<a onclick=\"getElementById('assessmentform').feedback_$i.value+=' '+'".
-                                addslashes($stockcomment->comments)."';\">&lt;&lt;$stockcomment->comments&gt;&gt;</a>\n";
-                            if (workshop_is_teacheredit($workshop, $USER->id)) {
-                                echo " <a onclick=\"getElementById('assessmentform').action.value='removestockcomment';getElementById('assessmentform').stockcommentid.value=$stockcomment->id;getElementById('assessmentform').submit();\"> <small><i>&lt;--".get_string("delete","workshop")."</i></small></a>\n";
-                            }
-                            echo "<br />\n";
-                        }
-                    } 
-                    echo "</td></tr>\n";
-                }
-
-                echo "<tr valign=\"top\">\n";
-                echo "  <td colspan=\"2\" class=\"workshopassessmentheading\">&nbsp;</td>\n";
-                echo "</tr>\n";
-                }
-            break;
-            
-        case 1: // accumulative grading
-            // now print the form
-            for ($i=0; $i < count($elements); $i++) {
-                $iplus1 = $i+1;
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"right\"><p><b>". get_string("element","workshop")." $iplus1:</b></p></td>\n";
-                echo "  <td>".format_text($elements[$i]->description);
-                echo "<p style=\"text-align:right\">".get_string("weight", "workshop").": ".
-                    number_format($WORKSHOP_EWEIGHTS[$elements[$i]->weight], 2)."</p>\n";
-                echo "</td></tr>\n";
-                if ($showgrades) {
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td align=\"right\"><p><b>". get_string("grade"). ":</b></p></td>\n";
-                    echo "  <td valign=\"top\">\n";
-                    
-                    // get the appropriate scale
-                    $scalenumber=$elements[$i]->scale;
-                    $SCALE = (object)$WORKSHOP_SCALES[$scalenumber];
-                    switch ($SCALE->type) {
-                        case 'radio' :
-                                // show selections highest first
-                                echo "<div class=\"boxaligncenter\"><b>$SCALE->start</b>&nbsp;&nbsp;&nbsp;";
-                                for ($j = $SCALE->size - 1; $j >= 0 ; $j--) {
-                                    $checked = false;
-                                    if (isset($grades[$i]->grade)) { 
-                                        if ($j == $grades[$i]->grade) {
-                                            $checked = true;
-                                            }
-                                        }
-                                    else { // there's no previous grade so check the lowest option
-                                        if ($j == 0) {
-                                            $checked = true;
-                                            }
-                                        }
-                                    if ($checked) {
-                                        echo " <input type=\"radio\" name=\"grade[$i]\" value=\"$j\" checked=\"checked\" alt=\"$j\" /> &nbsp;&nbsp;&nbsp;\n";
-                                        }
-                                    else {
-                                        echo " <input type=\"radio\" name=\"grade[$i]\" value=\"$j\" alt=\"$j\" /> &nbsp;&nbsp;&nbsp;\n";
-                                        }
-                                    }
-                                echo "&nbsp;&nbsp;&nbsp;<b>$SCALE->end</b></div>\n";
-                                break;
-                        case 'selection' :  
-                                unset($numbers);
-                                for ($j = $SCALE->size; $j >= 0; $j--) {
-                                    $numbers[$j] = $j;
-                                    }
-                                if (isset($grades[$i]->grade)) {
-                                    choose_from_menu($numbers, "grade[$i]", $grades[$i]->grade, "");
-                                    }
-                                else {
-                                    choose_from_menu($numbers, "grade[$i]", 0, "");
-                                    }
-                                break;
-                        }
-            
-                    echo "  </td>\n";
-                    echo "</tr>\n";
-                    }
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"right\"><p><b>". get_string("feedback").":</b></p></td>\n";
-                echo "  <td>\n";
-                if ($allowchanges) {
-                    echo "      <textarea name=\"feedback_$i\" rows=\"3\" cols=\"75\" >\n";
-                    if (isset($grades[$i]->feedback)) {
-                        echo $grades[$i]->feedback;
-                        }
-                    echo "</textarea>\n";
-                    }
-                else {
-                    echo format_text($grades[$i]->feedback);
-                    }
-                echo "  </td>\n";
-                echo "</tr>\n";
-                
-                // if active and the teacher show stock comments...
-                if ($allowchanges and workshop_is_teacher($workshop, $USER->id)) {
-                    echo "<tr><td valign=\"top\" align=\"right\"><input type=\"button\" value=\"".
-                        get_string("addcomment", "workshop")."\" 
-                        onclick=\"getElementById('assessmentform').action.value='addstockcomment';
-                        getElementById('assessmentform').elementno.value=$i;getElementById('assessmentform').submit();\" /> \n";
-                    helpbutton("addcommenttobank", get_string("addcomment", "workshop"), "workshop");
-                    echo "</td><td>\n";
-                    if ($stockcomments = get_records_select("workshop_stockcomments", "workshopid = $workshop->id
-                            AND elementno = $i", "id")) { // get comments in a fixed order - oldest first
-                        foreach ($stockcomments as $stockcomment) {
-                            echo "<a onclick=\"getElementById('assessmentform').feedback_$i.value+=' '+'".
-                                addslashes($stockcomment->comments).
-                                "';\">&lt;&lt;$stockcomment->comments&gt;&gt;</a>\n";
-                            if (workshop_is_teacheredit($workshop, $USER->id)) {
-                                echo " <a onclick=\"getElementById('assessmentform').action.value='removestockcomment';getElementById('assessmentform').stockcommentid.value=$stockcomment->id;getElementById('assessmentform').submit();\"> <small><i>&lt;--".get_string("delete","workshop")."</i></small></a>\n";
-                            }
-                            echo "<br />\n";
-                        }
-                    } 
-                    echo "</td></tr>\n";
-                }
-
-                echo "<tr valign=\"top\">\n";
-                echo "  <td colspan=\"2\" class=\"workshopassessmentheading\">&nbsp;</td>\n";
-                echo "</tr>\n";
-                }
-            break;
-            
-        case 2: // error banded grading
-            // now run through the elements
-            $negativecount = 0;
-            for ($i=0; $i < count($elements) - 1; $i++) {
-                $iplus1 = $i+1;
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"right\"><p><b>". get_string("element","workshop")." $iplus1:</b></p></td>\n";
-                echo "  <td>".format_text($elements[$i]->description);
-                echo "<p style=\"text-align:right\">".get_string("weight", "workshop").": ".
-                    number_format($WORKSHOP_EWEIGHTS[$elements[$i]->weight], 2)."\n";
-                echo "</td></tr>\n";
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"right\"><p><b>". get_string("grade"). ":</b></p></td>\n";
-                echo "  <td valign=\"top\">\n";
-                    
-                // get the appropriate scale - yes/no scale (0)
-                $SCALE = (object) $WORKSHOP_SCALES[0];
-                switch ($SCALE->type) {
-                    case 'radio' :
-                            // show selections highest first
-                            echo "<div class=\"boxaligncenter\"><b>$SCALE->start</b>&nbsp;&nbsp;&nbsp;";
-                            for ($j = $SCALE->size - 1; $j >= 0 ; $j--) {
-                                $checked = false;
-                                if (isset($grades[$i]->grade)) { 
-                                    if ($j == $grades[$i]->grade) {
-                                        $checked = true;
-                                        }
-                                    }
-                                else { // there's no previous grade so check the lowest option
-                                    if ($j == 0) {
-                                        $checked = true;
-                                        }
-                                    }
-                                if ($checked) {
-                                    echo " <input type=\"radio\" name=\"grade[$i]\" value=\"$j\" checked=\"checked\" alt=\"$j\" /> &nbsp;&nbsp;&nbsp;\n";
-                                    }
-                                else {
-                                    echo " <input type=\"radio\" name=\"grade[$i]\" value=\"$j\" alt=\"$j\" /> &nbsp;&nbsp;&nbsp;\n";
-                                    }
-                                }
-                            echo "&nbsp;&nbsp;&nbsp;<b>$SCALE->end</b></div>\n";
-                            break;
-                    case 'selection' :  
-                            unset($numbers);
-                            for ($j = $SCALE->size; $j >= 0; $j--) {
-                                $numbers[$j] = $j;
-                                }
-                            if (isset($grades[$i]->grade)) {
-                                choose_from_menu($numbers, "grade[$i]", $grades[$i]->grade, "");
-                                }
-                            else {
-                                choose_from_menu($numbers, "grade[$i]", 0, "");
-                                }
-                            break;
-                    }
-        
-                echo "  </td>\n";
-                echo "</tr>\n";
-                echo "<tr valign=\"top\">\n";
-                echo "  <td align=\"right\"><p><b>". get_string("feedback").":</b></p></td>\n";
-                echo "  <td>\n";
-                if ($allowchanges) {
-                    echo "      <textarea name=\"feedback_$i\" rows=\"3\" cols=\"75\" >\n";
-                    if (isset($grades[$i]->feedback)) {
-                        echo $grades[$i]->feedback;
-                        }
-                    echo "</textarea>\n";
-                    }
-                else {
-                    if (isset($grades[$i]->feedback)) {
-                        echo format_text($grades[$i]->feedback);
-                        }
-                    }
-                echo "&nbsp;</td>\n";
-                echo "</tr>\n";
-
-                // if active and the teacher show stock comments...
-                if ($allowchanges and workshop_is_teacher($workshop, $USER->id)) {
-                    echo "<tr><td valign=\"top\" align=\"right\"><input type=\"button\" value=\"".
-                        get_string("addcomment", "workshop")."\" 
-                        onclick=\"getElementById('assessmentform').action.value='addstockcomment';
-                        getElementById('assessmentform').elementno.value=$i;getElementById('assessmentform').submit();\" /> \n";
-                    helpbutton("addcommenttobank", get_string("addcomment", "workshop"), "workshop");
-                    echo "</td><td>\n";
-                    if ($stockcomments = get_records_select("workshop_stockcomments", "workshopid = $workshop->id
-                            AND elementno = $i", "id")) { // get comments in a fixed order - oldest first
-                        foreach ($stockcomments as $stockcomment) {
-                            echo "<a onclick=\"getElementById('assessmentform').feedback_$i.value+=' '+'".
-                                addslashes($stockcomment->comments).
-                                "';\">&lt;&lt;$stockcomment->comments&gt;&gt;</a>\n";
-                            if (workshop_is_teacheredit($workshop, $USER->id)) {
-                                echo " <a onclick=\"getElementById('assessmentform').action.value='removestockcomment';getElementById('assessmentform').stockcommentid.value=$stockcomment->id;getElementById('assessmentform').submit();\"> <small><i>&lt;--".get_string("delete","workshop")."</i></small></a>\n";
-                            }
-                            echo "<br />\n";
-                        }
-                    } 
-                    echo "</td></tr>\n";
-                }
-                echo "<tr valign=\"top\">\n";
-                echo "  <td colspan=\"2\" class=\"workshopassessmentheading\">&nbsp;</td>\n";
-                echo "</tr>\n";
-                if (empty($grades[$i]->grade)) {
-                    $negativecount++;
-                    }
-                }
-            // print the number of negative elements
-            // echo "<tr><td>".get_string("numberofnegativeitems", "workshop")."</td><td>$negativecount</td></tr>\n";
-            // echo "<tr valign=\"top\">\n";
-            // echo "   <td colspan=\"2\" class=\"workshopassessmentheading\">&nbsp;</td>\n";
-            echo "</table></div>\n";
-            // now print the grade table
-            echo "<p><div style=\"text-align:center;\"><b>".get_string("gradetable","workshop")."</b></div>\n";
-            echo "<div class=\"boxaligncenter\"><table cellpadding=\"5\" border=\"1\"><tr><td align=\"CENTER\">".
-                get_string("numberofnegativeresponses", "workshop");
-            echo "</td><td>". get_string("suggestedgrade", "workshop")."</td></tr>\n";
-            for ($j = 100; $j >= 0; $j--) {
-                $numbers[$j] = $j;
-                }
-            for ($i=0; $i<=$workshop->nelements; $i++) {
-                if ($i == $negativecount) {
-                    echo "<tr><td align=\"CENTER\"><img src=\"$CFG->pixpath/t/right.gif\" alt=\"\" /> $i</td><td align=\"center\">{$elements[$i]->maxscore}</td></tr>\n";
-                    }
-                else {
-                    echo "<tr><td align=\"CENTER\">$i</td><td align=\"CENTER\">{$elements[$i]->maxscore}</td></tr>\n";
-                    }
-                }
-            echo "</table></div>\n";
-            echo "<p><div class=\"boxaligncenter\"><table cellpadding=\"5\" border=\"1\"><tr><td><b>".get_string("optionaladjustment", 
-                    "workshop")."</b></td><td>\n";
-            unset($numbers);
-            for ($j = 20; $j >= -20; $j--) {
-                $numbers[$j] = $j;
-                }
-            if (isset($grades[$workshop->nelements]->grade)) {
-                choose_from_menu($numbers, "grade[$workshop->nelements]", $grades[$workshop->nelements]->grade, "");
-                }
-            else {
-                choose_from_menu($numbers, "grade[$workshop->nelements]", 0, "");
-                }
-            echo "</td></tr>\n";
-            break;
-            
-        case 3: // criteria grading
-            echo "<tr valign=\"top\">\n";
-            echo "  <td class=\"workshopassessmentheading\">&nbsp;</td>\n";
-            echo "  <td class=\"workshopassessmentheading\"><b>". get_string("criterion","workshop")."</b></td>\n";
-            echo "  <td class=\"workshopassessmentheading\"><b>".get_string("select", "workshop")."</b></td>\n";
-            echo "  <td class=\"workshopassessmentheading\"><b>".get_string("suggestedgrade", "workshop")."</b></td>\n";
-            // find which criteria has been selected (saved in the zero element), if any
-            if (isset($grades[0]->grade)) {
-                $selection = $grades[0]->grade;
-                }
-            else {
-                $selection = 0;
-                }
-            // now run through the elements
-            for ($i=0; $i < count($elements); $i++) {
-                $iplus1 = $i+1;
-                echo "<tr valign=\"top\">\n";
-                echo "  <td>$iplus1</td><td>".format_text($elements[$i]->description)."</td>\n";
-                if ($selection == $i) {
-                    echo "  <td align=\"center\"><input type=\"radio\" name=\"grade[0]\" value=\"$i\" checked=\"checked\" alt=\"$i\" /></td>\n";
-                    }
-                else {
-                    echo "  <td align=\"center\"><input type=\"radio\" name=\"grade[0]\" value=\"$i\" alt=\"$i\" /></td>\n";
-                    }
-                echo "<td align=\"center\">{$elements[$i]->maxscore}</td></tr>\n";
-                }
-            echo "</table></div>\n";
-            echo "<p><div class=\"boxaligncenter\"><table cellpadding=\"5\" border=\"1\"><tr><td><b>".get_string("optionaladjustment", 
-                    "workshop")."</b></td><td>\n";
-            unset($numbers);
-            for ($j = 20; $j >= -20; $j--) {
-                $numbers[$j] = $j;
-                }
-            if (isset($grades[1]->grade)) {
-                choose_from_menu($numbers, "grade[1]", $grades[1]->grade, "");
-                }
-            else {
-                choose_from_menu($numbers, "grade[1]", 0, "");
-                }
-            echo "</td></tr>\n";
-            break;
-            
-        case 4: // rubric grading
-            // now run through the elements...
-            for ($i=0; $i < count($elements); $i++) {
-                $iplus1 = $i+1;
-                echo "<tr valign=\"top\">\n";
-                echo "<td align=\"right\"><b>".get_string("element", "workshop")." $iplus1:</b></td>\n";
-                echo "<td>".format_text($elements[$i]->description).
-                     "<p style=\"text-align:right\">".get_string("weight", "workshop").": ".
-                    number_format($WORKSHOP_EWEIGHTS[$elements[$i]->weight], 2)."</td></tr>\n";
-                echo "<tr valign=\"top\">\n";
-                echo "  <td class=\"workshopassessmentheading\" align=\"center\"><b>".get_string("select", "workshop").
-                    "</b></td>\n";
-                echo "  <td class=\"workshopassessmentheading\"><b>". get_string("criterion","workshop").
-                    "</b></td></tr>\n";
-                if (isset($grades[$i])) {
-                    $selection = $grades[$i]->grade;
-                } else {
-                    $selection = 0;
-                }
-                // ...and the rubrics
-                if ($rubricsraw = get_records_select("workshop_rubrics", "workshopid = $workshop->id AND 
-                        elementno = $i", "rubricno ASC")) {
-                    unset($rubrics);
-                    foreach ($rubricsraw as $rubic) {
-                        $rubrics[] = $rubic;   // to renumber index 0,1,2...
-                    }
-                    for ($j=0; $j<5; $j++) {
-                        if (empty($rubrics[$j]->description)) {
-                            break; // out of inner for loop
-                        }
-                        echo "<tr valign=\"top\">\n";
-                        if ($selection == $j) {
-                            echo "  <td align=\"center\"><input type=\"radio\" name=\"grade[$i]\" value=\"$j\" 
-                                checked=\"checked\" alt=\"$j\" /></td>\n";
-                        } else {
-                            echo "  <td align=\"center\"><input type=\"radio\" name=\"grade[$i]\" value=\"$j\" 
-                                alt=\"$j\" /></td>\n";
-                        }
-                        echo "<td>".format_text($rubrics[$j]->description)."</td>\n";
-                    }
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td align=\"right\"><p><b>". get_string("feedback").":</b></p></td>\n";
-                    echo "  <td>\n";
-                    if ($allowchanges) {
-                        echo "      <textarea name=\"feedback_$i\" rows=\"3\" cols=\"75\" >\n";
-                        if (isset($grades[$i]->feedback)) {
-                            echo $grades[$i]->feedback;
-                        }
-                        echo "</textarea>\n";
-                    } else {
-                        echo format_text($grades[$i]->feedback);
-                    }
-                    echo "  </td>\n";
-                    echo "</tr>\n";
-
-                    // if active and the teacher show stock comments...
-                    if ($allowchanges and workshop_is_teacher($workshop, $USER->id)) {
-                    echo "<tr><td valign=\"top\" align=\"right\"><input type=\"button\" value=\"".
-                        get_string("addcomment", "workshop")."\" 
-                        onclick=\"getElementById('assessmentform').action.value='addstockcomment';
-                        getElementById('assessmentform').elementno.value=$i;getElementById('assessmentform').submit();\" /> \n";
-                    helpbutton("addcommenttobank", get_string("addcomment", "workshop"), "workshop");
-                    echo "</td><td>\n";
-                        if ($stockcomments = get_records_select("workshop_stockcomments", "workshopid = $workshop->id
-                                    AND elementno = $i", "id")) { // show comments in fixed (creation) order
-                            foreach ($stockcomments as $stockcomment) {
-                                echo "<a onclick=\"getElementById('assessmentform').feedback_$i.value+=' '+'".
-                                    addslashes($stockcomment->comments).
-                                    "';\">&lt;&lt;$stockcomment->comments&gt;&gt;</a>\n";
-                                if (workshop_is_teacheredit($workshop, $USER->id)) {
-                                    echo " <a onclick=\"getElementById('assessmentform').action.value='removestockcomment';getElementById('assessmentform').stockcommentid.value=$stockcomment->id;getElementById('assessmentform').submit();\"> <small><i>&lt;--".get_string("delete","workshop")."</i></small></a>\n";
-                                }
-                                echo "<br />\n";
-                            }
-                        } 
-                        echo "</td></tr>\n";
-                    }
-
-                    echo "<tr valign=\"top\">\n";
-                    echo "  <td colspan=\"2\" class=\"workshopassessmentheading\">&nbsp;</td>\n";
-                    echo "</tr>\n";
-                }
-            }
-            break;
-        } // end of outer switch
-    
-        // now get the general comment (present in all types)
-        echo "<tr valign=\"top\">\n";
-        switch ($workshop->gradingstrategy) {
-            case 0:
-            case 1:
-            case 4 : // no grading, accumulative and rubic
-                echo "  <td align=\"right\"><p><b>". get_string("generalcomment", "workshop").":</b></p></td>\n";
-                break; 
-            default : 
-                echo "  <td align=\"right\"><p><b>".get_string("generalcomment", "workshop")."/<br />".
-                    get_string("reasonforadjustment", "workshop").":</b></p></td>\n";
-        }
-        echo "  <td>\n";
-        if ($allowchanges) {
-            echo "      <textarea name=\"generalcomment\" rows=\"5\" cols=\"75\" >\n";
-            if (isset($assessment->generalcomment)) {
-                echo $assessment->generalcomment;
-            }
-            echo "</textarea>\n";
-        } else {
-        if ($assessment) {
-            if (isset($assessment->generalcomment)) {
-                echo format_text($assessment->generalcomment);
-            }
-        } else {
-            print_string("yourfeedbackgoeshere", "workshop");
-        }
-    }
-    echo "&nbsp;</td>\n";
-    echo "</tr>\n";
-    // if active and the teacher show stock comments...
-    if ($allowchanges and workshop_is_teacher($workshop, $USER->id)) {
-        echo "<tr><td valign=\"top\" align=\"right\"><input type=\"button\" value=\"".
-            get_string("addcomment", "workshop")."\" 
-            onclick=\"getElementById('assessmentform').action.value='addstockcomment';
-        getElementById('assessmentform').elementno.value=99;getElementById('assessmentform').submit();\" /> \n";
-        helpbutton("addcommenttobank", get_string("addcomment", "workshop"), "workshop");
-        echo "</td><td>\n";
-        if ($stockcomments = get_records_select("workshop_stockcomments", "workshopid = $workshop->id
-                    AND elementno = 99", "id")) { // show in the same order (oldest at the top)
-            foreach ($stockcomments as $stockcomment) {
-                echo "<a onclick=\"getElementById('assessmentform').generalcomment.value+=' '+'".
-                    addslashes($stockcomment->comments)."';\">&lt;&lt;$stockcomment->comments&gt;&gt;</a>\n";
-                if (workshop_is_teacheredit($workshop, $USER->id)) {
-                    echo " <a onclick=\"getElementById('assessmentform').action.value='removestockcomment';getElementById('assessmentform').stockcommentid.value=$stockcomment->id;getElementById('assessmentform').submit();\"> <small><i>&lt;--".get_string("delete","workshop")."</i></small></a>\n";
-                }
-                echo "<br />\n";
-            }
-        } 
-        echo "</td></tr>\n";
-    }
-    
-    $timenow = time();
-    // now show the grading grade if available...
-    if ($assessment and $assessment->timegraded) {
-        echo "<tr valign=\"top\">\n";
-        echo "<td colspan=\"2\" class=\"workshopassessmentheading\" align=\"center\"><b>".
-            get_string('gradeforstudentsassessment', 'workshop')."</b></td>\n";
-        echo "</tr>\n";
-        
-        if ($assessment->teachercomment) {
-            echo "<tr valign=top>\n";
-            echo "  <td align=\"right\"><p><b>". get_string("teacherscomment", "workshop").":</b></p></td>\n";
-            echo "  <td>\n";
-            echo text_to_html($assessment->teachercomment);
-            echo "&nbsp;</td>\n";
-            echo "</tr>\n";
-        }
-
-        echo "<tr valign=\"top\">\n";
-        echo "  <td align=\"right\"><p><b>";
-        print_string('grade', 'workshop');
-        echo ":</b></p></td><td>\n";
-        echo number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0);
-        echo "&nbsp;</td>\n";
-        echo "</tr>\n";
-    }
-    
-    echo "<tr valign=\"top\">\n";
-    echo "  <td colspan=\"2\" class=\"workshopassessmentheading\">&nbsp;</td>\n";
-    echo "</tr>\n";
-            
-    // ...and close the table, show submit button if needed...
-    echo "</table>\n";
-    if ($assessment) {
-        if ($allowchanges) {  
-            echo "<input type=\"submit\" value=\"".get_string("savemyassessment", "workshop")."\" />\n";
-        }
-        // ...if user is author, assessment not agreed, there's no comments, the showcommentlinks flag is set and 
-        // it's not self assessment then show some buttons!
-        if (($submission->userid == $USER->id) and !$assessment->timeagreed and !$comments and $showcommentlinks and 
-                $submission->userid != $assessment->userid) {
-            echo "<input type=\"button\" value=\"".get_string("agreetothisassessment", "workshop")."\" 
-                onclick=\"getElementById('assessmentform').action.value='agreeassessment';getElementById('assessmentform').submit();\" />\n";
-            echo "<input type=\"submit\" value=\"".get_string("disagreewiththisassessment", "workshop")."\"
-                onclick=\"getElementById('assessmentform').action.value='addcomment';getElementById('assessmentform').submit();\" />\n";
-        }
-    }
-    echo "</div>";
-    echo "</div></form>\n";
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_print_assessments_by_user_for_admin($workshop, $user) {
-
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        print_error("Course Module ID was incorrect");
-    }
-
-    if ($assessments = workshop_get_user_assessments_done($workshop, $user)) {
-        foreach ($assessments as $assessment) {
-            workshop_print_assessment($workshop, $assessment);
-            echo "<p style=\"text-align:right\">".
-                '<a href="viewassessment.php?&amp;id='.$cm->id.'&amp;stype=student&amp;aid='.$assessment->id.'">'.
-                get_string('assessthisassessment', 'workshop').'</a> | '.
-                "<a href=\"assessments.php?action=confirmdelete&amp;id=$cm->id&amp;aid=$assessment->id\">".
-                get_string("delete", "workshop")."</a></p><hr />\n";
-            }
-        }
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_print_assessments_for_admin($workshop, $submission) {
-
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        print_error("Course Module ID was incorrect");
-    }
-
-    if ($assessments =workshop_get_assessments($submission)) {
-        foreach ($assessments as $assessment) {
-            if (!$user = get_record("user", "id", $assessment->userid)) {
-                error (" workshop_print_assessments_for_admin: unable to get user record");
-                }
-            echo "<p><div style=\"text-align:center;\"><b>".get_string("assessmentby", "workshop", fullname($user))."</b></div></p>\n";
-            workshop_print_assessment($workshop, $assessment);
-            echo "<p style=\"text-align:right\"><a href=\"assessments.php?action=confirmdelete&amp;id=$cm->id&amp;aid=$assessment->id\">".
-                get_string("delete", "workshop")."</a></p><hr />\n";
-            }
-        }
-    }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_print_assignment_info($workshop) {
-    global $CFG;
-
-    if (! $course = get_record("course", "id", $workshop->course)) {
-        print_error("Course is misconfigured");
-    }
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
-        print_error("Course Module ID was incorrect");
-    }
-    // print standard assignment heading
-    print_heading(format_string($workshop->name), "center");
-    print_simple_box_start("center");
-
-    // print phase and date info
-    $string = '<b>'.get_string('currentphase', 'workshop').'</b>: '.workshop_phase($workshop).'<br />';
-    $dates = array(
-        'submissionstart' => $workshop->submissionstart,
-        'submissionend' => $workshop->submissionend,
-        'assessmentstart' => $workshop->assessmentstart,
-        'assessmentend' => $workshop->assessmentend
-    );
-    foreach ($dates as $type => $date) {
-        if ($date) {
-            $strdifference = format_time($date - time());
-            if (($date - time()) < 0) {
-                $strdifference = "<span class=\"redfont\">$strdifference</span>";
-            }
-            $string .= '<b>'.get_string($type, 'workshop').'</b>: '.userdate($date)." ($strdifference)<br />";
-        }
-    }
-    echo $string;
-
-    $grade = $workshop->gradinggrade + $workshop->grade;
-    echo "<br /><b>".get_string("maximumgrade")."</b>: $grade  ";
-    // print link to specimen assessment form
-    echo "(<a href=\"assessments.php?id=$cm->id&amp;action=displaygradingform\">".
-        get_string("specimenassessmentform", "workshop")."</a>";
-    // print edit icon
-    if (workshop_is_teacheredit($workshop) and $workshop->nelements) {
-        echo " <a href=\"assessments.php?id=$cm->id&amp;action=editelements\">".
-             "<img src=\"$CFG->pixpath/t/edit.gif\" ".
-             'class="iconsmall" alt="'.get_string('amendassessmentelements', 'workshop').'" /></a>';
-    }
-    echo ")<br />";
-    print_simple_box_end();
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_print_difference($time) {
-    if ($time < 0) {
-        $timetext = get_string("late", "assignment", format_time($time));
-        return " (<span class=\"redfont\">$timetext</span>)";
-    } else {
-        $timetext = get_string("early", "assignment", format_time($time));
-        return " ($timetext)";
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_print_key($workshop) {
-    // print an explaination of the grades
-    
-    if (!$course = get_record("course", "id", $workshop->course)) {
-        print_error("Print key: course not found");
-    }
-    echo "<div class=\"workshopkey\">\n";
-    echo "<p><small>{} ".get_string("assessmentby", "workshop", $course->student).";&nbsp;&nbsp;\n";
-    echo "[] ".get_string("assessmentby", "workshop", $course->teacher).";&nbsp;&nbsp;\n";
-    echo "&lt;&gt; ".get_string("assessmentdropped", "workshop").";\n";
-    if ($workshop->agreeassessments) echo "&lt;&lt;&gt;&gt; ".get_string("assessmentnotyetagreed", "workshop").";\n";
-    echo "<br />() ".get_string("automaticgradeforassessment", "workshop").";&nbsp;&nbsp;\n";
-    echo "[] ".get_string("teachergradeforassessment", "workshop", $course->teacher).".\n";
-    echo "<br />".get_string("gradesforsubmissionsare", "workshop", $workshop->grade).";&nbsp;&nbsp;\n";
-    echo get_string("gradesforassessmentsare", "workshop", $workshop->gradinggrade).".</small></p>\n";
-    echo "</div>\n";
-    return;    
-}
-    
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_print_league_table($workshop) {
-    // print an order table of (student) submissions showing teacher's and student's assessments
-    
-    if (! $course = get_record("course", "id", $workshop->course)) {
-        print_error("Print league table: Course is misconfigured");
-    }
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-            print_error("Course Module ID was incorrect");
-    }
-    // set $groupid if workshop is in SEPARATEGROUPS mode
-    if (groupmode($course, $cm) == SEPARATEGROUPS) {
-        $groupid = get_current_group($course->id);
-    } else {
-        $groupid = 0;
-    }
-    $nentries = $workshop->showleaguetable;
-    if ($workshop->anonymous and workshop_is_student($workshop)) {
-        $table->head = array (get_string("title", "workshop"), 
-            get_string("teacherassessments", "workshop", $course->teacher),  
-            get_string("studentassessments", "workshop",    $course->student), get_string("overallgrade", "workshop"));
-        $table->align = array ("left",  "center", "center", "center");
-        $table->size = array ("*", "*", "*", "*");
-    }
-    else { // show names
-        $table->head = array (get_string("title", "workshop"),  get_string("name"),
-            get_string("teacherassessments", "workshop", $course->teacher),  
-            get_string("studentassessments", "workshop",    $course->student), get_string("overallgrade", "workshop"));
-        $table->align = array ("left", "left", "center", "center", "center");
-        $table->size = array ("*", "*", "*", "*", "*");
-    }
-    $table->cellpadding = 2;
-    $table->cellspacing = 0;
-
-    if ($submissions = workshop_get_student_submissions($workshop)) {
-        foreach ($submissions as $submission) {
-            if ($groupid) {
-                // check submission's group
-                if (!groups_is_member($groupid, $submission->userid)) {
-                    continue; // skip this submission
-                }
-            }
-            $grades[$submission->id] = workshop_submission_grade($workshop, $submission);
-        }
-        arsort($grades); // largest grade first
-        reset($grades);
-        $n = 1;
-        while (list($submissionid, $grade) = each($grades)) {
-            if (!$submission = get_record("workshop_submissions", "id", $submissionid)) {
-                print_error("Print league table: submission not found");
-            }
-            if (!$user = get_record("user", "id", $submission->userid)) {
-                print_error("Print league table: user not found");
-            }
-            if ($workshop->anonymous and workshop_is_student($workshop)) {
-                $table->data[] = array(workshop_print_submission_title($workshop, $submission),
-                        workshop_print_submission_assessments($workshop, $submission, "teacher"),
-                        workshop_print_submission_assessments($workshop, $submission, "student"), $grade);
-            }
-            else {
-                $table->data[] = array(workshop_print_submission_title($workshop, $submission), fullname($user),
-                        workshop_print_submission_assessments($workshop, $submission, "teacher"),
-                        workshop_print_submission_assessments($workshop, $submission, "student"), $grade);
-            }
-            $n++;
-            if ($n > $nentries) {
-                break;
-            }
-        }
-        print_heading(get_string("leaguetable", "workshop"));
-        print_table($table);
-        workshop_print_key($workshop);
-    }
-}
-    
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_print_submission($workshop, $submission) {
-    // prints the submission with optional attachments
-    global $CFG;
-
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-            print_error("Course Module ID was incorrect");
-    }
-    print_simple_box(format_text($submission->description), 'center');
-    if ($workshop->nattachments) {
-        $n = 1;
-        echo "<table align=\"center\">\n";
-        $filearea = workshop_file_area_name($workshop, $submission);
-        if ($basedir = workshop_file_area($workshop, $submission)) {
-            if ($files = get_directory_list($basedir)) {
-                foreach ($files as $file) {
-                    $icon = mimeinfo("icon", $file);
-                    if ($CFG->slasharguments) {
-                        $ffurl = "file.php/$filearea/$file";
-                    } else {
-                        $ffurl = "file.php?file=/$filearea/$file";
-                    }
-                    echo "<tr><td><b>".get_string("attachment", "workshop")." $n:</b> \n";
-                    // removed target=\"uploadedfile\" as it does not validate
-                    // MDL-7861
-                    echo "<img src=\"$CFG->pixpath/f/$icon\" class=\"icon\" alt=\"".get_string('file')."\" />".
-                        "&nbsp;<a href=\"$CFG->wwwroot/$ffurl\">$file</a></td></tr>";
-                    $n++;
-                }
-            }
-        }
-        echo "</table>\n";
-    }
-    return;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_print_submission_assessments($workshop, $submission, $type) {
-    global $USER, $CFG;
-    // Returns the teacher or peer grade and a hyperlinked list of grades for this submission
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        print_error("Course Module ID was incorrect");
-    }
-    $str = '';
-    // get the assessments in grade order, highest first
-    if ($assessments = workshop_get_assessments($submission, "", "grade DESC")) {
-        if ($type == 'teacher' or $type == 'all') {
-            // students can see teacher assessments only if the release date has passed
-            $timenow = time();
-            if (workshop_is_teacher($workshop, $USER->id) or ($timenow > $workshop->releasegrades)) {
-                foreach ($assessments as $assessment) {
-                    if (workshop_is_teacher($workshop, $assessment->userid)) {
-                        if ($type == 'all') {
-                            $str .= workshop_fullname($assessment->userid, $workshop->course).': ';
-                        }
-                        $str .= "<a href=\"viewassessment.php?aid=$assessment->id\">"
-                             . "[".number_format($assessment->grade *$workshop->grade / 100, 0)."]</a>";
-                        if (workshop_is_teacher($workshop, $USER->id)) {
-                            $str .= ' <a title="'.get_string('reassess', 'workshop').
-                                "\" href=\"assess.php?id=$cm->id&amp;sid=$submission->id\"><img src=\"$CFG->pixpath/t/edit.gif\" ".
-                                ' class="iconsmall" alt="'.get_string('reassess', 'workshop').'" /></a>';
-                            $str .= ' <a title="'.get_string('delete', 'workshop').
-                                "\" href=\"assessments.php?action=confirmdelete&amp;wid=$workshop->id&amp;aid=$assessment->id\"><img src=\"$CFG->pixpath/t/delete.gif\" ".
-                                ' class="iconsmall" alt="'.get_string('delete', 'workshop').'" /></a><br />';
-                       }
-                    }
-                }
-            }
-        }
-        if ($type == 'student' or $type == 'all') {
-            foreach ($assessments as $assessment) {
-                if (workshop_is_student($workshop, $assessment->userid)) {
-                    if ($type == 'all') {
-                        $str .= workshop_fullname($assessment->userid, $workshop->course).': ';
-                    }
-                    $str .= "<a href=\"viewassessment.php?aid=$assessment->id\">";
-                    if ($workshop->agreeassessments and !$assessment->timeagreed and 
-                            workshop_is_student($workshop, $submission->userid)) { // agreement on student work only
-                        $str .= "&lt;&lt;".number_format($assessment->grade * $workshop->grade / 100, 0)." (".
-                            number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0).
-                            ")&gt;&gt;</a> ";
-                    } elseif ($assessment->timegraded) {
-                        if ($assessment->gradinggrade) {
-                            $str .= "{".number_format($assessment->grade * $workshop->grade / 100, 0);
-                            if ($assessment->teachergraded) {
-                                $str .= " [".number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0).
-                                "]}</a> ";
-                            } else {
-                                $str .= " (".number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0).
-                                ")}</a> ";
-                            }
-                        } else {
-                            $str .= "&lt;".number_format($assessment->grade * $workshop->grade / 100, 0).
-                                " (0)&gt;</a> ";
-                        }
-                    } else {
-                        $str .= "{".number_format($assessment->grade * $workshop->grade / 100, 0)."}</a> ";
-                    }
-                    $str .= '<br />';
-                }
-            }
-        }
-    }
-    if (!$str) {
-        $str = "&nbsp;";   // be kind to Mozilla browsers!
-    }
-    return $str;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_print_submission_title($workshop, $submission) {
-// Arguments are objects
-
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-            print_error("Course Module ID was incorrect");
-    }
-    
-    if (!$submission->timecreated) { // a "no submission"
-        return $submission->title;
-    }
-    return "<a name=\"sid_$submission->id\" href=\"submissions.php?id=$cm->id&amp;action=showsubmission&amp;sid=$submission->id\">$submission->title</a>";
-}
-
-
-
-function workshop_print_time_to_deadline($time) {
-    if ($time < 0) {
-        $timetext = get_string("afterdeadline", "workshop", format_time($time));
-        return " (<span class=\"redfont\">$timetext</span>)";
-    } else {
-        $timetext = get_string("beforedeadline", "workshop", format_time($time));
-        return " ($timetext)";
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_print_upload_form($workshop) {
-    global $CFG;
-
-    if (! $course = get_record("course", "id", $workshop->course)) {
-        print_error("Course is misconfigured");
-    }
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
-        print_error("Course Module ID was incorrect");
-    }
-    $usehtmleditor = can_use_html_editor();
-
-    echo "<div class=\"workshopuploadform\">";
-    echo "<form enctype=\"multipart/form-data\" method=\"POST\" action=\"upload.php\">";
-    echo "<fieldset class=\"invisiblefieldset\">";
-    echo " <input type=\"hidden\" name=\"id\" value=\"$cm->id\" />";
-    echo "<table celpadding=\"5\" border=\"1\" align=\"center\">\n";
-    // now get the submission
-    echo "<tr valign=\"top\"><td><b>". get_string("title", "workshop").":</b>\n";
-    echo "<input type=\"text\" name=\"title\" size=\"60\" maxlength=\"100\" value=\"\" />\n";
-    echo "</td></tr><tr><td><b>".get_string("submission", "workshop").":</b><br />\n";
-    print_textarea($usehtmleditor, 25,70, 630, 400, "description");
-    use_html_editor("description");
-    echo "</td></tr><tr><td>\n";
-    if ($workshop->nattachments) {
-        require_once($CFG->dirroot.'/lib/uploadlib.php');
-        for ($i=0; $i < $workshop->nattachments; $i++) {
-            $iplus1 = $i + 1;
-            $tag[$i] = get_string("attachment", "workshop")." $iplus1:";
-        }
-        upload_print_form_fragment($workshop->nattachments,null,$tag,false,null,$course->maxbytes,
-                $workshop->maxbytes,false);
-    }
-    echo "</td></tr></table>\n";
-    echo " <input type=\"submit\" name=\"save\" value=\"".get_string("submitassignment","workshop")."\" />";
-    echo "</fieldset></form>";
-    echo "</div>";
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_print_user_assessments($workshop, $user, &$gradinggrade) {
-    // Returns the number of assessments and a hyperlinked list of grading grades for the assessments made by this user
-
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-            print_error("Course Module ID was incorrect");
-    }
-    $gradinggrade = 0;
-    $n = 0;
-    $str = '';
-    if ($assessments = workshop_get_user_assessments_done($workshop, $user)) {
-        foreach ($assessments as $assessment) {
-            $gradinggrade += $assessment->gradinggrade;
-            $n++;
-            $str .= "<a href=\"viewassessment.php?aid=$assessment->id\">";
-            if ($assessment->timegraded) {
-                if ($assessment->gradinggrade) {
-                    $str .= "{".number_format($assessment->grade * $workshop->grade / 100, 0);
-                    if ($assessment->teachergraded) {
-                        $str .= " [".number_format($assessment->gradinggrade * $workshop->gradinggrade / 100)."]}</a> ";
-                    } else {
-                        $str .= " (".number_format($assessment->gradinggrade * $workshop->gradinggrade / 100).")}</a> ";
-                    }
-                } else {
-                    $str .= "&lt;".number_format($assessment->grade * $workshop->grade / 100, 0)." (0)&gt;</a> ";
-                }
-            } else {
-                $str .= "{".number_format($assessment->grade * $workshop->grade / 100, 0)." (-)}</a> ";
-            }
-            $str .= '<br />';
-        }
-    }
-    else {
-        $str ="0";
-    }
-    if ($n = max($n, $workshop->ntassessments + $workshop->nsassessments)) {
-        $gradinggrade = number_format($gradinggrade/$n * $workshop->gradinggrade / 100, 1);
-    }
-    
-    return $str;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_test_user_assessments($workshop, $user) {
-    // see if user has assessed required number of assessments of teachers submissions...
-    global $CFG;
-    
-    $result = true;
-    $n = 0;
-    $timenow =time();
-    if ($submissions = workshop_get_teacher_submissions($workshop)) {
-        foreach ($submissions as $submission) {
-            if ($assessment = workshop_get_submission_assessment($submission, $user)) {
-                // ...the date stamp on the assessment should be in the past 
-                if ($assessment->timecreated < $timenow) {
-                    $n++;
-                }
-            }
-        }
-        if ($n < min($workshop->ntassessments, workshop_count_teacher_submissions($workshop))) {
-            $result = false; 
-        }
-    }
-    return $result;
-}
-    
-
-?>
diff --git a/mod/workshop/mod.html b/mod/workshop/mod.html
deleted file mode 100644 (file)
index 6d012a4..0000000
+++ /dev/null
@@ -1,425 +0,0 @@
-<?php
-    require_once("$CFG->dirroot/mod/workshop/lib.php");  // for parameter arrays
-    require_once("$CFG->dirroot/mod/workshop/locallib.php");  // for parameter arrays
-
-    // ...and fill the form if needed
-    if (empty($form->name)) {
-        $form->name = "";
-    }
-    if (empty($form->description)) {
-        $form->description = "";
-    }
-    if (empty($form->format)) {
-        $form->format = "";
-    }
-    if (!isset($form->gradinggrade)) {
-        $form->gradinggrade = 100;
-    }
-    if (!isset($form->grade)) {
-        $form->grade = 100;
-    }
-    if (!isset($form->gradingstrategy)) {
-       $form->gradingstrategy = 1;  // default is accumulative
-    }
-    if (!isset($form->nelements)) {
-        $form->nelements = 1;
-    }
-    if (!isset($form->nattachments)) {
-        $form->nattachments = 0;
-    }
-    if (empty($form->resubmit)) {
-        $form->resubmit = "";
-    }
-    if (!isset($form->ntassessments)) {
-        $form->ntassessments = 0;
-    }
-    if (!isset($form->assessmentcomps)) {
-        $form->assessmentcomps = 2;
-    }
-    if (!isset($form->nsassessments)) {
-        $form->nsassessments = 0;
-    }
-    if (!isset($form->teacherweight)) {
-        $form->teacherweight = 1;
-    }
-    if (!isset($form->overallocation)) {
-        $form->overallocation = 0;
-    }
-    if (empty($form->includeself)) {
-        $form->includeself = "";
-    }
-    if (empty($form->agreeassessments)) {
-        $form->agreeassessments = "";
-    }
-    if (empty($form->hidegrades)) {
-        $form->hidegrades = "";
-    }
-    if (empty($form->showleaguetable)) {
-        $form->showleaguetable = 0;
-    }
-    if (empty($form->anonymous)) {
-        $form->anonymous = 0;
-    }
-    if (empty($form->usepassword)) {
-        $form->usepassword = 0;
-    }
-    if (empty($form->maxbytes)) {
-        $form->maxbytes = "";
-    }
-    if (empty($form->submissionstart)) {
-        $form->submissionstart = time();
-    }
-    if (empty($form->assessmentstart)) {
-        $form->assessmentstart = time();
-    }
-    if (empty($form->submissionend)) {
-        $form->submissionend = time();
-    }
-    if (empty($form->assessmentend)) {
-        $form->assessmentend = time();
-    }
-    if (empty($form->releasegrades)) {
-        $form->releasegrades = time();
-    }
-?>
-
-<form id="form" method="post" action="mod.php">
-<table cellpadding="5">
-<tr valign="top">
-    <td align="right"><b><?php  print_string("title", "workshop") ?>:</b></td>
-    <td>
-        <input type="text" name="name" size="60" value="<?php  p($form->name) ?>" alt="<?php  print_string("title", "workshop") ?>" />
-    </td>
-</tr>
-<tr valign="top">
-    <td align="right"><b><?php  print_string("description", "workshop") ?>:</b><br />
-     <?php
-        helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
-        echo "<br />";
-        if ($usehtmleditor) {
-           helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
-        } else {
-           helpbutton("text", get_string("helptext"), "moodle", true, true);
-           echo "<br />";
-           emoticonhelpbutton("form", "description", "moodle", true, true);
-           echo "<br />";
-        }
-      ?>
-      <br />
-    </td>
-    <td>
-    <?php
-       print_textarea($usehtmleditor, 20, 60, 595, 400, "description", $form->description);
-
-       if ($usehtmleditor) {
-           echo '<input type="hidden" name="format" value="'.FORMAT_HTML.'" />';
-       } else {
-           echo '<p style="text-align:right">';
-           helpbutton("textformat", get_string("formattexttype"));
-           print_string("formattexttype");
-           echo ':&nbsp;';
-           if (!$form->format) {
-               $form->format = $defaultformat;
-           }
-           choose_from_menu(format_text_menu(), "format", $form->format, "");
-           echo '</p>';
-       }
-    ?>
-    </td>
-</tr>
-
-<tr valign="top">
-    <td align="right"><b><?php  print_string("gradeforassessments", "workshop") ?>:</b></td>
-    <td>
-        <?php
-        for ($i=100; $i>=0; $i--) {
-            $grades[$i] = $i;
-        }
-        choose_from_menu($grades, "gradinggrade", "$form->gradinggrade", "");
-        helpbutton("gradinggrade", get_string("gradeforassessments", "workshop"), "workshop");
-        ?>
-    </td>
-</tr>
-
-<tr valign="top">
-    <td align="right"><b><?php  print_string("gradeforsubmission", "workshop") ?>:</b></td>
-    <td>
-        <?php
-        choose_from_menu($grades, "grade", "$form->grade", "");
-        helpbutton("grade", get_string("gradeforsubmission", "workshop"), "workshop");
-        ?>
-    </td>
-</tr>
-
-<tr valign="top">
-    <td align="right"><b><?php  print_string("gradingstrategy", "workshop") ?>:</b></td>
-    <td>
-    <?php
-       choose_from_menu($WORKSHOP_TYPE, "gradingstrategy", $form->gradingstrategy, "");
-       helpbutton("gradingstrategy", get_string("gradingstrategy", "workshop"), "workshop");
-    ?>
-    </td>
-</tr>
-
-<tr valign="top">
-    <td align="right"><b><?php  print_string("numberofassessmentelements", "workshop") ?>:</b></td>
-    <td valign="middle">
-        <?php
-        for ($i=20; $i>=0; $i--) {
-            $numbers[$i] = $i;
-        }
-        choose_from_menu($numbers, "nelements", "$form->nelements", "");
-       helpbutton("nelements", get_string("numberofassessmentelements", "workshop"), "workshop");
-        ?>
-    </td>
-</tr>
-
-<tr valign="top">
-    <td align="right"><b><?php  print_string("numberofattachments", "workshop") ?>:</b></td>
-    <td valign="middle">
-        <?php
-        unset($numbers);
-        for ($i=5; $i>=0; $i--) {
-            $numbers[$i] = $i;
-        }
-        choose_from_menu($numbers, "nattachments", "$form->nattachments", "");
-       helpbutton("nattachments", get_string("numberofattachments", "workshop"), "workshop");
-        ?>
-    </td>
-</tr>
-
-<tr>
-    <td align="right"><b><?php  print_string("allowresubmit", "workshop") ?>:</b></td>
-    <td>
-    <?php
-        $options[0] = get_string("no"); $options[1] = get_string("yes");
-        choose_from_menu($options, "resubmit", $form->resubmit, "");
-        helpbutton("resubmit", get_string("allowresubmit", "workshop"), "workshop");
-    ?>
-    </td>
-</tr>
-
-<tr valign="top">
-    <td align="right"><b><?php  print_string("numberofassessmentsofteachersexamples", "workshop") ?>:</b></td>
-    <td>
-        <?php
-        unset($numbers);
-        for ($i=20; $i>=0; $i--) {
-            $numbers[$i] = $i;
-        }
-        choose_from_menu($numbers, "ntassessments", $form->ntassessments, "");
-       helpbutton("nassessmentsofteachersexamples", get_string("numberofassessmentsofteachersexamples", "workshop"), "workshop");
-        ?>
-    </td>
-</tr>
-
-<tr>
-    <td align="right"><b><?php print_string("comparisonofassessments", "workshop") ?>:</b></td>
-    <td>
-        <?php
-        // set up comparison names
-        foreach ($WORKSHOP_ASSESSMENT_COMPS as $KEY => $COMPARISON) {
-            $COMPARISONS[] = $COMPARISON['name'];
-        }
-        choose_from_menu($COMPARISONS, "assessmentcomps", $form->assessmentcomps, "");
-        helpbutton("comparisonofassessments", get_string("comparisonofassessments", "workshop"), "workshop");
-    ?>
-    </td>
-</tr>
-
-<tr valign="top">
-    <td align="right"><b><?php  print_string("numberofassessmentsofstudentsubmissions", "workshop") ?>:</b></td>
-    <td>
-        <?php
-        unset($numbers);
-        for ($i=20; $i>=0; $i--) {
-            $numbers[$i] = $i;
-        }
-        choose_from_menu($numbers, "nsassessments", $form->nsassessments, "");
-       helpbutton("nassessmentsofstudentsubmissions", get_string("numberofassessmentsofstudentsubmissions", "workshop"), "workshop");
-        ?>
-    </td>
-</tr>
-
-<tr valign="top">
-    <td align="right"><b><?php  print_string("weightforteacherassessments", "workshop") ?>:</b></td>
-    <td>
-        <?php
-        unset($numbers);
-        for ($i=10; $i>=0; $i--) {
-            $numbers[$i] = $i;
-        }
-        choose_from_menu($numbers, "teacherweight", $form->teacherweight, "");
-       helpbutton("teacherweight", get_string("weightforteacherassessments", "workshop"), "workshop");
-        ?>
-    </td>
-</tr>
-
-<tr valign="top">
-    <td align="right"><b><?php print_string("overallocation", "workshop") ?>:</b></td>
-    <td>
-        <?php
-        unset($numbers);
-        for ($i=2; $i>=0; $i--) {
-            $numbers[$i] = $i;
-        }
-        choose_from_menu($numbers, "overallocation", "$form->overallocation", "");
-        helpbutton("overallocation", get_string("overallocation", "workshop"), "workshop");
-        ?>
-    </td>
-</tr>
-
-<tr>
-    <td align="right"><b><?php  print_string("selfassessment", "workshop") ?>:</b></td>
-    <td>
-    <?php
-        $options[0] = get_string("no"); $options[1] = get_string("yes");
-        choose_from_menu($options, "includeself", $form->includeself, "");
-        helpbutton("selfassessment", get_string("selfassessment", "workshop"), "workshop");
-    ?>
-    </td>
-</tr>
-
-<tr>
-    <td align="right"><b><?php  print_string("assessmentsmustbeagreed", "workshop") ?>:</b></td>
-    <td>
-    <?php
-        choose_from_menu($options, "agreeassessments", $form->agreeassessments, "");
-        helpbutton("agreeassessments", get_string("assessmentsmustbeagreed", "workshop"), "workshop");
-    ?>
-    </td>
-</tr>
-
-<tr>
-    <td align="right"><b><?php  print_string("hidegradesbeforeagreement", "workshop") ?>:</b></td>
-    <td>
-    <?php
-        choose_from_menu($options, "hidegrades", $form->hidegrades, "");
-        helpbutton("showinggrades", get_string("hidegradesbeforeagreement", "workshop"), "workshop");
-    ?>
-    </td>
-</tr>
-
-<tr>
-    <td align="right"><b><?php print_string("leaguetable", "workshop"); ?>:</b></td>
-    <td>
-    <?php
-        unset($numbers);
-        $numbers[22] = '100';
-        $numbers[21] = 50;
-        for ($i=20; $i>=0; $i--) {
-            $numbers[$i] = $i;
-        }
-        choose_from_menu($numbers, "showleaguetable", $form->showleaguetable, "");
-        helpbutton("leaguetable", get_string("leaguetable", "workshop"), "workshop");
-    ?>
-    </td>
-</tr>
-
-<tr>
-    <td align="right"><b><?php print_string("hidenamesfromstudents", "workshop", $course->students) ?>:</b></td>
-    <td>
-    <?php
-        choose_from_menu($options, "anonymous", $form->anonymous, "");
-        helpbutton("anonymous", get_string("hidenamesfromstudents", "workshop", $course->students), "workshop");
-    ?>
-    </td>
-</tr>
-
-<tr>
-    <td align="right"><b><?php  print_string("usepassword", "workshop"); ?>:</b></td>
-    <td>
-    <?php
-        $options[0] = get_string("no"); $options[1] = get_string("yes");
-        choose_from_menu($options, "usepassword", $form->usepassword, "");
-        helpbutton("password", get_string("usepassword", "workshop"), "workshop");
-    ?>
-    </td>
-</tr>
-
-<tr>
-    <td align="right"><b><?php  print_string("password"); ?>:</b></td>
-    <td>
-        <input type="text" name="password" size="10" value="" alt="<?php  print_string("password"); ?>" /> <?php echo " (".get_string("leavetokeep").")"; ?>
-        <?php helpbutton("password", get_string("password"), "workshop"); ?>
-    </td>
-</tr>
-
-<tr valign="top">
-    <td align="right"><b><?php  print_string("maximumsize", "workshop") ?>:</b></td>
-    <td>
-        <?php
-        $choices = get_max_upload_sizes($CFG->maxbytes, $course->maxbytes);
-        choose_from_menu($choices, "maxbytes", "$form->maxbytes","" );
-        ?>
-    </td>
-</tr>
-
-<tr valign="top">
-    <td align="right"><b><?php  print_string("submissionstart", "workshop") ?>:</b></td>
-    <td><?php
-            print_date_selector("submissionstartday", "submissionstartmonth", "submissionstartyear", $form->submissionstart);
-            echo "&nbsp;-&nbsp;";
-            print_time_selector("submissionstarthour", "submissionstartminute", $form->submissionstart);
-            helpbutton("submissionstart", get_string("submissionstart", "workshop"), "workshop");
-    ?></td>
-</tr>
-
-<tr valign="top">
-    <td align="right"><b><?php  print_string("assessmentstart", "workshop") ?>:</b></td>
-    <td><?php
-            print_date_selector("assessmentstartday", "assessmentstartmonth", "assessmentstartyear", $form->assessmentstart);
-            echo "&nbsp;-&nbsp;";
-            print_time_selector("assessmentstarthour", "assessmentstartminute", $form->assessmentstart);
-            helpbutton("assessmentstart", get_string("assessmentstart", "workshop"), "workshop");
-    ?></td>
-</tr>
-
-<tr valign="top">
-    <td align="right"><b><?php  print_string("submissionend", "workshop") ?>:</b></td>
-    <td><?php
-            print_date_selector("submissionendday", "submissionendmonth", "submissionendyear", $form->submissionend);
-            echo "&nbsp;-&nbsp;";
-            print_time_selector("submissionendhour", "submissionendminute", $form->submissionend);
-            helpbutton("submissionend", get_string("submissionend", "workshop"), "workshop");
-    ?></td>
-</tr>
-
-<tr valign="top">
-    <td align="right"><b><?php  print_string("assessmentend", "workshop") ?>:</b></td>
-    <td><?php
-            print_date_selector("assessmentendday", "assessmentendmonth", "assessmentendyear", $form->assessmentend);
-            echo "&nbsp;-&nbsp;";
-            print_time_selector("assessmentendhour", "assessmentendminute", $form->assessmentend);
-            helpbutton("assessmentend", get_string("assessmentend", "workshop"), "workshop");
-    ?></td>
-</tr>
-<tr valign="top">
-    <td align="right"><b><?php  print_string("releaseteachergrades", "workshop") ?>:</b></td>
-    <td><?php
-            print_date_selector("releaseday", "releasemonth", "releaseyear", $form->releasegrades);
-            echo "&nbsp;-&nbsp;";
-            print_time_selector("releasehour", "releaseminute", $form->releasegrades);
-            helpbutton("releasegrades", get_string("releaseteachergrades", "workshop"), "workshop");
-    ?></td>
-</tr>
-<?php 
-$features = new stdClass;
-$features->groupings = true;
-print_standard_coursemodule_settings($form, $features); 
-?>
-</table>
-<br />
-<div class="boxaligncenter">
-<input type="hidden" name="course"     value="<?php  p($form->course) ?>" />
-<input type="hidden" name="sesskey"    value="<?php  p($form->sesskey) ?>" />
-<input type="hidden" name="coursemodule"  value="<?php  p($form->coursemodule) ?>" />
-<input type="hidden" name="section"    value="<?php  p($form->section) ?>" />
-<input type="hidden" name="module"     value="<?php  p($form->module) ?>" />
-<input type="hidden" name="modulename" value="<?php  p($form->modulename) ?>" />
-<input type="hidden" name="instance"   value="<?php  p($form->instance) ?>" />
-<input type="hidden" name="mode"       value="<?php  p($form->mode) ?>" />
-<input type="submit" value="<?php  print_string("savechanges") ?>" />
-<input type="submit" name="cancel" value="<?php  print_string("cancel") ?>" />
-</div>
-</form>
diff --git a/mod/workshop/restorelib.php b/mod/workshop/restorelib.php
deleted file mode 100644 (file)
index bc9a12b..0000000
+++ /dev/null
@@ -1,969 +0,0 @@
-<?php //$Id$
-    //This php script contains all the stuff to backup/restore
-    //workshop mods
-
-    //This is the "graphical" structure of the workshop mod:
-    //
-    //                                          workshop
-    //                                         (CL,pk->id)
-    //                                             |
-    //                                             |
-    //                                             |
-    //              |------------------------------|-----------------------------------------------------|
-    //              |                                                                                    |
-    //              |                                                                                    |
-    //              |                                                                                    |
-    //              |                                                                            workshop_submissions
-    //              |                                                                        (UL,pk->id,fk->workshopid,files)
-    //              |                                                                                    |
-    //              |        |-------------------------------------|      |----------------------|       |
-    //              |        |                                     |      |                      |       |
-    //             workshop_elements                           workshop_grades                  workshop_assessments
-    //         (CL,pk->id,fk->workshopid)                (UL,pk->id,fk->assessmentid)       (UL,pk->id,fk->submissionid)
-    //              |                  |                 (          fk->elementno   )                    |
-    //              |                  |                                                                 |
-    //              |                  |                                                                 |
-    //      workshop_rubrics          workshop_stockcomments                                        workshop_comments
-    // (CL,pk->id,fk->elementno)   (CL, pk->id, fk->elementno)                             (UL,pk->id,fk->assessmentid)
-    //
-    // Meaning: pk->primary key field of the table
-    //          fk->foreign key to link with parent
-    //          nt->nested field (recursive data)
-    //          CL->course level info
-    //          UL->user level info
-    //          files->table may have files)
-    //
-    //-----------------------------------------------------------
-
-    //This function executes all the restore procedure about this mod
-    function workshop_restore_mods($mod,$restore) {
-
-        global $CFG;
-
-        $status = true;
-
-        //Get record from backup_ids
-        $data = backup_getid($restore->backup_unique_code,$mod->modtype,$mod->id);
-
-        if ($data) {
-            //Now get completed xmlized object   
-            $info = $data->info;
-            //if necessary, write to restorelog and adjust date/time fields
-            if ($restore->course_startdateoffset) {
-                restore_log_date_changes('Workshop', $restore, $info['MOD']['#'], array('SUBMISSIONSTART','ASSESSMENTSTART', 'SUBMISSIONEND', 'ASSESSMENTEND', 'RELEASEGRADES'));
-            }
-            //traverse_xmlize($info);                                                                     //Debug
-            //print_object ($GLOBALS['traverse_array']);                                                  //Debug
-            //$GLOBALS['traverse_array']="";                                                              //Debug
-
-            //Now, build the WORKSHOP record structure
-            $workshop->course = $restore->course_id;
-            $workshop->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
-            $workshop->description = backup_todb($info['MOD']['#']['DESCRIPTION']['0']['#']);
-            $workshop->wtype = backup_todb($info['MOD']['#']['WTYPE']['0']['#']);
-            $workshop->nelements = backup_todb($info['MOD']['#']['NELEMENTS']['0']['#']);
-            $workshop->nattachments = backup_todb($info['MOD']['#']['NATTACHMENTS']['0']['#']);
-            $workshop->phase = backup_todb($info['MOD']['#']['PHASE']['0']['#']);
-            $workshop->format = backup_todb($info['MOD']['#']['FORMAT']['0']['#']);
-            $workshop->gradingstrategy = backup_todb($info['MOD']['#']['GRADINGSTRATEGY']['0']['#']);
-            $workshop->resubmit = backup_todb($info['MOD']['#']['RESUBMIT']['0']['#']);
-            $workshop->agreeassessments = backup_todb($info['MOD']['#']['AGREEASSESSMENTS']['0']['#']);
-            $workshop->hidegrades = backup_todb($info['MOD']['#']['HIDEGRADES']['0']['#']);
-            $workshop->anonymous = backup_todb($info['MOD']['#']['ANONYMOUS']['0']['#']);
-            $workshop->includeself = backup_todb($info['MOD']['#']['INCLUDESELF']['0']['#']);
-            $workshop->maxbytes = backup_todb($info['MOD']['#']['MAXBYTES']['0']['#']);
-            $workshop->submissionstart = backup_todb($info['MOD']['#']['SUBMISSIONSTART']['0']['#']);
-            $workshop->assessmentstart = backup_todb($info['MOD']['#']['ASSESSMENTSTART']['0']['#']);
-            $workshop->deadline = backup_todb($info['MOD']['#']['DEADLINE']['0']['#']);
-            $workshop->submissionend = backup_todb($info['MOD']['#']['SUBMISSIONEND']['0']['#']);
-            $workshop->assessmentend = backup_todb($info['MOD']['#']['ASSESSMENTEND']['0']['#']);
-            $workshop->releasegrades = backup_todb($info['MOD']['#']['RELEASEGRADES']['0']['#']);
-            $workshop->grade = backup_todb($info['MOD']['#']['GRADE']['0']['#']);
-            $workshop->gradinggrade = backup_todb($info['MOD']['#']['GRADINGGRADE']['0']['#']);
-            $workshop->ntassessments = backup_todb($info['MOD']['#']['NTASSESSMENTS']['0']['#']);
-            $workshop->assessmentcomps = backup_todb($info['MOD']['#']['ASSESSMENTCOMPS']['0']['#']);
-            $workshop->nsassessments = backup_todb($info['MOD']['#']['NSASSESSMENTS']['0']['#']);
-            $workshop->overallocation = backup_todb($info['MOD']['#']['OVERALLOCATION']['0']['#']);
-            $workshop->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
-            $workshop->teacherweight = backup_todb($info['MOD']['#']['TEACHERWEIGHT']['0']['#']);
-            $workshop->showleaguetable = backup_todb($info['MOD']['#']['SHOWLEAGUETABLE']['0']['#']);
-            $workshop->usepassword = backup_todb($info['MOD']['#']['USEPASSWORD']['0']['#']);
-            $workshop->password = backup_todb($info['MOD']['#']['PASSWORD']['0']['#']);
-
-            //If we have retrieved workshop->phase, it's a pre 1.5 backup, so we have to do
-            //some conversions before inserting to DB. Upwards compatibility :-)
-            if ( isset($info['MOD']['#']['PHASE']['0']['#'])) { //It's a pre-15 backup file
-
-                //Adjust the wtype field (mimetised from the upgrade script)
-                $workshop->wtype = 0;
-                if ($workshop->includeself || $workshop->ntassessments) {
-                    $workshop->wtype = 1;    // 3 phases with grading grades
-                } else if ($workshop->nsassessments) {
-                    $workshop->wtype = 2;   // 5 phases with grading grades
-                }
-
-                //Now, adjust phases time limits (mimetised from the upgrade script too)
-                $early = 0;
-                $late = 0;
-                $now = time();
-                if ($now < $workshop->deadline) {
-                    $late = $workshop->deadline;
-                } else {
-                    $early = $workshop->deadline;
-                }
-                if ($workshop->phase > 1) {
-                    $workshop->submissionstart = $early;
-                } else {
-                    $workshop->submissionstart = $late;
-                }
-                if ($workshop->phase > 2) {
-                    $workshop->assessmentstart = $early;
-                } else {
-                    $workshop->assessmentstart = $late;
-                }
-                if ($workshop->phase > 3) {
-                    $workshop->submissionend = $early;
-                } else {
-                    $workshop->submissionend = $late;
-                }
-                if ($workshop->phase > 4) {
-                    $workshop->assessmentend = $early;
-                } else {
-                    $workshop->assessmentend = $late;
-                }
-                if ($workshop->phase > 5) {
-                    $workshop->releasegrades = $now;
-                } else {
-                    $workshop->releasegrades = $now + (4 * 7 * 24 * 60 * 60); //Grades will be available in 4 weeks
-                }
-            }
-
-            //The structure is equal to the db, so insert the workshop
-            $newid = insert_record ("workshop",$workshop);
-
-            //Do some output     
-            if (!defined('RESTORE_SILENTLY')) {
-                echo "<li>".get_string("modulename","workshop")." \"".format_string(stripslashes($workshop->name),true)."\"</li>";
-            }
-            backup_flush(300);
-            
-            if ($newid) {
-                //We have the newid, update backup_ids
-                backup_putid($restore->backup_unique_code,$mod->modtype,
-                             $mod->id, $newid);
-                //We have to restore the workshop_elements table now (course level table)
-                $status = workshop_elements_restore_mods($newid,$info,$restore);
-                //Now check if want to restore user data and do it.
-                if (restore_userdata_selected($restore,'workshop',$mod->id)) {
-                    //Restore workshop_submissions
-                    $status = workshop_submissions_restore_mods ($mod->id, $newid,$info,$restore);
-                }
-            } else {
-                $status = false;
-            }
-        } else {
-            $status = false;
-        }
-
-        return $status;
-    }
-
-    //This function restores the workshop_elements
-    function workshop_elements_restore_mods($workshop_id,$info,$restore) {
-
-        global $CFG;
-
-        $status = true;
-
-        //Get the workshop_elements array
-        $elements = $info['MOD']['#']['ELEMENTS']['0']['#']['ELEMENT'];
-
-        //Iterate over workshop_elements
-        for($i = 0; $i < sizeof($elements); $i++) {
-            $ele_info = $elements[$i];
-            //traverse_xmlize($ele_info);                                                                 //Debug
-            //print_object ($GLOBALS['traverse_array']);                                                  //Debug
-            //$GLOBALS['traverse_array']="";                                                              //Debug
-
-            //Now, build the WORKSHOP_ELEMENTS record structure
-            $element->workshopid = $workshop_id;
-            $element->elementno = backup_todb($ele_info['#']['ELEMENTNO']['0']['#']);
-            $element->description = backup_todb($ele_info['#']['DESCRIPTION']['0']['#']);
-            $element->scale = backup_todb($ele_info['#']['SCALE']['0']['#']);
-            $element->maxscore = backup_todb($ele_info['#']['MAXSCORE']['0']['#']);
-            $element->weight = backup_todb($ele_info['#']['WEIGHT']['0']['#']);
-            $element->stddev = backup_todb($ele_info['#']['STDDEV']['0']['#']);
-            $element->totalassessments = backup_todb($ele_info['#']['TOTALASSESSMENTS']['0']['#']);
-
-            //The structure is equal to the db, so insert the workshop_elements
-            $newid = insert_record ("workshop_elements",$element);
-
-            //Do some output
-            if (($i+1) % 10 == 0) {
-                if (!defined('RESTORE_SILENTLY')) {
-                    echo ".";
-                    if (($i+1) % 200 == 0) {
-                        echo "<br />";
-                    }
-                }
-                backup_flush(300);
-            }
-
-            if ($newid) {
-                //We have to restore the workshop_rubrics table now (course level table)
-                $status = workshop_rubrics_restore_mods($workshop_id,$element->elementno,$ele_info,$restore);
-                //We have to restore the workshop_stockcomment table now (course level table)
-                $status = workshop_stockcomments_restore_mods($workshop_id,$element->elementno,$ele_info,$restore);
-            } else {
-                $status = false;
-            }
-        }
-
-        return $status;
-    }
-
-
-    //This function restores the workshop_rubrics
-    function workshop_rubrics_restore_mods($workshop_id,$elementno,$info,$restore) {
-
-        global $CFG;
-
-        $status = true;
-
-        //Get the workshop_rubrics array (optional)
-        if (isset($info['#']['RUBRICS']['0']['#']['RUBRIC'])) {
-            $rubrics = $info['#']['RUBRICS']['0']['#']['RUBRIC'];
-
-            //Iterate over workshop_rubrics
-            for($i = 0; $i < sizeof($rubrics); $i++) {
-                $rub_info = $rubrics[$i];
-                //traverse_xmlize($rub_info);                             //Debug
-                //print_object ($GLOBALS['traverse_array']);              //Debug
-                //$GLOBALS['traverse_array']="";                          //Debug
-
-                //Now, build the WORKSHOP_RUBRICS record structure
-                $rubric->workshopid = $workshop_id;
-                $rubric->elementno = $elementno;
-                $rubric->rubricno = backup_todb($rub_info['#']['RUBRICNO']['0']['#']);
-                $rubric->description = backup_todb($rub_info['#']['DESCRIPTION']['0']['#']);
-
-                //The structure is equal to the db, so insert the workshop_rubrics
-                $newid = insert_record ("workshop_rubrics",$rubric);
-
-                //Do some output
-                if (($i+1) % 10 == 0) {
-                    if (!defined('RESTORE_SILENTLY')) {
-                        echo ".";
-                        if (($i+1) % 200 == 0) {
-                            echo "<br />";
-                        }
-                    }
-                    backup_flush(300);
-                }
-
-                if (!$newid) {
-                    $status = false;
-                }
-            }
-        }
-        return $status;
-    }
-
-
-    //This function restores the workshop_stockcomments
-    function workshop_stockcomments_restore_mods($new_workshop_id, $elementno, $info, $restore) {
-
-        global $CFG;
-
-        $status = true;
-
-        //Get the stockcomments array (optional)
-        if (isset($info['#']['STOCKCOMMENTS']['0']['#']['STOCKCOMMENT'])) {
-            $stockcomments = $info['#']['STOCKCOMMENTS']['0']['#']['STOCKCOMMENT'];
-
-            //Iterate over stock comments
-            for($i = 0; $i < sizeof($stockcomments); $i++) {
-                $com_info = $stockcomments[$i];
-                //traverse_xmlize($com_info);                            //Debug
-                //print_object ($GLOBALS['traverse_array']);             //Debug
-                //$GLOBALS['traverse_array']="";                         //Debug
-
-                //Now, build the WORKSHOP_STOCKCOMMENTS record structure
-                $stockcomment->workshopid = $new_workshop_id;
-                $stockcomment->elementno = $elementno;
-                $stockcomment->comments = backup_todb($com_info['#']['COMMENT_TEXT']['0']['#']);
-
-                //The structure is equal to the db, so insert the workshop_comment
-                $newid = insert_record ("workshop_stockcomments",$stockcomment);
-
-                //Do some output
-                if (($i+1) % 50 == 0) {
-                    if (!defined('RESTORE_SILENTLY')) {
-                        echo ".";
-                        if (($i+1) % 1000 == 0) {
-                            echo "<br />";
-                        }
-                    }
-                    backup_flush(300);
-                }
-
-                if (!$newid) {
-                    $status = false;
-                }
-            }
-        }
-
-        return $status;
-    }
-
-    //This function restores the workshop_submissions
-    function workshop_submissions_restore_mods($old_workshop_id, $new_workshop_id,$info,$restore) {
-
-        global $CFG;
-
-        $status = true;
-
-        //Get the submissions array 
-        $submissions = $info['MOD']['#']['SUBMISSIONS']['0']['#']['SUBMISSION'];
-            
-        //Iterate over submissions
-        for($i = 0; $i < sizeof($submissions); $i++) {
-            $sub_info = $submissions[$i];
-            //traverse_xmlize($sub_info);                                     //Debug
-            //print_object ($GLOBALS['traverse_array']);                      //Debug
-            //$GLOBALS['traverse_array']="";                                  //Debug
-
-            //We'll need this later!!
-            $oldid = backup_todb($sub_info['#']['ID']['0']['#']);
-            $olduserid = backup_todb($sub_info['#']['USERID']['0']['#']);
-
-            //Now, build the WORKSHOP_SUBMISSIONS record structure
-            $submission->workshopid = $new_workshop_id;
-            $submission->userid = backup_todb($sub_info['#']['USERID']['0']['#']);
-            $submission->title = backup_todb($sub_info['#']['TITLE']['0']['#']); 
-            $submission->timecreated = backup_todb($sub_info['#']['TIMECREATED']['0']['#']);
-            $submission->timecreated += $restore->course_startdateoffset;
-            $submission->mailed = backup_todb($sub_info['#']['MAILED']['0']['#']);
-            $submission->description = backup_todb($sub_info['#']['DESCRIPTION']['0']['#']);
-            $submission->gradinggrade = backup_todb($sub_info['#']['GRADINGGRADE']['0']['#']);
-            $submission->finalgrade = backup_todb($sub_info['#']['FINALGRADE']['0']['#']);
-            $submission->late = backup_todb($sub_info['#']['LATE']['0']['#']);
-            $submission->nassessments = backup_todb($sub_info['#']['NASSESSMENTS']['0']['#']);
-
-            //We have to recode the userid field
-            $user = backup_getid($restore->backup_unique_code,"user",$olduserid);
-            if ($user) {
-                $submission->userid = $user->new_id;
-            }
-
-            //The structure is equal to the db, so insert the workshop_submission
-            $newid = insert_record ("workshop_submissions",$submission);
-
-            //Do some output
-            if (($i+1) % 50 == 0) {
-                if (!defined('RESTORE_SILENTLY')) {
-                    echo ".";
-                    if (($i+1) % 1000 == 0) {
-                        echo "<br />";
-                    }
-                }
-                backup_flush(300);
-            }
-
-            if ($newid) {
-                //We have the newid, update backup_ids
-                backup_putid($restore->backup_unique_code,"workshop_submissions",$oldid,
-                             $newid);
-
-                //Now copy moddata associated files
-                $status = workshop_restore_files ($oldid, $newid,$restore); 
-                //Now we need to restore workshop_assessments (user level table)
-                if ($status) {
-                    $status = workshop_assessments_restore_mods ($new_workshop_id, $newid,$sub_info,$restore);
-                }
-            } else {
-                $status = false;
-            }
-        }
-
-        return $status;
-    }
-
-    //This function restores the workshop_assessments       
-    function workshop_assessments_restore_mods($new_workshop_id, $new_submission_id,$info,$restore) {
-
-        global $CFG;
-
-        $status = true;
-
-        //Get the assessments array (if any)
-        if (isset($info['#']['ASSESSMENTS']['0']['#']['ASSESSMENT'])) {
-            $assessments = $info['#']['ASSESSMENTS']['0']['#']['ASSESSMENT'];
-
-            //Iterate over assessments
-            for($i = 0; $i < sizeof($assessments); $i++) {
-                $ass_info = $assessments[$i];
-                //traverse_xmlize($ass_info);                                                                 //Debug
-                //print_object ($GLOBALS['traverse_array']);                                                  //Debug
-                //$GLOBALS['traverse_array']="";                                                              //Debug
-
-                //We'll need this later!!
-                $oldid = backup_todb($ass_info['#']['ID']['0']['#']);
-                $olduserid = backup_todb($ass_info['#']['USERID']['0']['#']);
-
-                //Now, build the WORKSHOP_ASSESSMENTS record structure
-                $assessment->workshopid = $new_workshop_id;
-                $assessment->submissionid = $new_submission_id;
-                $assessment->userid = backup_todb($ass_info['#']['USERID']['0']['#']);
-                $assessment->timecreated = backup_todb($ass_info['#']['TIMECREATED']['0']['#']);
-                $assessment->timegraded = backup_todb($ass_info['#']['TIMEGRADED']['0']['#']);
-                $assessment->timeagreed = backup_todb($ass_info['#']['TIMEAGREED']['0']['#']);
-                $assessment->grade = backup_todb($ass_info['#']['GRADE']['0']['#']);
-                $assessment->gradinggrade = backup_todb($ass_info['#']['GRADINGGRADE']['0']['#']);
-                $assessment->mailed = backup_todb($ass_info['#']['MAILED']['0']['#']);
-                $assessment->resubmission = backup_todb($ass_info['#']['RESUBMISSION']['0']['#']);
-                $assessment->donotuse = backup_todb($ass_info['#']['DONOTUSE']['0']['#']);
-                $assessment->generalcomment = backup_todb($ass_info['#']['GENERALCOMMENT']['0']['#']);
-                $assessment->teachercomment = backup_todb($ass_info['#']['TEACHERCOMMENT']['0']['#']);
-
-                //We have to recode the userid field
-                $user = backup_getid($restore->backup_unique_code,"user",$olduserid);
-                if ($user) {
-                    $assessment->userid = $user->new_id;
-                }
-
-                //The structure is equal to the db, so insert the workshop_assessment
-                $newid = insert_record ("workshop_assessments",$assessment);
-
-                //Do some output
-                if (($i+1) % 50 == 0) {
-                    if (!defined('RESTORE_SILENTLY')) {
-                        echo ".";
-                        if (($i+1) % 1000 == 0) {
-                            echo "<br />";
-                        }
-                    }
-                    backup_flush(300);
-                }
-
-                if ($newid) {
-                    //We have the newid, update backup_ids
-                    backup_putid($restore->backup_unique_code,"workshop_assessments",$oldid,
-                            $newid);
-
-                    //Now we need to restore workshop_comments (user level table)
-                    if ($status) {
-                        $status = workshop_comments_restore_mods ($new_workshop_id, $newid,$ass_info,$restore);
-                    }
-                    //Now we need to restore workshop_grades (user level table)   
-                    if ($status) {
-                        $status = workshop_grades_restore_mods ($new_workshop_id, $newid,$ass_info,$restore);   
-                    }
-                } else {
-                    $status = false;
-                }
-            }
-        }
-
-        return $status;
-    }
-
-    //This function restores the workshop_comments
-    function workshop_comments_restore_mods($new_workshop_id, $new_assessment_id,$info,$restore) {
-
-        global $CFG;
-
-        $status = true;
-
-        //Get the comments array (optional)
-        if (isset($info['#']['COMMENTS']['0']['#']['COMMENT'])) {
-            $comments = $info['#']['COMMENTS']['0']['#']['COMMENT'];
-
-            //Iterate over comments
-            for($i = 0; $i < sizeof($comments); $i++) {
-                $com_info = $comments[$i];
-                //traverse_xmlize($com_info);                            //Debug
-                //print_object ($GLOBALS['traverse_array']);             //Debug
-                //$GLOBALS['traverse_array']="";                         //Debug
-
-                //We'll need this later!!
-                $olduserid = backup_todb($com_info['#']['USERID']['0']['#']);
-
-                //Now, build the WORKSHOP_COMMENTS record structure
-                $comment->workshopid = $new_workshop_id;
-                $comment->assessmentid = $new_assessment_id;
-                $comment->userid = backup_todb($com_info['#']['USERID']['0']['#']);
-                $comment->timecreated = backup_todb($com_info['#']['TIMECREATED']['0']['#']);
-                $comment->mailed = backup_todb($com_info['#']['MAILED']['0']['#']);
-                $comment->comments = backup_todb($com_info['#']['COMMENT_TEXT']['0']['#']);
-
-                //We have to recode the userid field
-                $user = backup_getid($restore->backup_unique_code,"user",$olduserid);
-                if ($user) {
-                    $comment->userid = $user->new_id;
-                }
-
-                //The structure is equal to the db, so insert the workshop_comment
-                $newid = insert_record ("workshop_comments",$comment);
-
-                //Do some output
-                if (($i+1) % 50 == 0) {
-                    if (!defined('RESTORE_SILENTLY')) {
-                        echo ".";
-                        if (($i+1) % 1000 == 0) {
-                            echo "<br />";
-                        }
-                    }
-                    backup_flush(300);
-                }
-
-                if (!$newid) {
-                    $status = false;
-                }
-            }
-        }
-
-        return $status;
-    }
-
-    //This function restores the workshop_grades
-    function workshop_grades_restore_mods($new_workshop_id, $new_assessment_id,$info,$restore) {
-
-        global $CFG;
-
-        $status = true;
-
-        //Get the grades array (optional)
-        if (isset($info['#']['GRADES']['0']['#']['GRADE'])) {
-            $grades = $info['#']['GRADES']['0']['#']['GRADE'];
-
-            //Iterate over grades
-            for($i = 0; $i < sizeof($grades); $i++) {
-                $gra_info = $grades[$i];
-                //traverse_xmlize($gra_info);                             //Debug
-                //print_object ($GLOBALS['traverse_array']);              //Debug
-                //$GLOBALS['traverse_array']="";                          //Debug
-
-                //Now, build the WORKSHOP_GRADES record structure
-                $grade->workshopid = $new_workshop_id;
-                $grade->assessmentid = $new_assessment_id;
-                $grade->elementno = backup_todb($gra_info['#']['ELEMENTNO']['0']['#']);
-                $grade->feedback = backup_todb($gra_info['#']['FEEDBACK']['0']['#']);
-                $grade->grade = backup_todb($gra_info['#']['GRADE_VALUE']['0']['#']);
-
-                //The structure is equal to the db, so insert the workshop_grade
-                $newid = insert_record ("workshop_grades",$grade);
-
-                //Do some output
-                if (($i+1) % 50 == 0) {
-                    if (!defined('RESTORE_SILENTLY')) {
-                        echo ".";
-                        if (($i+1) % 1000 == 0) {
-                            echo "<br />";
-                        }
-                    }
-                    backup_flush(300);
-                }
-
-                if (!$newid) {
-                    $status = false;
-                }
-            }
-        }
-
-        return $status;
-    }
-
-    //This function copies the workshop related info from backup temp dir to course moddata folder,
-    //creating it if needed and recoding everything (submission_id) 
-    function workshop_restore_files ($oldsubmiss, $newsubmiss, $restore) {
-
-        global $CFG;
-
-        $status = true;
-        $todo = false;
-        $moddata_path = "";
-        $workshop_path = "";
-        $temp_path = "";
-
-        //First, we check to "course_id" exists and create is as necessary
-        //in CFG->dataroot
-        $dest_dir = $CFG->dataroot."/".$restore->course_id;
-        $status = check_dir_exists($dest_dir,true);
-
-        //Now, locate course's moddata directory
-        $moddata_path = $CFG->dataroot."/".$restore->course_id."/".$CFG->moddata;
-   
-        //Check it exists and create it
-        $status = check_dir_exists($moddata_path,true);
-
-        //Now, locate workshop directory
-        if ($status) {
-            $workshop_path = $moddata_path."/workshop";
-            //Check it exists and create it
-            $status = check_dir_exists($workshop_path,true);
-        }
-
-        //Now locate the temp dir we are gong to restore
-        if ($status) {
-            $temp_path = $CFG->dataroot."/temp/backup/".$restore->backup_unique_code.
-                         "/moddata/workshop/".$oldsubmiss;
-            //Check it exists
-            if (is_dir($temp_path)) {
-                $todo = true;
-            }
-        }
-
-        //If todo, we create the neccesary dirs in course moddata/workshop
-        if ($status and $todo) {
-            //First this workshop id
-            $this_workshop_path = $workshop_path."/".$newsubmiss;
-            $status = check_dir_exists($this_workshop_path,true);
-            //And now, copy temp_path to this_workshop_path
-            $status = backup_copy_file($temp_path, $this_workshop_path); 
-        }
-       
-        return $status;
-    }
-
-    //This function converts texts in FORMAT_WIKI to FORMAT_MARKDOWN for
-    //some texts in the module
-    function workshop_restore_wiki2markdown ($restore) {
-
-        global $CFG;
-
-        $status = true;
-
-        //Convert workshop->description
-        if ($records = get_records_sql ("SELECT w.id, w.description, w.format
-                                         FROM {$CFG->prefix}workshop w,
-                                              {$CFG->prefix}backup_ids b
-                                         WHERE w.course = $restore->course_id AND
-                                               format = ".FORMAT_WIKI. " AND
-                                               b.backup_code = $restore->backup_unique_code AND
-                                               b.table_name = 'workshop' AND
-                                               b.new_id = w.id")) {
-            foreach ($records as $record) {
-                //Rebuild wiki links
-                $record->description = restore_decode_wiki_content($record->description, $restore);
-                //Convert to Markdown
-                $wtm = new WikiToMarkdown();
-                $record->description = $wtm->convert($record->description, $restore->course_id);
-                $record->format = FORMAT_MARKDOWN;
-                $status = update_record('workshop', addslashes_object($record));
-                //Do some output
-                $i++;
-                if (($i+1) % 1 == 0) {
-                    if (!defined('RESTORE_SILENTLY')) {
-                        echo ".";
-                        if (($i+1) % 20 == 0) {
-                            echo "<br />";
-                        }
-                    }
-                    backup_flush(300);
-                }
-            }
-
-        }
-        return $status;
-    }
-
-    //Return a content decoded to support interactivities linking. Every module
-    //should have its own. They are called automatically from
-    //workshop_decode_content_links_caller() function in each module
-    //in the restore process
-    function workshop_decode_content_links ($content,$restore) {
-
-        global $CFG;
-
-        $result = $content;
-
-        //Link to the list of workshops
-
-        $searchstring='/\$@(WORKSHOPINDEX)\*([0-9]+)@\$/';
-        //We look for it
-        preg_match_all($searchstring,$content,$foundset);
-        //If found, then we are going to look for its new id (in backup tables)
-        if ($foundset[0]) {
-            //print_object($foundset);                                     //Debug
-            //Iterate over foundset[2]. They are the old_ids
-            foreach($foundset[2] as $old_id) {
-                //We get the needed variables here (course id)
-                $rec = backup_getid($restore->backup_unique_code,"course",$old_id);
-                //Personalize the searchstring
-                $searchstring='/\$@(WORKSHOPINDEX)\*('.$old_id.')@\$/';
-                //If it is a link to this course, update the link to its new location
-                if($rec->new_id) {
-                    //Now replace it
-                    $result= preg_replace($searchstring,$CFG->wwwroot.'/mod/workshop/index.php?id='.$rec->new_id,$result);
-                } else {
-                    //It's a foreign link so leave it as original
-                    $result= preg_replace($searchstring,$restore->original_wwwroot.'/mod/workshop/index.php?id='.$old_id,$result);
-                }
-            }
-        }
-
-        //Link to workshop view by moduleid
-
-        $searchstring='/\$@(WORKSHOPVIEWBYID)\*([0-9]+)@\$/';
-        //We look for it
-        preg_match_all($searchstring,$result,$foundset);
-        //If found, then we are going to look for its new id (in backup tables)
-        if ($foundset[0]) {
-            //print_object($foundset);                                     //Debug
-            //Iterate over foundset[2]. They are the old_ids
-            foreach($foundset[2] as $old_id) {
-                //We get the needed variables here (course_modules id)
-                $rec = backup_getid($restore->backup_unique_code,"course_modules",$old_id);
-                //Personalize the searchstring
-                $searchstring='/\$@(WORKSHOPVIEWBYID)\*('.$old_id.')@\$/';
-                //If it is a link to this course, update the link to its new location
-                if($rec->new_id) {
-                    //Now replace it
-                    $result= preg_replace($searchstring,$CFG->wwwroot.'/mod/workshop/view.php?id='.$rec->new_id,$result);
-                } else {
-                    //It's a foreign link so leave it as original
-                    $result= preg_replace($searchstring,$restore->original_wwwroot.'/mod/workshop/view.php?id='.$old_id,$result);
-                }
-            }
-        }
-
-        return $result;
-    }
-
-    //This function makes all the necessary calls to xxxx_decode_content_links()
-    //function in each module, passing them the desired contents to be decoded
-    //from backup format to destination site/course in order to mantain inter-activities
-    //working in the backup/restore process. It's called from restore_decode_content_links()
-    //function in restore process
-    function workshop_decode_content_links_caller($restore) {
-        global $CFG;
-        $status = true;
-
-        //Process every WORKSHOP (description) in the course
-        if ($workshops = get_records_sql ("SELECT w.id, w.description
-                                           FROM {$CFG->prefix}workshop w
-                                           WHERE w.course = $restore->course_id")) {
-            //Iterate over each workshop->description
-            $i = 0;   //Counter to send some output to the browser to avoid timeouts
-            foreach ($workshops as $workshop) {
-                //Increment counter
-                $i++;
-                $content = $workshop->description;
-                $result = restore_decode_content_links_worker($content,$restore);
-                if ($result != $content) {
-                    //Update record
-                    $workshop->description = addslashes($result);
-                    $status = update_record("workshop",$workshop);
-                    if (debugging()) {
-                        if (!defined('RESTORE_SILENTLY')) {
-                            echo '<br /><hr />'.s($content).'<br />changed to<br />'.s($result).'<hr /><br />';
-                        }
-                    }
-                }
-                //Do some output
-                if (($i+1) % 5 == 0) {
-                    if (!defined('RESTORE_SILENTLY')) {
-                        echo ".";
-                        if (($i+1) % 100 == 0) {
-                            echo "<br />";
-                        }
-                    }
-                    backup_flush(300);
-                }
-            }
-        }
-
-        return $status;
-    }
-
-    //This function returns a log record with all the necessay transformations
-    //done. It's used by restore_log_module() to restore modules log.
-    function workshop_restore_logs($restore,$log) {
-                    
-        $status = false;
-                    
-        //Depending of the action, we recode different things
-        switch ($log->action) {
-        case "add":
-            if ($log->cmid) {
-                //Get the new_id of the module (to recode the info field)
-                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
-                if ($mod) {
-                    $log->url = "view.php?id=".$log->cmid;
-                    $log->info = $mod->new_id;
-                    $status = true;
-                }
-            }
-            break;
-        case "update":
-            if ($log->cmid) {
-                //Get the new_id of the module (to recode the info field)
-                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
-                if ($mod) {
-                    $log->url = "view.php?id=".$log->cmid;
-                    $log->info = $mod->new_id;
-                    $status = true;
-                }
-            }
-            break;
-        case "view":
-            if ($log->cmid) {
-                //Get the new_id of the module (to recode the info field)
-                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
-                if ($mod) {
-                    $log->url = "view.php?id=".$log->cmid;
-                    $log->info = $mod->new_id;
-                    $status = true;
-                }
-            }
-            break;
-        case "view all":
-            $log->url = "index.php?id=".$log->course;
-            $status = true;
-            break;
-        case "submit":
-            if ($log->cmid) {
-                //Get the new_id of the module (to recode the info field)
-                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
-                if ($mod) {
-                    $log->url = "view.php?id=".$log->cmid;
-                    $log->info = $mod->new_id;
-                    $status = true;
-                }
-            }
-            break;
-        case "resubmit":
-            if ($log->cmid) {
-                //Get the new_id of the module (to recode the info field)
-                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
-                if ($mod) {
-                    $log->url = "view.php?id=".$log->cmid;
-                    $log->info = $mod->new_id;
-                    $status = true;
-                }   
-            }   
-            break;
-        case "league table":
-            if ($log->cmid) {
-                //Get the new_id of the module (to recode the info field)
-                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
-                if ($mod) {
-                    $log->url = "view.php?id=".$log->cmid;
-                    $log->info = $mod->new_id;
-                    $status = true;
-                }
-            }
-            break;
-        case "submissions":
-            if ($log->cmid) {
-                //Get the new_id of the module (to recode the info field)
-                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
-                if ($mod) {
-                    $log->url = "view.php?id=".$log->cmid;
-                    $log->info = $mod->new_id;
-                    $status = true;
-                }
-            }
-            break;
-        case "allow both":
-            if ($log->cmid) {
-                //Get the new_id of the module (to recode the info field)
-                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
-                if ($mod) {
-                    $log->url = "view.php?id=".$log->cmid;
-                    $log->info = $mod->new_id;
-                    $status = true;
-                }
-            }
-            break;
-        case "set up":
-            if ($log->cmid) {
-                //Get the new_id of the module (to recode the info field)
-                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
-                if ($mod) {
-                    $log->url = "view.php?id=".$log->cmid;
-                    $log->info = $mod->new_id;
-                    $status = true;
-                }
-            }
-            break;
-        case "assessments onl":
-            if ($log->cmid) {
-                //Get the new_id of the module (to recode the info field)
-                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
-                if ($mod) {
-                    $log->url = "view.php?id=".$log->cmid;
-                    $log->info = $mod->new_id;
-                    $status = true;
-                }
-            }
-            break;
-        case "close":
-            if ($log->cmid) {
-                //Get the new_id of the module (to recode the info field)
-                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
-                if ($mod) {
-                    $log->url = "view.php?id=".$log->cmid;
-                    $log->info = $mod->new_id;
-                    $status = true;
-                }
-            }
-            break;
-        case "display grades":
-            if ($log->cmid) {
-                //Get the new_id of the module (to recode the info field)
-                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
-                if ($mod) {
-                    $log->url = "view.php?id=".$log->cmid;
-                    $log->info = $mod->new_id;
-                    $status = true;
-                }
-            }
-            break;
-        case "over allocation":
-            if ($log->cmid) {
-                //Get the new_id of the module (to recode the info field)
-                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
-                if ($mod) {
-                    $log->url = "view.php?id=".$log->cmid;
-                    $log->info = $mod->new_id;
-                    $status = true;
-                }
-            }
-            break;
-        case "assess":
-            if ($log->cmid) {
-                //Get the new_id of the workshop assessments
-                $ass = backup_getid($restore->backup_unique_code,"workshop_assessments",$log->info);
-                if ($ass) {
-                    $log->url = "assessments.php?action=viewassessment&id=".$log->cmid."&aid=".$ass->new_id;
-                    $log->info = $ass->new_id;
-                    $status = true;
-                }
-            }
-            break;
-        case "grade":
-            if ($log->cmid) {
-                //Get the new_id of the workshop assessments
-                $ass = backup_getid($restore->backup_unique_code,"workshop_assessments",$log->info);
-                if ($ass) {
-                    $log->url = "assessments.php?action=viewassessment&id=".$log->cmid."&aid=".$ass->new_id;
-                    $log->info = $ass->new_id;
-                    $status = true;
-                }
-            }
-            break;
-        default:
-            if (!defined('RESTORE_SILENTLY')) {
-                echo "action (".$log->module."-".$log->action.") unknown. Not restored<br />";                 //Debug
-            }
-            break;
-        }
-
-        if ($status) {
-            $status = $log;
-        }
-        return $status;
-    }
-?>
diff --git a/mod/workshop/styles.php b/mod/workshop/styles.php
deleted file mode 100644 (file)
index 7eeb0d1..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-.workshop_feedbackbox {
-    margin-top: 5px;
-    border-width: 1px;
-    border-style: solid;
-    border-color: #999999;
-}
-
-.workshop_feedbackbox .picture {
-    vertical-align: top;
-}
-
-.workshop_feedbackbox .author {
-    vertical-align: top;
-    display: block;
-}
-
-.workshop_feedbackbox .time {
-    vertical-align: top;
-    display: block;
-}
-
-.workshop_feedbackbox .content {
-    vertical-align: top;
-}
-
-.workshop_feedbackbox .comment {
-    display: block;
-}
-
-.workshop_feedbackbox .teachercomment {
-    display: block;
-    font-weight: bold;
-}
diff --git a/mod/workshop/submissions.php b/mod/workshop/submissions.php
deleted file mode 100644 (file)
index 505d74d..0000000
+++ /dev/null
@@ -1,463 +0,0 @@
-<?php  // $Id$
-
-/*************************************************
-    ACTIONS handled are:
-
-    adminamendtitle
-    confirmdelete
-    delete
-    adminlist
-    editsubmission
-    listallsubmissions
-    listforassessmentstudent
-    listforassessmentteacher
-    showsubmission
-    updatesubmission
-
-
-************************************************/
-
-    require("../../config.php");
-    require("lib.php");
-    require("locallib.php");
-
-    $id          = required_param('id', PARAM_INT);    // Course Module ID
-    $action      = optional_param('action', '', PARAM_ALPHA);
-    $sid         = optional_param('sid', 0, PARAM_INT); //submission id
-    $order       = optional_param('order', 'name', PARAM_ALPHA);
-    $title       = optional_param('title', '', PARAM_CLEAN);
-    $nentries    = optional_param('nentries', '', PARAM_ALPHANUM);
-    $anonymous   = optional_param('anonymous', '', PARAM_CLEAN);
-    $description = optional_param('description', '', PARAM_CLEAN);
-
-    $timenow = time();
-
-    // get some useful stuff...
-    if (! $cm = get_coursemodule_from_id('workshop', $id)) {
-        print_error("Course Module ID was incorrect");
-    }
-    if (! $course = get_record("course", "id", $cm->course)) {
-        print_error("Course is misconfigured");
-    }
-    if (! $workshop = get_record("workshop", "id", $cm->instance)) {
-        print_error("Course module is incorrect");
-    }
-
-    require_login($course->id, false, $cm);
-    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
-    $strworkshops = get_string("modulenameplural", "workshop");
-    $strworkshop  = get_string("modulename", "workshop");
-    $strsubmissions = get_string("submissions", "workshop");
-
-    // ... print the header and...
-    $navigation = build_navigation($strsubmissions, $cm);
-    print_header_simple(format_string($workshop->name), "", $navigation,
-                  "", "", true);
-
-    //...get the action or set up an suitable default
-    if (empty($action)) {
-        $action = "listallsubmissions";
-    }
-
-
-/******************* admin amend title ************************************/
-    elseif ($action == 'adminamendtitle' ) {
-
-        require_capability('mod/workshop:manage', $context);
-        if (empty($sid)) {
-            print_error("Admin Amend Title: submission id missing");
-        }
-
-        $submission = get_record("workshop_submissions", "id", $sid);
-        print_heading(get_string("amendtitle", "workshop"));
-        ?>
-        <form id="amendtitleform" action="submissions.php" method="post">
-        <fieldset class="invisiblefieldset">
-        <input type="hidden" name="action" value="adminupdatetitle" />
-        <input type="hidden" name="id" value="<?php echo $cm->id ?>" />
-        <input type="hidden" name="sid" value="<?php echo $sid ?>" />
-        <div class="boxaligncenter">
-        <table cellpadding="5" border="1">
-        <?php
-
-        // now get the comment
-        echo "<tr valign=\"top\">\n";
-        echo "  <td align=\"right\"><p><b>". get_string("title", "workshop").":</b></p></td>\n";
-        echo "  <td>\n";
-        echo "      <input type=\"text\" name=\"title\" size=\"60\" maxlength=\"100\" value=\"$submission->title\" />\n";
-        echo "  </td></tr></table>\n";
-        echo "<input type=\"submit\" value=\"".get_string("amendtitle", "workshop")."\" />\n";
-        echo "</div></fieldset></form>\n";
-
-        print_heading("<a $CFG->frametarget href=\"view.php?id=$cm->id#sid=$submission->id\">".get_string("cancel")."</a>");
-    }
-
-
-    /******************* admin clear late (flag) ************************************/
-    elseif ($action == 'adminclearlate' ) {
-
-        require_capability('mod/workshop:manage', $context);
-        if (empty($sid)) {
-            print_error("Admin clear late flag: submission id missing");
-        }
-
-        if (!$submission = get_record("workshop_submissions", "id", $sid)) {
-            print_error("Admin clear late flag: can not get submission record");
-        }
-        if (set_field("workshop_submissions", "late", 0, "id", $sid)) {
-            print_heading(get_string("clearlateflag", "workshop")." ".get_string("ok"));
-        }
-
-        add_to_log($course->id, "workshop", "late flag cleared", "view.php?id=$cm->id", "submission $submission->id");
-
-        redirect("view.php?id=$cm->id");
-    }
-
-
-    /******************* confirm delete ************************************/
-    elseif ($action == 'confirmdelete' ) {
-
-        if (empty($sid)) {
-            print_error("Confirm delete: submission id missing");
-            }
-        notice_yesno(get_string("confirmdeletionofthisitem","workshop", get_string("submission", "workshop")),
-             "submissions.php?action=delete&amp;id=$cm->id&amp;sid=$sid", "view.php?id=$cm->id#sid=$sid");
-        }
-
-
-    /******************* delete ************************************/
-    elseif ($action == 'delete' ) {
-
-        if (empty($sid)) {
-            print_error("Delete: submission id missing");
-        }
-
-        if (!$submission = get_record("workshop_submissions", "id", $sid)) {
-            print_error("Admin delete: can not get submission record");
-        }
-
-        // students are only allowed to delete their own submission and only up to the deadline
-        if (!(workshop_is_teacher($workshop) or
-               (($USER->id = $submission->userid) and ($timenow < $workshop->submissionend)
-                   and (($timenow < $workshop->assessmentstart) or ($timenow < $submission->timecreated + $CFG->maxeditingtime))))) {
-            print_error("You are not authorized to delete this submission");
-        }
-
-        print_string("deleting", "workshop");
-        // first get any assessments...
-        if ($assessments = workshop_get_assessments($submission, 'ALL')) {
-            foreach($assessments as $assessment) {
-                // ...and all the associated records...
-                delete_records("workshop_comments", "assessmentid", $assessment->id);
-                delete_records("workshop_grades", "assessmentid", $assessment->id);
-                echo ".";
-            }
-            // ...now delete the assessments...
-            delete_records("workshop_assessments", "submissionid", $submission->id);
-        }
-        // ...and the submission record...
-        delete_records("workshop_submissions", "id", $submission->id);
-        // ..and finally the submitted file
-        workshop_delete_submitted_files($workshop, $submission);
-
-        redirect("view.php?id=$cm->id");
-    }
-
-
-    /******************* admin (confirm) late flag ************************************/
-    elseif ($action == 'adminlateflag' ) {
-
-        require_capability('mod/workshop:manage', $context);
-        if (empty($sid)) {
-            print_error("Admin confirm late flag: submission id missing");
-        }
-        if (!$submission = get_record("workshop_submissions", "id", $sid)) {
-            print_error("Admin confirm late flag: can not get submission record");
-        }
-
-        notice_yesno(get_string("clearlateflag","workshop")."?",
-             "submissions.php?action=adminclearlate&amp;id=$cm->id&amp;sid=$sid",
-             "view.php?id=$cm->id");
-    }
-
-
-    /******************* list all submissions ************************************/
-    elseif ($action == 'adminlist' ) {
-
-        require_capability('mod/workshop:manage', $context);
-
-        workshop_list_submissions_for_admin($workshop, $order);
-        print_continue("view.php?id=$cm->id");
-
-    }
-
-
-    /******************* admin update title ************************************/
-    elseif ($action == 'adminupdatetitle' ) {
-
-        require_capability('mod/workshop:manage', $context);
-        if (empty($sid)) {
-            print_error("Admin Update Title: submission id missing");
-        }
-
-        if (set_field("workshop_submissions", "title", $title, "id", $sid)) {
-            print_heading(get_string("amendtitle", "workshop")." ".get_string("ok"));
-        }
-        print_continue("view.php?id=$cm->id");
-    }
-
-
-    /******************* confirm remove attachments ************************************/
-    elseif ($action == 'confirmremoveattachments' ) {
-
-        if (empty($sid)) {
-            print_error("Admin confirm delete: submission id missing");
-        }
-        if (!$submission = get_record("workshop_submissions", "id", $sid)) {
-            print_error("Admin delete: can not get submission record");
-        }
-
-        notice_yesno(get_string("confirmremoveattachments","workshop"),
-             "submissions.php?action=removeattachments&amp;id=$cm->id&amp;sid=$sid",
-             "view.php?id=$cm->id");
-    }
-
-
-    /******************* edit submission ************************************/
-    elseif ($action == 'editsubmission' ) {
-
-        if (empty($sid)) {
-            print_error("Edit submission: submission id missing");
-        }
-        $usehtmleditor = can_use_html_editor();
-
-        $submission = get_record("workshop_submissions", "id", $sid);
-        print_heading(get_string("editsubmission", "workshop"));
-        if ($submission->userid <> $USER->id) {
-            print_error("Edit submission: Userids do not match");
-        }
-        if (($submission->timecreated < ($timenow - $CFG->maxeditingtime)) and ($workshop->assessmentstart < $timenow)) {
-            print_error('notallowed', 'workshop');
-        }
-        ?>
-        <form id="editform" enctype="multipart/form-data" action="submissions.php" method="post">
-        <fieldset class="invisiblefieldset">
-        <input type="hidden" name="action" value="updatesubmission" />
-        <input type="hidden" name="id" value="<?php echo $cm->id ?>" />
-        <input type="hidden" name="sid" value="<?php echo $sid ?>" />
-        <div class="boxaligncenter">
-        <table cellpadding="5" border="1">
-        <?php
-        echo "<tr valign=\"top\"><td><b>". get_string("title", "workshop").":</b>\n";
-        echo "<input type=\"text\" name=\"title\" size=\"60\" maxlength=\"100\" value=\"$submission->title\" />\n";
-        echo "</td></tr><tr><td><b>".get_string("submission", "workshop").":</b><br />\n";
-        print_textarea($usehtmleditor, 25,70, 630, 400, "description", $submission->description);
-        use_html_editor("description");
-        echo "</td></tr>\n";
-        if ($workshop->nattachments) {
-            $filearea = workshop_file_area_name($workshop, $submission);
-            if ($basedir = workshop_file_area($workshop, $submission)) {
-                if ($files = get_directory_list($basedir)) {
-                    echo "<tr><td><b>".get_string("attachments", "workshop").
-                        "</b><div style=\"text-align:right;\"><input type=\"button\" value=\"".get_string("removeallattachments",
-                        "workshop")."\" onclick=\"getElementById('editform').action.value='removeattachments';
-                        getElementById('editform').submit();\"/></div></td></tr>\n";
-                    $n = 1;
-                    foreach ($files as $file) {
-                        $icon = mimeinfo("icon", $file);
-                        if ($CFG->slasharguments) {
-                            $ffurl = "file.php/$filearea/$file";
-                        } else {
-                            $ffurl = "file.php?file=/$filearea/$file";
-                        }
-                        // removed target=\"uploadedfile\" 
-                        // as it does not validate MDL_7861
-                        echo "<tr><td>".get_string("attachment", "workshop")." $n: <img src=\"$CFG->pixpath/f/$icon\"
-                            class=\"icon\" alt=\"".get_string('file')."\" />".
-                            "&nbsp;<a href=\"$CFG->wwwroot/$ffurl\">$file</a></td></tr>\n";
-                    }
-                } else {
-                    echo "<tr><td><b>".get_string("noattachments", "workshop")."</b></td></tr>\n";
-                }
-            }
-            echo "<tr><td>\n";
-            require_once($CFG->dirroot.'/lib/uploadlib.php');
-            for ($i=0; $i < $workshop->nattachments; $i++) {
-                $iplus1 = $i + 1;
-                $tag[$i] = get_string("newattachment", "workshop")." $iplus1:";
-            }
-            upload_print_form_fragment($workshop->nattachments,null,$tag,false,null,$course->maxbytes,
-                $workshop->maxbytes,false);
-            echo "</td></tr>\n";
-        }
-
-        echo "</table>\n";
-        echo "<input type=\"submit\" value=\"".get_string("savemysubmission", "workshop")."\" />\n";
-        echo "</div></fieldset></form>\n";
-    }
-
-
-    /******************* list all submissions ************************************/
-    elseif ($action == 'listallsubmissions' ) {
-        if (!$users = workshop_get_students($workshop)) {
-            print_heading(get_string("nostudentsyet"));
-            print_footer($course);
-            exit;
-        }
-        print_heading(get_string("listofallsubmissions", "workshop").":", "CENTER");
-        workshop_list_all_submissions($workshop, $USER);
-        print_continue("view.php?id=$cm->id");
-
-    }
-
-
-    /******************* list for assessment student (submissions) ************************************/
-    elseif ($action == 'listforassessmentstudent' ) {
-        if (!$users = workshop_get_students($workshop)) {
-            print_heading(get_string("nostudentsyet"));
-            print_footer($course);
-            exit;
-        }
-        workshop_list_unassessed_student_submissions($workshop, $USER);
-        print_continue("view.php?id=$cm->id");
-
-    }
-
-
-    /******************* list for assessment teacher (submissions) ************************************/
-    elseif ($action == 'listforassessmentteacher' ) {
-
-        require_capability('mod/workshop:manage', $context);
-
-        workshop_list_unassessed_teacher_submissions($workshop, $USER);
-        print_continue("view.php?id=$cm->id");
-
-    }
-
-
-    /******************* remove (all) attachments ************************************/
-    elseif ($action == 'removeattachments' ) {
-
-        $form = data_submitted();
-
-        if (empty($form->sid)) {
-            print_error("Update submission: submission id missing");
-        }
-
-        $submission = get_record("workshop_submissions", "id", $form->sid);
-
-        // students are only allowed to remove their own attachments and only up to the deadline
-        if (!(workshop_is_teacher($workshop) or
-               (($USER->id = $submission->userid) and ($timenow < $workshop->submissionend)
-                   and (($timenow < $workshop->assessmentstart) or ($timenow < $submission->timecreated + $CFG->maxeditingtime))))) {
-            print_error("You are not authorized to delete these attachments");
-        }
-
-        // amend title... just in case they were modified
-        // check existence of title
-        if (empty($form->title)) {
-            notify(get_string("notitlegiven", "workshop"));
-        } else {
-            set_field("workshop_submissions", "title", $form->title, "id", $submission->id);
-            set_field("workshop_submissions", "description", trim($form->description), "id", $submission->id);
-        }
-        print_string("removeallattachments", "workshop");
-        workshop_delete_submitted_files($workshop, $submission);
-        add_to_log($course->id, "workshop", "removeattachments", "view.php?id=$cm->id", "submission $submission->id");
-
-        print_continue("view.php?id=$cm->id#sid=$submission->id");
-    }
-
-
-    /******************* show submission ************************************/
-    elseif ($action == 'showsubmission' ) {
-
-        if (empty($sid)) {
-            print_error("Show submission: submission id missing");
-        }
-
-        $submission = get_record("workshop_submissions", "id", $sid);
-        $title = '"'.$submission->title.'" ';
-        if (workshop_is_teacher($workshop)) {
-            $title .= get_string('by', 'workshop').' '.workshop_fullname($submission->userid, $course->id);
-        }
-        print_heading($title);
-        echo '<div style="text-align:center">'.get_string('submitted', 'workshop').': '.userdate($submission->timecreated).'</div><br />';
-        workshop_print_submission($workshop, $submission);
-        print_continue(htmlentities($_SERVER['HTTP_REFERER'].'#sid='.$submission->id));
-    }
-
-
-    /*************** update (league table options teacher) ***************************/
-    elseif ($action == 'updateleaguetable') {
-
-        require_capability('mod/workshop:manage', $context);
-
-        // save number of entries in showleaguetable option
-        if ($nentries == 'All') {
-            $nentries = 99;
-        }
-        set_field("workshop", "showleaguetable", $nentries, "id", "$workshop->id");
-
-        // save the anonymous option
-        set_field("workshop", "anonymous", $anonymous, "id", "$workshop->id");
-        add_to_log($course->id, "workshop", "league table", "view.php?id=$cm->id", $nentries, $cm->id);
-
-        redirect("view.php?id=$cm->id");
-    }
-
-
-    /*************** update submission ***************************/
-    elseif ($action == 'updatesubmission') {
-
-        if (empty($sid)) {
-            print_error("Update submission: submission id missing");
-        }
-        $submission = get_record("workshop_submissions", "id", $sid);
-
-        // students are only allowed to update their own submission and only up to the deadline
-        if (!(workshop_is_teacher($workshop) or
-               (($USER->id = $submission->userid) and ($timenow < $workshop->submissionend)
-                   and (($timenow < $workshop->assessmentstart) or ($timenow < $submission->timecreated + $CFG->maxeditingtime))))) {
-            print_error("You are not authorized to update your submission");
-        }
-
-        // check existence of title
-        if (empty($title)) {
-            $title = get_string("notitle", "workshop");
-        }
-        set_field("workshop_submissions", "title", $title, "id", $submission->id);
-        set_field("workshop_submissions", "description", trim($description), "id", $submission->id);
-        set_field("workshop_submissions", "timecreated", $timenow, "id", $submission->id);
-        if ($workshop->nattachments) {
-            require_once($CFG->dirroot.'/lib/uploadlib.php');
-            $um = new upload_manager(null,false,false,$course,false,$workshop->maxbytes);
-            if ($um->preprocess_files()) {
-                $dir = workshop_file_area_name($workshop, $submission);
-                if ($um->save_files($dir)) {
-                    add_to_log($course->id, "workshop", "newattachment", "view.php?id=$cm->id", "$workshop->id");
-                    print_heading(get_string("uploadsuccess", "workshop"));
-                }
-                // upload manager will print errors.
-            }
-            print_continue("view.php?id=$cm->id");
-        } else {
-            echo '</div>'; // close <div id='page'>
-            redirect("view.php?id=$cm->id#sid=$submission->id");
-        }
-    }
-
-
-    /*************** no man's land **************************************/
-
-    else {
-
-        print_error("Fatal Error: Unknown Action: ".$action."\n");
-
-    }
-
-
-    print_footer($course);
-
-?>
diff --git a/mod/workshop/upload.php b/mod/workshop/upload.php
deleted file mode 100644 (file)
index 62a572c..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-<?php  // $Id$
-
-    require("../../config.php");
-    require("lib.php");
-    require("locallib.php");
-
-    $id = required_param('id', PARAM_INT);          // CM ID
-
-
-    if (! $cm = get_record("course_modules", "id", $id)) {
-        print_error("Course Module ID was incorrect");
-    }
-    if (! $course = get_record("course", "id", $cm->course)) {
-        print_error("Course is misconfigured");
-    }
-    if (! $workshop = get_record("workshop", "id", $cm->instance)) {
-        print_error("Course module is incorrect");
-    }
-
-    require_login($course->id, false, $cm);
-
-    $strworkshops = get_string('modulenameplural', 'workshop');
-    $strworkshop = get_string('modulename', 'workshop');
-    $strsubmission = get_string('submission', 'workshop');
-
-    $navigation = build_navigation($strsubmission, $cm);
-    print_header_simple(format_string($workshop->name)." : $strsubmission", "", $navigation,
-                  "", "", true);
-    $timenow = time();
-
-    $form = data_submitted("nomatch"); // POST may come from two forms
-
-    // don't be picky about not having a title
-    if (!$title = $form->title) {
-        $title = get_string("notitle", "workshop");
-    }
-
-    // check that this is not a "rapid" second submission, caused by using the back button
-    // only check if a student, teachers may want to submit a set of workshop examples rapidly
-    if (workshop_is_student($workshop)) {
-        if ($submissions = workshop_get_user_submissions($workshop, $USER)) {
-            // returns all submissions, newest on first
-            foreach ($submissions as $submission) {
-                if ($submission->timecreated > $timenow - $CFG->maxeditingtime) {
-                    // ignore this new submission
-                    redirect("view.php?id=$cm->id");
-                    print_footer($course);
-                    exit();
-                }
-            }
-        }
-    }
-
-    // get the current set of submissions
-    $submissions = workshop_get_user_submissions($workshop, $USER);
-    // add new submission record
-    $newsubmission->workshopid  = $workshop->id;
-    $newsubmission->userid      = $USER->id;
-    $newsubmission->title       = clean_param($title, PARAM_CLEAN);
-    $newsubmission->description = trim(clean_param($form->description, PARAM_CLEAN));
-    $newsubmission->timecreated = $timenow;
-    if ($timenow > $workshop->submissionend) {
-        $newsubmission->late = 1;
-    }
-    if (!$newsubmission->id = insert_record("workshop_submissions", $newsubmission)) {
-        print_error("Workshop submission: Failure to create new submission record!");
-    }
-    // see if this is a resubmission by looking at the previous submissions...
-    if ($submissions and ($workshop->submissionstart > time())) { // ...but not teacher submissions
-        // find the last submission
-        foreach ($submissions as $submission) {
-            $lastsubmission = $submission;
-            break;
-        }
-        // find all the possible assessments of this submission
-        // ...and if they have been assessed give the assessor a new assessment
-        // based on their old assessment, if the assessment has not be made
-        // just delete it!
-        if ($assessments = workshop_get_assessments($submission, 'ALL')) {
-            foreach ($assessments as $assessment) {
-                if ($assessment->timecreated < $timenow) {
-                    // a Cold or Warm assessment...
-                    if ($assessment->userid <> $USER->id) {
-                        // only copy other students assessment not the self assessment (if present)
-                        // copy it with feedback..
-                        $newassessment = workshop_copy_assessment($assessment, $newsubmission, true);
-                        // set the resubmission flag so student can be emailed/told about
-                        // this assessment
-                        set_field("workshop_assessments", "resubmission", 1, "id", $newassessment->id);
-                    }
-                } else {
-                    // a hot assessment, was not used, just dump it
-                    delete_records("workshop_assessments", "id", $assessment->id);
-                }
-            }
-        }
-        add_to_log($course->id, "workshop", "resubmit", "view.php?id=$cm->id", "$workshop->id","$cm->id");
-    }
-    // do something about the attachments, if there are any
-    if ($workshop->nattachments) {
-        require_once($CFG->dirroot.'/lib/uploadlib.php');
-        $um = new upload_manager(null,false,false,$course,false,$workshop->maxbytes);
-        if ($um->preprocess_files()) {
-            $dir = workshop_file_area_name($workshop, $newsubmission);
-            if ($um->save_files($dir)) {
-                print_heading(get_string("uploadsuccess", "workshop"));
-            }
-        // um will take care of printing errors.
-        }
-    }
-    if (!$workshop->nattachments) {
-        print_heading(get_string("submitted", "workshop")." ".get_string("ok"));
-    }
-    add_to_log($course->id, "workshop", "submit", "view.php?id=$cm->id", "$workshop->id", "$cm->id");
-    print_continue("view.php?id=$cm->id");
-    print_footer($course);
-
-?>
diff --git a/mod/workshop/version.php b/mod/workshop/version.php
deleted file mode 100644 (file)
index 5b5ec1d..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php // $Id$
-
-////////////////////////////////////////////////////////////////////////////////
-//  Code fragment to define the module version etc.
-//  This fragment is called by /admin/index.php
-////////////////////////////////////////////////////////////////////////////////
-
-$module->version  = 2007101509;
-$module->requires = 2007101509;  // Requires this Moodle version
-$module->cron     = 60;
-
-?>
diff --git a/mod/workshop/view.php b/mod/workshop/view.php
deleted file mode 100644 (file)
index b6beb13..0000000
+++ /dev/null
@@ -1,578 +0,0 @@
-<?php  // $Id$
-
-/*************************************************
-    ACTIONS handled are:
-
-    displayfinalgrade (for students)
-    notavailable (for students)
-    studentsview
-    submitexample
-    teachersview
-    showdescription
-    showallsubmissions
-
-************************************************/
-
-    require("../../config.php");
-    require("lib.php");
-    require("locallib.php");
-
-    $id     = required_param('id', PARAM_INT);    // Course Module ID
-    $action = optional_param('action', '', PARAM_ALPHA);
-    $sort   = optional_param('sort', 'lastname', PARAM_ALPHA);
-    $dir    = optional_param('dir', 'ASC', PARAM_ALPHA);
-
-    $timenow = time();
-
-    // get some useful stuff...
-    if (! $cm = get_coursemodule_from_id('workshop', $id)) {
-        print_error("Course Module ID was incorrect");
-    }
-    if (! $course = get_record("course", "id", $cm->course)) {
-        print_error("Course is misconfigured");
-    }
-    if (! $workshop = get_record("workshop", "id", $cm->instance)) {
-        print_error("Course module is incorrect");
-    }
-
-    require_login($course->id, false, $cm);
-    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
-    $strworkshops = get_string("modulenameplural", "workshop");
-    $strworkshop  = get_string("modulename", "workshop");
-
-    // ...and if necessary set default action
-    if (workshop_is_teacher($workshop)) {
-        if (empty($action)) { // no action specified, either go straight to elements page else the admin page
-            // has the assignment any elements
-            if (count_records("workshop_elements", "workshopid", $workshop->id) >= $workshop->nelements) {
-                $action = "teachersview";
-            }
-            else {
-                redirect("assessments.php?action=editelements&id=$cm->id");
-            }
-        }
-    } else { // it's a student then
-        if (!$cm->visible) {
-            notice(get_string("activityiscurrentlyhidden"));
-        }
-        if ($timenow < $workshop->submissionstart) {
-            $action = 'notavailable';
-        } else if (!$action) {
-            if ($timenow < $workshop->assessmentend) {
-                $action = 'studentsview';
-            } else {
-                $action = 'displayfinalgrade';
-            }
-        }
-    }
-
-    // ...display header...
-    $navigation = build_navigation($action, $cm);    
-    print_header_simple(format_string($workshop->name), "", $navigation,
-                  "", "", true, update_module_button($cm->id, $course->id, $strworkshop), navmenu($course, $cm));
-
-
-    // ...log activity...
-    add_to_log($course->id, "workshop", "view", "view.php?id=$cm->id", $workshop->id, $cm->id);
-
-    if ($action == 'studentsview' and !workshop_is_student($workshop)) {
-        $action = 'showdescription';
-    }
-
-    /****************** display final grade (for students) ************************************/
-    if ($action == 'displayfinalgrade' ) {
-        require_capability('mod/workshop:participate', $context);
-
-        print_heading("<b><a href=\"view.php?id=$cm->id&amp;action=showdescription\">".
-                get_string("showdescription", 'workshop')."</a></b>");
-        // show the final grades as stored in the tables...
-        if ($submissions = workshop_get_user_submissions($workshop, $USER)) { // any submissions from user?
-            print_heading(get_string("displayoffinalgrades", "workshop"));
-            echo "<div class=\"boxaligncenter\"><table border=\"1\" width=\"90%\"><tr>";
-            echo "<td><b>".get_string("submissions", "workshop")."</b></td>";
-            if ($workshop->wtype) {
-                echo "<td align=\"center\"><b>".get_string("assessmentsdone", "workshop")."</b></td>";
-                echo "<td align=\"center\"><b>".get_string("gradeforassessments", "workshop")."</b></td>";
-            }
-            echo "<td align=\"center\"><b>".get_string("teacherassessments", "workshop",
-                        $course->teacher)."</b></td>";
-            if ($workshop->wtype) {
-                echo "<td align=\"center\"><b>".get_string("studentassessments", "workshop",
-                        $course->student)."</b></td>";
-            }
-            echo "<td align=\"center\"><b>".get_string("gradeforsubmission", "workshop")."</b></td>";
-            echo "<td align=\"center\"><b>".get_string("overallgrade", "workshop")."</b></td></tr>\n";
-            foreach ($submissions as $submission) {
-                $grade = workshop_submission_grade($workshop, $submission);
-                echo "<tr><td>".workshop_print_submission_title($workshop, $submission)."</td>\n";
-                if ($workshop->wtype) {
-                    echo "<td align=\"center\">".workshop_print_user_assessments($workshop, $USER, $gradinggrade)."</td>";
-                    echo "<td align=\"center\">$gradinggrade</td>";
-                }
-                echo "<td align=\"center\">".workshop_print_submission_assessments($workshop,
-                            $submission, "teacher")."</td>";
-                if ($workshop->wtype) {
-                    echo "<td align=\"center\">".workshop_print_submission_assessments($workshop,
-                            $submission, "student")."</td>";
-                }
-                echo "<td align=\"center\">$grade</td>";
-                echo "<td align=\"center\">".number_format($gradinggrade + $grade, 1)."</td></tr>\n";
-            }
-            echo "</table></div><br clear=\"all\" />\n";
-            workshop_print_key($workshop);
-        } else {
-            print_heading(get_string('nowork', 'workshop'));
-        }
-        if ($workshop->showleaguetable) {
-            workshop_print_league_table($workshop);
-        }
-    }
-
-
-    /****************** assignment not available (for students)***********************/
-    elseif ($action == 'notavailable') {
-        print_heading(get_string("notavailable", "workshop"));
-    }
-
-    /****************** student's view could be in 1 of 4 stages ***********************/
-    elseif ($action == 'studentsview') {
-        require_capability('mod/workshop:participate', $context);
-
-        // is a password needed?
-        if ($workshop->usepassword) {
-            $correctpass = false;
-            if (isset($_POST['userpassword'])) {
-                if ($workshop->password == md5(trim($_POST['userpassword']))) {
-                    $USER->workshoploggedin[$workshop->id] = true;
-                    $correctpass = true;
-                }
-            } elseif (isset($USER->workshoploggedin[$workshop->id])) {
-                $correctpass = true;
-            }
-
-            if (!$correctpass) {
-                print_simple_box_start("center");
-                echo "<form id=\"password\" method=\"post\" action=\"view.php\">\n";
-                echo "<input type=\"hidden\" name=\"id\" value=\"$cm->id\" />\n";
-                echo "<table cellpadding=\"7px\">";
-                if (isset($_POST['userpassword'])) {
-                    echo "<tr align=\"center\" style='color:#DF041E;'><td>".get_string("wrongpassword", "workshop").
-                        "</td></tr>";
-                }
-                echo "<tr align=\"center\"><td>".get_string("passwordprotectedworkshop", "workshop", format_string($workshop->name)).
-                    "</td></tr>";
-                echo "<tr align=\"center\"><td>".get_string("enterpassword", "workshop").
-                    " <input type=\"password\" name=\"userpassword\" /></td></tr>";
-
-                echo "<tr align=\"center\"><td>";
-                echo "<input type=\"button\" value=\"".get_string("cancel").
-                    "\" onclick=\"parent.location='../../course/view.php?id=$course->id';\">  ";
-                echo "<input type=\"button\" value=\"".get_string("continue").
-                    "\" onclick=\"document.password.submit();\" />";
-                echo "</td></tr></table>";
-                print_simple_box_end();
-                exit();
-            }
-        }
-        workshop_print_assignment_info($workshop);
-
-        // if the student has not yet submitted show the full description
-        if (!record_exists('workshop_submissions', 'workshopid', $workshop->id, 'userid', $USER->id)) {
-            print_box(format_text($workshop->description, $workshop->format), 'generalbox', 'intro');
-        } else {
-            print_heading("<b><a href=\"view.php?id=$cm->id&amp;action=showdescription\">".
-                get_string("showdescription", 'workshop')."</a></b>");
-        }
-
-        // in Stage 1? - are there any teacher's submissions? and...
-        // ...has student assessed the required number of the teacher's submissions
-        if ($workshop->ntassessments and (!workshop_test_user_assessments($workshop, $USER))) {
-            print_heading(get_string("pleaseassesstheseexamplesfromtheteacher", "workshop",
-                        $course->teacher));
-            workshop_list_teacher_submissions($workshop, $USER);
-        }
-        // in stage 2? - submit own first attempt
-        else {
-            if ($workshop->ntassessments) {
-                // show assessment of the teacher's examples, there may be feedback from teacher
-                print_heading(get_string("yourassessmentsofexamplesfromtheteacher", "workshop",
-                            $course->teacher));
-                workshop_list_teacher_submissions($workshop, $USER);
-            }
-            // has user submitted anything yet?
-            if (!workshop_get_user_submissions($workshop, $USER)) {
-                if ($timenow < $workshop->submissionend) {
-                    // print upload form
-                    print_heading(get_string("submitassignmentusingform", "workshop").":");
-                    workshop_print_upload_form($workshop);
-                } else {
-                    print_heading(get_string("submissionsnolongerallowed", "workshop"));
-                }
-            }
-            // in stage 3? - grade other student's submissions, resubmit and list all submissions
-            else {
-                // is self assessment used in this workshop?
-                if ($workshop->includeself) {
-                    // prints a table if there are any submissions which have not been self assessed yet
-                    workshop_list_self_assessments($workshop, $USER);
-                }
-                // if peer assessments are being done then show some  to assess...
-                if ($workshop->nsassessments and ($workshop->assessmentstart < $timenow and $workshop->assessmentend > $timenow)) {
-                    workshop_list_student_submissions($workshop, $USER);
-                }
-                // ..and any they have already done (and have gone cold)...
-                if (workshop_count_user_assessments($workshop, $USER, "student")) {
-                    print_heading(get_string("yourassessments", "workshop"));
-                    workshop_list_assessed_submissions($workshop, $USER);
-                }
-                // list any assessments by teachers
-                if (workshop_count_teacher_assessments_by_user($workshop, $USER) and ($timenow > $workshop->releasegrades)) {
-                    print_heading(get_string("assessmentsby", "workshop", $course->teachers));
-                    workshop_list_teacher_assessments_by_user($workshop, $USER);
-                }
-                // ... and show peer assessments
-                if (workshop_count_peer_assessments($workshop, $USER)) {
-                    print_heading(get_string("assessmentsby", "workshop", $course->students));
-                    workshop_list_peer_assessments($workshop, $USER);
-                }
-                // list previous submissions
-                print_heading(get_string("yoursubmissions", "workshop"));
-                workshop_list_user_submissions($workshop, $USER);
-
-                // are resubmissions allowed and the workshop is in submission/assessment phase?
-                if ($workshop->resubmit and ($timenow > $workshop->assessmentstart and $timenow < $workshop->submissionend)) {
-                    // see if there are any cold assessments of the last submission
-                    // if there are then print upload form
-                    if ($submissions = workshop_get_user_submissions($workshop, $USER)) {
-                        foreach ($submissions as $submission) {
-                            $lastsubmission = $submission;
-                            break;
-                        }
-                        $n = 0; // number of cold assessments (not include self assessments)
-                        if ($assessments = workshop_get_assessments($lastsubmission)) {
-                            foreach ($assessments as $assessment) {
-                                if ($assessment->userid <> $USER->id) {
-                                    $n++;
-                                }
-                            }
-                        }
-                        if ($n) {
-                            echo "<hr size=\"1\" noshade=\"noshade\" />";
-                            print_heading(get_string("submitrevisedassignment", "workshop").":");
-                            workshop_print_upload_form($workshop);
-                            echo "<hr size=\"1\" noshade=\"noshade\" />";
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-
-    /****************** submission of example by teacher only***********************/
-    elseif ($action == 'submitexample') {
-
-        require_capability('mod/workshop:manage', $context);
-
-        // list previous submissions from teacher
-        workshop_list_user_submissions($workshop, $USER);
-
-        echo "<hr size=\"1\" noshade=\"noshade\" />";
-
-        // print upload form
-        print_heading(get_string("submitexampleassignment", "workshop").":");
-        workshop_print_upload_form($workshop);
-
-        print_heading("<a $CFG->frametarget href=\"view.php?id=$cm->id\">".get_string("cancel")."</a>");
-    }
-
-
-    /****************** teacher's view - display admin page  ************/
-    elseif ($action == 'teachersview') {
-
-        require_capability('mod/workshop:manage', $context);
-
-        // automatically grade assessments if workshop has examples and/or peer assessments
-        if ($workshop->gradingstrategy and ($workshop->ntassessments or $workshop->nsassessments)) {
-            workshop_grade_assessments($workshop);
-        }
-
-        $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
-        /// find out current groups mode
-        $groupmode = groups_get_activity_groupmode($cm);
-        $currentgroup = groups_get_activity_group($cm, true);
-        groups_print_activity_menu($cm, "view.php?id=$cm->id");
-
-        /// Print admin links
-        echo "<table width=\"100%\"><tr><td>";
-        echo "<a href=\"submissions.php?id=$cm->id&amp;action=adminlist\">".
-            get_string("administration")."</a>\n";
-
-        echo '</td></tr>';
-
-        echo '<tr><td>';
-        workshop_print_assignment_info($workshop);
-        print_heading("<a href=\"view.php?id=$cm->id&amp;action=showdescription\">".
-               get_string("showdescription", 'workshop')."</a>");
-        echo '</td></tr>';
-
-        /// Print grade tables /////////////////////////////////////////////////
-
-        // display the teacher's submissions
-        if ($workshop->ntassessments) {
-            $table->head = array(get_string("examplesubmissions", "workshop"),
-                get_string("assessmentsby", "workshop", $course->teachers),
-                get_string("assessmentsby", "workshop", $course->students));
-            $table->data = array();
-            if ($submissions = workshop_get_teacher_submissions($workshop)) {
-                foreach ($submissions as $submission) {
-                    $teacherassessments = workshop_print_submission_assessments($workshop, $submission, "teacher");
-                    // If not yet assessed, show assess link
-                    if ($teacherassessments == '&nbsp;') {
-                        $teacherassessments = '<a href="assess.php?id='.
-                            $cm->id.'&amp;sid='.$submission->id.'">'.get_string('assess', 'workshop').'</a>';
-                    }
-                    $title = workshop_print_submission_title($workshop, $submission).
-                        " <a href=\"submissions.php?action=editsubmission&amp;id=$cm->id&amp;sid=$submission->id\">".
-                        "<img src=\"$CFG->pixpath/t/edit.gif\" ".
-                        'class="iconsmall" alt="'.get_string('edit').'" /></a>'.
-                        " <a href=\"submissions.php?action=confirmdelete&amp;id=$cm->id&amp;sid=$submission->id\">".
-                        "<img src=\"$CFG->pixpath/t/delete.gif\" ".
-                        'class="iconsmall" alt="'.get_string('delete', 'workshop').'" /></a>';
-                    $table->data[] = array($title, $teacherassessments,
-                        workshop_print_submission_assessments($workshop, $submission, "student"));
-                }
-            }
-            // Put in a submission link
-            $table->data[] = array("<b><a href=\"view.php?id=$cm->id&amp;action=submitexample\">".
-                get_string("submitexampleassignment", "workshop")."</a></b>".
-                helpbutton("submissionofexamples", get_string("submitexampleassignment", "workshop"), "workshop", true, false, '', true),
-                '&nbsp;', '&nbsp;');
-            print_table($table);
-            workshop_print_key($workshop);
-        }
-
-        // Get all the students
-        if (!$users = workshop_get_students($workshop)) {
-            echo ('</table>');
-            print_heading(get_string("nostudentsyet"));
-            print_footer($course);
-            exit;
-        }
-        
-        if (!empty($CFG->enablegroupings) && !empty($cm->groupingid) && !empty($users)) {
-            $groupingusers = groups_get_grouping_members($cm->groupingid, 'u.id', 'u.id');
-            foreach($users as $key => $user) {
-                if (!isset($groupingusers[$user->id])) {
-                    unset($users[$key]);
-                }
-            }
-        }
-
-        /// Now prepare table with student assessments and submissions
-        $tablesort->data = array();
-        $tablesort->sortdata = array();
-        foreach ($users as $user) {
-            // skip if student not in group
-            if ($currentgroup) {
-                if (!groups_is_member($currentgroup, $user->id)) {
-                    continue;
-                }
-            }
-            if ($submissions = workshop_get_user_submissions($workshop, $user)) {
-                foreach ($submissions as $submission) {
-                    $data = array();
-                    $sortdata = array();
-
-                    $data[] = "<a name=\"userid$user->id\" href=\"{$CFG->wwwroot}/user/view.php?id=$user->id&amp;course=$course->id\">".
-                        fullname($user).'</a>';
-                    $sortdata['firstname'] = $user->firstname;
-                    $sortdata['lastname'] = $user->lastname;
-
-                    if ($workshop->wtype) {
-                        $data[] = workshop_print_user_assessments($workshop, $user, $gradinggrade);
-
-                        $data[] = $gradinggrade;
-                        $sortdata['agrade'] = $gradinggrade;
-                    }
-
-                    $data[] = workshop_print_submission_title($workshop, $submission).
-                        " <a href=\"submissions.php?action=adminamendtitle&amp;id=$cm->id&amp;sid=$submission->id\">".
-                        "<img src=\"$CFG->pixpath/t/edit.gif\" ".
-                        'class="iconsmall" alt="'.get_string('amendtitle', 'workshop').'" /></a>'.
-                        " <a href=\"submissions.php?action=confirmdelete&amp;id=$cm->id&amp;sid=$submission->id\">".
-                        "<img src=\"$CFG->pixpath/t/delete.gif\" ".
-                        'class="iconsmall" alt="'.get_string('delete', 'workshop').'" /></a>';
-                    $sortdata['title'] = $submission->title;
-
-                    $data[] = userdate($submission->timecreated, get_string('datestr', 'workshop'));
-                    $sortdata['date'] = $submission->timecreated;
-
-                    if (($tmp = workshop_print_submission_assessments($workshop, $submission, "teacher")) == '&nbsp;') {
-                        $data[] = '<a href="assess.php?id='.
-                            $cm->id.'&amp;sid='.$submission->id.'">'.get_string('assess', 'workshop').'</a>';
-                        $sortdata['tassmnt'] = -1;
-                    } else {
-                        $data[] = $tmp;
-                        $sortdata['tassmnt'] = 1; // GWD still have to fix this
-                    }
-
-                    if ($workshop->wtype) {
-                        $data[] = workshop_print_submission_assessments($workshop, $submission, "student");
-                    }
-
-                    $grade = workshop_submission_grade($workshop, $submission);
-                    $data[] = $grade;
-                    $sortdata['sgrade'] = $grade;
-
-                    if ($workshop->wtype) {
-                        $data[] = number_format($gradinggrade + $grade, 1);
-                        $sortdata['ograde'] = $gradinggrade + $grade;
-                    }
-
-                    $tablesort->data[] = $data;
-                    $tablesort->sortdata[] = $sortdata;
-                }
-            }
-        }
-
-        function workshop_sortfunction($a, $b) {
-           global $sort, $dir;
-           if ($dir == 'ASC') {
-               return ($a[$sort] > $b[$sort]);
-           } else {
-               return ($a[$sort] < $b[$sort]);
-           }
-        }
-        uasort($tablesort->sortdata, 'workshop_sortfunction');
-        $table->data = array();
-        foreach($tablesort->sortdata as $key => $row) {
-            $table->data[] = $tablesort->data[$key];
-        }
-
-        if ($workshop->wtype) {
-            $table->align = array ('left', 'center', 'center', 'left', 'center', 'center', 'center', 'center', 'center', 'center');
-            $columns = array('firstname', 'lastname', 'agrade', 'title', 'date', 'tassmnt', 'sgrade', 'ograde');
-        } else {
-            $table->align = array ('left', 'left', 'center', 'center', 'center', 'center');
-            $columns = array('firstname', 'lastname', 'title', 'date', 'tassmnt', 'ograde');
-        }
-        $table->width = "95%";
-
-        foreach ($columns as $column) {
-            $string[$column] = get_string("$column", 'workshop');
-            if ($sort != $column) {
-                $columnicon = '';
-                $columndir = 'ASC';
-            } else {
-                $columndir = $dir == 'ASC' ? 'DESC':'ASC';
-                if ($column == 'lastaccess') {
-                    $columnicon = $dir == 'ASC' ? 'up':'down';
-                } else {
-                    $columnicon = $dir == 'ASC' ? 'down':'up';
-                }
-                $columnicon = " <img src=\"$CFG->pixpath/t/$columnicon.gif\" alt=\"$columnicon\" />";
-
-            }
-            $$column = "<a href=\"view.php?id=$id&amp;sort=$column&amp;dir=$columndir\">".$string[$column]."</a>$columnicon";
-        }
-
-        if ($workshop->wtype) {
-            $table->head = array ("$firstname / $lastname", get_string("assmnts", "workshop"), $agrade,
-                $title, $date, $tassmnt, get_string('passmnts', 'workshop'), $sgrade, $ograde);
-        } else {
-            $table->head = array ("$firstname / $lastname", $title, $date, $tassmnt, $ograde);
-        }
-
-        echo '<tr><td>';
-        print_table($table);
-        echo '</td></tr>';
-        echo '<tr><td>';
-        workshop_print_key($workshop);
-        echo '</td></tr>';
-
-        // grading grade analysis
-        unset($table);
-        $table->head = array (get_string("count", "workshop"), get_string("mean", "workshop"),
-            get_string("standarddeviation", "workshop"), get_string("maximum", "workshop"),
-            get_string("minimum", "workshop"));
-        $table->align = array ("center", "center", "center", "center", "center");
-        $table->size = array ("*", "*", "*", "*", "*");
-        $table->cellpadding = 2;
-        $table->cellspacing = 0;
-        if ($currentgroup) {
-            $stats = get_record_sql("SELECT COUNT(*) as count, AVG(gradinggrade) AS mean,
-                    STDDEV(gradinggrade) AS stddev, MIN(gradinggrade) AS min, MAX(gradinggrade) AS max
-                    FROM {$CFG->prefix}groups_members g, {$CFG->prefix}workshop_assessments a
-                    WHERE g.groupid = $currentgroup AND a.userid = g.userid AND a.timegraded > 0
-                    AND a.workshopid = $workshop->id");
-        } elseif (!empty($cm->groupingid) && !empty($CFG->enablegroupings)) {
-            $stats = get_record_sql("SELECT COUNT(*) as count, AVG(gradinggrade) AS mean,
-                    STDDEV(gradinggrade) AS stddev, MIN(gradinggrade) AS min, MAX(gradinggrade) AS max
-                    FROM {$CFG->prefix}workshop_assessments a
-                    INNER JOIN {$CFG->prefix}groups_members g ON a.userid = g.userid
-                    INNER JOIN {$CFG->prefix}groupings_groups gg ON g.groupid = gg.groupid
-                    WHERE gg.groupingid = {$cm->groupingid} AND a.timegraded > 0
-                    AND a.workshopid = $workshop->id");
-        } else { // no group/all participants
-            $stats = get_record_sql("SELECT COUNT(*) as count, AVG(gradinggrade) AS mean,
-                    STDDEV(gradinggrade) AS stddev, MIN(gradinggrade) AS min, MAX(gradinggrade) AS max
-                    FROM {$CFG->prefix}workshop_assessments a
-                    WHERE a.timegraded > 0 AND a.workshopid = $workshop->id");
-        }
-        $table->data[] = array($stats->count, number_format($stats->mean * $workshop->gradinggrade / 100, 1),
-                number_format($stats->stddev * $workshop->gradinggrade /100, 1),
-                number_format($stats->max * $workshop->gradinggrade / 100, 1),
-                number_format($stats->min* $workshop->gradinggrade / 100, 1));
-        echo '<tr><td>';
-        print_heading(get_string("gradinggrade", "workshop")." ".get_string("analysis", "workshop"));
-        print_table($table);
-        echo '</td></tr>';
-
-        if ($workshop->showleaguetable and time() > $workshop->assessmentend) {
-            workshop_print_league_table($workshop);
-            if ($workshop->anonymous) {
-                echo "<p>".get_string("namesnotshowntostudents", "workshop", $course->students)."</p>\n";
-            }
-        }
-        echo '</table>';
-    }
-
-
-    /****************** show description  ************/
-    elseif ($action == 'showdescription') {
-        workshop_print_assignment_info($workshop);
-        print_box(format_text($workshop->description, $workshop->format), 'generalbox', 'intro');
-        if (isset($_SERVER["HTTP_REFERER"])) {
-            print_continue(htmlentities($_SERVER["HTTP_REFERER"]));
-        } else {
-            print_continue("$CFG->wwwroot/course/view.php?id=$cm->id");
-        }
-    }
-
-
-    /****************** teacher's view - list all submissions  ************/
-    elseif ($action == 'allsubmissions') {
-        require_capability('mod/workshop:manage', $context);
-
-        if ($submissions = get_records('workshop_submissions', 'workshopid', $workshop->id)) {
-            foreach($submissions as $submission) {
-                $user = get_record('user', 'id', $submission->userid);
-                print_heading('"'.$submission->title.'" '.get_string('by', 'workshop').' '.fullname($user));
-                workshop_print_submission($workshop, $submission);
-            }
-        }
-    }
-
-
-    /*************** no man's land **************************************/
-    else {
-        print_error("Fatal Error: Unknown Action: ".$action."\n");
-    }
-
-
-    print_footer($course);
-
-?>
diff --git a/mod/workshop/viewassessment.php b/mod/workshop/viewassessment.php
deleted file mode 100644 (file)
index 93020f5..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php  // $Id$
-
-    require("../../config.php");
-    require("lib.php");
-    require("locallib.php");
-
-    $aid           = required_param('aid', PARAM_INT);   // Assessment ID
-    $allowcomments = optional_param('allowcomments', false, PARAM_BOOL);
-    $redirect      = optional_param('redirect', '', PARAM_URL);
-    $frameset      = optional_param('frameset', '', PARAM_ALPHA);
-
-    if (! $assessment = get_record("workshop_assessments", "id", $aid)) {
-        print_error("Assessment id is incorrect");
-    }
-    if (! $submission = get_record('workshop_submissions', 'id', $assessment->submissionid)) {
-        print_error("Incorrect submission id");
-    }
-    if (! $workshop = get_record("workshop", "id", $submission->workshopid)) {
-        print_error("Submission is incorrect");
-    }
-    if (! $course = get_record("course", "id", $workshop->course)) {
-        print_error("Workshop is misconfigured");
-    }
-    if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
-        print_error("No coursemodule found");
-    }
-
-    if (!$redirect) {
-        $redirect = htmlentities($_SERVER["HTTP_REFERER"].'#sid='.$submission->id);
-    }
-
-    require_login($course->id, false, $cm);
-
-    $strworkshops = get_string("modulenameplural", "workshop");
-    $strworkshop  = get_string("modulename", "workshop");
-    $strassess = get_string("viewassessment", "workshop");
-
-    /// Now check whether we need to display a frameset
-
-    if (empty($frameset)) {
-        if ( get_string('thisdirection') == 'rtl' ) {
-            $direction = ' dir="rtl"';
-        } else {
-            $direction = ' dir="ltr"';
-        }
-        echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n";
-        echo "<html $direction>\n";
-        echo "<head><meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n";
-        echo "<title>{$course->shortname}: ".format_string($workshop->name,true)."</title></head>\n";
-        echo "<frameset rows=\"90%,*\" border=\"10\">";
-        echo "  <frame src=\"viewassessment.php?id=$id&amp;aid=$aid&amp;allowcomments=$allowcomments&amp;frameset=top&amp;redirect=$redirect\" border=\"10\" />";
-        echo "  <frame src=\"viewassessment.php?id=$id&amp;aid=$aid&amp;allowcomments=$allowcomments&amp;frameset=bottom&amp;redirect=$redirect\" />";
-        echo "</frameset>";
-        echo "</html>";
-        exit;
-    }
-
-    /// top frame with the navigation bar and the assessment form
-
-    if ($frameset == "top") {
-        $navigation = build_navigation($strassess, $cm);
-        print_header_simple(format_string($workshop->name), "", $navigation,
-                      "", '', true);
-
-        // show assessment but don't allow changes
-        workshop_print_assessment($workshop, $assessment, false, $allowcomments);
-
-        if (workshop_is_teacher($workshop) and !workshop_is_teacher($workshop, $assessment->userid)) {
-            print_heading_with_help(get_string("gradeassessment", "workshop"), "gradingassessments", "workshop");
-            include('assessment_grading_form.html');
-        }
-        print_continue($redirect);
-        print_footer($course);
-        exit;
-    }
-
-    /// print bottom frame with the submission
-    // removed <base target="_parent" /> as it does not validate
-    print_header('', '', '', '', '');
-    $title = '"'.$submission->title.'" ';
-    if (workshop_is_teacher($workshop)) {
-        $title .= ' '.get_string('by', 'workshop').' '.workshop_fullname($submission->userid, $course->id);
-    }
-    print_heading($title);
-    workshop_print_submission($workshop, $submission);
-    print_footer('none');
-
-?>
index be0ebd33ee005b3540db7fb18b52be263cce0e65..39a3599b7a39c1e6cad184d6f005b04323b99eff 100644 (file)
@@ -192,7 +192,7 @@ fclose($handle);
 //// Outputs pictures from theme or core pix folder. Only used if $CFG->smartpix is
 //// turned on.
 //
-//$nomoodlecookie = true; // Stops it making a session
+//define('NO_MOODLE_COOKIES', true); // session not used here
 //require_once('../config.php');
 //require_once('../lib/filelib.php');
 //global $CFG;
diff --git a/question/type/calculated/db/mysql.php b/question/type/calculated/db/mysql.php
deleted file mode 100644 (file)
index 5ad1bef..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php  // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-// MySQL commands for upgrading this question type
-
-function qtype_calculated_upgrade($oldversion=0) {
-    global $CFG;
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/question/type/calculated/db/postgres7.php b/question/type/calculated/db/postgres7.php
deleted file mode 100644 (file)
index a06ccbc..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php  // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-// PostgreSQL commands for upgrading this question type
-
-function qtype_calculated_upgrade($oldversion=0) {
-    global $CFG;
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/question/type/essay/db/mysql.php b/question/type/essay/db/mysql.php
deleted file mode 100644 (file)
index 5a00788..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php  // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-// MySQL commands for upgrading this question type
-
-function qtype_essay_upgrade($oldversion=0) {
-    global $CFG;
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/question/type/essay/db/postgres7.php b/question/type/essay/db/postgres7.php
deleted file mode 100644 (file)
index 6137345..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php  // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-// PostgreSQL commands for upgrading this question type
-
-function qtype_essay_upgrade($oldversion=0) {
-    global $CFG;
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/question/type/match/db/mysql.php b/question/type/match/db/mysql.php
deleted file mode 100644 (file)
index 7f48be5..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php  // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-// MySQL commands for upgrading this question type
-
-function qtype_match_upgrade($oldversion=0) {
-    global $CFG;
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/question/type/match/db/postgres7.php b/question/type/match/db/postgres7.php
deleted file mode 100644 (file)
index 295cbca..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php  // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-// PostgreSQL commands for upgrading this question type
-
-function qtype_match_upgrade($oldversion=0) {
-    global $CFG;
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/question/type/multianswer/db/mysql.php b/question/type/multianswer/db/mysql.php
deleted file mode 100644 (file)
index 5d62b8e..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php  // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-// MySQL commands for upgrading this question type
-
-function qtype_multianswer_upgrade($oldversion=0) {
-    global $CFG;
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/question/type/multianswer/db/postgres7.php b/question/type/multianswer/db/postgres7.php
deleted file mode 100644 (file)
index 644cbcc..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php  // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-// PostgreSQL commands for upgrading this question type
-
-function qtype_multianswer_upgrade($oldversion=0) {
-    global $CFG;
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/question/type/multichoice/db/mysql.php b/question/type/multichoice/db/mysql.php
deleted file mode 100644 (file)
index e0f78be..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php  // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-// MySQL commands for upgrading this question type
-
-function qtype_multichoice_upgrade($oldversion=0) {
-    global $CFG;
-    $success = true;
-    
-    if ($success && $oldversion < 2006081900) {
-        $success = $success && table_column('question_multichoice', '', 'correctfeedback', 'text', '', '', '');
-        $success = $success && table_column('question_multichoice', '', 'partiallycorrectfeedback', 'text', '', '', '');
-        $success = $success && table_column('question_multichoice', '', 'incorrectfeedback', 'text', '', '', '');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return $success;
-}
-
-?>
diff --git a/question/type/multichoice/db/postgres7.php b/question/type/multichoice/db/postgres7.php
deleted file mode 100644 (file)
index 7bb44a8..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php  // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-// PostgreSQL commands for upgrading this question type
-
-function qtype_multichoice_upgrade($oldversion=0) {
-    global $CFG;
-    $success = true;
-    
-    if ($success && $oldversion < 2006081900) {
-        $success = $success && table_column('question_multichoice', '', 'correctfeedback', 'text', '', '', '');
-        $success = $success && table_column('question_multichoice', '', 'partiallycorrectfeedback', 'text', '', '', '');
-        $success = $success && table_column('question_multichoice', '', 'incorrectfeedback', 'text', '', '', '');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return $success;
-}
-
-?>
diff --git a/question/type/numerical/db/mysql.php b/question/type/numerical/db/mysql.php
deleted file mode 100644 (file)
index 962d25e..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php  // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-// MySQL commands for upgrading this question type
-
-function qtype_numerical_upgrade($oldversion=0) {
-    global $CFG;
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/question/type/numerical/db/postgres7.php b/question/type/numerical/db/postgres7.php
deleted file mode 100644 (file)
index 5d57e65..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php  // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-// PostgreSQL commands for upgrading this question type
-
-function qtype_numerical_upgrade($oldversion=0) {
-    global $CFG;
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/question/type/randomsamatch/db/mysql.php b/question/type/randomsamatch/db/mysql.php
deleted file mode 100644 (file)
index 641cf3c..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php  // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-// MySQL commands for upgrading this question type
-
-function qtype_randomsamatch_upgrade($oldversion=0) {
-    global $CFG;
-
-    if ($oldversion < 2006042800) {
-        // This is a random questiontype and therefore answers are always shuffled, no need for this field
-        modify_database('', 'ALTER TABLE prefix_question_randomsamatch DROP shuffleanswers');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/question/type/randomsamatch/db/postgres7.php b/question/type/randomsamatch/db/postgres7.php
deleted file mode 100644 (file)
index 77e6f48..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php  // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-// PostgreSQL commands for upgrading this question type
-
-function qtype_randomsamatch_upgrade($oldversion=0) {
-    global $CFG;
-
-    if ($oldversion < 2006042800) {
-        // This is a random questiontype and therefore answers are always shuffled, no need for this field
-        modify_database('', 'ALTER TABLE prefix_question_randomsamatch DROP shuffleanswers');
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/question/type/rqp/icon.gif b/question/type/rqp/icon.gif
deleted file mode 100644 (file)
index 5a26124..0000000
Binary files a/question/type/rqp/icon.gif and /dev/null differ
diff --git a/question/type/shortanswer/db/mysql.php b/question/type/shortanswer/db/mysql.php
deleted file mode 100644 (file)
index eea4758..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php  // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-// MySQL commands for upgrading this question type
-
-function qtype_shortanswer_upgrade($oldversion=0) {
-    global $CFG;
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/question/type/shortanswer/db/postgres7.php b/question/type/shortanswer/db/postgres7.php
deleted file mode 100644 (file)
index b3414d7..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php  // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-// PostgreSQL commands for upgrading this question type
-
-function qtype_shortanswer_upgrade($oldversion=0) {
-    global $CFG;
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/question/type/truefalse/db/mysql.php b/question/type/truefalse/db/mysql.php
deleted file mode 100644 (file)
index a7b58b6..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php  // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-// MySQL commands for upgrading this question type
-
-function qtype_truefalse_upgrade($oldversion=0) {
-    global $CFG;
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
diff --git a/question/type/truefalse/db/postgres7.php b/question/type/truefalse/db/postgres7.php
deleted file mode 100644 (file)
index 48b9f26..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php  // $Id$
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-
-// PostgreSQL commands for upgrading this question type
-
-function qtype_truefalse_upgrade($oldversion=0) {
-    global $CFG;
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    return true;
-}
-
-?>
index 4f349416dcbd474d4b493a0e055ce18b07f0b2c3..362a3505055551669b6056f29b3cc3698ba44852 100644 (file)
@@ -13,7 +13,7 @@
     //to correct users. It isn't unbreakable,
     //obviously, but its the best I've thought!!
 
-    $nomoodlecookie = true;     // Because it interferes with caching
+    define('NO_MOODLE_COOKIES', true); // session not used here
 
     require_once('../config.php');
     require_once($CFG->libdir.'/filelib.php');
@@ -21,7 +21,7 @@
 
     $lifetime = 3600;  // Seconds for files to remain in caches - 1 hour
 
-    // hack for problems with concurrent use of $nomoodlecookie and capabilities MDL-7243
+    // hack for problems with concurrent use of NO_MOODLE_COOKIES and capabilities MDL-7243
     // it should be replaced once we get to codes in urls 
     $USER = new object();
     $USER->id = 0;
index b2cc8425549387b6c010f0afc2074bcac855e28b..16e4450b96825ef50d76186388367ea5c04f2c47 100644 (file)
@@ -2,59 +2,56 @@ Cette distribution partielle contient une refonte du moteur de
 recherche globale de Moodle.
 
 Le moteur de recherche est capable d'indexer et de rechercher 
-des informations dans un grand nombre de contenus stockés
-dans la plate-forme Ã  travers la manipulation des activités et
+des informations dans un grand nombre de contenus stockés
+dans la plate-forme Ã  travers la manipulation des activités et
 des blocs.
 
-Le moteur de recherche procède Ã  une première indexation des
+Le moteur de recherche procède Ã  une première indexation des
 ressources disponibles par action de l'administrateur. Une fois
-cette indexation effectuée, le moteur maintient régulièrement les
-indexes, en ajoutant les nouvelles entrées et en nettoyant les 
-entrées obsolètes.
+cette indexation effectuée, le moteur maintient régulièrement les
+indexes, en ajoutant les nouvelles entrées et en nettoyant les 
+entrées obsolètes.
 
-La recherche permet d'obtenir des références d'accès au contexte
+La recherche permet d'obtenir des références d'accès au contexte
 qui diffuse cette information, au nom de l'utilisateur courant.
-Le filtrage des résultats enlève de la liste des réponses toute
-ressource que la situation de l'utilisateur empêcherait de voir
-s'il y accédait dans son contexte habituel.
+Le filtrage des résultats enlève de la liste des réponses toute
+ressource que la situation de l'utilisateur empêcherait de voir
+s'il y accédait dans son contexte habituel.
 
 Mise en oeuvre
 ##############
 
-Pour déployer le moteur : 
+La distribution fait désormais partie du noyau de Moodle.
 
+Il sera probablement nécessaire d'ajouter un certain nombre de librairies additionnelles
+pour la conversion de documents physiques en vue de leur indexation. Ces librairies sont
+actuellement fournies dans le CVS dans la rubrique contrib/patches/global_search_libraries 
+(antiword et xpdf). La prise en charge des fichiers "shockwave" est assurée, sous réserve 
+de l'obtention des libairies de conversion auprès de Adobe (http://www.adobe.com/licensing/developer/)
 
-* Copie de fichiers
+1. Allez sur le bloc d'administration et réglez les paramètres du bloc Recherche Globale. 
+Ceci initialisera un certain nombre de fonctions dans le moteur.
 
-1. Ajouter les deux librairies fournies aux librairies de Moodle
-2. Ecraser le répertoire "search" par le répertoire fourni
-3. Ecraser le bloc "blocs/search" par le bloc fourni.
+2. Insérer un nouveau bloc de recherche globale dans la plate-forme
 
-* Installation logique
+3. Effectuer une recherche vide (en administrateur)
 
-4. Aller dans les notifications administratives et dérouler la procédure d'installation/mise Ã  jour du bloc. L'installation crée la table image
-des documents indexés et utilisés dans le module search.
+4. Aller sur la page des statistiques
 
-5. Insérer un nouveau bloc de recherche globale dans la plate-forme
+5. Activer l'indexation (indexsplash.php). Attention, si la plate-form contient beaucoup de contenus cette indexation peut Ãªtre TRES LONGUE.
 
-6. Effectuer une recherche vide (en administrateur)
+Pour effectuer des recherches, une fois la première indexation terminée, retourner au bloc de recherche et tenter une recherche.
 
-7. Aller sur la page des statistiques
-
-8. Activer l'indexation (indexsplash.php). Attention, si la plate-form contient beaucoup de contenus cette indexation peut Ãªtre TRES LONGUE.
-
-Pour effectuer des recherches, une fois la première indexation terminée, retourner au bloc de recherche et tenter une recherche.
-
-Eléments pris en charge
+Eléments pris en charge
 #######################
 
-Dans l'état actuel, les Ã©léments indexés par le moteur sont :
+Dans l'état actuel, les Ã©léments indexés par le moteur sont :
 
-- les entrées de forum
-- les fiches de base de données
-- les commentaires sur fiches de données
-- les entrées de glossaire
-- les commentaires sur entrées de glossaire
+- les entrées de forum
+- les fiches de base de données
+- les commentaires sur fiches de données
+- les entrées de glossaire
+- les commentaires sur entrées de glossaire
 - les ressources natives Moodle
 - les ressources physiques de type MSWord
 - les ressources physiques de type PDF
@@ -63,27 +60,30 @@ Dans l'état actuel, les Ã©léments indexés par le moteur sont :
 - les ressources physiques de type XML (.xml)
 - les ressources physiques de type (Microsoft) Powerpoint (.ppt)
 - les pages de wiki
-- les entités de projet technique
 - les sessions de chat
 
+Des modules tiers ont Ã©té rendus indexables 
+
+- Techproject
+
 Extensions
 ##########
 
-L'API du moteur de recherche permet désormais : 
+L'API du moteur de recherche permet désormais : 
 
 - l'indexation de contenus de blocs.
 - l'indexation de modules contenant une information complexe ou de plusieurs types distincts
-- la sécurisation des informations indexées lors des extractions de résultats
-- l'indexation de tout module tiers par ajout d'un fichier php calibré
-- l'indexation de toute nouvelle resource physique par ajout d'un fichier php calibré
+- la sécurisation des informations indexées lors des extractions de résultats
+- l'indexation de tout module tiers par ajout d'un fichier php calibré
+- l'indexation de toute nouvelle resource physique par ajout d'un fichier php calibré
 
 Extensions futures
 ##################
 
 - De nouvelles prises en charge de contenus tels que les attachements des forums, les attachement des glossaires, ainsi que d'autres modules non encore
-implémentés.
+implémentés.
 
-- l'extension mnet de la recherche dans un réseau de moodle interconnectés.
+- l'extension mnet de la recherche dans un réseau de moodle interconnectés.
 
  
 
index 64296be2f0b56ccfa6ccbc25ba907d7f0885a490..02b7d5786a5f42e93b09ae722a90f7f3b4bba9ec 100644 (file)
-2006/09/08
-----------
-Google Summer of Code is finished, spent a couple of weeks away from
-the project to think about it and also to take a break. Working on it
-now I discovered bugs in the query parser (now fixed), and I also
-un-convoluted the querylib logic (well slighlty).
+This directoery contains the central implementation of
+Moodle's Global Search Engine.
 
-Updated ZFS files to latest SVN.
-
-2006/08/21
-----------
-Fixed index document count, and created new config variable to store
-the size. (Search now has 3 global vars in $CFG, date, size and complete,
-see indexer.php for var names). Index size is cached to provide an always
-current value for the index - this is to take into account the fact that
-deleted documents are in fact not removed from the index, but instead just
-marked as deleted and not returned in search results. The actual document
-still features in the index, and skews sizes. When the index optimiser is
-completed in ZFS, then these deleted documents will be pruned, thus
-correctly modifying the index size.
-
-Additional commenting added.
-
-Query page logic very slightly modified to clean up GET string a bit (removed
-'p' variable).
-
-Add/delete functions added to other document types.
-
-A few TODO fields added to source, indicating changes still to come (or at
-least to be considered).
-
-2006/08/16
-----------
-Add/delete/update cron functions finished - can be called seperately
-or all at once via cron.php.
-
-Document date field added to index and database summary.
-
-Some index db functionality abstracted out to indexlib.php - can
-use IndexDBControl class to add/del documents from database, and
-to make sure the db table is functioning.
-
-DB sql files changed to add some extra fields.
-
-Default 'simple' query modified to search title and author, as well
-as contents of document, to provide better results for users.
-
-2006/08/14
-----------
-First revision of the advanced search page completed. Functional,
-but needs a date search field still.
-
-2006/08/02
-----------
-Added resource search type, and the ability to specify custom 'virtual'
-models to search - allowing for non-module specific information to be
-indexed. Specify the extra search types to use in lib.php.
-
-2006/07/28
-----------
-Added delete logic to documents; the moodle database log is checked
-and any found delete events are used to remove the referenced documents
-from the database table and search index.
-
-Added database table name constant to lib.php, must change files using
-the static table name.
-
-Changed documents to use 'docid' instead of 'id' to reference the moodle
-instance id, since Zend Search adds it's own internal 'id' field. Noticed
-this whilst working on deletions.
-
-Added some additional fields to the permissions checking method, must still
-implement it though.
-
-2006/07/25
-----------
-Query logic moved into the SearchQuery class in querylib.php. Should be able
-to include this file in any page and run a query against the index (PHP 5
-checks must be added to those pages then, though).
-
-Index info can be retrieved using IndexInfo class in indexlib.php.
-
-Abstracted some stuff away, to reduce rendundancy and decrease the
-likelihood of errors. Improved the stats.php page to include some
-diagnostics for adminstrators.
-
-delete.php skeleton created for removing deleted documents from the
-index. cron.php will contain the logic for running delete.php,
-update.php and eventually add.php.
-
-2006/07/11
-----------
-(Warning: It took me 1900 seconds to index the forum, go make coffee
-whilst you wait.) [Moodle.org forum data]
-
-Forum search functions changed to use 'get_recordset' instead of
-'get_records', for speed reasons. This provides a significant improvement,
-but indexing is still slow - getting data from the database and Zend's
-tokenising _seem_ to be the prime suspects at the moment.
-
-/search/tests/ added - index.php can be used to see which modules are
-ready to be included in the search index, and it informs you of any
-errors - should be a prerequisite for indexing.
-
-Search result pagination added to query.php, will default to 20 until
-an admin page for the search module is written.
-
-2006/07/07
-----------
-Search-enabling functions moved out've the mod's lib.php files and into
-/search/documents/mod_document.php - this requires the search module to
-operate without requiring modification of lib files.
-
-SearchDocument base class improved, and the way module documents extend
-it. A custom-data field has been added to allow modules to add any custom
-data they wish to be stored in the index - this field is serialised into
-the index as a binary field.
-
-Database field 'type' renamed to 'doctype' to match the renaming in the
-index, 'type' seems to be a reserved word in Lucene. Several index field
-names change to be more descriptive (cid -> course_id). URLs are now
-stored in the index, and don't have to be generated on the fly during
-display of query results.
-
-2006/07/05
-------
-Started cleaning and standardising things.
-
-cvs v1.1
---------
-This is the initial release (prototype) of Moodle's new search module -
-so basically watch out for sharp edges.
-
-The structure has not been finalised, but this is what is working at the
-moment, when I start looking at other content to index, it will most likely
-change. I don't recommend trying to make your own content modules indexable,
-at least not until the whole flow is finalised. I will be implementing the
-functions needed to index all of the default content modules on Moodle, so
-expect that around mid-August.
-
-Wiki pages were my goal for this release, they can be indexed and searched,
-but not updated or deleted at this stage (was waiting for ZF 0.14 actually).
-
-I need to check the PostgreSQL sql file, I don't have a PG7 install lying
-around to test on, so the script is untested.
-
-To index for the first time, login as an admin user and browse to /search/index.php
-or /search/stats.php - there will be a message and a link telling you to go index.
-
--- Michael Champanis (mchampan)
-   email: cynnical@gmail.com
-   skype: mchampan
-   Summer of Code 2006
\ No newline at end of file
+The Global Search Engine stores indexes about a huge quantity  
+of information from within modules, block or resources stored 
+by Moodle either in the database or the file system.
+
+The administrator initialy indexes the existing content. Once this 
+first initialization performed, the search engine maintains indexes
+regularily, adding new entries, deleting obsolete one or updating
+some that have changed.
+
+Search will produce links for acceding the information in a similar
+context as usually accessed, from the current user point of view.
+Results filtering removes from results any link to information the
+current user would not be allowed to acces on a straight situation.
+
+Deployement
+###########
+
+The search engine is now part of Moodle core distribution.
+
+Some extra libraries might be added for converting physical documents to text
+so it can be indexed. Moodle CVS (entry contrib/patches/global_search_libraries)
+provides packs for antiword and xpdf GPL libraries the search engine is ready for 
+shockwave indexing, but will not provide Adobe Search converters that should be 
+obtained at http://www.adobe.com/licensing/developer/
+
+1. Go to the block administration panel and setup once the Global Search
+block. This will initialize useful parameters for the global search engine.
+
+2. Insert a new Global Search block somewhere in a course or top-level screen. 
+
+3. Launch an empty search (you must be administrator).
+
+4. Go to the statistics screen.
+
+5. Activate indexation (indexersplash.php). Beware, if your Moodle has
+a large amount of content, indexing process may be VERY LONG.
+
+To search, go back to the search block and try a query.
+
+Handled information for indexing
+################################
+
+In the actual state, the engine indexes the following information:
+
+- assignment descriptions
+- forum posts
+- database records (using textual fields only)
+- database comments
+- glossary entries
+- glossary comments on entries
+- Moodle native resources
+- physical MSWord files as resources (.doc)
+- physical Powerpoint files as resources (.ppt)
+- physical PDF files as resources 
+- physical text files as resources (.txt)
+- physical html files as resources (.htm and .html)
+- physical xml files as resources (.xml)
+- wiki pages
+- chat sessions
+- lesson pages
+
+Some third party plugins are also searchable using the new Search API implementation
+
+- Techproject
+
+Extensions
+##########
+
+The reviewed search engine API allows: 
+
+- indexing of blocks contents
+- indexation of modules or blocks containing a complex information model
+- securing the access to the results
+- adding indexing handling for additional modules and plugins adding a php calibrated script
+- adding physical filetype handling adding a php calibrated script
+
+Future extensions
+#################
+
+- Should be added more information to index such as forum and glossary attachements, 
+  so will other standard module contents.
+- extending the search capability to a mnet network information space by aggregating remote search responses.
\ No newline at end of file
diff --git a/search/READMETOO.txt b/search/READMETOO.txt
deleted file mode 100644 (file)
index 391fc70..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-This partial distribution contains a complete review of the
-Global Search Engine of Moodle.
-
-The Global Search Engine stores indexes about a huge quantity  
-of information from within modules, block or resources stored 
-by Moodle either in the database or the file system.
-
-The administrator initialy indexes the existing content. Once this 
-first initialization performed, the search engine maintains indexes
-regularily, adding new entries, deleting obsolete one or updating
-some that have changed.
-
-Search will produce links for acceding the information in a similar
-context as usually accessed, from the current user point of view.
-Results filtering removes from results any link to information the
-current user would not be allowed to acces on a straight situation.
-
-Deployement
-###########
-
-For setting the engine : 
-
-
-* File copy
-
-1. Add to Moodle's library both additional libraries provided in the distribution
-2. Replace the "search" directory with the new one
-3. Replace the "blocks/search" with the new one.
-
-* Logical install
-
-4. Browse to the administrative notification screen and let the 
-install/update process run. The install process creates the Moodle
-table needed for backing the indexed documents identities.
-
-5. Go to the block administration panel and setup once the Global Search
-block. This will initialize useful parameters for the global search engine.
-
-6. Insert a new Global Search block somewhere in a course or top-level screen. 
-
-7. Launch an empty search (you must be administrator).
-
-8. Go to the statistics screen.
-
-9. Activate indexation (indexersplash.php). Beware, if your Moodle has
-a large amount of content, indexing process may be VERY LONG.
-
-To search, go back to the search block and try a query.
-
-Handled information for indexing
-################################
-
-In the actual state, the engine indexes the following information:
-
-- forum posts
-- database records (using textual fields only)
-- database comments
-- glossary entries
-- glossary comments on entries
-- Moodle native resources
-- physical MSWord files as resources (.doc)
-- physical Powerpoint files as resources (.ppt)
-- physical PDF files as resources 
-- physical text files as resources (.txt)
-- physical html files as resources (.htm and .html)
-- physical xml files as resources (.xml)
-- wiki pages
-- techproject descriptions
-- char sessions
-- lesson pages
-
-Extensions
-##########
-
-The reviewed search engine API allows: 
-
-- indexing of blocks contents
-- indexation of modules or blocks containing a complex information model
-- securing the access to the results
-- adding indexing handling adding a php calibrated script
-- adding physical filetype handling adding a php calibrated script
-
-Future extensions
-#################
-
-- Should be added more information to index such as forum and glossary attachements, so will other standard module contents.
-
-- extending the search capability to a mnet network information space.
-
-
diff --git a/search/README_ARCHIVE.txt b/search/README_ARCHIVE.txt
new file mode 100644 (file)
index 0000000..64296be
--- /dev/null
@@ -0,0 +1,153 @@
+2006/09/08
+----------
+Google Summer of Code is finished, spent a couple of weeks away from
+the project to think about it and also to take a break. Working on it
+now I discovered bugs in the query parser (now fixed), and I also
+un-convoluted the querylib logic (well slighlty).
+
+Updated ZFS files to latest SVN.
+
+2006/08/21
+----------
+Fixed index document count, and created new config variable to store
+the size. (Search now has 3 global vars in $CFG, date, size and complete,
+see indexer.php for var names). Index size is cached to provide an always
+current value for the index - this is to take into account the fact that
+deleted documents are in fact not removed from the index, but instead just
+marked as deleted and not returned in search results. The actual document
+still features in the index, and skews sizes. When the index optimiser is
+completed in ZFS, then these deleted documents will be pruned, thus
+correctly modifying the index size.
+
+Additional commenting added.
+
+Query page logic very slightly modified to clean up GET string a bit (removed
+'p' variable).
+
+Add/delete functions added to other document types.
+
+A few TODO fields added to source, indicating changes still to come (or at
+least to be considered).
+
+2006/08/16
+----------
+Add/delete/update cron functions finished - can be called seperately
+or all at once via cron.php.
+
+Document date field added to index and database summary.
+
+Some index db functionality abstracted out to indexlib.php - can
+use IndexDBControl class to add/del documents from database, and
+to make sure the db table is functioning.
+
+DB sql files changed to add some extra fields.
+
+Default 'simple' query modified to search title and author, as well
+as contents of document, to provide better results for users.
+
+2006/08/14
+----------
+First revision of the advanced search page completed. Functional,
+but needs a date search field still.
+
+2006/08/02
+----------
+Added resource search type, and the ability to specify custom 'virtual'
+models to search - allowing for non-module specific information to be
+indexed. Specify the extra search types to use in lib.php.
+
+2006/07/28
+----------
+Added delete logic to documents; the moodle database log is checked
+and any found delete events are used to remove the referenced documents
+from the database table and search index.
+
+Added database table name constant to lib.php, must change files using
+the static table name.
+
+Changed documents to use 'docid' instead of 'id' to reference the moodle
+instance id, since Zend Search adds it's own internal 'id' field. Noticed
+this whilst working on deletions.
+
+Added some additional fields to the permissions checking method, must still
+implement it though.
+
+2006/07/25
+----------
+Query logic moved into the SearchQuery class in querylib.php. Should be able
+to include this file in any page and run a query against the index (PHP 5
+checks must be added to those pages then, though).
+
+Index info can be retrieved using IndexInfo class in indexlib.php.
+
+Abstracted some stuff away, to reduce rendundancy and decrease the
+likelihood of errors. Improved the stats.php page to include some
+diagnostics for adminstrators.
+
+delete.php skeleton created for removing deleted documents from the
+index. cron.php will contain the logic for running delete.php,
+update.php and eventually add.php.
+
+2006/07/11
+----------
+(Warning: It took me 1900 seconds to index the forum, go make coffee
+whilst you wait.) [Moodle.org forum data]
+
+Forum search functions changed to use 'get_recordset' instead of
+'get_records', for speed reasons. This provides a significant improvement,
+but indexing is still slow - getting data from the database and Zend's
+tokenising _seem_ to be the prime suspects at the moment.
+
+/search/tests/ added - index.php can be used to see which modules are
+ready to be included in the search index, and it informs you of any
+errors - should be a prerequisite for indexing.
+
+Search result pagination added to query.php, will default to 20 until
+an admin page for the search module is written.
+
+2006/07/07
+----------
+Search-enabling functions moved out've the mod's lib.php files and into
+/search/documents/mod_document.php - this requires the search module to
+operate without requiring modification of lib files.
+
+SearchDocument base class improved, and the way module documents extend
+it. A custom-data field has been added to allow modules to add any custom
+data they wish to be stored in the index - this field is serialised into
+the index as a binary field.
+
+Database field 'type' renamed to 'doctype' to match the renaming in the
+index, 'type' seems to be a reserved word in Lucene. Several index field
+names change to be more descriptive (cid -> course_id). URLs are now
+stored in the index, and don't have to be generated on the fly during
+display of query results.
+
+2006/07/05
+------
+Started cleaning and standardising things.
+
+cvs v1.1
+--------
+This is the initial release (prototype) of Moodle's new search module -
+so basically watch out for sharp edges.
+
+The structure has not been finalised, but this is what is working at the
+moment, when I start looking at other content to index, it will most likely
+change. I don't recommend trying to make your own content modules indexable,
+at least not until the whole flow is finalised. I will be implementing the
+functions needed to index all of the default content modules on Moodle, so
+expect that around mid-August.
+
+Wiki pages were my goal for this release, they can be indexed and searched,
+but not updated or deleted at this stage (was waiting for ZF 0.14 actually).
+
+I need to check the PostgreSQL sql file, I don't have a PG7 install lying
+around to test on, so the script is untested.
+
+To index for the first time, login as an admin user and browse to /search/index.php
+or /search/stats.php - there will be a message and a link telling you to go index.
+
+-- Michael Champanis (mchampan)
+   email: cynnical@gmail.com
+   skype: mchampan
+   Summer of Code 2006
\ No newline at end of file
index c518e930717bca4d60d852a662ade9f34b515d02..01164d8874fad5178af630ec259fb75b5d806f0a 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Analysis
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Analysis_Analyzer */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Analysis/Analyzer.php';
+require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
 
 
 /**
@@ -34,7 +34,7 @@ require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Analysis/Analyzer.php';
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Analysis
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 abstract class Zend_Search_Lucene_Analysis_Analyzer_Common extends Zend_Search_Lucene_Analysis_Analyzer
@@ -68,7 +68,7 @@ abstract class Zend_Search_Lucene_Analysis_Analyzer_Common extends Zend_Search_L
         foreach ($this->_filters as $filter) {
             $token = $filter->normalize($token);
 
-            // resulting token can be null if the filter removed it
+            // resulting token can be null if the filter removes it
             if (is_null($token)) {
                 return null;
             }
index d9f786a8703f9e5e2711e8520322a4d76b7a9966..4e3dd662a730e3151b33163f42bbfe0e47663d51 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Analysis
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Analysis_Analyzer_Common_Text */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Analysis/Analyzer/Common/Text.php';
+require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Text.php';
 
 /** Zend_Search_Lucene_Analysis_TokenFilter_LowerCase */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Analysis/TokenFilter/LowerCase.php';
+require_once 'Zend/Search/Lucene/Analysis/TokenFilter/LowerCase.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Analysis
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
index d68b594a07715eb6a9c8e01f68300233d290e7cf..b8aca5d95f780f5f8db663cd2e88a46e17b69c89 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Analysis
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Analysis_Analyzer_Common */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Analysis/Analyzer/Common.php';
+require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Analysis
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
@@ -74,7 +74,7 @@ class Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum extends Zend_Search_Lu
             if (! preg_match('/[a-zA-Z0-9]+/', $this->_input, $match, PREG_OFFSET_CAPTURE, $this->_position)) {
                 // It covers both cases a) there are no matches (preg_match(...) === 0)
                 // b) error occured (preg_match(...) === FALSE)
-               return null;
+                return null;
             }
 
             $str = $match[0][0];
index 6eab4372291fe645c1c2ce9d9b1776e399d5ce56..89873f10f17bebc062722f7857654f38b3e36ce1 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Analysis
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum.php';
+require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum.php';
 
 /** Zend_Search_Lucene_Analysis_TokenFilter_LowerCase */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Analysis/TokenFilter/LowerCase.php';
+require_once 'Zend/Search/Lucene/Analysis/TokenFilter/LowerCase.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Analysis
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
diff --git a/search/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8/CaseInsensitive.php b/search/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8/CaseInsensitive.php
new file mode 100644 (file)
index 0000000..4213fb3
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Search_Lucene
+ * @subpackage Analysis
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+
+/** Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8 */
+require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8.php';
+
+/** Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8 */
+require_once 'Zend/Search/Lucene/Analysis/TokenFilter/LowerCaseUtf8.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Search_Lucene
+ * @subpackage Analysis
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+
+class Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive extends Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8 
+{
+    public function __construct()
+    {
+        parent::__construct();
+
+        $this->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8());
+    }
+}
+
index 982b55418fd134130c797215490a7d8e801f5c5a..74c89be0c2117bc7512074a618742a479fe7739e 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Analysis
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Analysis_Analyzer_Common */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Analysis/Analyzer/Common.php';
+require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Analysis
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
@@ -49,11 +49,18 @@ class Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num extends Zend_Search_Lu
     private $_bytePosition;
 
     /**
-     * Stream length
+     * Object constructor
      *
-     * @var integer
+     * @throws Zend_Search_Lucene_Exception
      */
-    private $_streamLength;
+    public function __construct()
+    {
+        if (@preg_match('/\pL/u', 'a') != 1) {
+            // PCRE unicode support is turned off
+            require_once 'Zend/Search/Lucene/Exception.php';
+            throw new Zend_Search_Lucene_Exception('Utf8Num analyzer needs PCRE unicode support to be enabled.');
+        }
+    }
 
     /**
      * Reset token stream
@@ -69,53 +76,6 @@ class Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num extends Zend_Search_Lu
                 $this->_input = iconv($this->_encoding, 'UTF-8', $this->_input);
                 $this->_encoding = 'UTF-8';
         }
-
-        // Get UTF-8 string length.
-        // It also checks if it's a correct utf-8 string
-        $this->_streamLength = iconv_strlen($this->_input, 'UTF-8');
-    }
-
-    /**
-     * Check, that character is a letter
-     *
-     * @param string $char
-     * @return boolean
-     */
-    private static function _isAlNum($char)
-    {
-        if (strlen($char) > 1) {
-            // It's an UTF-8 character
-            return true;
-        }
-
-        return ctype_alnum($char);
-    }
-
-    /**
-     * Get next UTF-8 char
-     *
-     * @param string $char
-     * @return boolean
-     */
-    private function _nextChar()
-    {
-        $char = $this->_input[$this->_bytePosition++];
-
-        if (( ord($char) & 0xC0 ) == 0xC0) {
-            $addBytes = 1;
-            if (ord($char) & 0x20 ) {
-                $addBytes++;
-                if (ord($char) & 0x10 ) {
-                    $addBytes++;
-                }
-            }
-            $char .= substr($this->_input, $this->_bytePosition, $addBytes);
-            $this->_bytePosition += $addBytes;
-        }
-
-        $this->_position++;
-
-        return $char;
     }
 
     /**
@@ -131,39 +91,35 @@ class Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num extends Zend_Search_Lu
             return null;
         }
 
-        while ($this->_position < $this->_streamLength) {
-            // skip white space
-            while ($this->_position < $this->_streamLength &&
-                   !self::_isAlNum($char = $this->_nextChar())) {
-                $char = '';
-            }
-
-            $termStartPosition = $this->_position - 1;
-            $termText = $char;
-
-            // read token
-            while ($this->_position < $this->_streamLength &&
-                   self::_isAlNum($char = $this->_nextChar())) {
-                $termText .= $char;
-            }
-
-            // Empty token, end of stream.
-            if ($termText == '') {
+        do {
+            if (! preg_match('/[\p{L}\p{N}]+/u', $this->_input, $match, PREG_OFFSET_CAPTURE, $this->_bytePosition)) {
+                // It covers both cases a) there are no matches (preg_match(...) === 0)
+                // b) error occured (preg_match(...) === FALSE)
                 return null;
             }
 
-            $token = new Zend_Search_Lucene_Analysis_Token(
-                                      $termText,
-                                      $termStartPosition,
-                                      $this->_position - 1);
-            $token = $this->normalize($token);
-            if ($token !== null) {
-                return $token;
-            }
-            // Continue if token is skipped
-        }
-
-        return null;
+            // matched string
+            $matchedWord = $match[0][0];
+            
+            // binary position of the matched word in the input stream
+            $binStartPos = $match[0][1];
+            
+            // character position of the matched word in the input stream
+            $startPos = $this->_position + 
+                        iconv_strlen(substr($this->_input,
+                                            $this->_bytePosition,
+                                            $binStartPos - $this->_bytePosition),
+                                     'UTF-8');
+            // character postion of the end of matched word in the input stream
+            $endPos = $startPos + iconv_strlen($matchedWord, 'UTF-8');
+
+            $this->_bytePosition = $binStartPos + strlen($matchedWord);
+            $this->_position     = $endPos;
+
+            $token = $this->normalize(new Zend_Search_Lucene_Analysis_Token($matchedWord, $startPos, $endPos));
+        } while ($token === null); // try again if token is skipped
+
+        return $token;
     }
 }
 
diff --git a/search/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num/CaseInsensitive.php b/search/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num/CaseInsensitive.php
new file mode 100644 (file)
index 0000000..1ec0d5c
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Search_Lucene
+ * @subpackage Analysis
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+
+/** Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num */
+require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num.php';
+
+/** Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8 */
+require_once 'Zend/Search/Lucene/Analysis/TokenFilter/LowerCaseUtf8.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Search_Lucene
+ * @subpackage Analysis
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+
+class Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive extends Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num
+{
+    public function __construct()
+    {
+        parent::__construct();
+
+        $this->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8());
+    }
+}
+
index 91586b01f727f4c77820b0ab23f459e6028facc2..3097992a9b834604d5cb507ca1f93ca9f195f0f3 100644 (file)
@@ -15,7 +15,7 @@
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Analysis
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
@@ -24,7 +24,7 @@
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Analysis
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Analysis_Token
index 4d559a93b7fbf2fca04dbf9acc069c4136be50ce..5c582024a1532a20cf2b5ff1adb6018195e8f880 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Analysis
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Analysis_Token */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Analysis/Token.php';
+require_once 'Zend/Search/Lucene/Analysis/Token.php';
 
 
 /**
@@ -30,7 +30,7 @@ require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Analysis/Token.php';
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Analysis
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
index 01d25c67452da74f2b096ef0262fc2db77cb635a..9fb545cb36f639a8e5783c5139622a4272bdd035 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Analysis
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Analysis_TokenFilter */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Analysis/TokenFilter.php';
+require_once 'Zend/Search/Lucene/Analysis/TokenFilter.php';
 
 
 /**
@@ -30,7 +30,7 @@ require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Analysis/TokenFilter.php'
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Analysis
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
index 83abfb22c3fd54a4aa6815e0bd29c87a832325e8..50c3f50d60ab08f9ce0d2f99642ba2dfd4a21dd5 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Analysis
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Analysis_TokenFilter */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Analysis/TokenFilter.php';
+require_once 'Zend/Search/Lucene/Analysis/TokenFilter.php';
 
 
 /**
@@ -30,7 +30,7 @@ require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Analysis/TokenFilter.php'
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Analysis
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
index f85d5d55d8e933cbb52c34a1a9011941a1439935..55b7567c1bfc0996d935ccca84a7506ab17259f4 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Analysis
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Analysis_TokenFilter */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Analysis/TokenFilter.php';
-require_once $CFG->dirroot.'/search/Zend/Search/Exception.php';
+require_once 'Zend/Search/Lucene/Analysis/TokenFilter.php';
+require_once 'Zend/Search/Exception.php';
 
 
 /**
@@ -34,14 +34,14 @@ require_once $CFG->dirroot.'/search/Zend/Search/Exception.php';
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Analysis
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 class Zend_Search_Lucene_Analysis_TokenFilter_StopWords extends Zend_Search_Lucene_Analysis_TokenFilter
 {
     /**
-     * Minimum allowed term length
+     * Stop Words
      * @var array
      */
     private $_stopSet;
@@ -63,7 +63,6 @@ class Zend_Search_Lucene_Analysis_TokenFilter_StopWords extends Zend_Search_Luce
      */
     public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken) {
         if (array_key_exists($srcToken->getTermText(), $this->_stopSet)) {
-            $t = $srcToken->getTermText();
             return null;
         } else {
             return $srcToken;
index c10c8236c5c555b8bd94ee346833979262ffb899..e7cd2f90f4f6dc28d49f5cf009c499f34a6a75b1 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Document
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Document */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Document.php';
+require_once 'Zend/Search/Lucene/Document.php';
 
 
 /**
@@ -30,7 +30,7 @@ require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Document.php';
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Document
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Document_Html extends Zend_Search_Lucene_Document
@@ -290,7 +290,7 @@ class Zend_Search_Lucene_Document_Html extends Zend_Search_Lucene_Document
 
         $xpath = new DOMXPath($this->_doc);
 
-        $matchedNodes = $xpath->query("/html/body/*");
+        $matchedNodes = $xpath->query("/html/body");
         foreach ($matchedNodes as $matchedNode) {
             $this->_highlightNode($matchedNode, $wordsToHighlightFlipped, $color);
         }
diff --git a/search/Zend/Search/Lucene/EncodingConverter.php b/search/Zend/Search/Lucene/EncodingConverter.php
deleted file mode 100644 (file)
index 9c22e5c..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
-class EncodingConverter {
-  private $last_error,
-          $in_encoding,
-          $out_encoding;
-          
-  function __construct($in_encoding, $out_encoding) {
-    $this->in_encoding = $in_encoding;
-    $this->out_encoding = $out_encoding;
-  } //constructor
-  
-  function handleError($err, $msg) {
-    $this->last_error = $msg;
-  } //handleError
-  
-  function convert($str) {
-    $this->last_error = FALSE;
-    
-    set_error_handler(array(&$this, 'handleError'));
-    $ret = iconv($this->in_encoding, $this->out_encoding, $str);
-    restore_error_handler();
-    
-    return $ret;
-  } //convert
-  
-  function getLastError() {
-    return $this->last_error;
-  } //getLastError
-} //EncodingConverter
-
-?>
\ No newline at end of file
index 31c9069fe4c5087b92ebee65f1dd084a79cbbf46..55e758fe7da1f845b876f3456fd6f08aeb11b872 100644 (file)
  *
  * @category   Zend
  * @package    Zend_Search_Lucene
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_FSMAction */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/FSMAction.php';
+require_once 'Zend/Search/Lucene/FSMAction.php';
 
 /** Zend_Search_Exception */
-require_once $CFG->dirroot.'/search/Zend/Search/Exception.php';
+require_once 'Zend/Search/Exception.php';
 
 
 /**
@@ -37,7 +37,7 @@ require_once $CFG->dirroot.'/search/Zend/Search/Exception.php';
  *
  * @category   Zend
  * @package    Zend_Search_Lucene
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 abstract class Zend_Search_Lucene_FSM
index 606de7b613f4cb5f9ec91a238f4a34995871313d..fdbd6ff659a87789a1286197a29fde820d4a7fcd 100644 (file)
@@ -14,7 +14,7 @@
  *
  * @category   Zend
  * @package    Zend_Search_Lucene
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
@@ -25,7 +25,7 @@
  *
  * @category   Zend
  * @package    Zend_Search_Lucene
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_FSMAction
index 86cd22ccea1797f456cb1da120abaa036498f432..d02f1d9497986030eec4fbbd6070e253d57a7d01 100644 (file)
@@ -15,7 +15,7 @@
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Document
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
@@ -31,7 +31,7 @@
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Document
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Field
index d3f0669c814fb428980a6ea404ac5a9ba219b849..f01be7b4b13cc859add576c72b50152527b25b0a 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Index
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Exception */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Exception.php';
+require_once 'Zend/Search/Lucene/Exception.php';
 
 
 /**
@@ -35,7 +35,7 @@ require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Exception.php';
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Index
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Index_DictionaryLoader
@@ -61,11 +61,12 @@ class Zend_Search_Lucene_Index_DictionaryLoader
         // $tiVersion = $tiiFile->readInt();
         $tiVersion = ord($data[0]) << 24 | ord($data[1]) << 16 | ord($data[2]) << 8  | ord($data[3]);
         $pos += 4;
-        if ($tiVersion != (int)0xFFFFFFFE) {
+        if ($tiVersion != (int)0xFFFFFFFE /* pre-2.1 format */ &&
+            $tiVersion != (int)0xFFFFFFFD /* 2.1+ format    */) {
             throw new Zend_Search_Lucene_Exception('Wrong TermInfoIndexFile file format');
         }
 
-        // $indexTermCount = $tiiFile->readLong();
+        // $indexTermCount = $tiiFile->readLong();
         if (PHP_INT_SIZE > 4) {
             $indexTermCount = ord($data[$pos]) << 56  |
                               ord($data[$pos+1]) << 48  |
@@ -101,6 +102,11 @@ class Zend_Search_Lucene_Index_DictionaryLoader
             throw new Zend_Search_Lucene_Exception('Wrong number of terms in a term dictionary index');
         }
 
+        if ($tiVersion == (int)0xFFFFFFFD /* 2.1+ format */) {
+            /* Skip MaxSkipLevels value */
+            $pos += 4;
+        }
+
         $prevTerm     = '';
         $freqPointer  =  0;
         $proxPointer  =  0;
index 1d138b6575f0c036bb1da69d6ab02495b5328c45..0a91872e3e50156d0a0b942eb22ac423d8b6c265 100644 (file)
@@ -15,7 +15,7 @@
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Index
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
@@ -24,7 +24,7 @@
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Index
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Index_FieldInfo
index c6f7868fd509e15ce0851a08bcb5fc0ac11a8613..5270ee606124846afb7ebc828eb3ce76e51678a8 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Index
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 /** Zend_Search_Lucene_Index_DictionaryLoader */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Index/DictionaryLoader.php';
+require_once 'Zend/Search/Lucene/Index/DictionaryLoader.php';
 
 
 /** Zend_Search_Lucene_Exception */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Exception.php';
+require_once 'Zend/Search/Lucene/Exception.php';
+
+/** Zend_Search_Lucene_LockManager */
+require_once 'Zend/Search/Lucene/LockManager.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Index
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Index_SegmentInfo
@@ -110,6 +113,35 @@ class Zend_Search_Lucene_Index_SegmentInfo
      */
     private $_segFileSizes;
 
+    /**
+     * Delete file generation number
+     *
+     * -1 means 'there is no delete file'
+     *  0 means pre-2.1 format delete file
+     *  X specifies used delete file
+     *
+     * @var integer
+     */
+    private $_delGen;
+
+    /**
+     * Segment has single norms file
+     *
+     * If true then one .nrm file is used for all fields
+     * Otherwise .fN files are used
+     *
+     * @var boolean
+     */
+    private $_hasSingleNormFile;
+
+    /**
+     * Use compound segment file (*.cfs) to collect all other segment files
+     * (excluding .del files)
+     *
+     * @var boolean
+     */
+    private $_isCompound;
+
 
     /**
      * File system adapter.
@@ -136,7 +168,7 @@ class Zend_Search_Lucene_Index_SegmentInfo
      *
      * @var mixed
      */
-    private $_deleted;
+    private $_deleted = null;
 
     /**
      * $this->_deleted update flag
@@ -147,22 +179,45 @@ class Zend_Search_Lucene_Index_SegmentInfo
 
 
     /**
-     * Zend_Search_Lucene_Index_SegmentInfo constructor needs Segmentname,
-     * Documents count and Directory as a parameter.
+     * Zend_Search_Lucene_Index_SegmentInfo constructor
      *
+     * @param Zend_Search_Lucene_Storage_Directory $directory
      * @param string $name
      * @param integer $docCount
-     * @param Zend_Search_Lucene_Storage_Directory $directory
+     * @param integer $delGen
+     * @param boolean $isCompound
      */
-    public function __construct($name, $docCount, $directory)
+    public function __construct(Zend_Search_Lucene_Storage_Directory $directory, $name, $docCount, $delGen = 0, $hasSingleNormFile = false, $isCompound = null)
     {
-        $this->_name = $name;
-        $this->_docCount = $docCount;
         $this->_directory = $directory;
-        $this->_termDictionary = null;
+        $this->_name              = $name;
+        $this->_docCount          = $docCount;
+        $this->_hasSingleNormFile = $hasSingleNormFile;
+        $this->_delGen            = $delGen;
+        $this->_termDictionary    = null;
+
+        if (!is_null($isCompound)) {
+            $this->_isCompound    = $isCompound;
+        } else {
+               // It's a pre-2.1 segment
+               // detect if it uses compond file
+               $this->_isCompound = true;
+
+               try {
+                       // Try to open compound file
+                       $this->_directory->getFileObject($name . '.cfs');
+               } catch (Zend_Search_Lucene_Exception $e) {
+                       if (strpos($e->getMessage(), 'is not readable') !== false) {
+                               // Compound file is not found or is not readable
+                               $this->_isCompound = false;
+                       } else {
+                               throw $e;
+                       }
+               }
+        }
 
         $this->_segFiles = array();
-        if ($this->_directory->fileExists($name . '.cfs')) {
+        if ($this->_isCompound) {
             $cfsFile = $this->_directory->getFileObject($name . '.cfs');
             $segFilesCount = $cfsFile->readVInt();
 
@@ -202,38 +257,84 @@ class Zend_Search_Lucene_Index_SegmentInfo
         array_multisort($fieldNames, SORT_ASC, SORT_REGULAR, $fieldNums);
         $this->_fieldsDicPositions = array_flip($fieldNums);
 
-        try {
-            $delFile = $this->openCompoundFile('.del');
-
-            $byteCount = $delFile->readInt();
-            $byteCount = ceil($byteCount/8);
-            $bitCount  = $delFile->readInt();
+        if ($this->_delGen == -1) {
+            // There is no delete file for this segment
+            // Do nothing
+        } else if ($this->_delGen == 0) {
+            // It's a segment with pre-2.1 format delete file
+            // Try to find delete file
+            try {
+                // '.del' files always stored in a separate file
+                // Segment compound is not used
+                $delFile = $this->_directory->getFileObject($this->_name . '.del');
+
+                $byteCount = $delFile->readInt();
+                $byteCount = ceil($byteCount/8);
+                $bitCount  = $delFile->readInt();
+
+                if ($bitCount == 0) {
+                    $delBytes = '';
+                } else {
+                    $delBytes = $delFile->readBytes($byteCount);
+                }
 
-            if ($bitCount == 0) {
-                $delBytes = '';
-            } else {
-                $delBytes = $delFile->readBytes($byteCount);
+                if (extension_loaded('bitset')) {
+                    $this->_deleted = $delBytes;
+                } else {
+                    $this->_deleted = array();
+                    for ($count = 0; $count < $byteCount; $count++) {
+                        $byte = ord($delBytes{$count});
+                        for ($bit = 0; $bit < 8; $bit++) {
+                            if ($byte & (1<<$bit)) {
+                                $this->_deleted[$count*8 + $bit] = 1;
+                            }
+                        }
+                    }
+                }
+            } catch(Zend_Search_Exception $e) {
+                if (strpos($e->getMessage(), 'is not readable') === false ) {
+                    throw $e;
+                }
+                // There is no delete file
+                // Do nothing
             }
+        } else {
+            // It's 2.1+ format delete file
+            $delFile = $this->_directory->getFileObject($this->_name . '_' . base_convert($this->_delGen, 10, 36) . '.del');
+
+            $format = $delFile->readInt();
 
-            if (extension_loaded('bitset')) {
-                $this->_deleted = $delBytes;
+            if ($format == (int)0xFFFFFFFF) {
+                /**
+                 * @todo Implement support of DGaps delete file format.
+                 * See Lucene file format for details - http://lucene.apache.org/java/docs/fileformats.html#Deleted%20Documents
+                 */
+                throw new Zend_Search_Lucene_Exception('DGaps delete file format is not supported. Optimize index to use it with Zend_Search_Lucene');
             } else {
-                $this->_deleted = array();
-                for ($count = 0; $count < $byteCount; $count++) {
-                    $byte = ord($delBytes{$count});
-                    for ($bit = 0; $bit < 8; $bit++) {
-                        if ($byte & (1<<$bit)) {
-                            $this->_deleted[$count*8 + $bit] = 1;
+                // $format is actually byte count
+                $byteCount = ceil($format/8);
+                $bitCount  = $delFile->readInt();
+
+                if ($bitCount == 0) {
+                    $delBytes = '';
+                } else {
+                    $delBytes = $delFile->readBytes($byteCount);
+                }
+
+                if (extension_loaded('bitset')) {
+                    $this->_deleted = $delBytes;
+                } else {
+                    $this->_deleted = array();
+                    for ($count = 0; $count < $byteCount; $count++) {
+                        $byte = ord($delBytes{$count});
+                        for ($bit = 0; $bit < 8; $bit++) {
+                            if ($byte & (1<<$bit)) {
+                                $this->_deleted[$count*8 + $bit] = 1;
+                            }
                         }
                     }
                 }
             }
-        } catch(Zend_Search_Exception $e) {
-            if (strpos($e->getMessage(), 'compound file doesn\'t contain') !== false ) {
-                $this->_deleted = null;
-            } else {
-                throw $e;
-            }
         }
     }
 
@@ -249,13 +350,12 @@ class Zend_Search_Lucene_Index_SegmentInfo
     {
         $filename = $this->_name . $extension;
 
-        // Try to open common file first
-        if ($this->_directory->fileExists($filename)) {
+        if (!$this->_isCompound) {
             return $this->_directory->getFileObject($filename, $shareHandler);
         }
 
         if( !isset($this->_segFiles[$filename]) ) {
-            throw new Zend_Search_Lucene_Exception('Index compound file doesn\'t contain '
+            throw new Zend_Search_Lucene_Exception('Segment compound file doesn\'t contain '
                                        . $filename . ' file.' );
         }
 
@@ -343,6 +443,16 @@ class Zend_Search_Lucene_Index_SegmentInfo
         return $this->_fields;
     }
 
+    /**
+     * Returns actual deletions file generation number.
+     *
+     * @return integer
+     */
+    public function getDelGen()
+    {
+        return $this->_delGen;
+    }
+
     /**
      * Returns the total number of documents in this segment (including deleted documents).
      *
@@ -431,6 +541,41 @@ class Zend_Search_Lucene_Index_SegmentInfo
         }
     }
 
+    /**
+     * Load terms dictionary index
+     * 
+     * @throws Zend_Search_Lucene_Exception
+     */
+    private function _loadDictionaryIndex()
+    {
+        // Check, if index is already serialized
+        if ($this->_directory->fileExists($this->_name . '.sti')) {
+            // Load serialized dictionary index data
+            $stiFile = $this->_directory->getFileObject($this->_name . '.sti');
+            $stiFileData = $stiFile->readBytes($this->_directory->fileLength($this->_name . '.sti'));
+
+            // Load dictionary index data
+            if (($unserializedData = @unserialize($stiFileData)) !== false) {
+                list($this->_termDictionary, $this->_termDictionaryInfos) = $unserializedData;
+                return;
+            }
+        }
+
+        // Load data from .tii file and generate .sti file
+
+        // Prefetch dictionary index data
+        $tiiFile = $this->openCompoundFile('.tii');
+        $tiiFileData = $tiiFile->readBytes($this->compoundFileLength('.tii'));
+
+        // Load dictionary index data
+        list($this->_termDictionary, $this->_termDictionaryInfos) =
+                    Zend_Search_Lucene_Index_DictionaryLoader::load($tiiFileData);
+
+        $stiFileData = serialize(array($this->_termDictionary, $this->_termDictionaryInfos));
+        $stiFile = $this->_directory->createFile($this->_name . '.sti');
+        $stiFile->writeBytes($stiFileData);
+    }
+
     /**
      * Scans terms dictionary and returns term info
      *
@@ -452,32 +597,9 @@ class Zend_Search_Lucene_Index_SegmentInfo
 
 
         if ($this->_termDictionary === null) {
-            // Check, if index is already serialized
-            if ($this->_directory->fileExists($this->_name . '.sti')) {
-                // Prefetch dictionary index data
-                $stiFile = $this->_directory->getFileObject($this->_name . '.sti');
-                $stiFileData = $stiFile->readBytes($this->_directory->fileLength($this->_name . '.sti'));
-
-                // Load dictionary index data
-                list($this->_termDictionary, $this->_termDictionaryInfos) = unserialize($stiFileData);
-            } else {
-                // Prefetch dictionary index data
-                $tiiFile = $this->openCompoundFile('.tii');
-                $tiiFileData = $tiiFile->readBytes($this->compoundFileLength('.tii'));
-
-                // Load dictionary index data
-                list($this->_termDictionary, $this->_termDictionaryInfos) =
-                            Zend_Search_Lucene_Index_DictionaryLoader::load($tiiFileData);
-
-                $stiFileData = serialize(array($this->_termDictionary, $this->_termDictionaryInfos));
-                $stiFile = $this->_directory->createFile($this->_name . '.sti');
-                $stiFile->writeBytes($stiFileData);
-            }
-
+            $this->_loadDictionaryIndex();
         }
 
-
-
         $searchField = $this->getFieldNum($term->field);
 
         if ($searchField == -1) {
@@ -526,15 +648,19 @@ class Zend_Search_Lucene_Index_SegmentInfo
 
         $tisFile = $this->openCompoundFile('.tis');
         $tiVersion = $tisFile->readInt();
-        if ($tiVersion != (int)0xFFFFFFFE) {
+        if ($tiVersion != (int)0xFFFFFFFE /* pre-2.1 format */  &&
+            $tiVersion != (int)0xFFFFFFFD /* 2.1+ format    */) {
             throw new Zend_Search_Lucene_Exception('Wrong TermInfoFile file format');
         }
 
         $termCount     = $tisFile->readLong();
         $indexInterval = $tisFile->readInt();
         $skipInterval  = $tisFile->readInt();
+        if ($tiVersion == (int)0xFFFFFFFD /* 2.1+ format */) {
+            $maxSkipLevels = $tisFile->readInt();
+        }
 
-        $tisFile->seek($prevTermInfo[4] /* indexPointer */ - 20 /* header size*/, SEEK_CUR);
+        $tisFile->seek($prevTermInfo[4] /* indexPointer */ - (($tiVersion == (int)0xFFFFFFFD)? 24 : 20) /* header size*/, SEEK_CUR);
 
         $termValue    = $prevTerm[1] /* text */;
         $termFieldNum = $prevTerm[0] /* field */;
@@ -666,11 +792,29 @@ class Zend_Search_Lucene_Index_SegmentInfo
      * Load normalizatin factors from an index file
      *
      * @param integer $fieldNum
+     * @throws Zend_Search_Lucene_Exception
      */
     private function _loadNorm($fieldNum)
     {
-        $fFile = $this->openCompoundFile('.f' . $fieldNum);
-        $this->_norms[$fieldNum] = $fFile->readBytes($this->_docCount);
+        if ($this->_hasSingleNormFile) {
+            $normfFile = $this->openCompoundFile('.nrm');
+
+            $header              = $normfFile->readBytes(3);
+            $headerFormatVersion = $normfFile->readByte();
+
+            if ($header != 'NRM'  ||  $headerFormatVersion != (int)0xFF) {
+                throw new  Zend_Search_Lucene_Exception('Wrong norms file format.');
+            }
+
+            foreach ($this->_fields as $fieldNum => $fieldInfo) {
+                if ($fieldInfo->isIndexed) {
+                    $this->_norms[$fieldNum] = $normfFile->readBytes($this->_docCount);
+                }
+            }
+        } else {
+            $fFile = $this->openCompoundFile('.f' . $fieldNum);
+            $this->_norms[$fieldNum] = $fFile->readBytes($this->_docCount);
+        }
     }
 
     /**
@@ -731,6 +875,26 @@ class Zend_Search_Lucene_Index_SegmentInfo
     }
 
 
+    /**
+     * Returns true if segment has single norms file.
+     *
+     * @return boolean
+     */
+    public function hasSingleNormFile()
+    {
+        return $this->_hasSingleNormFile ? 1 : 0;
+    }
+
+    /**
+     * Returns true if segment is stored using compound segment file.
+     *
+     * @return boolean
+     */
+    public function isCompound()
+    {
+        return $this->_isCompound ? 1 : 0;
+    }
+
     /**
      * Deletes a document from the index segment.
      * $id is an internal document id
@@ -803,7 +967,35 @@ class Zend_Search_Lucene_Index_SegmentInfo
         }
 
 
-        $delFile = $this->_directory->createFile($this->_name . '.del');
+        // Get new generation number
+        Zend_Search_Lucene_LockManager::obtainWriteLock($this->_directory);
+
+        $delFileList = array();
+        foreach ($this->_directory->fileList() as $file) {
+               if ($file == $this->_name . '.del') {
+                       // Matches <segment_name>.del file name
+                       $delFileList[] = 0;
+               } else if (preg_match('/^' . $this->_name . '_([a-zA-Z0-9]+)\.del$/i', $file, $matches)) {
+                       // Matches <segment_name>_NNN.del file names
+                $delFileList[] = (int)base_convert($matches[1], 36, 10);
+            }
+        }
+
+        if (count($delFileList) == 0) {
+               // There is no deletions file for current segment in the directory
+               // Set detetions file generation number to 1
+               $this->_delGen = 1;
+        } else {
+               // There are some deletions files for current segment in the directory
+               // Set detetions file generation number to the highest + 1
+               $this->_delGen = max($delFileList) + 1;
+        }
+
+        $delFile = $this->_directory->createFile($this->_name . '_' . base_convert($this->_delGen, 10, 36) . '.del');
+
+        Zend_Search_Lucene_LockManager::releaseWriteLock($this->_directory);
+
+
         $delFile->writeInt($this->_docCount);
         $delFile->writeInt($bitCount);
         $delFile->writeBytes($delBytes);
@@ -820,6 +1012,13 @@ class Zend_Search_Lucene_Index_SegmentInfo
      */
     private $_tisFile = null;
 
+    /**
+     * Actual offset of the .tis file data
+     *
+     * @var integer
+     */
+    private $_tisFileOffset;
+
     /**
      * Frequencies File object for stream like terms reading
      *
@@ -828,7 +1027,7 @@ class Zend_Search_Lucene_Index_SegmentInfo
     private $_frqFile = null;
 
     /**
-     * Offset of the .frq file in the compound file
+     * Actual offset of the .frq file data
      *
      * @var integer
      */
@@ -842,7 +1041,7 @@ class Zend_Search_Lucene_Index_SegmentInfo
     private $_prxFile = null;
 
     /**
-     * Offset of the .prx file in the compound file
+     * Actual offset of the .prx file in the compound file
      *
      * @var integer
      */
@@ -850,12 +1049,26 @@ class Zend_Search_Lucene_Index_SegmentInfo
 
 
     /**
-     * Number of terms in term stream
+     * Actual number of terms in term stream
      *
      * @var integer
      */
     private $_termCount = 0;
 
+    /**
+     * Overall number of terms in term stream
+     *
+     * @var integer
+     */
+    private $_termNum = 0;
+
+    /**
+     * Segment index interval
+     *
+     * @var integer
+     */
+    private $_indexInterval;
+
     /**
      * Segment skip interval
      *
@@ -891,10 +1104,32 @@ class Zend_Search_Lucene_Index_SegmentInfo
      * An array of all term positions in the documents.
      * Array structure: array( docId => array( pos1, pos2, ...), ...)
      *
-     * @var array
+     * Is set to null if term positions loading has to be skipped
+     *
+     * @var array|null
      */
     private $_lastTermPositions;
 
+
+    /**
+     * Terms scan mode
+     *
+     * Values:
+     *
+     * self::SM_TERMS_ONLY - terms are scanned, no additional info is retrieved
+     * self::SM_MERGE_INFO - terms are scanned, frequency and position info is retrieved
+     *                       document numbers are compacted (shifted if segment has deleted documents)
+     *
+     * @var integer
+     */
+    private $_termsScanMode;
+
+    /** Scan modes */
+    const SM_TERMS_ONLY = 0;    // terms are scanned, no additional info is retrieved
+    const SM_FULL_INFO  = 1;    // terms are scanned, frequency and position info is retrieved
+    const SM_MERGE_INFO = 2;    // terms are scanned, frequency and position info is retrieved
+                                // document numbers are compacted (shifted if segment contains deleted documents)
+
     /**
      * Reset terms stream
      *
@@ -904,50 +1139,223 @@ class Zend_Search_Lucene_Index_SegmentInfo
      * Returns start document id for the next segment
      *
      * @param integer $startId
-     * @param boolean $compact
+     * @param integer $mode
      * @throws Zend_Search_Lucene_Exception
      * @return integer
      */
-    public function reset($startId = 0, $compact = false)
+    public function reset($startId = 0, $mode = self::SM_TERMS_ONLY)
     {
         if ($this->_tisFile !== null) {
             $this->_tisFile = null;
         }
 
         $this->_tisFile = $this->openCompoundFile('.tis', false);
+        $this->_tisFileOffset = $this->_tisFile->tell();
+
         $tiVersion = $this->_tisFile->readInt();
-        if ($tiVersion != (int)0xFFFFFFFE) {
+        if ($tiVersion != (int)0xFFFFFFFE /* pre-2.1 format */  &&
+            $tiVersion != (int)0xFFFFFFFD /* 2.1+ format    */) {
             throw new Zend_Search_Lucene_Exception('Wrong TermInfoFile file format');
         }
 
-        $this->_termCount    = $this->_tisFile->readLong();
-                               $this->_tisFile->readInt();  // Read Index interval
-        $this->_skipInterval = $this->_tisFile->readInt();  // Read skip interval
+        $this->_termCount     =
+              $this->_termNum = $this->_tisFile->readLong(); // Read terms count
+        $this->_indexInterval = $this->_tisFile->readInt();  // Read Index interval
+        $this->_skipInterval  = $this->_tisFile->readInt();  // Read skip interval
+        if ($tiVersion == (int)0xFFFFFFFD /* 2.1+ format */) {
+            $maxSkipLevels = $this->_tisFile->readInt();
+        }
 
         if ($this->_frqFile !== null) {
             $this->_frqFile = null;
         }
-        $this->_frqFile = $this->openCompoundFile('.frq', false);
-        $this->_frqFileOffset = $this->_frqFile->tell();
-
         if ($this->_prxFile !== null) {
             $this->_prxFile = null;
         }
-        $this->_prxFile = $this->openCompoundFile('.prx', false);
-        $this->_prxFileOffset = $this->_prxFile->tell();
+        $this->_docMap = array();
 
-        $this->_lastTerm     = new Zend_Search_Lucene_Index_Term('', -1);
-        $this->_lastTermInfo = new Zend_Search_Lucene_Index_TermInfo(0, 0, 0, 0);
+        $this->_lastTerm          = new Zend_Search_Lucene_Index_Term('', -1);
+        $this->_lastTermInfo      = new Zend_Search_Lucene_Index_TermInfo(0, 0, 0, 0);
+        $this->_lastTermPositions = null;
 
-        $this->_docMap = array();
-        for ($count = 0; $count < $this->_docCount; $count++) {
-            if (!$this->isDeleted($count)) {
-                $this->_docMap[$count] = $startId + ($compact ? count($this->_docMap) : $count);
-            }
+        $this->_termsScanMode = $mode;
+
+        switch ($mode) {
+            case self::SM_TERMS_ONLY:
+                // Do nothing
+                break;
+
+            case self::SM_FULL_INFO:
+                // break intentionally omitted
+            case self::SM_MERGE_INFO:
+                $this->_frqFile = $this->openCompoundFile('.frq', false);
+                $this->_frqFileOffset = $this->_frqFile->tell();
+
+                $this->_prxFile = $this->openCompoundFile('.prx', false);
+                $this->_prxFileOffset = $this->_prxFile->tell();
+
+                for ($count = 0; $count < $this->_docCount; $count++) {
+                    if (!$this->isDeleted($count)) {
+                        $this->_docMap[$count] = $startId + (($mode == self::SM_MERGE_INFO) ? count($this->_docMap) : $count);
+                    }
+                }
+                break;
+
+            default:
+                throw new Zend_Search_Lucene_Exception('Wrong terms scaning mode specified.');
+                break;
         }
 
+
         $this->nextTerm();
-        return $startId + ($compact ? count($this->_docMap) : $this->_docCount);
+        return $startId + (($mode == self::SM_MERGE_INFO) ? count($this->_docMap) : $this->_docCount);
+    }
+
+
+    /**
+     * Skip terms stream up to specified term preffix.
+     *
+     * Prefix contains fully specified field info and portion of searched term
+     *
+     * @param Zend_Search_Lucene_Index_Term $prefix
+     * @throws Zend_Search_Lucene_Exception
+     */
+    public function skipTo(Zend_Search_Lucene_Index_Term $prefix)
+    {
+        if ($this->_termDictionary === null) {
+            $this->_loadDictionaryIndex();
+        }
+
+        $searchField = $this->getFieldNum($prefix->field);
+
+        if ($searchField == -1) {
+            /**
+             * Field is not presented in this segment
+             * Go to the end of dictionary
+             */
+            $this->_tisFile = null;
+            $this->_frqFile = null;
+            $this->_prxFile = null;
+
+            $this->_lastTerm          = null;
+            $this->_lastTermInfo      = null;
+            $this->_lastTermPositions = null;
+
+            return;
+        }
+        $searchDicField = $this->_getFieldPosition($searchField);
+
+        // search for appropriate value in dictionary
+        $lowIndex = 0;
+        $highIndex = count($this->_termDictionary)-1;
+        while ($highIndex >= $lowIndex) {
+            // $mid = ($highIndex - $lowIndex)/2;
+            $mid = ($highIndex + $lowIndex) >> 1;
+            $midTerm = $this->_termDictionary[$mid];
+
+            $fieldNum = $this->_getFieldPosition($midTerm[0] /* field */);
+            $delta = $searchDicField - $fieldNum;
+            if ($delta == 0) {
+                $delta = strcmp($prefix->text, $midTerm[1] /* text */);
+            }
+
+            if ($delta < 0) {
+                $highIndex = $mid-1;
+            } elseif ($delta > 0) {
+                $lowIndex  = $mid+1;
+            } else {
+                // We have reached term we are looking for
+                break;
+            }
+        }
+
+        if ($highIndex == -1) {
+            // Term is out of the dictionary range
+            $this->_tisFile = null;
+            $this->_frqFile = null;
+            $this->_prxFile = null;
+
+            $this->_lastTerm          = null;
+            $this->_lastTermInfo      = null;
+            $this->_lastTermPositions = null;
+
+            return;
+        }
+
+        $prevPosition = $highIndex;
+        $prevTerm = $this->_termDictionary[$prevPosition];
+        $prevTermInfo = $this->_termDictionaryInfos[$prevPosition];
+
+        if ($this->_tisFile === null) {
+            // The end of terms stream is reached and terms dictionary file is closed
+            // Perform mini-reset operation
+            $this->_tisFile = $this->openCompoundFile('.tis', false);
+
+            if ($this->_termsScanMode == self::SM_FULL_INFO  ||  $this->_termsScanMode == self::SM_MERGE_INFO) {
+                $this->_frqFile = $this->openCompoundFile('.frq', false);
+                $this->_prxFile = $this->openCompoundFile('.prx', false);
+            }
+        }
+        $this->_tisFile->seek($this->_tisFileOffset + $prevTermInfo[4], SEEK_SET);
+
+        $this->_lastTerm     = new Zend_Search_Lucene_Index_Term($prevTerm[1] /* text */,
+                                                                 ($prevTerm[0] == -1) ? '' : $this->_fields[$prevTerm[0] /* field */]->name);
+        $this->_lastTermInfo = new Zend_Search_Lucene_Index_TermInfo($prevTermInfo[0] /* docFreq */,
+                                                                     $prevTermInfo[1] /* freqPointer */,
+                                                                     $prevTermInfo[2] /* proxPointer */,
+                                                                     $prevTermInfo[3] /* skipOffset */);
+        $this->_termCount  =  $this->_termNum - $prevPosition*$this->_indexInterval;
+
+        if ($highIndex == 0) {
+            // skip start entry
+            $this->nextTerm();
+        } else if ($prefix->field == $this->_lastTerm->field  &&  $prefix->text  == $this->_lastTerm->text) {
+            // We got exact match in the dictionary index
+
+            if ($this->_termsScanMode == self::SM_FULL_INFO  ||  $this->_termsScanMode == self::SM_MERGE_INFO) {
+                $this->_lastTermPositions = array();
+
+                $this->_frqFile->seek($this->_lastTermInfo->freqPointer + $this->_frqFileOffset, SEEK_SET);
+                $freqs = array();   $docId = 0;
+                for( $count = 0; $count < $this->_lastTermInfo->docFreq; $count++ ) {
+                    $docDelta = $this->_frqFile->readVInt();
+                    if( $docDelta % 2 == 1 ) {
+                        $docId += ($docDelta-1)/2;
+                        $freqs[ $docId ] = 1;
+                    } else {
+                        $docId += $docDelta/2;
+                        $freqs[ $docId ] = $this->_frqFile->readVInt();
+                    }
+                }
+
+                $this->_prxFile->seek($this->_lastTermInfo->proxPointer + $this->_prxFileOffset, SEEK_SET);
+                foreach ($freqs as $docId => $freq) {
+                    $termPosition = 0;  $positions = array();
+
+                    for ($count = 0; $count < $freq; $count++ ) {
+                        $termPosition += $this->_prxFile->readVInt();
+                        $positions[] = $termPosition;
+                    }
+
+                    if (isset($this->_docMap[$docId])) {
+                        $this->_lastTermPositions[$this->_docMap[$docId]] = $positions;
+                    }
+                }
+            }
+
+            return;
+        }
+
+        // Search term matching specified prefix
+        while ($this->_lastTerm !== null) {
+            if ( strcmp($this->_lastTerm->field, $prefix->field) > 0  ||
+                 ($prefix->field == $this->_lastTerm->field  &&  strcmp($this->_lastTerm->text, $prefix->text) >= 0) ) {
+                    // Current term matches or greate than the pattern
+                    return;
+            }
+
+            $this->nextTerm();
+        }
     }
 
 
@@ -959,8 +1367,10 @@ class Zend_Search_Lucene_Index_SegmentInfo
     public function nextTerm()
     {
         if ($this->_tisFile === null  ||  $this->_termCount == 0) {
-            $this->_lastTerm     = null;
-            $this->_lastTermInfo = null;
+            $this->_lastTerm          = null;
+            $this->_lastTermInfo      = null;
+            $this->_lastTermPositions = null;
+            $this->_docMap            = null;
 
             // may be necessary for "empty" segment
             $this->_tisFile = null;
@@ -989,36 +1399,37 @@ class Zend_Search_Lucene_Index_SegmentInfo
         $this->_lastTermInfo = new Zend_Search_Lucene_Index_TermInfo($docFreq, $freqPointer, $proxPointer, $skipOffset);
 
 
-        $this->_lastTermPositions = array();
+        if ($this->_termsScanMode == self::SM_FULL_INFO  ||  $this->_termsScanMode == self::SM_MERGE_INFO) {
+            $this->_lastTermPositions = array();
 
-        $this->_frqFile->seek($this->_lastTermInfo->freqPointer + $this->_frqFileOffset, SEEK_SET);
-        $freqs = array();   $docId = 0;
-        for( $count = 0; $count < $this->_lastTermInfo->docFreq; $count++ ) {
-            $docDelta = $this->_frqFile->readVInt();
-            if( $docDelta % 2 == 1 ) {
-                $docId += ($docDelta-1)/2;
-                $freqs[ $docId ] = 1;
-            } else {
-                $docId += $docDelta/2;
-                $freqs[ $docId ] = $this->_frqFile->readVInt();
+            $this->_frqFile->seek($this->_lastTermInfo->freqPointer + $this->_frqFileOffset, SEEK_SET);
+            $freqs = array();   $docId = 0;
+            for( $count = 0; $count < $this->_lastTermInfo->docFreq; $count++ ) {
+                $docDelta = $this->_frqFile->readVInt();
+                if( $docDelta % 2 == 1 ) {
+                    $docId += ($docDelta-1)/2;
+                    $freqs[ $docId ] = 1;
+                } else {
+                    $docId += $docDelta/2;
+                    $freqs[ $docId ] = $this->_frqFile->readVInt();
+                }
             }
-        }
 
-        $this->_prxFile->seek($this->_lastTermInfo->proxPointer + $this->_prxFileOffset, SEEK_SET);
-        foreach ($freqs as $docId => $freq) {
-            $termPosition = 0;  $positions = array();
+            $this->_prxFile->seek($this->_lastTermInfo->proxPointer + $this->_prxFileOffset, SEEK_SET);
+            foreach ($freqs as $docId => $freq) {
+                $termPosition = 0;  $positions = array();
 
-            for ($count = 0; $count < $freq; $count++ ) {
-                $termPosition += $this->_prxFile->readVInt();
-                $positions[] = $termPosition;
-            }
+                for ($count = 0; $count < $freq; $count++ ) {
+                    $termPosition += $this->_prxFile->readVInt();
+                    $positions[] = $termPosition;
+                }
 
-            if (isset($this->_docMap[$docId])) {
-                $this->_lastTermPositions[$this->_docMap[$docId]] = $positions;
+                if (isset($this->_docMap[$docId])) {
+                    $this->_lastTermPositions[$this->_docMap[$docId]] = $positions;
+                }
             }
         }
 
-
         $this->_termCount--;
         if ($this->_termCount == 0) {
             $this->_tisFile = null;
@@ -1029,11 +1440,28 @@ class Zend_Search_Lucene_Index_SegmentInfo
         return $this->_lastTerm;
     }
 
+    /**
+     * Close terms stream
+     *
+     * Should be used for resources clean up if stream is not read up to the end
+     */
+    public function closeTermsStream()
+    {
+        $this->_tisFile = null;
+        $this->_frqFile = null;
+        $this->_prxFile = null;
+
+        $this->_lastTerm          = null;
+        $this->_lastTermInfo      = null;
+        $this->_lastTermPositions = null;
+
+        $this->_docMap            = null;
+    }
+
 
     /**
      * Returns term in current position
      *
-     * @param Zend_Search_Lucene_Index_Term $term
      * @return Zend_Search_Lucene_Index_Term|null
      */
     public function currentTerm()
index 4d0f346ceb214e86792c5d2d7c4d990dee278d23..233d7987545ec2555a833e156c3a2c2aa78c6985 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Index
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Exception */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Exception.php';
+require_once 'Zend/Search/Lucene/Exception.php';
 
 /** Zend_Search_Lucene */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/PriorityQueue.php';
+require_once 'Zend/Search/Lucene/PriorityQueue.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Index
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Index_SegmentInfoPriorityQueue extends Zend_Search_Lucene_PriorityQueue
index 157489c492ecd263f5610a2c3a157a6f3c9a1171..97ce4bf6d80a04b3cb1ecb43e09c4037d27c0c72 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Index
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Exception */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Exception.php';
+require_once 'Zend/Search/Lucene/Exception.php';
 
 /** Zend_Search_Lucene_Index_SegmentInfo */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Index/SegmentInfo.php';
+require_once 'Zend/Search/Lucene/Index/SegmentInfo.php';
 
 /** Zend_Search_Lucene_Index_SegmentWriter_StreamWriter */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Index/SegmentWriter/StreamWriter.php';
+require_once 'Zend/Search/Lucene/Index/SegmentWriter/StreamWriter.php';
 
 /** Zend_Search_Lucene_Index_SegmentInfoPriorityQueue */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Index/SegmentInfoPriorityQueue.php';
+require_once 'Zend/Search/Lucene/Index/SegmentInfoPriorityQueue.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Index
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Index_SegmentMerger
@@ -232,7 +232,7 @@ class Zend_Search_Lucene_Index_SegmentMerger
 
         $segmentStartId = 0;
         foreach ($this->_segmentInfos as $segName => $segmentInfo) {
-            $segmentStartId = $segmentInfo->reset($segmentStartId, true);
+            $segmentStartId = $segmentInfo->reset($segmentStartId, Zend_Search_Lucene_Index_SegmentInfo::SM_MERGE_INFO);
 
             // Skip "empty" segments
             if ($segmentInfo->currentTerm() !== null) {
index 2f1a05e3229353212ea850f6e9eb6e686949b1d4..21e9a04d0de365120b5c5d3a13f987a37d66adf9 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Index
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Exception */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Exception.php';
+require_once 'Zend/Search/Lucene/Exception.php';
 
 /** Zend_Search_Lucene_Index_SegmentInfo */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Index/SegmentInfo.php';
+require_once 'Zend/Search/Lucene/Index/SegmentInfo.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Index
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 abstract class Zend_Search_Lucene_Index_SegmentWriter
@@ -47,19 +47,33 @@ abstract class Zend_Search_Lucene_Index_SegmentWriter
      */
     public static $indexInterval = 128;
 
-    /** Expert: The fraction of TermDocs entries stored in skip tables.
+    /**
+     * Expert: The fraction of TermDocs entries stored in skip tables.
      * Larger values result in smaller indexes, greater acceleration, but fewer
      * accelerable cases, while smaller values result in bigger indexes,
      * less acceleration and more
      * accelerable cases. More detailed experiments would be useful here.
      *
-     * 0x0x7FFFFFFF indicates that we don't use skip data
-     * Default value is 16
+     * 0x7FFFFFFF indicates that we don't use skip data
+     *
+     * Note: not used in current implementation
      *
      * @var integer
      */
     public static $skipInterval = 0x7FFFFFFF;
 
+    /**
+     * Expert: The maximum number of skip levels. Smaller values result in
+     * slightly smaller indexes, but slower skipping in big posting lists.
+     *
+     * 0 indicates that we don't use skip data
+     *
+     * Note: not used in current implementation
+     *
+     * @var integer
+     */
+    public static $maxSkipLevels = 0;
+
     /**
      * Number of docs in a segment
      *
@@ -245,6 +259,16 @@ abstract class Zend_Search_Lucene_Index_SegmentWriter
         return $this->_docCount;
     }
 
+    /**
+     * Return segment name
+     *
+     * @return string
+     */
+    public function getName()
+    {
+        return $this->_name;
+    }
+    
     /**
      * Dump Field Info (.fnm) segment file
      */
@@ -253,6 +277,12 @@ abstract class Zend_Search_Lucene_Index_SegmentWriter
         $fnmFile = $this->_directory->createFile($this->_name . '.fnm');
         $fnmFile->writeVInt(count($this->_fields));
 
+        $nrmFile = $this->_directory->createFile($this->_name . '.nrm');
+        // Write header
+        $nrmFile->writeBytes('NRM');
+        // Write format specifier
+        $nrmFile->writeByte((int)0xFF);
+
         foreach ($this->_fields as $field) {
             $fnmFile->writeString($field->name);
             $fnmFile->writeByte(($field->isIndexed       ? 0x01 : 0x00) |
@@ -262,14 +292,18 @@ abstract class Zend_Search_Lucene_Index_SegmentWriter
                                );
 
             if ($field->isIndexed) {
-                $normFileName = $this->_name . '.f' . $field->number;
-                $fFile = $this->_directory->createFile($normFileName);
-                $fFile->writeBytes($this->_norms[$field->name]);
-                $this->_files[] = $normFileName;
+                // pre-2.1 index mode (not used now)
+                // $normFileName = $this->_name . '.f' . $field->number;
+                // $fFile = $this->_directory->createFile($normFileName);
+                // $fFile->writeBytes($this->_norms[$field->name]);
+                // $this->_files[] = $normFileName;
+
+                $nrmFile->writeBytes($this->_norms[$field->name]);
             }
         }
 
         $this->_files[] = $this->_name . '.fnm';
+        $this->_files[] = $this->_name . '.nrm';
     }
 
 
@@ -351,16 +385,18 @@ abstract class Zend_Search_Lucene_Index_SegmentWriter
     public function initializeDictionaryFiles()
     {
         $this->_tisFile = $this->_directory->createFile($this->_name . '.tis');
-        $this->_tisFile->writeInt((int)0xFFFFFFFE);
+        $this->_tisFile->writeInt((int)0xFFFFFFFD);
         $this->_tisFile->writeLong(0 /* dummy data for terms count */);
         $this->_tisFile->writeInt(self::$indexInterval);
         $this->_tisFile->writeInt(self::$skipInterval);
+        $this->_tisFile->writeInt(self::$maxSkipLevels);
 
         $this->_tiiFile = $this->_directory->createFile($this->_name . '.tii');
-        $this->_tiiFile->writeInt((int)0xFFFFFFFE);
+        $this->_tiiFile->writeInt((int)0xFFFFFFFD);
         $this->_tiiFile->writeLong(0 /* dummy data for terms count */);
         $this->_tiiFile->writeInt(self::$indexInterval);
         $this->_tiiFile->writeInt(self::$skipInterval);
+        $this->_tiiFile->writeInt(self::$maxSkipLevels);
 
         /** Dump dictionary header */
         $this->_tiiFile->writeVInt(0);                    // preffix length
@@ -370,7 +406,7 @@ abstract class Zend_Search_Lucene_Index_SegmentWriter
         $this->_tiiFile->writeVInt(0);                    // DocFreq
         $this->_tiiFile->writeVInt(0);                    // FreqDelta
         $this->_tiiFile->writeVInt(0);                    // ProxDelta
-        $this->_tiiFile->writeVInt(20);                   // IndexDelta
+        $this->_tiiFile->writeVInt(24);                   // IndexDelta
 
         $this->_frqFile = $this->_directory->createFile($this->_name . '.frq');
         $this->_prxFile = $this->_directory->createFile($this->_name . '.prx');
@@ -384,7 +420,7 @@ abstract class Zend_Search_Lucene_Index_SegmentWriter
         $this->_prevTermInfo      = null;
         $this->_prevIndexTerm     = null;
         $this->_prevIndexTermInfo = null;
-        $this->_lastIndexPosition = 20;
+        $this->_lastIndexPosition = 24;
         $this->_termCount         = 0;
 
     }
index 7dd2bf91587f611a5a276a33796864675016357b..56d226512a847a3e9eb4f06bb148469e033c5034 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Index
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Exception */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Exception.php';
+require_once 'Zend/Search/Lucene/Exception.php';
 
 /** Zend_Search_Lucene_Analysis_Analyzer */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Analysis/Analyzer.php';
+require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
 
 /** Zend_Search_Lucene_Index_SegmentWriter */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Index/SegmentWriter.php';
+require_once 'Zend/Search/Lucene/Index/SegmentWriter.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Index
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter extends Zend_Search_Lucene_Index_SegmentWriter
@@ -204,9 +204,12 @@ class Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter extends Zend_Search_
 
         $this->_generateCFS();
 
-        return new Zend_Search_Lucene_Index_SegmentInfo($this->_name,
+        return new Zend_Search_Lucene_Index_SegmentInfo($this->_directory,
+                                                        $this->_name,
                                                         $this->_docCount,
-                                                        $this->_directory);
+                                                        -1,
+                                                        true,
+                                                        true);
     }
 
 }
index ba0e202522af0c4d4e0cabeb6c3ca126da899a2d..318a3a39889f7541e3cc85c96de7f3bbee97ead7 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Index
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Exception */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Exception.php';
+require_once 'Zend/Search/Lucene/Exception.php';
 
 /** Zend_Search_Lucene_Index_SegmentInfo */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Index/SegmentInfo.php';
+require_once 'Zend/Search/Lucene/Index/SegmentInfo.php';
 
 /** Zend_Search_Lucene_Index_SegmentWriter */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Index/SegmentWriter.php';
+require_once 'Zend/Search/Lucene/Index/SegmentWriter.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Index
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Index_SegmentWriter_StreamWriter extends Zend_Search_Lucene_Index_SegmentWriter
@@ -86,9 +86,12 @@ class Zend_Search_Lucene_Index_SegmentWriter_StreamWriter extends Zend_Search_Lu
         $this->_dumpFNM();
         $this->_generateCFS();
 
-        return new Zend_Search_Lucene_Index_SegmentInfo($this->_name,
+        return new Zend_Search_Lucene_Index_SegmentInfo($this->_directory,
+                                                        $this->_name,
                                                         $this->_docCount,
-                                                        $this->_directory);
+                                                        -1,
+                                                        true,
+                                                        true);
     }
 }
 
index 465b4ef41baff902e7616315cb085a48b1df2a53..1a5ac62caf9faf8ee0cf1f3bf700f44b8fc38e13 100644 (file)
@@ -15,7 +15,7 @@
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Index
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
@@ -31,7 +31,7 @@
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Index
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Index_Term
@@ -74,6 +74,7 @@ class Zend_Search_Lucene_Index_Term
     /**
      * Get term prefix
      *
+     * @param string $str
      * @param integer $length
      * @return string
      */
@@ -104,5 +105,39 @@ class Zend_Search_Lucene_Index_Term
 
         return substr($str, 0, $prefixBytes);
     }
+
+    /**
+     * Get UTF-8 string length
+     *
+     * @param string $str
+     * @return string
+     */
+    public static function getLength($str)
+    {
+        $bytes = 0;
+        $chars = 0;
+        while ($bytes < strlen($str)) {
+            $charBytes = 1;
+            if ((ord($str[$bytes]) & 0xC0) == 0xC0) {
+                $charBytes++;
+                if (ord($str[$bytes]) & 0x20 ) {
+                    $charBytes++;
+                    if (ord($str[$bytes]) & 0x10 ) {
+                        $charBytes++;
+                    }
+                }
+            }
+
+            if ($bytes + $charBytes > strlen($str)) {
+                // wrong character
+                break;
+            }
+
+            $chars++;
+            $bytes += $charBytes;
+        }
+
+        return $chars;
+    }
 }
 
index 95f7cfc65f4ff9f1b5aa869b3da48a4d9da01d4f..2d46724bd9f380c7527ce851a3bcb8e44669b477 100644 (file)
@@ -15,7 +15,7 @@
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Index
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
@@ -26,7 +26,7 @@
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Index
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Index_TermInfo
index 8e32f4e1f6ed30ce62e43363d0925204b325f60a..fb681516d91357f48fe83cd9738ab938f9874c22 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Index
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
-/** Zend_Search_Lucene_Index_SegmentWriter_ */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Index/SegmentWriter/DocumentWriter.php';
+/** Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter */
+require_once 'Zend/Search/Lucene/Index/SegmentWriter/DocumentWriter.php';
 
 /** Zend_Search_Lucene_Index_SegmentInfo */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Index/SegmentInfo.php';
+require_once 'Zend/Search/Lucene/Index/SegmentInfo.php';
 
 /** Zend_Search_Lucene_Index_SegmentMerger */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Index/SegmentMerger.php';
+require_once 'Zend/Search/Lucene/Index/SegmentMerger.php';
+
+/** Zend_Search_Lucene_LockManager */
+require_once 'Zend/Search/Lucene/LockManager.php';
 
 
 
@@ -35,7 +38,7 @@ require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Index/SegmentMerger.php';
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Index
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Index_Writer
@@ -154,33 +157,29 @@ class Zend_Search_Lucene_Index_Writer
                                              '.del' => '.del',
                                              '.sti' => '.sti' );
 
+    
     /**
-     * Opens the index for writing
-     *
-     * IndexWriter constructor needs Directory as a parameter. It should be
-     * a string with a path to the index folder or a Directory object.
-     * Second constructor parameter create is optional - true to create the
-     * index or overwrite the existing one.
+     * Create empty index
      *
      * @param Zend_Search_Lucene_Storage_Directory $directory
-     * @param array $segmentInfos
-     * @param boolean $create
+     * @param integer $generation
+     * @param integer $nameCount
      */
-    public function __construct(Zend_Search_Lucene_Storage_Directory $directory, &$segmentInfos, $create = false)
+    public static function createIndex(Zend_Search_Lucene_Storage_Directory $directory, $generation, $nameCount)
     {
-        $this->_directory    = $directory;
-        $this->_segmentInfos = &$segmentInfos;
+        if ($generation == 0) {
+            // Create index in pre-2.1 mode
 
-        if ($create) {
-            foreach ($this->_directory->fileList() as $file) {
+            foreach ($directory->fileList() as $file) {
                 if ($file == 'deletable' ||
                     $file == 'segments'  ||
                     isset(self::$_indexExtensions[ substr($file, strlen($file)-4)]) ||
                     preg_match('/\.f\d+$/i', $file) /* matches <segment_name>.f<decimal_nmber> file names */) {
-                        $this->_directory->deleteFile($file);
+                        $directory->deleteFile($file);
                     }
             }
-            $segmentsFile = $this->_directory->createFile('segments');
+
+            $segmentsFile = $directory->createFile('segments');
             $segmentsFile->writeInt((int)0xFFFFFFFF);
 
             // write version (is initialized by current time
@@ -190,22 +189,55 @@ class Zend_Search_Lucene_Index_Writer
             $segmentsFile->writeInt((int)($version & 0xFFFFFFFF));
 
             // write name counter
-            $segmentsFile->writeInt(0);
+            $segmentsFile->writeInt($nameCount);
             // write segment counter
             $segmentsFile->writeInt(0);
 
-            $deletableFile = $this->_directory->createFile('deletable');
+            $deletableFile = $directory->createFile('deletable');
             // write counter
             $deletableFile->writeInt(0);
         } else {
-            $segmentsFile = $this->_directory->getFileObject('segments');
-            $format = $segmentsFile->readInt();
-            if ($format != (int)0xFFFFFFFF) {
-                throw new Zend_Search_Lucene_Exception('Wrong segments file format');
-            }
+            $genFile = $directory->createFile('segments.gen');
+
+            $genFile->writeInt((int)0xFFFFFFFE);
+            // Write generation two times
+            $genFile->writeLong($generation);
+            $genFile->writeLong($generation);
+
+            $segmentsFile = $directory->createFile(Zend_Search_Lucene::getSegmentFileName($generation));
+            $segmentsFile->writeInt((int)0xFFFFFFFD);
+
+            // write version (is initialized by current time
+            // $segmentsFile->writeLong((int)microtime(true));
+            $version = microtime(true);
+            $segmentsFile->writeInt((int)($version/((double)0xFFFFFFFF + 1)));
+            $segmentsFile->writeInt((int)($version & 0xFFFFFFFF));
+
+            // write name counter
+            $segmentsFile->writeInt($nameCount);
+            // write segment counter
+            $segmentsFile->writeInt(0);
         }
     }
 
+    /**
+     * Open the index for writing
+     *
+     * IndexWriter constructor needs Directory as a parameter. It should be
+     * a string with a path to the index folder or a Directory object.
+     * Second constructor parameter create is optional - true to create the
+     * index or overwrite the existing one.
+     *
+     * @param Zend_Search_Lucene_Storage_Directory $directory
+     * @param array $segmentInfos
+     * @param Zend_Search_Lucene_Storage_File $cleanUpLock
+     */
+    public function __construct(Zend_Search_Lucene_Storage_Directory $directory, &$segmentInfos)
+    {
+        $this->_directory    = $directory;
+        $this->_segmentInfos = &$segmentInfos;
+    }
+
     /**
      * Adds a document to this index.
      *
@@ -223,27 +255,86 @@ class Zend_Search_Lucene_Index_Writer
             $this->commit();
         }
 
-        $this->_versionUpdate++;
-
         $this->_maybeMergeSegments();
+
+        $this->_versionUpdate++;
     }
 
 
+    /**
+     * Check if we have anything to merge
+     * 
+     * @return boolean
+     */
+    private function _hasAnythingToMerge()
+    {
+        $segmentSizes = array();
+        foreach ($this->_segmentInfos as $segName => $segmentInfo) {
+            $segmentSizes[$segName] = $segmentInfo->count();
+        }
+
+        $mergePool   = array();
+        $poolSize    = 0;
+        $sizeToMerge = $this->maxBufferedDocs;
+        asort($segmentSizes, SORT_NUMERIC);
+        foreach ($segmentSizes as $segName => $size) {
+            // Check, if segment comes into a new merging block
+            while ($size >= $sizeToMerge) {
+                // Merge previous block if it's large enough
+                if ($poolSize >= $sizeToMerge) {
+                    return true;
+                }
+                $mergePool   = array();
+                $poolSize    = 0;
+
+                $sizeToMerge *= $this->mergeFactor;
+
+                if ($sizeToMerge > $this->maxMergeDocs) {
+                    return false;
+                }
+            }
+
+            $mergePool[] = $this->_segmentInfos[$segName];
+            $poolSize += $size;
+        }
+
+        if ($poolSize >= $sizeToMerge) {
+            return true;
+        }
+        
+        return false;
+    }
+    
     /**
      * Merge segments if necessary
      */
     private function _maybeMergeSegments()
     {
+        if (Zend_Search_Lucene_LockManager::obtainOptimizationLock($this->_directory) === false) {
+            return;
+        }
+        
+
+        if (!$this->_hasAnythingToMerge()) {
+            Zend_Search_Lucene_LockManager::releaseOptimizationLock($this->_directory);
+            return;
+        }
+        
+        // Update segments list to be sure all segments are not merged yet by other process
+        $this->_updateSegments();
+        
+        
+        // Perform standard auto-optimization procedure
         $segmentSizes = array();
-        foreach ($this->_segmentInfos as $segId => $segmentInfo) {
-            $segmentSizes[$segId] = $segmentInfo->count();
+        foreach ($this->_segmentInfos as $segName => $segmentInfo) {
+            $segmentSizes[$segName] = $segmentInfo->count();
         }
 
         $mergePool   = array();
         $poolSize    = 0;
         $sizeToMerge = $this->maxBufferedDocs;
         asort($segmentSizes, SORT_NUMERIC);
-        foreach ($segmentSizes as $segId => $size) {
+        foreach ($segmentSizes as $segName => $size) {
             // Check, if segment comes into a new merging block
             while ($size >= $sizeToMerge) {
                 // Merge previous block if it's large enough
@@ -256,17 +347,20 @@ class Zend_Search_Lucene_Index_Writer
                 $sizeToMerge *= $this->mergeFactor;
 
                 if ($sizeToMerge > $this->maxMergeDocs) {
+                    Zend_Search_Lucene_LockManager::releaseOptimizationLock($this->_directory);
                     return;
                 }
             }
 
-            $mergePool[] = $this->_segmentInfos[$segId];
+            $mergePool[] = $this->_segmentInfos[$segName];
             $poolSize += $size;
         }
 
         if ($poolSize >= $sizeToMerge) {
             $this->_mergeSegments($mergePool);
         }
+        
+        Zend_Search_Lucene_LockManager::releaseOptimizationLock($this->_directory);
     }
 
     /**
@@ -278,13 +372,6 @@ class Zend_Search_Lucene_Index_Writer
      */
     private function _mergeSegments($segments)
     {
-        // Try to get exclusive non-blocking lock to the 'index.optimization.lock'
-        // Skip optimization if it's performed by other process right now
-        $optimizationLock = $this->_directory->createFile('index.optimization.lock');
-        if (!$optimizationLock->lock(LOCK_EX,true)) {
-            return;
-        }
-
         $newName = $this->_newSegmentName();
         $merger = new Zend_Search_Lucene_Index_SegmentMerger($this->_directory,
                                                              $newName);
@@ -299,9 +386,6 @@ class Zend_Search_Lucene_Index_Writer
         }
 
         $this->commit();
-
-        // optimization is finished
-        $optimizationLock->unlock();
     }
 
     /**
@@ -312,119 +396,299 @@ class Zend_Search_Lucene_Index_Writer
     private function _updateSegments()
     {
         // Get an exclusive index lock
-        // Wait, until all parallel searchers or indexers won't stop
-        // and stop all next searchers, while we are updating segments file
-        $lock = $this->_directory->getFileObject('index.lock');
-        if (!$lock->lock(LOCK_EX)) {
-            throw new Zend_Search_Lucene_Exception('Can\'t obtain exclusive index lock');
-        }
-
-
-        // Do not share file handlers to get file updates from other sessions.
-        $segmentsFile   = $this->_directory->getFileObject('segments', false);
-        $newSegmentFile = $this->_directory->createFile('segments.new', false);
-
-        // Write format marker
-        $newSegmentFile->writeInt((int)0xFFFFFFFF);
-
-        // Write index version
-        $segmentsFile->seek(4, SEEK_CUR);
-        // $version = $segmentsFile->readLong() + $this->_versionUpdate;
-        // Process version on 32-bit platforms
-        $versionHigh = $segmentsFile->readInt();
-        $versionLow  = $segmentsFile->readInt();
-        $version = $versionHigh * ((double)0xFFFFFFFF + 1) +
-                   (($versionLow < 0)? (double)0xFFFFFFFF - (-1 - $versionLow) : $versionLow);
-        $version += $this->_versionUpdate;
-        $this->_versionUpdate = 0;
-        $newSegmentFile->writeInt((int)($version/((double)0xFFFFFFFF + 1)));
-        $newSegmentFile->writeInt((int)($version & 0xFFFFFFFF));
-
-        // Write segment name counter
-        $newSegmentFile->writeInt($segmentsFile->readInt());
-
-        // Get number of segments offset
-        $numOfSegmentsOffset = $newSegmentFile->tell();
-        // Write number of segemnts
-        $segmentsCount = $segmentsFile->readInt();
-        $newSegmentFile->writeInt(0);  // Write dummy data (segment counter)
-
-        $segments = array();
-        for ($count = 0; $count < $segmentsCount; $count++) {
-            $segName = $segmentsFile->readString();
-            $segSize = $segmentsFile->readInt();
-
-            if (!in_array($segName, $this->_segmentsToDelete)) {
-                $newSegmentFile->writeString($segName);
-                $newSegmentFile->writeInt($segSize);
-
-                $segments[$segName] = $segSize;
-            }
-        }
-        $segmentsFile->close();
+        Zend_Search_Lucene_LockManager::obtainWriteLock($this->_directory);
 
-        $segmentsCount = count($segments) + count($this->_newSegments);
+        $generation = Zend_Search_Lucene::getActualGeneration($this->_directory);
+        $segmentsFile   = $this->_directory->getFileObject(Zend_Search_Lucene::getSegmentFileName($generation), false);
+        $newSegmentFile = $this->_directory->createFile(Zend_Search_Lucene::getSegmentFileName(++$generation), false);
 
-        // Remove segments, not listed in $segments (deleted)
-        // Load segments, not listed in $this->_segmentInfos
-        foreach ($this->_segmentInfos as $segId => $segInfo) {
-            if (isset($segments[$segInfo->getName()])) {
-                // Segment is already included into $this->_segmentInfos
-                unset($segments[$segInfo->getName()]);
+        try {
+            $genFile = $this->_directory->getFileObject('segments.gen', false);
+        } catch (Zend_Search_Lucene_Exception $e) {
+            if (strpos($e->getMessage(), 'is not readable') !== false) {
+                $genFile = $this->_directory->createFile('segments.gen');
             } else {
-                // remove deleted segment from a list
-                unset($this->_segmentInfos[$segId]);
+                throw $e;
             }
         }
-        // $segments contains a list of segments to load
-        // do it later
-
-        foreach ($this->_newSegments as $segName => $segmentInfo) {
-            $newSegmentFile->writeString($segName);
-            $newSegmentFile->writeInt($segmentInfo->count());
-
-            $this->_segmentInfos[] = $segmentInfo;
+        
+        $genFile->writeInt((int)0xFFFFFFFE);
+        // Write generation (first copy)
+        $genFile->writeLong($generation);
+
+        try {
+            // Write format marker
+            $newSegmentFile->writeInt((int)0xFFFFFFFD);
+    
+            // Skip format identifier
+            $segmentsFile->seek(4, SEEK_CUR);
+            // $version = $segmentsFile->readLong() + $this->_versionUpdate;
+            // Process version on 32-bit platforms
+            $versionHigh = $segmentsFile->readInt();
+            $versionLow  = $segmentsFile->readInt();
+            $version = $versionHigh * ((double)0xFFFFFFFF + 1) +
+                       (($versionLow < 0)? (double)0xFFFFFFFF - (-1 - $versionLow) : $versionLow);
+            $version += $this->_versionUpdate;
+            $this->_versionUpdate = 0;
+            $newSegmentFile->writeInt((int)($version/((double)0xFFFFFFFF + 1)));
+            $newSegmentFile->writeInt((int)($version & 0xFFFFFFFF));
+    
+            // Write segment name counter
+            $newSegmentFile->writeInt($segmentsFile->readInt());
+    
+            // Get number of segments offset
+            $numOfSegmentsOffset = $newSegmentFile->tell();
+            // Write dummy data (segment counter)
+            $newSegmentFile->writeInt(0);
+    
+            // Read number of segemnts
+            $segmentsCount = $segmentsFile->readInt();
+
+            $segments = array();
+            for ($count = 0; $count < $segmentsCount; $count++) {
+                $segName = $segmentsFile->readString();
+                $segSize = $segmentsFile->readInt();
+    
+                if ($generation == 1 /* retrieved generation is 0 */) {
+                    // pre-2.1 index format
+                    $delGenHigh = 0;
+                    $delGenLow  = 0;
+                    $hasSingleNormFile = false;
+                    $numField = (int)0xFFFFFFFF;
+                    $isCompound = 1;
+                } else {
+                    //$delGen          = $segmentsFile->readLong();
+                    $delGenHigh        = $segmentsFile->readInt();
+                    $delGenLow         = $segmentsFile->readInt();
+                    $hasSingleNormFile = $segmentsFile->readByte();
+                    $numField          = $segmentsFile->readInt();
+    
+                    $normGens = array();
+                    if ($numField != (int)0xFFFFFFFF) {
+                        for ($count1 = 0; $count1 < $numField; $count1++) {
+                            $normGens[] = $segmentsFile->readLong();
+                        }
+                    }
+                    $isCompound        = $segmentsFile->readByte();
+                }
+    
+                if (!in_array($segName, $this->_segmentsToDelete)) {
+                    // Load segment if necessary
+                    if (!isset($this->_segmentInfos[$segName])) {
+                        $delGen = $delGenHigh * ((double)0xFFFFFFFF + 1) +
+                                     (($delGenLow < 0)? (double)0xFFFFFFFF - (-1 - $delGenLow) : $delGenLow);
+                        $this->_segmentInfos[$segName] = 
+                                    new Zend_Search_Lucene_Index_SegmentInfo($this->_directory,
+                                                                             $segName,
+                                                                             $segSize,
+                                                                             $delGen,
+                                                                             $hasSingleNormFile,
+                                                                             $isCompound);
+                    } else {
+                        // Retrieve actual detetions file generation number
+                        $delGen = $this->_segmentInfos[$segName]->getDelGen();
+                        
+                        if ($delGen >= 0) {
+                            $delGenHigh = (int)($delGen/((double)0xFFFFFFFF + 1));
+                            $delGenLow  =(int)($delGen & 0xFFFFFFFF);
+                        } else {
+                            $delGenHigh = $delGenLow = (int)0xFFFFFFFF;
+                        }
+                    }
+                    
+                    $newSegmentFile->writeString($segName);
+                    $newSegmentFile->writeInt($segSize);
+                    $newSegmentFile->writeInt($delGenHigh);
+                    $newSegmentFile->writeInt($delGenLow);
+                    $newSegmentFile->writeByte($hasSingleNormFile);
+                    $newSegmentFile->writeInt($numField);
+                    if ($numField != (int)0xFFFFFFFF) {
+                        foreach ($normGens as $normGen) {
+                            $newSegmentFile->writeLong($normGen);
+                        }
+                    }
+                    $newSegmentFile->writeByte($isCompound);
+    
+                    $segments[$segName] = $segSize;
+                }
+            }
+            $segmentsFile->close();
+    
+            $segmentsCount = count($segments) + count($this->_newSegments);
+    
+            foreach ($this->_newSegments as $segName => $segmentInfo) {
+                $newSegmentFile->writeString($segName);
+                $newSegmentFile->writeInt($segmentInfo->count());
+    
+                // delete file generation: -1 (there is no delete file yet)
+                $newSegmentFile->writeInt((int)0xFFFFFFFF);$newSegmentFile->writeInt((int)0xFFFFFFFF);
+                // HasSingleNormFile
+                $newSegmentFile->writeByte($segmentInfo->hasSingleNormFile());
+                // NumField
+                $newSegmentFile->writeInt((int)0xFFFFFFFF);
+                // IsCompoundFile
+                $newSegmentFile->writeByte($segmentInfo->isCompound());
+    
+                $segments[$segmentInfo->getName()] = $segmentInfo->count();
+                $this->_segmentInfos[$segName] = $segmentInfo;
+            }
+            $this->_newSegments = array();
+    
+            $newSegmentFile->seek($numOfSegmentsOffset);
+            $newSegmentFile->writeInt($segmentsCount);  // Update segments count
+            $newSegmentFile->close();
+        } catch (Exception $e) {
+            /** Restore previous index generation */
+            $generation--;
+            $genFile->seek(4, SEEK_SET);
+            // Write generation number twice
+            $genFile->writeLong($generation); $genFile->writeLong($generation);
+
+            // Release index write lock
+            Zend_Search_Lucene_LockManager::releaseWriteLock($this->_directory);
+            
+            // Throw the exception
+            throw $e;
         }
-        $this->_newSegments = array();
-
-        $newSegmentFile->seek($numOfSegmentsOffset);
-        $newSegmentFile->writeInt($segmentsCount);  // Update segments count
-        $newSegmentFile->close();
-        $this->_directory->renameFile('segments.new', 'segments');
-
-
-        // Segments file update is finished
-        // Switch back to shared lock mode
-        $lock->lock(LOCK_SH);
-
 
-        $fileList = $this->_directory->fileList();
-        foreach ($this->_segmentsToDelete as $nameToDelete) {
-            foreach (self::$_indexExtensions as $ext) {
-                if ($this->_directory->fileExists($nameToDelete . $ext)) {
-                    $this->_directory->deleteFile($nameToDelete . $ext);
+        // Write generation (second copy)
+        $genFile->writeLong($generation);
+
+        
+        // Check if another update process is not running now
+        // If yes, skip clean-up procedure
+        if (Zend_Search_Lucene_LockManager::escalateReadLock($this->_directory)) {
+            /**
+             * Clean-up directory
+             */
+            $filesToDelete = array();
+            $filesTypes    = array();
+            $filesNumbers  = array();
+            
+            // list of .del files of currently used segments
+            // each segment can have several generations of .del files
+            // only last should not be deleted
+            $delFiles = array();
+            
+            foreach ($this->_directory->fileList() as $file) {
+                if ($file == 'deletable') {
+                    // 'deletable' file
+                    $filesToDelete[] = $file;
+                    $filesTypes[]    = 0; // delete this file first, since it's not used starting from Lucene v2.1
+                    $filesNumbers[]  = 0;
+                } else if ($file == 'segments') {
+                    // 'segments' file
+    
+                    $filesToDelete[] = $file;
+                    $filesTypes[]    = 1; // second file to be deleted "zero" version of segments file (Lucene pre-2.1)
+                    $filesNumbers[]  = 0;
+                } else if (preg_match('/^segments_[a-zA-Z0-9]+$/i', $file)) {
+                    // 'segments_xxx' file
+                    // Check if it's not a just created generation file
+                    if ($file != Zend_Search_Lucene::getSegmentFileName($generation)) {
+                        $filesToDelete[] = $file;
+                        $filesTypes[]    = 2; // first group of files for deletions
+                        $filesNumbers[]  = (int)base_convert(substr($file, 9), 36, 10); // ordered by segment generation numbers 
+                    }
+                } else if (preg_match('/(^_([a-zA-Z0-9]+))\.f\d+$/i', $file, $matches)) {
+                    // one of per segment files ('<segment_name>.f<decimal_number>')
+                    // Check if it's not one of the segments in the current segments set
+                    if (!isset($segments[$matches[1]])) {
+                        $filesToDelete[] = $file;
+                        $filesTypes[]    = 3; // second group of files for deletions
+                        $filesNumbers[]  = (int)base_convert($matches[2], 36, 10); // order by segment number 
+                    }
+                } else if (preg_match('/(^_([a-zA-Z0-9]+))(_([a-zA-Z0-9]+))\.del$/i', $file, $matches)) {
+                    // one of per segment files ('<segment_name>_<del_generation>.del' where <segment_name> is '_<segment_number>')
+                    // Check if it's not one of the segments in the current segments set
+                    if (!isset($segments[$matches[1]])) {
+                        $filesToDelete[] = $file;
+                        $filesTypes[]    = 3; // second group of files for deletions
+                        $filesNumbers[]  = (int)base_convert($matches[2], 36, 10); // order by segment number 
+                    } else {
+                        $segmentNumber = (int)base_convert($matches[2], 36, 10);
+                        $delGeneration = (int)base_convert($matches[4], 36, 10);
+                        if (!isset($delFiles[$segmentNumber])) {
+                            $delFiles[$segmentNumber] = array();
+                        }
+                        $delFiles[$segmentNumber][$delGeneration] = $file;
+                    }
+                } else if (isset(self::$_indexExtensions[substr($file, strlen($file)-4)])) {
+                    // one of per segment files ('<segment_name>.<ext>')
+                    $segmentName = substr($file, 0, strlen($file) - 4);
+                    // Check if it's not one of the segments in the current segments set
+                    if (!isset($segments[$segmentName])  &&
+                        ($this->_currentSegment === null  ||  $this->_currentSegment->getName() != $segmentName)) {
+                        $filesToDelete[] = $file;
+                        $filesTypes[]    = 3; // second group of files for deletions
+                        $filesNumbers[]  = (int)base_convert(substr($file, 1 /* skip '_' */, strlen($file)-5), 36, 10); // order by segment number 
+                    }
                 }
             }
 
-            foreach ($fileList as $file) {
-                if (substr($file, 0, strlen($nameToDelete) + 2) == ($nameToDelete . '.f') &&
-                    ctype_digit( substr($file, strlen($nameToDelete) + 2) )) {
-                        $this->_directory->deleteFile($file);
+            $maxGenNumber = 0;
+            // process .del files of currently used segments
+            foreach ($delFiles as $segmentNumber => $segmentDelFiles) {
+                ksort($delFiles[$segmentNumber], SORT_NUMERIC);
+                array_pop($delFiles[$segmentNumber]); // remove last delete file generation from candidates for deleting
+                
+                end($delFiles[$segmentNumber]);
+                $lastGenNumber = key($delFiles[$segmentNumber]);
+                if ($lastGenNumber > $maxGenNumber) {
+                    $maxGenNumber = $lastGenNumber; 
+                }
+            }
+            foreach ($delFiles as $segmentNumber => $segmentDelFiles) {
+                foreach ($segmentDelFiles as $delGeneration => $file) {
+                        $filesToDelete[] = $file;
+                        $filesTypes[]    = 4; // third group of files for deletions
+                        $filesNumbers[]  = $segmentNumber*$maxGenNumber + $delGeneration; // order by <segment_number>,<del_generation> pair 
+                }
+            }
+            
+            // Reorder files for deleting
+            array_multisort($filesTypes,    SORT_ASC, SORT_NUMERIC,
+                            $filesNumbers,  SORT_ASC, SORT_NUMERIC,
+                            $filesToDelete, SORT_ASC, SORT_STRING);
+            
+            foreach ($filesToDelete as $file) {
+                try {
+                    $this->_directory->deleteFile($file);
+                } catch (Zend_Search_Lucene_Exception $e) {
+                    if (strpos($e->getMessage(), 'Can\'t delete file') === false) {
+                        // That's not "file is under processing or already deleted" exception
+                        // Pass it through
+                        throw $e;
                     }
+                }
+            }
+            
+            // Return read lock into the previous state
+            Zend_Search_Lucene_LockManager::deEscalateReadLock($this->_directory);
+        } else {
+            // Only release resources if another index reader is running now
+            foreach ($this->_segmentsToDelete as $segName) {
+                foreach (self::$_indexExtensions as $ext) {
+                    $this->_directory->purgeFile($segName . $ext);
+                }
             }
         }
+
+        // Clean-up _segmentsToDelete container
         $this->_segmentsToDelete = array();
+        
 
-        // Load segments, created by other process
-        foreach ($segments as $segName => $segSize) {
-            // Load new segments
-            $this->_segmentInfos[] = new Zend_Search_Lucene_Index_SegmentInfo($segName,
-                                                                              $segSize,
-                                                                              $this->_directory);
+        // Release index write lock
+        Zend_Search_Lucene_LockManager::releaseWriteLock($this->_directory);
+
+        // Remove unused segments from segments list
+        foreach ($this->_segmentInfos as $segName => $segmentInfo) {
+            if (!isset($segments[$segName])) {
+                unset($this->_segmentInfos[$segName]);
+            }
         }
     }
 
-
     /**
      * Commit current changes
      */
@@ -438,10 +702,7 @@ class Zend_Search_Lucene_Index_Writer
             $this->_currentSegment = null;
         }
 
-        if (count($this->_newSegments)      != 0 ||
-            count($this->_segmentsToDelete) != 0) {
-            $this->_updateSegments();
-        }
+        $this->_updateSegments();
     }
 
 
@@ -459,15 +720,24 @@ class Zend_Search_Lucene_Index_Writer
     }
 
     /**
-     * Merges all segments together into a single segment, optimizing
-     * an index for search.
-     * Input is an array of Zend_Search_Lucene_Index_SegmentInfo objects
+     * Merges all segments together into new one
+     * 
+     * Returns true on success and false if another optimization or auto-optimization process 
+     * is running now 
      *
-     * @throws Zend_Search_Lucene_Exception
+     * @return boolean
      */
     public function optimize()
     {
+        if (Zend_Search_Lucene_LockManager::obtainOptimizationLock($this->_directory) === false) {
+            return false;
+        }
+
         $this->_mergeSegments($this->_segmentInfos);
+        
+        Zend_Search_Lucene_LockManager::releaseOptimizationLock($this->_directory);
+        
+        return true;
     }
 
     /**
@@ -477,16 +747,10 @@ class Zend_Search_Lucene_Index_Writer
      */
     private function _newSegmentName()
     {
-        // Do not share file handler to get file updates from other sessions.
-        $segmentsFile = $this->_directory->getFileObject('segments', false);
-
-        // Get exclusive segments file lock
-        // We have guarantee, that we will not intersect with _updateSegments() call
-        // of other process, because it needs exclusive index lock and waits
-        // until all other searchers won't stop
-        if (!$segmentsFile->lock(LOCK_EX)) {
-            throw new Zend_Search_Lucene_Exception('Can\'t obtain exclusive index lock');
-        }
+        Zend_Search_Lucene_LockManager::obtainWriteLock($this->_directory);
+        
+        $generation = Zend_Search_Lucene::getActualGeneration($this->_directory);
+        $segmentsFile = $this->_directory->getFileObject(Zend_Search_Lucene::getSegmentFileName($generation), false);
 
         $segmentsFile->seek(12); // 12 = 4 (int, file format marker) + 8 (long, index version)
         $segmentNameCounter = $segmentsFile->readInt();
@@ -498,8 +762,8 @@ class Zend_Search_Lucene_Index_Writer
         // return (which calls $segmentsFile destructor)
         $segmentsFile->flush();
 
-        $segmentsFile->unlock();
-
+        Zend_Search_Lucene_LockManager::releaseWriteLock($this->_directory);
+        
         return '_' . base_convert($segmentNameCounter, 10, 36);
     }
 
index 58c75b644f367c7981d3b264bbd67e6333db8b2c..4e9dea5ea7579bd8470cb27300ef8a762f3a3b20 100644 (file)
@@ -14,7 +14,7 @@
  *
  * @category   Zend
  * @package    Zend_Search_Lucene
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
@@ -22,7 +22,7 @@
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 interface Zend_Search_Lucene_Interface
@@ -86,6 +86,24 @@ interface Zend_Search_Lucene_Interface
      */
     public static function getDefaultSearchField();
 
+    /**
+     * Set result set limit.
+     *
+     * 0 (default) means no limit
+     *
+     * @param integer $limit
+     */
+    public static function setResultSetLimit($limit);
+
+    /**
+     * Set result set limit.
+     *
+     * 0 means no limit
+     *
+     * @return integer
+     */
+    public static function getResultSetLimit();
+
     /**
      * Retrieve index maxBufferedDocs option
      *
@@ -306,6 +324,43 @@ interface Zend_Search_Lucene_Interface
      */
     public function terms();
 
+
+    /**
+     * Reset terms stream.
+     */
+    public function resetTermsStream();
+
+    /**
+     * Skip terms stream up to specified term preffix.
+     *
+     * Prefix contains fully specified field info and portion of searched term
+     *
+     * @param Zend_Search_Lucene_Index_Term $prefix
+     */
+    public function skipTo(Zend_Search_Lucene_Index_Term $prefix);
+
+    /**
+     * Scans terms dictionary and returns next term
+     *
+     * @return Zend_Search_Lucene_Index_Term|null
+     */
+    public function nextTerm();
+
+    /**
+     * Returns term in current position
+     *
+     * @return Zend_Search_Lucene_Index_Term|null
+     */
+    public function currentTerm();
+
+    /**
+     * Close terms stream
+     *
+     * Should be used for resources clean up if stream is not read up to the end
+     */
+    public function closeTermsStream();
+
+
     /**
      * Undeletes all documents currently marked as deleted in this index.
      */
diff --git a/search/Zend/Search/Lucene/LockManager.php b/search/Zend/Search/Lucene/LockManager.php
new file mode 100644 (file)
index 0000000..4730b51
--- /dev/null
@@ -0,0 +1,161 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Search_Lucene
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+
+/** Zend_Search_Lucene_Exception */
+require_once 'Zend/Search/Lucene/Exception.php';
+
+/** Zend_Search_Lucene_Storage_Directory */
+require_once 'Zend/Search/Lucene/Storage/Directory.php';
+
+/** Zend_Search_Lucene_Storage_File */
+require_once 'Zend/Search/Lucene/Storage/File.php';
+
+
+
+/**
+ * This is an utility class which provides index locks processing functionality
+ * 
+ * @category   Zend
+ * @package    Zend_Search_Lucene
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Search_Lucene_LockManager
+{
+    const WRITE_LOCK_FILE        = 'write.lock.file';
+    const READ_LOCK_FILE         = 'read.lock.file';
+    const OPTIMIZATION_LOCK_FILE = 'optimization.lock.file';
+    
+    /**
+     * Obtain exclusive write lock on the index
+     *
+     * @param Zend_Search_Lucene_Storage_Directory $lockDirectory
+     * @return Zend_Search_Lucene_Storage_File
+     * @throws Zend_Search_Lucene_Exception
+     */
+    public static function obtainWriteLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
+    {
+        $lock = $lockDirectory->createFile(self::WRITE_LOCK_FILE);
+        if (!$lock->lock(LOCK_EX)) {
+            throw new Zend_Search_Lucene_Exception('Can\'t obtain exclusive index lock');
+        }
+        return $lock;
+    }
+    
+    /**
+     * Release exclusive write lock
+     * 
+     * @param Zend_Search_Lucene_Storage_Directory $lockDirectory
+     */
+    public static function releaseWriteLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
+    {
+        $lock = $lockDirectory->getFileObject(self::WRITE_LOCK_FILE);
+        $lock->unlock();
+    }
+    
+    /**
+     * Obtain shared read lock on the index
+     * 
+     * It doesn't block other read or update processes, but prevent index from the premature cleaning-up
+     *
+     * @param Zend_Search_Lucene_Storage_Directory $defaultLockDirectory
+     * @return Zend_Search_Lucene_Storage_File
+     * @throws Zend_Search_Lucene_Exception
+     */
+    public static function obtainReadLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
+    {
+        $lock = $lockDirectory->createFile(self::READ_LOCK_FILE);
+        if (!$lock->lock(LOCK_SH)) {
+            throw new Zend_Search_Lucene_Exception('Can\'t obtain shared reading index lock');
+        }
+        return $lock;
+    }
+    
+    /**
+     * Release shared read lock
+     * 
+     * @param Zend_Search_Lucene_Storage_Directory $lockDirectory
+     */
+    public static function releaseReadLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
+    {
+        $lock = $lockDirectory->getFileObject(self::READ_LOCK_FILE);
+        $lock->unlock();
+    }
+
+    /**
+     * Escalate Read lock to exclusive level
+     * 
+     * @param Zend_Search_Lucene_Storage_Directory $lockDirectory
+     * @return boolean
+     */
+    public static function escalateReadLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
+    {
+        $lock = $lockDirectory->getFileObject(self::READ_LOCK_FILE);
+        
+        // Try to escalate read lock
+        if (!$lock->lock(LOCK_EX, true)) {
+            // Restore lock state
+            $lock->lock(LOCK_SH);
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * De-escalate Read lock to shared level
+     * 
+     * @param Zend_Search_Lucene_Storage_Directory $lockDirectory
+     */
+    public static function deEscalateReadLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
+    {
+        $lock = $lockDirectory->getFileObject(self::READ_LOCK_FILE);
+        $lock->lock(LOCK_SH);
+    }
+
+    /**
+     * Obtain exclusive optimization lock on the index
+     * 
+     * Returns lock object on success and false otherwise (doesn't block execution)
+     *
+     * @param Zend_Search_Lucene_Storage_Directory $lockDirectory
+     * @return mixed
+     */
+    public static function obtainOptimizationLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
+    {
+        $lock = $lockDirectory->createFile(self::OPTIMIZATION_LOCK_FILE);
+        if (!$lock->lock(LOCK_EX, true)) {
+            return false;
+        }
+        return $lock;
+    }
+    
+    /**
+     * Release exclusive optimization lock
+     * 
+     * @param Zend_Search_Lucene_Storage_Directory $lockDirectory
+     */
+    public static function releaseOptimizationLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
+    {
+        $lock = $lockDirectory->getFileObject(self::OPTIMIZATION_LOCK_FILE);
+        $lock->unlock();
+    }
+    
+}
index 4e844b18f600ee681ab6a19fc6a0a1eebc74dd2f..4712e559acadb7c36b02dfad996fbd2a098c379c 100644 (file)
@@ -14,7 +14,7 @@
  *
  * @category   Zend
  * @package    Zend_Search_Lucene
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
@@ -31,7 +31,7 @@
  *
  * @category   Zend
  * @package    Zend_Search_Lucene
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 abstract class Zend_Search_Lucene_PriorityQueue
index 53fb150bd4991e533a594607158ef546fdadcfea..74610877862b494a48b6b60eac3d77a050fbcae3 100644 (file)
  *
  * @category   Zend
  * @package    Zend_Search_Lucene
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 /** Zend_Search_Lucene_Interface */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Interface.php';
+require_once 'Zend/Search/Lucene/Interface.php';
 
 
 /**
@@ -29,7 +29,7 @@ require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Interface.php';
  *
  * @category   Zend
  * @package    Zend_Search_Lucene
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Proxy implements Zend_Search_Lucene_Interface
@@ -144,6 +144,30 @@ class Zend_Search_Lucene_Proxy implements Zend_Search_Lucene_Interface
         return Zend_Search_Lucene::getDefaultSearchField();
     }
 
+    /**
+     * Set result set limit.
+     *
+     * 0 (default) means no limit
+     *
+     * @param integer $limit
+     */
+    public static function setResultSetLimit($limit)
+    {
+        Zend_Search_Lucene::setResultSetLimit($limit);
+    }
+
+    /**
+     * Set result set limit.
+     *
+     * 0 means no limit
+     *
+     * @return integer
+     */
+    public static function getResultSetLimit()
+    {
+        return Zend_Search_Lucene::getResultSetLimit();
+    }
+
     /**
      * Retrieve index maxBufferedDocs option
      *
@@ -436,6 +460,58 @@ class Zend_Search_Lucene_Proxy implements Zend_Search_Lucene_Interface
         return $this->_index->terms();
     }
 
+
+    /**
+     * Reset terms stream.
+     */
+    public function resetTermsStream()
+    {
+        $this->_index->resetTermsStream();
+    }
+
+    /**
+     * Skip terms stream up to specified term preffix.
+     *
+     * Prefix contains fully specified field info and portion of searched term
+     *
+     * @param Zend_Search_Lucene_Index_Term $prefix
+     */
+    public function skipTo(Zend_Search_Lucene_Index_Term $prefix)
+    {
+        return $this->_index->skipTo($prefix);
+    }
+
+    /**
+     * Scans terms dictionary and returns next term
+     *
+     * @return Zend_Search_Lucene_Index_Term|null
+     */
+    public function nextTerm()
+    {
+        return $this->_index->nextTerm();
+    }
+
+    /**
+     * Returns term in current position
+     *
+     * @return Zend_Search_Lucene_Index_Term|null
+     */
+    public function currentTerm()
+    {
+        return $this->_index->currentTerm();
+    }
+
+    /**
+     * Close terms stream
+     *
+     * Should be used for resources clean up if stream is not read up to the end
+     */
+    public function closeTermsStream()
+    {
+        $this->_index->closeTermsStream();
+    }
+
+
     /**
      * Undeletes all documents currently marked as deleted in this index.
      */
index 1801bc1cf3a21d8ff078e38b1aff7947384e341a..649c222b9b5e4d4718583db608bb51637869ae86 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_FSM */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/FSM.php';
+require_once 'Zend/Search/Lucene/FSM.php';
 
 /** Zend_Search_Lucene_Search_QueryToken */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/QueryToken.php';
+require_once 'Zend/Search/Lucene/Search/QueryToken.php';
 
 /** Zend_Search_Lucene_Search_QueryParser */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/QueryParser.php';
+require_once 'Zend/Search/Lucene/Search/QueryParser.php';
 
 
 /** Zend_Search_Lucene_Exception */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Exception.php';
+require_once 'Zend/Search/Lucene/Exception.php';
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Search_BooleanExpressionRecognizer extends Zend_Search_Lucene_FSM
index e55c22ce0133ec5a1f13f6b3446396c54a2b96a8..e230eba268b303a61553599b6fe61d094e2c0bf4 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 /** Zend_Search_Lucene_Document_Html */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Document/Html.php';
+require_once 'Zend/Search/Lucene/Document/Html.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 abstract class Zend_Search_Lucene_Search_Query
index 710a41f381ffaa1c81d9d21fec6f007ff4a28a96..3846aa15633a2a143d5e1e796d0f2f4ec27292fc 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Search_Query */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/Query.php';
+require_once 'Zend/Search/Lucene/Search/Query.php';
 
 /** Zend_Search_Lucene_Search_Weight_Boolean */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/Weight/Boolean.php';
+require_once 'Zend/Search/Lucene/Search/Weight/Boolean.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_Query
@@ -39,7 +39,7 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
 
     /**
      * Subqueries
-     * Array of Zend_Search_Lucene_Query
+     * Array of Zend_Search_Lucene_Search_Query
      *
      * @var array
      */
@@ -105,7 +105,7 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
 
 
     /**
-     * Add a $subquery (Zend_Search_Lucene_Query) to this query.
+     * Add a $subquery (Zend_Search_Lucene_Search_Query) to this query.
      *
      * The sign is specified as:
      *     TRUE  - subquery is required
@@ -119,6 +119,7 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
     public function addSubquery(Zend_Search_Lucene_Search_Query $subquery, $sign=null) {
         if ($sign !== true || $this->_signs !== null) {       // Skip, if all subqueries are required
             if ($this->_signs === null) {                     // Check, If all previous subqueries are required
+                $this->_signs = array();
                 foreach ($this->_subqueries as $prevSubquery) {
                     $this->_signs[] = true;
                 }
@@ -165,6 +166,31 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
             $signs[]      = ($this->_signs === null)? true : $this->_signs[$id];
         }
 
+        // Remove insignificant subqueries
+        foreach ($subqueries as $id => $subquery) {
+            if ($subquery instanceof Zend_Search_Lucene_Search_Query_Insignificant) {
+                // Insignificant subquery has to be removed anyway
+                unset($subqueries[$id]);
+                unset($signs[$id]);
+            }
+        }
+        if (count($subqueries) == 0) {
+            // Boolean query doesn't has non-insignificant subqueries
+            return new Zend_Search_Lucene_Search_Query_Insignificant();
+        }
+        // Check if all non-insignificant subqueries are prohibited
+        $allProhibited = true;
+        foreach ($signs as $sign) {
+            if ($sign !== false) {
+                $allProhibited = false;
+                break;
+            }
+        }
+        if ($allProhibited) {
+            return new Zend_Search_Lucene_Search_Query_Insignificant();
+        }
+
+
         // Check for empty subqueries
         foreach ($subqueries as $id => $subquery) {
             if ($subquery instanceof Zend_Search_Lucene_Search_Query_Empty) {
@@ -180,6 +206,10 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
             }
         }
 
+        // Check, if reduced subqueries list is empty
+        if (count($subqueries) == 0) {
+            return new Zend_Search_Lucene_Search_Query_Empty();
+        }
 
         // Check if all non-empty subqueries are prohibited
         $allProhibited = true;
@@ -210,12 +240,6 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
         }
 
 
-        // Check, if reduced subqueries list is empty
-        if (count($subqueries) == 0) {
-            return new Zend_Search_Lucene_Search_Query_Empty();
-        }
-
-
         // Prepare first candidate for optimized query
         $optimizedQuery = new Zend_Search_Lucene_Search_Query_Boolean($subqueries, $signs);
         $optimizedQuery->setBoost($this->getBoost());
@@ -456,11 +480,35 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
             $this->_resVector = array();
         }
 
-        foreach ($this->_subqueries as $subquery) {
+        $resVectors      = array();
+        $resVectorsSizes = array();
+        $resVectorsIds   = array(); // is used to prevent arrays comparison
+        foreach ($this->_subqueries as $subqueryId => $subquery) {
+            $resVectors[]      = $subquery->matchedDocs();
+            $resVectorsSizes[] = count(end($resVectors));
+            $resVectorsIds[]   = $subqueryId;
+        }
+        // sort resvectors in order of subquery cardinality increasing
+        array_multisort($resVectorsSizes, SORT_ASC, SORT_NUMERIC,
+                        $resVectorsIds,   SORT_ASC, SORT_NUMERIC,
+                        $resVectors);
+        
+        foreach ($resVectors as $nextResVector) {
             if($this->_resVector === null) {
-                $this->_resVector = $subquery->matchedDocs();
+                $this->_resVector = $nextResVector;
             } else {
-                $this->_resVector = array_intersect_key($this->_resVector, $subquery->matchedDocs());
+                //$this->_resVector = array_intersect_key($this->_resVector, $nextResVector);
+                
+                /**
+                 * This code is used as workaround for array_intersect_key() slowness problem.
+                 */
+                $updatedVector = array();
+                foreach ($this->_resVector as $id => $value) {
+                    if (isset($nextResVector[$id])) {
+                        $updatedVector[$id] = $value;
+                    }
+                }
+                $this->_resVector = $updatedVector;
             }
 
             if (count($this->_resVector) == 0) {
@@ -469,7 +517,8 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
             }
         }
 
-        ksort($this->_resVector, SORT_NUMERIC);
+        // ksort($this->_resVector, SORT_NUMERIC);
+        // Used algorithm doesn't change elements order
     }
 
 
@@ -479,30 +528,61 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
      */
     private function _calculateNonConjunctionResult()
     {
-        $required   = null;
-        $optional   = array();
+        $requiredVectors      = array();
+        $requiredVectorsSizes = array();
+        $requiredVectorsIds   = array(); // is used to prevent arrays comparison
 
-        foreach ($this->_subqueries as $subqueryId => $subquery) {
-            $docs = $subquery->matchedDocs();
+        $optional = array();
 
+        foreach ($this->_subqueries as $subqueryId => $subquery) {
             if ($this->_signs[$subqueryId] === true) {
                 // required
-                if ($required !== null) {
-                    // array intersection
-                    $required = array_intersect_key($required, $docs);
-                } else {
-                    $required = $docs;
-                }
+                $requiredVectors[]      = $subquery->matchedDocs();
+                $requiredVectorsSizes[] = count(end($requiredVectors));
+                $requiredVectorsIds[]   = $subqueryId;
             } elseif ($this->_signs[$subqueryId] === false) {
                 // prohibited
                 // Do nothing. matchedDocs() may include non-matching id's
+                // Calculating prohibited vector may take significant time, but do not affect the result
+                // Skipped.  
             } else {
                 // neither required, nor prohibited
                 // array union
-                $optional += $docs;
+                $optional += $subquery->matchedDocs();
             }
         }
 
+        // sort resvectors in order of subquery cardinality increasing
+        array_multisort($requiredVectorsSizes, SORT_ASC, SORT_NUMERIC,
+                        $requiredVectorsIds,   SORT_ASC, SORT_NUMERIC,
+                        $requiredVectors);
+        
+        $required = null;
+        foreach ($requiredVectors as $nextResVector) {
+            if($required === null) {
+                $required = $nextResVector;
+            } else {
+                //$required = array_intersect_key($required, $nextResVector);
+                
+                /**
+                 * This code is used as workaround for array_intersect_key() slowness problem.
+                 */
+                $updatedVector = array();
+                foreach ($required as $id => $value) {
+                    if (isset($nextResVector[$id])) {
+                        $updatedVector[$id] = $value;
+                    }
+                }
+                $required = $updatedVector;
+            }
+
+            if (count($required) == 0) {
+                // Empty result set, we don't need to check other terms
+                break;
+            }
+        }
+                
+        
         if ($required !== null) {
             $this->_resVector = &$required;
         } else {
@@ -705,7 +785,7 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
             $query .= '(' . $subquery->__toString() . ')';
 
             if ($subquery->getBoost() != 1) {
-                $query .= '^' . $subquery->getBoost();
+                $query .= '^' . round($subquery->getBoost(), 4);
             }
         }
 
index 738e33232fdb24dacf1dbf1fdd05e9cd09b125e1..2b67d1bfb25324286e486213f933372724371175 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Search_Query */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/Query.php';
+require_once 'Zend/Search/Lucene/Search/Query.php';
 
 /** Zend_Search_Lucene_Search_Weight_Empty */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/Weight/Empty.php';
+require_once 'Zend/Search/Lucene/Search/Weight/Empty.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Search_Query_Empty extends Zend_Search_Lucene_Search_Query
diff --git a/search/Zend/Search/Lucene/Search/Query/Fuzzy.php b/search/Zend/Search/Lucene/Search/Query/Fuzzy.php
new file mode 100644 (file)
index 0000000..5171d19
--- /dev/null
@@ -0,0 +1,390 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Search_Lucene
+ * @subpackage Search
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+
+/** Zend_Search_Lucene_Search_Query */
+require_once 'Zend/Search/Lucene/Search/Query.php';
+
+/** Zend_Search_Lucene_Search_Query_MultiTerm */
+require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Search_Lucene
+ * @subpackage Search
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Query
+{
+       /** Default minimum similarity */
+       const DEFAULT_MIN_SIMILARITY = 0.5;
+       
+       /**
+        * Maximum number of matched terms.
+        * Apache Lucene defines this limitation as boolean query maximum number of clauses:
+        * org.apache.lucene.search.BooleanQuery.getMaxClauseCount()
+        */
+       const MAX_CLAUSE_COUNT = 1024;
+       
+       /**
+        * Array of precalculated max distances
+        * 
+        * keys are integers representing a word size
+        */
+       private $_maxDistances = array();
+
+    /**
+     * Base searching term.
+     *
+     * @var Zend_Search_Lucene_Index_Term
+     */
+    private $_term;
+    
+    /**
+     * A value between 0 and 1 to set the required similarity
+     *  between the query term and the matching terms. For example, for a
+     *  _minimumSimilarity of 0.5 a term of the same length
+     *  as the query term is considered similar to the query term if the edit distance
+     *  between both terms is less than length(term)*0.5
+     * 
+     * @var float
+     */
+    private $_minimumSimilarity;
+
+    /**
+     * The length of common (non-fuzzy) prefix
+     * 
+     * @var integer
+     */
+    private $_prefixLength;
+    
+    /**
+     * Matched terms.
+     *
+     * Matched terms list.
+     * It's filled during the search (rewrite operation) and may be used for search result
+     * post-processing
+     *
+     * Array of Zend_Search_Lucene_Index_Term objects
+     *
+     * @var array
+     */
+    private $_matches = null;
+    
+    /**
+     * Matched terms scores
+     * 
+     * @var array
+     */
+    private $_scores = null;
+
+    /**
+     * Array of the term keys.
+     * Used to sort terms in alphabetical order if terms have the same socres
+     * 
+     * @var array
+     */
+    private $_termKeys = null;
+    
+    /**
+     * Zend_Search_Lucene_Search_Query_Wildcard constructor.
+     *
+     * @param Zend_Search_Lucene_Index_Term $pattern
+     * @throws Zend_Search_Lucene_Exception
+     */
+    public function __construct(Zend_Search_Lucene_Index_Term $term, $minimumSimilarity = self::DEFAULT_MIN_SIMILARITY, $prefixLength = 0)
+    {
+        if ($minimumSimilarity < 0) {
+            throw new Zend_Search_Lucene_Exception('minimumSimilarity cannot be less than 0');
+        }
+       if ($minimumSimilarity >= 1) {
+               throw new Zend_Search_Lucene_Exception('minimumSimilarity cannot be greater than or equal to 1');
+       }
+        if ($prefixLength < 0) {
+            throw new Zend_Search_Lucene_Exception('prefixLength cannot be less than 0');
+        }
+        
+       $this->_term              = $term;
+        $this->_minimumSimilarity = $minimumSimilarity;
+        $this->_prefixLength      = $prefixLength;
+    }
+
+    /**
+     * Calculate maximum distance for specified word length
+     *
+     * @param integer $prefixLength
+     * @param integer $termLength
+     * @param integer $length
+     * @return integer
+     */
+    private function _calculateMaxDistance($prefixLength, $termLength, $length)
+    {
+       $this->_maxDistances[$length] = (int) ((1 - $this->_minimumSimilarity)*(min($termLength, $length) + $prefixLength)); 
+       return $this->_maxDistances[$length];
+    }
+
+    /**
+     * Re-write query into primitive queries in the context of specified index
+     *
+     * @param Zend_Search_Lucene_Interface $index
+     * @return Zend_Search_Lucene_Search_Query
+     */
+    public function rewrite(Zend_Search_Lucene_Interface $index)
+    {
+        $this->_matches  = array();
+        $this->_scores   = array();
+        $this->_termKeys = array();
+
+        if ($this->_term->field === null) {
+            // Search through all fields
+            $fields = $index->getFieldNames(true /* indexed fields list */);
+        } else {
+            $fields = array($this->_term->field);
+        }
+
+        $prefix           = Zend_Search_Lucene_Index_Term::getPrefix($this->_term->text, $this->_prefixLength);
+        $prefixByteLength = strlen($prefix);
+        $prefixUtf8Length = Zend_Search_Lucene_Index_Term::getLength($prefix);
+        
+        $termLength       = Zend_Search_Lucene_Index_Term::getLength($this->_term->text);
+        
+        $termRest         = substr($this->_term->text, $prefixByteLength);
+        // we calculate length of the rest in bytes since levenshtein() is not UTF-8 compatible
+        $termRestLength   = strlen($termRest);
+
+        $scaleFactor = 1/(1 - $this->_minimumSimilarity);
+
+        foreach ($fields as $field) {
+            $index->resetTermsStream();
+
+            if ($prefix != '') {
+                $index->skipTo(new Zend_Search_Lucene_Index_Term($prefix, $field));
+
+                while ($index->currentTerm() !== null          &&
+                       $index->currentTerm()->field == $field  &&
+                       substr($index->currentTerm()->text, 0, $prefixByteLength) == $prefix) {
+                    // Calculate similarity
+                    $target = substr($index->currentTerm()->text, $prefixByteLength);
+
+                    $maxDistance = isset($this->_maxDistances[strlen($target)])?
+                                       $this->_maxDistances[strlen($target)] :
+                                       $this->_calculateMaxDistance($prefixUtf8Length, $termRestLength, strlen($target));
+
+                    if ($termRestLength == 0) {
+                       // we don't have anything to compare.  That means if we just add
+                        // the letters for current term we get the new word
+                       $similarity = (($prefixUtf8Length == 0)? 0 : 1 - strlen($target)/$prefixUtf8Length);
+                    } else if (strlen($target) == 0) {
+                       $similarity = (($prefixUtf8Length == 0)? 0 : 1 - $termRestLength/$prefixUtf8Length);
+                    } else if ($maxDistance < abs($termRestLength - strlen($target))){
+                       //just adding the characters of term to target or vice-versa results in too many edits
+                       //for example "pre" length is 3 and "prefixes" length is 8.  We can see that
+                       //given this optimal circumstance, the edit distance cannot be less than 5.
+                       //which is 8-3 or more precisesly abs(3-8).
+                       //if our maximum edit distance is 4, then we can discard this word
+                       //without looking at it.
+                       $similarity = 0;
+                    } else {
+                        $similarity = 1 - levenshtein($termRest, $target)/($prefixUtf8Length + min($termRestLength, strlen($target)));
+                    }
+                    
+                    if ($similarity > $this->_minimumSimilarity) {
+                        $this->_matches[]  = $index->currentTerm();
+                        $this->_termKeys[] = $index->currentTerm()->key();
+                        $this->_scores[]   = ($similarity - $this->_minimumSimilarity)*$scaleFactor;
+                    }
+
+                    $index->nextTerm();
+                }
+            } else {
+                $index->skipTo(new Zend_Search_Lucene_Index_Term('', $field));
+
+                while ($index->currentTerm() !== null  &&  $index->currentTerm()->field == $field) {
+                    // Calculate similarity
+                    $target = $index->currentTerm()->text;
+
+                    $maxDistance = isset($this->_maxDistances[strlen($target)])?
+                                       $this->_maxDistances[strlen($target)] :
+                                       $this->_calculateMaxDistance(0, $termRestLength, strlen($target));
+
+                    if ($maxDistance < abs($termRestLength - strlen($target))){
+                        //just adding the characters of term to target or vice-versa results in too many edits
+                        //for example "pre" length is 3 and "prefixes" length is 8.  We can see that
+                        //given this optimal circumstance, the edit distance cannot be less than 5.
+                        //which is 8-3 or more precisesly abs(3-8).
+                        //if our maximum edit distance is 4, then we can discard this word
+                        //without looking at it.
+                        $similarity = 0;
+                    } else {
+                        $similarity = 1 - levenshtein($termRest, $target)/min($termRestLength, strlen($target));
+                    }
+                    
+                    if ($similarity > $this->_minimumSimilarity) {
+                        $this->_matches[]  = $index->currentTerm();
+                        $this->_termKeys[] = $index->currentTerm()->key();
+                        $this->_scores[]   = ($similarity - $this->_minimumSimilarity)*$scaleFactor;
+                    }
+
+                    $index->nextTerm();
+                }
+            }
+
+            $index->closeTermsStream();
+        }
+
+        if (count($this->_matches) == 0) {
+            return new Zend_Search_Lucene_Search_Query_Empty();
+        } else if (count($this->_matches) == 1) {
+            return new Zend_Search_Lucene_Search_Query_Term(reset($this->_matches));
+        } else {
+            $rewrittenQuery = new Zend_Search_Lucene_Search_Query_Boolean();
+            
+            array_multisort($this->_scores,   SORT_DESC, SORT_NUMERIC,
+                            $this->_termKeys, SORT_ASC,  SORT_STRING,
+                            $this->_matches);
+
+            $termCount = 0;
+            foreach ($this->_matches as $id => $matchedTerm) {
+               $subquery = new Zend_Search_Lucene_Search_Query_Term($matchedTerm);
+               $subquery->setBoost($this->_scores[$id]);
+               
+                $rewrittenQuery->addSubquery($subquery);
+                
+                $termCount++;
+                if ($termCount >= self::MAX_CLAUSE_COUNT) {
+                       break;
+                }
+            }
+
+            return $rewrittenQuery;
+        }
+    }
+
+    /**
+     * Optimize query in the context of specified index
+     *
+     * @param Zend_Search_Lucene_Interface $index
+     * @return Zend_Search_Lucene_Search_Query
+     */
+    public function optimize(Zend_Search_Lucene_Interface $index)
+    {
+        throw new Zend_Search_Lucene_Exception('Wildcard query should not be directly used for search. Use $query->rewrite($index)');
+    }
+
+    /**
+     * Return query terms
+     *
+     * @return array
+     * @throws Zend_Search_Lucene_Exception
+     */
+    public function getQueryTerms()
+    {
+        if ($this->_matches === null) {
+            throw new Zend_Search_Lucene_Exception('Search has to be performed first to get matched terms');
+        }
+
+        return $this->_matches;
+    }
+
+    /**
+     * Constructs an appropriate Weight implementation for this query.
+     *
+     * @param Zend_Search_Lucene_Interface $reader
+     * @return Zend_Search_Lucene_Search_Weight
+     * @throws Zend_Search_Lucene_Exception
+     */
+    public function createWeight(Zend_Search_Lucene_Interface $reader)
+    {
+        throw new Zend_Search_Lucene_Exception('Wildcard query should not be directly used for search. Use $query->rewrite($index)');
+    }
+
+
+    /**
+     * Execute query in context of index reader
+     * It also initializes necessary internal structures
+     *
+     * @param Zend_Search_Lucene_Interface $reader
+     * @throws Zend_Search_Lucene_Exception
+     */
+    public function execute(Zend_Search_Lucene_Interface $reader)
+    {
+        throw new Zend_Search_Lucene_Exception('Wildcard query should not be directly used for search. Use $query->rewrite($index)');
+    }
+
+    /**
+     * Get document ids likely matching the query
+     *
+     * It's an array with document ids as keys (performance considerations)
+     *
+     * @return array
+     * @throws Zend_Search_Lucene_Exception
+     */
+    public function matchedDocs()
+    {
+        throw new Zend_Search_Lucene_Exception('Wildcard query should not be directly used for search. Use $query->rewrite($index)');
+    }
+
+    /**
+     * Score specified document
+     *
+     * @param integer $docId
+     * @param Zend_Search_Lucene_Interface $reader
+     * @return float
+     * @throws Zend_Search_Lucene_Exception
+     */
+    public function score($docId, Zend_Search_Lucene_Interface $reader)
+    {
+        throw new Zend_Search_Lucene_Exception('Wildcard query should not be directly used for search. Use $query->rewrite($index)');
+    }
+
+    /**
+     * Highlight query terms
+     *
+     * @param integer &$colorIndex
+     * @param Zend_Search_Lucene_Document_Html $doc
+     */
+    public function highlightMatchesDOM(Zend_Search_Lucene_Document_Html $doc, &$colorIndex)
+    {
+        $words = array();
+
+        foreach ($this->_matches as $term) {
+            $words[] = $term->text;
+        }
+
+        $doc->highlight($words, $this->_getHighlightColor($colorIndex));
+    }
+
+    /**
+     * Print a query
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        // It's used only for query visualisation, so we don't care about characters escaping
+        return (($this->_term->field === null)? '' : $this->_term->field . ':')
+             . $this->_term->text . '~'
+             . (($this->_minimumSimilarity != self::DEFAULT_MIN_SIMILARITY)? round($this->_minimumSimilarity, 4) : '');
+    }
+}
+
diff --git a/search/Zend/Search/Lucene/Search/Query/Insignificant.php b/search/Zend/Search/Lucene/Search/Query/Insignificant.php
new file mode 100644 (file)
index 0000000..b61955d
--- /dev/null
@@ -0,0 +1,140 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Search_Lucene
+ * @subpackage Search
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+
+/** Zend_Search_Lucene_Search_Query */
+require_once 'Zend/Search/Lucene/Search/Query.php';
+
+/** Zend_Search_Lucene_Search_Weight_Empty */
+require_once 'Zend/Search/Lucene/Search/Weight/Empty.php';
+
+
+/**
+ * The insignificant query returns empty result, but doesn't limit result set as a part of other queries
+ *
+ * @category   Zend
+ * @package    Zend_Search_Lucene
+ * @subpackage Search
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Search_Lucene_Search_Query_Insignificant extends Zend_Search_Lucene_Search_Query
+{
+    /**
+     * Re-write query into primitive queries in the context of specified index
+     *
+     * @param Zend_Search_Lucene_Interface $index
+     * @return Zend_Search_Lucene_Search_Query
+     */
+    public function rewrite(Zend_Search_Lucene_Interface $index)
+    {
+        return $this;
+    }
+
+    /**
+     * Optimize query in the context of specified index
+     *
+     * @param Zend_Search_Lucene_Interface $index
+     * @return Zend_Search_Lucene_Search_Query
+     */
+    public function optimize(Zend_Search_Lucene_Interface $index)
+    {
+        return $this;
+    }
+
+    /**
+     * Constructs an appropriate Weight implementation for this query.
+     *
+     * @param Zend_Search_Lucene_Interface $reader
+     * @return Zend_Search_Lucene_Search_Weight
+     */
+    public function createWeight(Zend_Search_Lucene_Interface $reader)
+    {
+        return new Zend_Search_Lucene_Search_Weight_Empty();
+    }
+
+    /**
+     * Execute query in context of index reader
+     * It also initializes necessary internal structures
+     *
+     * @param Zend_Search_Lucene_Interface $reader
+     */
+    public function execute(Zend_Search_Lucene_Interface $reader)
+    {
+        // Do nothing
+    }
+
+    /**
+     * Get document ids likely matching the query
+     *
+     * It's an array with document ids as keys (performance considerations)
+     *
+     * @return array
+     */
+    public function matchedDocs()
+    {
+        return array();
+    }
+
+    /**
+     * Score specified document
+     *
+     * @param integer $docId
+     * @param Zend_Search_Lucene_Interface $reader
+     * @return float
+     */
+    public function score($docId, Zend_Search_Lucene_Interface $reader)
+    {
+        return 0;
+    }
+
+    /**
+     * Return query terms
+     *
+     * @return array
+     */
+    public function getQueryTerms()
+    {
+        return array();
+    }
+
+    /**
+     * Highlight query terms
+     *
+     * @param integer &$colorIndex
+     * @param Zend_Search_Lucene_Document_Html $doc
+     */
+    public function highlightMatchesDOM(Zend_Search_Lucene_Document_Html $doc, &$colorIndex)
+    {
+        // Do nothing
+    }
+
+    /**
+     * Print a query
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return '<InsignificantQuery>';
+    }
+}
+
index 9258279a0037bfeaf16fde5156cf0b9330e549e5..e3f79acedd1f5801fa3e05269855292294296415 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Search_Query */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/Query.php';
+require_once 'Zend/Search/Lucene/Search/Query.php';
 
 /** Zend_Search_Lucene_Search_Weight_MultiTerm */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/Weight/MultiTerm.php';
+require_once 'Zend/Search/Lucene/Search/Weight/MultiTerm.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Search_Query
@@ -103,7 +103,6 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
      *
      * @param array $terms    Array of Zend_Search_Lucene_Index_Term objects
      * @param array $signs    Array of signs.  Sign is boolean|null.
-     * @return void
      */
     public function __construct($terms = null, $signs = null)
     {
@@ -139,6 +138,7 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
     public function addTerm(Zend_Search_Lucene_Index_Term $term, $sign = null) {
         if ($sign !== true || $this->_signs !== null) {       // Skip, if all terms are required
             if ($this->_signs === null) {                     // Check, If all previous terms are required
+                $this->_signs = array();
                 foreach ($this->_terms as $prevTerm) {
                     $this->_signs[] = true;
                 }
@@ -316,22 +316,47 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
             $this->_resVector = array();
         }
 
-        foreach( $this->_terms as $termId=>$term ) {
+        $resVectors      = array();
+        $resVectorsSizes = array();
+        $resVectorsIds   = array(); // is used to prevent arrays comparison
+        foreach ($this->_terms as $termId => $term) {
+            $resVectors[]      = array_flip($reader->termDocs($term));
+            $resVectorsSizes[] = count(end($resVectors));
+            $resVectorsIds[]   = $termId;
+
+            $this->_termsFreqs[$termId] = $reader->termFreqs($term);
+        }
+        // sort resvectors in order of subquery cardinality increasing
+        array_multisort($resVectorsSizes, SORT_ASC, SORT_NUMERIC,
+                        $resVectorsIds,   SORT_ASC, SORT_NUMERIC,
+                        $resVectors);
+
+        foreach ($resVectors as $nextResVector) {
             if($this->_resVector === null) {
-                $this->_resVector = array_flip($reader->termDocs($term));
+                $this->_resVector = $nextResVector;
             } else {
-                $this->_resVector = array_intersect_key($this->_resVector, array_flip($reader->termDocs($term)));
+                //$this->_resVector = array_intersect_key($this->_resVector, $nextResVector);
+                
+                /**
+                 * This code is used as workaround for array_intersect_key() slowness problem.
+                 */
+                $updatedVector = array();
+                foreach ($this->_resVector as $id => $value) {
+                    if (isset($nextResVector[$id])) {
+                        $updatedVector[$id] = $value;
+                    }
+                }
+                $this->_resVector = $updatedVector;
             }
 
             if (count($this->_resVector) == 0) {
                 // Empty result set, we don't need to check other terms
                 break;
             }
-
-            $this->_termsFreqs[$termId] = $reader->termFreqs($term);
         }
 
-        ksort($this->_resVector, SORT_NUMERIC);
+        // ksort($this->_resVector, SORT_NUMERIC);
+        // Docs are returned ordered. Used algorithm doesn't change elements order.
     }
 
 
@@ -343,21 +368,21 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
      */
     private function _calculateNonConjunctionResult(Zend_Search_Lucene_Interface $reader)
     {
-        $required   = null;
+        $requiredVectors      = array();
+        $requiredVectorsSizes = array();
+        $requiredVectorsIds   = array(); // is used to prevent arrays comparison
+        
         $optional   = array();
         $prohibited = array();
-
+        
         foreach ($this->_terms as $termId => $term) {
             $termDocs = array_flip($reader->termDocs($term));
 
             if ($this->_signs[$termId] === true) {
                 // required
-                if ($required !== null) {
-                    // array intersection
-                    $required = array_intersect_key($required, $termDocs);
-                } else {
-                    $required = $termDocs;
-                }
+                $requiredVectors[]      = $termDocs;
+                $requiredVectorsSizes[] = count($termDocs);
+                $requiredVectorsIds[]   = $termId;
             } elseif ($this->_signs[$termId] === false) {
                 // prohibited
                 // array union
@@ -371,16 +396,65 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
             $this->_termsFreqs[$termId] = $reader->termFreqs($term);
         }
 
+        // sort resvectors in order of subquery cardinality increasing
+        array_multisort($requiredVectorsSizes, SORT_ASC, SORT_NUMERIC,
+                        $requiredVectorsIds,   SORT_ASC, SORT_NUMERIC,
+                        $requiredVectors);
+        
+        $required = null;
+        foreach ($requiredVectors as $nextResVector) {
+            if($required === null) {
+                $required = $nextResVector;
+            } else {
+                //$required = array_intersect_key($required, $nextResVector);
+                
+                /**
+                 * This code is used as workaround for array_intersect_key() slowness problem.
+                 */
+                $updatedVector = array();
+                foreach ($required as $id => $value) {
+                    if (isset($nextResVector[$id])) {
+                        $updatedVector[$id] = $value;
+                    }
+                }
+                $required = $updatedVector;
+            }
+
+            if (count($required) == 0) {
+                // Empty result set, we don't need to check other terms
+                break;
+            }
+        }
+                
         if ($required !== null) {
-            $this->_resVector = (count($prohibited) > 0) ?
-                                           array_diff_key($required, $prohibited) :
-                                           $required;
+            $this->_resVector = $required;
         } else {
-            $this->_resVector = (count($prohibited) > 0) ?
-                                           array_diff_key($optional, $prohibited) :
-                                           $optional;
+            $this->_resVector = $optional;
         }
 
+        if (count($prohibited) != 0) {
+            // $this->_resVector = array_diff_key($this->_resVector, $prohibited);
+            
+            /**
+             * This code is used as workaround for array_diff_key() slowness problem.
+             */
+            if (count($this->_resVector) < count($prohibited)) {
+                $updatedVector = $this->_resVector;
+                foreach ($this->_resVector as $id => $value) {
+                    if (isset($prohibited[$id])) {
+                        unset($updatedVector[$id]);
+                    }
+                }
+                $this->_resVector = $updatedVector;
+            } else {
+                $updatedVector = $this->_resVector;
+                foreach ($prohibited as $id => $value) {
+                    unset($updatedVector[$id]);
+                }
+                $this->_resVector = $updatedVector;
+            }
+        }
+        
         ksort($this->_resVector, SORT_NUMERIC);
     }
 
index 3e7b782792f35bc7ac2cfc4bc34307070136fdb0..d275fe37f1f5253d1fd460aeff24b6f441439c3a 100644 (file)
@@ -15,7 +15,7 @@
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 /**
  * Zend_Search_Lucene_Search_Query
  */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/Query.php';
+require_once 'Zend/Search/Lucene/Search/Query.php';
 
 /**
  * Zend_Search_Lucene_Search_Weight_MultiTerm
  */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/Weight/Phrase.php';
+require_once 'Zend/Search/Lucene/Search/Weight/Phrase.php';
 
 
 /**
@@ -37,7 +37,7 @@ require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/Weight/Phrase.php'
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Query
@@ -416,23 +416,48 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
             $this->_resVector = array();
         }
 
-        foreach( $this->_terms as $termId=>$term ) {
+        $resVectors      = array();
+        $resVectorsSizes = array();
+        $resVectorsIds   = array(); // is used to prevent arrays comparison
+        foreach ($this->_terms as $termId => $term) {
+            $resVectors[]      = array_flip($reader->termDocs($term));
+            $resVectorsSizes[] = count(end($resVectors));
+            $resVectorsIds[]   = $termId;
+            
+            $this->_termsPositions[$termId] = $reader->termPositions($term);
+        }
+        // sort resvectors in order of subquery cardinality increasing
+        array_multisort($resVectorsSizes, SORT_ASC, SORT_NUMERIC,
+                        $resVectorsIds,   SORT_ASC, SORT_NUMERIC,
+                        $resVectors);
+        
+        foreach ($resVectors as $nextResVector) {
             if($this->_resVector === null) {
-                $this->_resVector = array_flip($reader->termDocs($term));
+                $this->_resVector = $nextResVector;
             } else {
-                $this->_resVector = array_intersect_key($this->_resVector, array_flip($reader->termDocs($term)));
+                //$this->_resVector = array_intersect_key($this->_resVector, $nextResVector);
+                
+                /**
+                 * This code is used as workaround for array_intersect_key() slowness problem.
+                 */
+                $updatedVector = array();
+                foreach ($this->_resVector as $id => $value) {
+                    if (isset($nextResVector[$id])) {
+                        $updatedVector[$id] = $value;
+                    }
+                }
+                $this->_resVector = $updatedVector;
             }
 
             if (count($this->_resVector) == 0) {
                 // Empty result set, we don't need to check other terms
                 break;
             }
-
-            $this->_termsPositions[$termId] = $reader->termPositions($term);
         }
 
-        ksort($this->_resVector, SORT_NUMERIC);
-
+        // ksort($this->_resVector, SORT_NUMERIC);
+        // Docs are returned ordered. Used algorithm doesn't change elements order.
+                        
         // Initialize weight if it's not done yet
         $this->_initWeight($reader);
     }
diff --git a/search/Zend/Search/Lucene/Search/Query/Range.php b/search/Zend/Search/Lucene/Search/Query/Range.php
new file mode 100644 (file)
index 0000000..4e8c638
--- /dev/null
@@ -0,0 +1,331 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Search_Lucene
+ * @subpackage Search
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+
+/** Zend_Search_Lucene_Search_Query */
+require_once 'Zend/Search/Lucene/Search/Query.php';
+
+/** Zend_Search_Lucene_Search_Query_MultiTerm */
+require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Search_Lucene
+ * @subpackage Search
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Search_Lucene_Search_Query_Range extends Zend_Search_Lucene_Search_Query
+{
+    /**
+     * Lower term.
+     *
+     * @var Zend_Search_Lucene_Index_Term
+     */
+    private $_lowerTerm;
+
+    /**
+     * Upper term.
+     *
+     * @var Zend_Search_Lucene_Index_Term
+     */
+    private $_upperTerm;
+
+
+    /**
+     * Search field
+     *
+     * @var string
+     */
+    private $_field;
+
+    /**
+     * Inclusive
+     *
+     * @var boolean
+     */
+    private $_inclusive;
+
+    /**
+     * Matched terms.
+     *
+     * Matched terms list.
+     * It's filled during the search (rewrite operation) and may be used for search result
+     * post-processing
+     *
+     * Array of Zend_Search_Lucene_Index_Term objects
+     *
+     * @var array
+     */
+    private $_matches;
+
+
+    /**
+     * Zend_Search_Lucene_Search_Query_Range constructor.
+     *
+     * @param Zend_Search_Lucene_Index_Term|null $lowerTerm
+     * @param Zend_Search_Lucene_Index_Term|null $upperTerm
+     * @param boolean $inclusive
+     * @throws Zend_Search_Lucene_Exception
+     */
+    public function __construct($lowerTerm, $upperTerm, $inclusive)
+    {
+        if ($lowerTerm === null  &&  $upperTerm === null) {
+            throw new Zend_Search_Lucene_Exception('At least one term must be non-null');
+        }
+        if ($lowerTerm !== null  &&  $upperTerm !== null  &&  $lowerTerm->field != $upperTerm->field) {
+            throw new Zend_Search_Lucene_Exception('Both terms must be for the same field');
+        }
+
+        $this->_field     = ($lowerTerm !== null)? $lowerTerm->field : $upperTerm->field;
+        $this->_lowerTerm = $lowerTerm;
+        $this->_upperTerm = $upperTerm;
+        $this->_inclusive = $inclusive;
+    }
+
+    /**
+     * Get query field name
+     *
+     * @return string|null
+     */
+    public function getField()
+    {
+        return $this->_field;
+    }
+
+    /**
+     * Get lower term
+     *
+     * @return Zend_Search_Lucene_Index_Term|null
+     */
+    public function getLowerTerm()
+    {
+        return $this->_lowerTerm;
+    }
+
+    /**
+     * Get upper term
+     *
+     * @return Zend_Search_Lucene_Index_Term|null
+     */
+    public function getUpperTerm()
+    {
+        return $this->_upperTerm;
+    }
+
+    /**
+     * Get upper term
+     *
+     * @return boolean
+     */
+    public function isInclusive()
+    {
+        return $this->_inclusive;
+    }
+
+    /**
+     * Re-write query into primitive queries in the context of specified index
+     *
+     * @param Zend_Search_Lucene_Interface $index
+     * @return Zend_Search_Lucene_Search_Query
+     */
+    public function rewrite(Zend_Search_Lucene_Interface $index)
+    {
+        $this->_matches = array();
+
+        if ($this->_field === null) {
+            // Search through all fields
+            $fields = $index->getFieldNames(true /* indexed fields list */);
+        } else {
+            $fields = array($this->_field);
+        }
+
+        foreach ($fields as $field) {
+            $index->resetTermsStream();
+
+            if ($this->_lowerTerm !== null) {
+                $lowerTerm = new Zend_Search_Lucene_Index_Term($this->_lowerTerm->text, $field);
+
+                $index->skipTo($lowerTerm);
+
+                if (!$this->_inclusive  &&
+                    $index->currentTerm() == $lowerTerm) {
+                    // Skip lower term
+                    $index->nextTerm();
+                }
+            } else {
+                $index->skipTo(new Zend_Search_Lucene_Index_Term('', $field));
+            }
+
+
+            if ($this->_upperTerm !== null) {
+                // Walk up to the upper term
+                $upperTerm = new Zend_Search_Lucene_Index_Term($this->_upperTerm->text, $field);
+
+                while ($index->currentTerm() !== null          &&
+                       $index->currentTerm()->field == $field  &&
+                       $index->currentTerm()->text  <  $upperTerm->text) {
+                    $this->_matches[] = $index->currentTerm();
+                    $index->nextTerm();
+                }
+
+                if ($this->_inclusive  &&  $index->currentTerm() == $upperTerm) {
+                    // Include upper term into result
+                    $this->_matches[] = $upperTerm;
+                }
+            } else {
+                // Walk up to the end of field data
+                while ($index->currentTerm() !== null  &&  $index->currentTerm()->field == $field) {
+                    $this->_matches[] = $index->currentTerm();
+                    $index->nextTerm();
+                }
+            }
+
+            $index->closeTermsStream();
+        }
+
+        if (count($this->_matches) == 0) {
+            return new Zend_Search_Lucene_Search_Query_Empty();
+        } else if (count($this->_matches) == 1) {
+            return new Zend_Search_Lucene_Search_Query_Term(reset($this->_matches));
+        } else {
+            $rewrittenQuery = new Zend_Search_Lucene_Search_Query_MultiTerm();
+
+            foreach ($this->_matches as $matchedTerm) {
+                $rewrittenQuery->addTerm($matchedTerm);
+            }
+
+            return $rewrittenQuery;
+        }
+    }
+
+    /**
+     * Optimize query in the context of specified index
+     *
+     * @param Zend_Search_Lucene_Interface $index
+     * @return Zend_Search_Lucene_Search_Query
+     */
+    public function optimize(Zend_Search_Lucene_Interface $index)
+    {
+        throw new Zend_Search_Lucene_Exception('Range query should not be directly used for search. Use $query->rewrite($index)');
+    }
+
+    /**
+     * Return query terms
+     *
+     * @return array
+     * @throws Zend_Search_Lucene_Exception
+     */
+    public function getQueryTerms()
+    {
+        if ($this->_matches === null) {
+            throw new Zend_Search_Lucene_Exception('Search has to be performed first to get matched terms');
+        }
+
+        return $this->_matches;
+    }
+
+    /**
+     * Constructs an appropriate Weight implementation for this query.
+     *
+     * @param Zend_Search_Lucene_Interface $reader
+     * @return Zend_Search_Lucene_Search_Weight
+     * @throws Zend_Search_Lucene_Exception
+     */
+    public function createWeight(Zend_Search_Lucene_Interface $reader)
+    {
+        throw new Zend_Search_Lucene_Exception('Range query should not be directly used for search. Use $query->rewrite($index)');
+    }
+
+
+    /**
+     * Execute query in context of index reader
+     * It also initializes necessary internal structures
+     *
+     * @param Zend_Search_Lucene_Interface $reader
+     * @throws Zend_Search_Lucene_Exception
+     */
+    public function execute(Zend_Search_Lucene_Interface $reader)
+    {
+        throw new Zend_Search_Lucene_Exception('Range query should not be directly used for search. Use $query->rewrite($index)');
+    }
+
+    /**
+     * Get document ids likely matching the query
+     *
+     * It's an array with document ids as keys (performance considerations)
+     *
+     * @return array
+     * @throws Zend_Search_Lucene_Exception
+     */
+    public function matchedDocs()
+    {
+        throw new Zend_Search_Lucene_Exception('Range query should not be directly used for search. Use $query->rewrite($index)');
+    }
+
+    /**
+     * Score specified document
+     *
+     * @param integer $docId
+     * @param Zend_Search_Lucene_Interface $reader
+     * @return float
+     * @throws Zend_Search_Lucene_Exception
+     */
+    public function score($docId, Zend_Search_Lucene_Interface $reader)
+    {
+        throw new Zend_Search_Lucene_Exception('Range query should not be directly used for search. Use $query->rewrite($index)');
+    }
+
+    /**
+     * Highlight query terms
+     *
+     * @param integer &$colorIndex
+     * @param Zend_Search_Lucene_Document_Html $doc
+     */
+    public function highlightMatchesDOM(Zend_Search_Lucene_Document_Html $doc, &$colorIndex)
+    {
+        $words = array();
+
+        foreach ($this->_matches as $term) {
+            $words[] = $term->text;
+        }
+
+        $doc->highlight($words, $this->_getHighlightColor($colorIndex));
+    }
+
+    /**
+     * Print a query
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        // It's used only for query visualisation, so we don't care about characters escaping
+        return (($this->_field === null)? '' : $this->_field . ':')
+             . (($this->_inclusive)? '[' : '{')
+             . (($this->_lowerTerm !== null)?  $this->_lowerTerm->text : 'null')
+             . ' TO '
+             . (($this->_upperTerm !== null)?  $this->_upperTerm->text : 'null')
+             . (($this->_inclusive)? ']' : '}');
+    }
+}
+
diff --git a/search/Zend/Search/Lucene/Search/Query/Wildcard.php b/search/Zend/Search/Lucene/Search/Query/Wildcard.php
new file mode 100644 (file)
index 0000000..5ca692d
--- /dev/null
@@ -0,0 +1,297 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Search_Lucene
+ * @subpackage Search
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+
+/** Zend_Search_Lucene_Search_Query */
+require_once 'Zend/Search/Lucene/Search/Query.php';
+
+/** Zend_Search_Lucene_Search_Query_MultiTerm */
+require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Search_Lucene
+ * @subpackage Search
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Search_Lucene_Search_Query_Wildcard extends Zend_Search_Lucene_Search_Query
+{
+    /**
+     * Search pattern.
+     *
+     * Field has to be fully specified or has to be null
+     * Text may contain '*' or '?' symbols
+     *
+     * @var Zend_Search_Lucene_Index_Term
+     */
+    private $_pattern;
+
+    /**
+     * Matched terms.
+     *
+     * Matched terms list.
+     * It's filled during the search (rewrite operation) and may be used for search result
+     * post-processing
+     *
+     * Array of Zend_Search_Lucene_Index_Term objects
+     *
+     * @var array
+     */
+    private $_matches = null;
+
+    /**
+     * Zend_Search_Lucene_Search_Query_Wildcard constructor.
+     *
+     * @param Zend_Search_Lucene_Index_Term $pattern
+     */
+    public function __construct(Zend_Search_Lucene_Index_Term $pattern)
+    {
+        $this->_pattern = $pattern;
+    }
+
+    /**
+     * Get terms prefix
+     *
+     * @param string $word
+     * @return string
+     */
+    private static function _getPrefix($word)
+    {
+        $questionMarkPosition = strpos($word, '?');
+        $astrericPosition     = strpos($word, '*');
+
+        if ($questionMarkPosition !== false) {
+            if ($astrericPosition !== false) {
+                return substr($word, 0, min($questionMarkPosition, $astrericPosition));
+            }
+
+            return substr($word, 0, $questionMarkPosition);
+        } else if ($astrericPosition !== false) {
+            return substr($word, 0, $astrericPosition);
+        }
+
+        return $word;
+    }
+
+    /**
+     * Re-write query into primitive queries in the context of specified index
+     *
+     * @param Zend_Search_Lucene_Interface $index
+     * @return Zend_Search_Lucene_Search_Query
+     */
+    public function rewrite(Zend_Search_Lucene_Interface $index)
+    {
+        $this->_matches = array();
+
+        if ($this->_pattern->field === null) {
+            // Search through all fields
+            $fields = $index->getFieldNames(true /* indexed fields list */);
+        } else {
+            $fields = array($this->_pattern->field);
+        }
+
+        $prefix          = self::_getPrefix($this->_pattern->text);
+        $prefixLength    = strlen($prefix);
+        $matchExpression = '/^' . str_replace(array('\\?', '\\*'), array('.', '.*') , preg_quote($this->_pattern->text, '/')) . '$/';
+
+        /** @todo check for PCRE unicode support may be performed through Zend_Environment in some future */
+        if (@preg_match('/\pL/u', 'a') == 1) {
+            // PCRE unicode support is turned on
+            // add Unicode modifier to the match expression
+            $matchExpression .= 'u';
+        }
+
+
+        foreach ($fields as $field) {
+            $index->resetTermsStream();
+
+            if ($prefix != '') {
+                $index->skipTo(new Zend_Search_Lucene_Index_Term($prefix, $field));
+
+                while ($index->currentTerm() !== null          &&
+                       $index->currentTerm()->field == $field  &&
+                       substr($index->currentTerm()->text, 0, $prefixLength) == $prefix) {
+                    if (preg_match($matchExpression, $index->currentTerm()->text) === 1) {
+                        $this->_matches[] = $index->currentTerm();
+                    }
+
+                    $index->nextTerm();
+                }
+            } else {
+                $index->skipTo(new Zend_Search_Lucene_Index_Term('', $field));
+
+                while ($index->currentTerm() !== null  &&  $index->currentTerm()->field == $field) {
+                    if (preg_match($matchExpression, $index->currentTerm()->text) === 1) {
+                        $this->_matches[] = $index->currentTerm();
+                    }
+
+                    $index->nextTerm();
+                }
+            }
+
+            $index->closeTermsStream();
+        }
+
+        if (count($this->_matches) == 0) {
+            return new Zend_Search_Lucene_Search_Query_Empty();
+        } else if (count($this->_matches) == 1) {
+            return new Zend_Search_Lucene_Search_Query_Term(reset($this->_matches));
+        } else {
+            $rewrittenQuery = new Zend_Search_Lucene_Search_Query_MultiTerm();
+
+            foreach ($this->_matches as $matchedTerm) {
+                $rewrittenQuery->addTerm($matchedTerm);
+            }
+
+            return $rewrittenQuery;
+        }
+    }
+
+    /**
+     * Optimize query in the context of specified index
+     *
+     * @param Zend_Search_Lucene_Interface $index
+     * @return Zend_Search_Lucene_Search_Query
+     */
+    public function optimize(Zend_Search_Lucene_Interface $index)
+    {
+        throw new Zend_Search_Lucene_Exception('Wildcard query should not be directly used for search. Use $query->rewrite($index)');
+    }
+
+
+    /**
+     * Returns query pattern
+     *
+     * @return Zend_Search_Lucene_Index_Term
+     */
+    public function getPattern()
+    {
+        return $this->_pattern;
+    }
+
+
+    /**
+     * Return query terms
+     *
+     * @return array
+     * @throws Zend_Search_Lucene_Exception
+     */
+    public function getQueryTerms()
+    {
+        if ($this->_matches === null) {
+            throw new Zend_Search_Lucene_Exception('Search has to be performed first to get matched terms');
+        }
+
+        return $this->_matches;
+    }
+
+    /**
+     * Constructs an appropriate Weight implementation for this query.
+     *
+     * @param Zend_Search_Lucene_Interface $reader
+     * @return Zend_Search_Lucene_Search_Weight
+     * @throws Zend_Search_Lucene_Exception
+     */
+    public function createWeight(Zend_Search_Lucene_Interface $reader)
+    {
+        throw new Zend_Search_Lucene_Exception('Wildcard query should not be directly used for search. Use $query->rewrite($index)');
+    }
+
+
+    /**
+     * Execute query in context of index reader
+     * It also initializes necessary internal structures
+     *
+     * @param Zend_Search_Lucene_Interface $reader
+     * @throws Zend_Search_Lucene_Exception
+     */
+    public function execute(Zend_Search_Lucene_Interface $reader)
+    {
+        throw new Zend_Search_Lucene_Exception('Wildcard query should not be directly used for search. Use $query->rewrite($index)');
+    }
+
+    /**
+     * Get document ids likely matching the query
+     *
+     * It's an array with document ids as keys (performance considerations)
+     *
+     * @return array
+     * @throws Zend_Search_Lucene_Exception
+     */
+    public function matchedDocs()
+    {
+        throw new Zend_Search_Lucene_Exception('Wildcard query should not be directly used for search. Use $query->rewrite($index)');
+    }
+
+    /**
+     * Score specified document
+     *
+     * @param integer $docId
+     * @param Zend_Search_Lucene_Interface $reader
+     * @return float
+     * @throws Zend_Search_Lucene_Exception
+     */
+    public function score($docId, Zend_Search_Lucene_Interface $reader)
+    {
+        throw new Zend_Search_Lucene_Exception('Wildcard query should not be directly used for search. Use $query->rewrite($index)');
+    }
+
+    /**
+     * Highlight query terms
+     *
+     * @param integer &$colorIndex
+     * @param Zend_Search_Lucene_Document_Html $doc
+     */
+    public function highlightMatchesDOM(Zend_Search_Lucene_Document_Html $doc, &$colorIndex)
+    {
+        $words = array();
+
+        $matchExpression = '/^' . str_replace(array('\\?', '\\*'), array('.', '.*') , preg_quote($this->_pattern->text, '/')) . '$/';
+        if (@preg_match('/\pL/u', 'a') == 1) {
+            // PCRE unicode support is turned on
+            // add Unicode modifier to the match expression
+            $matchExpression .= 'u';
+        }
+
+        $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($doc->getFieldUtf8Value('body'), 'UTF-8');
+        foreach ($tokens as $token) {
+            if (preg_match($matchExpression, $token->getTermText()) === 1) {
+                $words[] = $token->getTermText();
+            }
+        }
+
+        $doc->highlight($words, $this->_getHighlightColor($colorIndex));
+    }
+
+    /**
+     * Print a query
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        // It's used only for query visualisation, so we don't care about characters escaping
+        return (($this->_pattern->field === null)? '' : $this->_pattern->field . ':') . $this->_pattern->text;
+    }
+}
+
index 53777c8570ff086e8cd42041e8f0b39407b5f64b..b5ea48317e9fa4d4b89d2c7e9f808d3d2e40813d 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Index_Term */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Index/Term.php';
+require_once 'Zend/Search/Lucene/Index/Term.php';
 
 /** Zend_Search_Lucene_Exception */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Exception.php';
+require_once 'Zend/Search/Lucene/Exception.php';
 
 /** Zend_Search_Lucene_Search_QueryEntry_Term */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/QueryEntry/Term.php';
+require_once 'Zend/Search/Lucene/Search/QueryEntry/Term.php';
 
 /** Zend_Search_Lucene_Search_QueryEntry_Phrase */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/QueryEntry/Phrase.php';
+require_once 'Zend/Search/Lucene/Search/QueryEntry/Phrase.php';
 
 /** Zend_Search_Lucene_Search_QueryEntry_Subquery */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/QueryEntry/Subquery.php';
+require_once 'Zend/Search/Lucene/Search/QueryEntry/Subquery.php';
 
 
 /** Zend_Search_Lucene_Search_QueryParserException */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/QueryParserException.php';
+require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 abstract class Zend_Search_Lucene_Search_QueryEntry
index e90a58b4977ea6b3c4da623cb645fdbaf14c5e86..0f0090ab4f459231c1df1d6ae06f9f54b23b4235 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Index_Term */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Index/Term.php';
+require_once 'Zend/Search/Lucene/Index/Term.php';
 
 /** Zend_Search_Lucene_Exception */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Exception.php';
+require_once 'Zend/Search/Lucene/Exception.php';
 
 /** Zend_Search_Lucene_Search_QueryEntry */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/QueryEntry.php';
+require_once 'Zend/Search/Lucene/Search/QueryEntry.php';
 
 /** Zend_Search_Lucene_Search_QueryParserException */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/QueryParserException.php';
+require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
 
 /** Zend_Search_Lucene_Analysis_Analyzer */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Analysis/Analyzer.php';
+require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
 
 
 
@@ -41,7 +41,7 @@ require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Analysis/Analyzer.php';
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Search_QueryEntry_Phrase extends Zend_Search_Lucene_Search_QueryEntry
@@ -118,7 +118,7 @@ class Zend_Search_Lucene_Search_QueryEntry_Phrase extends Zend_Search_Lucene_Sea
         $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_phrase, $encoding);
 
         if (count($tokens) == 0) {
-            return new Zend_Search_Lucene_Search_Query_Empty();
+            return new Zend_Search_Lucene_Search_Query_Insignificant();
         }
 
         if (count($tokens) == 1) {
@@ -130,10 +130,12 @@ class Zend_Search_Lucene_Search_QueryEntry_Phrase extends Zend_Search_Lucene_Sea
         }
 
         //It's not empty or one term query
+        $position = -1;
         $query = new Zend_Search_Lucene_Search_Query_Phrase();
         foreach ($tokens as $token) {
+            $position += $token->getPositionIncrement();
             $term = new Zend_Search_Lucene_Index_Term($token->getTermText(), $this->_field);
-            $query->addTerm($term);
+            $query->addTerm($term, $position);
         }
 
         if ($this->_proximityQuery) {
index 8d6e64fc63d801d7b947163a6f53bc99d7613af7..de15ba81df2debeb7878b2774cef575222cb8987 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Index_Term */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Index/Term.php';
+require_once 'Zend/Search/Lucene/Index/Term.php';
 
 /** Zend_Search_Lucene_Exception */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Exception.php';
+require_once 'Zend/Search/Lucene/Exception.php';
 
 /** Zend_Search_Lucene_Search_QueryEntry */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/QueryEntry.php';
+require_once 'Zend/Search/Lucene/Search/QueryEntry.php';
 
 /** Zend_Search_Lucene_Search_QueryParserException */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/QueryParserException.php';
+require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Search_QueryEntry_Subquery extends Zend_Search_Lucene_Search_QueryEntry
index f9b3d9746eb6241c8b3be2256f6869271a2ad772..9b81e84dcfd13c69c9fd71f21ff43574e8886adf 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Index_Term */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Index/Term.php';
+require_once 'Zend/Search/Lucene/Index/Term.php';
 
 /** Zend_Search_Lucene_Exception */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Exception.php';
+require_once 'Zend/Search/Lucene/Exception.php';
 
 /** Zend_Search_Lucene_Search_QueryEntry */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/QueryEntry.php';
+require_once 'Zend/Search/Lucene/Search/QueryEntry.php';
 
 /** Zend_Search_Lucene_Search_QueryParserException */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/QueryParserException.php';
+require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
 
 /** Zend_Search_Lucene_Analysis_Analyzer */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Analysis/Analyzer.php';
+require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
 
 
 
@@ -41,7 +41,7 @@ require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Analysis/Analyzer.php';
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Search_QueryEntry_Term extends Zend_Search_Lucene_Search_QueryEntry
@@ -100,7 +100,7 @@ class Zend_Search_Lucene_Search_QueryEntry_Term extends Zend_Search_Lucene_Searc
         if ($parameter !== null) {
             $this->_similarity = $parameter;
         } else {
-            $this->_similarity = 0.5;
+            $this->_similarity = Zend_Search_Lucene_Search_Query_Fuzzy::DEFAULT_MIN_SIMILARITY;
         }
     }
 
@@ -113,28 +113,77 @@ class Zend_Search_Lucene_Search_QueryEntry_Term extends Zend_Search_Lucene_Searc
      */
     public function getQuery($encoding)
     {
-        if ($this->_fuzzyQuery) {
-            throw new Zend_Search_Lucene_Search_QueryParserException('Fuzzy search is not supported yet.');
-        }
-
         if (strpos($this->_term, '?') !== false || strpos($this->_term, '*') !== false) {
-            throw new Zend_Search_Lucene_Search_QueryParserException('Wildcard queries are not supported yet.');
+               if ($this->_fuzzyQuery) {
+                   throw new Zend_Search_Lucene_Search_QueryParserException('Fuzzy search is not supported for terms with wildcards.');
+               }
+
+               $pattern = '';
+
+            $subPatterns = explode('*', $this->_term);
+
+            $astericFirstPass = true;
+            foreach ($subPatterns as $subPattern) {
+                if (!$astericFirstPass) {
+                    $pattern .= '*';
+                } else {
+                    $astericFirstPass = false;
+                }
+
+                $subPatternsL2 = explode('?', $subPattern);
+
+                $qMarkFirstPass = true;
+                foreach ($subPatternsL2 as $subPatternL2) {
+                    if (!$qMarkFirstPass) {
+                        $pattern .= '?';
+                    } else {
+                        $qMarkFirstPass = false;
+                    }
+
+                    $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($subPatternL2, $encoding);
+                    if (count($tokens) > 1) {
+                        throw new Zend_Search_Lucene_Search_QueryParserException('Wildcard search is supported only for non-multiple word terms');
+                    }
+
+                    foreach ($tokens as $token) {
+                        $pattern .= $token->getTermText();
+                    }
+                }
+            }
+
+            $term  = new Zend_Search_Lucene_Index_Term($pattern, $this->_field);
+            $query = new Zend_Search_Lucene_Search_Query_Wildcard($term);
+            $query->setBoost($this->_boost);
+
+            return $query;
         }
 
         $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_term, $encoding);
 
         if (count($tokens) == 0) {
-            return new Zend_Search_Lucene_Search_Query_Empty();
+            return new Zend_Search_Lucene_Search_Query_Insignificant();
         }
 
-        if (count($tokens) == 1) {
-            $term  = new Zend_Search_Lucene_Index_Term($tokens[0]->getTermText(), $this->_field);
+        if (count($tokens) == 1  && !$this->_fuzzyQuery) {
+               $term  = new Zend_Search_Lucene_Index_Term($tokens[0]->getTermText(), $this->_field);
             $query = new Zend_Search_Lucene_Search_Query_Term($term);
             $query->setBoost($this->_boost);
 
             return $query;
         }
 
+        if (count($tokens) == 1  && $this->_fuzzyQuery) {
+            $term  = new Zend_Search_Lucene_Index_Term($tokens[0]->getTermText(), $this->_field);
+            $query = new Zend_Search_Lucene_Search_Query_Fuzzy($term, $this->_similarity);
+            $query->setBoost($this->_boost);
+
+            return $query;
+        }
+
+        if ($this->_fuzzyQuery) {
+            throw new Zend_Search_Lucene_Search_QueryParserException('Fuzzy search is supported only for non-multiple word terms');
+        }
+        
         //It's not empty or one term query
         $query = new Zend_Search_Lucene_Search_Query_MultiTerm();
 
index 12278ea4ad84a40e6bdc3313362a6193df89e525..2a281979b73f66dcbf6ea40363e4af2dc004a748 100644 (file)
@@ -15,7 +15,7 @@
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
@@ -24,7 +24,7 @@
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Search_QueryHit
index 6b72110bfd1820fddad4e4909e0d33525944151b..206e7a66b77d86c35b7ac405d04a69998d0d7503 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_FSM */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/FSM.php';
+require_once 'Zend/Search/Lucene/FSM.php';
 
 /** Zend_Search_Lucene_Search_QueryParser */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/QueryToken.php';
+require_once 'Zend/Search/Lucene/Search/QueryToken.php';
 
 /** Zend_Search_Lucene_Exception */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Exception.php';
+require_once 'Zend/Search/Lucene/Exception.php';
 
 /** Zend_Search_Lucene_Search_QueryParserException */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/QueryParserException.php';
+require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
index 9d172c69fa593320a45fff992009cb16372cbf5a..f63914ee2e83b8aed300f91fd38841b876cc14d0 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 /** Zend_Search_Lucene_FSM */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/FSM.php';
+require_once 'Zend/Search/Lucene/FSM.php';
 
 
 /** Zend_Search_Lucene_Index_Term */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Index/Term.php';
+require_once 'Zend/Search/Lucene/Index/Term.php';
 
 /** Zend_Search_Lucene_Search_QueryToken */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/QueryToken.php';
+require_once 'Zend/Search/Lucene/Search/QueryToken.php';
 
 /** Zend_Search_Lucene_Search_Query_Term */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/Query/Term.php';
+require_once 'Zend/Search/Lucene/Search/Query/Term.php';
 
 /** Zend_Search_Lucene_Search_Query_MultiTerm */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/Query/MultiTerm.php';
+require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
 
 /** Zend_Search_Lucene_Search_Query_Boolean */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/Query/Boolean.php';
+require_once 'Zend/Search/Lucene/Search/Query/Boolean.php';
 
 /** Zend_Search_Lucene_Search_Query_Phrase */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/Query/Phrase.php';
+require_once 'Zend/Search/Lucene/Search/Query/Phrase.php';
 
 /** Zend_Search_Lucene_Exception */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Exception.php';
+require_once 'Zend/Search/Lucene/Exception.php';
 
 /** Zend_Search_Lucene_Search_QueryParserException */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/QueryParserException.php';
+require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
 
 /** Zend_Search_Lucene_Search_BooleanExpressionRecognizer */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/BooleanExpressionRecognizer.php';
+require_once 'Zend/Search/Lucene/Search/BooleanExpressionRecognizer.php';
 
 /** Zend_Search_Lucene_Search_QueryEntry */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/QueryEntry.php';
+require_once 'Zend/Search/Lucene/Search/QueryEntry.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Search_QueryParserContext
@@ -360,7 +360,7 @@ class Zend_Search_Lucene_Search_QueryParserContext
             }
 
             if (!$nonNegativeEntryFound) {
-               unset($conjuctions[$conjuctionId]);
+                unset($conjuctions[$conjuctionId]);
             }
         }
 
@@ -382,7 +382,7 @@ class Zend_Search_Lucene_Search_QueryParserContext
         }
 
         if (count($subqueries) == 0) {
-            return new Zend_Search_Lucene_Search_Query_Empty();
+            return new Zend_Search_Lucene_Search_Query_Insignificant();
         }
 
         if (count($subqueries) == 1) {
index 8ca791ffb7e3cf164ee8f21c2d7df9c62c166a16..52f6fb7bf58b7b6f49a1578d85545441254bf833 100644 (file)
@@ -15,7 +15,7 @@
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 /**
  * Zend_Search_Lucene base exception
  */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Exception.php';
+require_once 'Zend/Search/Lucene/Exception.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  *
  * Special exception type, which may be used to intercept wrong user input
index cf153096d2a1bc24ad49c5b9014e1304afba6474..f8cbdcfbe01b2de3b240ac4f5a31acbe96a1b141 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Exception */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Exception.php';
+require_once 'Zend/Search/Lucene/Exception.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Search_QueryToken
diff --git a/search/Zend/Search/Lucene/Search/QueryTokenizer.php b/search/Zend/Search/Lucene/Search/QueryTokenizer.php
deleted file mode 100644 (file)
index 2965eaa..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-<?php
-/**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category   Zend
- * @package    Zend_Search_Lucene
- * @subpackage Search
- * @copyright  Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
-
-/** Zend_Search_Lucene_Search_QueryToken */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/QueryToken.php';
-
-/** Zend_Search_Lucene_Exception */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Exception.php';
-
-
-/**
- * @category   Zend
- * @package    Zend_Search_Lucene
- * @subpackage Search
- * @copyright  Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_Search_Lucene_Search_QueryTokenizer implements Iterator
-{
-    /**
-     * inputString tokens.
-     *
-     * @var array
-     */
-    protected $_tokens = array();
-
-    /**
-     * tokens pointer.
-     *
-     * @var integer
-     */
-    protected $_currToken = 0;
-
-
-    /**
-     * QueryTokenize constructor needs query string as a parameter.
-     *
-     * @param string $inputString
-     */
-    public function __construct($inputString)
-    {
-        if (!strlen($inputString)) {
-            throw new Zend_Search_Lucene_Exception('Cannot tokenize empty query string.');
-        }
-
-        $currentToken = '';
-        for ($count = 0; $count < strlen($inputString); $count++) {
-            if (ctype_alnum( $inputString{$count} ) ||
-                $inputString{$count} == '_') {
-                $currentToken .= $inputString{$count};
-            } else if ($inputString{$count} == '\\') { // Escaped character
-                $count++;
-
-                if ($count == strlen($inputString)) {
-                    throw new Zend_Search_Lucene_Exception('Non finished escape sequence.');
-                }
-
-                $currentToken .= $inputString{$count};
-            } else {
-                // Previous token is finished
-                if (strlen($currentToken)) {
-                    $this->_tokens[] = new Zend_Search_Lucene_Search_QueryToken(Zend_Search_Lucene_Search_QueryToken::TOKTYPE_WORD,
-                                                                $currentToken);
-                    $currentToken = '';
-                }
-
-                if ($inputString{$count} == '+' || $inputString{$count} == '-') {
-                    $this->_tokens[] = new Zend_Search_Lucene_Search_QueryToken(Zend_Search_Lucene_Search_QueryToken::TOKTYPE_SIGN,
-                                                                $inputString{$count});
-                } elseif ($inputString{$count} == '(' || $inputString{$count} == ')') {
-                    $this->_tokens[] = new Zend_Search_Lucene_Search_QueryToken(Zend_Search_Lucene_Search_QueryToken::TOKTYPE_BRACKET,
-                                                                $inputString{$count});
-                } elseif ($inputString{$count} == ':' && $this->count()) {
-                    if ($this->_tokens[count($this->_tokens)-1]->type == Zend_Search_Lucene_Search_QueryToken::TOKTYPE_WORD) {
-                        $this->_tokens[count($this->_tokens)-1]->type = Zend_Search_Lucene_Search_QueryToken::TOKTYPE_FIELD;
-                    }
-                }
-            }
-        }
-
-        if (strlen($currentToken)) {
-            $this->_tokens[] = new Zend_Search_Lucene_Search_QueryToken(Zend_Search_Lucene_Search_QueryToken::TOKTYPE_WORD, $currentToken);
-        }
-    }
-
-
-    /**
-     * Returns number of tokens
-     *
-     * @return integer
-     */
-    public function count()
-    {
-        return count($this->_tokens);
-    }
-
-
-    /**
-     * Returns TRUE if a token exists at the current position.
-     *
-     * @return boolean
-     */
-    public function valid()
-    {
-        return $this->_currToken < $this->count();
-    }
-
-
-    /**
-     * Resets token stream.
-     *
-     * @return integer
-     */
-    public function rewind()
-    {
-        $this->_currToken = 0;
-    }
-
-
-    /**
-     * Returns the token at the current position or FALSE if
-     * the position does not contain a valid token.
-     *
-     * @return mixed
-     */
-    public function current()
-    {
-        return $this->valid() ? $this->_tokens[$this->_currToken] : false;
-    }
-
-
-    /**
-     * Returns next token
-     *
-     * @return Zend_Search_Lucene_Search_QueryToken
-     */
-    public function next()
-    {
-        return ++$this->_currToken;
-    }
-
-
-    /**
-     * Return the position of the current token.
-     *
-     * @return integer
-     */
-    public function key()
-    {
-        return $this->_currToken;
-    }
-
-}
-
index 016d232a24486f70951e2b2f42ae1ca1294ccbd3..95b0565656048bcc8bdfa60f6e226d4726194322 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Search_Similarity_Default */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/Similarity/Default.php';
+require_once 'Zend/Search/Lucene/Search/Similarity/Default.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 abstract class Zend_Search_Lucene_Search_Similarity
index 8263f2a72f8347495cdd6f54548c714e6c570dde..7b8d6ef7c75f62793a23d7893c79781f9d077c7e 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Search_Similarity */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/Similarity.php';
+require_once 'Zend/Search/Lucene/Search/Similarity.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Search_Similarity_Default extends Zend_Search_Lucene_Search_Similarity
@@ -38,7 +38,7 @@ class Zend_Search_Lucene_Search_Similarity_Default extends Zend_Search_Lucene_Se
      * Implemented as '1/sqrt(numTerms)'.
      *
      * @param string $fieldName
-     * @param integer numTerms
+     * @param integer $numTerms
      * @return float
      */
     public function lengthNorm($fieldName, $numTerms)
index 2faba2861bf620f36d1af6cc35cdc917a4b3d60f..285fed8e758cde80dd202c649f36d9b408882281 100644 (file)
@@ -15,7 +15,7 @@
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
@@ -32,7 +32,7 @@
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 abstract class Zend_Search_Lucene_Search_Weight
index 7a42ed28269497bad3c948e051b1638885de829b..08385b797138b3b60464e7da778c9ea91e15a418 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Search_Weight */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/Weight.php';
+require_once 'Zend/Search/Lucene/Search/Weight.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Search_Weight_Boolean extends Zend_Search_Lucene_Search_Weight
index 00c1bce45172d9b732fdeafb131101b8c4daaaf9..0b1702ae096626f156714a6928fd58862e78bd99 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Search_Weight */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/Weight.php';
+require_once 'Zend/Search/Lucene/Search/Weight.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Search_Weight_Empty extends Zend_Search_Lucene_Search_Weight
index 122cfa4035a1d523b869b7fa94eb7cc66156eed3..f284a28dacdcde02fd191820a824cfa10ddf2a6c 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Search_Weight */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/Weight.php';
+require_once 'Zend/Search/Lucene/Search/Weight.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Search_Weight_MultiTerm extends Zend_Search_Lucene_Search_Weight
index 7faaa7ad130ea99a3cbe4f964ec525c23590fe94..873e44c30392fb27b54e3fb2e2cd8e8cff2bca50 100644 (file)
@@ -15,7 +15,7 @@
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 /**
  * Zend_Search_Lucene_Search_Weight
  */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/Weight.php';
+require_once 'Zend/Search/Lucene/Search/Weight.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Search_Weight_Phrase extends Zend_Search_Lucene_Search_Weight
index 478cb2a8058c1fe7ff18ec6a20887c03a7a4d3f6..1d880b2db00411d2341b0887bee61cacde376647 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Search_Weight */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/Weight.php';
+require_once 'Zend/Search/Lucene/Search/Weight.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Search
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Search_Weight_Term extends Zend_Search_Lucene_Search_Weight
index 67e2b295f528de5b860770936a37501f31430e9b..011734efa5e10e4fd2df9605ed880b259e4884df 100644 (file)
@@ -15,7 +15,7 @@
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Storage
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
@@ -24,7 +24,7 @@
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Storage
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 abstract class Zend_Search_Lucene_Storage_Directory
@@ -61,7 +61,16 @@ abstract class Zend_Search_Lucene_Storage_Directory
      */
     abstract public function deleteFile($filename);
 
-
+    /**
+     * Purge file if it's cached by directory object
+     * 
+     * Method is used to prevent 'too many open files' error
+     *
+     * @param string $filename
+     * @return void
+     */
+    abstract public function purgeFile($filename);
+    
     /**
      * Returns true if a file with the given $filename exists.
      *
index 7ac76810ab6a5d1d095f0becad20169c2cf15521..9220ad2da048d739454655a08c6494dc3fad09a8 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Storage
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Storage_Directory */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Storage/Directory.php';
+require_once 'Zend/Search/Lucene/Storage/Directory.php';
 
 /** Zend_Search_Lucene_Storage_File_Filesystem */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Storage/File/Filesystem.php';
+require_once 'Zend/Search/Lucene/Storage/File/Filesystem.php';
 
 
 /**
@@ -33,7 +33,7 @@ require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Storage/File/Filesystem.p
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Storage
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene_Storage_Directory
@@ -43,7 +43,7 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
      *
      * @var string
      */
-    private $_dirPath = null;
+    protected $_dirPath = null;
 
     /**
      * Cache for Zend_Search_Lucene_Storage_File_Filesystem objects
@@ -52,7 +52,35 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
      * @var array
      * @throws Zend_Search_Lucene_Exception
      */
-    private $_fileHandlers;
+    protected $_fileHandlers;
+
+    /**
+     * Default file permissions
+     *
+     * @var integer
+     */
+    protected static $_defaultFilePermissions = 0666;
+
+
+    /**
+     * Get default file permissions
+     *
+     * @return integer
+     */
+    public static function getDefaultFilePermissions()
+    {
+        return self::$_defaultFilePermissions;
+    }
+
+    /**
+     * Set default file permissions
+     *
+     * @param integer $mode
+     */
+    public static function setDefaultFilePermissions($mode)
+    {
+        self::$_defaultFilePermissions = $mode;
+    }
 
 
     /**
@@ -144,6 +172,7 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
      *
      * @param string $filename
      * @return Zend_Search_Lucene_Storage_File
+     * @throws Zend_Search_Lucene_Exception
      */
     public function createFile($filename)
     {
@@ -152,6 +181,15 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
         }
         unset($this->_fileHandlers[$filename]);
         $this->_fileHandlers[$filename] = new Zend_Search_Lucene_Storage_File_Filesystem($this->_dirPath . '/' . $filename, 'w+b');
+
+        global $php_errormsg;
+        $trackErrors = ini_get('track_errors'); ini_set('track_errors', '1');
+        if (!@chmod($this->_dirPath . '/' . $filename, self::$_defaultFilePermissions)) {
+            ini_set('track_errors', $trackErrors);
+            throw new Zend_Search_Lucene_Exception($php_errormsg);
+        }
+        ini_set('track_errors', $trackErrors);
+
         return $this->_fileHandlers[$filename];
     }
 
@@ -161,22 +199,42 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
      *
      * @param string $filename
      * @return void
+     * @throws Zend_Search_Lucene_Exception
      */
     public function deleteFile($filename)
     {
-        /**
-         * @todo add support of "deletable" file
-         * "deletable" is used on Windows systems if file can't be deleted
-         * (while it is still open).
-         */
-
         if (isset($this->_fileHandlers[$filename])) {
             $this->_fileHandlers[$filename]->close();
         }
         unset($this->_fileHandlers[$filename]);
-        unlink($this->_dirPath . '/' . $filename);
+
+        global $php_errormsg;
+        $trackErrors = ini_get('track_errors'); ini_set('track_errors', '1');
+        if (!@unlink($this->_dirPath . '/' . $filename)) {
+            ini_set('track_errors', $trackErrors);
+            throw $e;
+            
+            throw new Zend_Search_Lucene_Exception('Can\'t delete file: ' . $php_errormsg);
+        }
+        ini_set('track_errors', $trackErrors);
     }
 
+    /**
+     * Purge file if it's cached by directory object
+     * 
+     * Method is used to prevent 'too many open files' error
+     *
+     * @param string $filename
+     * @return void
+     */
+    public function purgeFile($filename)
+    {
+        if (isset($this->_fileHandlers[$filename])) {
+            $this->_fileHandlers[$filename]->close();
+        }
+        unset($this->_fileHandlers[$filename]);
+    }
+    
 
     /**
      * Returns true if a file with the given $filename exists.
index 8370c719db7047bc337fb3f3a906dba89c400049..8a4fab5a188a678aa79f7a1b9109c6b9af729e56 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Storage
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 
 /** Zend_Search_Lucene_Exception */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Exception.php';
+require_once 'Zend/Search/Lucene/Exception.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Storage
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 abstract class Zend_Search_Lucene_Storage_File
index 1f2097eb4f67d7eab5dacb512a1db7b9ce1d826b..d508ce9dcff13044e25695999955813dd7a5e1ed 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Storage
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Storage_File */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Storage/File.php';
+require_once 'Zend/Search/Lucene/Storage/File.php';
 
 /** Zend_Search_Lucene_Exception */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Exception.php';
+require_once 'Zend/Search/Lucene/Exception.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Storage
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Storage_File_Filesystem extends Zend_Search_Lucene_Storage_File
@@ -41,7 +41,8 @@ class Zend_Search_Lucene_Storage_File_Filesystem extends Zend_Search_Lucene_Stor
      *
      * @var resource
      */
-    private $_fileHandle;
+    protected $_fileHandle;
+
 
     /**
      * Class constructor.  Open the file.
@@ -53,6 +54,11 @@ class Zend_Search_Lucene_Storage_File_Filesystem extends Zend_Search_Lucene_Stor
     {
         global $php_errormsg;
 
+        if (strpos($mode, 'w') === false  &&  !is_readable($filename)) {
+            // opening for reading non-readable file
+            throw new Zend_Search_Lucene_Exception('File \'' . $filename . '\' is not readable.');
+        }
+
         $trackErrors = ini_get('track_errors');
         ini_set('track_errors', '1');
 
@@ -185,12 +191,12 @@ class Zend_Search_Lucene_Storage_File_Filesystem extends Zend_Search_Lucene_Stor
      * Lock type may be a LOCK_SH (shared lock) or a LOCK_EX (exclusive lock)
      *
      * @param integer $lockType
-     * @param boolean $nonBlockinLock
+     * @param boolean $nonBlockingLock
      * @return boolean
      */
-    public function lock($lockType, $nonBlockinLock = false)
+    public function lock($lockType, $nonBlockingLock = false)
     {
-        if ($nonBlockinLock) {
+        if ($nonBlockingLock) {
             return flock($this->_fileHandle, $lockType | LOCK_NB);
         } else {
             return flock($this->_fileHandle, $lockType);
index e3567c66dab57b1a599809cf8f7c9f67b25e5cda..e830bcea703bd1eaebad284659899142527313de 100644 (file)
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Storage
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
 
 /** Zend_Search_Lucene_Storage_File */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Storage/File.php';
+require_once 'Zend/Search/Lucene/Storage/File.php';
 
 /** Zend_Search_Lucene_Exception */
-require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Exception.php';
+require_once 'Zend/Search/Lucene/Exception.php';
 
 
 /**
  * @category   Zend
  * @package    Zend_Search_Lucene
  * @subpackage Storage
- * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Search_Lucene_Storage_File_Memory extends Zend_Search_Lucene_Storage_File
index e03d44566f22c6b61a014b34247a770e288963b5..a4929931306d6e7e71ac39a9bb9d6db75921a693 100644 (file)
 /**
 * @param object $resource
 */
-function get_text_for_indexing_html(&$resource){
+function get_text_for_indexing_html(&$resource, $directfile = ''){
     
     // wraps to htm handler
     include_once 'physical_htm.php';
-    return get_text_for_indexing_htm($resource);
+    return get_text_for_indexing_htm($resource, $directfile);
 }
 ?>
\ No newline at end of file
diff --git a/search/documents/techproject_document.php b/search/documents/techproject_document.php
deleted file mode 100644 (file)
index 53f5a4a..0000000
+++ /dev/null
@@ -1,301 +0,0 @@
-<?php
-/**
-* Global Search Engine for Moodle
-*
-* @package search
-* @category core
-* @subpackage document_wrappers
-* @author Michael Campanis, Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
-* @date 2008/03/31
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-*
-* document handling for techproject activity module
-*/
-
-/**
-* requires and includes
-*/
-require_once("$CFG->dirroot/search/documents/document.php");
-require_once("$CFG->dirroot/mod/techproject/lib.php");
-
-/**
-* a class for representing searchable information
-*
-*/
-class TechprojectEntrySearchDocument extends SearchDocument {
-
-    /**
-    * constructor
-    *
-    */
-    public function __construct(&$entry, $course_id, $context_id) {
-        // generic information
-        $doc->docid     = $entry['id'];
-        $doc->documenttype  = SEARCH_TYPE_TECHPROJECT;
-        $doc->itemtype      = $entry['entry_type'];
-        $doc->contextid     = $context_id;
-
-        
-        $doc->title     = $entry['abstract'];
-        $doc->author    = ($entry['userid']) ? $entry['author'] : '';
-        $doc->contents  = strip_tags($entry['description']);
-        $doc->date      = '';
-        
-        $doc->url       = techproject_make_link($entry['projectid'], $entry['id'], $entry['entry_type'], $entry['groupid']);
-        
-        // module specific information
-        $data->techproject = $entry['projectid'];
-        
-        parent::__construct($doc, $data, $course_id, $entry['groupid'], $entry['userid'], PATH_FOR_SEARCH_TYPE_TECHPROJECT);
-    } //constructor
-} //TechprojectEntrySearchDocument
-
-/**
-* constructs a valid link to a description detail
-*
-*/
-function techproject_make_link($techproject_id, $entry_id, $entry_type, $group_id) {
-    global $CFG;
-    return $CFG->wwwroot.'/mod/techproject/view.php?view=view_detail&amp;id='.$techproject_id.'&amp;objectId='.$entry_id.'&amp;objectClass='.$entry_type.'&amp;group='.$group_id;
-} //techproject_make_link
-
-/**
-* search standard API
-*
-*/
-function techproject_iterator() {
-    $techprojects = get_records('techproject');
-    return $techprojects;    
-} //techproject_iterator
-
-/**
-* search standard API
-* @param techproject a techproject instance
-* @return an array of collected searchable documents
-*/
-function techproject_get_content_for_index(&$techproject) {
-    $documents = array();
-    if (!$techproject) return $documents;
-
-    $requirements = techproject_get_entries($techproject->id, 'requirement');
-    $specifications = techproject_get_entries($techproject->id, 'specification');
-    $tasks = techproject_get_tasks($techproject->id);
-    $milestones = techproject_get_entries($techproject->id, 'milestone');
-    $deliverables = techproject_get_entries($techproject->id, 'deliverable');
-    $coursemodule = get_field('modules', 'id', 'name', 'techproject');
-    $cm = get_record('course_modules', 'course', $techproject->course, 'module', $coursemodule, 'instance', $techproject->id);
-    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
-    $entries = @array_merge($requirements, $specifications, $milestones, $deliverables);
-    if ($entries){
-        foreach($entries as $anEntry) {
-            if ($anEntry) {
-                if (strlen($anEntry->description) > 0) {
-                    $anEntry->author = '';
-                    $documents[] = new TechprojectEntrySearchDocument(get_object_vars($anEntry), $techproject->course, $context->id);
-                } 
-            } 
-        } 
-    }
-    if ($tasks){
-        foreach($tasks as $aTask) {
-            if ($aTask) {
-                if (strlen($aTask->description) > 0) {
-                    if ($aTask->assignee){
-                        $user = get_record('user', 'id', $aTask->assignee);
-                        $aTask->author = $user->firstname.' '.$user->lastname;
-                    }
-                    $documents[] = new TechprojectEntrySearchDocument(get_object_vars($aTask), $techproject->course, $context->id);
-                } 
-            } 
-        } 
-    }
-    return $documents;
-} //techproject_get_content_for_index
-
-/**
-* returns a single techproject search document based on a techproject_entry id and itemtype
-*
-*/
-function techproject_single_document($id, $itemtype) {
-    switch ($itemtype){
-        case 'requirement':{
-            $entry = get_record('techproject_requirement', 'id', $id);
-            $entry->author = '';
-            break;
-        }
-        case 'specification':{
-            $entry = get_record('techproject_specification', 'id', $id);
-            $entry->author = '';
-            break;
-        }
-        case 'milestone':{
-            $entry = get_record('techproject_milestone', 'id', $id);
-            $entry->author = '';
-            break;
-        }
-        case 'deliverable':{
-            $entry = get_record('techproject_deliverable', 'id', $id);
-            $entry->author = '';
-            break;
-        }
-        case 'task':{
-            $entry = get_record('techproject_task', 'id', $id);
-            if ($entry->assignee){
-                $user = get_record('user', 'id', $entry->assignee);
-                $entry->author = $user->firstname.' '.$user->lastname;
-            }
-            break;
-        }
-    }
-    $techproject_course = get_field('techproject', 'course', 'id', $entry->projectid);
-    $coursemodule = get_field('modules', 'id', 'name', 'techproject');
-    $cm = get_record('course_modules', 'course', $techproject_course, 'module', $coursemodule, 'instance', $entry->projectid);
-    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-    $entry->type = $itemtype;
-    $techproject = get_record('techproject', 'id', $requirement->projectid);
-    return new TechprojectEntrySearchDocument(get_object_vars($anEntry), $techproject->course, $context->id);
-} //techproject_single_document
-
-/**
-* dummy delete function that packs id with itemtype.
-* this was here for a reason, but I can't remember it at the moment.
-*
-*/
-function techproject_delete($info, $itemtype) {
-    $object->id = $info;
-    $object->itemtype = $itemtype;
-    return $object;
-} //techproject_delete
-
-/**
-* returns the var names needed to build a sql query for addition/deletions
-*
-*/
-// TODO : what should we do there ?
-function techproject_db_names() {
-    //[primary id], [table name], [time created field name], [time modified field name]
-    return array(
-        array('id', 'techproject_requirement', 'created', 'modified', 'requirement'),
-        array('id', 'techproject_specification', 'created', 'modified', 'specification'),
-        array('id', 'techproject_task', 'created', 'modified', 'task'),
-        array('id', 'techproject_milestone', 'created', 'modified', 'milestone'),
-        array('id', 'techproject_deliverable', 'created', 'modified', 'deliverable')
-    );
-} //techproject_db_names
-
-/**
-* get a complete list of entries of one particular type
-* @param techprojectId the project instance
-* @param type the entity type
-* @return an array of records
-*/
-function techproject_get_entries($techproject_id, $type) {
-    global $CFG;
-    
-    $query = "
-        SELECT 
-            e.id, 
-            e.abstract, 
-            e.description,
-            e.projectid,
-            e.groupid,
-            e.userid,
-            '$type' AS entry_type
-        FROM 
-            {$CFG->prefix}techproject_{$type} AS e
-        WHERE 
-            e.projectid = '{$techproject_id}'
-    ";
-    return get_records_sql($query);
-} //techproject_get_entries
-
-/**
-* get the task list for a project instance
-* @param techprojectId the project
-* @return an array of records that represent tasks
-*/
-function techproject_get_tasks($techproject_id) {
-    global $CFG;
-    
-    $query = "
-        SELECT 
-            t.id, 
-            t.abstract, 
-            t.description,
-            t.projectid,
-            t.groupid,
-            t.owner as userid,
-            u.firstname,
-            u.lastname,
-            'task' as entry_type
-        FROM 
-            {$CFG->prefix}techproject_task AS t
-        LEFT JOIN
-            {$CFG->prefix}user AS u
-        ON
-            t.owner = u.id            
-        WHERE 
-            t.projectid = '{$techproject_id}'
-        ORDER BY 
-            t.taskstart ASC
-    ";
-    return get_records_sql($query);
-} //techproject_get_tasks
-
-/**
-* this function handles the access policy to contents indexed as searchable documents. If this 
-* function does not exist, the search engine assumes access is allowed.
-* When this point is reached, we already know that : 
-* - user is legitimate in the surrounding context
-* - user may be guest and guest access is allowed to the module
-* - the function may perform local checks within the module information logic
-* @param path the access path to the module script code
-* @param entry_type the information subclassing (usefull for complex modules, defaults to 'standard')
-* @param this_id the item id within the information class denoted by entry_type. In techprojects, this id 
-* points to the techproject instance in which all resources are indexed.
-* @param user the user record denoting the user who searches
-* @param group_id the current group used by the user when searching
-* @return true if access is allowed, false elsewhere
-*/
-function techproject_check_text_access($path, $entry_type, $this_id, $user, $group_id, $context_id){
-    global $CFG;
-    
-    include_once("{$CFG->dirroot}/{$path}/lib.php");
-
-    // get the techproject object and all related stuff
-    $techproject = get_record('techproject', 'id', $this_id);
-    $course = get_record('course', 'id', $techproject->course);
-    $module_context = get_record('context', 'id', $context_id);
-    $cm = get_record('course_modules', 'id', $module_context->instanceid);
-    if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $module_context)) return false;
-    
-    //group consistency check : checks the following situations about groups
-    // if user is guest check access capabilities for guests :
-    // guests can see default project, and other records if groups are liberal
-    // TODO : change guestsallowed in a capability
-    if (isguest() && $techproject->guestsallowed){
-        if ($group_id && groupmode($course, $cm) == SEPARATEGROUPS)
-            return false;
-        return true;
-    }
-    
-    // trap if user is not same group and groups are separated
-    $current_group = get_current_group($course->id);
-    if ((groupmode($course) == SEPARATEGROUPS) && $group_id != $current_group && $group_id) return false;
-    
-    //trap if ungroupedsees is off in strict access mode and user is not teacher
-    if ((groupmode($course) == SEPARATEGROUPS) && !$techproject->ungroupedsees && !$group_id && isteacher($user->id)) return false;
-    
-    return true;
-} //techproject_check_text_access
-
-/**
-* this call back is called when displaying the link for some last post processing
-*
-*/
-function techproject_link_post_processing($title){
-     return mb_convert_encoding($title, 'UTF-8', 'auto');
-}
-
-?>
\ No newline at end of file
diff --git a/search/lang/en_utf8/search.php b/search/lang/en_utf8/search.php
deleted file mode 100644 (file)
index 3d0127c..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-$string['advancedsearch'] = 'Advanced search';
-$string['all'] = 'All';
-$string['author'] = 'Author';
-$string['authorname'] = 'Author name';
-$string['back'] = 'Back';
-$string['beadmin'] = 'You need to be an admin user to use this page.';
-$string['checkdb'] = 'Check Database';
-$string['checkdbadvice'] = 'Check your database for any problems.';
-$string['checkdir'] = 'Check dir';
-$string['checkdiradvice'] = 'Ensure the data directory exists and is writable.';
-$string['commenton'] = 'Comment on ';
-$string['createanindex'] = 'create an index';
-$string['createdon'] = 'Created on';
-$string['database'] = 'Database';
-$string['databasestate'] = 'Indexing Database State';
-$string['datadirectory'] = 'Data directory';
-$string['deletionsinindex'] = 'Deletions in index';
-$string['doctype'] = 'Doctype';
-$string['documents'] = 'documents';
-$string['documentsfor'] = 'Documents for ';
-$string['documentsindatabase'] = 'Documents in database';
-$string['documentsinindex'] = 'Documents in index';
-$string['duration'] = 'Duration';
-$string['emptydatabaseerror'] = 'Database table is not present, or contains no index records.';
-$string['enteryoursearchquery'] = 'Enter your search query';
-$string['errors'] = 'Errors ';
-$string['filesinindexdirectory'] = 'Files in index directory';
-$string['globalsearchdisabled'] = 'Global searching is not enabled.';
-$string['invalidindexerror'] = 'Index directory either contains an invalid index, or nothing at all.';
-$string['ittook'] = 'It took';
-$string['next'] = 'Next';
-$string['noindexmessage'] = 'Admin: There appears to be no search index. Please';
-$string['normalsearch'] = 'Normal search';
-$string['openedon'] = 'opened on';
-$string['resultsreturnedfor'] = ' results returned for ';
-$string['runindexer'] = 'Run indexer (real)';
-$string['runindexertest'] = 'Run indexer test';
-$string['score'] = 'Score';
-$string['search'] = 'Search';
-$string['searching'] = 'Searching in ...';
-$string['seconds'] = ' seconds ';
-$string['solutions'] = 'Solutions';
-$string['statistics'] = 'Statistics';
-$string['thesewordshelpimproverank'] = 'These words help improve rank';
-$string['thesewordsmustappear'] = 'These words must appear';
-$string['thesewordsmustnotappear'] = 'These words must not appear';
-$string['title'] = 'Title';
-$string['tofetchtheseresults'] = 'to fetch these results';
-$string['totalsize'] = 'Total Size ';
-$string['type'] = 'Type';
-$string['uncompleteindexingerror'] = 'Indexing was not successfully completed, please restart it.';
-$string['versiontoolow'] = 'Sorry, global search requires PHP 5.0.0 or later (currently using version '.$phpversion.')';
-$string['whichmodulestosearch?'] = 'Which modules to search?';
-$string['wordsintitle'] = 'Words in title';
-?>
\ No newline at end of file
diff --git a/search/lang/fr_utf8/search.php b/search/lang/fr_utf8/search.php
deleted file mode 100644 (file)
index 52fa498..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-$string['advancedsearch'] = 'Recherche avancée';
-$string['all'] = 'Tous';
-$string['author'] = 'Auteur ';
-$string['authorname'] = 'Nom de l\'auteur';
-$string['back'] = 'Précédent';
-$string['beadmin'] = 'Vous devez Ãªtre administrateur pour utiliser cette page.';
-$string['checkdb'] = 'vérifier la base de données';
-$string['checkdbadvice'] = 'Vérifiez votre base de données.';
-$string['checkdir'] = 'Vérifier le répertoire';
-$string['checkdiradvice'] = 'Assurez vous que le répertoire de données utilisateur existe et est accessible en Ã©criture.';
-$string['commenton'] = 'Commentaire sur ';
-$string['createanindex'] = 'créer un index';
-$string['createdon'] = 'Créé le ';
-$string['database'] = 'Base de données';
-$string['databasestate'] = 'Etat de la base d\'indexation';
-$string['datadirectory'] = 'Répertoire des ressources utilisateur';
-$string['deletionsinindex'] = 'Suppressions dans l\'index';
-$string['doctype'] = 'Type de document ';
-$string['documents'] = 'documents ';
-$string['documentsfor'] = 'Documents des ';
-$string['documentsindatabase'] = 'Documents dans la base de données';
-$string['documentsinindex'] = 'Documents dans l\'index';
-$string['duration'] = 'Durée';
-$string['emptydatabaseerror'] = 'La table d\'indexation n\'est pas présente, ou ne contient aucune donnée.';
-$string['enteryoursearchquery'] = 'Entrez votre recherche';
-$string['errors'] = 'Erreurs ';
-$string['filesinindexdirectory'] = 'Fichiers du répertoire index';
-$string['globalsearchdisabled'] = 'La recherche globale est désactivée sur ce site.';
-$string['invalidindexerror'] = 'Le répertoire d\'indexation n\'existe pas ou contient des indexes invalides, ou rien du tout.';
-$string['ittook'] = 'Le moteur a pris ';
-$string['next'] = 'Suivant';
-$string['noindexmessage'] = 'Administrateur : L\'index de recherche n\'existe pas. Veuillez ';
-$string['normalsearch'] = 'Recherche standard';
-$string['openedon'] = 'ouvert(e) le';
-$string['resultsreturnedfor'] = 'résultats pour la requête ';
-$string['runindexer'] = 'Lancer l\'indexeur';
-$string['runindexertest'] = 'Lancer l\'indexeur en mode test';
-$string['score'] = 'Score ';
-$string['search'] = 'Rechercher ';
-$string['searching'] = 'Recherche en cours dans ...';
-$string['seconds'] = ' secondes ';
-$string['solutions'] = 'Solutions';
-$string['statistics'] = 'Statistiques ';
-$string['thesewordshelpimproverank'] = 'Ces mots améliorent le score';
-$string['thesewordsmustappear'] = 'Ces mots doivent apparaître dans le texte';
-$string['thesewordsmustnotappear'] = 'Ces mots doivent Ãªtre absents du texte';
-$string['title'] = 'Titre ';
-$string['tofetchtheseresults'] = 'pour trouver ces résultats';
-$string['totalsize'] = 'Taille totale ';
-$string['type'] = 'Type ';
-$string['uncompleteindexingerror'] = 'L\'indexation ne s\'est pas terminée, relancez le processus.';
-$string['versiontoolow'] = 'La recherche globale nécessite une version minimale de PHP en 5.0.0 (vous utilisez actuellement la version '.phpversion().')';
-$string['whichmodulestosearch?'] = 'Dans quels modules effectuer la recherche ?';
-$string['wordsintitle'] = 'Mots des titres';
-?>
\ No newline at end of file
diff --git a/search/lang/nl_utf8/search.php b/search/lang/nl_utf8/search.php
deleted file mode 100644 (file)
index 1f17a04..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-$string['advancedsearch'] = 'Geavanceerd zoeken';
-$string['all'] = 'Alle';
-$string['author'] = 'Auteur';
-$string['authorname'] = 'Naam auteur';
-$string['back'] = 'Terug';
-$string['beadmin'] = 'Je moet beheerder zijn om deze pagina te gebruiken.';
-$string['checkdb'] = 'Controleer de databank';
-$string['checkdbadvice'] = 'Controleer of er problemen met de databank zijn.';
-$string['checkdir'] = 'Controleer map';
-$string['checkdiradvice'] = 'Zorg ervoor dat de datamap bestaat en schrijfbaar is.';
-$string['commenton'] = 'Geef commentaar op ';
-$string['createanindex'] = 'maak een index';
-$string['createdon'] = 'Gemaakt op';
-$string['database'] = 'Databank';
-$string['databasestate'] = 'De databank aan het indexen';
-$string['datadirectory'] = 'Datamap';
-$string['deletionsinindex'] = 'Verwijderingen uit de index';
-$string['doctype'] = 'Doctype';
-$string['documents'] = 'documenten';
-$string['documentsfor'] = 'Documenten voor ';
-$string['documentsindatabase'] = 'Documenten in de databank';
-$string['documentsinindex'] = 'Documenten in  de index';
-$string['duration'] = 'Tijd';
-$string['emptydatabaseerror'] = 'De tabel bestaat niet in de databank of er zijn geen records.';
-$string['enteryoursearchquery'] = 'Typ je zoekopdracht';
-$string['errors'] = 'Fouten ';
-$string['filesinindexdirectory'] = 'Bestanden in de index map';
-$string['globalsearchdisabled'] = 'Globaal zoeken is niet aangezet.';
-$string['invalidindexerror'] = 'De index map heeft een foute index of heeft helemaal geen gegevens.';
-$string['ittook'] = 'Het duurde ';
-$string['next'] = 'Volgende';
-$string['noindexmessage'] = 'Beheerder: Het lijkt alsof er geen index gegevens zijn.';
-$string['normalsearch'] = 'Simpel zoeken';
-$string['openedon'] = 'geopend op';
-$string['resultsreturnedfor'] = ' resultaten gevonden voor ';
-$string['runindexer'] = 'Draai indexer (echt)';
-$string['runindexertest'] = 'Draai indexer test';
-$string['score'] = 'Score';
-$string['search'] = 'Zoek';
-$string['searching'] = 'Zoeken in ...';
-$string['seconds'] = ' seconden ';
-$string['solutions'] = 'Oplossingen';
-$string['statistics'] = 'Statistieken';
-$string['thesewordshelpimproverank'] = 'Deze woorden zijn belangrijk en verhogen de rank';
-$string['thesewordsmustappear'] = 'Deze woorden moeten voorkomen';
-$string['thesewordsmustnotappear'] = 'Deze woorden mogen niet voorkomen';
-$string['title'] = 'Titel';
-$string['tofetchtheseresults'] = 'om deze resultaten op te halen';
-$string['totalsize'] = 'Totale Grootte ';
-$string['type'] = 'Type';
-$string['uncompleteindexingerror'] = 'Het indexeren is niet succesvol beëindigd, probeer het opnieuw te starten.';
-$string['versiontoolow'] = 'Global search heeft helaas PHP versie 5.0.0 of later nodig (op dit moment draai jij versie '.$phpversion.')';
-$string['whichmodulestosearch?'] = 'In welke modules moet er gezocht worden?';
-$string['wordsintitle'] = 'Woorden in de titel';
-?>
index fd3271b72d4f42bc092a0d27312afb07d160f2f5..097d3afe22c7d2e7b9f17c5ff75ff8e86078cbf0 100644 (file)
@@ -8,7 +8,7 @@
 
 
     $lifetime  = 600;                                   // Seconds to cache this stylesheet
-    $nomoodlecookie = true;                             // Cookies prevent caching, so don't use them
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
     require_once("../../config.php");                   // Load up the Moodle libraries
     $themename = basename(dirname(__FILE__));           // Name of the folder we are in
     $forceconfig = optional_param('forceconfig', '', PARAM_FILE);   // Get config from this theme
index 5a4c4df2e565b1abdb2b2377b07ed7a243506af1..f396540a384759017509e56e0f5c4c47bb2c357e 100644 (file)
@@ -1,7 +1,7 @@
 <?PHP /*  $Id$ */
 
 /// We use PHP so we can do value substitutions into the styles
-    $nomoodlecookie = true;
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
 
     require_once("../../config.php");
     $themename = optional_param('themename', NULL, PARAM_SAFEDIR);
diff --git a/theme/cornflower/images/headerbg.jpg b/theme/cornflower/images/headerbg.jpg
deleted file mode 100644 (file)
index 4e6c752..0000000
Binary files a/theme/cornflower/images/headerbg.jpg and /dev/null differ
diff --git a/theme/cornflower/images/logo2.jpg b/theme/cornflower/images/logo2.jpg
deleted file mode 100644 (file)
index c019ff4..0000000
Binary files a/theme/cornflower/images/logo2.jpg and /dev/null differ
index bd329f640b53a699e0b3f7d77b02a5ce9725bce6..61ff453952e1be41f445ba65de95f6d00abe6902 100644 (file)
@@ -8,7 +8,7 @@
 
 
     $lifetime  = 600;                                   // Seconds to cache this stylesheet
-    $nomoodlecookie = true;                             // Cookies prevent caching, so don't use them
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
     require_once("../../config.php");                   // Load up the Moodle libraries
     $themename = basename(dirname(__FILE__));           // Name of the folder we are in
     $forceconfig = optional_param('forceconfig', '', PARAM_FILE);   // Get config from this theme
diff --git a/theme/custom_corners/js/jquery-latest.pack.js b/theme/custom_corners/js/jquery-latest.pack.js
deleted file mode 100644 (file)
index b52712d..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * jQuery 1.2.2 - New Wave Javascript
- *
- * Copyright (c) 2007 John Resig (jquery.com)
- * Dual licensed under the MIT (MIT-LICENSE.txt)
- * and GPL (GPL-LICENSE.txt) licenses.
- *
- * $Date$
- * $Rev: 4454 $
- */
-eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(J(){7(1e.19)L w=1e.19;L E=1e.19=J(a,b){K 1D E.2m.4Y(a,b)};7(1e.$)L D=1e.$;1e.$=E;L u=/^[^<]*(<(.|\\s)+>)[^>]*$|^#(\\w+)$/;L G=/^.[^:#\\[\\.]*$/;E.1i=E.2m={4Y:J(d,b){d=d||T;7(d.15){6[0]=d;6.M=1;K 6}N 7(1v d=="25"){L c=u.39(d);7(c&&(c[1]||!b)){7(c[1])d=E.5c([c[1]],b);N{L a=T.5N(c[3]);7(a)7(a.2s!=c[3])K E().2r(d);N{6[0]=a;6.M=1;K 6}N d=[]}}N K 1D E(b).2r(d)}N 7(E.1q(d))K 1D E(T)[E.1i.21?"21":"43"](d);K 6.6G(d.1n==1N&&d||(d.5j||d.M&&d!=1e&&!d.15&&d[0]!=10&&d[0].15)&&E.2H(d)||[d])},5j:"1.2.2",82:J(){K 6.M},M:0,22:J(a){K a==10?E.2H(6):6[a]},2E:J(b){L a=E(b);a.56=6;K a},6G:J(a){6.M=0;1N.2m.1h.1j(6,a);K 6},V:J(a,b){K E.V(6,a,b)},5E:J(b){L a=-1;6.V(J(i){7(6==b)a=i});K a},1K:J(c,a,b){L d=c;7(c.1n==4d)7(a==10)K 6.M&&E[b||"1K"](6[0],c)||10;N{d={};d[c]=a}K 6.V(J(i){P(c 1r d)E.1K(b?6.Y:6,c,E.1l(6,d[c],b,i,c))})},1m:J(b,a){7((b==\'29\'||b==\'1P\')&&2M(a)<0)a=10;K 6.1K(b,a,"2q")},1t:J(b){7(1v b!="4D"&&b!=W)K 6.4B().3t((6[0]&&6[0].2u||T).5v(b));L a="";E.V(b||6,J(){E.V(6.3p,J(){7(6.15!=8)a+=6.15!=1?6.6M:E.1i.1t([6])})});K a},5r:J(b){7(6[0])E(b,6[0].2u).5J().3n(6[0]).2a(J(){L a=6;2e(a.1B)a=a.1B;K a}).3t(6);K 6},8t:J(a){K 6.V(J(){E(6).6C().5r(a)})},8m:J(a){K 6.V(J(){E(6).5r(a)})},3t:J(){K 6.3P(1a,R,S,J(a){7(6.15==1)6.3k(a)})},6s:J(){K 6.3P(1a,R,R,J(a){7(6.15==1)6.3n(a,6.1B)})},6o:J(){K 6.3P(1a,S,S,J(a){6.1b.3n(a,6)})},5a:J(){K 6.3P(1a,S,R,J(a){6.1b.3n(a,6.2J)})},3h:J(){K 6.56||E([])},2r:J(b){L c=E.2a(6,J(a){K E.2r(b,a)});K 6.2E(/[^+>] [^+>]/.17(b)||b.1g("..")>-1?E.57(c):c)},5J:J(e){L f=6.2a(J(){7(E.14.1d&&!E.3W(6)){L a=6.6c(R),5u=T.2R("1u"),4T=T.2R("1u");5u.3k(a);4T.38=5u.38;K 4T.1B}N K 6.6c(R)});L d=f.2r("*").4R().V(J(){7(6[F]!=10)6[F]=W});7(e===R)6.2r("*").4R().V(J(i){7(6.15==3)K;L c=E.Q(6,"2N");P(L a 1r c)P(L b 1r c[a])E.16.1c(d[i],a,c[a][b],c[a][b].Q)});K f},1F:J(b){K 6.2E(E.1q(b)&&E.3x(6,J(a,i){K b.1O(a,i)})||E.3d(b,6))},4I:J(b){7(b.1n==4d)7(G.17(b))K 6.2E(E.3d(b,6,R));N b=E.3d(b,6);L a=b.M&&b[b.M-1]!==10&&!b.15;K 6.1F(J(){K a?E.35(6,b)<0:6!=b})},1c:J(a){K!a?6:6.2E(E.34(6.22(),a.1n==4d?E(a).22():a.M!=10&&(!a.12||E.12(a,"3i"))?a:[a]))},3K:J(a){K a?E.3d(a,6).M>0:S},7g:J(a){K 6.3K("."+a)},5P:J(b){7(b==10){7(6.M){L c=6[0];7(E.12(c,"2y")){L e=c.44,5L=[],11=c.11,30=c.U=="2y-30";7(e<0)K W;P(L i=30?e:0,2b=30?e+1:11.M;i<2b;i++){L d=11[i];7(d.2p){b=E.14.1d&&!d.9s.1C.9o?d.1t:d.1C;7(30)K b;5L.1h(b)}}K 5L}N K(6[0].1C||"").1p(/\\r/g,"")}K 10}K 6.V(J(){7(6.15!=1)K;7(b.1n==1N&&/5w|5y/.17(6.U))6.3o=(E.35(6.1C,b)>=0||E.35(6.37,b)>=0);N 7(E.12(6,"2y")){L a=b.1n==1N?b:[b];E("90",6).V(J(){6.2p=(E.35(6.1C,a)>=0||E.35(6.1t,a)>=0)});7(!a.M)6.44=-1}N 6.1C=b})},3q:J(a){K a==10?(6.M?6[0].38:W):6.4B().3t(a)},6P:J(a){K 6.5a(a).1Y()},6N:J(i){K 6.2V(i,i+1)},2V:J(){K 6.2E(1N.2m.2V.1j(6,1a))},2a:J(b){K 6.2E(E.2a(6,J(a,i){K b.1O(a,i,a)}))},4R:J(){K 6.1c(6.56)},3P:J(g,f,h,d){L e=6.M>1,3m;K 6.V(J(){7(!3m){3m=E.5c(g,6.2u);7(h)3m.8I()}L b=6;7(f&&E.12(6,"1V")&&E.12(3m[0],"4x"))b=6.3V("1S")[0]||6.3k(6.2u.2R("1S"));L c=E([]);E.V(3m,J(){L a=e?E(6).5J(R)[0]:6;7(E.12(a,"1o")){c=c.1c(a)}N{7(a.15==1)c=c.1c(E("1o",a).1Y());d.1O(b,a)}});c.V(6D)})}};E.2m.4Y.2m=E.2m;J 6D(i,a){7(a.3R)E.3Q({1f:a.3R,3l:S,1G:"1o"});N E.5l(a.1t||a.6A||a.38||"");7(a.1b)a.1b.2X(a)}E.1s=E.1i.1s=J(){L b=1a[0]||{},i=1,M=1a.M,5i=S,11;7(b.1n==8f){5i=b;b=1a[1]||{};i=2}7(1v b!="4D"&&1v b!="J")b={};7(M==1){b=6;i=0}P(;i<M;i++)7((11=1a[i])!=W)P(L a 1r 11){7(b===11[a])6z;7(5i&&11[a]&&1v 11[a]=="4D"&&b[a]&&!11[a].15)b[a]=E.1s(b[a],11[a]);N 7(11[a]!=10)b[a]=11[a]}K b};L F="19"+(1D 3O()).3N(),6y=0,5e={};L H=/z-?5E|89-?87|1y|6q|85-?1P/i;E.1s({81:J(a){1e.$=D;7(a)1e.19=w;K E},1q:J(a){K!!a&&1v a!="25"&&!a.12&&a.1n!=1N&&/J/i.17(a+"")},3W:J(a){K a.1I&&!a.1k||a.28&&a.2u&&!a.2u.1k},5l:J(a){a=E.3f(a);7(a){L b=T.3V("6k")[0]||T.1I,1o=T.2R("1o");1o.U="1t/4l";7(E.14.1d)1o.1t=a;N 1o.3k(T.5v(a));b.3k(1o);b.2X(1o)}},12:J(b,a){K b.12&&b.12.2F()==a.2F()},1Q:{},Q:J(c,d,b){c=c==1e?5e:c;L a=c[F];7(!a)a=c[F]=++6y;7(d&&!E.1Q[a])E.1Q[a]={};7(b!=10)E.1Q[a][d]=b;K d?E.1Q[a][d]:a},3H:J(c,b){c=c==1e?5e:c;L a=c[F];7(b){7(E.1Q[a]){2T E.1Q[a][b];b="";P(b 1r E.1Q[a])1T;7(!b)E.3H(c)}}N{1R{2T c[F]}1W(e){7(c.55)c.55(F)}2T E.1Q[a]}},V:J(c,a,b){7(b){7(c.M==10){P(L d 1r c)7(a.1j(c[d],b)===S)1T}N P(L i=0,M=c.M;i<M;i++)7(a.1j(c[i],b)===S)1T}N{7(c.M==10){P(L d 1r c)7(a.1O(c[d],d,c[d])===S)1T}N P(L i=0,M=c.M,1C=c[0];i<M&&a.1O(1C,i,1C)!==S;1C=c[++i]){}}K c},1l:J(b,a,c,i,d){7(E.1q(a))a=a.1O(b,i);K a&&a.1n==53&&c=="2q"&&!H.17(d)?a+"2P":a},1w:{1c:J(c,b){E.V((b||"").2d(/\\s+/),J(i,a){7(c.15==1&&!E.1w.3E(c.1w,a))c.1w+=(c.1w?" ":"")+a})},1Y:J(c,b){7(c.15==1)c.1w=b!=10?E.3x(c.1w.2d(/\\s+/),J(a){K!E.1w.3E(b,a)}).6g(" "):""},3E:J(b,a){K E.35(a,(b.1w||b).3D().2d(/\\s+/))>-1}},6e:J(b,c,a){L e={};P(L d 1r c){e[d]=b.Y[d];b.Y[d]=c[d]}a.1O(b);P(L d 1r c)b.Y[d]=e[d]},1m:J(d,e,c){7(e=="29"||e=="1P"){L b,3S={3C:"4Z",4X:"23",18:"3u"},3r=e=="29"?["7P","7M"]:["7L","7K"];J 4S(){b=e=="29"?d.7J:d.7I;L a=0,3a=0;E.V(3r,J(){a+=2M(E.2q(d,"7H"+6,R))||0;3a+=2M(E.2q(d,"3a"+6+"62",R))||0});b-=1Z.7E(a+3a)}7(E(d).3K(":4b"))4S();N E.6e(d,3S,4S);K 1Z.2b(0,b)}K E.2q(d,e,c)},2q:J(e,k,j){L d;J 3y(b){7(!E.14.26)K S;L a=T.4a.4L(b,W);K!a||a.4K("3y")==""}7(k=="1y"&&E.14.1d){d=E.1K(e.Y,"1y");K d==""?"1":d}7(E.14.2B&&k=="18"){L c=e.Y.18;e.Y.18="3u";e.Y.18=c}7(k.1E(/4c/i))k=y;7(!j&&e.Y&&e.Y[k])d=e.Y[k];N 7(T.4a&&T.4a.4L){7(k.1E(/4c/i))k="4c";k=k.1p(/([A-Z])/g,"-$1").2w();L h=T.4a.4L(e,W);7(h&&!3y(e))d=h.4K(k);N{L f=[],2L=[];P(L a=e;a&&3y(a);a=a.1b)2L.4U(a);P(L i=0;i<2L.M;i++)7(3y(2L[i])){f[i]=2L[i].Y.18;2L[i].Y.18="3u"}d=k=="18"&&f[2L.M-1]!=W?"2D":(h&&h.4K(k))||"";P(L i=0;i<f.M;i++)7(f[i]!=W)2L[i].Y.18=f[i]}7(k=="1y"&&d=="")d="1"}N 7(e.4j){L g=k.1p(/\\-(\\w)/g,J(a,b){K b.2F()});d=e.4j[k]||e.4j[g];7(!/^\\d+(2P)?$/i.17(d)&&/^\\d/.17(d)){L l=e.Y.2c,3A=e.3A.2c;e.3A.2c=e.4j.2c;e.Y.2c=d||0;d=e.Y.7l+"2P";e.Y.2c=l;e.3A.2c=3A}}K d},5c:J(l,h){L k=[];h=h||T;7(1v h.2R==\'10\')h=h.2u||h[0]&&h[0].2u||T;E.V(l,J(i,d){7(!d)K;7(d.1n==53)d=d.3D();7(1v d=="25"){d=d.1p(/(<(\\w+)[^>]*?)\\/>/g,J(b,a,c){K c.1E(/^(7k|7h|5Q|7f|48|5O|a3|3v|9Y|9W|9T)$/i)?b:a+"></"+c+">"});L f=E.3f(d).2w(),1u=h.2R("1u");L e=!f.1g("<9R")&&[1,"<2y 78=\'78\'>","</2y>"]||!f.1g("<9O")&&[1,"<77>","</77>"]||f.1E(/^<(9K|1S|9I|9F|9A)/)&&[1,"<1V>","</1V>"]||!f.1g("<4x")&&[2,"<1V><1S>","</1S></1V>"]||(!f.1g("<9y")||!f.1g("<9v"))&&[3,"<1V><1S><4x>","</4x></1S></1V>"]||!f.1g("<5Q")&&[2,"<1V><1S></1S><76>","</76></1V>"]||E.14.1d&&[1,"1u<1u>","</1u>"]||[0,"",""];1u.38=e[1]+d+e[2];2e(e[0]--)1u=1u.5D;7(E.14.1d){L g=!f.1g("<1V")&&f.1g("<1S")<0?1u.1B&&1u.1B.3p:e[1]=="<1V>"&&f.1g("<1S")<0?1u.3p:[];P(L j=g.M-1;j>=0;--j)7(E.12(g[j],"1S")&&!g[j].3p.M)g[j].1b.2X(g[j]);7(/^\\s/.17(d))1u.3n(h.5v(d.1E(/^\\s*/)[0]),1u.1B)}d=E.2H(1u.3p)}7(d.M===0&&(!E.12(d,"3i")&&!E.12(d,"2y")))K;7(d[0]==10||E.12(d,"3i")||d.11)k.1h(d);N k=E.34(k,d)});K k},1K:J(d,e,c){7(!d||d.15==3||d.15==8)K 10;L f=E.3W(d)?{}:E.3S;7(e=="2p"&&E.14.26)d.1b.44;7(f[e]){7(c!=10)d[f[e]]=c;K d[f[e]]}N 7(E.14.1d&&e=="Y")K E.1K(d.Y,"9r",c);N 7(c==10&&E.14.1d&&E.12(d,"3i")&&(e=="9q"||e=="9p"))K d.9n(e).6M;N 7(d.28){7(c!=10){7(e=="U"&&E.12(d,"48")&&d.1b)6Z"U 9i 9g\'t 9b 9a";d.99(e,""+c)}7(E.14.1d&&/6T|3R/.17(e)&&!E.3W(d))K d.4z(e,2);K d.4z(e)}N{7(e=="1y"&&E.14.1d){7(c!=10){d.6q=1;d.1F=(d.1F||"").1p(/6W\\([^)]*\\)/,"")+(2M(c).3D()=="93"?"":"6W(1y="+c*6S+")")}K d.1F&&d.1F.1g("1y=")>=0?(2M(d.1F.1E(/1y=([^)]*)/)[1])/6S).3D():""}e=e.1p(/-([a-z])/92,J(a,b){K b.2F()});7(c!=10)d[e]=c;K d[e]}},3f:J(a){K(a||"").1p(/^\\s+|\\s+$/g,"")},2H:J(b){L a=[];7(1v b!="91")P(L i=0,M=b.M;i<M;i++)a.1h(b[i]);N a=b.2V(0);K a},35:J(b,a){P(L i=0,M=a.M;i<M;i++)7(a[i]==b)K i;K-1},34:J(a,b){7(E.14.1d){P(L i=0;b[i];i++)7(b[i].15!=8)a.1h(b[i])}N P(L i=0;b[i];i++)a.1h(b[i]);K a},57:J(a){L c=[],2j={};1R{P(L i=0,M=a.M;i<M;i++){L b=E.Q(a[i]);7(!2j[b]){2j[b]=R;c.1h(a[i])}}}1W(e){c=a}K c},3x:J(c,a,d){7(1v a=="25")a=4A("S||J(a,i){K "+a+"}");L b=[];P(L i=0,M=c.M;i<M;i++)7(!d&&a(c[i],i)||d&&!a(c[i],i))b.1h(c[i]);K b},2a:J(d,a){L c=[];P(L i=0,M=d.M;i<M;i++){L b=a(d[i],i);7(b!==W&&b!=10){7(b.1n!=1N)b=[b];c=c.6Q(b)}}K c}});L v=8X.8V.2w();E.14={5n:(v.1E(/.+(?:8R|8Q|8P|8O)[\\/: ]([\\d.]+)/)||[])[1],26:/6L/.17(v),2B:/2B/.17(v),1d:/1d/.17(v)&&!/2B/.17(v),3X:/3X/.17(v)&&!/(8M|6L)/.17(v)};L y=E.14.1d?"6K":"6J";E.1s({8J:!E.14.1d||T.6I=="6H",3S:{"P":"8G","8E":"1w","4c":y,6J:y,6K:y,38:"38",1w:"1w",1C:"1C",2W:"2W",3o:"3o",8C:"8B",2p:"2p",8A:"8z",44:"44",6F:"6F",28:"28",12:"12"}});E.V({6E:"O.1b",8y:"19.4w(O,\'1b\')",8x:"19.31(O,2,\'2J\')",8w:"19.31(O,2,\'4v\')",8v:"19.4w(O,\'2J\')",8u:"19.4w(O,\'4v\')",8s:"19.5m(O.1b.1B,O)",8r:"19.5m(O.1B)",6C:"19.12(O,\'8q\')?O.8p||O.8o.T:19.2H(O.3p)"},J(c,d){d=4A("S||J(O){K "+d+"}");E.1i[c]=J(b){L a=E.2a(6,d);7(b&&1v b=="25")a=E.3d(b,a);K 6.2E(E.57(a))}});E.V({6B:"3t",8n:"6s",3n:"6o",8l:"5a",8k:"6P"},J(c,b){E.1i[c]=J(){L a=1a;K 6.V(J(){P(L i=0,M=a.M;i<M;i++)E(a[i])[b](6)})}});E.V({8j:J(a){E.1K(6,a,"");7(6.15==1)6.55(a)},8i:J(a){E.1w.1c(6,a)},8h:J(a){E.1w.1Y(6,a)},8g:J(a){E.1w[E.1w.3E(6,a)?"1Y":"1c"](6,a)},1Y:J(a){7(!a||E.1F(a,[6]).r.M){E("*",6).1c(6).V(J(){E.16.1Y(6);E.3H(6)});7(6.1b)6.1b.2X(6)}},4B:J(){E(">*",6).1Y();2e(6.1B)6.2X(6.1B)}},J(a,b){E.1i[a]=J(){K 6.V(b,1a)}});E.V(["8e","62"],J(i,c){L b=c.2w();E.1i[b]=J(a){K 6[0]==1e?E.14.2B&&T.1k["5h"+c]||E.14.26&&1e["8d"+c]||T.6I=="6H"&&T.1I["5h"+c]||T.1k["5h"+c]:6[0]==T?1Z.2b(1Z.2b(T.1k["5g"+c],T.1I["5g"+c]),1Z.2b(T.1k["5f"+c],T.1I["5f"+c])):a==10?(6.M?E.1m(6[0],b):W):6.1m(b,a.1n==4d?a:a+"2P")}});L C=E.14.26&&4t(E.14.5n)<8c?"(?:[\\\\w*4s-]|\\\\\\\\.)":"(?:[\\\\w\\8b-\\8a*4s-]|\\\\\\\\.)",6w=1D 4r("^>\\\\s*("+C+"+)"),6v=1D 4r("^("+C+"+)(#)("+C+"+)"),6u=1D 4r("^([#.]?)("+C+"*)");E.1s({5d:{"":"m[2]==\'*\'||19.12(a,m[2])","#":"a.4z(\'2s\')==m[2]",":":{88:"i<m[3]-0",86:"i>m[3]-0",31:"m[3]-0==i",6N:"m[3]-0==i",3j:"i==0",3M:"i==r.M-1",6r:"i%2==0",6p:"i%2","3j-4m":"a.1b.3V(\'*\')[0]==a","3M-4m":"19.31(a.1b.5D,1,\'4v\')==a","84-4m":"!19.31(a.1b.5D,2,\'4v\')",6E:"a.1B",4B:"!a.1B",83:"(a.6A||a.80||19(a).1t()||\'\').1g(m[3])>=0",4b:\'"23"!=a.U&&19.1m(a,"18")!="2D"&&19.1m(a,"4X")!="23"\',23:\'"23"==a.U||19.1m(a,"18")=="2D"||19.1m(a,"4X")=="23"\',7Y:"!a.2W",2W:"a.2W",3o:"a.3o",2p:"a.2p||19.1K(a,\'2p\')",1t:"\'1t\'==a.U",5w:"\'5w\'==a.U",5y:"\'5y\'==a.U",5b:"\'5b\'==a.U",3J:"\'3J\'==a.U",59:"\'59\'==a.U",6n:"\'6n\'==a.U",6m:"\'6m\'==a.U",2G:\'"2G"==a.U||19.12(a,"2G")\',48:"/48|2y|6l|2G/i.17(a.12)",3E:"19.2r(m[3],a).M",7X:"/h\\\\d/i.17(a.12)",7W:"19.3x(19.3I,J(1i){K a==1i.O;}).M"}},6j:[/^(\\[) *@?([\\w-]+) *([!*$^~=]*) *(\'?"?)(.*?)\\4 *\\]/,/^(:)([\\w-]+)\\("?\'?(.*?(\\(.*?\\))?[^(]*?)"?\'?\\)/,1D 4r("^([:.#]*)("+C+"+)")],3d:J(a,c,b){L d,2o=[];2e(a&&a!=d){d=a;L f=E.1F(a,c,b);a=f.t.1p(/^\\s*,\\s*/,"");2o=b?c=f.r:E.34(2o,f.r)}K 2o},2r:J(t,p){7(1v t!="25")K[t];7(p&&p.15!=1&&p.15!=9)K[];p=p||T;L d=[p],2j=[],3M,12;2e(t&&3M!=t){L r=[];3M=t;t=E.3f(t);L o=S;L g=6w;L m=g.39(t);7(m){12=m[1].2F();P(L i=0;d[i];i++)P(L c=d[i].1B;c;c=c.2J)7(c.15==1&&(12=="*"||c.12.2F()==12))r.1h(c);d=r;t=t.1p(g,"");7(t.1g(" ")==0)6z;o=R}N{g=/^([>+~])\\s*(\\w*)/i;7((m=g.39(t))!=W){r=[];L l={};12=m[2].2F();m=m[1];P(L j=0,3g=d.M;j<3g;j++){L n=m=="~"||m=="+"?d[j].2J:d[j].1B;P(;n;n=n.2J)7(n.15==1){L h=E.Q(n);7(m=="~"&&l[h])1T;7(!12||n.12.2F()==12){7(m=="~")l[h]=R;r.1h(n)}7(m=="+")1T}}d=r;t=E.3f(t.1p(g,""));o=R}}7(t&&!o){7(!t.1g(",")){7(p==d[0])d.4k();2j=E.34(2j,d);r=d=[p];t=" "+t.6i(1,t.M)}N{L k=6v;L m=k.39(t);7(m){m=[0,m[2],m[3],m[1]]}N{k=6u;m=k.39(t)}m[2]=m[2].1p(/\\\\/g,"");L f=d[d.M-1];7(m[1]=="#"&&f&&f.5N&&!E.3W(f)){L q=f.5N(m[2]);7((E.14.1d||E.14.2B)&&q&&1v q.2s=="25"&&q.2s!=m[2])q=E(\'[@2s="\'+m[2]+\'"]\',f)[0];d=r=q&&(!m[3]||E.12(q,m[3]))?[q]:[]}N{P(L i=0;d[i];i++){L a=m[1]=="#"&&m[3]?m[3]:m[1]!=""||m[0]==""?"*":m[2];7(a=="*"&&d[i].12.2w()=="4D")a="3v";r=E.34(r,d[i].3V(a))}7(m[1]==".")r=E.58(r,m[2]);7(m[1]=="#"){L e=[];P(L i=0;r[i];i++)7(r[i].4z("2s")==m[2]){e=[r[i]];1T}r=e}d=r}t=t.1p(k,"")}}7(t){L b=E.1F(t,r);d=r=b.r;t=E.3f(b.t)}}7(t)d=[];7(d&&p==d[0])d.4k();2j=E.34(2j,d);K 2j},58:J(r,m,a){m=" "+m+" ";L c=[];P(L i=0;r[i];i++){L b=(" "+r[i].1w+" ").1g(m)>=0;7(!a&&b||a&&!b)c.1h(r[i])}K c},1F:J(t,r,h){L d;2e(t&&t!=d){d=t;L p=E.6j,m;P(L i=0;p[i];i++){m=p[i].39(t);7(m){t=t.7V(m[0].M);m[2]=m[2].1p(/\\\\/g,"");1T}}7(!m)1T;7(m[1]==":"&&m[2]=="4I")r=G.17(m[3])?E.1F(m[3],r,R).r:E(r).4I(m[3]);N 7(m[1]==".")r=E.58(r,m[2],h);N 7(m[1]=="["){L g=[],U=m[3];P(L i=0,3g=r.M;i<3g;i++){L a=r[i],z=a[E.3S[m[2]]||m[2]];7(z==W||/6T|3R|2p/.17(m[2]))z=E.1K(a,m[2])||\'\';7((U==""&&!!z||U=="="&&z==m[5]||U=="!="&&z!=m[5]||U=="^="&&z&&!z.1g(m[5])||U=="$="&&z.6i(z.M-m[5].M)==m[5]||(U=="*="||U=="~=")&&z.1g(m[5])>=0)^h)g.1h(a)}r=g}N 7(m[1]==":"&&m[2]=="31-4m"){L e={},g=[],17=/(-?)(\\d*)n((?:\\+|-)?\\d*)/.39(m[3]=="6r"&&"2n"||m[3]=="6p"&&"2n+1"||!/\\D/.17(m[3])&&"7U+"+m[3]||m[3]),3j=(17[1]+(17[2]||1))-0,d=17[3]-0;P(L i=0,3g=r.M;i<3g;i++){L j=r[i],1b=j.1b,2s=E.Q(1b);7(!e[2s]){L c=1;P(L n=1b.1B;n;n=n.2J)7(n.15==1)n.4p=c++;e[2s]=R}L b=S;7(3j==0){7(j.4p==d)b=R}N 7((j.4p-d)%3j==0&&(j.4p-d)/3j>=0)b=R;7(b^h)g.1h(j)}r=g}N{L f=E.5d[m[1]];7(1v f!="25")f=E.5d[m[1]][m[2]];f=4A("S||J(a,i){K "+f+"}");r=E.3x(r,f,h)}}K{r:r,t:t}},4w:J(b,c){L d=[];L a=b[c];2e(a&&a!=T){7(a.15==1)d.1h(a);a=a[c]}K d},31:J(a,e,c,b){e=e||1;L d=0;P(;a;a=a[c])7(a.15==1&&++d==e)1T;K a},5m:J(n,a){L r=[];P(;n;n=n.2J){7(n.15==1&&(!a||n!=a))r.1h(n)}K r}});E.16={1c:J(f,i,g,e){7(f.15==3||f.15==8)K;7(E.14.1d&&f.54!=10)f=1e;7(!g.2A)g.2A=6.2A++;7(e!=10){L h=g;g=J(){K h.1j(6,1a)};g.Q=e;g.2A=h.2A}L j=E.Q(f,"2N")||E.Q(f,"2N",{}),1x=E.Q(f,"1x")||E.Q(f,"1x",J(){L a;7(1v E=="10"||E.16.52)K a;a=E.16.1x.1j(1a.3G.O,1a);K a});1x.O=f;E.V(i.2d(/\\s+/),J(c,b){L a=b.2d(".");b=a[0];g.U=a[1];L d=j[b];7(!d){d=j[b]={};7(!E.16.2l[b]||E.16.2l[b].4i.1O(f)===S){7(f.3F)f.3F(b,1x,S);N 7(f.6h)f.6h("4h"+b,1x)}}d[g.2A]=g;E.16.2g[b]=R});f=W},2A:1,2g:{},1Y:J(e,h,f){7(e.15==3||e.15==8)K;L i=E.Q(e,"2N"),2f,5E;7(i){7(h==10)P(L g 1r i)6.1Y(e,g);N{7(h.U){f=h.2k;h=h.U}E.V(h.2d(/\\s+/),J(b,a){L c=a.2d(".");a=c[0];7(i[a]){7(f)2T i[a][f.2A];N P(f 1r i[a])7(!c[1]||i[a][f].U==c[1])2T i[a][f];P(2f 1r i[a])1T;7(!2f){7(!E.16.2l[a]||E.16.2l[a].4g.1O(e)===S){7(e.6f)e.6f(a,E.Q(e,"1x"),S);N 7(e.6d)e.6d("4h"+a,E.Q(e,"1x"))}2f=W;2T i[a]}}})}P(2f 1r i)1T;7(!2f){L d=E.Q(e,"1x");7(d)d.O=W;E.3H(e,"2N");E.3H(e,"1x")}}},1U:J(f,b,c,d,g){b=E.2H(b||[]);7(!c){7(6.2g[f])E("*").1c([1e,T]).1U(f,b)}N{7(c.15==3||c.15==8)K 10;L a,2f,1i=E.1q(c[f]||W),16=!b[0]||!b[0].32;7(16)b.4U(6.51({U:f,2K:c}));b[0].U=f;7(E.1q(E.Q(c,"1x")))a=E.Q(c,"1x").1j(c,b);7(!1i&&c["4h"+f]&&c["4h"+f].1j(c,b)===S)a=S;7(16)b.4k();7(g&&E.1q(g)){2f=g.1j(c,a==W?b:b.6Q(a));7(2f!==10)a=2f}7(1i&&d!==S&&a!==S&&!(E.12(c,\'a\')&&f=="50")){6.52=R;1R{c[f]()}1W(e){}}6.52=S}K a},1x:J(c){L a;c=E.16.51(c||1e.16||{});L b=c.U.2d(".");c.U=b[0];L f=E.Q(6,"2N")&&E.Q(6,"2N")[c.U],3B=1N.2m.2V.1O(1a,1);3B.4U(c);P(L j 1r f){L d=f[j];3B[0].2k=d;3B[0].Q=d.Q;7(!b[1]||d.U==b[1]){L e=d.1j(6,3B);7(a!==S)a=e;7(e===S){c.32();c.41()}}}7(E.14.1d)c.2K=c.32=c.41=c.2k=c.Q=W;K a},51:J(c){L a=c;c=E.1s({},a);c.32=J(){7(a.32)a.32();a.7T=S};c.41=J(){7(a.41)a.41();a.7S=R};7(!c.2K)c.2K=c.7R||T;7(c.2K.15==3)c.2K=a.2K.1b;7(!c.4W&&c.4V)c.4W=c.4V==c.2K?c.7Q:c.4V;7(c.6b==W&&c.6a!=W){L b=T.1I,1k=T.1k;c.6b=c.6a+(b&&b.2i||1k&&1k.2i||0)-(b.68||0);c.7O=c.7N+(b&&b.2x||1k&&1k.2x||0)-(b.67||0)}7(!c.3r&&((c.4f||c.4f===0)?c.4f:c.66))c.3r=c.4f||c.66;7(!c.65&&c.64)c.65=c.64;7(!c.3r&&c.2G)c.3r=(c.2G&1?1:(c.2G&2?3:(c.2G&4?2:0)));K c},2l:{21:{4i:J(){5A();K},4g:J(){K}},47:{4i:J(){7(E.14.1d)K S;E(6).2z("4Q",E.16.2l.47.2k);K R},4g:J(){7(E.14.1d)K S;E(6).42("4Q",E.16.2l.47.2k);K R},2k:J(a){7(I(a,6))K R;1a[0].U="47";K E.16.1x.1j(6,1a)}},46:{4i:J(){7(E.14.1d)K S;E(6).2z("4P",E.16.2l.46.2k);K R},4g:J(){7(E.14.1d)K S;E(6).42("4P",E.16.2l.46.2k);K R},2k:J(a){7(I(a,6))K R;1a[0].U="46";K E.16.1x.1j(6,1a)}}}};E.1i.1s({2z:J(c,a,b){K c=="4O"?6.30(c,a,b):6.V(J(){E.16.1c(6,c,b||a,b&&a)})},30:J(d,b,c){K 6.V(J(){E.16.1c(6,d,J(a){E(6).42(a);K(c||b).1j(6,1a)},c&&b)})},42:J(a,b){K 6.V(J(){E.16.1Y(6,a,b)})},1U:J(c,a,b){K 6.V(J(){E.16.1U(c,a,6,R,b)})},63:J(c,a,b){7(6[0])K E.16.1U(c,a,6[0],S,b);K 10},2h:J(){L b=1a;K 6.50(J(a){6.4N=0==6.4N?1:0;a.32();K b[6.4N].1j(6,1a)||S})},7F:J(a,b){K 6.2z(\'47\',a).2z(\'46\',b)},21:J(a){5A();7(E.2Q)a.1O(T,E);N E.3w.1h(J(){K a.1O(6,E)});K 6}});E.1s({2Q:S,3w:[],21:J(){7(!E.2Q){E.2Q=R;7(E.3w){E.V(E.3w,J(){6.1j(T)});E.3w=W}E(T).63("21")}}});L x=S;J 5A(){7(x)K;x=R;7(T.3F&&!E.14.2B)T.3F("61",E.21,S);7(E.14.1d&&1e==3b)(J(){7(E.2Q)K;1R{T.1I.7D("2c")}1W(3e){3z(1a.3G,0);K}E.21()})();7(E.14.2B)T.3F("61",J(){7(E.2Q)K;P(L i=0;i<T.4M.M;i++)7(T.4M[i].2W){3z(1a.3G,0);K}E.21()},S);7(E.14.26){L a;(J(){7(E.2Q)K;7(T.3c!="60"&&T.3c!="1z"){3z(1a.3G,0);K}7(a===10)a=E("Y, 5O[7B=7A]").M;7(T.4M.M!=a){3z(1a.3G,0);K}E.21()})()}E.16.1c(1e,"43",E.21)}E.V(("7z,7y,43,7x,5g,4O,50,7w,"+"7v,7u,7C,4Q,4P,7t,2y,"+"59,7s,7r,7G,3e").2d(","),J(i,b){E.1i[b]=J(a){K a?6.2z(b,a):6.1U(b)}});L I=J(a,c){L b=a.4W;2e(b&&b!=c)1R{b=b.1b}1W(3e){b=c}K b==c};E(1e).2z("4O",J(){E("*").1c(T).42()});E.1i.1s({43:J(g,d,c){7(E.1q(g))K 6.2z("43",g);L e=g.1g(" ");7(e>=0){L i=g.2V(e,g.M);g=g.2V(0,e)}c=c||J(){};L f="4J";7(d)7(E.1q(d)){c=d;d=W}N{d=E.3v(d);f="5Z"}L h=6;E.3Q({1f:g,U:f,1G:"3q",Q:d,1z:J(a,b){7(b=="1X"||b=="5Y")h.3q(i?E("<1u/>").3t(a.4e.1p(/<1o(.|\\s)*?\\/1o>/g,"")).2r(i):a.4e);h.V(c,[a.4e,b,a])}});K 6},7q:J(){K E.3v(6.5X())},5X:J(){K 6.2a(J(){K E.12(6,"3i")?E.2H(6.7p):6}).1F(J(){K 6.37&&!6.2W&&(6.3o||/2y|6l/i.17(6.12)||/1t|23|3J/i.17(6.U))}).2a(J(i,c){L b=E(6).5P();K b==W?W:b.1n==1N?E.2a(b,J(a,i){K{37:c.37,1C:a}}):{37:c.37,1C:b}}).22()}});E.V("5W,5V,5U,69,5T,5S".2d(","),J(i,o){E.1i[o]=J(f){K 6.2z(o,f)}});L B=(1D 3O).3N();E.1s({22:J(d,b,a,c){7(E.1q(b)){a=b;b=W}K E.3Q({U:"4J",1f:d,Q:b,1X:a,1G:c})},7o:J(b,a){K E.22(b,W,a,"1o")},7n:J(c,b,a){K E.22(c,b,a,"2O")},7m:J(d,b,a,c){7(E.1q(b)){a=b;b={}}K E.3Q({U:"5Z",1f:d,Q:b,1X:a,1G:c})},7Z:J(a){E.1s(E.4H,a)},4H:{2g:R,U:"4J",2U:0,5R:"49/x-7j-3i-7i",6x:R,3l:R,Q:W,6t:W,3J:W,4n:{3L:"49/3L, 1t/3L",3q:"1t/3q",1o:"1t/4l, 49/4l",2O:"49/2O, 1t/4l",1t:"1t/7e",4o:"*/*"}},4q:{},3Q:J(s){L f,2Y=/=\\?(&|$)/g,1A,Q;s=E.1s(R,s,E.1s(R,{},E.4H,s));7(s.Q&&s.6x&&1v s.Q!="25")s.Q=E.3v(s.Q);7(s.1G=="4u"){7(s.U.2w()=="22"){7(!s.1f.1E(2Y))s.1f+=(s.1f.1E(/\\?/)?"&":"?")+(s.4u||"7d")+"=?"}N 7(!s.Q||!s.Q.1E(2Y))s.Q=(s.Q?s.Q+"&":"")+(s.4u||"7d")+"=?";s.1G="2O"}7(s.1G=="2O"&&(s.Q&&s.Q.1E(2Y)||s.1f.1E(2Y))){f="4u"+B++;7(s.Q)s.Q=(s.Q+"").1p(2Y,"="+f+"$1");s.1f=s.1f.1p(2Y,"="+f+"$1");s.1G="1o";1e[f]=J(a){Q=a;1X();1z();1e[f]=10;1R{2T 1e[f]}1W(e){}7(h)h.2X(g)}}7(s.1G=="1o"&&s.1Q==W)s.1Q=S;7(s.1Q===S&&s.U.2w()=="22"){L i=(1D 3O()).3N();L j=s.1f.1p(/(\\?|&)4s=.*?(&|$)/,"$a2="+i+"$2");s.1f=j+((j==s.1f)?(s.1f.1E(/\\?/)?"&":"?")+"4s="+i:"")}7(s.Q&&s.U.2w()=="22"){s.1f+=(s.1f.1E(/\\?/)?"&":"?")+s.Q;s.Q=W}7(s.2g&&!E.5M++)E.16.1U("5W");7((!s.1f.1g("9Z")||!s.1f.1g("//"))&&(s.1G=="1o"||s.1G=="2O")&&s.U.2w()=="22"){L h=T.3V("6k")[0];L g=T.2R("1o");g.3R=s.1f;7(s.7c)g.9X=s.7c;7(!f){L l=S;g.9V=g.9U=J(){7(!l&&(!6.3c||6.3c=="60"||6.3c=="1z")){l=R;1X();1z();h.2X(g)}}}h.3k(g);K 10}L m=S;L k=1e.7a?1D 7a("9S.9Q"):1D 79();k.9P(s.U,s.1f,s.3l,s.6t,s.3J);1R{7(s.Q)k.4G("9N-9M",s.5R);7(s.5I)k.4G("9L-5H-9J",E.4q[s.1f]||"9H, 9G 9E 9B 5G:5G:5G 9z");k.4G("X-9x-9u","79");k.4G("9t",s.1G&&s.4n[s.1G]?s.4n[s.1G]+", */*":s.4n.4o)}1W(e){}7(s.75)s.75(k);7(s.2g)E.16.1U("5S",[k,s]);L c=J(a){7(!m&&k&&(k.3c==4||a=="2U")){m=R;7(d){74(d);d=W}1A=a=="2U"&&"2U"||!E.73(k)&&"3e"||s.5I&&E.72(k,s.1f)&&"5Y"||"1X";7(1A=="1X"){1R{Q=E.71(k,s.1G)}1W(e){1A="5C"}}7(1A=="1X"){L b;1R{b=k.5B("70-5H")}1W(e){}7(s.5I&&b)E.4q[s.1f]=b;7(!f)1X()}N E.5t(s,k,1A);1z();7(s.3l)k=W}};7(s.3l){L d=54(c,13);7(s.2U>0)3z(J(){7(k){k.9m();7(!m)c("2U")}},s.2U)}1R{k.9l(s.Q)}1W(e){E.5t(s,k,W,e)}7(!s.3l)c();J 1X(){7(s.1X)s.1X(Q,1A);7(s.2g)E.16.1U("5T",[k,s])}J 1z(){7(s.1z)s.1z(k,1A);7(s.2g)E.16.1U("5U",[k,s]);7(s.2g&&!--E.5M)E.16.1U("5V")}K k},5t:J(s,a,b,e){7(s.3e)s.3e(a,b,e);7(s.2g)E.16.1U("69",[a,s,e])},5M:0,73:J(r){1R{K!r.1A&&9k.9j=="5b:"||(r.1A>=6Y&&r.1A<9h)||r.1A==6X||r.1A==9e||E.14.26&&r.1A==10}1W(e){}K S},72:J(a,c){1R{L b=a.5B("70-5H");K a.1A==6X||b==E.4q[c]||E.14.26&&a.1A==10}1W(e){}K S},71:J(r,b){L c=r.5B("9d-U");L d=b=="3L"||!b&&c&&c.1g("3L")>=0;L a=d?r.9c:r.4e;7(d&&a.1I.28=="5C")6Z"5C";7(b=="1o")E.5l(a);7(b=="2O")a=4A("("+a+")");K a},3v:J(a){L s=[];7(a.1n==1N||a.5j)E.V(a,J(){s.1h(3s(6.37)+"="+3s(6.1C))});N P(L j 1r a)7(a[j]&&a[j].1n==1N)E.V(a[j],J(){s.1h(3s(j)+"="+3s(6))});N s.1h(3s(j)+"="+3s(a[j]));K s.6g("&").1p(/%20/g,"+")}});E.1i.1s({1J:J(c,b){K c?6.27({1P:"1J",29:"1J",1y:"1J"},c,b):6.1F(":23").V(J(){6.Y.18=6.5x||"";7(E.1m(6,"18")=="2D"){L a=E("<"+6.28+" />").6B("1k");6.Y.18=a.1m("18");7(6.Y.18=="2D")6.Y.18="3u";a.1Y()}}).3h()},1H:J(b,a){K b?6.27({1P:"1H",29:"1H",1y:"1H"},b,a):6.1F(":4b").V(J(){6.5x=6.5x||E.1m(6,"18");6.Y.18="2D"}).3h()},6U:E.1i.2h,2h:J(a,b){K E.1q(a)&&E.1q(b)?6.6U(a,b):a?6.27({1P:"2h",29:"2h",1y:"2h"},a,b):6.V(J(){E(6)[E(6).3K(":23")?"1J":"1H"]()})},98:J(b,a){K 6.27({1P:"1J"},b,a)},97:J(b,a){K 6.27({1P:"1H"},b,a)},96:J(b,a){K 6.27({1P:"2h"},b,a)},95:J(b,a){K 6.27({1y:"1J"},b,a)},94:J(b,a){K 6.27({1y:"1H"},b,a)},9f:J(c,a,b){K 6.27({1y:a},c,b)},27:J(l,k,j,h){L i=E.6V(k,j,h);K 6[i.2S===S?"V":"2S"](J(){7(6.15!=1)K S;L g=E.1s({},i);L f=E(6).3K(":23"),4y=6;P(L p 1r l){7(l[p]=="1H"&&f||l[p]=="1J"&&!f)K E.1q(g.1z)&&g.1z.1j(6);7(p=="1P"||p=="29"){g.18=E.1m(6,"18");g.36=6.Y.36}}7(g.36!=W)6.Y.36="23";g.40=E.1s({},l);E.V(l,J(c,a){L e=1D E.2v(4y,g,c);7(/2h|1J|1H/.17(a))e[a=="2h"?f?"1J":"1H":a](l);N{L b=a.3D().1E(/^([+-]=)?([\\d+-.]+)(.*)$/),24=e.2o(R)||0;7(b){L d=2M(b[2]),2C=b[3]||"2P";7(2C!="2P"){4y.Y[c]=(d||1)+2C;24=((d||1)/e.2o(R))*24;4y.Y[c]=24+2C}7(b[1])d=((b[1]=="-="?-1:1)*d)+24;e.3Z(24,d,2C)}N e.3Z(24,a,"")}});K R})},2S:J(a,b){7(E.1q(a)||(a&&a.1n==1N)){b=a;a="2v"}7(!a||(1v a=="25"&&!b))K A(6[0],a);K 6.V(J(){7(b.1n==1N)A(6,a,b);N{A(6,a).1h(b);7(A(6,a).M==1)b.1j(6)}})},8Z:J(b,c){L a=E.3I;7(b)6.2S([]);6.V(J(){P(L i=a.M-1;i>=0;i--)7(a[i].O==6){7(c)a[i](R);a.6R(i,1)}});7(!c)6.5z();K 6}});L A=J(b,c,a){7(!b)K 10;c=c||"2v";L q=E.Q(b,c+"2S");7(!q||a)q=E.Q(b,c+"2S",a?E.2H(a):[]);K q};E.1i.5z=J(a){a=a||"2v";K 6.V(J(){L q=A(6,a);q.4k();7(q.M)q[0].1j(6)})};E.1s({6V:J(b,a,c){L d=b&&b.1n==8Y?b:{1z:c||!c&&a||E.1q(b)&&b,2t:b,3Y:c&&a||a&&a.1n!=8W&&a};d.2t=(d.2t&&d.2t.1n==53?d.2t:{9w:8U,8T:6Y}[d.2t])||8S;d.5o=d.1z;d.1z=J(){7(d.2S!==S)E(6).5z();7(E.1q(d.5o))d.5o.1j(6)};K d},3Y:{6O:J(p,n,b,a){K b+a*p},5F:J(p,n,b,a){K((-1Z.9C(p*1Z.9D)/2)+0.5)*a+b}},3I:[],3T:W,2v:J(b,c,a){6.11=c;6.O=b;6.1l=a;7(!c.3U)c.3U={}}});E.2v.2m={4C:J(){7(6.11.33)6.11.33.1j(6.O,[6.2I,6]);(E.2v.33[6.1l]||E.2v.33.4o)(6);7(6.1l=="1P"||6.1l=="29")6.O.Y.18="3u"},2o:J(a){7(6.O[6.1l]!=W&&6.O.Y[6.1l]==W)K 6.O[6.1l];L r=2M(E.1m(6.O,6.1l,a));K r&&r>-8N?r:2M(E.2q(6.O,6.1l))||0},3Z:J(c,b,d){6.5s=(1D 3O()).3N();6.24=c;6.3h=b;6.2C=d||6.2C||"2P";6.2I=6.24;6.4E=6.4F=0;6.4C();L e=6;J t(a){K e.33(a)}t.O=6.O;E.3I.1h(t);7(E.3T==W){E.3T=54(J(){L a=E.3I;P(L i=0;i<a.M;i++)7(!a[i]())a.6R(i--,1);7(!a.M){74(E.3T);E.3T=W}},13)}},1J:J(){6.11.3U[6.1l]=E.1K(6.O.Y,6.1l);6.11.1J=R;6.3Z(0,6.2o());7(6.1l=="29"||6.1l=="1P")6.O.Y[6.1l]="8L";E(6.O).1J()},1H:J(){6.11.3U[6.1l]=E.1K(6.O.Y,6.1l);6.11.1H=R;6.3Z(6.2o(),0)},33:J(a){L t=(1D 3O()).3N();7(a||t>6.11.2t+6.5s){6.2I=6.3h;6.4E=6.4F=1;6.4C();6.11.40[6.1l]=R;L b=R;P(L i 1r 6.11.40)7(6.11.40[i]!==R)b=S;7(b){7(6.11.18!=W){6.O.Y.36=6.11.36;6.O.Y.18=6.11.18;7(E.1m(6.O,"18")=="2D")6.O.Y.18="3u"}7(6.11.1H)6.O.Y.18="2D";7(6.11.1H||6.11.1J)P(L p 1r 6.11.40)E.1K(6.O.Y,p,6.11.3U[p])}7(b&&E.1q(6.11.1z))6.11.1z.1j(6.O);K S}N{L n=t-6.5s;6.4F=n/6.11.2t;6.4E=E.3Y[6.11.3Y||(E.3Y.5F?"5F":"6O")](6.4F,n,0,1,6.11.2t);6.2I=6.24+((6.3h-6.24)*6.4E);6.4C()}K R}};E.2v.33={2i:J(a){a.O.2i=a.2I},2x:J(a){a.O.2x=a.2I},1y:J(a){E.1K(a.O.Y,"1y",a.2I)},4o:J(a){a.O.Y[a.1l]=a.2I+a.2C}};E.1i.5f=J(){L b=0,3b=0,O=6[0],5q;7(O)8K(E.14){L d=O.1b,45=O,1M=O.1M,1L=O.2u,5p=26&&4t(5n)<8H,2Z=E.1m(O,"3C")=="2Z";7(O.7b){L c=O.7b();1c(c.2c+1Z.2b(1L.1I.2i,1L.1k.2i),c.3b+1Z.2b(1L.1I.2x,1L.1k.2x));1c(-1L.1I.68,-1L.1I.67)}N{1c(O.5k,O.5K);2e(1M){1c(1M.5k,1M.5K);7(3X&&!/^t(8F|d|h)$/i.17(1M.28)||26&&!5p)3a(1M);7(!2Z&&E.1m(1M,"3C")=="2Z")2Z=R;45=/^1k$/i.17(1M.28)?45:1M;1M=1M.1M}2e(d&&d.28&&!/^1k|3q$/i.17(d.28)){7(!/^a0|1V.*$/i.17(E.1m(d,"18")))1c(-d.2i,-d.2x);7(3X&&E.1m(d,"36")!="4b")3a(d);d=d.1b}7((5p&&(2Z||E.1m(45,"3C")=="4Z"))||(3X&&E.1m(45,"3C")!="4Z"))1c(-1L.1k.5k,-1L.1k.5K);7(2Z)1c(1Z.2b(1L.1I.2i,1L.1k.2i),1Z.2b(1L.1I.2x,1L.1k.2x))}5q={3b:3b,2c:b}}J 3a(a){1c(E.2q(a,"a1",R),E.2q(a,"8D",R))}J 1c(l,t){b+=4t(l)||0;3b+=4t(t)||0}K 5q}})();',62,624,'||||||this|if||||||||||||||||||||||||||||||||||||||function|return|var|length|else|elem|for|data|true|false|document|type|each|null||style||undefined|options|nodeName||browser|nodeType|event|test|display|jQuery|arguments|parentNode|add|msie|window|url|indexOf|push|fn|apply|body|prop|css|constructor|script|replace|isFunction|in|extend|text|div|typeof|className|handle|opacity|complete|status|firstChild|value|new|match|filter|dataType|hide|documentElement|show|attr|doc|offsetParent|Array|call|height|cache|try|tbody|break|trigger|table|catch|success|remove|Math||ready|get|hidden|start|string|safari|animate|tagName|width|map|max|left|split|while|ret|global|toggle|scrollLeft|done|handler|special|prototype||cur|selected|curCSS|find|id|duration|ownerDocument|fx|toLowerCase|scrollTop|select|bind|guid|opera|unit|none|pushStack|toUpperCase|button|makeArray|now|nextSibling|target|stack|parseFloat|events|json|px|isReady|createElement|queue|delete|timeout|slice|disabled|removeChild|jsre|fixed|one|nth|preventDefault|step|merge|inArray|overflow|name|innerHTML|exec|border|top|readyState|multiFilter|error|trim|rl|end|form|first|appendChild|async|elems|insertBefore|checked|childNodes|html|which|encodeURIComponent|append|block|param|readyList|grep|color|setTimeout|runtimeStyle|args|position|toString|has|addEventListener|callee|removeData|timers|password|is|xml|last|getTime|Date|domManip|ajax|src|props|timerId|orig|getElementsByTagName|isXMLDoc|mozilla|easing|custom|curAnim|stopPropagation|unbind|load|selectedIndex|offsetChild|mouseleave|mouseenter|input|application|defaultView|visible|float|String|responseText|charCode|teardown|on|setup|currentStyle|shift|javascript|child|accepts|_default|nodeIndex|lastModified|RegExp|_|parseInt|jsonp|previousSibling|dir|tr|self|getAttribute|eval|empty|update|object|pos|state|setRequestHeader|ajaxSettings|not|GET|getPropertyValue|getComputedStyle|styleSheets|lastToggle|unload|mouseout|mouseover|andSelf|getWH|container2|unshift|fromElement|relatedTarget|visibility|init|absolute|click|fix|triggered|Number|setInterval|removeAttribute|prevObject|unique|classFilter|submit|after|file|clean|expr|windowData|offset|scroll|client|deep|jquery|offsetLeft|globalEval|sibling|version|old|safari2|results|wrapAll|startTime|handleError|container|createTextNode|radio|oldblock|checkbox|dequeue|bindReady|getResponseHeader|parsererror|lastChild|index|swing|00|Modified|ifModified|clone|offsetTop|values|active|getElementById|link|val|col|contentType|ajaxSend|ajaxSuccess|ajaxComplete|ajaxStop|ajaxStart|serializeArray|notmodified|POST|loaded|DOMContentLoaded|Width|triggerHandler|ctrlKey|metaKey|keyCode|clientTop|clientLeft|ajaxError|clientX|pageX|cloneNode|detachEvent|swap|removeEventListener|join|attachEvent|substr|parse|head|textarea|reset|image|before|odd|zoom|even|prepend|username|quickClass|quickID|quickChild|processData|uuid|continue|textContent|appendTo|contents|evalScript|parent|defaultValue|setArray|CSS1Compat|compatMode|cssFloat|styleFloat|webkit|nodeValue|eq|linear|replaceWith|concat|splice|100|href|_toggle|speed|alpha|304|200|throw|Last|httpData|httpNotModified|httpSuccess|clearInterval|beforeSend|colgroup|fieldset|multiple|XMLHttpRequest|ActiveXObject|getBoundingClientRect|scriptCharset|callback|plain|img|hasClass|br|urlencoded|www|abbr|pixelLeft|post|getJSON|getScript|elements|serialize|keypress|keydown|change|mouseup|mousedown|dblclick|resize|focus|blur|stylesheet|rel|mousemove|doScroll|round|hover|keyup|padding|offsetHeight|offsetWidth|Bottom|Top|Right|clientY|pageY|Left|toElement|srcElement|cancelBubble|returnValue|0n|substring|animated|header|enabled|ajaxSetup|innerText|noConflict|size|contains|only|line|gt|weight|lt|font|uFFFF|u0128|417|inner|Height|Boolean|toggleClass|removeClass|addClass|removeAttr|replaceAll|insertAfter|wrap|prependTo|contentWindow|contentDocument|iframe|children|siblings|wrapInner|prevAll|nextAll|prev|next|parents|maxLength|maxlength|readOnly|readonly|borderTopWidth|class|able|htmlFor|522|reverse|boxModel|with|1px|compatible|10000|ie|ra|it|rv|400|fast|600|userAgent|Function|navigator|Object|stop|option|array|ig|NaN|fadeOut|fadeIn|slideToggle|slideUp|slideDown|setAttribute|changed|be|responseXML|content|1223|fadeTo|can|300|property|protocol|location|send|abort|getAttributeNode|specified|method|action|cssText|attributes|Accept|With|th|slow|Requested|td|GMT|cap|1970|cos|PI|Jan|colg|01|Thu|tfoot|Since|thead|If|Type|Content|leg|open|XMLHTTP|opt|Microsoft|embed|onreadystatechange|onload|area|charset|hr|http|inline|borderLeftWidth|1_|meta'.split('|'),0,{}))
\ No newline at end of file
diff --git a/theme/custom_corners/js/jquery.php b/theme/custom_corners/js/jquery.php
deleted file mode 100644 (file)
index 7ba8302..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-<script src="<?php echo $CFG->themewww ?>/custom_corners/js/jquery-latest.pack.js" type="text/javascript"></script>
-
-<script type="text/javascript" charset="utf-8">
-/* <![CDATA[ */
-    var script = {
-        
-        corrections: function () {
-            if (top.user) {
-                top.document.getElementsByTagName('frameset')[0].rows = "117,30%,0,200";
-            }
-            
-            // correct some Safari 2 (webkit 419.3) rtl rendering issues 
-            if($.browser.version == '419.3') {
-                if ($('body.dir-rtl').length) {
-                    $('div.bb div,div.bt div').css('left','13px');
-                }
-            }
-            
-            // check for layouttabel and add haslayouttable class to body
-            var layoutTable = $('#layout-table #middle-column');
-            
-            if (layoutTable.length) {
-                $('body').addClass('haslayouttable');
-            } else {
-                $('body').addClass('nolayouttable');
-            }
-            
-            // set a smaller right and left padding on the admin pages
-            // with a htmlarea
-            var htmlarea = $('#adminsettings .form-htmlarea');
-            var docwidth = $(document).width();
-            
-            if (htmlarea.length && (docwidth <= 1024)) {
-                $('#page').css('margin', '0 1%');
-            }
-        },
-        
-        info: function() {
-            $('#infooverlay').text($('body').attr('class'));
-            
-            window.setTimeout(function(){$('#infowrapper').click();}, 4000);
-            $('#infowrapper').toggle(function() {
-                $('#infooverlay').animate({height: 'toggle'}, "fast");
-                $(this).animate({opacity: 0.3}, "fast");
-            }, function() {
-                $('#infooverlay').animate({height: 'toggle'}, "fast");
-                $(this).animate({opacity: 0.9}, "fast");
-            });
-        },
-        
-        init: function() {
-            script.corrections();
-//            script.info();
-        }
-    };
-/* ]]> */
-</script>
\ No newline at end of file
index bf9c29c9cd08cbba4c82b6102e7c361249494d53..b4e33844d7de427b457f93aea2526858139e2b32 100644 (file)
@@ -8,7 +8,7 @@
 
 
     $lifetime  = 600;                                   // Seconds to cache this stylesheet
-    $nomoodlecookie = true;                             // Cookies prevent caching, so don't use them
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
     require_once("../../config.php");                   // Load up the Moodle libraries
     $themename = basename(dirname(__FILE__));           // Name of the folder we are in
     $forceconfig = optional_param('forceconfig', '', PARAM_FILE);   // Get config from this theme
index 296b28d3dff7dd6252705c8d0ccd968857fa0db5..37e75f50812ae8c42fe22b85d7c603e5e29dd120 100644 (file)
@@ -1,7 +1,7 @@
 <?PHP /*  $Id$ */
 
 /// We use PHP so we can do value substitutions into the styles
-    $nomoodlecookie = true;
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
 
     require_once("../../config.php");
     $themename = optional_param('themename', NULL, PARAM_SAFEDIR);
index fd3271b72d4f42bc092a0d27312afb07d160f2f5..097d3afe22c7d2e7b9f17c5ff75ff8e86078cbf0 100644 (file)
@@ -8,7 +8,7 @@
 
 
     $lifetime  = 600;                                   // Seconds to cache this stylesheet
-    $nomoodlecookie = true;                             // Cookies prevent caching, so don't use them
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
     require_once("../../config.php");                   // Load up the Moodle libraries
     $themename = basename(dirname(__FILE__));           // Name of the folder we are in
     $forceconfig = optional_param('forceconfig', '', PARAM_FILE);   // Get config from this theme
index 8359feddec5ba41f3fd0ca267bf034b76dd1f95f..e80d7414854ff6071bb267449af8b12403b32c51 100644 (file)
@@ -8,7 +8,7 @@
 
 
     $lifetime  = 1800;                                  // Seconds to cache this stylesheet
-    $nomoodlecookie = true;                             // Cookies prevent caching, so don't use them
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
     require_once("../../config.php");                   // Load up the Moodle libraries
     $themename = basename(dirname(__FILE__));           // Name of the folder we are in
     $forceconfig = optional_param('forceconfig', '', PARAM_FILE);   // Get config from this theme
index 074d4554ea97f69f0be685663259ffc5e6f08317..09f1cb2e1e561f9b8f5b0688bb44902d6a129a24 100644 (file)
@@ -1,7 +1,7 @@
 <?PHP /*  $Id$ */
 
 /// We use PHP so we can do value substitutions into the styles
-    $nomoodlecookie = true;
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
 
     require_once("../../config.php");
     $themename = optional_param('themename', NULL, PARAM_SAFEDIR);
index fd3271b72d4f42bc092a0d27312afb07d160f2f5..097d3afe22c7d2e7b9f17c5ff75ff8e86078cbf0 100644 (file)
@@ -8,7 +8,7 @@
 
 
     $lifetime  = 600;                                   // Seconds to cache this stylesheet
-    $nomoodlecookie = true;                             // Cookies prevent caching, so don't use them
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
     require_once("../../config.php");                   // Load up the Moodle libraries
     $themename = basename(dirname(__FILE__));           // Name of the folder we are in
     $forceconfig = optional_param('forceconfig', '', PARAM_FILE);   // Get config from this theme
index bb9976e44ecf627209b5771c1bc60c99fb835b4f..251adac59c7ba8fb19bc366f03a6cdb5b917abe3 100644 (file)
@@ -1,7 +1,7 @@
 <?PHP /*  $Id$ */
 
 /// We use PHP so we can do value substitutions into the styles
-    $nomoodlecookie = true;
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
 
     require_once("../../config.php");
     $themename = optional_param('themename', NULL, PARAM_SAFEDIR);
index bd329f640b53a699e0b3f7d77b02a5ce9725bce6..61ff453952e1be41f445ba65de95f6d00abe6902 100644 (file)
@@ -8,7 +8,7 @@
 
 
     $lifetime  = 600;                                   // Seconds to cache this stylesheet
-    $nomoodlecookie = true;                             // Cookies prevent caching, so don't use them
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
     require_once("../../config.php");                   // Load up the Moodle libraries
     $themename = basename(dirname(__FILE__));           // Name of the folder we are in
     $forceconfig = optional_param('forceconfig', '', PARAM_FILE);   // Get config from this theme
index bb9976e44ecf627209b5771c1bc60c99fb835b4f..251adac59c7ba8fb19bc366f03a6cdb5b917abe3 100644 (file)
@@ -1,7 +1,7 @@
 <?PHP /*  $Id$ */
 
 /// We use PHP so we can do value substitutions into the styles
-    $nomoodlecookie = true;
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
 
     require_once("../../config.php");
     $themename = optional_param('themename', NULL, PARAM_SAFEDIR);
index bd329f640b53a699e0b3f7d77b02a5ce9725bce6..61ff453952e1be41f445ba65de95f6d00abe6902 100644 (file)
@@ -8,7 +8,7 @@
 
 
     $lifetime  = 600;                                   // Seconds to cache this stylesheet
-    $nomoodlecookie = true;                             // Cookies prevent caching, so don't use them
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
     require_once("../../config.php");                   // Load up the Moodle libraries
     $themename = basename(dirname(__FILE__));           // Name of the folder we are in
     $forceconfig = optional_param('forceconfig', '', PARAM_FILE);   // Get config from this theme
index 5a4c4df2e565b1abdb2b2377b07ed7a243506af1..f396540a384759017509e56e0f5c4c47bb2c357e 100644 (file)
@@ -1,7 +1,7 @@
 <?PHP /*  $Id$ */
 
 /// We use PHP so we can do value substitutions into the styles
-    $nomoodlecookie = true;
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
 
     require_once("../../config.php");
     $themename = optional_param('themename', NULL, PARAM_SAFEDIR);
index fd3271b72d4f42bc092a0d27312afb07d160f2f5..097d3afe22c7d2e7b9f17c5ff75ff8e86078cbf0 100644 (file)
@@ -8,7 +8,7 @@
 
 
     $lifetime  = 600;                                   // Seconds to cache this stylesheet
-    $nomoodlecookie = true;                             // Cookies prevent caching, so don't use them
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
     require_once("../../config.php");                   // Load up the Moodle libraries
     $themename = basename(dirname(__FILE__));           // Name of the folder we are in
     $forceconfig = optional_param('forceconfig', '', PARAM_FILE);   // Get config from this theme
index 8359feddec5ba41f3fd0ca267bf034b76dd1f95f..e80d7414854ff6071bb267449af8b12403b32c51 100644 (file)
@@ -8,7 +8,7 @@
 
 
     $lifetime  = 1800;                                  // Seconds to cache this stylesheet
-    $nomoodlecookie = true;                             // Cookies prevent caching, so don't use them
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
     require_once("../../config.php");                   // Load up the Moodle libraries
     $themename = basename(dirname(__FILE__));           // Name of the folder we are in
     $forceconfig = optional_param('forceconfig', '', PARAM_FILE);   // Get config from this theme
index 8359feddec5ba41f3fd0ca267bf034b76dd1f95f..e80d7414854ff6071bb267449af8b12403b32c51 100644 (file)
@@ -8,7 +8,7 @@
 
 
     $lifetime  = 1800;                                  // Seconds to cache this stylesheet
-    $nomoodlecookie = true;                             // Cookies prevent caching, so don't use them
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
     require_once("../../config.php");                   // Load up the Moodle libraries
     $themename = basename(dirname(__FILE__));           // Name of the folder we are in
     $forceconfig = optional_param('forceconfig', '', PARAM_FILE);   // Get config from this theme
index 8359feddec5ba41f3fd0ca267bf034b76dd1f95f..e80d7414854ff6071bb267449af8b12403b32c51 100644 (file)
@@ -8,7 +8,7 @@
 
 
     $lifetime  = 1800;                                  // Seconds to cache this stylesheet
-    $nomoodlecookie = true;                             // Cookies prevent caching, so don't use them
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
     require_once("../../config.php");                   // Load up the Moodle libraries
     $themename = basename(dirname(__FILE__));           // Name of the folder we are in
     $forceconfig = optional_param('forceconfig', '', PARAM_FILE);   // Get config from this theme
index 8359feddec5ba41f3fd0ca267bf034b76dd1f95f..e80d7414854ff6071bb267449af8b12403b32c51 100644 (file)
@@ -8,7 +8,7 @@
 
 
     $lifetime  = 1800;                                  // Seconds to cache this stylesheet
-    $nomoodlecookie = true;                             // Cookies prevent caching, so don't use them
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
     require_once("../../config.php");                   // Load up the Moodle libraries
     $themename = basename(dirname(__FILE__));           // Name of the folder we are in
     $forceconfig = optional_param('forceconfig', '', PARAM_FILE);   // Get config from this theme
index 8359feddec5ba41f3fd0ca267bf034b76dd1f95f..e80d7414854ff6071bb267449af8b12403b32c51 100644 (file)
@@ -8,7 +8,7 @@
 
 
     $lifetime  = 1800;                                  // Seconds to cache this stylesheet
-    $nomoodlecookie = true;                             // Cookies prevent caching, so don't use them
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
     require_once("../../config.php");                   // Load up the Moodle libraries
     $themename = basename(dirname(__FILE__));           // Name of the folder we are in
     $forceconfig = optional_param('forceconfig', '', PARAM_FILE);   // Get config from this theme
index 8359feddec5ba41f3fd0ca267bf034b76dd1f95f..e80d7414854ff6071bb267449af8b12403b32c51 100644 (file)
@@ -8,7 +8,7 @@
 
 
     $lifetime  = 1800;                                  // Seconds to cache this stylesheet
-    $nomoodlecookie = true;                             // Cookies prevent caching, so don't use them
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
     require_once("../../config.php");                   // Load up the Moodle libraries
     $themename = basename(dirname(__FILE__));           // Name of the folder we are in
     $forceconfig = optional_param('forceconfig', '', PARAM_FILE);   // Get config from this theme
index d909551eaff4acb8dbe20a2e8db1dcc61f8a9413..00370135c03f5ef170a1002fd82bfedd842bf071 100644 (file)
@@ -3,7 +3,7 @@
       // Syntax:   pix.php/userid/f1.jpg or pix.php/userid/f2.jpg
       //     OR:   ?file=userid/f1.jpg or ?file=userid/f2.jpg
 
-    $nomoodlecookie = true;     // Because it interferes with caching
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
 
     require_once('../config.php');
     require_once($CFG->libdir.'/filelib.php');
index 28aeedcbdcb910782b9a2146c9fee03df0e7c511..f14879b3285824692835e10068d1f40d6741ba52 100644 (file)
@@ -3,7 +3,7 @@
       // Syntax:   pix.php/groupid/f1.jpg or pix.php/groupid/f2.jpg
       //     OR:   ?file=groupid/f1.jpg or ?file=groupid/f2.jpg
 
-    $nomoodlecookie = true;     // Because it interferes with caching
+    define('NO_MOODLE_COOKIES', true);                  // session not used here
 
     require_once('../config.php');
     require_once($CFG->libdir.'/filelib.php');
@@ -28,6 +28,6 @@
         send_file($pathname, $image);
     } else {
         header('HTTP/1.0 404 not found');
-        error(get_string('filenotfound', 'error')); //this is not displayed on IIS??
+        print_error('filenotfound', 'error'); //this is not displayed on IIS??
     }
 ?>