Merge branch 'MDL-46195' of git://github.com/timhunt/moodle

This commit is contained in:
Dan Poltawski
2014-09-15 16:07:05 +01:00
4 changed files with 40 additions and 19 deletions
+1 -1
View File
@@ -221,7 +221,7 @@ function lesson_save_question_options($question, $lesson) {
$totalfraction = round($totalfraction,2);
if ($totalfraction != 1) {
$totalfraction = $totalfraction * 100;
$result->notice = get_string("fractionsaddwrong", "quiz", $totalfraction);
$result->notice = get_string("fractionsaddwrong", "qtype_multichoice", $totalfraction);
return $result;
}
}
+1 -1
View File
@@ -230,7 +230,7 @@ class qformat_default {
echo "<strong>{$message}</strong>\n";
echo "</div>";
$this->importerrors++;
$this->importerrors++;
}
/**
+8 -17
View File
@@ -337,7 +337,6 @@ class qformat_webct extends qformat_default {
'[+-]?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)((e|E|\\*10\\*\\*)([+-]?[0-9]+|\\([+-]?[0-9]+\\)))?';
$questions = array();
$errors = array();
$warnings = array();
$webctoptions = array();
@@ -453,7 +452,7 @@ class qformat_webct extends qformat_default {
$questionok = false;
}
if (count($question->answer) < 1) { // A question must have at least 1 answer.
$errors[] = get_string('missinganswer', 'qformat_webct', $nquestionstartline);
$this->error(get_string('missinganswer', 'qformat_webct', $nquestionstartline), '', $question->name);
$questionok = false;
} else {
// Create empty feedback array.
@@ -497,8 +496,8 @@ class qformat_webct extends qformat_default {
case 'shortanswer':
if ($maxfraction != 1) {
$maxfraction = $maxfraction * 100;
$errors[] = "'{$question->name}': ".get_string('wronggrade', 'qformat_webct', $nlinecounter)
.' '.get_string('fractionsnomax', 'question', $maxfraction);
$this->error(get_string('wronggrade', 'qformat_webct', $nlinecounter)
.' '.get_string('fractionsnomax', 'question', $maxfraction), '', $question->name);;
$questionok = false;
}
break;
@@ -509,16 +508,17 @@ class qformat_webct extends qformat_default {
if ($question->single) {
if ($maxfraction != 1) {
$maxfraction = $maxfraction * 100;
$errors[] = "'{$question->name}': ".get_string('wronggrade', 'qformat_webct', $nlinecounter)
.' '.get_string('fractionsnomax', 'question', $maxfraction);
$this->error(get_string('wronggrade', 'qformat_webct', $nlinecounter)
.' '.get_string('fractionsnomax', 'question', $maxfraction), '', $question->name);
$questionok = false;
}
} else {
$totalfraction = round($totalfraction, 2);
if ($totalfraction != 1) {
$totalfraction = $totalfraction * 100;
$errors[] = "'{$question->name}': ".get_string('wronggrade', 'qformat_webct', $nlinecounter)
.' '.get_string('fractionsaddwrong', 'question', $totalfraction);
$this->error(get_string('wronggrade', 'qformat_webct', $nlinecounter)
.' '.get_string('fractionsaddwrong', 'qtype_multichoice', $totalfraction),
'', $question->name);
$questionok = false;
}
}
@@ -852,15 +852,6 @@ class qformat_webct extends qformat_default {
}
}
if (count($errors) > 0) {
echo '<p>'.get_string('errorsdetected', 'qformat_webct', count($errors)).'</p><ul>';
foreach ($errors as $error) {
echo "<li>{$error}</li>";
}
echo '</ul>';
unset($questions); // No questions imported.
}
if (count($warnings) > 0) {
echo '<p>'.get_string('warningsdetected', 'qformat_webct', count($warnings)).'</p><ul>';
foreach ($warnings as $warning) {
@@ -0,0 +1,30 @@
@qtype @qformat_webct
Feature: Test importing questions from WebCT format.
In order to reuse questions from am obsolete commercial LMS
As an teacher
I need to be able to import them in WebCT format.
Background:
Given the following "courses" exist:
| fullname | shortname | format |
| Course 1 | C1 | topics |
And the following "users" exist:
| username | firstname |
| teacher | Teacher |
And the following "course enrolments" exist:
| user | course | role |
| teacher | C1 | editingteacher |
And I log in as "teacher"
And I follow "Course 1"
@javascript @_file_upload
Scenario: import some WebCT questions
When I navigate to "Import" node in "Course administration > Question bank"
And I set the field "id_format_webct" to "1"
And I upload "question/format/webct/tests/fixtures/sample_webct.txt" file to "Import" filemanager
And I press "id_submitbutton"
Then I should see "Parsing questions from import file."
And I should see "Importing 6 questions from file"
And I should see "What's between orange and green in the spectrum?"
When I press "Continue"
Then I should see "USER-3"