Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt mobile code to ionic 7 #17

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
26 changes: 12 additions & 14 deletions mobile/oumr.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
<section ion-list *ngIf="question.text || question.text === ''" class="qtype-oumultiresponse">
<ion-item text-wrap>
<p>
<core-format-text [component]="component" [componentId]="componentId" [text]="question.text"></core-format-text>
</p>
<p *ngIf="question.prompt">
<core-format-text [component]="component" [componentId]="componentId" [text]="question.prompt"></core-format-text>
</p>
<ion-item class="ion-text-wrap">
<ion-label>
<p>
<core-format-text [component]="component" [componentId]="componentId" [text]="question.text"></core-format-text>
</p>
<p *ngIf="question.prompt">
<core-format-text [component]="component" [componentId]="componentId" [text]="question.prompt"></core-format-text>
</p>
</ion-label>
</ion-item>
<ng-container>
<ion-item text-wrap *ngFor="let option of question.options" [ngClass]="option.qclass">
<ion-label>
<ion-item class="ion-text-wrap" *ngFor="let option of question.options" [ngClass]="option.qclass">
<ion-checkbox [attr.name]="option.name" [(ngModel)]="option.checked" [disabled]="option.disabled">
<core-format-text [component]="component" [componentId]="componentId" [text]="option.text"></core-format-text>
<p *ngIf="option.feedback" class="core-question-feedback-container">
<core-format-text [text]="option.feedback"></core-format-text>
</p>
</ion-label>
<ion-checkbox [attr.name]="option.name" [(ngModel)]="option.checked" [disabled]="option.disabled"
item-end></ion-checkbox>
<!-- ion-checkbox doesn't use an input. Create a hidden input to hold the value. -->
<input item-content type="hidden" [ngModel]="option.checked" [attr.name]="option.name">
</ion-checkbox>
</ion-item>
</ng-container>
</section>
6 changes: 3 additions & 3 deletions mobile/oumr.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ var result = {
var divs = answeroptions.querySelectorAll('div[class^=r]'); // Only get the answer options divs (class="r0...").
divs.forEach(function(d, i) {
// Each answer option contains all the data for presentation, it just needs extracting.
var label = d.querySelector('label').innerHTML;
var name = d.querySelector('label').getAttribute('for');
var label = d.querySelector('[id$="_label"]').innerHTML;
var name = d.querySelector('input[type=checkbox]').getAttribute('name');
var checked = (d.querySelector('input[type=checkbox]').getAttribute('checked') ? true : false);
var disabled = (d.querySelector('input').getAttribute('disabled') === 'disabled' ? true : false);
var feedback = (d.querySelector('div') ? d.querySelector('div').innerHTML : '');
var feedback = d.querySelector('.core-question-feedback-inline')?.innerHTML ?? '';
var qclass = d.getAttribute('class');
options.push({text: label, name: name, checked: checked, disabled: disabled, feedback: feedback, qclass: qclass});
});
Expand Down