mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
MDL-63827 qformat_gift: fix notice when importing categories
This commit is contained in:
parent
8b019fb709
commit
3a8cde29a4
@ -576,10 +576,10 @@ class qformat_default {
|
||||
// Do nothing unless the child category appears before the parent category
|
||||
// in the imported xml file. Because the parent was created without info being available
|
||||
// at that time, this allows the info to be added from the xml data.
|
||||
if ($key == (count($catnames) - 1) && $lastcategoryinfo && $lastcategoryinfo->info !== null &&
|
||||
$lastcategoryinfo->info !== "" && $category->info == "") {
|
||||
if ($key == (count($catnames) - 1) && $lastcategoryinfo && isset($lastcategoryinfo->info) &&
|
||||
$lastcategoryinfo->info !== '' && $category->info === '') {
|
||||
$category->info = $lastcategoryinfo->info;
|
||||
if ($lastcategoryinfo->infoformat !== null && $lastcategoryinfo->infoformat !== "") {
|
||||
if (isset($lastcategoryinfo->infoformat) && $lastcategoryinfo->infoformat !== '') {
|
||||
$category->infoformat = $lastcategoryinfo->infoformat;
|
||||
}
|
||||
$DB->update_record('question_categories', $category);
|
||||
@ -601,10 +601,10 @@ class qformat_default {
|
||||
$category->name = $catname;
|
||||
$category->info = '';
|
||||
// Only add info (category description) for the final category in the catpath.
|
||||
if ($key == (count($catnames) - 1) && $lastcategoryinfo && $lastcategoryinfo->info !== null &&
|
||||
$lastcategoryinfo->info !== "") {
|
||||
if ($key == (count($catnames) - 1) && $lastcategoryinfo && isset($lastcategoryinfo->info) &&
|
||||
$lastcategoryinfo->info !== '') {
|
||||
$category->info = $lastcategoryinfo->info;
|
||||
if ($lastcategoryinfo->infoformat !== null && $lastcategoryinfo->infoformat !== "") {
|
||||
if (isset($lastcategoryinfo->infoformat) && $lastcategoryinfo->infoformat !== '') {
|
||||
$category->infoformat = $lastcategoryinfo->infoformat;
|
||||
}
|
||||
}
|
||||
@ -703,7 +703,7 @@ class qformat_default {
|
||||
$question = new stdClass();
|
||||
$question->shuffleanswers = $defaultshuffleanswers;
|
||||
$question->defaultmark = 1;
|
||||
$question->image = "";
|
||||
$question->image = '';
|
||||
$question->usecase = 0;
|
||||
$question->multiplier = array();
|
||||
$question->questiontextformat = FORMAT_MOODLE;
|
||||
@ -874,7 +874,7 @@ class qformat_default {
|
||||
|
||||
// results are first written into string (and then to a file)
|
||||
// so create/initialize the string here
|
||||
$expout = "";
|
||||
$expout = '';
|
||||
|
||||
// track which category questions are in
|
||||
// if it changes we will record the category change in the output
|
||||
|
@ -34,3 +34,15 @@ Feature: Test importing questions from GIFT format.
|
||||
And I set the field "id_format_gift" to "1"
|
||||
And I press "Export questions to file"
|
||||
And following "click here" should download between "1500" and "1800" bytes
|
||||
|
||||
@javascript @_file_upload
|
||||
Scenario: import a GIFT file which specifies the category
|
||||
When I navigate to "Question bank > Import" in current page administration
|
||||
And I set the field "id_format_gift" to "1"
|
||||
And I upload "question/format/gift/tests/fixtures/questions_in_category.gift.txt" file to "Import" filemanager
|
||||
And I press "id_submitbutton"
|
||||
Then I should see "Parsing questions from import file."
|
||||
And I should see "Importing 4 questions from file"
|
||||
And I should see "Match the activity to the description."
|
||||
When I press "Continue"
|
||||
Then I should see "Moodle activities"
|
||||
|
27
question/format/gift/tests/fixtures/questions_in_category.gift.txt
vendored
Normal file
27
question/format/gift/tests/fixtures/questions_in_category.gift.txt
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
// question: 0 name: switch category to $course$/Default for New Features
|
||||
$CATEGORY: $course$/Default for New Features
|
||||
|
||||
// question: 44 name: Moodle activities
|
||||
::Moodle activities::[html]Match the activity to the description.{
|
||||
=An activity supporting asynchronous discussions. -> Forum
|
||||
=A teacher asks a question and specifies a choice of multiple responses. -> Choice
|
||||
=A bank of record entries which participants can add to. -> Database
|
||||
=A collection of web pages that anyone can add to or edit. -> Wiki
|
||||
= -> Chat
|
||||
}
|
||||
|
||||
// question: 43 name: Greeting
|
||||
::Greeting::[html]<a href\="http\://demo.moodle.net/file.php/5/media/bonjour.mp3">Listen to this greeting\:</a><br /><br />What language is being spoken?{
|
||||
~English#Sorry, listen again.
|
||||
=French#Yes, well done!
|
||||
~German#Sorry, listen again.
|
||||
~Spanish#Sorry, listen again.
|
||||
}
|
||||
|
||||
// question: 46 name: Moodle user
|
||||
::Moodle user::[html]Anyone who uses Moodle is a ...{
|
||||
=%100%Moodler#
|
||||
}
|
||||
|
||||
// question: 45 name: Moodle acronym
|
||||
::Moodle acronym::[html]Moodle is an acronym for <span style\="font-style\: italic;">Modular Object-Oriented Dynamic Learning Environment</span>.{TRUE}
|
Loading…
x
Reference in New Issue
Block a user