Skip to content

Commit e76ad37

Browse files
committed
ISSUE-868: Cannot transform lesson
ISSUE-868: Cannot transform lesson
1 parent adeacf9 commit e76ad37

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/transformer/utils/get_activity/lesson_question_page.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function lesson_question_page(array $config, \stdClass $course, \stdClass $lesso
5353
});
5454

5555
switch ($page->qtype) {
56-
case LESSON_PAGE_SHORTANSWER:
56+
case 1: // LESSON_PAGE_SHORTANSWER.
5757
$correctresponses = array_values(
5858
array_map(
5959
function($answer) {
@@ -70,16 +70,16 @@ function($answer) {
7070
$correctresponses
7171
);
7272
break;
73-
case LESSON_PAGE_ESSAY:
73+
case 10: // LESSON_PAGE_ESSAY.
7474
$activity['definition'] = utils\get_activity\definition\cmi\long_fill_in(
7575
$config,
7676
$page->title,
7777
utils\get_string_html_removed($page->contents),
7878
$courselang
7979
);
8080
break;
81-
case LESSON_PAGE_TRUEFALSE:
82-
case LESSON_PAGE_MULTICHOICE:
81+
case 2: // LESSON_PAGE_TRUEFALSE.
82+
case 3: // LESSON_PAGE_MULTICHOICE.
8383
$choices = array_values(
8484
array_map(
8585
function($answer) {
@@ -105,7 +105,7 @@ function($answer) {
105105
$correctchoices
106106
);
107107
break;
108-
case LESSON_PAGE_MATCHING:
108+
case 5: // LESSON_PAGE_MATCHING.
109109
$source = [];
110110
$target = [];
111111
foreach ($answers as $a) {
@@ -123,7 +123,7 @@ function($answer) {
123123
$courselang
124124
);
125125
break;
126-
case LESSON_PAGE_NUMERICAL:
126+
case 8: // LESSON_PAGE_NUMERICAL.
127127
// XAPI Numerical can only have one discrete correct response, or a
128128
// range but lessons do not support ranges, so taking first correct
129129
// answer to cover most cases.

src/transformer/utils/get_lesson_question_result.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ function get_lesson_question_result(array $config, \stdClass $lesson, \stdClass
4646
], 'timeseen DESC');
4747
if (!empty($attempts)) {
4848
$attempt = reset($attempts);
49-
if ($page->qtype == LESSON_PAGE_ESSAY) {
49+
if ($page->qtype == 10) { // LESSON_PAGE_ESSAY.
5050
// Essay is graded later, and is also serialized into an object.
5151
$essay = unserialize($attempt->useranswer);
5252
$result['response'] = get_string_html_removed($essay->answer);
53-
} else if ($page->qtype == LESSON_PAGE_MATCHING) {
53+
} else if ($page->qtype == 5) { // LESSON_PAGE_MATCHING.
5454
// Matching is the tricky one because the stored response is
5555
// nothing like the xapi expectation. We need to merge the answers
5656
// with the responses.

0 commit comments

Comments
 (0)