Skip to content

Commit

Permalink
Merge branch 'MDL-63827' of https://github.com/timhunt/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
Damyon Wiese committed Nov 5, 2018
2 parents 5aed9a4 + 3a8cde2 commit 842138a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 8 deletions.
16 changes: 8 additions & 8 deletions question/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -576,10 +576,10 @@ protected function create_category_path($catpath, $lastcategoryinfo = null) {
// 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);
Expand All @@ -601,10 +601,10 @@ protected function create_category_path($catpath, $lastcategoryinfo = null) {
$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;
}
}
Expand Down Expand Up @@ -703,7 +703,7 @@ protected function defaultquestion() {
$question = new stdClass();
$question->shuffleanswers = $defaultshuffleanswers;
$question->defaultmark = 1;
$question->image = "";
$question->image = '';
$question->usecase = 0;
$question->multiplier = array();
$question->questiontextformat = FORMAT_MOODLE;
Expand Down Expand Up @@ -874,7 +874,7 @@ public function exportprocess($checkcapabilities = true) {

// 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
Expand Down
12 changes: 12 additions & 0 deletions question/format/gift/tests/behat/import_export.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 27 additions & 0 deletions question/format/gift/tests/fixtures/questions_in_category.gift.txt
Original file line number Diff line number Diff line change
@@ -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}

0 comments on commit 842138a

Please sign in to comment.