Skip to content
Snippets Groups Projects
Commit 12f6b1e8 authored by Heine Mærde Brakstad's avatar Heine Mærde Brakstad
Browse files

Merge branch 'backend-frontend-sync' into 'main'

Backend frontend sync

See merge request !35
parents 7da7fd4e e7165de7
Branches
No related tags found
1 merge request!35Backend frontend sync
Pipeline #269412 passed
......@@ -85,6 +85,7 @@ public class QuizController {
quizDTO.setId(quiz.getId());
quizDTO.setTitle(quiz.getTitle());
quizDTO.setCategory(quiz.getCategory());
quizDTO.setDifficulty(quiz.getDifficulty());
return quizDTO;
}
......
......@@ -14,9 +14,7 @@
},
data() {
return {
quizTitle: null,
quizDifficulty: null,
quizCategory: null,
quizList: []
};
},
mounted() {
......@@ -24,13 +22,11 @@
},
methods: {
async getQuiz() {
console.log('Fetching data for quiz: ', this.quizId);
try {
const response = await apiClient.get('/quiz/quiz/' + this.quizId);
this.quizTitle = JSON.parse(response.data.title);
this.quizCategory = JSON.parse(response.data.category);
this.quizDifficulty = JSON.parse(response.data.difficulty);
const response = await apiClient.get('/quiz/');
this.quizList = response.data;
console.log(this.quizList[0])
} catch (error) {
// TODO: Proper error handling
console.error('Error retrieving quiz:', error);
......@@ -46,8 +42,9 @@
return categoryIcons.Default;
}
},
playQuiz() {
router.push({ name: 'playQuiz', params: { quizId: this.quizId } });
playQuiz(id) {
console.log(id)
router.push({ name: 'playQuiz', params: { quizId: id } });
},
},
};
......@@ -67,18 +64,18 @@
</div>
<div class="row">
<div class="quiz-col">
<div class="quiz-list">
<div class="quiz-col" v-for="quiz in quizList" :key="quiz.id">
<div class="quiz-header">
<h3>{{ quizTitle }} Fake quiz name</h3>
<Svg :name="quizCategory" />
<h3>{{ quiz.title }}</h3>
</div>
<div class="quiz-body">
<p>Difficulty level: {{ quizDifficulty }}</p>
<p>Category: {{ quizCategory }}</p>
<p>Difficulty level: {{ quiz.difficulty }}</p>
<p>Category: {{ quiz.category }}</p>
</div>
<div class="quiz-footer">
<button @click="playQuiz" class="play-btn">Play</button>
<button @click="playQuiz(quiz.id)" class="play-btn">Play</button>
</div>
</div>
</div>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment