Skip to content

Commit 3f23f19

Browse files
feat: author view only comment box for questions (#186)
* feat: persisting author comment box * fix(api): update common-mocks.ts to follow the new assignment structure by adding authorComent * feat: author comment box now has button * feat: detect changes to author comment field in assignment summary * troubleshooting git commit * Chore: Changing hover text on author comment box * feat/author comment box is now visible on author's learner preview side --------- Co-authored-by: MmagdyhafezZ <magdy.hafez9123@gmail.com>
1 parent d8c384c commit 3f23f19

File tree

22 files changed

+287
-75
lines changed

22 files changed

+287
-75
lines changed

.secrets.baseline

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"exclude": {
3-
"files": null,
3+
"files": "^.secrets.baseline$",
44
"lines": null
55
},
66
"generated_at": "2025-11-15T04:48:47Z",
@@ -602,7 +602,7 @@
602602
}
603603
]
604604
},
605-
"version": "0.13.1+ibm.64.dss",
605+
"version": "0.13.1+ibm.62.dss",
606606
"word_list": {
607607
"file": null,
608608
"hash": null
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- AlterTable
2+
ALTER TABLE "Question" ADD COLUMN "authorComment" TEXT;
3+
ALTER TABLE "QuestionVersion" ADD COLUMN "authorComment" TEXT;
4+

apps/api/prisma/schema.prisma

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ model QuestionVersion {
312312
id Int @id @default(autoincrement()) /// Unique identifier for the question version
313313
assignmentVersionId Int /// The ID of the assignment version this belongs to
314314
assignmentVersion AssignmentVersion @relation(fields: [assignmentVersionId], references: [id], onDelete: Cascade)
315+
authorComment String? /// The comment an author can leave for context on a question
315316
questionId Int? /// Reference to original question (null for new questions in version)
316317
totalPoints Int /// Points for this question
317318
type QuestionType /// Type of question
@@ -365,6 +366,7 @@ model Question {
365366
totalPoints Int /// Total points that can be scored for the question
366367
type QuestionType /// Type of question
367368
responseType ResponseType? /// Type of response expected from the learner
369+
authorComment String? /// The comment an author can leave for context on a question
368370
question String /// The text of the question
369371
variants QuestionVariant[] /// AI-generated variants for this question
370372
maxWords Int? /// Optional maximum number of words allowed for a written response type question

apps/api/src/api/assignment/attempt/attempt.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,7 @@ export class AttemptServiceV1 {
795795
id: originalQ.id,
796796
variantId: variant ? variant.id : undefined,
797797
question: questionText,
798+
authorComment: originalQ.authorComment ?? null,
798799
choices: finalChoices,
799800
maxWords,
800801
maxCharacters: maxChars,
@@ -1126,6 +1127,7 @@ export class AttemptServiceV1 {
11261127
id: originalQ.id,
11271128
question: primaryTranslation.translatedText || originalQ?.question,
11281129
choices: finalChoices,
1130+
authorComment: originalQ.authorComment ?? null,
11291131
translations: variant ? variantTranslations : questionTranslations,
11301132
maxWords: variant?.maxWords ?? originalQ?.maxWords,
11311133
maxCharacters: variant?.maxCharacters ?? originalQ?.maxCharacters,

apps/api/src/api/assignment/attempt/dto/assignment-attempt/get.assignment.attempt.response.dto.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import { Type } from "class-transformer";
1010
import { AttemptQuestionDto } from "src/api/assignment/dto/update.questions.request.dto";
1111
import { Choice } from "../../../question/dto/create.update.question.request.dto";
12+
import { IsOptional, IsString } from "class-validator";
1213

1314
export class AssignmentAttemptResponseDto {
1415
@ApiProperty({
@@ -143,6 +144,15 @@ export class AssignmentAttemptQuestions {
143144
})
144145
totalPoints: number;
145146

147+
@ApiPropertyOptional({
148+
description: "Author comment or note on this question",
149+
type: String,
150+
nullable: true,
151+
})
152+
@IsOptional()
153+
@IsString()
154+
authorComment?: string | null;
155+
146156
@ApiProperty({
147157
description: "Type of the question.",
148158
enum: QuestionType,

apps/api/src/api/assignment/dto/update.questions.request.dto.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,16 @@ export class QuestionDto {
204204
@IsBoolean()
205205
isDeleted?: boolean;
206206

207+
@ApiPropertyOptional({
208+
description: "Author comment or note on this question",
209+
type: String,
210+
nullable: true,
211+
})
212+
@IsOptional()
213+
@IsString()
214+
authorComment?: string | null;
215+
216+
207217
@ApiProperty({
208218
description: "Grading context question IDs (array of question IDs)",
209219
type: [Number],
@@ -769,6 +779,15 @@ export class AttemptQuestionDto {
769779
@Type(() => Choice)
770780
choices?: Choice[];
771781

782+
@ApiPropertyOptional({
783+
description: "Author comment or note on this question",
784+
type: String,
785+
nullable: true,
786+
})
787+
@IsOptional()
788+
@IsString()
789+
authorComment?: string | null;
790+
772791
@ApiPropertyOptional({
773792
description: "Dictionary of translations keyed by language code",
774793

apps/api/src/api/assignment/question/dto/create.update.question.request.dto.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ export class CreateUpdateQuestionRequestDto {
7979
@IsEnum(QuestionType)
8080
type: QuestionType;
8181

82+
@ApiPropertyOptional({
83+
description: "Author comment or note on this question",
84+
type: String,
85+
nullable: true,
86+
})
87+
@IsOptional()
88+
@IsString()
89+
authorComment?: string | null;
90+
8291
@ApiProperty({
8392
description: "The question content.",
8493
type: String,

apps/api/src/api/assignment/v2/repositories/assignment.repository.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ export class AssignmentRepository {
141141
assignmentId: result.id,
142142
isDeleted: false,
143143
totalPoints: qv.totalPoints,
144+
authorComment: qv.authorComment ?? legacy?.authorComment ?? null,
144145
type: qv.type,
145146
responseType: qv.responseType ?? null,
146147
question: qv.question,

apps/api/src/api/assignment/v2/repositories/question.repository.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export class QuestionRepository {
8181
totalPoints: questionData.totalPoints,
8282
type: questionData.type,
8383
question: questionData.question,
84+
authorComment: questionData.authorComment ?? null,
8485
responseType: questionData.responseType,
8586
maxWords: questionData.maxWords,
8687
maxCharacters: questionData.maxCharacters,
@@ -100,6 +101,7 @@ export class QuestionRepository {
100101
totalPoints: questionData.totalPoints,
101102
type: questionData.type,
102103
question: questionData.question,
104+
authorComment: questionData.authorComment ?? null,
103105
responseType: questionData.responseType,
104106
maxWords: questionData.maxWords,
105107
maxCharacters: questionData.maxCharacters,
@@ -176,6 +178,7 @@ export class QuestionRepository {
176178
type,
177179
question,
178180
assignmentId,
181+
authorComment,
179182
responseType,
180183
maxWords,
181184
maxCharacters,
@@ -223,6 +226,7 @@ export class QuestionRepository {
223226
type,
224227
question,
225228
responseType,
229+
authorComment: authorComment ?? null,
226230
maxWords,
227231
maxCharacters,
228232
randomizedChoices,

apps/api/src/api/assignment/v2/services/question.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ export class QuestionService {
204204
type: questionDto.type,
205205
answer: questionDto.answer ?? false,
206206
totalPoints: questionDto.totalPoints ?? 0,
207+
authorComment: questionDto.authorComment ?? null,
207208
choices: questionDto.choices,
208209
scoring: questionDto.scoring,
209210
maxWords: questionDto.maxWords,

0 commit comments

Comments
 (0)