Commit 33b056d3 authored by Konstantin Schulz's avatar Konstantin Schulz

context size for KWIC view is now configurable

parent a5b581b2
Pipeline #10920 passed with stage
in 1 minute and 33 seconds
......@@ -4,7 +4,7 @@ coverage:
stage: test
script:
- docker-compose build
- docker-compose run mc_frontend npm run test
- docker-compose run --entrypoint="npm run test" mc_frontend
coverage: '/Statements.*?(\d+(?:\.\d+)?)%/'
tags:
- node
......
......@@ -18,6 +18,7 @@ RUN ng analytics off
RUN npm install
COPY . .
COPY ./config.xml ./www/config.xml
# workaround to fix the missing binding issue for node-sass
RUN npm rebuild node-sass
......@@ -5,7 +5,7 @@ services:
build:
context: .
dockerfile: Dockerfile
entrypoint: ng build --prod
entrypoint: ng build --prod app
environment:
- CHROME_BIN=google-chrome
restart: always
......@@ -25,7 +25,6 @@ services:
volumes:
- $PWD/www:/usr/share/nginx/html
- ./nginx.conf:/etc/nginx/nginx.conf
- ./config.xml:/usr/share/nginx/html/config.xml
depends_on:
- mc_frontend
networks:
......
{
"name": "mc_frontend",
"version": "1.7.3",
"version": "1.7.4",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
......
......@@ -271,15 +271,16 @@ describe('CorpusService', () => {
}));
it('should initialize the update information', (done) => {
corpusService.storage.set(configMC.localStorageKeyUpdateInfo, null).then(() => {
corpusService.initUpdateInfo().then(() => {
corpusService.storage.get(configMC.localStorageKeyUpdateInfo).then((jsonString: string) => {
expect(jsonString).toBeTruthy();
const setSpy: Spy = spyOn(corpusService.storage, 'set').and.returnValue(Promise.resolve());
corpusService.initUpdateInfo().then(() => {
expect(setSpy).toHaveBeenCalledTimes(0);
done();
});
const updateInfoSpy: Spy = spyOn(corpusService.storage, 'get').withArgs(configMC.localStorageKeyUpdateInfo);
updateInfoSpy.and.returnValue(Promise.resolve(''));
corpusService.initUpdateInfo().then(() => {
updateInfoSpy.and.callThrough();
corpusService.storage.get(configMC.localStorageKeyUpdateInfo).then((jsonString: string) => {
expect(jsonString).toBeTruthy();
const setSpy: Spy = spyOn(corpusService.storage, 'set').and.returnValue(Promise.resolve());
corpusService.initUpdateInfo().then(() => {
expect(setSpy).toHaveBeenCalledTimes(0);
done();
});
});
});
......
......@@ -89,85 +89,102 @@
</ion-grid>
</ion-col>
</ion-row>
<ion-row *ngIf="corpusService.exercise.type !== ExerciseType.kwic">
<ion-col style="display: inline-grid">
<ion-grid style="text-align: left">
<ion-row>
<ion-col class="toggle-menu" style="padding: 0">
<button *ngIf="showFeedback; else dropright" (click)="showFeedback = !showFeedback">
<ion-icon name="caret-down"></ion-icon>
</button>
<ng-template #dropright>
<button (click)="showFeedback = !showFeedback">
<ion-icon name="caret-forward"></ion-icon>
</button>
</ng-template>
<div>
<h4 class="label" (click)="showFeedback = !showFeedback" style="padding:0.5em;">
{{ 'INSTRUCTIONS' | translate }}
+ {{ 'EXERCISE_FEEDBACK' | translate }}</h4>
</div>
</ion-col>
</ion-row>
<ion-row *ngIf="showFeedback">
<ion-col style="padding: 0;">
<ion-grid style="text-align: left; font-size: 1.2em;">
<ion-row>
<ion-col>
<label>
<input [(ngModel)]="corpusService.exercise.instructionsTranslation"
type="text" name="instructionsTranslation"/>
</label>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<b>{{ 'EXERCISE_FEEDBACK' | translate }}:</b>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<label>
{{ 'EXERCISE_FEEDBACK_GENERAL' | translate }}:
<input type="text" [(ngModel)]="corpusService.exercise.feedback.general"
name="feedbackGeneral"/>
</label>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<label>
{{ 'EXERCISE_FEEDBACK_CORRECT' | translate }}:
<input type="text" [(ngModel)]="corpusService.exercise.feedback.correct"
name="feedbackCorrect"/>
</label>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<label>
{{ 'EXERCISE_FEEDBACK_PARTIALLY_CORRECT' | translate }}:
<input type="text"
[(ngModel)]="corpusService.exercise.feedback.partiallyCorrect"
name="feedbackPartiallyCorrect"/>
</label>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<label>
{{ 'EXERCISE_FEEDBACK_INCORRECT' | translate }}:
<input type="text" [(ngModel)]="corpusService.exercise.feedback.incorrect"
name="feedbackIncorrect"/>
</label>
</ion-col>
</ion-row>
</ion-grid>
</ion-col>
</ion-row>
</ion-grid>
<ion-row *ngIf="corpusService.exercise.type === ExerciseType.kwic; else notKWIC">
<ion-col>
<label>
{{ 'LEFT_CONTEXT_SIZE' | translate }}:
<input [(ngModel)]="leftContextSize" type="number" min="1" name="leftContextSize"/>
</label>
</ion-col>
<ion-col>
<label>
{{ 'RIGHT_CONTEXT_SIZE' | translate }}:
<input [(ngModel)]="rightContextSize" type="number" min="1" name="rightContextSize"/>
</label>
</ion-col>
</ion-row>
<ng-template #notKWIC>
<ion-row>
<ion-col style="display: inline-grid">
<ion-grid style="text-align: left">
<ion-row>
<ion-col class="toggle-menu" style="padding: 0">
<button *ngIf="showFeedback; else dropright" (click)="showFeedback = !showFeedback">
<ion-icon name="caret-down"></ion-icon>
</button>
<ng-template #dropright>
<button (click)="showFeedback = !showFeedback">
<ion-icon name="caret-forward"></ion-icon>
</button>
</ng-template>
<div>
<h4 class="label" (click)="showFeedback = !showFeedback" style="padding:0.5em;">
{{ 'INSTRUCTIONS' | translate }}
+ {{ 'EXERCISE_FEEDBACK' | translate }}</h4>
</div>
</ion-col>
</ion-row>
<ion-row *ngIf="showFeedback">
<ion-col style="padding: 0;">
<ion-grid style="text-align: left; font-size: 1.2em;">
<ion-row>
<ion-col>
<label>
<input [(ngModel)]="corpusService.exercise.instructionsTranslation"
type="text" name="instructionsTranslation"/>
</label>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<b>{{ 'EXERCISE_FEEDBACK' | translate }}:</b>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<label>
{{ 'EXERCISE_FEEDBACK_GENERAL' | translate }}:
<input type="text" [(ngModel)]="corpusService.exercise.feedback.general"
name="feedbackGeneral"/>
</label>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<label>
{{ 'EXERCISE_FEEDBACK_CORRECT' | translate }}:
<input type="text" [(ngModel)]="corpusService.exercise.feedback.correct"
name="feedbackCorrect"/>
</label>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<label>
{{ 'EXERCISE_FEEDBACK_PARTIALLY_CORRECT' | translate }}:
<input type="text"
[(ngModel)]="corpusService.exercise.feedback.partiallyCorrect"
name="feedbackPartiallyCorrect"/>
</label>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<label>
{{ 'EXERCISE_FEEDBACK_INCORRECT' | translate }}:
<input type="text"
[(ngModel)]="corpusService.exercise.feedback.incorrect"
name="feedbackIncorrect"/>
</label>
</ion-col>
</ion-row>
</ion-grid>
</ion-col>
</ion-row>
</ion-grid>
</ion-col>
</ion-row>
</ng-template>
<ion-row>
<ion-col>
<ion-button (click)="generateExercise().then()">{{ 'PREVIEW' | translate }}</ion-button>
......
......@@ -8,7 +8,7 @@ import {
} from '../models/enum';
import {AnnisResponse} from 'src/app/models/annisResponse';
import {NavController, ToastController} from '@ionic/angular';
import {HttpClient, HttpErrorResponse} from '@angular/common/http';
import {HttpClient} from '@angular/common/http';
import {Component, OnInit} from '@angular/core';
import {TranslateService} from '@ngx-translate/core';
import {ExerciseService} from 'src/app/exercise.service';
......@@ -31,12 +31,13 @@ import configMC from '../../configMC';
export class ExerciseParametersPage implements OnInit {
public ExerciseType = ExerciseType;
ExerciseTypeTranslation = ExerciseTypeTranslation;
public leftContextSize = 5;
public Math = Math;
ObjectKeys = Object.keys;
Phenomenon = Phenomenon;
PhenomenonTranslation = PhenomenonTranslation;
public rightContextSize = 5;
showFeedback = false;
textTooLongString: string;
constructor(public navCtrl: NavController,
public toastCtrl: ToastController,
......@@ -142,6 +143,8 @@ export class ExerciseParametersPage implements OnInit {
getKwicExercise(formData: FormData): Promise<void> {
return new Promise<void>((resolve, reject) => {
formData.append('ctx_left', (Math.max(Math.round(this.leftContextSize), 1)).toString());
formData.append('ctx_right', (Math.max(Math.round(this.rightContextSize), 1)).toString());
const kwicUrl: string = configMC.backendBaseUrl + configMC.backendApiKwicPath;
this.helperService.makePostRequest(this.http, this.toastCtrl, kwicUrl, formData).then((svgString: string) => {
this.exerciseService.kwicGraphs = svgString;
......
......@@ -37,14 +37,9 @@ export class SemanticsPage implements OnInit {
return new Promise<void>(resolve => {
this.activatedRoute.queryParams.subscribe((params: any) => {
if (Object.keys(params).length) {
const paramSearchRegex: string = params.searchRegex;
this.searchRegex = paramSearchRegex ? paramSearchRegex : this.searchRegex;
const paramMinCount: string = params.minCount;
this.minCount = paramMinCount ? +paramMinCount : this.minCount;
const paramNearestNeighborCount: string = params.nearestNeighborCount;
this.nearestNeighborCount = paramNearestNeighborCount ? +paramNearestNeighborCount : this.nearestNeighborCount;
const paramHighlightRegex: string = params.highlightRegex;
this.highlightRegex = paramHighlightRegex ? paramHighlightRegex : this.highlightRegex;
Object.keys(params).forEach((key: string) => {
this[key] = typeof this[key] === 'number' ? +params[key] : params[key];
});
// dirty hack to get the loading spinner displayed correctly
setTimeout(this.updateVectorNetwork.bind(this), 500);
}
......
......@@ -226,6 +226,7 @@
"INVALID_TEXT_RANGE": "Ungültige Textauswahl",
"KWIC": "Beispielkontexte",
"LANGUAGE_CHANGE": "Sprache wählen",
"LEFT_CONTEXT_SIZE": "Kontextwörter links",
"LINK_COPIED": "Link kopiert",
"MACHINA_CALLIDA": "Machina Callida",
"MACHINA_CALLIDA_BACKEND": "Machina Callida Backend",
......@@ -278,6 +279,7 @@
"RESEARCH_STUDIES_3": "im Lateinunterricht der älteren Fortgeschrittenen (Oberstufe) ebenfalls die Studien zu Ovid und Cicero",
"RESEARCH_STUDIES_4": "eine Testung der computergestützten Übungsformate (MC) durch Studierende der Klassischen Philologie (Dez. 2018)",
"RESULT": "Ergebnis",
"RIGHT_CONTEXT_SIZE": "Kontextwörter rechts",
"SEARCH": "Suche",
"SEARCH_REGEX_MISSING": "Bitte Suchanfrage eingeben...",
"SEMANTICS": "Semantik",
......
......@@ -226,6 +226,7 @@
"INVALID_TEXT_RANGE": "Invalid text range",
"KWIC": "Keyword in context",
"LANGUAGE_CHANGE": "Choose language",
"LEFT_CONTEXT_SIZE": "Context words left",
"LINK_COPIED": "Link copied",
"MACHINA_CALLIDA": "Machina Callida",
"MACHINA_CALLIDA_BACKEND": "Machina Callida Backend",
......@@ -278,6 +279,7 @@
"RESEARCH_STUDIES_3": "in the Latin classes of the older advanced students (upper level) also the studies to Ovid and Cicero",
"RESEARCH_STUDIES_4": "a test of the computer-aided exercise formats (MC) by students of classical philology (Dec. 2018)",
"RESULT": "Result",
"RIGHT_CONTEXT_SIZE": "Context words right",
"SEARCH": "Search",
"SEARCH_REGEX_MISSING": "Please provide search query...",
"SEMANTICS": "Semantics",
......
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