Table of Contents

Class OnboardingController

Namespace
Builvero.Api.Controllers
Assembly
Builvero.Api.dll

Provides API endpoints for the onboarding quiz, allowing users to start, submit, and retrieve quiz results.

[ApiController]
[Route("api/onboarding")]
[Authorize]
public class OnboardingController : ControllerBase
Inheritance
OnboardingController
Inherited Members

Remarks

All endpoints require authentication (JWT token). This controller handles:

  • Starting a new quiz attempt
  • Submitting quiz answers
  • Retrieving quiz results and scores

Users can have multiple quiz attempts, but only one active (unsubmitted) attempt at a time. Quiz results include the score, pass/fail status, and detailed answer information.

Constructors

OnboardingController(IOnboardingQuizService)

Initializes a new instance of the OnboardingController class.

public OnboardingController(IOnboardingQuizService quizService)

Parameters

quizService IOnboardingQuizService

Service for onboarding quiz operations.

Methods

GetQuizResult(Guid, CancellationToken)

Retrieves the result of a submitted quiz attempt.

[HttpGet("quiz/result")]
public Task<ActionResult<QuizResultDto>> GetQuizResult(Guid attemptId, CancellationToken cancellationToken = default)

Parameters

attemptId Guid

The unique identifier of the quiz attempt to retrieve results for.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<ActionResult<QuizResultDto>>

200 OK: Returns QuizResultDto with score, pass/fail status, and detailed answer information

404 Not Found: Quiz attempt not found

403 Forbidden: User attempts to retrieve a quiz result that doesn't belong to them

400 Bad Request: Error retrieving quiz result

Remarks

Requires authentication. Returns the result of a submitted quiz attempt, including the score, pass/fail status, and detailed answer information. Only the user who created the attempt can retrieve its result. Unsubmitted attempts cannot have results retrieved.

StartQuiz(CancellationToken)

Starts a new onboarding quiz attempt for the authenticated user.

[HttpPost("quiz/start")]
public Task<ActionResult<QuizStartResponse>> StartQuiz(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<ActionResult<QuizStartResponse>>

200 OK: Returns QuizStartResponse with attempt ID and question set

403 Forbidden: User already has an active (unsubmitted) quiz attempt

400 Bad Request: Error starting quiz

Remarks

Requires authentication. Creates a new quiz attempt and returns the question set. Users can only have one active (unsubmitted) attempt at a time. If a user already has an active attempt, they must submit or wait for it to expire before starting a new one.

SubmitQuiz(QuizSubmitRequest, CancellationToken)

Submits quiz answers for a quiz attempt.

[HttpPost("quiz/submit")]
public Task<ActionResult<QuizSubmitResponse>> SubmitQuiz(QuizSubmitRequest request, CancellationToken cancellationToken = default)

Parameters

request QuizSubmitRequest

The submit request containing the attempt ID and answers.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<ActionResult<QuizSubmitResponse>>

200 OK: Returns QuizSubmitResponse with score, pass/fail status, and result details

403 Forbidden: User attempts to submit a quiz attempt that doesn't belong to them

400 Bad Request: Invalid attempt ID, attempt already submitted, or other error

Remarks

Requires authentication. Submits answers for a quiz attempt and calculates the score. Only the user who created the attempt can submit it. Once submitted, the attempt cannot be modified. The response includes the score, pass/fail status, and detailed answer information.