Skip to content

Commit

Permalink
Merge pull request #3814 from dpalou/MOBILE-4362
Browse files Browse the repository at this point in the history
Mobile 4362
  • Loading branch information
NoelDeMartin authored Oct 10, 2023
2 parents 78aacf8 + 5b9d262 commit aebbe33
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/addons/mod/lesson/pages/player/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
this.eolData = data.data;
this.messages = this.messages.concat(data.messages);
this.processData = undefined;
this.endTime = undefined;

CoreEvents.trigger(CoreEvents.ACTIVITY_DATA_SENT, { module: 'lesson' });

Expand Down
7 changes: 5 additions & 2 deletions src/addons/mod/lesson/pages/user-retake/user-retake.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ <h2>{{student.fullname}}</h2>
<ng-container *ngIf="page.isQuestion">
<!-- Question page, show the right input for the answer. -->

<!-- Truefalse or matching. -->
<!-- Truefalse or multichoice. -->
<ion-item class="ion-text-wrap" *ngIf="answer[0].isCheckbox"
[ngClass]="{'addon-mod_lesson-highlight': answer[0].highlight}">
<ion-label>
Expand All @@ -138,12 +138,15 @@ <h2>{{student.fullname}}</h2>
[courseId]="courseId">
</core-format-text>
</p>
<ion-badge *ngIf="answer[1]" color="dark">
<ion-badge *ngIf="answer[1]" color="dark" class="addon-mod_lesson-answer-stats">
<core-format-text [component]="component" [componentId]="lesson?.coursemodule"
[text]="answer[1]" contextLevel="module" [contextInstanceId]="lesson?.coursemodule"
[courseId]="courseId">
</core-format-text>
</ion-badge>
<ion-badge *ngIf="answer[0].successBadge" color="success" class="addon-mod_lesson-answer-success">
{{ answer[0].successBadge }}
</ion-badge>
</ion-label>
<ion-checkbox [attr.name]="answer[0].name" [ngModel]="answer[0].checked" [disabled]="true" slot="end">
</ion-checkbox>
Expand Down
6 changes: 6 additions & 0 deletions src/addons/mod/lesson/pages/user-retake/user-retake.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import "~theme/globals";

:host {
.button-disabled {
opacity: 0.4;
Expand All @@ -14,4 +16,8 @@
.item-interactive-disabled ion-label {
opacity: 0.5;
}

.addon-mod_lesson-answer-success {
@include margin-horizontal(4px, null);
}
}
8 changes: 6 additions & 2 deletions src/addons/mod/lesson/services/lesson-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,25 +461,28 @@ export class AddonModLessonHelperProvider {
const element = CoreDomUtils.convertToElement(html);

// Check if it has a checkbox.
let input = <HTMLInputElement> element.querySelector('input[type="checkbox"][name*="answer"]');
let input = element.querySelector<HTMLInputElement>('input[type="checkbox"][name*="answer"]');
if (input) {
// Truefalse or multichoice.
const successBadge = element.querySelector<HTMLElement>('.badge.badge-success');
const data: AddonModLessonCheckboxAnswerData = {
isCheckbox: true,
checked: !!input.checked,
name: input.name,
highlight: !!element.querySelector('.highlight'),
content: '',
successBadge: successBadge?.innerText,
};

input.remove();
successBadge?.remove();
data.content = element.innerHTML.trim();

return data;
}

// Check if it has an input text or number.
input = <HTMLInputElement> element.querySelector('input[type="number"],input[type="text"]');
input = element.querySelector<HTMLInputElement>('input[type="number"],input[type="text"]');
if (input) {
// Short answer or numeric.
return {
Expand Down Expand Up @@ -700,6 +703,7 @@ export type AddonModLessonCheckboxAnswerData = {
name: string;
highlight: boolean;
content: string;
successBadge?: string;
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ Feature: Test attempts and grading settings of SCORM activity in app
And I press the back button in the app
Then I should find "74%" within "Grade reported" "ion-item" in the app

@lms_from4.1
Scenario: SCORM grade is calculated right based on 'Attempts grading' setting
Given the following "activities" exist:
| activity | name | course | idnumber | packagefilepath | maxattempt | whatgrade | grademethod | forcenewattempt |
Expand Down
1 change: 1 addition & 0 deletions src/addons/mod/scorm/tests/behat/availability.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Feature: Test availability options of SCORM activity in app
| scorm | C1 | Current SCORM | mod/scorm/tests/packages/singlesco_scorm12.zip | ##yesterday## | ##tomorrow## |
| scorm | C1 | Future SCORM | mod/scorm/tests/packages/singlesco_scorm12.zip | ##tomorrow## | ##+2 days## |

@lms_from4.1
Scenario: Only open SCORMs can be played
Given I entered the course "Course 1" as "student1" in the app
When I press "Past SCORM" in the app
Expand Down
3 changes: 2 additions & 1 deletion src/addons/mod/scorm/tests/behat/basic_usage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,15 @@ Feature: Test basic usage of SCORM activity in app
| activity | name | course | idnumber | packagefilepath |
| scorm | Basic SCORM | C1 | scorm | mod/scorm/tests/packages/RuntimeMinimumCalls_SCORM12-mini.zip |
And I entered the course "Course 1" as "student1" in the app
And I change viewport size to "1200x640" in the app
When I press "Basic SCORM" in the app
And I press "Enter" in the app
And I press "Disable fullscreen" in the app
Then I should find "2 / 11" in the app

When I open a browser tab with url "$WWWROOT"
And I log in as "admin"
And I am on the "System logs report" page
And I navigate to "Reports > Reports > Logs" in site administration
And I set the field "id" to "Course 1"
And I set the field "user" to "Student student"
And I press "Get these logs"
Expand Down
2 changes: 1 addition & 1 deletion src/core/services/utils/iframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export class CoreIframeUtilsProvider {
*/
getContentWindowAndDocument(element: CoreFrameElement): { window: Window | null; document: Document | null } {
const src = 'src' in element ? element.src : element.data;
if (!CoreUrlUtils.isLocalFileUrl(src)) {
if (src !== 'about:blank' && !CoreUrlUtils.isLocalFileUrl(src)) {
// No permissions to access the iframe.
return { window: null, document: null };
}
Expand Down

0 comments on commit aebbe33

Please sign in to comment.