本文整理汇总了PHP中change_field_type函数的典型用法代码示例。如果您正苦于以下问题:PHP change_field_type函数的具体用法?PHP change_field_type怎么用?PHP change_field_type使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了change_field_type函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xmldb_taoresource_upgrade
function xmldb_taoresource_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
/// }
//===== 1.9.0 upgrade line ======//
// change the remoteid key to be non-unique
if ($result && $oldversion < 2007101510) {
$table = new XMLDBTable('taoresource_entry');
$index = new XMLDBIndex('remoteid');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('remoteid'));
if (index_exists($table, $index)) {
$result = $result && drop_index($table, $index);
}
$result = $result && add_index($table, $index);
}
// change the remoteid key to be non-unique
if ($result && $oldversion < 2007101511) {
$table = new XMLDBTable('taoresource_metadata');
$field = new XMLDBField('entry_id');
// change the field type from ext to int
if (field_exists($table, $field)) {
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'id');
$result = $result && change_field_type($table, $field);
}
}
return $result;
}
示例2: xmldb_block_accessibility_upgrade
function xmldb_block_accessibility_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 < 2009082500) {
/// Define field colourscheme to be added to accessibility
$table = new XMLDBTable('accessibility');
$field = new XMLDBField('colourscheme');
$field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, null, 'fontsize');
/// Launch add field colourscheme
$result = $result && add_field($table, $field);
}
if ($result && $oldversion < 2009071000) {
/// Changing type of field fontsize on table accessibility to number
$table = new XMLDBTable('accessibility');
$field = new XMLDBField('fontsize');
$field->setAttributes(XMLDB_TYPE_NUMBER, '4, 1', XMLDB_UNSIGNED, null, null, null, null, null, 'userid');
/// Launch change of type for field fontsize
$result = $result && change_field_type($table, $field);
}
return $result;
}
示例3: xmldb_ezproxy_upgrade
function xmldb_ezproxy_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 < 2009042403) {
/// Rebuild the course cache of every course which uses one of these modules in it to get
/// the new link.
if ($courseids = get_records_menu('ezproxy', '', '', 'course ASC', 'id, course')) {
/// Just get the unique course ID values.
$courseids = array_unique(array_values($courseids));
if (!empty($courseids)) {
require_once $CFG->dirroot . '/course/lib.php';
foreach ($courseids as $courseid) {
rebuild_course_cache($courseid);
// Does not return a bool
}
}
}
}
if ($result && $oldversion < 2009042404) {
$table = new XMLDBTable('ezproxy');
$field = new XMLDBField('serverurl');
$field->setAttributes(XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, '', 'name');
$result = change_field_type($table, $field);
}
return $result;
}
示例4: xmldb_elis_core_upgrade
/**
* ELIS(TM): Enterprise Learning Intelligence Suite
* Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
*
* 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 3 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package elis
* @subpackage core
* @author Remote-Learner.net Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
*
*/
function xmldb_elis_core_upgrade($oldversion = 0)
{
global $CFG, $THEME, $db;
$result = true;
if ($result && $oldversion < 2011030402) {
/***********************************************************************
* Replace plugintype and pluginname with plugin field
**********************************************************************/
/// Define field plugin to be added to elis_scheduled_tasks
$table = new XMLDBTable('elis_scheduled_tasks');
$field = new XMLDBField('plugin');
$field->setAttributes(XMLDB_TYPE_CHAR, '166', null, XMLDB_NOTNULL, null, null, null, null, 'id');
/// Launch add field plugin
$result = $result && add_field($table, $field);
/// Define index plugin_idx (not unique) to be dropped form elis_scheduled_tasks
$index = new XMLDBIndex('plugin_idx');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('plugintype', 'pluginname', 'taskname'));
/// Launch drop index plugin_idx
$result = $result && drop_index($table, $index);
/// Define index plugin_idx (not unique) to be added to elis_scheduled_tasks
$index = new XMLDBIndex('plugin_idx');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('plugin', 'taskname'));
/// Launch add index plugin_idx
$result = $result && add_index($table, $index);
/// Define field plugin to be dropped from elis_scheduled_tasks
$field = new XMLDBField('plugintype');
/// Launch drop field plugin
$result = $result && drop_field($table, $field);
/// Define field plugin to be dropped from elis_scheduled_tasks
$field = new XMLDBField('pluginname');
/// Launch drop field plugin
$result = $result && drop_field($table, $field);
/***********************************************************************
* Change callfunction from text to char
**********************************************************************/
/// Changing type of field callfunction on table elis_scheduled_tasks to char
$field = new XMLDBField('callfunction');
$field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'callfile');
/// Launch change of type for field callfunction
$result = $result && change_field_type($table, $field);
}
if ($result && $oldversion < 2011030403) {
/// Define field startdate to be added to elis_scheduled_tasks
$table = new XMLDBTable('elis_scheduled_tasks');
$field = new XMLDBField('startdate');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'runsremaining');
/// Launch add field startdate
$result = $result && add_field($table, $field);
}
return $result;
}
示例5: xmldb_bookmarks_upgrade
function xmldb_bookmarks_upgrade($oldversion = 0)
{
global $CFG, $THEME, $db;
$result = true;
if ($oldversion < 2008062001) {
$table = new XMLDBTable("bookmarks");
$field = new XMLDBField("intro");
$field->setAttributes(XMLDB_TYPE_TEXT, small, null, true, null, null, null, "", null);
change_field_default($table, $field);
change_field_type($table, $field);
change_field_notnull($table, $field);
}
return $result;
}
示例6: xmldb_book_upgrade
function xmldb_book_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 < 2007052001) {
/// Changing type of field importsrc on table book_chapters to char
$table = new XMLDBTable('book_chapters');
$field = new XMLDBField('importsrc');
$field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'timemodified');
/// Launch change of type for field importsrc
$result = $result && change_field_type($table, $field);
}
return $result;
}
示例7: xmldb_assignment_type_peerreview_upgrade
function xmldb_assignment_type_peerreview_upgrade($oldversion = 0)
{
global $CFG, $THEME, $db;
$result = true;
// Change type of criteria values to integers
if ($result && $oldversion < 2010050700) {
$table = new XMLDBTable('assignment_criteria');
$field = new XMLDBField('value');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'textshownatreview');
$result = $result && change_field_type($table, $field);
}
// Add fields for review metrics
if ($result && $oldversion < 2010050500) {
$table = new XMLDBTable('assignment_review');
$field = new XMLDBField('timedownloaded');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'downloaded');
$result = $result && add_field($table, $field);
$field = new XMLDBField('timecompleted');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'complete');
$result = $result && add_field($table, $field);
}
return $result;
}
示例8: xmldb_format_page_upgrade
//.........这里部分代码省略.........
rs_close($rs);
}
// Restore
$db->debug = $olddebug;
}
if ($result && $oldversion < 2007071803) {
// This could be huge, do not output everything
$olddebug = $db->debug;
$db->debug = false;
$result = true;
// Make sure all block weights are set properly (before this was never really managed properly)
if ($courses = get_records('course', 'format', 'page', '', 'id')) {
echo 'Fixing block weights in courses with format = \'page\'....';
$i = 0;
foreach ($courses as $course) {
page_fix_block_weights($course->id);
if ($i % 5 == 0) {
echo '.';
flush();
}
$i++;
}
}
// Restore
$db->debug = $olddebug;
}
if ($result && $oldversion < 2007071804) {
/// Changing the default of field sortorder on table format_page_items to 0
$table = new XMLDBTable('format_page_items');
$field = new XMLDBField('sortorder');
$field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'position');
/// Launch change of default for field sortorder
$result = $result && change_field_default($table, $field);
}
if ($result && $oldversion < 2007071805) {
// This could be huge, do not output everything
$olddebug = $db->debug;
$db->debug = false;
$result = true;
// Make sure all page sortorder values are set properly (before this was never really managed properly)
if ($courses = get_records('course', 'format', 'page', '', 'id')) {
echo 'Fixing page sort orders in courses with format = \'page\'....';
$i = 0;
foreach ($courses as $course) {
page_fix_page_sortorder($course->id);
if ($i % 5 == 0) {
echo '.';
flush();
}
$i++;
}
}
// Restore
$db->debug = $olddebug;
}
if ($result && $oldversion < 2007071806) {
// Remove old setting
if (record_exists('config', 'name', 'pageformatusedefault')) {
unset_config('pageformatusedefault');
}
}
if ($result && $oldversion < 2007071807) {
$site = get_site();
if ($site->format == 'page') {
$result = ($result and set_field('course', 'format', 'site', 'id', $site->id));
$result = ($result and set_config('pageformatonfrontpage', 1));
}
}
if ($result && $oldversion < 2008082100) {
$site = get_site();
if ($CFG->pageformatonfrontpage == 1) {
// Turns out having this set is very important - EG: backup/restore
$result = set_field('course', 'format', 'page', 'id', $site->id);
}
}
if ($result && $oldversion < 2008121000) {
/// Define field locks to be added to format_page
$table = new XMLDBTable('format_page');
$field = new XMLDBField('locks');
$field->setAttributes(XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null, 'showbuttons');
/// Launch add field locks
$result = $result && add_field($table, $field);
}
if ($result && $oldversion < 2009060200) {
//MR-263 column widths to strings to allow for px, % and em etc.
$table = new XMLDBTable('format_page');
$field = new XMLDBField('prefleftwidth');
$field->setType(XMLDB_TYPE_CHAR);
$result = $result && change_field_type($table, $field);
$field = new XMLDBField('prefcenterwidth');
$field->setType(XMLDB_TYPE_CHAR);
$result = $result && change_field_type($table, $field);
$field = new XMLDBField('prefrightwidth');
$field->setType(XMLDB_TYPE_CHAR);
$result = $result && change_field_type($table, $field);
// XMLDB_TYPE_CHAR isn't the same as varchar???
//$alter = "ALTER TABLE {$CFG->prefix}format_page CHANGE prefleftwidth prefleftwidth varchar(8)";
}
return $result;
}
示例9: xmldb_block_courseprefs_upgrade
//.........这里部分代码省略.........
/// Define field timestamp to be added to block_courseprefs_sections
$table = new XMLDBTable('block_courseprefs_sections');
$field = new XMLDBField('timestamp');
$field->setAttributes(XMLDB_TYPE_CHAR, '20', null, null, null, null, null, null, 'status');
/// Launch add field timestamp
$result = $result && add_field($table, $field);
/// Define field credit_hours to be added to block_courseprefs_students
$table = new XMLDBTable('block_courseprefs_students');
$field = new XMLDBField('credit_hours');
$field->setAttributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '3', 'status');
/// Launch add field credit_hours
$result = $result && add_field($table, $field);
/// Define field timestamp to be added to block_courseprefs_teachers
$table = new XMLDBTable('block_courseprefs_teachers');
$field = new XMLDBField('timestamp');
$field->setAttributes(XMLDB_TYPE_CHAR, '20', null, null, null, null, null, null, 'status');
$index = new XMLDBIndex('blocoutea-usesec-uix');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('usersid', 'sectionsid'));
/// Launch add field timestamp
$result = $result && add_field($table, $field) && drop_index($table, $index);
// Add unique index
$index = new XMLDBIndex('blocoutea_usesec_ix');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('usersid', 'sectionsid'));
$uindex = new XMLDBIndex('blocoutea_usesecpri_uix');
$uindex->setAttributes(XMLDB_INDEX_UNIQUE, array('usersid', 'sectionsid', 'primary_flag'));
$result = $result && add_index($table, $index) && add_index($table, $uindex);
//-------Changing of the enrollments ---------//
foreach ($enrollments as $enrollment) {
/// Changing list of values (enum) of field status on table block_courseprefs_students to 'enrolled', 'enroll', 'unenrolled', 'unenroll'
$table = new XMLDBTable('block_courseprefs_' . $enrollment);
$field = new XMLDBField('status');
$field->setAttributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('enrolled', 'enroll', 'unenrolled', 'unenroll'), 'enroll');
/// Launch change of list of values for field status
$result = $result && change_field_type($table, $field);
//Change 'pending' values
$sql = "UPDATE {$CFG->prefix}block_courseprefs_{$enrollment} \n SET status='enroll' \n WHERE status!='enrolled'";
$result = $result && execute_sql($sql);
}
//--------Changing of the split table ----------//
//Caching off the splits in record now
$splits = get_records('block_courseprefs_split');
$table = new XMLDBTable('block_courseprefs_split');
$index = new XMLDBIndex('blocouspl-usecou-uk');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('usersid', 'coursesid'));
$result = $result && drop_index($table, $index);
/// Define field coursesid to be dropped from block_courseprefs_split
$table = new XMLDBTable('block_courseprefs_split');
$field = new XMLDBField('coursesid');
/// Launch drop field coursesid
$result = $result && drop_field($table, $field);
/// Define field sectionsid to be added to block_courseprefs_split
$table = new XMLDBTable('block_courseprefs_split');
$field = new XMLDBField('sectionsid');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'usersid');
/// Launch add field sectionsid
$result = $result && add_field($table, $field);
/// Define field groupingsid to be added to block_courseprefs_split
$table = new XMLDBTable('block_courseprefs_split');
$field = new XMLDBField('groupingsid');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'sectionsid');
/// Launch add field groupingsid
$result = $result && add_field($table, $field);
/// Define field status to be added to block_courseprefs_split
$table = new XMLDBTable('block_courseprefs_split');
$field = new XMLDBField('status');
$field->setAttributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('todo', 'resolved', 'undo'), 'resolved', 'groupingsid');
示例10: xmldb_turnitintool_upgrade
/**
* @package turnitintool
* @copyright 2012 Turnitin
*/
function xmldb_turnitintool_upgrade($oldversion)
{
global $CFG, $THEME, $DB, $OUTPUT;
$result = true;
// Do necessary DB upgrades here
//function add_field($name, $type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $enum=null, $enumvalues=null, $default=null, $previous=null)
// Newer DB Man ($name, $type=null, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null)
if ($result && $oldversion < 2009071501) {
if (is_callable(array($DB, 'get_manager'))) {
$dbman = $DB->get_manager();
$table = new xmldb_table('turnitintool_submissions');
$field = new xmldb_field('submission_gmimaged', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'submission_grade');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
} else {
$table = new XMLDBTable('turnitintool_submissions');
$field = new XMLDBField('submission_gmimaged');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'submission_grade');
$result = $result && add_field($table, $field);
}
}
if ($result && $oldversion < 2009091401) {
if (is_callable(array($DB, 'get_manager'))) {
$dbman = $DB->get_manager();
$table = new xmldb_table('turnitintool');
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, null, null, '0', 'intro');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
} else {
$table = new XMLDBTable('turnitintool');
$field = new XMLDBField('introformat');
$field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, null, null, '0', 'intro');
$result = $result && add_field($table, $field);
}
}
if ($result && $oldversion < 2009092901) {
if (is_callable(array($DB, 'get_manager'))) {
$dbman = $DB->get_manager();
$table1 = new xmldb_table('turnitintool');
$field1 = new xmldb_field('resubmit', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, '0', 'defaultdtpost');
if ($dbman->field_exists($table1, $field1)) {
$dbman->rename_field($table1, $field1, 'anon');
}
$table2 = new xmldb_table('turnitintool_submissions');
$field2 = new xmldb_field('submission_unanon', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, NULL, null, null, null, '0', 'submission_nmlastname');
$field3 = new xmldb_field('submission_unanonreason', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, 'submission_unanon');
$field4 = new xmldb_field('submission_nmuserid', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null);
if (!$dbman->field_exists($table2, $field2)) {
$dbman->add_field($table2, $field2);
}
if (!$dbman->field_exists($table2, $field3)) {
$dbman->add_field($table2, $field3);
}
$dbman->change_field_type($table2, $field4);
} else {
$table1 = new XMLDBTable('turnitintool');
$field1 = new XMLDBField('resubmit');
$field1->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, '0', 'defaultdtpost');
$result = $result && rename_field($table1, $field1, 'anon');
$table2 = new XMLDBTable('turnitintool_submissions');
$field2 = new XMLDBField('submission_unanon');
$field3 = new XMLDBField('submission_unanonreason');
$field4 = new XMLDBField('submission_nmuserid');
$field2->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, '0', 'submission_nmlastname');
$result = $result && add_field($table2, $field2);
$field3->setAttributes(XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null, 'submission_unanon');
$result = $result && add_field($table2, $field3);
$field4->setAttributes(XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null, null);
$result = $result && change_field_type($table2, $field4);
}
}
if ($result && $oldversion < 2009120501) {
if (is_callable(array($DB, 'get_manager'))) {
$dbman = $DB->get_manager();
// Launch add index userid
$table = new xmldb_table('turnitintool_submissions');
$index = new xmldb_index('userid', XMLDB_INDEX_NOTUNIQUE, array('userid'));
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
// Launch add index turnitintoolid
$table = new xmldb_table('turnitintool_submissions');
$index = new xmldb_index('turnitintoolid', XMLDB_INDEX_NOTUNIQUE, array('turnitintoolid'));
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
} else {
$table = new XMLDBTable('turnitintool_submissions');
// Launch add index userid
$index = new XMLDBIndex('userid');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('userid'));
if (index_exists($table, $index)) {
$result = $result && add_index($table, $index);
}
//.........这里部分代码省略.........
示例11: xmldb_certificate_upgrade
function xmldb_certificate_upgrade($oldversion = 0)
{
global $CFG, $THEME, $db;
$result = true;
if ($result && $oldversion < 2007102806) {
/// Add new fields to certificate table
$table = new XMLDBTable('certificate');
$field = new XMLDBField('printoutcome');
$field->setAttributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'gradefmt');
$result = $result && add_field($table, $field);
}
if ($result && $oldversion < 2007102800) {
/// Add new fields to certificate table
$table = new XMLDBTable('certificate');
$field = new XMLDBField('reportcert');
$field->setAttributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'savecert');
$result = $result && add_field($table, $field);
$table = new XMLDBTable('certificate_issues');
$field = new XMLDBField('reportgrade');
$field->setAttributes(XMLDB_TYPE_CHAR, '10', null, null, null, null, null, null, 'certdate');
$result = $result && add_field($table, $field);
}
if ($result && $oldversion < 2007061300) {
/// Add new fields to certificate table
$table = new XMLDBTable('certificate');
$field = new XMLDBField('emailothers');
$field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'emailteachers');
$result = $result && add_field($table, $field);
$table = new XMLDBTable('certificate');
$field = new XMLDBField('printhours');
$field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'gradefmt');
$result = $result && add_field($table, $field);
$table = new XMLDBTable('certificate');
$field = new XMLDBField('lockgrade');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'printhours');
$result = $result && add_field($table, $field);
$table = new XMLDBTable('certificate');
$field = new XMLDBField('requiredgrade');
$field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'lockgrade');
$result = $result && add_field($table, $field);
/// Rename field save to savecert
$field = new XMLDBField('save');
if (field_exists($table, $field)) {
$field->setAttributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'emailothers');
/// Launch rename field savecert
$result = $result && rename_field($table, $field, 'savecert');
} else {
$field = new XMLDBField('savecert');
$field->setAttributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'emailothers');
$result = $result && add_field($table, $field);
}
}
if ($result && $oldversion < 2007061301) {
$table = new XMLDBTable('certificate_linked_modules');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null, null);
$table->addFieldInfo('certificate_id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'id');
$table->addFieldInfo('linkid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'certificate_id');
$table->addFieldInfo('linkgrade', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'linkid');
$table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'linkgrade');
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('certificate_id', XMLDB_INDEX_NOTUNIQUE, array('certificate_id'));
$table->addIndexInfo('linkid', XMLDB_INDEX_NOTUNIQUE, array('linkid'));
$result = create_table($table);
if ($result) {
require_once $CFG->dirroot . '/mod/certificate/lib.php';
$result = certificate_upgrade_grading_info();
}
}
if ($result && $oldversion < 2007061302) {
$table = new XMLDBTable('certificate_linked_modules');
$field = new XMLDBField('linkid');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0', 'certificate_id');
$result = change_field_unsigned($table, $field);
}
if ($result && $oldversion < 2008080902) {
$table = new XMLDBTable('certificate');
$field = new XMLDBField('requiredcertification');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0', 'printhours');
$result = add_field($table, $field);
}
if ($result && $oldversion < 2008080903) {
$table = new XMLDBTable('certificate');
$field = new XMLDBField('setcertification');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0', 'printhours');
$result = add_field($table, $field);
}
if ($result && $oldversion < 2008080904) {
/// Add new fields to certificate table if they dont already exist
$table = new XMLDBTable('certificate');
$field = new XMLDBField('intro');
$field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'name');
if (!field_exists($table, $field)) {
$result = $result && add_field($table, $field);
}
}
if ($result && $oldversion < 2008080905) {
$table = new XMLDBTable('certificate');
$field = new XMLDBField('setcertification');
$field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null, 'printhours');
$result = change_field_type($table, $field);
//.........这里部分代码省略.........
示例12: xmldb_main_upgrade
//.........这里部分代码省略.........
// PK and indexes
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('hostid_remoteid', XMLDB_INDEX_UNIQUE, array('hostid', 'remoteid'));
// Create the table
$result = $result && create_table($table);
$table = new XMLDBTable('mnet_enrol_assignments');
$table->comment = 'Information about enrolments on courses on remote hosts';
$f = $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$f = $table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
$f = $table->addFieldInfo('hostid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
$f = $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
$f = $table->addFieldInfo('rolename', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, NULL, null, null, null);
$f = $table->addFieldInfo('enroltime', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
$f = $table->addFieldInfo('enroltype', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, NULL, null, null, null);
// PK and indexes
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('hostid_courseid', XMLDB_INDEX_NOTUNIQUE, array('hostid', 'courseid'));
$table->addIndexInfo('userid', XMLDB_INDEX_NOTUNIQUE, array('userid'));
// Create the table
$result = $result && create_table($table);
}
if ($result && $oldversion < 2007010404) {
/// Define field shortname to be added to user_info_field
$table = new XMLDBTable('user_info_field');
$field = new XMLDBField('shortname');
$field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, 'shortname', 'id');
/// Launch add field shortname
$result = $result && add_field($table, $field);
/// Changing type of field name on table user_info_field to text
$table = new XMLDBTable('user_info_field');
$field = new XMLDBField('name');
$field->setAttributes(XMLDB_TYPE_TEXT, 'big', null, XMLDB_NOTNULL, null, null, null, null, 'shortname');
/// Launch change of type for field name
$result = $result && change_field_type($table, $field);
/// For existing fields use 'name' as the 'shortname' entry
if ($fields = get_records_select('user_info_field', '', '', 'id, name')) {
foreach ($fields as $field) {
$field->shortname = clean_param($field->name, PARAM_ALPHANUM);
$result && update_record('user_info_field', $field);
}
}
}
if ($result && $oldversion < 2007011200) {
/// Define table context_rel to be created
$table = new XMLDBTable('context_rel');
/// Adding fields to table context_rel
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('c1', XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null);
$table->addFieldInfo('c2', XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null);
/// Adding keys to table context_rel
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('c1', XMLDB_KEY_FOREIGN, array('c1'), 'context', array('id'));
$table->addKeyInfo('c2', XMLDB_KEY_FOREIGN, array('c2'), 'context', array('id'));
$table->addKeyInfo('c1c2', XMLDB_KEY_UNIQUE, array('c1', 'c2'));
/// Launch create table for context_rel
$result = $result && create_table($table);
/// code here to fill the context_rel table
/// use get record set to iterate slower
build_context_rel();
}
if ($result && $oldversion < 2007011501) {
if (!empty($CFG->enablerecordcache) && empty($CFG->rcache) && empty($CFG->cachetype) && empty($CFG->intcachemax)) {
set_config('cachetype', 'internal');
set_config('rcache', true);
set_config('intcachemax', $CFG->enablerecordcache);
unset_config('enablerecordcache');
示例13: xmldb_assignment_type_uploadpdf_upgrade
function xmldb_assignment_type_uploadpdf_upgrade($oldversion = 0)
{
global $CFG, $THEME, $db;
$result = true;
if ($result && $oldversion < 2009041700) {
$table = new XMLDBTable('assignment_uploadpdf');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('assignment', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('coversheet', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, '');
$table->addFieldInfo('template', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('onlypdf', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, null, null, null, null, '1');
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('assignment', XMLDB_INDEX_UNIQUE, array('assignment'));
$table->addIndexInfo('template', XMLDB_INDEX_NOTUNIQUE, array('template'));
$result = $result && create_table($table);
$table = new XMLDBTable('assignment_uploadpdf_template');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, '');
$table->addFieldInfo('course', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('course', XMLDB_INDEX_NOTUNIQUE, array('course'));
$result = $result && create_table($table);
$table = new XMLDBTable('assignment_uploadpdf_template_item');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('template', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('type', XMLDB_TYPE_CHAR, '15', null, XMLDB_NOTNULL, null, null, null, 'shorttext');
$table->addFieldInfo('xpos', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('ypos', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('width', XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, '0');
$table->addFieldInfo('setting', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, '');
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('template', XMLDB_INDEX_NOTUNIQUE, array('template'));
$result = $result && create_table($table);
$table = new XMLDBTable('assignment_uploadpdf_comment');
$field = new XMLDBField('colour');
$field->setAttributes(XMLDB_TYPE_CHAR, '10', null, null, null, null, null, 'yellow', null);
$result = $result && add_field($table, $field);
}
if ($result && $oldversion < 2009111800) {
$table = new XMLDBTable('assignment_uploadpdf_quicklist');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('text', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, '');
$table->addFieldInfo('width', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('colour', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, 'yellow');
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('userid', XMLDB_INDEX_NOTUNIQUE, array('userid'));
$result = $result && create_table($table);
}
if ($result && $oldversion < 2009112800) {
$table = new XMLDBTable('assignment_uploadpdf_annotation');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('assignment_submission', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('startx', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('starty', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('endx', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('endy', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('pageno', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('colour', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, 'red');
$table->addFieldInfo('type', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, 'line');
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('assignment_submission', XMLDB_INDEX_NOTUNIQUE, array('assignment_submission'));
$table->addIndexInfo('assignment_submission_pageno', XMLDB_INDEX_NOTUNIQUE, array('assignment_submission', 'pageno'));
$result = $result && create_table($table);
}
if ($result && $oldversion < 2009120100) {
// Rename the tables to fit within Oracle's 30 char limits (including 2 char prefix)
$table = new XMLDBTable('assignment_uploadpdf_template');
$result = $result && rename_table($table, 'assignment_uploadpdf_tmpl');
$table = new XMLDBTable('assignment_uploadpdf_template_item');
$result = $result && rename_table($table, 'assignment_uploadpdf_tmplitm');
$table = new XMLDBTable('assignment_uploadpdf_quicklist');
$result = $result && rename_table($table, 'assignment_uploadpdf_qcklist');
$table = new XMLDBTable('assignment_uploadpdf_annotation');
$result = $result && rename_table($table, 'assignment_uploadpdf_annot');
// Change the data type of the text field from 'char' to 'text' (removing 255 char limit)
$table = new XMLDBTable('assignment_uploadpdf_qcklist');
$field = new XMLDBField('text');
$field->setAttributes(XMLDB_TYPE_TEXT . 'medium', null, null, null, null, null, '');
$result = $result && change_field_type($table, $field);
// Remove 255 char limit from comments
$table = new XMLDBTable('assignment_uploadpdf_comment');
$field = new XMLDBField('rawtext');
$field->setAttributes(XMLDB_TYPE_TEXT . 'medium', null, null, null, null, null, '');
$result = $result && change_field_type($table, $field);
// Remove 255 char limit from coversheet path
$table = new XMLDBTable('assignment_uploadpdf');
$field = new XMLDBField('coversheet');
$field->setAttributes(XMLDB_TYPE_TEXT . 'medium', null, null, null, null, null, '');
$result = $result && change_field_type($table, $field);
}
if ($result && $oldversion < 2010031300) {
// Add new fields to allow linking with the checklist module
$table = new XMLDBTable('assignment_uploadpdf');
$field = new XMLDBField('checklist');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'onlypdf');
$result = $result && add_field($table, $field);
$field = new XMLDBField('checklist_percent');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'checklist');
$result = $result && add_field($table, $field);
//.........这里部分代码省略.........
示例14: xmldb_studynotes_upgrade
//.........这里部分代码省略.........
$field = new XMLDBField('user');
$field->setAttributes(XMLDB_TYPE_INTEGER, '11', XMLDB_UNSIGNED, null, null, null, null, '0', null);
/// Launch rename field
$result = $result && rename_field($table, $field, 'user_id');
}
// Rename tables longer than 24 chars
if ($result && $oldversion < 2009043001) {
/// Define table studynotes_feed_msg_stat to be renamed
$table = new XMLDBTable('studynotes_feed_messages_status');
/// Launch rename table for studynotes_feed_msg_stat
$result = $result && rename_table($table, 'studynotes_feed_msg_stat');
}
// Rename tables longer than 24 chars
if ($result && $oldversion < 2009043001) {
/// Define table studynotes_feed_subscrib to be renamed
$table = new XMLDBTable('studynotes_feed_subscriptions');
/// Launch rename table for studynotes_feed_subscrib
$result = $result && rename_table($table, 'studynotes_feed_subscrib');
}
// Rename tables longer than 24 chars
if ($result && $oldversion < 2009043001) {
/// Define table studynotes_rel_questions to be renamed
$table = new XMLDBTable('studynotes_relation_questions');
/// Launch rename table for studynotes_rel_questions
$result = $result && rename_table($table, 'studynotes_rel_questions');
}
// Rename tables longer than 24 chars
if ($result && $oldversion < 2009043001) {
/// Define table studynotes_rel_questions to be renamed
$table = new XMLDBTable('studynotes_relation_translations');
/// Launch rename table for studynotes_rel_questions
$result = $result && rename_table($table, 'studynotes_rel_translations');
}
if ($result && $oldversion < 2009050301) {
$fields = array(array('studynotes_cards', 'created'), array('studynotes_cards', 'modified'), array('studynotes_cards', 'locked_time'), array('studynotes_feed_messages', 'created'), array('studynotes_feed_messages', 'modified'), array('studynotes_feed_msg_stat', 'created'), array('studynotes_feed_msg_stat', 'modified'), array('studynotes_feeds', 'created'), array('studynotes_feeds', 'modified'), array('studynotes_groups', 'created'), array('studynotes_groups', 'modified'), array('studynotes_markers', 'created'), array('studynotes_markers', 'modified'), array('studynotes_memberships', 'created'), array('studynotes_memberships', 'modified'), array('studynotes_relations', 'created'), array('studynotes_relations', 'modified'), array('studynotes_relation_answers', 'created'), array('studynotes_relation_answers', 'modified'), array('studynotes_relation_links', 'created'), array('studynotes_relation_links', 'modified'), array('studynotes_rel_questions', 'created'), array('studynotes_rel_questions', 'modified'), array('studynotes_topics', 'created'), array('studynotes_topics', 'modified'), array('studynotes_uploads', 'created'), array('studynotes_uploads', 'modified'), array('studynotes_users', 'created'), array('studynotes_users', 'last_login'));
foreach ($fields as $info) {
$table = new XMLDBTable($info[0]);
$tmpField = new XMLDBField($info[1] . "_cpy");
$tmpField->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', $info[1]);
//add new integer field
$result = $result && add_field($table, $tmpField);
//get value
if ($records = get_records($info[0], '', '', '', 'id,' . $info[1])) {
//convert value
foreach ($records as $record) {
$record->{$info[1] . "_cpy"} = strtotime($record->{$info[1]});
unset($record->{$info[1]});
print_r($record);
$result = $result && update_record($info[0], $record);
}
}
//drop old field
$field = new XMLDBField($info[1]);
$result = $result && drop_field($table, $field);
//rename copy
$tmpField->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', null);
$result = $result && change_field_default($table, $tmpField);
$result = $result && rename_field($table, $tmpField, $info[1]);
}
}
if ($result && $oldversion < 2009050301) {
/// Define table studynotes_rel_translations to be dropped
$table = new XMLDBTable('studynotes_rel_translations');
/// Launch drop table for studynotes_rel_translations
$result = $result && drop_table($table);
}
if ($result && $oldversion < 2009070300) {
/// Define index link (not unique) to be dropped form studynotes_relation_links
$table = new XMLDBTable('studynotes_relation_links');
$index = new XMLDBIndex('link');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('link'));
/// Launch drop index link
$result = $result && drop_index($table, $index);
}
if ($result && $oldversion < 2009070300) {
/// Changing type of field link on table studynotes_relation_links to text
$table = new XMLDBTable('studynotes_relation_links');
$field = new XMLDBField('link');
$field->setAttributes(XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null, null, null, 'id');
/// Launch change of type for field link
$result = $result && change_field_type($table, $field);
}
if ($result && $oldversion < 2009070300) {
/// Changing type of field answer on table studynotes_relation_answers to text
$table = new XMLDBTable('studynotes_relation_answers');
$field = new XMLDBField('answer');
$field->setAttributes(XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null, 'id');
/// Launch change of type for field answer
$result = $result && change_field_type($table, $field);
}
if ($result && $oldversion < 2009070300) {
/// Changing type of field question on table studynotes_rel_questions to text
$table = new XMLDBTable('studynotes_rel_questions');
$field = new XMLDBField('question');
$field->setAttributes(XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null, null, null, 'id');
/// Launch change of type for field question
$result = $result && change_field_type($table, $field);
}
return $result;
}
示例15: xmldb_assignment_type_onlinejudge_upgrade
function xmldb_assignment_type_onlinejudge_upgrade($oldversion = 0)
{
global $CFG, $THEME, $db;
$result = true;
if ($result && $oldversion < 2010032700) {
/// Define field ratiope to be added to assignment_oj
$table = new XMLDBTable('assignment_oj');
$field = new XMLDBField('ratiope');
$field->setAttributes(XMLDB_TYPE_NUMBER, '20, 10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0.0', 'compileonly');
/// Launch add field ratiope
$result = $result && add_field($table, $field);
}
if ($result && $oldversion < 2010040701) {
/// Define index judged (not unique) to be added to assignment_oj_submissions
$table = new XMLDBTable('assignment_oj_submissions');
$index = new XMLDBIndex('judged');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('judged'));
/// Launch add index judged
$result = $result && add_index($table, $index);
/// Define index judgetime (not unique) to be added to assignment_oj_results
$table = new XMLDBTable('assignment_oj_results');
$index = new XMLDBIndex('judgetime');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('judgetime'));
/// Launch add index judgetime
$result = $result && add_index($table, $index);
}
if ($result && $oldversion < 2010042800) {
/// Define field duejudge to be dropped from assignment_oj
$table = new XMLDBTable('assignment_oj');
$field = new XMLDBField('duejudge');
/// Launch drop field duejudge
$result = $result && drop_field($table, $field);
/// Define key test (foreign) to be dropped form assignment_oj_results
$table = new XMLDBTable('assignment_oj_results');
$key = new XMLDBKey('test');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('test'), 'assignment_oj_tests', array('id'));
/// Launch drop key test
$result = $result && drop_key($table, $key);
/// Define field test to be dropped from assignment_oj_results
$field = new XMLDBField('test');
/// Launch drop field test
$result = $result && drop_field($table, $field);
}
if ($result && $oldversion < 2010070400) {
/// Define field usefile to be added to assignment_oj_tests
$table = new XMLDBTable('assignment_oj_tests');
$field = new XMLDBField('usefile');
$field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'output');
/// Launch add field usefile
$result = $result && add_field($table, $field);
/// Define field inputfile to be added to assignment_oj_tests
$table = new XMLDBTable('assignment_oj_tests');
$field = new XMLDBField('inputfile');
$field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'usefile');
/// Launch add field inputfile
$result = $result && add_field($table, $field);
/// Define field outputfile to be added to assignment_oj_tests
$table = new XMLDBTable('assignment_oj_tests');
$field = new XMLDBField('outputfile');
$field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'inputfile');
/// Launch add field outputfile
$result = $result && add_field($table, $field);
/// Changing type of field subgrade on table assignment_oj_tests to number
$table = new XMLDBTable('assignment_oj_tests');
$field = new XMLDBField('subgrade');
$field->setAttributes(XMLDB_TYPE_NUMBER, '20, 10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'feedback');
/// Launch change of type for field subgrade
$result = $result && change_field_type($table, $field);
/// Upgrade the value in subgrade field
if ($result) {
$ojs = get_records('assignment_oj');
foreach ($ojs as $oj) {
$modgrade = get_field('assignment', 'grade', 'id', $oj->assignment);
if ($modgrade) {
$sql = 'UPDATE ' . $CFG->prefix . 'assignment_oj_tests ' . 'SET subgrade=subgrade/' . $modgrade . ' ' . 'WHERE assignment=' . $oj->assignment;
$result = $result && execute_sql($sql);
}
}
}
}
// Tell the daemon to exit
set_config('assignment_oj_daemon_pid', '0');
return $result;
}