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
integration
prechecker
Commits
b180a119
Commit
b180a119
authored
Feb 15, 2011
by
Eloy Lafuente
Browse files
Merge branch 'MDL-26236' of
git://github.com/timhunt/moodle
parents
bcbb5902
c991ecb4
Changes
2
Hide whitespace changes
Inline
Side-by-side
question/type/random/backup/moodle2/restore_qtype_random_plugin.class.php
View file @
b180a119
...
...
@@ -47,9 +47,9 @@ class restore_qtype_random_plugin extends restore_qtype_plugin {
$answer
=
$state
->
answer
;
$result
=
''
;
// randomxx-yy answer format
if
(
preg_match
(
'~^random([0-9]+)-
(.*)$
~'
,
$answer
,
$matches
))
{
if
(
preg_match
(
'~^random([0-9]+)-~'
,
$answer
,
$matches
))
{
$questionid
=
$matches
[
1
];
$subanswer
=
$matches
[
2
]
;
$subanswer
=
substr
(
$answer
,
strlen
(
'random'
.
$questionid
.
'-'
))
;
$newquestionid
=
$this
->
get_mappingid
(
'question'
,
$questionid
);
$questionqtype
=
$DB
->
get_field
(
'question'
,
'qtype'
,
array
(
'id'
=>
$newquestionid
));
// Delegate subanswer recode to proper qtype, faking one question_states record
...
...
question/type/random/questiontype.php
View file @
b180a119
...
...
@@ -232,7 +232,7 @@ class random_qtype extends default_questiontype {
/// the other question types in that it now only needs one response
/// record per question.
global
$QTYPES
,
$DB
,
$OUTPUT
;
if
(
!
preg_match
(
'~^random([0-9]+)-
(.*)$
~'
,
$state
->
responses
[
''
],
$
answerreg
s
))
{
if
(
!
preg_match
(
'~^random([0-9]+)-~'
,
$state
->
responses
[
''
],
$
matche
s
))
{
if
(
empty
(
$state
->
responses
[
''
]))
{
// This is the case if there weren't enough questions available in the category.
$question
->
questiontext
=
'<span class="notifyproblem">'
.
...
...
@@ -250,15 +250,16 @@ class random_qtype extends default_questiontype {
echo
$OUTPUT
->
notification
(
"Wrapped state missing"
);
}
}
else
{
if
(
!
$wrappedquestion
=
$DB
->
get_record
(
'question'
,
array
(
'id'
=>
$answerregs
[
1
])))
{
$questionid
=
$matches
[
1
];
if
(
!
$wrappedquestion
=
$DB
->
get_record
(
'question'
,
array
(
'id'
=>
$questionid
)))
{
// The teacher must have deleted this question by mistake
// Convert it into a description type question with an explanation to the student
$wrappedquestion
=
clone
(
$question
);
$wrappedquestion
->
id
=
$
answerregs
[
1
]
;
$wrappedquestion
->
id
=
$
questionid
;
$wrappedquestion
->
questiontext
=
get_string
(
'questiondeleted'
,
'quiz'
);
$wrappedquestion
->
qtype
=
'missingtype'
;
}
$state
->
responses
[
''
]
=
(
false
===
$answerregs
[
2
])
?
'
'
:
$
answerregs
[
2
]
;
$state
->
responses
[
''
]
=
substr
(
$state
->
responses
[
''
],
strlen
(
'random
'
.
$
questionid
.
'-'
))
;
}
if
(
!
$QTYPES
[
$wrappedquestion
->
qtype
]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment