Skip to content

Commit 533ef21

Browse files
committed
ref: changing question control wordings and some logic
1 parent 1dfe078 commit 533ef21

File tree

18 files changed

+463
-371
lines changed

18 files changed

+463
-371
lines changed

apps/api-gateway/src/auth/jwt/cookie-based/mock.jwt.cookie.auth.guard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class MockJwtCookieAuthGuard extends AuthGuard("cookie-strategy") {
2323

2424
request.user = {
2525
userId: "magdy.hafez@ibm.com",
26-
role: UserRole.AUTHOR,
26+
role: UserRole.LEARNER,
2727
groupId: "autogen-faculty-v1-course-v1-IND-AI0103EN-v1",
2828
assignmentId: 1,
2929
gradingCallbackRequired: false,

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -757,9 +757,11 @@ export class AttemptServiceV1 {
757757
showSubmissionFeedback: true,
758758
showQuestionScore: true,
759759
showQuestions: true,
760+
questionControls: true,
760761
currentVersion: {
761762
select: {
762763
correctAnswerVisibility: true,
764+
questionControls: true,
763765
},
764766
},
765767
},
@@ -2342,25 +2344,13 @@ export class AttemptServiceV1 {
23422344
learnerResponse: string;
23432345
} {
23442346
const choices = this.parseChoices(question.choices);
2345-
console.log(
2346-
`Handling single correct question response for question ID: ${question.id}`,
2347-
);
23482347
const learnerChoice =
23492348
createQuestionResponseAttemptRequestDto.learnerChoices[0];
2350-
console.log(
2351-
`Learner choice: ${learnerChoice}, Choices: ${JSON.stringify(choices)}`,
2352-
);
23532349
const normalizedLearnerChoice = this.normalizeText(learnerChoice);
23542350
const correctChoice = choices.find((choice) => choice.isCorrect);
2355-
console.log(
2356-
`Correct choice: ${correctChoice ? correctChoice.choice : "None"}`,
2357-
);
23582351
const selectedChoice = choices.find(
23592352
(choice) => this.normalizeText(choice.choice) === normalizedLearnerChoice,
23602353
);
2361-
console.log(
2362-
`Selected choice: ${selectedChoice ? selectedChoice.choice : "None"}`,
2363-
);
23642354

23652355
const data = {
23662356
learnerChoice,

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,19 @@ export class GetAssignmentAttemptResponseDto extends AssignmentAttemptResponseDt
113113
})
114114
@Optional()
115115
comments?: string;
116+
117+
@ApiPropertyOptional({
118+
description: "Question-level controls (copy, paste, right-click, print)",
119+
type: "object",
120+
required: false,
121+
})
122+
@Optional()
123+
questionControls?: {
124+
disableCopy?: boolean;
125+
disablePaste?: boolean;
126+
disableRightClick?: boolean;
127+
disablePrint?: boolean;
128+
};
116129
}
117130

118131
export class AssignmentAttemptQuestions {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ import {
1717
} from "class-validator";
1818

1919
export interface QuestionControls {
20-
allowCopy?: boolean;
21-
allowPaste?: boolean;
22-
allowRightClick?: boolean;
23-
preventPrint?: boolean;
20+
disableCopy?: boolean;
21+
disablePaste?: boolean;
22+
disableRightClick?: boolean;
23+
disablePrint?: boolean;
2424
[key: string]: boolean | undefined;
2525
}
2626

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,19 @@ export class UpdateAssignmentQuestionsDto {
578578
@IsOptional()
579579
correctAnswerVisibility: CorrectAnswerVisibility;
580580

581+
@ApiProperty({
582+
description: "Question-level controls (copy, paste, right-click, print)",
583+
required: false,
584+
type: "object",
585+
})
586+
@IsOptional()
587+
questionControls?: {
588+
disableCopy?: boolean;
589+
disablePaste?: boolean;
590+
disableRightClick?: boolean;
591+
disablePrint?: boolean;
592+
};
593+
581594
@ApiProperty({
582595
description: "updatedAt",
583596
required: false,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ export class AssignmentServiceV2 {
231231
timeEstimateMinutes: updateDto.timeEstimateMinutes,
232232
showQuestions: updateDto.showQuestions,
233233
numberOfQuestionsPerAttempt: updateDto.numberOfQuestionsPerAttempt,
234+
questionControls: updateDto.questionControls,
234235
});
235236

236237
await this.jobStatusService.updateJobStatus(jobId, {

apps/web/app/Helpers/checkDiff.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export function useChangesSummary(): string {
7474
strictTimeLimit,
7575
graded,
7676
numberOfQuestionsPerAttempt,
77+
questionControls,
7778
} = useAssignmentConfig();
7879

7980
const {
@@ -121,7 +122,8 @@ export function useChangesSummary(): string {
121122
!safeCompare(showAssignmentScore, originalAssignment.showAssignmentScore)
122123
)
123124
diffs.push("Changed assignment score visibility.");
124-
125+
if (!safeCompare(questionControls, originalAssignment.questionControls))
126+
diffs.push("Modified question controls.");
125127
if (
126128
!safeCompare(
127129
correctAnswerVisibility,

apps/web/app/author/(components)/StepTwo/AssignmentQuestionControls.tsx

Lines changed: 23 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -14,64 +14,47 @@ const AssignmentQuestionControls: FC<Props> = () => {
1414
);
1515

1616
const handleToggle = (
17-
key: "allowCopy" | "allowPaste" | "allowRightClick" | "preventPrint",
17+
key: "disableCopy" | "disablePaste" | "disableRightClick" | "disablePrint",
1818
) => {
1919
const newValue = !questionControls?.[key];
2020
const newControls = {
2121
...questionControls,
2222
[key]: newValue,
2323
};
24-
25-
if (process.env.NODE_ENV === "development") {
26-
console.log(`=== Toggle ${key} ===`);
27-
console.log(`Old value:`, questionControls?.[key]);
28-
console.log(`New value:`, newValue);
29-
console.log(`Full questionControls:`, newControls);
30-
}
31-
3224
setQuestionControls(newControls);
3325
};
3426

3527
return (
3628
<SectionWithTitle
37-
title="Question Controls"
38-
description="Configure what actions learners can perform while taking the assignment"
29+
title="Assignment Restrictions"
30+
description="Configure restrictions to prevent unauthorized behaviors during the assignment"
3931
className="flex flex-col gap-y-4"
4032
>
4133
<div className="flex flex-col gap-y-3">
4234
<ControlToggle
43-
label="Allow Copying"
44-
description="Let learners copy question text and their answers"
45-
checked={questionControls?.allowCopy ?? false}
46-
onChange={() => handleToggle("allowCopy")}
35+
label="Disable Copying"
36+
description="Prevent learners from copying question text or answers. Enable this to discourage sharing or plagiarism."
37+
checked={questionControls?.disableCopy ?? false}
38+
onChange={() => handleToggle("disableCopy")}
4739
/>
4840
<ControlToggle
49-
label="Allow Pasting"
50-
description="Let learners paste content into answer fields"
51-
checked={questionControls?.allowPaste ?? false}
52-
onChange={() => handleToggle("allowPaste")}
41+
label="Disable Pasting"
42+
description="Prevent learners from pasting content into answer fields. Enable this to ensure original work or test typing skills."
43+
checked={questionControls?.disablePaste ?? false}
44+
onChange={() => handleToggle("disablePaste")}
5345
/>
5446
<ControlToggle
55-
label="Allow Right Click"
56-
description="Let learners access the context menu with right click"
57-
checked={questionControls?.allowRightClick ?? false}
58-
onChange={() => handleToggle("allowRightClick")}
47+
label="Disable Right Click"
48+
description="Prevent learners from accessing the right-click context menu. Enable this to reduce copying or accessing browser features."
49+
checked={questionControls?.disableRightClick ?? false}
50+
onChange={() => handleToggle("disableRightClick")}
51+
/>
52+
<ControlToggle
53+
label="Disable Printing"
54+
description="Block print attempts (Ctrl/Cmd+P) during the assignment. Enable this to prevent downloading or distributing the assignment."
55+
checked={questionControls?.disablePrint ?? false}
56+
onChange={() => handleToggle("disablePrint")}
5957
/>
60-
</div>
61-
62-
<div className="mt-2 pt-4 border-t border-gray-200">
63-
<h3 className="text-sm font-semibold text-gray-900 mb-3">
64-
Security Controls
65-
</h3>
66-
<div className="flex flex-col gap-y-3">
67-
<ControlToggle
68-
label="Prevent Printing"
69-
description="Block print attempts (Ctrl/Cmd+P) during the assignment. Users can still screenshot, but they cannot download the assignment by printing it."
70-
checked={questionControls?.preventPrint ?? false}
71-
onChange={() => handleToggle("preventPrint")}
72-
variant="prevent"
73-
/>
74-
</div>
7558
</div>
7659
</SectionWithTitle>
7760
);
@@ -82,27 +65,16 @@ interface ControlToggleProps {
8265
description: string;
8366
checked: boolean;
8467
onChange: () => void;
85-
variant?: "allow" | "prevent";
8668
}
8769

8870
const ControlToggle: FC<ControlToggleProps> = ({
8971
label,
9072
description,
9173
checked,
9274
onChange,
93-
variant = "allow",
9475
}) => {
95-
const bgColor =
96-
variant === "prevent"
97-
? checked
98-
? "bg-orange-600"
99-
: "bg-gray-200"
100-
: checked
101-
? "bg-violet-600"
102-
: "bg-gray-200";
103-
104-
const ringColor =
105-
variant === "prevent" ? "focus:ring-orange-600" : "focus:ring-violet-600";
76+
const bgColor = checked ? "bg-orange-600" : "bg-gray-200";
77+
const ringColor = "focus:ring-orange-600";
10678

10779
return (
10880
<div className="flex items-start justify-between p-4 border border-gray-200 rounded-md hover:border-gray-300 transition-colors">

0 commit comments

Comments
 (0)