Commit 962a7292 authored by Konstantin Schulz's avatar Konstantin Schulz
Browse files

test module now has custom vocabulary list items

parent a198cb74
......@@ -18,28 +18,26 @@
<ion-grid>
<!--<ion-row>-->
<!--<ion-col>{{ 'TEST_MODULE_GO_TO_EXERCISE' | translate}}-->
<!--<ion-col id="exerciseNav">{{ 'TEST_MODULE_GO_TO_EXERCISE' | translate}}-->
<!--<a *ngFor="let number of Array.from(Array(exercises.length).keys())"-->
<!--(click)="showNextExercise(number)">-->
<!--<span>{{number + 1}}</span>&nbsp;-->
<!--</a>-->
<!--&lt;!&ndash;suppress HtmlUnknownAttribute &ndash;&gt;-->
<!--<ion-select placeholder="{{ 'TEST_MODULE_EXERCISE_NUMBER' | translate }}" (ionChange)="goToExercise()"-->
<!--[(ngModel)]="newExerciseTarget" name="newExerciseTarget">-->
<!--<ion-select-option-->
<!--*ngFor="let number of Array.from(Array(exercises.length).keys())"-->
<!--value="{{number}}">{{number + 1}}</ion-select-option>-->
<!--</ion-select>-->
<!--&lt;!&ndash;<ion-select placeholder="{{ 'TEST_MODULE_EXERCISE_NUMBER' | translate }}" (ionChange)="goToExercise()"&ndash;&gt;-->
<!--&lt;!&ndash;[(ngModel)]="newExerciseTarget" name="newExerciseTarget">&ndash;&gt;-->
<!--&lt;!&ndash;<ion-select-option&ndash;&gt;-->
<!--&lt;!&ndash;*ngFor="let number of Array.from(Array(exercises.length).keys())"&ndash;&gt;-->
<!--&lt;!&ndash;value="{{number}}">{{number + 1}}</ion-select-option>&ndash;&gt;-->
<!--&lt;!&ndash;</ion-select>&ndash;&gt;-->
<!--</ion-col>-->
<!--</ion-row>-->
<!--<ion-row>-->
<!--<ion-row id="h5p-row">-->
<!--<ion-col>-->
<!--&lt;!&ndash; TODO: enable solution shuffling for H5P ? &ndash;&gt;-->
<!--<div class="h5p-container"></div>-->
<!--</ion-col>-->
<!--</ion-row>-->
<!--<ion-row>-->
<!--<ion-col *ngIf="this.exercises.indexOf(this.currentExercise) < this.exercises.length - 1">-->
<!--<ion-button (click)="showNextExercise(this.exercises.indexOf(this.currentExercise) + 1)">Weiter-->
<!--</ion-button>-->
<!--</ion-col>-->
<!--</ion-row>-->
<ion-row>
<ion-col>
......
import {Component} from '@angular/core';
import {Component, OnDestroy} from '@angular/core';
import {NavController} from "@ionic/angular";
import {HelperService} from '../helper.service';
import {XAPIevent} from "src/app/models/xAPIevent";
......@@ -19,19 +19,26 @@ window.onresize = () => {
templateUrl: './feedback.page.html',
styleUrls: ['./feedback.page.scss'],
})
export class FeedbackPage {
export class FeedbackPage implements OnDestroy {
Array = Array;
HelperService = HelperService;
public currentExercise: string = "";
public exercises: string[] = ["fill_blanks_1", "multi_choice_1", "multi_choice_2", "multi_choice_3", "multi_choice_4", "multi_choice_5", "multi_choice_6", "multi_choice_7", "multi_choice_8", "fill_blanks_2", "fill_blanks_3", "fill_blanks_4", "fill_blanks_5", "multi_choice_9", "fill_blanks_6", "multi_choice_10", "multi_choice_11", "multi_choice_12", "multi_choice_13"];
public newExerciseTarget: number;
public exercises: string[] = ["voc_list_1", "voc_list_2", "voc_list_3", "voc_list_4", "voc_list_5", "fill_blanks_1", "nonH5P_1", "multi_choice_1", "multi_choice_2", "multi_choice_3", "multi_choice_4", "multi_choice_5", "multi_choice_6", "multi_choice_7", "multi_choice_8", "fill_blanks_2", "fill_blanks_3", "fill_blanks_4", "fill_blanks_5", "multi_choice_9", "fill_blanks_6", "multi_choice_10", "multi_choice_11", "multi_choice_12", "multi_choice_13"];
constructor(public navCtrl: NavController, public translate: TranslateService) {
this.showNextExercise(0);
}
goToExercise() {
this.showNextExercise(this.newExerciseTarget);
H5P.externalDispatcher.on('xAPI', (event: XAPIevent) => {
// results are only available when a task has been completed/answered, not in the "attempted" or "interacted" stages
if (event.data.statement.verb.id === HelperService.config["xAPIverbIDanswered"] && event.data.statement.result) {
// TODO: SAVE THIS SCORE BY SENDING IT TO THE BACKEND? OR WRITE THE WHOLE STATEMENT?
// console.log(event.data.statement.result.score.scaled);
const iframe: HTMLIFrameElement = <HTMLIFrameElement>document.getElementById("h5p-iframe-1");
const checkbox: HTMLInputElement = <HTMLInputElement>iframe.contentWindow.document.getElementById("known");
if (checkbox) {
const isVocabularyKnown: boolean = checkbox.checked;
}
this.showNextExercise(this.exercises.indexOf(this.currentExercise) + 1);
}
});
}
public initH5P(exerciseType: string) {
......@@ -39,7 +46,6 @@ export class FeedbackPage {
setTimeout(() => {
(($) => {
$(() => {
// $('.h5p-container').empty();
$('.h5p-container').empty().h5p({
frameJs: 'assets/dist/js/h5p-standalone-frame.min.js',
frameCss: 'assets/dist/styles/h5p.css',
......@@ -47,22 +53,36 @@ export class FeedbackPage {
});
});
})(H5P.jQuery);
H5P.externalDispatcher.on('xAPI', (event: XAPIevent) => {
// results are only available when a task has been completed/answered, not in the "attempted" or "interacted" stages
if (event.data.statement.verb.id === HelperService.config["xAPIverbIDanswered"] && event.data.statement.result) {
// TODO: SAVE THIS SCORE BY SENDING IT TO THE BACKEND? OR WRITE THE WHOLE STATEMENT?
// console.log(event.data.statement.result.score.scaled);
}
});
}, 50);
}
ngOnDestroy() {
H5P.externalDispatcher.off('xAPI');
}
showNextExercise(newIndex: number) {
let oldIndex = this.exercises.indexOf(this.currentExercise);
let navLinks: HTMLCollection = document.getElementById("exerciseNav").children;
if (oldIndex > -1) {
// TODO: move highlighting & navigation to the results page
navLinks[oldIndex].children[0].classList.remove("highlight");
if (this.currentExercise.startsWith("nonH5P")) {
document.getElementById("h5p-row").classList.remove("hide");
}
}
this.currentExercise = this.exercises[newIndex];
navLinks[this.exercises.indexOf(this.currentExercise)].children[0].classList.add("highlight");
if (this.currentExercise.startsWith("nonH5P")) {
document.getElementById("h5p-row").classList.add("hide");
return;
}
let fileName: string = this.currentExercise.split("_").slice(-1) + "_" + this.translate.currentLang + ".json";
const exerciseType = this.currentExercise.split("_").slice(0, 2).join("_");
let exerciseType = this.currentExercise.split("_").slice(0, 2).join("_");
const baseUrl: string = location.protocol.concat('//').concat(window.location.host);
window.localStorage.setItem(HelperService.config['localStorageKeyH5P'], baseUrl + "/assets/h5p/" + exerciseType + "/content/" + fileName);
if (exerciseType.startsWith("voc_list")) {
exerciseType = "fill_blanks";
}
this.initH5P(exerciseType);
}
......
......@@ -4,7 +4,7 @@ import {HelperService} from 'src/app/helper.service';
import {NavController} from '@ionic/angular';
import {ExerciseService} from 'src/app/exercise.service';
import {CorpusService} from 'src/app/corpus.service';
import {Component} from '@angular/core';
import {Component, OnDestroy} from '@angular/core';
import {TranslateService} from '@ngx-translate/core';
import {Solution} from 'src/app/models/solution';
import {HttpClient} from '@angular/common/http';
......@@ -25,7 +25,7 @@ window.onresize = () => {
templateUrl: './preview.page.html',
styleUrls: ['./preview.page.scss'],
})
export class PreviewPage {
export class PreviewPage implements OnDestroy {
HelperService = HelperService;
public ExerciseType = ExerciseType;
public FileType = FileType;
......@@ -83,6 +83,10 @@ export class PreviewPage {
this.updateFileUrl();
}
ngOnDestroy(): void {
H5P.externalDispatcher.off('xAPI');
}
public processAnnisResponse(ar: AnnisResponse) {
this.exerciseService.annisResponse.solutions = ar.solutions;
this.processSolutions(ar.solutions);
......
......@@ -175,6 +175,7 @@ div.h5p-fullscreen {
}
.h5p-content ul.h5p-actions {
display: none;
box-sizing: border-box;
-moz-box-sizing: border-box;
overflow: hidden;
......
{"taskDescription":"<p>What are the colors of these berries when they are ripe?<\/p>\n","checkAnswer":"Check","tryAgain":"Retry","showSolution":"Show Solution","behaviour":{"enableRetry":true,"enableSolutionsButton":true,"instantFeedback":false,"enableCheckButton":true},"textField":"Blueberries are *blue:Check the name of the berry!*.\nStrawberries are *red*.\nCloudberries are *orange*.","overallFeedback":[{"from":0,"to":100,"feedback":"Score: @score of @total."}],"dropZoneIndex":"Drop Zone @index.","empty":"Drop Zone @index is empty.","contains":"Drop Zone @index contains draggable @draggable.","draggableIndex":"Draggable @text. @index of @count draggables.","tipLabel":"Show tip","correctText":"Correct!","incorrectText":"Incorrect!","resetDropTitle":"Reset drop","resetDropDescription":"Are you sure you want to reset this drop zone?","grabbed":"Draggable is grabbed.","cancelledDragging":"Cancelled dragging.","correctAnswer":"Correct answer:","feedbackHeader":"Feedback","scoreBarLabel":"You got :num out of :total points"}
{
"taskDescription": "<p>What are the colors of these berries when they are ripe?<\/p>\n",
"checkAnswer": "Check",
"tryAgain": "Retry",
"showSolution": "Show Solution",
"behaviour": {
"enableRetry": true,
"enableSolutionsButton": true,
"instantFeedback": false,
"enableCheckButton": true
},
"textField": "Blueberries are *blue:Check the name of the berry!*.\nStrawberries are *red*.\nCloudberries are *orange*.",
"overallFeedback": [
{
"from": 0,
"to": 100,
"feedback": "Score: @score of @total."
}
],
"dropZoneIndex": "Drop Zone @index.",
"empty": "Drop Zone @index is empty.",
"contains": "Drop Zone @index contains draggable @draggable.",
"draggableIndex": "Draggable @text. @index of @count draggables.",
"tipLabel": "Show tip",
"correctText": "Correct!",
"incorrectText": "Incorrect!",
"resetDropTitle": "Reset drop",
"resetDropDescription": "Are you sure you want to reset this drop zone?",
"grabbed": "Draggable is grabbed.",
"cancelledDragging": "Cancelled dragging.",
"correctAnswer": "Correct answer:",
"feedbackHeader": "Feedback",
"scoreBarLabel": "You got :num out of :total points"
}
......@@ -18,7 +18,7 @@
"separateLines": false,
"enableRetry": false,
"disableImageZooming": true,
"confirmCheckDialog": true,
"confirmCheckDialog": false,
"confirmRetryDialog": false,
"acceptSpellingErrors": false,
"enableCheckButton": true
......
......@@ -7,7 +7,7 @@
],
"showSolutions": "Show solutions",
"tryAgain": "Try again",
"text": "<p>Fill in the basic form.<\/p>\n",
"text": "<p>Fill in the basic form.<\/p><br><p><label><input type=\"checkbox\" id=\"known\"> I already know this</label></p>\n",
"checkAnswer": "Check",
"notFilledOut": "Please fill in all blanks",
"behaviour": {
......@@ -18,7 +18,7 @@
"separateLines": false,
"enableRetry": false,
"disableImageZooming": true,
"confirmCheckDialog": true,
"confirmCheckDialog": false,
"confirmRetryDialog": false,
"acceptSpellingErrors": false,
"enableCheckButton": true
......
......@@ -18,7 +18,7 @@
"separateLines": false,
"enableRetry": false,
"disableImageZooming": true,
"confirmCheckDialog": true,
"confirmCheckDialog": false,
"confirmRetryDialog": false,
"acceptSpellingErrors": false,
"enableCheckButton": true
......
......@@ -18,7 +18,7 @@
"separateLines": false,
"enableRetry": false,
"disableImageZooming": true,
"confirmCheckDialog": true,
"confirmCheckDialog": false,
"confirmRetryDialog": false,
"acceptSpellingErrors": false,
"enableCheckButton": true
......
......@@ -18,7 +18,7 @@
"separateLines": false,
"enableRetry": false,
"disableImageZooming": true,
"confirmCheckDialog": true,
"confirmCheckDialog": false,
"confirmRetryDialog": false,
"acceptSpellingErrors": false,
"enableCheckButton": true
......
......@@ -18,7 +18,7 @@
"separateLines": false,
"enableRetry": false,
"disableImageZooming": true,
"confirmCheckDialog": true,
"confirmCheckDialog": false,
"confirmRetryDialog": false,
"acceptSpellingErrors": false,
"enableCheckButton": true
......
......@@ -16,7 +16,7 @@
"separateLines": false,
"enableRetry": false,
"disableImageZooming": true,
"confirmCheckDialog": true,
"confirmCheckDialog": false,
"confirmRetryDialog": false,
"acceptSpellingErrors": false,
"enableCheckButton": true
......
......@@ -16,7 +16,7 @@
"separateLines": false,
"enableRetry": false,
"disableImageZooming": true,
"confirmCheckDialog": true,
"confirmCheckDialog": false,
"confirmRetryDialog": false,
"acceptSpellingErrors": false,
"enableCheckButton": true
......
......@@ -16,7 +16,7 @@
"separateLines": false,
"enableRetry": false,
"disableImageZooming": true,
"confirmCheckDialog": true,
"confirmCheckDialog": false,
"confirmRetryDialog": false,
"acceptSpellingErrors": false,
"enableCheckButton": true
......
......@@ -16,7 +16,7 @@
"separateLines": false,
"enableRetry": false,
"disableImageZooming": true,
"confirmCheckDialog": true,
"confirmCheckDialog": false,
"confirmRetryDialog": false,
"acceptSpellingErrors": false,
"enableCheckButton": true
......
......@@ -18,7 +18,7 @@
"separateLines": false,
"enableRetry": false,
"disableImageZooming": true,
"confirmCheckDialog": true,
"confirmCheckDialog": false,
"confirmRetryDialog": false,
"acceptSpellingErrors": false,
"enableCheckButton": true
......
......@@ -18,7 +18,7 @@
"separateLines": false,
"enableRetry": false,
"disableImageZooming": true,
"confirmCheckDialog": true,
"confirmCheckDialog": false,
"confirmRetryDialog": false,
"acceptSpellingErrors": false,
"enableCheckButton": true
......
......@@ -52,7 +52,7 @@
"showSolutionsRequiresInput": false,
"type": "auto",
"disableImageZooming": true,
"confirmCheckDialog": true,
"confirmCheckDialog": false,
"confirmRetryDialog": false,
"autoCheck": false,
"passPercentage": 100,
......
......@@ -52,7 +52,7 @@
"showSolutionsRequiresInput": false,
"type": "auto",
"disableImageZooming": true,
"confirmCheckDialog": true,
"confirmCheckDialog": false,
"confirmRetryDialog": false,
"autoCheck": false,
"passPercentage": 100,
......
......@@ -43,7 +43,7 @@
"showSolutionsRequiresInput": false,
"type": "auto",
"disableImageZooming": true,
"confirmCheckDialog": true,
"confirmCheckDialog": false,
"confirmRetryDialog": false,
"autoCheck": false,
"passPercentage": 100,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment