-
-
+
+
+
+
{{ 'core.question.howtodraganddrop' | translate }}
-
+
diff --git a/src/addon/qtype/ddwtos/component/ddwtos.scss b/src/addon/qtype/ddwtos/component/ddwtos.scss
new file mode 100644
index 000000000..69d5ae1c1
--- /dev/null
+++ b/src/addon/qtype/ddwtos/component/ddwtos.scss
@@ -0,0 +1,108 @@
+// Style ddwtos content a bit. Almost all these styles are copied from Moodle.
+addon-qtype-ddwtos {
+ .qtext {
+ margin-bottom: 0.5em;
+ display: block;
+ }
+
+ .draghome {
+ margin-bottom: 1em;
+ }
+
+ .answertext {
+ margin-bottom: 0.5em;
+ }
+
+ .drop {
+ display: inline-block;
+ text-align: center;
+ border: 1px solid $gray-darker;
+ margin-bottom: 2px;
+ border-radius: 5px;
+ }
+ .draghome, .drag {
+ display: inline-block;
+ text-align: center;
+ background: transparent;
+ border: 0;
+ }
+ .draghome, .drag.unplaced{
+ border: 1px solid $gray-darker;
+ border-radius: 5px;
+ }
+ .draghome {
+ visibility: hidden;
+ }
+ .drag {
+ z-index: 2;
+ border-radius: 5px;
+ }
+ .drag.selected {
+ z-index: 3;
+ box-shadow: 3px 3px 4px $gray-darker;
+ }
+
+ .drop.selected {
+ border-color: $yellow-light;
+ box-shadow: 0 0 5px 5px $yellow-light;
+ }
+
+ &.notreadonly .drag,
+ &.notreadonly .draghome,
+ &.notreadonly .drop,
+ &.notreadonly .answercontainer {
+ cursor: pointer;
+ border-radius: 5px;
+ }
+
+ &.readonly .drag,
+ &.readonly .draghome,
+ &.readonly .drop,
+ &.readonly .answercontainer {
+ cursor: default;
+ }
+
+ span.incorrect {
+ background-color: $red-light;
+ }
+ span.correct {
+ background-color: $green-light;
+ }
+
+ .group1 {
+ background-color: $white;
+ }
+ .group2 {
+ background-color: #DCDCDC;
+ }
+ .group3 {
+ background-color: $blue-light;
+ }
+ .group4 {
+ background-color: #D8BFD8;
+ }
+ .group5 {
+ background-color: #87CEFA;
+ }
+ .group6 {
+ background-color: #DAA520;
+ }
+ .group7 {
+ background-color: #FFD700;
+ }
+ .group8 {
+ background-color: #F0E68C;
+ }
+
+ sub, sup {
+ font-size: 80%;
+ position: relative;
+ vertical-align: baseline;
+ }
+ sup {
+ top: -0.4em;
+ }
+ sub {
+ bottom: -0.2em;
+ }
+}
diff --git a/src/addon/qtype/ddwtos/component/ddwtos.ts b/src/addon/qtype/ddwtos/component/ddwtos.ts
index 18a4a121a..3241e435d 100644
--- a/src/addon/qtype/ddwtos/component/ddwtos.ts
+++ b/src/addon/qtype/ddwtos/component/ddwtos.ts
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-import { Component, OnInit, OnDestroy, AfterViewInit, Injector, ElementRef } from '@angular/core';
+import { Component, OnInit, OnDestroy, Injector, ElementRef } from '@angular/core';
import { CoreLoggerProvider } from '@providers/logger';
import { CoreQuestionBaseComponent } from '@core/question/classes/base-question-component';
import { AddonQtypeDdwtosQuestion } from '../classes/ddwtos';
@@ -24,14 +24,15 @@ import { AddonQtypeDdwtosQuestion } from '../classes/ddwtos';
selector: 'addon-qtype-ddwtos',
templateUrl: 'ddwtos.html'
})
-export class AddonQtypeDdwtosComponent extends CoreQuestionBaseComponent implements OnInit, AfterViewInit, OnDestroy {
+export class AddonQtypeDdwtosComponent extends CoreQuestionBaseComponent implements OnInit, OnDestroy {
protected element: HTMLElement;
protected questionInstance: AddonQtypeDdwtosQuestion;
- protected inputIds: string[]; // Ids of the inputs of the question (where the answers will be stored).
+ protected inputIds: string[] = []; // Ids of the inputs of the question (where the answers will be stored).
+ protected destroyed = false;
- constructor(logger: CoreLoggerProvider, injector: Injector, element: ElementRef) {
- super(logger, 'AddonQtypeDdwtosComponent', injector);
+ constructor(protected loggerProvider: CoreLoggerProvider, injector: Injector, element: ElementRef) {
+ super(loggerProvider, 'AddonQtypeDdwtosComponent', injector);
this.element = element.nativeElement;
}
@@ -74,28 +75,30 @@ export class AddonQtypeDdwtosComponent extends CoreQuestionBaseComponent impleme
}
// Get the inputs where the answers will be stored and add them to the question text.
- const inputEls = Array.from(div.querySelectorAll('input[type="hidden"]:not([name*=sequencecheck])')),
- inputIds = [];
+ const inputEls = Array.from(div.querySelectorAll('input[type="hidden"]:not([name*=sequencecheck])'));
inputEls.forEach((inputEl) => {
this.question.text += inputEl.outerHTML;
- inputIds.push(inputEl.getAttribute('id'));
+ this.inputIds.push(inputEl.getAttribute('id'));
});
}
/**
- * View has been initialized.
+ * The question has been rendered.
*/
- ngAfterViewInit(): void {
- // Create the instance.
- this.questionInstance = new AddonQtypeDdwtosQuestion(this.logger, this.domUtils, this.element, this.question,
- this.question.readOnly, this.inputIds);
+ questionRendered(): void {
+ if (!this.destroyed) {
+ // Create the instance.
+ this.questionInstance = new AddonQtypeDdwtosQuestion(this.loggerProvider, this.domUtils, this.element, this.question,
+ this.question.readOnly, this.inputIds);
+ }
}
/**
* Component being destroyed.
*/
ngOnDestroy(): void {
+ this.destroyed = true;
this.questionInstance && this.questionInstance.destroy();
}
}
diff --git a/src/addon/qtype/essay/component/essay.html b/src/addon/qtype/essay/component/essay.html
index 1098c8304..0b098d82e 100644
--- a/src/addon/qtype/essay/component/essay.html
+++ b/src/addon/qtype/essay/component/essay.html
@@ -7,13 +7,13 @@
-
+
- {{question.textarea.text}}
+
-
+
+ [component]="component" [componentId]="componentId" -->
diff --git a/src/addon/qtype/essay/component/essay.ts b/src/addon/qtype/essay/component/essay.ts
index c421fa629..ba298ce37 100644
--- a/src/addon/qtype/essay/component/essay.ts
+++ b/src/addon/qtype/essay/component/essay.ts
@@ -15,6 +15,7 @@
import { Component, OnInit, Injector } from '@angular/core';
import { CoreLoggerProvider } from '@providers/logger';
import { CoreQuestionBaseComponent } from '@core/question/classes/base-question-component';
+import { FormControl, FormBuilder } from '@angular/forms';
/**
* Component to render an essay question.
@@ -25,7 +26,9 @@ import { CoreQuestionBaseComponent } from '@core/question/classes/base-question-
})
export class AddonQtypeEssayComponent extends CoreQuestionBaseComponent implements OnInit {
- constructor(logger: CoreLoggerProvider, injector: Injector) {
+ protected formControl: FormControl;
+
+ constructor(logger: CoreLoggerProvider, injector: Injector, protected fb: FormBuilder) {
super(logger, 'AddonQtypeEssayComponent', injector);
}
@@ -34,5 +37,7 @@ export class AddonQtypeEssayComponent extends CoreQuestionBaseComponent implemen
*/
ngOnInit(): void {
this.initEssayComponent();
+
+ this.formControl = this.fb.control(this.question.textarea && this.question.textarea.text);
}
}
diff --git a/src/addon/qtype/gapselect/component/gapselect.scss b/src/addon/qtype/gapselect/component/gapselect.scss
new file mode 100644
index 000000000..b467d9351
--- /dev/null
+++ b/src/addon/qtype/gapselect/component/gapselect.scss
@@ -0,0 +1,19 @@
+// Style gapselect content a bit. All these styles are copied from Moodle.
+addon-qtype-gapselect {
+ p {
+ margin: 0 0 .5em;
+ }
+
+ select {
+ height: 30px;
+ line-height: 30px;
+ display: inline-block;
+ border: 1px solid $gray-dark;
+ padding: 4px 6px;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+ margin-bottom: 10px;
+ background: $gray-lighter;
+ }
+}
diff --git a/src/addon/qtype/match/component/match.html b/src/addon/qtype/match/component/match.html
index fb40981c6..cfa627279 100644
--- a/src/addon/qtype/match/component/match.html
+++ b/src/addon/qtype/match/component/match.html
@@ -3,17 +3,21 @@