Merge branch 'MDL-48473' of git://github.com/jmvedrine/moodle

This commit is contained in:
Eloy Lafuente (stronk7)
2014-12-16 01:12:56 +01:00
3 changed files with 197 additions and 8 deletions
+18 -8
View File
@@ -350,21 +350,31 @@ class lesson_display_answer_form_shortanswer extends moodleform {
}
}
$placeholder = false;
if (preg_match('/_____+/', $contents, $matches)) {
$placeholder = $matches[0];
$contentsparts = explode( $placeholder, $contents, 2);
$attrs['size'] = round(strlen($placeholder) * 1.1);
}
$mform->addElement('header', 'pageheader');
$mform->addElement('html', $OUTPUT->container($contents, 'contents'));
$options = new stdClass;
$options->para = false;
$options->noclean = true;
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'pageid');
$mform->setType('pageid', PARAM_INT);
$mform->addElement('text', 'answer', get_string('youranswer', 'lesson'), $attrs);
if ($placeholder) {
$contentsgroup = array();
$contentsgroup[] = $mform->createElement('static', '', '', $contentsparts[0]);
$contentsgroup[] = $mform->createElement('text', 'answer', '', $attrs);
$contentsgroup[] = $mform->createElement('static', '', '', $contentsparts[1]);
$mform->addGroup($contentsgroup, '', '', '', false);
} else {
$mform->addElement('html', $OUTPUT->container($contents, 'contents'));
$mform->addElement('text', 'answer', get_string('youranswer', 'lesson'), $attrs);
}
$mform->setType('answer', PARAM_TEXT);
if ($hasattempt) {
@@ -0,0 +1,41 @@
@mod @mod_lesson
Feature: In a lesson activity, teacher can import blackboard fill in the blank question
As a teacher
I need to import a fill in the blank question made in Blackboard in a lesson
@javascript @_file_upload
Scenario: Import fill in the blank question in a lesson
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@asd.com |
| student1 | Student | 1 | student1@asd.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I log in as "teacher1"
When I am on homepage
And I follow "Course 1"
And I turn editing mode on
And I add a "Lesson" to section "1" and I fill the form with:
| Name | Test lesson name |
| Description | Test lesson description |
And I follow "Test lesson name"
And I follow "Import questions"
And I set the field "File format" to "Blackboard"
And I upload "mod/lesson/tests/fixtures/sample_blackboard_fib_qti.dat" file to "Upload" filemanager
And I press "Import"
Then I should see "Importing 1 questions"
And I should see "Name an amphibian: __________"
And I press "Continue"
And I should not see "__________"
And I should not see "Your answer"
And I set the field "id_answer" to "frog"
And I press "Submit"
And I should see "Your answer : frog"
And I should see "A frog is an amphibian"
And I press "Continue"
And I should see "Congratulations - end of lesson reached"
+138
View File
@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8"?>
<questestinterop>
<assessment title="sample_blackboard_six">
<section>
<item maxattempts="0">
<itemmetadata>
<bbmd_asi_object_id>DD76E663D4244C598FC91CFC433F6D5B</bbmd_asi_object_id>
<bbmd_asitype>Item</bbmd_asitype>
<bbmd_assessmenttype>Pool</bbmd_assessmenttype>
<bbmd_sectiontype>Subsection</bbmd_sectiontype>
<bbmd_questiontype>Fill in the Blank</bbmd_questiontype>
<bbmd_is_from_cartridge>false</bbmd_is_from_cartridge>
<qmd_absolutescore>0.0,1.0</qmd_absolutescore>
<qmd_absolutescore_min>0.0</qmd_absolutescore_min>
<qmd_absolutescore_max>1.0</qmd_absolutescore_max>
<qmd_assessmenttype>Proprietary</qmd_assessmenttype>
<qmd_itemtype>Logical Identifier</qmd_itemtype>
<qmd_levelofdifficulty>School</qmd_levelofdifficulty>
<qmd_maximumscore>0.0</qmd_maximumscore>
<qmd_numberofitems>0</qmd_numberofitems>
<qmd_renderingtype>Proprietary</qmd_renderingtype>
<qmd_responsetype>Single</qmd_responsetype>
<qmd_scoretype>Absolute</qmd_scoretype>
<qmd_status>Normal</qmd_status>
<qmd_timelimit>0</qmd_timelimit>
<qmd_weighting>0.0</qmd_weighting>
<qmd_typeofsolution>Complete</qmd_typeofsolution>
</itemmetadata>
<presentation>
<flow class="Block">
<flow class="QUESTION_BLOCK">
<flow class="FORMATTED_TEXT_BLOCK">
<material>
<mat_extension>
<mat_formattedtext type="HTML">&lt;span style="font-size:12pt"&gt;Name an amphibian&amp;#58; __________.&lt;/span&gt;</mat_formattedtext>
</mat_extension>
</material>
</flow>
<flow class="FILE_BLOCK">
<material/>
</flow>
<flow class="LINK_BLOCK">
<material>
<mattext charset="us-ascii" texttype="text/plain" uri="" xml:space="default"/>
</material>
</flow>
</flow>
<flow class="RESPONSE_BLOCK">
<response_str ident="response" rcardinality="Single" rtiming="No">
<render_fib charset="us-ascii" columns="127" encoding="UTF_8" fibtype="String" maxchars="0" maxnumber="0" minnumber="0" prompt="Box" rows="1"/>
</response_str>
</flow>
</flow>
</presentation>
<resprocessing scoremodel="SumOfScores">
<outcomes>
<decvar defaultval="0.0" maxvalue="1.0" minvalue="0.0" varname="SCORE" vartype="Decimal"/>
</outcomes>
<respcondition title="1CE934E53BDB437B8FD315E68063DA47">
<conditionvar>
<varequal case="No" respident="response">frog</varequal>
</conditionvar>
<displayfeedback feedbacktype="Response" linkrefid="correct"/>
<displayfeedback feedbacktype="Response" linkrefid="1CE934E53BDB437B8FD315E68063DA47"/>
</respcondition>
<respcondition title="incorrect">
<conditionvar>
<other/>
</conditionvar>
<setvar action="Set" variablename="SCORE">0.0</setvar>
<displayfeedback feedbacktype="Response" linkrefid="incorrect"/>
</respcondition>
</resprocessing>
<itemfeedback ident="correct" view="All">
<flow_mat class="Block">
<flow_mat class="FORMATTED_TEXT_BLOCK">
<material>
<mat_extension>
<mat_formattedtext type="HTML">A frog is an amphibian.</mat_formattedtext>
</mat_extension>
</material>
</flow_mat>
<flow_mat class="FILE_BLOCK">
<material/>
</flow_mat>
<flow_mat class="LINK_BLOCK">
<material>
<mattext charset="us-ascii" texttype="text/plain" uri="" xml:space="default"/>
</material>
</flow_mat>
</flow_mat>
</itemfeedback>
<itemfeedback ident="incorrect" view="All">
<flow_mat class="Block">
<flow_mat class="FORMATTED_TEXT_BLOCK">
<material>
<mat_extension>
<mat_formattedtext type="HTML">A frog is an amphibian.</mat_formattedtext>
</mat_extension>
</material>
</flow_mat>
<flow_mat class="FILE_BLOCK">
<material/>
</flow_mat>
<flow_mat class="LINK_BLOCK">
<material>
<mattext charset="us-ascii" texttype="text/plain" uri="" xml:space="default"/>
</material>
</flow_mat>
</flow_mat>
</itemfeedback>
<itemfeedback ident="1CE934E53BDB437B8FD315E68063DA47" view="All">
<solution feedbackstyle="Complete" view="All">
<solutionmaterial>
<flow_mat class="Block">
<flow_mat class="FORMATTED_TEXT_BLOCK">
<material>
<mat_extension>
<mat_formattedtext type="HTML">A frog is an amphibian.</mat_formattedtext>
</mat_extension>
</material>
</flow_mat>
<flow_mat class="FILE_BLOCK">
<material/>
</flow_mat>
<flow_mat class="LINK_BLOCK">
<material>
<mattext charset="us-ascii" texttype="text/plain" uri="" xml:space="default"/>
</material>
</flow_mat>
</flow_mat>
</solutionmaterial>
</solution>
</itemfeedback>
</item>
</section>
</assessment>
</questestinterop>