Skip to content

Commit 5c503ea

Browse files
committed
MOBILE-1987 quiz: Fix styling match questions
1 parent 2c59a8b commit 5c503ea

File tree

4 files changed

+53
-17
lines changed

4 files changed

+53
-17
lines changed
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
// Style match content a bit.
2-
.mma-qtype-match-container {
3-
select {
2+
.mma-qtype-match-container .item-select {
3+
select,
4+
.mm-select-fix {
45
padding: 0 36px 0 0;
56
max-width: 100%;
7+
display: flex;
8+
justify-content:center;
9+
align-content:center;
10+
flex-direction:column;
611
}
712
}

www/addons/qtype/match/template.html

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
<div class="item item-text-wrap">
33
<p><mm-format-text watch="true" component="{{component}}" component-id="{{componentId}}">{{ question.text }}</mm-format-text></p>
44
</div>
5-
<div class="item item-text-wrap row mm-item-padding" ng-repeat="row in question.rows">
6-
<div class="col">
7-
<p><mm-format-text watch="true" id="mma-question-{{row.id}}" component="{{component}}" component-id="{{componentId}}">{{ row.text }}</mm-format-text></p>
8-
</div>
9-
<div class="col text-center item-select" ng-class='{"mm-question-answer-correct": row.isCorrect === 1, "mm-question-answer-incorrect": row.isCorrect === 0}'>
10-
<label class="accesshide" for="{{row.id}}" ng-if="row.accessibilityLabel">{{ row.accessibilityLabel }}</label>
11-
<select id="{{row.id}}" name="{{row.name}}" ng-disabled="row.disabled" aria-labelledby="mma-question-{{row.id}}" mm-ios-select-fix>
12-
<option ng-repeat="o in row.options" value="{{o.value}}" label="{{o.label}}" ng-selected="{{o.selected}}">{{o.label}}</option>
13-
</select>
14-
</div>
15-
</div>
5+
<div class="item item-text-wrap row mm-item-padding" ng-repeat="row in question.rows">
6+
<div class="col">
7+
<p><mm-format-text watch="true" id="mma-question-{{row.id}}" component="{{component}}" component-id="{{componentId}}">{{ row.text }}</mm-format-text></p>
8+
</div>
9+
<div class="col" ng-class='{"item-select": !row.disabled, "mm-question-answer-correct": row.isCorrect === 1, "mm-question-answer-incorrect": row.isCorrect === 0}'>
10+
<label class="accesshide" for="{{row.id}}" ng-if="row.accessibilityLabel">{{ row.accessibilityLabel }}</label>
11+
<select id="{{row.id}}" name="{{row.name}}" ng-if="!row.disabled" aria-labelledby="mma-question-{{row.id}}" ng-options="option.label for option in row.options track by option.value" ng-model="row.selected" mm-ios-select-fix>
12+
</select>
13+
<p class="mm-select-fix" ng-if="row.selected && row.selected.label">
14+
{{row.selected.label}}
15+
</p>
16+
</div>
17+
</div>
1618
</section>

www/core/components/question/services/helper.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ angular.module('mm.core.question')
687687
rowModel.id = select.id;
688688
rowModel.name = select.name;
689689
rowModel.disabled = select.disabled;
690+
rowModel.selected = false;
690691
rowModel.options = [];
691692

692693
// Check if answer is correct.
@@ -702,12 +703,17 @@ angular.module('mm.core.question')
702703
log.warn('Aborting because couldn\'t find option value.', question.name);
703704
return self.showDirectiveError(scope);
704705
}
705-
706-
rowModel.options.push({
706+
var opt = {
707707
value: option.value,
708708
label: option.innerHTML,
709709
selected: option.selected
710-
});
710+
};
711+
712+
if (opt.selected) {
713+
rowModel.selected = opt;
714+
}
715+
716+
rowModel.options.push(opt);
711717
});
712718

713719
// Get the accessibility label.

www/core/scss/styles.scss

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ mm-navigation-bar {
581581

582582
// When using .item and .row in the same element, .row's padding prevails. Use this class to keep .item's padding.
583583
.item.row.mm-item-padding {
584-
padding: $item-padding;
584+
padding: $item-padding / 2;
585585
}
586586

587587
p.mm-error {
@@ -746,6 +746,28 @@ mm-timer {
746746
}
747747
}
748748

749+
.item-select .mm-select-fix {
750+
// Taken from .item-select select.
751+
position: absolute;
752+
top: 0;
753+
bottom: 0;
754+
right: 0;
755+
padding: 0 ($item-padding * 3) 0 $item-padding;
756+
max-width: 65%;
757+
width: 100%;
758+
border: none;
759+
background: $item-default-bg;
760+
color: #333;
761+
text-indent: .01px;
762+
white-space: nowrap;
763+
font-size: $font-size-base;
764+
cursor: pointer;
765+
direction: rtl; // right align the select text
766+
767+
pointer-events: none;
768+
}
769+
770+
749771
.item-input-inset .item-input-wrapper input,
750772
.item-input .item-input-wrapper input {
751773
width: 100%;
@@ -923,6 +945,7 @@ mm-timer {
923945

924946
.input-label, .mm-textarea {
925947
padding-left: $item-padding;
948+
padding-top: $item-padding/2;
926949
}
927950
}
928951

0 commit comments

Comments
 (0)