Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/transformer/utils/get_activity/lesson_question_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function lesson_question_page(array $config, \stdClass $course, \stdClass $lesso
});

switch ($page->qtype) {
case LESSON_PAGE_SHORTANSWER:
case 1: // LESSON_PAGE_SHORTANSWER.
$correctresponses = array_values(
array_map(
function($answer) {
Expand All @@ -70,16 +70,16 @@ function($answer) {
$correctresponses
);
break;
case LESSON_PAGE_ESSAY:
case 10: // LESSON_PAGE_ESSAY.
$activity['definition'] = utils\get_activity\definition\cmi\long_fill_in(
$config,
$page->title,
utils\get_string_html_removed($page->contents),
$courselang
);
break;
case LESSON_PAGE_TRUEFALSE:
case LESSON_PAGE_MULTICHOICE:
case 2: // LESSON_PAGE_TRUEFALSE.
case 3: // LESSON_PAGE_MULTICHOICE.
$choices = array_values(
array_map(
function($answer) {
Expand All @@ -105,7 +105,7 @@ function($answer) {
$correctchoices
);
break;
case LESSON_PAGE_MATCHING:
case 5: // LESSON_PAGE_MATCHING.
$source = [];
$target = [];
foreach ($answers as $a) {
Expand All @@ -123,7 +123,7 @@ function($answer) {
$courselang
);
break;
case LESSON_PAGE_NUMERICAL:
case 8: // LESSON_PAGE_NUMERICAL.
// XAPI Numerical can only have one discrete correct response, or a
// range but lessons do not support ranges, so taking first correct
// answer to cover most cases.
Expand Down
4 changes: 2 additions & 2 deletions src/transformer/utils/get_lesson_question_result.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ function get_lesson_question_result(array $config, \stdClass $lesson, \stdClass
], 'timeseen DESC');
if (!empty($attempts)) {
$attempt = reset($attempts);
if ($page->qtype == LESSON_PAGE_ESSAY) {
if ($page->qtype == 10) { // LESSON_PAGE_ESSAY.
// Essay is graded later, and is also serialized into an object.
$essay = unserialize($attempt->useranswer);
$result['response'] = get_string_html_removed($essay->answer);
} else if ($page->qtype == LESSON_PAGE_MATCHING) {
} else if ($page->qtype == 5) { // LESSON_PAGE_MATCHING.
// Matching is the tricky one because the stored response is
// nothing like the xapi expectation. We need to merge the answers
// with the responses.
Expand Down