Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions backend/Api/Controllers/QuizController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,24 @@ public async Task<IActionResult> GenerateQuestions([FromRoute] string classId, [
return BadRequest(ModelState);
}

var tenantId = User.FindFirstValue("tenant");
var questions = await _quizService.GenerateQuestionsAsync(request, tenantId!);
var tenant = HttpContext.Items["Tenant"] as TokenTenantDTO;
var questions = await _quizService.GenerateQuestionsAsync(request, tenant!.Id);
return Ok(questions);
}

[HttpPost("{id}/submissions/{submissionId}/grade")]
[Authorize(Policy = "RequireEducator")]
public async Task<IActionResult> GradeSubmission([FromRoute] string classId, [FromRoute] string id, [FromRoute] string submissionId, [FromBody] GradeSubmissionDto request)
{
var tenant = HttpContext.Items["Tenant"] as TokenTenantDTO;
var userId = User.FindFirst(ClaimTypes.NameIdentifier)!.Value;

if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}

await _quizService.GradeSubmission(tenant!, classId, id, submissionId, request, userId);
return Ok();
}
}
8 changes: 8 additions & 0 deletions backend/Api/Middleware/ExceptionMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ private async Task HandleExceptionAsync(HttpContext context, Exception exception
code = HttpStatusCode.NotFound;
message = exception.Message;
break;
case QuizNotActiveException:
code = HttpStatusCode.BadRequest;
message = exception.Message;
break;
case QuizAlreadySubmittedException:
code = HttpStatusCode.Conflict;
message = exception.Message;
break;
case AIServiceUnavailableException:
code = HttpStatusCode.ServiceUnavailable;
message = exception.Message;
Expand Down
52 changes: 26 additions & 26 deletions backend/Api/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"LiveKit": {
"ApiKey": "my_key",
"ApiSecret": "135135135135135135135135135135135135135135780913750871389571908375908173059871390857190387590183750981375908713905871390571903759081375890",
"Url": "http://192.168.1.8:7880"
},
"DiscordWebhook": "https://discord.com/api/webhooks/1424138993427025922/KISsDXSVhRaOtjNvFN3FXwS_1WTOvFpuUA7LzUZxyYcG0-_mA_yPUNOXq4-96ih7Vqip",
"Firebase": {
"ServiceAccount": "{\n \"type\": \"service_account\",\n \"project_id\": \"twoaxis-yaspo\",\n \"private_key_id\": \"4c06954b742ed1b2adb1ea44949b5a00ef0b31b5\",\n \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDFI2vMaNmv0p/e\\n2FPq6ILZvMnSe5uFzawGtvikNbOXblQsBCrdjMBOlzaElP6d1jPDoXm+Sp5mRVhd\\nlF+uHZVaknkdtQnkdgom+ye6/e7wsgtSx12sfELmJetARmPDUpRPlh2+dmBjMPyX\\nN6vIwk1suwbhhXcEegqEOghzb1HeTLqwpje6QqqPhhmcOoi1OehBJDPWpevforaY\\nigH1OJfWSu1H5/SiSpJuu0lmkyzOvqt8XIKSj4caBQHAaA/mfVST0tHhXNTuL/0v\\nuXPrE/mVQVm9zJl9tsl2cOrfBstGDkGV21QvhVxODiFpELUXeOMyD4OOnesKU2lD\\nHFQDVH6TAgMBAAECggEAJGvi4qUMcttrBfTZrDDA3BFxCB4mIZZaDfOIBG6Xe4a6\\nrlcmxD/Y16xAOkZ8tBR7A821fF603Rg6ty9ObhCxI0akccScy0Szo3gLYxS/LGD4\\njpaey9s5UOP4jqtyiweatwl4/VNJg4ntYNK8Ph8HxurW3puV3ZHel4dRQGJ0sakP\\nraRUoeDH8VAyixFMXXjvIcUVmNsOMOsCGs4sJrhDlLwT6gn9agBcygPWD6K5v2zo\\nKxR0l/m6yAsjoDeqgQfYIju9cdrFArEbYEnXRjm5VG1Qjb6blS9LR+AfDQVx9xrz\\n+7vlEpaQHxsXx9qksDVbDCZ+NnNi1Vsa2rlMsUDOYQKBgQD/61j2tC6pz9zXJ0Eu\\nLRHQfjQwIThA7nPzLJ1sSSgBuACayC9qt/gy6KO0it2crOakT9DmdiPLocl4qp86\\nRAYg3TLN4h+DlbIzT1fJ4VVSZIDaK9mUgyu9ZMUIz5oSA4ldTCxP75OHJi/k65HX\\nyUGxuSVwyP/z5b2E+/vLlHwHnQKBgQDFM1R6p8ARnmvc/GCg1lvA7ukXy73cwXVm\\n3HvfOybzCsLokd0V4elcLNrxDZcWeNAAk+EegyB9RYiAz4UehWhgk8iznqdPievb\\nm23vuWFLd/2J6GZZDD4TnQ8b4isIUrzQL/nuNWF+xbJIRJyfVqEtjNc/k0NG4Piq\\n5jRAJ4T/7wKBgFxsLjDKWZ/SBbtd3dhDRo+5RDeth5dLhmxnzGJy+RPF09ISQa2U\\nyvn3skddbzNJ7fGhMZxJRhwgTZZaaC6uqlfsCpD3/NGUmkqVeOrbiei7ix0/gNB1\\nnrJDVjUcZFPlGxKqk8Y6i1jfnaRavszjTepVJwRYUrdOXOdN6V1YPoKxAoGAHnXG\\nR8ffkBkjWhgVqOJTe+KrWISdCBtN0hyeeaW+Z24zGw9k0ft6O0Wmb/OEcfEpV91/\\nuWHRw+fYpOTpEATVUY2iQ7Ru7YdFSj+g5JWC5NBc9k9Sd9C/SfJJoin2MavuBE5U\\n0amnLJjG6AjJFIeiD9IgcW6CxtD7OBKk4X/5ODsCgYBf8j8CQevEcQTt2tCMfk7t\\ncuVGrOAkiUbIshDBojJjaYAGd5YRpmVyi6eSuAUzIwmdpB6JFGkoue/xufgV17v/\\n3ks6Qovt6ObNrWLlKlHGV5m8btQNS4L5P4FQVGW5+r7VXc/dKK0S6xPiijUUn6x7\\nspneKUMPLyGMX11I4R9Rlw==\\n-----END PRIVATE KEY-----\\n\",\n \"client_email\": \"[email protected]\",\n \"client_id\": \"109655795699936403272\",\n \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n \"token_uri\": \"https://oauth2.googleapis.com/token\",\n \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-fbsvc%40twoaxis-yaspo.iam.gserviceaccount.com\",\n \"universe_domain\": \"googleapis.com\"\n}\n"
},
"AWS": {
"AccessKey": "AKIA4XYMC6GGWDYJLOHO",
"SecretKey": "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",
"Region": "eu-central-1",
"BucketName": "yaspo-staging-bucket"
},
"Gemini": {
"ApiKey": "API_KEY"
}
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"LiveKit": {
"ApiKey": "my_key",
"ApiSecret": "135135135135135135135135135135135135135135780913750871389571908375908173059871390857190387590183750981375908713905871390571903759081375890",
"Url": "http://192.168.1.8:7880"
},
"DiscordWebhook": "https://discord.com/api/webhooks/1424138993427025922/KISsDXSVhRaOtjNvFN3FXwS_1WTOvFpuUA7LzUZxyYcG0-_mA_yPUNOXq4-96ih7Vqip",
"Firebase": {
"ServiceAccount": "{\n \"type\": \"service_account\",\n \"project_id\": \"twoaxis-yaspo\",\n \"private_key_id\": \"4c06954b742ed1b2adb1ea44949b5a00ef0b31b5\",\n \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDFI2vMaNmv0p/e\\n2FPq6ILZvMnSe5uFzawGtvikNbOXblQsBCrdjMBOlzaElP6d1jPDoXm+Sp5mRVhd\\nlF+uHZVaknkdtQnkdgom+ye6/e7wsgtSx12sfELmJetARmPDUpRPlh2+dmBjMPyX\\nN6vIwk1suwbhhXcEegqEOghzb1HeTLqwpje6QqqPhhmcOoi1OehBJDPWpevforaY\\nigH1OJfWSu1H5/SiSpJuu0lmkyzOvqt8XIKSj4caBQHAaA/mfVST0tHhXNTuL/0v\\nuXPrE/mVQVm9zJl9tsl2cOrfBstGDkGV21QvhVxODiFpELUXeOMyD4OOnesKU2lD\\nHFQDVH6TAgMBAAECggEAJGvi4qUMcttrBfTZrDDA3BFxCB4mIZZaDfOIBG6Xe4a6\\nrlcmxD/Y16xAOkZ8tBR7A821fF603Rg6ty9ObhCxI0akccScy0Szo3gLYxS/LGD4\\njpaey9s5UOP4jqtyiweatwl4/VNJg4ntYNK8Ph8HxurW3puV3ZHel4dRQGJ0sakP\\nraRUoeDH8VAyixFMXXjvIcUVmNsOMOsCGs4sJrhDlLwT6gn9agBcygPWD6K5v2zo\\nKxR0l/m6yAsjoDeqgQfYIju9cdrFArEbYEnXRjm5VG1Qjb6blS9LR+AfDQVx9xrz\\n+7vlEpaQHxsXx9qksDVbDCZ+NnNi1Vsa2rlMsUDOYQKBgQD/61j2tC6pz9zXJ0Eu\\nLRHQfjQwIThA7nPzLJ1sSSgBuACayC9qt/gy6KO0it2crOakT9DmdiPLocl4qp86\\nRAYg3TLN4h+DlbIzT1fJ4VVSZIDaK9mUgyu9ZMUIz5oSA4ldTCxP75OHJi/k65HX\\nyUGxuSVwyP/z5b2E+/vLlHwHnQKBgQDFM1R6p8ARnmvc/GCg1lvA7ukXy73cwXVm\\n3HvfOybzCsLokd0V4elcLNrxDZcWeNAAk+EegyB9RYiAz4UehWhgk8iznqdPievb\\nm23vuWFLd/2J6GZZDD4TnQ8b4isIUrzQL/nuNWF+xbJIRJyfVqEtjNc/k0NG4Piq\\n5jRAJ4T/7wKBgFxsLjDKWZ/SBbtd3dhDRo+5RDeth5dLhmxnzGJy+RPF09ISQa2U\\nyvn3skddbzNJ7fGhMZxJRhwgTZZaaC6uqlfsCpD3/NGUmkqVeOrbiei7ix0/gNB1\\nnrJDVjUcZFPlGxKqk8Y6i1jfnaRavszjTepVJwRYUrdOXOdN6V1YPoKxAoGAHnXG\\nR8ffkBkjWhgVqOJTe+KrWISdCBtN0hyeeaW+Z24zGw9k0ft6O0Wmb/OEcfEpV91/\\nuWHRw+fYpOTpEATVUY2iQ7Ru7YdFSj+g5JWC5NBc9k9Sd9C/SfJJoin2MavuBE5U\\n0amnLJjG6AjJFIeiD9IgcW6CxtD7OBKk4X/5ODsCgYBf8j8CQevEcQTt2tCMfk7t\\ncuVGrOAkiUbIshDBojJjaYAGd5YRpmVyi6eSuAUzIwmdpB6JFGkoue/xufgV17v/\\n3ks6Qovt6ObNrWLlKlHGV5m8btQNS4L5P4FQVGW5+r7VXc/dKK0S6xPiijUUn6x7\\nspneKUMPLyGMX11I4R9Rlw==\\n-----END PRIVATE KEY-----\\n\",\n \"client_email\": \"[email protected]\",\n \"client_id\": \"109655795699936403272\",\n \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n \"token_uri\": \"https://oauth2.googleapis.com/token\",\n \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-fbsvc%40twoaxis-yaspo.iam.gserviceaccount.com\",\n \"universe_domain\": \"googleapis.com\"\n}\n"
},
"AWS": {
"AccessKey": "AKIA4XYMC6GGWDYJLOHO",
"SecretKey": "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",
"Region": "eu-central-1",
"BucketName": "yaspo-staging-bucket"
},
"Gemini": {
"ApiKey": "API_KEY"
}
}
16 changes: 10 additions & 6 deletions backend/Application.Tests/Services/QuizServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

public QuizServiceTests()
{
_quizService = new QuizService(_mockQuizRepository.Object, _mockClassRepository.Object, _mockUserRepository.Object, null, new Mock<IPlanEnforcementService>().Object);

Check warning on line 21 in backend/Application.Tests/Services/QuizServiceTests.cs

View workflow job for this annotation

GitHub Actions / test

Cannot convert null literal to non-nullable reference type.
}

[Fact]
Expand Down Expand Up @@ -172,7 +172,9 @@
It.IsAny<DateTime>(),
60,
classId,
It.IsAny<ICollection<Question>>()),
It.IsAny<ICollection<Question>>(),
It.IsAny<bool>(),
It.IsAny<bool>()),
Times.Once);
Assert.NotNull(uuid);
}
Expand Down Expand Up @@ -239,7 +241,9 @@
It.IsAny<DateTime>(),
It.IsAny<DateTime>(),
60,
It.IsAny<ICollection<Question>>()),
It.IsAny<ICollection<Question>>(),
It.IsAny<bool>(),
It.IsAny<bool>()),
Times.Once);
}

Expand Down Expand Up @@ -353,7 +357,7 @@
_mockQuizRepository.Setup(r => r.GetQuizById(quizId)).ReturnsAsync(quiz);
_mockQuizRepository.Setup(r => r.GetStudentSubmissions(studentId, classId)).ReturnsAsync([]);

await Assert.ThrowsAsync<InvalidOperationException>(() => _quizService.StartQuiz(new TokenTenantDTO { Id = tenantId, Type = TenantType.SINGLE_CLASS }, "single", studentId, quizId, studentId));
await Assert.ThrowsAsync<QuizNotActiveException>(() => _quizService.StartQuiz(new TokenTenantDTO { Id = tenantId, Type = TenantType.SINGLE_CLASS }, "single", studentId, quizId, studentId));
}

[Fact]
Expand Down Expand Up @@ -383,7 +387,7 @@
_mockQuizRepository.Setup(r => r.GetQuizById(quizId)).ReturnsAsync(quiz);
_mockQuizRepository.Setup(r => r.GetStudentSubmissions(studentId, classId)).ReturnsAsync([]);

await Assert.ThrowsAsync<InvalidOperationException>(() => _quizService.StartQuiz(new TokenTenantDTO { Id = tenantId, Type = TenantType.SINGLE_CLASS }, "single", studentId, quizId, studentId));
await Assert.ThrowsAsync<QuizNotActiveException>(() => _quizService.StartQuiz(new TokenTenantDTO { Id = tenantId, Type = TenantType.SINGLE_CLASS }, "single", studentId, quizId, studentId));
}

[Fact]
Expand Down Expand Up @@ -411,7 +415,7 @@
_mockQuizRepository.Setup(r => r.GetQuizById(quizId)).ReturnsAsync(quiz);
_mockQuizRepository.Setup(r => r.GetStudentSubmissions(studentId, classId)).ReturnsAsync(submissions);

var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => _quizService.StartQuiz(new TokenTenantDTO { Id = tenantId, Type = TenantType.SINGLE_CLASS }, "single", studentId, quizId, studentId));
var exception = await Assert.ThrowsAsync<QuizAlreadySubmittedException>(() => _quizService.StartQuiz(new TokenTenantDTO { Id = tenantId, Type = TenantType.SINGLE_CLASS }, "single", studentId, quizId, studentId));
// Expecting default message or empty because we removed the specific message in service
}

Expand Down Expand Up @@ -455,7 +459,7 @@
new QuizSubmissionAnswerDto { QuestionId = "q1", SelectedAnswerIndex = 0 }
], studentId);

_mockQuizRepository.Verify(r => r.AddQuizSubmission(It.IsAny<string>(), quizId, studentId, It.IsAny<DateTime>(), It.IsAny<int>(), It.IsAny<List<QuizSubmissionAnswer>>()), Times.Once);
_mockQuizRepository.Verify(r => r.AddQuizSubmission(It.IsAny<string>(), quizId, studentId, It.IsAny<DateTime>(), It.IsAny<int>(), It.IsAny<bool>(), It.IsAny<List<QuizSubmissionAnswer>>()), Times.Once);
_mockQuizRepository.Verify(r => r.DeleteQuizSession(session.Id), Times.Once);

Assert.Equal(10, result.Score);
Expand Down
11 changes: 8 additions & 3 deletions backend/Application/DTOs/Quiz/CreateQuestionDto.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Domain.Enums;

namespace Application.DTOs.Quiz;

Expand All @@ -23,8 +24,12 @@ public class CreateQuestionDto
[JsonPropertyName("points")]
public int Points { get; set; } = 1;

[Required]
[Length(2, 4)]
[JsonPropertyName("type")]
public QuestionType Type { get; set; } = QuestionType.MultipleChoice;

[JsonPropertyName("model_answer")]
public string? ModelAnswer { get; set; }

[JsonPropertyName("answers")]
public List<string> Answers { get; set; } = [];
}
8 changes: 8 additions & 0 deletions backend/Application/DTOs/Quiz/GradeSubmissionDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System.Collections.Generic;

namespace Application.DTOs.Quiz;

public class GradeSubmissionDto
{
public Dictionary<string, int> Grades { get; set; } = new();
}
10 changes: 8 additions & 2 deletions backend/Application/DTOs/Quiz/QuestionDto.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Domain.Enums;

namespace Application.DTOs.Quiz;

Expand All @@ -21,8 +22,13 @@ public class QuestionDto
[Required]
[JsonPropertyName("points")]
public int points { get; set; }

[JsonPropertyName("type")]
public QuestionType Type { get; set; } = QuestionType.MultipleChoice;

[JsonPropertyName("model_answer")]
public string? ModelAnswer { get; set; }
[Required]
[MinLength(2)]
[JsonPropertyName("answers")]
public List<AnswerDto> Answers { get; set; } = new();

Expand Down
8 changes: 7 additions & 1 deletion backend/Application/DTOs/Quiz/QuizDto.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
Expand Down Expand Up @@ -34,6 +34,12 @@ public class QuizDto
[JsonPropertyName("time_limit_in_minutes")]
public int TimeLimitInMinutes { get; set; } = 0;

[JsonPropertyName("auto_grade")]
public bool AutoGrade { get; set; }

[JsonPropertyName("show_marks_at_end")]
public bool ShowMarksAtEnd { get; set; }

[Required]
[MinLength(1)]
[JsonPropertyName("questions")]
Expand Down
6 changes: 6 additions & 0 deletions backend/Application/DTOs/Quiz/QuizRequestDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ public class QuizRequestDto
[Range(1, int.MaxValue)]
public int TimeLimitInMinutes { get; set; }

[JsonPropertyName("auto_grade")]
public bool AutoGrade { get; set; } = false;

[JsonPropertyName("show_marks_at_end")]
public bool ShowMarksAtEnd { get; set; } = true;

[Required]
[MinLength(1)]
[JsonPropertyName("questions")]
Expand Down
4 changes: 4 additions & 0 deletions backend/Application/DTOs/Quiz/QuizResponseDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ public class QuizResponseDto
public DateTime? StartsAt { get; set; }
[JsonPropertyName("ends_at")]
public DateTime? EndsAt { get; set; }
[JsonPropertyName("auto_grade")]
public bool AutoGrade { get; set; }
[JsonPropertyName("show_marks_at_end")]
public bool ShowMarksAtEnd { get; set; }
}
5 changes: 4 additions & 1 deletion backend/Application/DTOs/Quiz/QuizResultDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ namespace Application.DTOs.Quiz;
public class QuizResultDto
{
[JsonPropertyName("score")]
public int Score { get; set; }
public int? Score { get; set; }

[JsonPropertyName("total_points")]
public int TotalPoints { get; set; }

[JsonPropertyName("needsManualGrading")]
public bool NeedsManualGrading { get; set; }
}
5 changes: 4 additions & 1 deletion backend/Application/DTOs/Quiz/QuizSessionQuestionDto.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
Expand All @@ -20,4 +20,7 @@ public class QuizSessionQuestionDto
[JsonPropertyName("answers")]
public List<AnswerDto> Answers { get; set; } = [];

[JsonPropertyName("type")]
public Domain.Enums.QuestionType Type { get; set; } = Domain.Enums.QuestionType.MultipleChoice;

}
4 changes: 3 additions & 1 deletion backend/Application/DTOs/Quiz/QuizSubmissionAnswerDto.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
namespace Application.DTOs.Quiz;
namespace Application.DTOs.Quiz;

public class QuizSubmissionAnswerDto
{
public string QuestionId { get; set; } = string.Empty;
public int SelectedAnswerIndex { get; set; }
public string? WrittenAnswer { get; set; }
public int? PointsAwarded { get; set; }

}
1 change: 1 addition & 0 deletions backend/Application/DTOs/Quiz/QuizSubmissionListItemDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ public class QuizSubmissionListItemDto
public string StudentName { get; set; } = string.Empty;
public DateTime SubmittedAt { get; set; }
public int TotalScore { get; set; }
public bool NeedsManualGrading { get; set; }
}
9 changes: 7 additions & 2 deletions backend/Application/DTOs/Quiz/UpdateQuestionDto.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;

namespace Application.DTOs.Quiz;
Expand All @@ -13,7 +13,12 @@ public class UpdateQuestionDto
[Range(1, int.MaxValue)]
public int Points { get; set; } = 1;

[MinLength(2)]
[JsonPropertyName("type")]
public Domain.Enums.QuestionType Type { get; set; } = Domain.Enums.QuestionType.MultipleChoice;

[JsonPropertyName("model_answer")]
public string? ModelAnswer { get; set; }

[JsonPropertyName("answers")]
public List<string> Answers { get; set; } = [];
}
6 changes: 6 additions & 0 deletions backend/Application/DTOs/Quiz/UpdateQuizRequestDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public class UpdateQuizRequestDto
[Range(1, int.MaxValue)]
public int TimeLimitInMinutes { get; set; }

[JsonPropertyName("auto_grade")]
public bool AutoGrade { get; set; }

[JsonPropertyName("show_marks_at_end")]
public bool ShowMarksAtEnd { get; set; }

[MinLength(1)]
[JsonPropertyName("questions")]
public List<UpdateQuestionDto> Questions { get; set; } = new();
Expand Down
Loading
Loading