Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Fullstack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Madeleine Stenberg Jonassen
Fullstack
Merge requests
!50
Questions endpoint
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Questions endpoint
questions_endpoint
into
main
Overview
0
Commits
8
Pipelines
1
Changes
13
Merged
Kristiane Skogvang Kolshus
requested to merge
questions_endpoint
into
main
1 year ago
Overview
0
Commits
8
Pipelines
1
Changes
13
Expand
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
5f17325f
8 commits,
1 year ago
13 files
+
291
−
66
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
13
Search (e.g. *.vue) (Ctrl+P)
FullstackProsjekt/src/backend/main/java/edu/ntnu/idatt2105/controller/QuestionController.java
+
17
−
14
Options
@@ -4,7 +4,9 @@ import edu.ntnu.idatt2105.dto.QuestionDTO;
import
edu.ntnu.idatt2105.model.Question
;
import
edu.ntnu.idatt2105.service.QuestionService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.server.ResponseStatusException
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@@ -71,6 +73,7 @@ public class QuestionController {
);
}
/**
* Endpoint for deleting a question by ID.
*
@@ -88,18 +91,18 @@ public class QuestionController {
* @return A list of question DTOs for the quiz.
*/
@GetMapping
(
"/allQuestionsToAQuiz/{quizId}"
)
public
List
<
QuestionDTO
>
getAllQuestionsToAQuiz
(
@PathVariable
Integer
quizId
)
{
List
<
Question
>
questions
=
questionService
.
findAllQuestionsToAQuiz
(
quizId
);
return
questions
.
stream
()
.
map
(
question
->
new
QuestionDTO
(
question
.
getId
(),
question
.
getQuestionText
(),
question
.
getType
(),
question
.
getAnswer
(),
question
.
getOptionsList
(),
question
.
getScore
(),
question
.
getQuiz
().
getId
()
))
.
collect
(
Collectors
.
toList
());
}
public
List
<
QuestionDTO
>
getAllQuestionsToAQuiz
(
@PathVariable
Integer
quizId
)
{
List
<
Question
>
questions
=
questionService
.
findAllQuestionsToAQuiz
(
quizId
);
return
questions
.
stream
()
.
map
(
question
->
new
QuestionDTO
(
question
.
getId
(),
question
.
getQuestionText
(),
question
.
getType
(),
question
.
getAnswer
(),
question
.
getOptionsList
(),
question
.
getScore
(),
question
.
getQuiz
().
getId
()
))
.
collect
(
Collectors
.
toList
());
}
}
Loading