Skip to content
Snippets Groups Projects
Commit 516aa3f6 authored by ywb16155's avatar ywb16155
Browse files

commit #15 - updating minute paper service to guard against submission spam

parent 54a18bfd
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,7 @@ public class AnswerEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public int answerId;
private int answerId;
@Column
private String answerText;
......
......@@ -85,7 +85,11 @@ public class MinutePaperService {
private int hasExistingAnswer(String username, int paperId, int questionId) {
if(answerEntityRepository.existsByUsernameAndPaperIdAndQuestionId(username,paperId,questionId)) {
return answerEntityRepository.findByUsernameAndPaperIdAndQuestionId(username,paperId,questionId).get().answerId;
AnswerEntity entity = answerEntityRepository.findByUsernameAndPaperIdAndQuestionId(username,paperId,questionId).get();
if(entity.getSubmitted()) {
return -1;
}
return entity.getAnswerId();
}
return -1;
}
......
......@@ -10,7 +10,7 @@
</div>
<div class="row">
<label for="{{i}}">{{question.questionText}}</label>
<textarea id="{{i}}" [formControlName]="i" class="form-control" type="text" rows="3" placeholder="Start typing your response here.."></textarea>
<textarea id="{{i}}" [formControlName]="i" class="form-control" type="text" rows="3" [value]="answerList[i].answerText" placeholder="Start typing your response here.."></textarea>
</div>
</div>
<!-- Buttons -->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment