Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- AlterTable
ALTER TABLE "Question" ADD COLUMN "authorComment" TEXT;
ALTER TABLE "QuestionVersion" ADD COLUMN "authorComment" TEXT;

2 changes: 2 additions & 0 deletions apps/api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ model QuestionVersion {
id Int @id @default(autoincrement()) /// Unique identifier for the question version
assignmentVersionId Int /// The ID of the assignment version this belongs to
assignmentVersion AssignmentVersion @relation(fields: [assignmentVersionId], references: [id], onDelete: Cascade)
authorComment String? /// The comment an author can leave for context on a question
questionId Int? /// Reference to original question (null for new questions in version)
totalPoints Int /// Points for this question
type QuestionType /// Type of question
Expand Down Expand Up @@ -363,6 +364,7 @@ model Question {
totalPoints Int /// Total points that can be scored for the question
type QuestionType /// Type of question
responseType ResponseType? /// Type of response expected from the learner
authorComment String? /// The comment an author can leave for context on a question
question String /// The text of the question
variants QuestionVariant[] /// AI-generated variants for this question
maxWords Int? /// Optional maximum number of words allowed for a written response type question
Expand Down
2 changes: 2 additions & 0 deletions apps/api/src/api/assignment/attempt/attempt.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ export class AttemptServiceV1 {
id: originalQ.id,
variantId: variant ? variant.id : undefined,
question: questionText,
authorComment: originalQ.authorComment ?? null,
choices: finalChoices,
maxWords,
maxCharacters: maxChars,
Expand Down Expand Up @@ -1124,6 +1125,7 @@ export class AttemptServiceV1 {
id: originalQ.id,
question: primaryTranslation.translatedText || originalQ?.question,
choices: finalChoices,
authorComment: originalQ.authorComment ?? null,
translations: variant ? variantTranslations : questionTranslations,
maxWords: variant?.maxWords ?? originalQ?.maxWords,
maxCharacters: variant?.maxCharacters ?? originalQ?.maxCharacters,
Expand Down
19 changes: 19 additions & 0 deletions apps/api/src/api/assignment/dto/update.questions.request.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,16 @@ export class QuestionDto {
@IsBoolean()
isDeleted?: boolean;

@ApiPropertyOptional({
description: "Author comment or note on this question",
type: String,
nullable: true,
})
@IsOptional()
@IsString()
authorComment?: string | null;


@ApiProperty({
description: "Grading context question IDs (array of question IDs)",
type: [Number],
Expand Down Expand Up @@ -756,6 +766,15 @@ export class AttemptQuestionDto {
@Type(() => Choice)
choices?: Choice[];

@ApiPropertyOptional({
description: "Author comment or note on this question",
type: String,
nullable: true,
})
@IsOptional()
@IsString()
authorComment?: string | null;

@ApiPropertyOptional({
description: "Dictionary of translations keyed by language code",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ export class CreateUpdateQuestionRequestDto {
@IsEnum(QuestionType)
type: QuestionType;

@ApiPropertyOptional({
description: "Author comment or note on this question",
type: String,
nullable: true,
})
@IsOptional()
@IsString()
authorComment?: string | null;

@ApiProperty({
description: "The question content.",
type: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export class AssignmentRepository {
assignmentId: result.id,
isDeleted: false,
totalPoints: qv.totalPoints,
authorComment: qv.authorComment ?? legacy?.authorComment ?? null,
type: qv.type,
responseType: qv.responseType ?? null,
question: qv.question,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export class QuestionRepository {
totalPoints: questionData.totalPoints,
type: questionData.type,
question: questionData.question,
authorComment: questionData.authorComment ?? null,
responseType: questionData.responseType,
maxWords: questionData.maxWords,
maxCharacters: questionData.maxCharacters,
Expand All @@ -100,6 +101,7 @@ export class QuestionRepository {
totalPoints: questionData.totalPoints,
type: questionData.type,
question: questionData.question,
authorComment: questionData.authorComment ?? null,
responseType: questionData.responseType,
maxWords: questionData.maxWords,
maxCharacters: questionData.maxCharacters,
Expand Down Expand Up @@ -176,6 +178,7 @@ export class QuestionRepository {
type,
question,
assignmentId,
authorComment,
responseType,
maxWords,
maxCharacters,
Expand Down Expand Up @@ -223,6 +226,7 @@ export class QuestionRepository {
type,
question,
responseType,
authorComment: authorComment ?? null,
maxWords,
maxCharacters,
randomizedChoices,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ export class QuestionService {
type: questionDto.type,
answer: questionDto.answer ?? false,
totalPoints: questionDto.totalPoints ?? 0,
authorComment: questionDto.authorComment ?? null,
choices: questionDto.choices,
scoring: questionDto.scoring,
maxWords: questionDto.maxWords,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ export class VersionManagementService {
assignmentVersionId: assignmentVersion.id,
questionId: question.id,
totalPoints: question.totalPoints,
authorComment: question.authorComment ?? null,
type: question.type,
responseType: question.responseType,
question: question.question,
Expand Down Expand Up @@ -489,6 +490,7 @@ export class VersionManagementService {
id: qv.id,
questionId: qv.questionId,
totalPoints: qv.totalPoints,
authorComment: qv.authorComment,
type: qv.type,
responseType: qv.responseType,
question: qv.question,
Expand Down Expand Up @@ -652,6 +654,7 @@ export class VersionManagementService {
data: {
assignmentVersionId: restoredVersion.id,
questionId: questionVersion.questionId,
authorComment: questionVersion.authorComment ?? null,
totalPoints: questionVersion.totalPoints,
type: questionVersion.type,
responseType: questionVersion.responseType,
Expand Down Expand Up @@ -973,6 +976,7 @@ export class VersionManagementService {
data: {
assignmentVersionId: draftId,
questionId: questionData.id || null,
authorComment: questionData.authorComment ?? null,
totalPoints: questionData.totalPoints || 0,
type: questionData.type,
responseType: questionData.responseType,
Expand Down Expand Up @@ -1080,6 +1084,7 @@ export class VersionManagementService {
data: {
assignmentVersionId: versionId,
questionId: question.id,
authorComment: question.authorComment ?? null,
totalPoints: question.totalPoints,
type: question.type,
responseType: question.responseType,
Expand Down Expand Up @@ -1376,6 +1381,7 @@ export class VersionManagementService {
data: {
assignmentVersionId: assignmentVersion.id,
questionId: questionData.id || null,
authorComment: questionData.authorComment ?? null,
totalPoints: questionData.totalPoints || 0,
type: questionData.type,
responseType: questionData.responseType,
Expand Down Expand Up @@ -1497,6 +1503,7 @@ export class VersionManagementService {
questions: latestDraft.questionVersions.map((qv) => ({
id: qv.questionId,
totalPoints: qv.totalPoints,
authorComment: qv.authorComment,
type: qv.type,
responseType: qv.responseType,
question: qv.question,
Expand Down Expand Up @@ -2072,6 +2079,7 @@ export class VersionManagementService {
data: {
assignmentVersionId: assignmentVersion.id,
questionId: questionData.id || undefined,
authorComment: questionData.authorComment ?? null,
totalPoints: questionData.totalPoints || 0,
type: questionData.type,
responseType: questionData.responseType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ export const createMockQuestion = (
isDeleted: false,
videoPresentationConfig: null,
liveRecordingConfig: null,
authorComment: null,
};

switch (questionType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export class AttemptQuestionsMapper {
variantId: variant ? variant.id : undefined,
question: questionText,
choices: finalChoices,
authorComment: null,
maxWords,
maxCharacters: maxChars,
scoring: scoring as ScoringDto,
Expand All @@ -176,7 +177,7 @@ export class AttemptQuestionsMapper {
if (variantQ) {
return variantQ;
}
return { ...originalQ, variantId: undefined };
return { ...originalQ, variantId: undefined, authorComment: null };
});

const questionsWithResponses = this.constructQuestionsWithResponses(
Expand Down Expand Up @@ -303,6 +304,7 @@ export class AttemptQuestionsMapper {
question: primaryTranslation.translatedText,
choices: sanitizedChoices,
translations: sanitizedTranslations,
authorComment: null,
maxWords: variant?.maxWords ?? originalQ?.maxWords,
maxCharacters: variant?.maxCharacters ?? originalQ?.maxCharacters,
scoring:
Expand Down Expand Up @@ -348,6 +350,7 @@ export class AttemptQuestionsMapper {
translationForLanguage?.translatedText || originalQ.question,
choices: sanitizedChoices,
translations: sanitizedTranslations,
authorComment: null,
maxWords: originalQ.maxWords,
maxCharacters: originalQ.maxCharacters,
scoring: originalQ.scoring,
Expand Down
10 changes: 10 additions & 0 deletions apps/web/app/Helpers/checkDiff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,16 @@ export function useChangesSummary(): string {
diffs.push(`Updated max characters for question ${question.id}.`);
}

const normalizedAuthorComment = (question.authorComment ?? "").trim();
const normalizedOriginalAuthorComment = (
originalQuestion.authorComment ?? ""
).trim();
if (
!safeCompare(normalizedAuthorComment, normalizedOriginalAuthorComment)
) {
diffs.push(`Updated the author comment for question ${question.id}.`);
}

if (
!safeCompare(
question.videoPresentationConfig,
Expand Down
Loading
Loading