Commit 00df96d4 authored by Konstantin Schulz's avatar Konstantin Schulz

introducing RxJS with its Observable/Subject syntax to make the access to...

introducing RxJS with its Observable/Subject syntax to make the access to remote data (incl. cache) more uniform and consistent
parent 71c4de41
{ {
"name": "mc_frontend", "name": "mc_frontend",
"version": "1.4.8", "version": "1.5.0",
"author": "Ionic Framework", "author": "Ionic Framework",
"homepage": "https://ionicframework.com/", "homepage": "https://ionicframework.com/",
"scripts": { "scripts": {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
</div> </div>
</ion-buttons> </ion-buttons>
<ion-spinner *ngIf="HelperService.isLoading"></ion-spinner> <ion-spinner *ngIf="HelperService.isLoading"></ion-spinner>
<ion-title>{{ corpusService.currentAuthor?.name }}</ion-title> <ion-title *ngIf="HelperService.applicationState | async as state">{{ state.currentSetup.currentAuthor?.name }}</ion-title>
<ion-buttons slot="end"> <ion-buttons slot="end">
<ion-menu-button autoHide="false"></ion-menu-button> <ion-menu-button autoHide="false"></ion-menu-button>
</ion-buttons> </ion-buttons>
...@@ -17,9 +17,8 @@ ...@@ -17,9 +17,8 @@
<ion-content padding> <ion-content padding>
<ion-list *ngIf="HelperService.applicationState | async as state">
<ion-list> <ion-item *ngFor="let corpus of state.currentSetup.currentAuthor?.corpora">
<ion-item *ngFor="let corpus of corpusService.currentAuthor?.corpora">
<button (click)="showPossibleReferences(corpus)"> <button (click)="showPossibleReferences(corpus)">
<span>{{corpus.title}}</span> <span>{{corpus.title}}</span>
</button> </button>
......
...@@ -5,25 +5,23 @@ import {TranslateService} from '@ngx-translate/core'; ...@@ -5,25 +5,23 @@ import {TranslateService} from '@ngx-translate/core';
import {HelperService} from '../helper.service'; import {HelperService} from '../helper.service';
import {CorpusService} from 'src/app/corpus.service'; import {CorpusService} from 'src/app/corpus.service';
import {HttpClient} from '@angular/common/http'; import {HttpClient} from '@angular/common/http';
import {TextRange} from 'src/app/models/textRange';
@Component({ @Component({
selector: 'app-author-detail', selector: 'app-author-detail',
templateUrl: './author-detail.page.html', templateUrl: './author-detail.page.html',
styleUrls: ['./author-detail.page.scss'], styleUrls: ['./author-detail.page.scss'],
}) })
export class AuthorDetailPage { export class AuthorDetailPage {
HelperService = HelperService; HelperService = HelperService;
constructor(public navCtrl: NavController, constructor(public navCtrl: NavController,
public corpusService: CorpusService, public corpusService: CorpusService,
public translate: TranslateService, public translate: TranslateService,
public http: HttpClient) { public http: HttpClient) {
} }
showPossibleReferences(corpus: CorpusMC) { showPossibleReferences(corpus: CorpusMC) {
this.corpusService.currentCorpus = corpus; this.corpusService.saveNewCorpus(corpus);
this.corpusService.currentTextRange = new TextRange({start: ['', '', ''], end: ['', '', '']}); HelperService.goToTextRangePage(this.navCtrl).then();
HelperService.goToTextRangePage(this.navCtrl).then(); }
}
} }
...@@ -20,20 +20,29 @@ ...@@ -20,20 +20,29 @@
<ion-row> <ion-row>
<ion-col> <ion-col>
<b style="padding: 0.5em;">{{ 'MOST_RECENT_SETUP' | translate }}:</b> <b style="padding: 0.5em;">{{ 'MOST_RECENT_SETUP' | translate }}:</b>
</ion-col>
</ion-row>
<ion-row *ngIf="HelperService.mostRecentSetup?.currentCorpus && HelperService.mostRecentSetup?.currentUrn">
<ion-col>
<a (click)="restoreLastSetup()">{{ [HelperService.mostRecentSetup.currentCorpus.author,
HelperService.mostRecentSetup.currentCorpus.title,
HelperService.mostRecentSetup.currentUrn?.split(":").slice(-1)[0]].join(", ") }}</a>
</ion-col> </ion-col>
</ion-row> </ion-row>
<div *ngIf="HelperService.applicationState | async as state">
<ion-row
*ngIf="state.mostRecentSetup && state.mostRecentSetup.currentCorpus && state.mostRecentSetup.currentUrn; else noEntryFound">
<ion-col>
<a (click)="restoreLastSetup()">
{{ [state.mostRecentSetup.currentCorpus.author, state.mostRecentSetup.currentCorpus.title,
state.mostRecentSetup.currentUrn?.split(":").slice(-1)[0]].join(", ") }}
</a>
</ion-col>
</ion-row>
<ng-template #noEntryFound>
<ion-row>
<ion-col>{{ "NO_ENTRY_FOUND" | translate }}</ion-col>
</ion-row>
</ng-template>
</div>
<ion-row> <ion-row>
<ion-col> <ion-col>
<label> <label>
<input type="checkbox" [(ngModel)]="showOnlyTreebanks" (change)="toggleTreebankAuthors()" /> <input type="checkbox" [(ngModel)]="showOnlyTreebanks" (change)="toggleTreebankAuthors()"/>
<span class="checkbox">{{ 'AUTHOR_SHOW_ONLY_TREEBANKS' | translate}}</span> <span class="checkbox">{{ 'AUTHOR_SHOW_ONLY_TREEBANKS' | translate}}</span>
</label> </label>
</ion-col> </ion-col>
...@@ -43,7 +52,7 @@ ...@@ -43,7 +52,7 @@
<label> <label>
<ion-icon name="search" class="search"></ion-icon> <ion-icon name="search" class="search"></ion-icon>
<input type="search" (ngModelChange)="getAuthors($event.toString())" <input type="search" (ngModelChange)="getAuthors($event.toString())"
placeholder="{{ 'AUTHOR_SEARCH' | translate }}" [(ngModel)]="currentSearchValue" /> placeholder="{{ 'AUTHOR_SEARCH' | translate }}" [(ngModel)]="currentSearchValue"/>
</label> </label>
</ion-col> </ion-col>
</ion-row> </ion-row>
...@@ -51,7 +60,7 @@ ...@@ -51,7 +60,7 @@
<ion-col style="display: inline-grid"> <ion-col style="display: inline-grid">
<h2>{{'AUTHOR' | translate}}</h2> <h2>{{'AUTHOR' | translate}}</h2>
<ion-grid *ngIf="corpusService.availableAuthors.length > 0; else loading" class="author" <ion-grid *ngIf="corpusService.availableAuthors.length > 0; else loading" class="author"
style="text-align: left"> style="text-align: left">
<ion-row *ngFor="let author of authorsDisplayed"> <ion-row *ngFor="let author of authorsDisplayed">
<ion-col> <ion-col>
<a href="javascript:" (click)="showCorpora(author)">{{author.name}}</a> <a href="javascript:" (click)="showCorpora(author)">{{author.name}}</a>
......
...@@ -6,6 +6,9 @@ import {CorpusService} from 'src/app/corpus.service'; ...@@ -6,6 +6,9 @@ import {CorpusService} from 'src/app/corpus.service';
import {HttpClient} from '@angular/common/http'; import {HttpClient} from '@angular/common/http';
import {HelperService} from '../helper.service'; import {HelperService} from '../helper.service';
import {ExerciseService} from '../exercise.service'; import {ExerciseService} from '../exercise.service';
import {ApplicationState} from '../models/applicationState';
import {Observable} from 'rxjs';
import {take} from 'rxjs/operators';
/** /**
* Generated class for the AuthorPage page. * Generated class for the AuthorPage page.
...@@ -71,9 +74,11 @@ export class AuthorPage { ...@@ -71,9 +74,11 @@ export class AuthorPage {
showCorpora(author: Author) { showCorpora(author: Author) {
this.corpusService.currentAuthor = author; this.corpusService.currentAuthor = author;
HelperService.mostRecentSetup.currentAuthor = author; HelperService.applicationState.pipe(take(1)).subscribe((as: ApplicationState) => {
this.helperService.saveMostRecentSetup().then(); as.currentSetup.currentAuthor = author;
this.navCtrl.navigateForward('/author-detail').then(); this.helperService.saveApplicationState(as).then();
this.navCtrl.navigateForward('/author-detail').then();
});
} }
toggleTreebankAuthors() { toggleTreebankAuthors() {
......
...@@ -15,7 +15,7 @@ import { ...@@ -15,7 +15,7 @@ import {
DependencyValue, DependencyValue,
ExerciseType, ExerciseType,
ExerciseTypeTranslation, ExerciseTypeTranslation,
InstructionsTranslation, MoodleExerciseType, InstructionsTranslation,
PartOfSpeechTranslation, PartOfSpeechTranslation,
PartOfSpeechValue, PartOfSpeechValue,
Phenomenon Phenomenon
...@@ -27,7 +27,10 @@ import {Exercise} from 'src/app/models/exercise'; ...@@ -27,7 +27,10 @@ import {Exercise} from 'src/app/models/exercise';
import {Feedback} from 'src/app/models/feedback'; import {Feedback} from 'src/app/models/feedback';
import {PhenomenonMap, PhenomenonMapContent} from 'src/app/models/phenomenonMap'; import {PhenomenonMap, PhenomenonMapContent} from 'src/app/models/phenomenonMap';
import {FrequencyItem} from 'src/app/models/frequencyItem'; import {FrequencyItem} from 'src/app/models/frequencyItem';
import {ExerciseMC} from 'src/app/models/exerciseMC'; import {BehaviorSubject, ReplaySubject} from 'rxjs';
import {ApplicationState} from './models/applicationState';
import {take} from 'rxjs/operators';
import {TextData} from './models/textData';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
...@@ -40,9 +43,11 @@ export class CorpusService { ...@@ -40,9 +43,11 @@ export class CorpusService {
public citationsUnavailableString: string; public citationsUnavailableString: string;
public corporaUnavailableString: string; public corporaUnavailableString: string;
public currentAuthor: Author; public currentAuthor: Author;
public currentCorpus: CorpusMC; public currentCorpus: ReplaySubject<CorpusMC>;
private currentCorpusCache: CorpusMC;
public currentText = ''; public currentText = '';
public currentTextRange: TextRange = new TextRange({start: ['', '', ''], end: ['', '', '']}); public currentTextRange: ReplaySubject<TextRange>;
private currentTextRangeCache: TextRange = new TextRange({start: ['', '', ''], end: ['', '', '']});
public currentUrn: string; public currentUrn: string;
public exercise: Exercise = new Exercise({ public exercise: Exercise = new Exercise({
type: ExerciseType.cloze, type: ExerciseType.cloze,
...@@ -71,16 +76,18 @@ export class CorpusService { ...@@ -71,16 +76,18 @@ export class CorpusService {
public helperService: HelperService, public helperService: HelperService,
) { ) {
this.isMostRecentSetupLoaded = false; this.isMostRecentSetupLoaded = false;
this.helperService.initApplicationState();
this.initCurrentCorpus();
this.initCurrentTextRange();
HelperService.waitForConfig().then(() => { HelperService.waitForConfig().then(() => {
this.checkForUpdates().then(() => { this.checkForUpdates().finally(() => {
this.checkAnnisResponse().then(() => { this.checkAnnisResponse().then(() => {
this.restoreLastCorpus().then(() => { this.restoreLastCorpus().then(() => {
this.isMostRecentSetupLoaded = true; this.isMostRecentSetupLoaded = true;
}, () => {
}); });
}, () => { }, () => {
this.isMostRecentSetupLoaded = true;
}); });
}, () => {
}); });
}); });
this.initPhenomenonMap(); this.initPhenomenonMap();
...@@ -122,12 +129,16 @@ export class CorpusService { ...@@ -122,12 +129,16 @@ export class CorpusService {
if (this.annisResponse) { if (this.annisResponse) {
return outerResolve(); return outerResolve();
} }
this.helperService.loadMostRecentSetup().then(() => { HelperService.applicationState.pipe(take(1)).subscribe((state: ApplicationState) => {
this.annisResponse = HelperService.mostRecentSetup.annisResponse; if (state.mostRecentSetup) {
this.currentAuthor = HelperService.mostRecentSetup.currentAuthor; this.annisResponse = state.mostRecentSetup.annisResponse;
this.currentUrn = HelperService.mostRecentSetup.currentUrn; this.currentAuthor = state.mostRecentSetup.currentAuthor;
this.currentCorpus = HelperService.mostRecentSetup.currentCorpus; this.currentUrn = state.mostRecentSetup.currentUrn;
return outerResolve(); this.currentCorpusCache = state.mostRecentSetup.currentCorpus;
return outerResolve();
} else {
return outerReject();
}
}, () => { }, () => {
return outerReject(); return outerReject();
}); });
...@@ -212,8 +223,10 @@ export class CorpusService { ...@@ -212,8 +223,10 @@ export class CorpusService {
HelperService.makeGetRequest(this.http, this.toastCtrl, url, params).then((fis: FrequencyItem[]) => { HelperService.makeGetRequest(this.http, this.toastCtrl, url, params).then((fis: FrequencyItem[]) => {
HelperService.isLoading = false; HelperService.isLoading = false;
this.annisResponse.frequency_analysis = fis; this.annisResponse.frequency_analysis = fis;
HelperService.mostRecentSetup.annisResponse = this.annisResponse; HelperService.applicationState.pipe(take(1)).subscribe((as: ApplicationState) => {
this.helperService.saveMostRecentSetup().then(); as.mostRecentSetup.annisResponse = this.annisResponse;
this.helperService.saveApplicationState(as).then();
});
return resolve(); return resolve();
}, () => { }, () => {
return reject(); return reject();
...@@ -281,6 +294,27 @@ export class CorpusService { ...@@ -281,6 +294,27 @@ export class CorpusService {
this.translate.get('LINK_COPIED').subscribe(value => this.shareLinkCopiedString = value); this.translate.get('LINK_COPIED').subscribe(value => this.shareLinkCopiedString = value);
} }
initCurrentCorpus(): void {
this.currentCorpus = new ReplaySubject<CorpusMC>(1);
if (!this.currentCorpusCache) {
HelperService.applicationState.subscribe((as: ApplicationState) => {
const textData: TextData = as.currentSetup ? as.currentSetup : as.mostRecentSetup;
this.currentCorpusCache = textData ? textData.currentCorpus : null;
this.currentCorpus.next(this.currentCorpusCache);
});
} else {
this.currentCorpus.next(this.currentCorpusCache);
}
}
initCurrentTextRange(): void {
this.currentTextRange = new ReplaySubject<TextRange>(1);
HelperService.applicationState.pipe(take(1)).subscribe((state: ApplicationState) => {
this.currentTextRangeCache = state.currentSetup.currentTextRange;
this.currentTextRange.next(this.currentTextRangeCache);
});
}
initPhenomenonMap() { initPhenomenonMap() {
// map the different phenomena to their respective Enum for processing and display/translation // map the different phenomena to their respective Enum for processing and display/translation
Object.keys(Phenomenon).forEach((key) => { Object.keys(Phenomenon).forEach((key) => {
...@@ -336,9 +370,11 @@ export class CorpusService { ...@@ -336,9 +370,11 @@ export class CorpusService {
}); });
this.annisResponse = ar; this.annisResponse = ar;
if (saveToCache) { if (saveToCache) {
HelperService.mostRecentSetup.currentUrn = this.currentUrn; HelperService.applicationState.pipe(take(1)).subscribe((as: ApplicationState) => {
HelperService.mostRecentSetup.annisResponse = ar; as.currentSetup.currentUrn = this.currentUrn;
this.helperService.saveMostRecentSetup().then(); as.currentSetup.annisResponse = ar;
this.helperService.saveApplicationState(as).then();
});
} }
} }
...@@ -404,28 +440,56 @@ export class CorpusService { ...@@ -404,28 +440,56 @@ export class CorpusService {
restoreLastCorpus() { restoreLastCorpus() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.annisResponse = HelperService.mostRecentSetup.annisResponse; HelperService.applicationState.pipe(take(1)).subscribe((state: ApplicationState) => {
this.currentUrn = HelperService.mostRecentSetup.currentUrn; this.annisResponse = state.mostRecentSetup.annisResponse;
this.currentCorpus = HelperService.mostRecentSetup.currentCorpus; this.currentUrn = state.mostRecentSetup.currentUrn;
this.currentTextRange = HelperService.mostRecentSetup.currentTextRange; this.currentCorpusCache = state.mostRecentSetup.currentCorpus;
this.isTextRangeCorrect = true; this.currentTextRangeCache = state.mostRecentSetup.currentTextRange;
if (this.annisResponse && this.annisResponse.nodes.length) { this.isTextRangeCorrect = true;
this.processAnnisResponse(this.annisResponse, false); if (this.annisResponse && this.annisResponse.nodes.length) {
} this.processAnnisResponse(this.annisResponse, false);
// check if the data is already present return resolve();
if (this.currentText) { } else if (this.currentText) {
return resolve(); // check if the data is already present
} return resolve();
const saveToCache: boolean = !HelperService.mostRecentSetup.annisResponse || } else {
!HelperService.mostRecentSetup.annisResponse.nodes.length; const saveToCache: boolean = !state.mostRecentSetup.annisResponse || !state.mostRecentSetup.annisResponse.nodes.length;
this.getText(saveToCache).then(() => { this.getText(saveToCache).then(() => {
return resolve(); return resolve();
}, () => { }, () => {
return reject(); return reject();
});
}
}); });
}); });
} }
saveNewCorpus(corpus: CorpusMC): void {
this.currentCorpusCache = corpus;
this.currentCorpus.next(this.currentCorpusCache);
this.setCurrentTextRange(-1, null, new TextRange({start: ['', '', ''], end: ['', '', '']}));
HelperService.applicationState.pipe(take(1)).subscribe((state: ApplicationState) => {
state.currentSetup.currentCorpus = corpus;
HelperService.applicationState.next(state);
});
}
setCurrentTextRange(inputId: number = -1, newValue: string = null, tr: TextRange = null): void {
if (tr) {
this.currentTextRangeCache = tr;
} else if (inputId >= 0) {
const isStart: boolean = inputId < 4;
const targetInputId = `input${inputId}`;
if (newValue === null) {
newValue = document.querySelector<HTMLInputElement>(`#${targetInputId}`).value;
}
const trIdx: number = inputId - (isStart ? 1 : 4);
const relevantTextRangePart: string[] = isStart ? this.currentTextRangeCache.start : this.currentTextRangeCache.end;
relevantTextRangePart[trIdx] = newValue;
}
this.currentTextRange.next(this.currentTextRangeCache);
}
updateBaseWord(query: QueryMC, queryIndex: number) { updateBaseWord(query: QueryMC, queryIndex: number) {
if (!this.annisResponse || !this.annisResponse.frequency_analysis || !this.annisResponse.frequency_analysis.length) { if (!this.annisResponse || !this.annisResponse.frequency_analysis || !this.annisResponse.frequency_analysis.length) {
return; return;
......
...@@ -60,24 +60,22 @@ ...@@ -60,24 +60,22 @@
</ion-col> </ion-col>
<ion-col> <ion-col>
<ng-container <ng-container
*ngIf="[ExerciseType.matching].indexOf(corpusService.exercise.type) === -1; else matching"> *ngIf="corpusService.exercise.type === ExerciseType.matching; else notMatching">
<label> <label>
<h2 class="label">{{ 'QUERY_VALUE' | translate }}</h2> <h2 class="label">{{ 'QUERY_VALUE' | translate }}</h2>
<select [(ngModel)]="query.values" name="queryValue" multiple <select [(ngModel)]="query.values[0]" name="queryValue"
size="{{Math.min(corpusService.getSortedQueryValues(query, i).length, 20)}}"> (change)="corpusService.updateBaseWord(query, i)">
<option *ngFor="let key of corpusService.getSortedQueryValues(query, i)" <option *ngFor="let key of corpusService.getSortedQueryValues(query, i)"
[value]=key>{{ getDisplayValue(query, key, i) }} [value]=key>{{ getDisplayValue(query, key, i) }}
</option> </option>
</select> </select>
</label> </label>
</ng-container> </ng-container>
<ng-template #matching> <ng-template #notMatching>
<label> <label>
<h2 class="label"> <h2 class="label">{{ 'QUERY_VALUE' | translate }}</h2>
{{ 'QUERY_VALUE' | translate }} <select [(ngModel)]="query.values" name="queryValue" multiple
</h2> size="{{Math.min(corpusService.getSortedQueryValues(query, i).length, 20)}}">
<select [(ngModel)]="query.values[0]" name="queryValue"
(change)="corpusService.updateBaseWord(query, i)">
<option *ngFor="let key of corpusService.getSortedQueryValues(query, i)" <option *ngFor="let key of corpusService.getSortedQueryValues(query, i)"
[value]=key>{{ getDisplayValue(query, key, i) }} [value]=key>{{ getDisplayValue(query, key, i) }}
</option> </option>
...@@ -116,8 +114,7 @@ ...@@ -116,8 +114,7 @@
<ion-col> <ion-col>
<label> <label>
<input [(ngModel)]="corpusService.exercise.instructionsTranslation" <input [(ngModel)]="corpusService.exercise.instructionsTranslation"
type="text" type="text" name="instructionsTranslation"/>
name="instructionsTranslation"/>
</label> </label>
</ion-col> </ion-col>
</ion-row> </ion-row>
......
...@@ -17,6 +17,10 @@ import {CorpusService} from 'src/app/corpus.service'; ...@@ -17,6 +17,10 @@ import {CorpusService} from 'src/app/corpus.service';
import {QueryMC} from 'src/app/models/queryMC'; import {QueryMC} from 'src/app/models/queryMC';
import {PhenomenonMapContent} from 'src/app/models/phenomenonMap'; import {PhenomenonMapContent} from 'src/app/models/phenomenonMap';
import {FrequencyItem} from 'src/app/models/frequencyItem'; import {FrequencyItem} from 'src/app/models/frequencyItem';
import {CorpusMC} from '../models/corpusMC';
import {ApplicationState} from '../models/applicationState';
import {take} from 'rxjs/operators';
import {TextRange} from '../models/textRange';
@Component({ @Component({
selector: 'app-exercise-parameters', selector: 'app-exercise-parameters',
...@@ -107,20 +111,22 @@ export class ExerciseParametersPage implements OnInit { ...@@ -107,20 +111,22 @@ export class ExerciseParametersPage implements OnInit {
const values: string[] = this.corpusService.exercise.queryItems[0].values as string[]; const values: string[] = this.corpusService.exercise.queryItems[0].values as string[];
instructions += ` [${values.map(x => pmc.translationValues[x]).join(', ')}]`; instructions += ` [${values.map(x => pmc.translationValues[x]).join(', ')}]`;
} }
// TODO: change the corpus title to something meaningful, e.g. concatenate user ID and wanted exercise title this.corpusService.currentCorpus.pipe(take(1)).subscribe((cc: CorpusMC) => {
const workTitle: string = this.corpusService.currentCorpus.title + ', ' + this.corpusService.currentTextRange.pipe(take(1)).subscribe((tr: TextRange) => {
this.corpusService.currentTextRange.start.filter(x => x).join('.') + '-' + // TODO: change the corpus title to something meaningful, e.g. concatenate user ID and wanted exercise title
this.corpusService.currentTextRange.end.filter(x => x).join('.'); const workTitle: string = cc.title + ', ' + tr.start.filter(x => x).join('.') + '-' + tr.end.filter(x => x).join('.');
formData.append('work_title', workTitle); formData.append('work_title', workTitle);
formData.append('type', MoodleExerciseType[this.corpusService.exercise.type]); formData.append('type', MoodleExerciseType[this.corpusService.exercise.type]);
formData.append('type_translation', this.corpusService.exercise.typeTranslation); formData.append('type_translation', this.corpusService.exercise.typeTranslation);
formData.append('instructions', instructions); formData.append('instructions', instructions);
formData.append('correct_feedback', this.corpusService.exercise.feedback.correct); formData.append('correct_feedback', this.corpusService.exercise.feedback.correct);
formData.append('partially_correct_feedback', this.corpusService.exercise.feedback.partiallyCorrect); formData.append('partially_correct_feedback', this.corpusService.exercise.feedback.partiallyCorrect);
formData.append('incorrect_feedback', this.corpusService.exercise.feedback.incorrect); formData.append('incorrect_feedback', this.corpusService.exercise.feedback.incorrect);
formData.append('general_feedback', this.corpusService.exercise.feedback.general); formData.append('general_feedback', this.corpusService.exercise.feedback.general);
formData.append('work_author', this.corpusService.currentCorpus.author); formData.append('work_author', cc.author);
this.getH5Pexercise(formData); this.getH5Pexercise(formData);
});
});
} }
getH5Pexercise(formData: FormData) { getH5Pexercise(formData: FormData) {
...@@ -131,12 +137,14 @@ export class ExerciseParametersPage implements OnInit { ...@@ -131,12 +137,14 @@ export class ExerciseParametersPage implements OnInit {
HelperService.isLoading = false; HelperService.isLoading = false;
// save the old frequency analysis in case we want to change the exercise parameters at a later time // save the old frequency analysis in case we want to change the exercise parameters at a later time
ar.frequency_analysis = this.corpusService.annisResponse.frequency_analysis; ar.frequency_analysis = this.corpusService.annisResponse.frequency_analysis;
HelperService.mostRecentSetup.annisResponse = ar; HelperService.applicationState.pipe(take(1)).subscribe((as: ApplicationState) => {
this.helperService.saveMostRecentSetup().then(); as.mostRecentSetup.annisResponse = ar;
this.corpusService.annisResponse.exercise_id = ar.exercise_id; this.helperService.saveApplicationState(as).then();
this.corpusService.annisResponse.uri = ar.uri; this.corpusService.annisResponse.exercise_id = ar.exercise_id;
this.corpusService.annisResponse.solutions = ar.solutions;