Merge branch 'master' of https://git.wmi.amu.edu.pl/s416178/Punktonerzy
This commit is contained in:
commit
900f8a70c2
@ -91,8 +91,9 @@ public class TestController {
|
||||
(o1, o2) -> o1.getId().compareTo(o2.getId()));
|
||||
}
|
||||
}
|
||||
if (testToReturn.getHelp()){
|
||||
|
||||
for (Question question : testToReturn.getQuestions()) {
|
||||
if (question.getHelp()){
|
||||
if (question instanceof QuestionChoices){
|
||||
QuestionChoices questionChoices = (QuestionChoices) question;
|
||||
List<AnswerChoices> answers = questionChoices.getAnswers();
|
||||
@ -146,7 +147,7 @@ public class TestController {
|
||||
}
|
||||
List<AnswerChoices> helpers = new ArrayList<>();
|
||||
if (question.getType().equals("single-choice")) {
|
||||
if (test.get().getHelp()){
|
||||
if (question.getHelp()){
|
||||
List<AnswerChoices> answers = answersDTOs;
|
||||
if (answers.size() > 2) {
|
||||
for (AnswerChoices answerChoices : answers){
|
||||
@ -369,8 +370,6 @@ public class TestController {
|
||||
test.setAddDate();
|
||||
test.setEditDate();
|
||||
test.setGrade();
|
||||
if (testDTO.getHelp() != null)
|
||||
test.setHelp(testDTO.getHelp());
|
||||
|
||||
// Badge for creating first test
|
||||
if(userBadgeRepository.findByIdAndUser((long)4, user.getId()).isEmpty()) {
|
||||
@ -551,8 +550,6 @@ public class TestController {
|
||||
// System.out.println("usuwam "+oldquestion.getId());
|
||||
}
|
||||
}
|
||||
if (testDTO.getHelp() != null)
|
||||
test.setHelp(testDTO.getHelp());
|
||||
testRepository.save(test);
|
||||
|
||||
for (Long a : deletea)
|
||||
|
@ -66,8 +66,7 @@ public class Test {
|
||||
@Nullable
|
||||
private Long availableTo = null;
|
||||
|
||||
@Column(columnDefinition = "TINYINT(1)")
|
||||
private Boolean help = false;
|
||||
|
||||
|
||||
|
||||
public void setAddDate() {
|
||||
|
@ -31,8 +31,6 @@ public class TestCreateDTO {
|
||||
@ApiModelProperty(value = "Default value for note", required = true,example = "public")
|
||||
private String permission;
|
||||
|
||||
private Boolean help = false;
|
||||
|
||||
@JsonIgnore
|
||||
private Long grade;
|
||||
@JsonProperty("body")
|
||||
|
@ -68,4 +68,9 @@ public abstract class Question {
|
||||
@Setter
|
||||
private int time;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Column(columnDefinition = "TINYINT(1)")
|
||||
private Boolean help = false;
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
</div>
|
||||
<div *ngSwitchCase="'single-choice'">
|
||||
<small>Pytanie jednokrotnego wyboru</small>
|
||||
<app-single-choice [question]="question" (emitNextQuestionRequest)="handleEmitNextQuestionRequest($event)"></app-single-choice>
|
||||
<app-single-choice [question]="question" [activeFifty]='activeFifty' (emitNextQuestionRequest)="handleEmitNextQuestionRequest($event)" (lifebuoy)="LifebuoyFifty($event)"></app-single-choice>
|
||||
</div>
|
||||
<div *ngSwitchCase="'multiple-choice'">
|
||||
<small>Pytanie wielokrotnego wyboru</small>
|
||||
|
@ -10,7 +10,10 @@ export class QuestionViewComponent implements OnInit {
|
||||
question;
|
||||
@Input()
|
||||
private questionIndex;
|
||||
@Input() activeFifty;
|
||||
@Output() emitNextQuestionRequest = new EventEmitter();
|
||||
@Output() lifebuoyTest = new EventEmitter<boolean>();
|
||||
|
||||
|
||||
constructor() { }
|
||||
|
||||
@ -22,6 +25,10 @@ export class QuestionViewComponent implements OnInit {
|
||||
this.nextQuestion(e);
|
||||
}
|
||||
|
||||
LifebuoyFifty(y) {
|
||||
this.lifebuoyTest.emit(y);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
|
@ -1,16 +1,23 @@
|
||||
<form #f="ngForm" (ngSubmit)="nextQuestion(f)" novalidate>
|
||||
<div class="alert alert-grey question">
|
||||
Pytanie za {{question.points}}pkt. <br /><span *ngIf="timeLeft > 0">Czas: {{ timeLeft }} sek. </span><span *ngIf="question.time === 0">Czas: bez limitu</span>
|
||||
<div *ngIf="question.help" class="fifty"><img src="./././././assets/50-50.png" width="80px" height="50px"></div>
|
||||
<div *ngIf="(question.help && activeFifty)" class="fifty" (click)="fiftyFifty()"><img src="./././././assets/50-50.png" width="80px" height="50px"></div>
|
||||
<div class="pytanie">{{question.question}} </div>
|
||||
<div class="answers">
|
||||
<div *ngIf="!fifty" class="answers">
|
||||
<div *ngFor="let item of question.answers" >
|
||||
|
||||
<input type="radio" name="answer" class="radio-answer" id="{{item.content}}" [value]="item.content" ngModel ><label for="{{item.content}}">{{item.content}}</label>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="(fifty)" class="answers">
|
||||
<div *ngFor="let item of question.answers_help" >
|
||||
|
||||
<input type="radio" name="answer" class="radio-answer" id="{{item.content}}" [value]="item.content" ngModel ><label for="{{item.content}}">{{item.content}}</label>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-study-cave" type="submit"><i class="fas fa-arrow-right"></i> Dalej</button>
|
||||
<button class="btn btn-study-cave" type="submit" (click)="noHelp()"><i class="fas fa-arrow-right"></i> Dalej</button>
|
||||
</form>
|
||||
|
@ -14,12 +14,16 @@ export class SingleChoiceComponent implements OnInit, OnDestroy {
|
||||
private _question;
|
||||
private answer;
|
||||
@Output() emitNextQuestionRequest = new EventEmitter();
|
||||
@Output() lifebuoy = new EventEmitter<boolean>();
|
||||
@Input() activeFifty;
|
||||
private id;
|
||||
private verifyAnswerSubscription: ISubscription;
|
||||
interval: any;
|
||||
public timeLeft = 0;
|
||||
public fifty: Boolean = false;
|
||||
@ViewChild('f') public form: NgForm;
|
||||
|
||||
|
||||
constructor(private route: ActivatedRoute, private testsService: TestsService) { }
|
||||
|
||||
nextQuestion(f) {
|
||||
@ -35,6 +39,15 @@ export class SingleChoiceComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
fiftyFifty() {
|
||||
this.fifty = true;
|
||||
this.lifebuoy.emit(false);
|
||||
}
|
||||
|
||||
noHelp() {
|
||||
this.fifty = false;
|
||||
}
|
||||
|
||||
startTimer() {
|
||||
this.interval = setInterval(() => {
|
||||
if (this.timeLeft > 0) {
|
||||
|
@ -38,7 +38,7 @@
|
||||
|
||||
|
||||
<div class="question-view">
|
||||
<app-question-view [question]="test.body[currentQuestionIndex]" [questionIndex]="currentQuestionIndex" (emitNextQuestionRequest)="handleEmitNextQuestionRequest($event)"></app-question-view>
|
||||
<app-question-view [question]="test.body[currentQuestionIndex]" [questionIndex]="currentQuestionIndex" [activeFifty]='lifebuoyTest' (emitNextQuestionRequest)="handleEmitNextQuestionRequest($event)" (lifebuoyTest)="LifebuoyFifty($event)" ></app-question-view>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -19,6 +19,7 @@ export class TestDetailsComponent implements OnInit, OnDestroy {
|
||||
currentQuestionIndex = 0;
|
||||
isEnded = false;
|
||||
points = 0;
|
||||
public lifebuoyTest: Boolean = true;
|
||||
maxPoints = 0;
|
||||
prevMaxResult = 0;
|
||||
prevAnswerResultBool;
|
||||
@ -78,6 +79,10 @@ export class TestDetailsComponent implements OnInit, OnDestroy {
|
||||
);
|
||||
}
|
||||
|
||||
LifebuoyFifty(y) {
|
||||
this.lifebuoyTest = y;
|
||||
}
|
||||
|
||||
getMaxResult() {
|
||||
if (this.currentUser) {
|
||||
this.getResultSubscription = this.testService.getResult(this.test.id, this.currentUser.username).subscribe(d => {
|
||||
|
@ -15,7 +15,6 @@ export class TestEditComponent implements OnInit, OnDestroy {
|
||||
owner: Number = 0;
|
||||
title: String = '';
|
||||
permission: Boolean = false;
|
||||
|
||||
test: Array<Object> = [];
|
||||
shown: Boolean = false;
|
||||
|
||||
@ -59,7 +58,8 @@ export class TestEditComponent implements OnInit, OnDestroy {
|
||||
question: d[i]['question'],
|
||||
time: d[i]['time'],
|
||||
answers: d[i]['answers'],
|
||||
points: d[i]['points']
|
||||
points: d[i]['points'],
|
||||
help: d[i]['help']
|
||||
},
|
||||
shortcut: short
|
||||
};
|
||||
@ -217,7 +217,8 @@ export class TestEditComponent implements OnInit, OnDestroy {
|
||||
time: this.test[i]['content']['time'],
|
||||
answers: this.test[i]['content']['answers'],
|
||||
points: this.test[i]['content']['points'],
|
||||
id: this.test[i]['content']['id']
|
||||
id: this.test[i]['content']['id'],
|
||||
help: this.test[i]['content']['help']
|
||||
});
|
||||
}
|
||||
toSend['body'] = body;
|
||||
|
Loading…
Reference in New Issue
Block a user