PUNKT-20 Tworzenie/edycja testów

This commit is contained in:
Marcin Szczepański 2019-11-29 21:46:49 +01:00
parent 0c93108991
commit 47934971ad
21 changed files with 76 additions and 5 deletions

View File

@ -16,7 +16,7 @@ export class FlashcardsAddCsvComponent implements OnInit {
progress: { percentage: number } = { percentage: 0 };
currentUser = JSON.parse(localStorage.getItem('currentUser'));
user: string;
permission: Boolean = true;
permission: Boolean = false;
constructor(private uploadService: FlashcardsService, private router: Router, public snackBar: MatSnackBar) { }
ngOnInit() { this.isLoggedIn(); }

View File

@ -14,7 +14,7 @@ export class FlashcardsAddTableComponent implements OnInit {
public fieldArray: Array<any> = [];
newAttribute: any = {};
currentUser;
permission: Boolean = true;
permission: Boolean = false;
constructor(private flashcardsService: FlashcardsService, public snackBar: MatSnackBar) { }

View File

@ -18,7 +18,7 @@ export class MaterialsAddComponent implements OnInit {
currentUser = JSON.parse(localStorage.getItem('currentUser'));
user: string;
title: string;
permission: Boolean = true;
permission: Boolean = false;
constructor(private uploadService: MaterialsService, private router: Router, public snackBar: MatSnackBar) { }

View File

@ -12,6 +12,10 @@
<p>Wprowadź treść pytania:</p>
<input type="text" name="question" class="form-control" [(ngModel)]="question"/>
</label>
<label class="block">
<p>Podaj czas na udzielenie odpowiedzi w sekundach (0 - brak limitu):</p>
<input type="number" step="1" min="0" name="time" class="form-control" [(ngModel)]="time" required/>
</label>
<br />
<p>Wpisz tekst widoczny i tekst luki (luka może mieć więcej niż 1 dobrą odpowiedź - każdą odpowiedź oddziel <b>średnikiem</b>).</p>
<div>

View File

@ -20,6 +20,7 @@ export class GapsQuestionComponent implements OnInit {
answersCorrect: Array<Object> = [];
answers: Array<Object> = [];
question: String = 'Uzupełnij luki w tekście:';
time = 0;
points: Number = 1;
id: Number = null;
@ -31,6 +32,7 @@ export class GapsQuestionComponent implements OnInit {
ngOnInit() {
if (this.edit) {
this.content['edit'] = true;
this.time = this.content['content']['time'];
this.question = this.content['content']['question'];
const answ = this.content['content']['answers'];
this.id = this.content['content']['id'];
@ -42,6 +44,7 @@ export class GapsQuestionComponent implements OnInit {
id: null,
type: 'gaps',
question: 'Uzupełnij luki w tekście.',
time: 0,
answers: [],
points: 1
};
@ -185,6 +188,7 @@ export class GapsQuestionComponent implements OnInit {
this.content['content']['question'] = this.question;
this.content['content']['answers'] = this.answers;
this.content['content']['points'] = this.points;
this.content['content']['time'] = this.time;
this.content['content']['id'] = this.id;
if (this.edit) {
this.editing.emit(this.content);
@ -210,6 +214,7 @@ export class GapsQuestionComponent implements OnInit {
this.content = {};
this.edit = false;
this.question = '';
this.time = 0;
this.answers = [];
this.noGapText = '';
this.gapText = '';

View File

@ -12,6 +12,10 @@
<p>Wprowadź treść pytania:</p>
<input type="text" name="question" class="form-control" [(ngModel)]="question"/>
</label>
<label class="block">
<p>Podaj czas na udzielenie odpowiedzi w sekundach (0 - brak limitu):</p>
<input type="number" step="1" min="0" name="time" class="form-control" [(ngModel)]="time" required/>
</label>
<br />
<p>Wpisz możliwe odpowiedzi i zaznacz prawidłową:</p>
<div>

View File

@ -21,6 +21,7 @@ export class MultipleChoiceQuestionComponent implements OnInit {
};
question: String = '';
points: Number = 1;
time = 0;
id: Number = null;
@Output() private add: EventEmitter<Object> = new EventEmitter();
@ -32,6 +33,7 @@ export class MultipleChoiceQuestionComponent implements OnInit {
if (this.edit) {
this.content['edit'] = true;
this.question = this.content['content']['question'];
this.time = this.content['content']['time'];
this.answers = [];
const answ = this.content['content']['answers'];
this.id = this.content['content']['id'];
@ -49,6 +51,7 @@ export class MultipleChoiceQuestionComponent implements OnInit {
id: this.id,
type: 'multiple-choice',
question: '',
time: 0,
answers: [],
points: 1
};
@ -141,6 +144,7 @@ export class MultipleChoiceQuestionComponent implements OnInit {
this.content['content']['question'] = this.question;
this.answers = this.answersCorrect;
this.content['content']['answers'] = this.answers;
this.content['content']['time'] = this.time;
this.content['content']['points'] = this.points;
this.content['content']['id'] = this.id;
if (this.edit) {
@ -169,6 +173,7 @@ export class MultipleChoiceQuestionComponent implements OnInit {
this.edit = false;
this.isChecked = false;
this.question = '';
this.time = 0;
this.answers = [];
this.answersCorrect = [];
this.newAttribute = {};

View File

@ -12,6 +12,10 @@
<p>Wprowadź treść pytania:</p>
<input type="text" name="question" class="form-control" [(ngModel)]="question"/>
</label>
<label class="block">
<p>Podaj czas na udzielenie odpowiedzi w sekundach (0 - brak limitu):</p>
<input type="number" step="1" min="0" name="time" class="form-control" [(ngModel)]="time" required/>
</label>
<br />
<p>Wpisz wszystkie dopasowania:</p>
<div>

View File

@ -20,6 +20,7 @@ export class PairsQuestionComponent implements OnInit {
};
question: String = 'Połącz w pary:';
points: Number = 1;
time = 0;
id: Number = null;
@Output() add: EventEmitter<Object> = new EventEmitter();
@ -32,6 +33,7 @@ export class PairsQuestionComponent implements OnInit {
this.answers = [];
this.content['edit'] = true;
this.question = this.content['content']['question'];
this.time = this.content['content']['time'];
this.id = this.content['content']['id'];
const answ = this.content['content']['answers'];
for (let i = 0; i < answ.length; i++) {
@ -48,6 +50,7 @@ export class PairsQuestionComponent implements OnInit {
id: null,
type: 'pairs',
question: 'Połącz w pary.',
time: 0,
answers: [],
points: 1
};
@ -131,6 +134,7 @@ export class PairsQuestionComponent implements OnInit {
}
}
if (!exists) {
this.content['content']['time'] = this.time;
this.content['content']['question'] = this.question;
this.answers = this.answersCorrect;
this.content['content']['answers'] = this.answers;
@ -161,6 +165,7 @@ export class PairsQuestionComponent implements OnInit {
this.content = {};
this.edit = false;
this.question = '';
this.time = 0;
this.answers = [];
this.answersCorrect = [];
this.newAttribute = {};

View File

@ -12,6 +12,10 @@
<p>Wprowadź treść pytania:</p>
<input type="text" name="question" class="form-control" [(ngModel)]="question"/>
</label>
<label class="block">
<p>Podaj czas na udzielenie odpowiedzi w sekundach (0 - brak limitu):</p>
<input type="number" step="1" min="0" name="time" class="form-control" [(ngModel)]="time" required/>
</label>
<br />
<p>Wpisz <b>kolejno</b> wszystkie elementy rozsypanki:</p>
<div>

View File

@ -19,6 +19,7 @@ export class PuzzleQuestionComponent implements OnInit {
};
question: String = 'Ułóż elementy w prawidłowej kolejności:';
points: Number = 1;
time = 0;
id: Number = null;
idAnsw: Number = null;
@ -31,6 +32,7 @@ export class PuzzleQuestionComponent implements OnInit {
if (this.edit) {
this.content['edit'] = true;
this.question = this.content['content']['question'];
this.time = this.content['content']['time'];
this.id = this.content['content']['id'];
this.answers = [];
const answ = this.content['content']['answers'][0]['correct'];
@ -47,6 +49,7 @@ export class PuzzleQuestionComponent implements OnInit {
type: 'puzzle',
question: 'Ułóż elementy w prawidłowej kolejności.',
answers: [],
time: 0,
points: 1
};
this.content['edit'] = false;
@ -120,6 +123,7 @@ export class PuzzleQuestionComponent implements OnInit {
this.content['content']['question'] = this.question;
this.content['content']['answers'] = this.answers;
this.content['content']['points'] = this.points;
this.content['content']['time'] = this.time;
this.content['content']['id'] = this.id;
if (this.edit) {
this.editing.emit(this.content);
@ -157,6 +161,7 @@ export class PuzzleQuestionComponent implements OnInit {
this.content = {};
this.edit = false;
this.question = '';
this.time = 0;
this.answers = [];
this.answersCorrect = [];
this.newAttribute = {};

View File

@ -12,6 +12,10 @@
<p>Wprowadź treść pytania:</p>
<input type="text" name="question" class="form-control" [(ngModel)]="question"/>
</label>
<label class="block">
<p>Podaj czas na udzielenie odpowiedzi w sekundach (0 - brak limitu):</p>
<input type="number" step="1" min="0" name="time" class="form-control" [(ngModel)]="time" required/>
</label>
<br />
<p>Wpisz możliwe odpowiedzi i zaznacz prawidłową:</p>
<div>

View File

@ -21,6 +21,7 @@ export class SingleChoiceQuestionComponent implements OnInit {
};
question: String = '';
points: Number = 1;
time = 0;
id: Number = null;
@Output() add: EventEmitter<Object> = new EventEmitter();
@ -34,6 +35,7 @@ export class SingleChoiceQuestionComponent implements OnInit {
this.question = this.content['content']['question'];
this.answers = [];
const answ = this.content['content']['answers'];
this.time = this.content['content']['time'];
this.id = this.content['content']['id'];
for (let i = 0; i < answ.length; i++) {
this.answersCorrect.push({
@ -50,7 +52,8 @@ export class SingleChoiceQuestionComponent implements OnInit {
type: 'single-choice',
question: '',
answers: [],
points: 1
points: 1,
time: 0
};
this.content['edit'] = false;
}
@ -157,6 +160,7 @@ export class SingleChoiceQuestionComponent implements OnInit {
this.answers = this.answersCorrect;
this.content['content']['answers'] = this.answers;
this.content['content']['points'] = this.points;
this.content['content']['time'] = this.time;
if (this.edit) {
this.editing.emit(this.content);
} else {
@ -184,6 +188,7 @@ export class SingleChoiceQuestionComponent implements OnInit {
this.edit = false;
this.isChecked = false;
this.question = '';
this.time = 0;
this.answers = [];
this.answersCorrect = [];
this.newAttribute = {};

View File

@ -29,6 +29,10 @@ label {
margin-left: 1rem;
}
.table {
color: #FFF !important;
}
.table td {
border-top-width: 0;
}

View File

@ -57,6 +57,7 @@ export class TestEditComponent implements OnInit, OnDestroy {
id: d[i]['id'],
type: d[i]['type'],
question: d[i]['question'],
time: d[i]['time'],
answers: d[i]['answers'],
points: d[i]['points']
},
@ -213,6 +214,7 @@ export class TestEditComponent implements OnInit, OnDestroy {
nr: this.test[i]['nr'],
type: this.test[i]['content']['type'],
question: this.test[i]['content']['question'],
time: this.test[i]['content']['time'],
answers: this.test[i]['content']['answers'],
points: this.test[i]['content']['points'],
id: this.test[i]['content']['id']

View File

@ -29,6 +29,10 @@ label {
margin-left: 1rem;
}
.table {
color: #FFF !important;
}
.table td {
border-top-width: 0;
}

View File

@ -50,6 +50,7 @@
<th>Lp.</th>
<th>Typ</th>
<th class="mobile">Punkty</th>
<th class="mobile">Czas na odpowiedź</th>
<th class="mobile">Pytanie</th>
<th>Usuń</th>
<th class="mobile">Przenieś</th>
@ -72,6 +73,8 @@
*ngIf='question.content.type == "pairs"'>Łączenie w pary</td>
<td (click)='showComponents(question.content.type, question.nr)'
class="mobile">{{ question.content.points }}</td>
<td (click)='showComponents(question.content.type, question.nr)'
class="mobile">{{ question.content.time }}</td>
<td (click)='showComponents(question.content.type, question.nr)'
class="mobile">{{ question.shortcut }}</td>
<td><button class="btn btn-study-cave" (click)="delete(question.nr)"><i class="fas fa-trash-alt"></i> Usuń</button></td>

View File

@ -11,7 +11,7 @@ export class TestMakerComponent implements OnInit {
owner: Number = 0;
title: String = '';
permission: Boolean = true;
permission: Boolean = false;
test: Array<Object> = [];
shown: Boolean = false;
@ -159,6 +159,7 @@ export class TestMakerComponent implements OnInit {
nr: this.test[i]['nr'],
type: this.test[i]['content']['type'],
question: this.test[i]['content']['question'],
time: this.test[i]['content']['time'],
answers: this.test[i]['content']['answers'],
points: this.test[i]['content']['points'],
id: this.test[i]['content']['id']

View File

@ -18,6 +18,7 @@ export class TestResource {
public id: number;
public points: number;
public question: string;
public time: string;
public nr: number;
public answers: Answer[];

View File

@ -12,6 +12,10 @@
<p>Wprowadź treść pytania:</p>
<input type="text" name="question" class="form-control" [(ngModel)]="content['content']['question']" required />
</label>
<label class="block">
<p>Podaj czas na udzielenie odpowiedzi w sekundach (0 - brak limitu):</p>
<input type="number" step="1" min="0" name="time" class="form-control" [(ngModel)]="content['content']['time']" required/>
</label>
<br />
<p>Zaznacz prawidłową odpowiedź:</p>
<label>

View File

@ -16,18 +16,22 @@ export class TrueFalseQuestionComponent implements OnInit {
@Output() add: EventEmitter<Object> = new EventEmitter();
@Output() editing: EventEmitter<Object> = new EventEmitter();
time = 0;
constructor() {}
ngOnInit() {
if (this.edit) {
this.content['edit'] = true;
this.id = this.content['content']['id'];
this.time = this.content['content']['time'];
} else {
this.content = {};
this.content['content'] = {
id: null,
type: 'true-false',
question: '',
time: 0,
answers: [
{id: null, content: 'Prawda', is_good: false},
{id: null, content: 'Fałsz', is_good: false}
@ -50,6 +54,7 @@ export class TrueFalseQuestionComponent implements OnInit {
id: this.id,
type: 'true-false',
question: value['question'],
time: value['time'],
answers: [
{id: this.content['content']['answers'][0]['id'], content: 'Prawda', is_good: true},
{id: this.content['content']['answers'][1]['id'], content: 'Fałsz', is_good: false}
@ -61,6 +66,7 @@ export class TrueFalseQuestionComponent implements OnInit {
id: this.id,
type: 'true-false',
question: value['question'],
time: value['time'],
answers: [
{id: this.content['content']['answers'][0]['id'], content: 'Prawda', is_good: false},
{id: this.content['content']['answers'][1]['id'], content: 'Fałsz', is_good: true}
@ -68,6 +74,7 @@ export class TrueFalseQuestionComponent implements OnInit {
points: value['points']
};
}
console.log(this.content);
if (this.edit) {
this.editing.emit(this.content);
} else {