Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
271e6dec
Commit
271e6dec
authored
Aug 09, 2007
by
jamiesensei
Browse files
merging MOODLE_19_QUESTIONS with HEAD
parent
3bee1ead
Changes
47
Expand all
Hide whitespace changes
Inline
Side-by-side
admin/report/question/index.php
0 → 100644
View file @
271e6dec
<?php
// $Id$
require_once
(
'../../../config.php'
);
require_once
(
$CFG
->
dirroot
.
'/question/upgrade.php'
);
require_once
(
$CFG
->
libdir
.
'/adminlib.php'
);
admin_externalpage_setup
(
'reportquestion'
);
admin_externalpage_print_header
();
print_heading
(
page_doc_link
(
get_string
(
'adminreport'
,
'question'
)));
$probstr
=
''
;
if
(
$CFG
->
version
<
2007081000
){
///cwrqpfs issue
$probstr
=
print_heading
(
get_string
(
'cwrqpfs'
,
'question'
),
''
,
3
,
'main'
,
true
);
if
(
$updates
=
question_cwqpfs_to_update
()){
$probstr
.
=
(
'<p>'
.
get_string
(
'cwrqpfsinfo'
,
'question'
)
.
'</p>'
);
$probstr
.
=
'<ul>'
;
$catlist
=
join
(
array_keys
(
$updates
),
','
);
//get info about cateogries and no of questions used outside category's course
$categories
=
get_records_sql
(
'SELECT qc.*, c.fullname as coursename FROM '
.
$CFG
->
prefix
.
'question_categories as qc, '
.
$CFG
->
prefix
.
'course as c WHERE qc.course = c.id AND qc.id IN ('
.
$catlist
.
')'
);
foreach
(
$updates
as
$id
=>
$publish
){
$categories
[
$id
]
->
caturl
=
"
$CFG->wwwroot
/question/category.php?sesskey="
.
sesskey
()
.
"&edit=
$id
&courseid="
.
$categories
[
$id
]
->
course
;
if
(
$categories
[
$id
]
->
publish
){
$categories
[
$id
]
->
changefrom
=
get_string
(
'published'
,
'question'
);
$categories
[
$id
]
->
changeto
=
get_string
(
'unpublished'
,
'question'
);
}
else
{
$categories
[
$id
]
->
changefrom
=
get_string
(
'unpublished'
,
'question'
);
$categories
[
$id
]
->
changeto
=
get_string
(
'published'
,
'question'
);
}
$probstr
.
=
'<li>'
.
get_string
(
'changepublishstatuscat'
,
'question'
,
$categories
[
$id
]);
if
(
$questions
=
get_records_sql
(
'SELECT q.*, qui.id as quizid, qui.name as quizname, cm.id as cmid, '
.
'qui.course, c.fullname as coursename FROM '
.
$CFG
->
prefix
.
'question as q, '
.
$CFG
->
prefix
.
'quiz_question_instances as qqi, '
.
$CFG
->
prefix
.
'quiz as qui, '
.
$CFG
->
prefix
.
'course_modules as cm, '
.
$CFG
->
prefix
.
'modules as m, '
.
$CFG
->
prefix
.
'course as c '
.
'WHERE (q.category = '
.
$id
.
' AND qqi.question = q.id '
.
'AND qqi.quiz = qui.id '
.
'AND qui.course = c.id '
.
'AND cm.instance = qui.id '
.
'AND cm.module = m.id '
.
'AND m.name = \'quiz\''
.
'AND ('
.
$categories
[
$id
]
->
course
.
' <> qui.course)) ORDER BY qui.id ASC'
)){
$probstr
.
=
'<ul>'
;
foreach
(
$questions
as
$question
){
$question
->
quizurl
=
"
$CFG->wwwroot
/mod/quiz/edit.php?cmid="
.
$question
->
cmid
;
$question
->
qurl
=
"
$CFG->wwwroot
/question/question.php?cmid=
{
$question
->
cmid
}
&id=
{
$question
->
id
}
&returnurl="
.
urlencode
(
$FULLME
);
$probstr
.
=
'<li>'
.
get_string
(
'questionaffected'
,
'question'
,
$question
)
.
'</li>'
;
}
$probstr
.
=
'</ul>'
;
}
$probstr
.
=
'</li>'
;
}
$probstr
.
=
'</ul>'
;
}
else
{
$probstr
.
=
(
'<p>'
.
get_string
(
'cwrqpfsnoprob'
,
'question'
)
.
'</p>'
);
}
}
if
(
$probstr
)
{
print_box
(
$probstr
);
}
else
{
print_box
(
get_string
(
'noprobs'
,
'question'
),
'boxwidthnarrow boxaligncenter generalbox'
);
}
admin_externalpage_print_footer
();
?>
lib/db/access.php
View file @
271e6dec
...
...
@@ -799,9 +799,7 @@ $moodle_capabilities = array(
)
),
'moodle/question:import'
=>
array
(
'riskbitmask'
=>
RISK_XSS
,
'moodle/question:managecategory'
=>
array
(
'captype'
=>
'write'
,
'contextlevel'
=>
CONTEXT_COURSE
,
...
...
@@ -809,40 +807,95 @@ $moodle_capabilities = array(
'editingteacher'
=>
CAP_ALLOW
,
'admin'
=>
CAP_ALLOW
)
),
//new in moodle 1.9
'moodle/question:add'
=>
array
(
'riskbitmask'
=>
RISK_SPAM
,
'captype'
=>
'write'
,
'contextlevel'
=>
CONTEXT_COURSE
,
'legacy'
=>
array
(
'editingteacher'
=>
CAP_ALLOW
,
'admin'
=>
CAP_ALLOW
),
'clonepermissionsfrom'
=>
'moodle/question:manage'
),
'moodle/question:export'
=>
array
(
'moodle/question:editmine'
=>
array
(
'riskbitmask'
=>
RISK_SPAM
,
'captype'
=>
'write'
,
'contextlevel'
=>
CONTEXT_COURSE
,
'legacy'
=>
array
(
'editingteacher'
=>
CAP_ALLOW
,
'admin'
=>
CAP_ALLOW
),
'clonepermissionsfrom'
=>
'moodle/question:manage'
),
'moodle/question:editall'
=>
array
(
'riskbitmask'
=>
RISK_SPAM
,
'captype'
=>
'write'
,
'contextlevel'
=>
CONTEXT_COURSE
,
'legacy'
=>
array
(
'editingteacher'
=>
CAP_ALLOW
,
'admin'
=>
CAP_ALLOW
),
'clonepermissionsfrom'
=>
'moodle/question:manage'
),
'moodle/question:viewmine'
=>
array
(
'captype'
=>
'read'
,
'contextlevel'
=>
CONTEXT_COURSE
,
'legacy'
=>
array
(
'editingteacher'
=>
CAP_ALLOW
,
'admin'
=>
CAP_ALLOW
)
),
'clonepermissionsfrom'
=>
'moodle/question:manage'
),
'moodle/question:managecategory'
=>
array
(
'moodle/question:viewall'
=>
array
(
'captype'
=>
'read'
,
'contextlevel'
=>
CONTEXT_COURSE
,
'legacy'
=>
array
(
'editingteacher'
=>
CAP_ALLOW
,
'admin'
=>
CAP_ALLOW
),
'clonepermissionsfrom'
=>
'moodle/question:manage'
),
'moodle/question:usemine'
=>
array
(
'captype'
=>
'read'
,
'contextlevel'
=>
CONTEXT_COURSE
,
'legacy'
=>
array
(
'editingteacher'
=>
CAP_ALLOW
,
'admin'
=>
CAP_ALLOW
),
'clonepermissionsfrom'
=>
'moodle/question:manage'
),
'moodle/question:useall'
=>
array
(
'captype'
=>
'read'
,
'contextlevel'
=>
CONTEXT_COURSE
,
'legacy'
=>
array
(
'editingteacher'
=>
CAP_ALLOW
,
'admin'
=>
CAP_ALLOW
),
'clonepermissionsfrom'
=>
'moodle/question:manage'
),
'moodle/question:movemine'
=>
array
(
'captype'
=>
'write'
,
'contextlevel'
=>
CONTEXT_COURSE
,
'legacy'
=>
array
(
'editingteacher'
=>
CAP_ALLOW
,
'admin'
=>
CAP_ALLOW
)
),
'clonepermissionsfrom'
=>
'moodle/question:manage'
),
'moodle/question:manage'
=>
array
(
'riskbitmask'
=>
RISK_XSS
,
'moodle/question:moveall'
=>
array
(
'captype'
=>
'write'
,
'contextlevel'
=>
CONTEXT_COURSE
,
'legacy'
=>
array
(
'editingteacher'
=>
CAP_ALLOW
,
'admin'
=>
CAP_ALLOW
)
),
'clonepermissionsfrom'
=>
'moodle/question:manage'
),
//END new in moodle 1.9
// Configure the installed question types.
'moodle/question:config'
=>
array
(
...
...
lib/db/upgrade.php
View file @
271e6dec
...
...
@@ -37,13 +37,13 @@ function xmldb_main_upgrade($oldversion=0) {
if
(
$module
=
get_record
(
'modules'
,
'name'
,
'exercise'
))
{
if
(
$module
->
visible
)
{
// Hide/disable the module entry
set_field
(
'modules'
,
'visible'
,
'0'
,
'id'
,
$module
->
id
);
set_field
(
'modules'
,
'visible'
,
'0'
,
'id'
,
$module
->
id
);
// Save existing visible state for all activities
set_field
(
'course_modules'
,
'visibleold'
,
'1'
,
'visible'
,
'1'
,
'module'
,
$module
->
id
);
set_field
(
'course_modules'
,
'visibleold'
,
'0'
,
'visible'
,
'0'
,
'module'
,
$module
->
id
);
// Hide all activities
set_field
(
'course_modules'
,
'visible'
,
'0'
,
'module'
,
$module
->
id
);
require_once
(
$CFG
->
dirroot
.
'/course/lib.php'
);
rebuild_course_cache
();
// Rebuld cache for all modules because they might have changed
}
...
...
@@ -55,7 +55,7 @@ function xmldb_main_upgrade($oldversion=0) {
set_field
(
'modules'
,
'visible'
,
0
,
'name'
,
'lams'
);
// Disable it by default
}
}
if
(
$result
&&
$oldversion
<
2006102600
)
{
/// Define fields to be added to user_info_field
...
...
@@ -81,7 +81,7 @@ function xmldb_main_upgrade($oldversion=0) {
$result
=
$result
&&
add_field
(
$table
,
$field4
);
$result
=
$result
&&
add_field
(
$table
,
$field5
);
}
if
(
$result
&&
$oldversion
<
2006112000
)
{
/// Define field attachment to be added to post
...
...
@@ -92,7 +92,7 @@ function xmldb_main_upgrade($oldversion=0) {
/// Launch add field attachment
$result
=
$result
&&
add_field
(
$table
,
$field
);
}
if
(
$result
&&
$oldversion
<
2006112200
)
{
/// Define field imagealt to be added to user
...
...
@@ -102,7 +102,7 @@ function xmldb_main_upgrade($oldversion=0) {
/// Launch add field imagealt
$result
=
$result
&&
add_field
(
$table
,
$field
);
$table
=
new
XMLDBTable
(
'user'
);
$field
=
new
XMLDBField
(
'screenreader'
);
$field
->
setAttributes
(
XMLDB_TYPE_INTEGER
,
'1'
,
null
,
XMLDB_NOTNULL
,
null
,
null
,
null
,
'0'
,
'imagealt'
);
...
...
@@ -121,7 +121,7 @@ function xmldb_main_upgrade($oldversion=0) {
if
(
$oldversion
<
2006120400
)
{
/// Remove secureforms config setting
execute_sql
(
"DELETE FROM
{
$CFG
->
prefix
}
config where name='secureforms'"
,
true
);
}
if
(
!
empty
(
$CFG
->
rolesactive
)
&&
$oldversion
<
2006120700
)
{
// add moodle/user:viewdetails to all roles!
// note: use of assign_capability() is discouraged in upgrade script!
if
(
$roles
=
get_records
(
'role'
))
{
...
...
@@ -198,7 +198,7 @@ function xmldb_main_upgrade($oldversion=0) {
XMLDB_NOTNULL
,
null
,
null
,
null
,
0
);
$f
=
$table
->
addFieldInfo
(
'last_log_id'
,
XMLDB_TYPE_INTEGER
,
'10'
,
XMLDB_UNSIGNED
,
XMLDB_NOTNULL
,
null
,
null
,
null
,
0
);
// PK and indexes
// PK and indexes
$table
->
addKeyInfo
(
'primary'
,
XMLDB_KEY_PRIMARY
,
array
(
'id'
));
// Create the table
$result
=
$result
&&
create_table
(
$table
);
...
...
@@ -317,14 +317,14 @@ function xmldb_main_upgrade($oldversion=0) {
$result
=
$result
&&
create_table
(
$table
);
//
// Prime MNET configuration entries -- will be needed later by auth/mnet
// Prime MNET configuration entries -- will be needed later by auth/mnet
//
include_once
$CFG
->
dirroot
.
'/mnet/lib.php'
;
$env
=
new
mnet_environment
();
$env
->
init
();
unset
(
$env
);
// add mnethostid to user-
// add mnethostid to user-
$table
=
new
XMLDBTable
(
'user'
);
$field
=
new
XMLDBField
(
'mnethostid'
);
$field
->
setType
(
XMLDB_TYPE_INTEGER
);
...
...
@@ -339,8 +339,8 @@ function xmldb_main_upgrade($oldversion=0) {
// The default mnethostid is zero... we need to update this for all
// users of the local IdP service.
set_field
(
'user'
,
'mnethostid'
,
$CFG
->
mnet_localhost_id
,
set_field
(
'user'
,
'mnethostid'
,
$CFG
->
mnet_localhost_id
,
'mnethostid'
,
'0'
);
...
...
@@ -353,7 +353,7 @@ function xmldb_main_upgrade($oldversion=0) {
notify
(
get_string
(
'duplicate_usernames'
,
'mnet'
,
'http://docs.moodle.org/en/DuplicateUsernames'
));
}
unset
(
$table
,
$field
,
$index
);
unset
(
$table
,
$field
,
$index
);
/**
** auth/mnet tables
...
...
@@ -458,7 +458,7 @@ function xmldb_main_upgrade($oldversion=0) {
$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
);
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
,
...
...
@@ -522,14 +522,14 @@ function xmldb_main_upgrade($oldversion=0) {
/// 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
)
&&
if
(
!
empty
(
$CFG
->
enablerecordcache
)
&&
empty
(
$CFG
->
rcache
)
&&
// Note: won't force-load these settings into CFG
// we don't need or want cache during the upgrade itself
empty
(
$CFG
->
cachetype
)
&&
empty
(
$CFG
->
intcachemax
))
{
...
...
@@ -679,30 +679,30 @@ function xmldb_main_upgrade($oldversion=0) {
/// Launch drop index text
$result
=
$result
&&
drop_index
(
$table
,
$index
);
$field
=
new
XMLDBField
(
'text'
);
$field
->
setAttributes
(
XMLDB_TYPE_CHAR
,
'255'
,
null
,
XMLDB_NOTNULL
,
null
,
null
,
null
,
null
,
'userid'
);
/// Launch change of type for field text
$result
=
$result
&&
change_field_type
(
$table
,
$field
);
$index
=
new
XMLDBIndex
(
'text'
);
$index
->
setAttributes
(
XMLDB_INDEX_NOTUNIQUE
,
array
(
'text'
));
/// Launch add index text
$result
=
$result
&&
add_index
(
$table
,
$index
);
$result
=
$result
&&
add_index
(
$table
,
$index
);
}
if
(
$result
&&
$oldversion
<
2007041100
)
{
/// Define field idnumber to be added to course_modules
$table
=
new
XMLDBTable
(
'course_modules'
);
$field
=
new
XMLDBField
(
'idnumber'
);
$field
->
setAttributes
(
XMLDB_TYPE_CHAR
,
'100'
,
null
,
null
,
null
,
null
,
null
,
null
,
'section'
);
/// Launch add field idnumber
$result
=
$result
&&
add_field
(
$table
,
$field
);
/// Define index idnumber (unique) to be added to course_modules
$table
=
new
XMLDBTable
(
'course_modules'
);
$index
=
new
XMLDBIndex
(
'idnumber'
);
...
...
@@ -717,7 +717,7 @@ function xmldb_main_upgrade($oldversion=0) {
We could do all this with one tricky SQL statement but it's a one-off so no
harm in using PHP loops */
if
(
$result
&&
$oldversion
<
2007041600
)
{
/// Get the menu fields
if
(
$fields
=
get_records
(
'user_info_field'
,
'datatype'
,
'menu'
))
{
foreach
(
$fields
as
$field
)
{
...
...
@@ -729,7 +729,7 @@ function xmldb_main_upgrade($oldversion=0) {
$options
=
explode
(
"
\n
"
,
$this
->
field
->
param1
);
foreach
(
$data
as
$d
)
{
$key
=
array_search
(
$d
->
data
,
$options
);
/// If the data is an integer and is not one of the options,
/// set the respective option value
if
(
is_int
(
$d
->
data
)
and
((
$key
===
NULL
)
or
(
$key
===
false
))
and
isset
(
$options
[
$d
->
data
]))
{
...
...
@@ -740,9 +740,9 @@ function xmldb_main_upgrade($oldversion=0) {
}
}
}
}
/// adding new gradebook tables
if
(
$result
&&
$oldversion
<
2007041800
)
{
...
...
@@ -764,7 +764,7 @@ function xmldb_main_upgrade($oldversion=0) {
/// Launch create table for events_handlers
$result
=
$result
&&
create_table
(
$table
);
/// Define table events_queue to be created
$table
=
new
XMLDBTable
(
'events_queue'
);
...
...
@@ -782,7 +782,7 @@ function xmldb_main_upgrade($oldversion=0) {
/// Launch create table for events_queue
$result
=
$result
&&
create_table
(
$table
);
/// Define table events_queue_handlers to be created
$table
=
new
XMLDBTable
(
'events_queue_handlers'
);
...
...
@@ -813,7 +813,7 @@ function xmldb_main_upgrade($oldversion=0) {
/// Launch add field schedule
$result
=
$result
&&
add_field
(
$table
,
$field
);
/// Define field status to be added to events_handlers
$table
=
new
XMLDBTable
(
'events_handlers'
);
$field
=
new
XMLDBField
(
'status'
);
...
...
@@ -899,7 +899,7 @@ function xmldb_main_upgrade($oldversion=0) {
/// Launch add field usermodified
$result
=
$result
&&
add_field
(
$table
,
$field
);
/// Define key usermodified (foreign) to be added to post
$table
=
new
XMLDBTable
(
'post'
);
$key
=
new
XMLDBKey
(
'usermodified'
);
...
...
@@ -952,7 +952,7 @@ function xmldb_main_upgrade($oldversion=0) {
$application
->
xmlrpc_server_url
=
'/api/xmlrpc/server.php'
;
$application
->
sso_land_url
=
'/auth/xmlrpc/land.php'
;
$result
=
$result
&&
insert_record
(
'mnet_application'
,
$application
,
false
);
// New mnet_host->applicationid field
$table
=
new
XMLDBTable
(
'mnet_host'
);
$field
=
new
XMLDBField
(
'applicationid'
);
...
...
@@ -975,7 +975,6 @@ function xmldb_main_upgrade($oldversion=0) {
$result
=
$result
&&
question_remove_rqp_qtype_config_string
();
}
if
(
$result
&&
$oldversion
<
2007072200
)
{
/// Remove obsoleted unit tests tables - they will be recreated automatically
$tables
=
array
(
'grade_categories'
,
...
...
@@ -1448,21 +1447,21 @@ function xmldb_main_upgrade($oldversion=0) {
if
(
$result
&&
$oldversion
<
2007073100
)
{
/// Define table grade_outcomes_courses to be created
$table
=
new
XMLDBTable
(
'grade_outcomes_courses'
);
/// Adding fields to table grade_outcomes_courses
$table
->
addFieldInfo
(
'id'
,
XMLDB_TYPE_INTEGER
,
'10'
,
null
,
XMLDB_NOTNULL
,
XMLDB_SEQUENCE
,
null
,
null
,
null
);
$table
->
addFieldInfo
(
'courseid'
,
XMLDB_TYPE_INTEGER
,
'10'
,
XMLDB_UNSIGNED
,
XMLDB_NOTNULL
,
null
,
null
,
null
,
null
);
$table
->
addFieldInfo
(
'outcomeid'
,
XMLDB_TYPE_INTEGER
,
'10'
,
XMLDB_UNSIGNED
,
XMLDB_NOTNULL
,
null
,
null
,
null
,
null
);
/// Adding keys to table grade_outcomes_courses
$table
->
addKeyInfo
(
'primary'
,
XMLDB_KEY_PRIMARY
,
array
(
'id'
));
$table
->
addKeyInfo
(
'courseid'
,
XMLDB_KEY_FOREIGN
,
array
(
'courseid'
),
'course'
,
array
(
'id'
));
$table
->
addKeyInfo
(
'outcomeid'
,
XMLDB_KEY_FOREIGN
,
array
(
'outcomeid'
),
'grade_outcomes'
,
array
(
'id'
));
/// Launch create table for grade_outcomes_courses
$result
=
$result
&&
create_table
(
$table
);
/// Define table grade_outcomes_courses to be created
$table
=
new
XMLDBTable
(
'grade_outcomes_courses'
);
/// Adding fields to table grade_outcomes_courses
$table
->
addFieldInfo
(
'id'
,
XMLDB_TYPE_INTEGER
,
'10'
,
null
,
XMLDB_NOTNULL
,
XMLDB_SEQUENCE
,
null
,
null
,
null
);
$table
->
addFieldInfo
(
'courseid'
,
XMLDB_TYPE_INTEGER
,
'10'
,
XMLDB_UNSIGNED
,
XMLDB_NOTNULL
,
null
,
null
,
null
,
null
);
$table
->
addFieldInfo
(
'outcomeid'
,
XMLDB_TYPE_INTEGER
,
'10'
,
XMLDB_UNSIGNED
,
XMLDB_NOTNULL
,
null
,
null
,
null
,
null
);
/// Adding keys to table grade_outcomes_courses
$table
->
addKeyInfo
(
'primary'
,
XMLDB_KEY_PRIMARY
,
array
(
'id'
));
$table
->
addKeyInfo
(
'courseid'
,
XMLDB_KEY_FOREIGN
,
array
(
'courseid'
),
'course'
,
array
(
'id'
));
$table
->
addKeyInfo
(
'outcomeid'
,
XMLDB_KEY_FOREIGN
,
array
(
'outcomeid'
),
'grade_outcomes'
,
array
(
'id'
));
/// Launch create table for grade_outcomes_courses
$result
=
$result
&&
create_table
(
$table
);
}
...
...
@@ -1562,7 +1561,7 @@ function xmldb_main_upgrade($oldversion=0) {
$result
=
$result
&&
add_field
(
$table
,
$field
);
}
}
// adding unique contraint on (courseid,shortname) of an outcome
if
(
$result
&&
$oldversion
<
2007080100
)
{
...
...
@@ -1581,7 +1580,7 @@ function xmldb_main_upgrade($oldversion=0) {
set_config
(
'supportemail'
,
s
(
$firstadmin
->
email
));
}
}
/// MDL-10679, context_rel clean up
if
(
$result
&&
$oldversion
<
2007080200
)
{
delete_records
(
'context_rel'
);
...
...
@@ -1719,6 +1718,14 @@ function xmldb_main_upgrade($oldversion=0) {
}
}
*/
//need to change this when we merge with HEAD
if
(
$result
&&
$oldversion
<
2007081000
)
{
require_once
(
$CFG
->
dirroot
.
'/question/upgrade.php'
);
$result
=
$result
&&
question_upgrade_context_etc
();
}
return
$result
;
}
?>
lib/form/questioncategory.php
View file @
271e6dec
...
...
@@ -2,20 +2,22 @@
/**
* A moodle form field type for question categories.
*
* @copyright
© 2006 The Open University
* @author
T.J.Hunt@open.ac.uk
* @copyright
Jamie Pratt
* @author
Jamie Pratt
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package moodleforms
*/
/** */
*/
global
$CFG
;
require_once
(
"
$CFG->libdir
/form/select.php"
);
require_once
(
"
$CFG->libdir
/form/selectgroups.php"
);
require_once
(
"
$CFG->libdir
/questionlib.php"
);
/**
* HTML class for a drop down element to select a question category.
* @access public
*/
class
MoodleQuickForm_questioncategory
extends
MoodleQuickForm_select
{
class
MoodleQuickForm_questioncategory
extends
MoodleQuickForm_selectgroups
{
var
$_options
=
array
(
'top'
=>
false
,
'currentcat'
=>
0
,
'nochildrenof'
=>
-
1
);
/**
* Constructor
...
...
@@ -28,45 +30,16 @@ class MoodleQuickForm_questioncategory extends MoodleQuickForm_select {
* @access public
* @return void
*/
function
MoodleQuickForm_questioncategory
(
$elementName
=
null
,
$elementLabel
=
null
,
$attributes
=
null
,
$options
=
null
)
{
HTML_QuickForm_element
::
HTML_QuickForm_element
(
$elementName
,
$elementLabel
,
$attributes
,
null
);
global
$COURSE
;
function
MoodleQuickForm_questioncategory
(
$elementName
=
null
,
$elementLabel
=
null
,
$options
=
null
,
$attributes
=
null
)
{
MoodleQuickForm_selectgroups
::
MoodleQuickForm_selectgroups
(
$elementName
,
$elementLabel
,
array
(),
$attributes
);
$this
->
_type
=
'questioncategory'
;
if
(
!
empty
(
$options
[
'courseid'
]))
{
$this
->
_courseid
=
$options
[
'courseid'
];
}
else
{
$this
->
_courseid
=
$COURSE
->
id
;
}
if
(
!
empty
(
$options
[
'published'
]))
{
$this
->
_published
=
$options
[
'published'
];
}
else
{
$this
->
_published
=
false
;
}
if
(
!
empty
(
$options
[
'only_editable'
]))
{
$this
->
_only_editable
=
$options
[
'only_editable'
];
}
else
{
$this
->
_only_editable
=
false
;
if
(
is_array
(
$options
))
{
$this
->
_options
=
$options
+
$this
->
_options
;
$this
->
loadArrayOptGroups
(
question_category_options
(
$this
->
_options
[
'contexts'
],
$this
->
_options
[
'top'
],
$this
->
_options
[
'currentcat'
],
false
,
$this
->
_options
[
'nochildrenof'
]));
}
}
/**
* 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
* @access public
* @return mixed
*/
function
onQuickFormEvent
(
$event
,
$arg
,
&
$caller
)
{
switch
(
$event
)
{
case
'createElement'
:
$this
->
load
(
question_category_options
(
$this
->
_courseid
,
$this
->
_published
,
$this
->
_only_editable
));
break
;
}
return
parent
::
onQuickFormEvent
(
$event
,
$arg
,
$caller
);
}
}
?>
\ No newline at end of file
mod/quiz/backuplib.php
View file @
271e6dec
...
...
@@ -29,27 +29,54 @@
// When we backup a quiz we also need to backup the questions and possibly
// the data about student interaction with the questions. The functions to do
// that are included with the following library
require_once
(
"
$CFG->libdir
/questionlib.php"
);
require_once
(
"
$CFG->dirroot
/question/backuplib.php"
);
//STEP 1. Backup categories/questions and associated structures
// (course independent)
//Insert necessary category ids to backup_ids table
function
insert_category_ids
(
$course
,
$backup_unique_code
,
$instances
=
null
)
{
/*
* Insert necessary category ids to backup_ids table. Called during backup_check.html
*/
function
insert_category_and_question_ids
(
$course
,
$backup_unique_code
,
$instances
=
null
)
{
global
$CFG
;
include_once
(
"
$CFG->dirroot
/mod/quiz/lib.php"
);
// Create missing categories and reasign orphaned questions.
fix_orphaned_questions
(
$course
);
// First, ALL categories from this course.
// First, all categories from this course's context.
$coursecontext
=
get_context_instance
(
CONTEXT_COURSE
,
$course
);
$status
=
execute_sql
(
"INSERT INTO
{
$CFG
->
prefix
}
backup_ids
(backup_code, table_name, old_id, info)
SELECT '
$backup_unique_code
', 'question_categories', qc.id, ''
FROM
{
$CFG
->
prefix
}
question_categories qc
WHERE qc.course =
$course
"
,
false
);
// Then published categories from other courses used by the quizzes we are backing up.
WHERE qc.contextid =
{
$coursecontext
->
id
}
"
,
false
);
// then, all categories from this course's modules' contexts.
// using 'dummykeyname' in sql because otherwise get_records_sql_menu returns an error
// if two key names are the same.
$cmcontexts
=
get_records_sql_menu
(
"SELECT c.id, c.id AS dummykeyname FROM `
{
$CFG
->
prefix
}
modules` AS `mod`,