Skip to content

Commit b907ca2

Browse files
committed
issue-277 Add support for CodeLens enabling/disabling in ActiveCode components
1 parent 0a84e5b commit b907ca2

6 files changed

Lines changed: 69 additions & 22 deletions

File tree

bases/rsptx/assignment_server_api/assignment_builder/src/components/routes/AssignmentBuilder/components/exercises/components/CreateExercise/components/ActiveCodeExercise/ActiveCodeExercise.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ const getDefaultFormData = (): Partial<CreateExerciseFormType> => ({
6060
// CodeTailor support
6161
enableCodeTailor: false,
6262
parsonspersonalize: "",
63-
parsonsexample: ""
63+
parsonsexample: "",
64+
enableCodelens: true
6465
});
6566

6667
export const ActiveCodeExercise: FC<ExerciseComponentProps> = ({
@@ -98,7 +99,8 @@ export const ActiveCodeExercise: FC<ExerciseComponentProps> = ({
9899
{
99100
enableCodeTailor: data.enableCodeTailor,
100101
parsonspersonalize: data.parsonspersonalize,
101-
parsonsexample: data.parsonsexample
102+
parsonsexample: data.parsonsexample,
103+
enableCodelens: data.enableCodelens
102104
}
103105
);
104106
},
@@ -232,6 +234,10 @@ export const ActiveCodeExercise: FC<ExerciseComponentProps> = ({
232234
name={formData.name || ""}
233235
stdin={formData.stdin || ""}
234236
selectedExistingDataFiles={formData.selectedExistingDataFiles || []}
237+
enableCodeTailor={formData.enableCodeTailor}
238+
parsonspersonalize={formData.parsonspersonalize}
239+
parsonsexample={formData.parsonsexample}
240+
enableCodelens={formData.enableCodelens}
235241
/>
236242
);
237243

bases/rsptx/assignment_server_api/assignment_builder/src/components/routes/AssignmentBuilder/components/exercises/components/CreateExercise/components/ActiveCodeExercise/ActiveCodeExerciseSettings.tsx

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,40 @@ export const ActiveCodeExerciseSettings: FC<ActiveCodeExerciseSettingsProps> = (
4747
const codeTailorFields = (
4848
<div className={styles.codeTailorSection}>
4949
<div className={styles.formField}>
50-
<div className="flex align-items-center gap-2">
51-
<InputSwitch
52-
id="enableCodeTailor"
53-
checked={formData.enableCodeTailor ?? false}
54-
onChange={(e) => handleCodeTailorToggle(e.value)}
55-
/>
56-
<label htmlFor="enableCodeTailor" className="font-medium">
57-
Personalized Parsons Support (CodeTailor)
58-
</label>
59-
<i
60-
className="pi pi-info-circle codetailor-info-icon"
61-
data-pr-tooltip="CodeTailor provides personalized Parsons puzzles as adaptive support for students struggling with coding exercises."
62-
data-pr-position="right"
63-
/>
64-
<Tooltip target=".codetailor-info-icon" />
50+
<div className="flex align-items-center gap-4">
51+
<div className="flex align-items-center gap-2">
52+
<InputSwitch
53+
id="enableCodeTailor"
54+
checked={formData.enableCodeTailor ?? false}
55+
onChange={(e) => handleCodeTailorToggle(e.value)}
56+
/>
57+
<label htmlFor="enableCodeTailor" className="font-medium">
58+
Personalized Parsons Support (CodeTailor)
59+
</label>
60+
<i
61+
className="pi pi-info-circle codetailor-info-icon"
62+
data-pr-tooltip="CodeTailor provides personalized Parsons puzzles as adaptive support for students struggling with coding exercises."
63+
data-pr-position="right"
64+
/>
65+
<Tooltip target=".codetailor-info-icon" />
66+
</div>
67+
68+
<div className="flex align-items-center gap-2">
69+
<InputSwitch
70+
id="enableCodelens"
71+
checked={formData.enableCodelens ?? true}
72+
onChange={(e) => onChange({ enableCodelens: e.value })}
73+
/>
74+
<label htmlFor="enableCodelens" className="font-medium">
75+
Show CodeLens Button
76+
</label>
77+
<i
78+
className="pi pi-info-circle codelens-info-icon"
79+
data-pr-tooltip="CodeLens button provides step-by-step visualization of code execution."
80+
data-pr-position="right"
81+
/>
82+
<Tooltip target=".codelens-info-icon" />
83+
</div>
6584
</div>
6685
</div>
6786

bases/rsptx/assignment_server_api/assignment_builder/src/components/routes/AssignmentBuilder/components/exercises/components/CreateExercise/components/ActiveCodeExercise/ActiveCodePreview.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ interface ActiveCodePreviewProps {
1414
name: string;
1515
stdin?: string;
1616
selectedExistingDataFiles?: SelectedDataFile[];
17+
enableCodeTailor?: boolean;
18+
parsonspersonalize?: "solution-level" | "block-and-solution" | "";
19+
parsonsexample?: string;
20+
enableCodelens?: boolean;
1721
}
1822

1923
export const ActiveCodePreview: FC<ActiveCodePreviewProps> = ({
@@ -24,7 +28,11 @@ export const ActiveCodePreview: FC<ActiveCodePreviewProps> = ({
2428
suffix_code,
2529
name,
2630
stdin,
27-
selectedExistingDataFiles = []
31+
selectedExistingDataFiles = [],
32+
enableCodeTailor,
33+
parsonspersonalize,
34+
parsonsexample,
35+
enableCodelens
2836
}) => {
2937
// Fetch datafiles list to get filenames for selected acids
3038
const { data: allDatafiles = [] } = useFetchDatafilesQuery();
@@ -51,7 +59,13 @@ export const ActiveCodePreview: FC<ActiveCodePreviewProps> = ({
5159
suffix_code,
5260
name,
5361
stdin,
54-
selectedDatafilesInfo
62+
selectedDatafilesInfo,
63+
{
64+
enableCodeTailor,
65+
parsonspersonalize,
66+
parsonsexample,
67+
enableCodelens
68+
}
5569
)}
5670
/>
5771
</div>

bases/rsptx/assignment_server_api/assignment_builder/src/types/exercises.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export type QuestionJSON = Partial<{
109109
enableCodeTailor: boolean;
110110
parsonspersonalize: "solution-level" | "block-and-solution" | "";
111111
parsonsexample: string;
112+
enableCodelens: boolean;
112113
iframeSrc: string;
113114
}>;
114115

bases/rsptx/assignment_server_api/assignment_builder/src/utils/preview/activeCode.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface CodeTailorOptions {
99
enableCodeTailor?: boolean;
1010
parsonspersonalize?: "solution-level" | "block-and-solution" | "";
1111
parsonsexample?: string;
12+
enableCodelens?: boolean;
1213
}
1314

1415
export const generateActiveCodePreview = (
@@ -40,6 +41,10 @@ export const generateActiveCodePreview = (
4041
codeTailorAttrs += ` data-parsonsexample="${parsonsExampleValue}"`;
4142
}
4243

44+
// Codelens attribute - defaults to true
45+
const codelensEnabled = codeTailorOptions?.enableCodelens !== false;
46+
const codelensAttr = `data-codelens="${codelensEnabled}"`;
47+
4348
return `
4449
<div class="runestone explainer ac_section ">
4550
<div data-component="activecode" id="${safeId}" data-question_label="${name}">
@@ -49,7 +54,7 @@ export const generateActiveCodePreview = (
4954
</div>
5055
<textarea
5156
data-lang="${language}" id="${safeId}_editor"
52-
data-timelimit=25000 data-codelens="true"
57+
data-timelimit=25000 ${codelensAttr}
5358
data-audio=''
5459
data-wasm=/_static
5560
${stdinAttr}${datafileAttr}${codeTailorAttrs}

bases/rsptx/assignment_server_api/assignment_builder/src/utils/questionJson.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export const buildQuestionJson = (data: CreateExerciseFormType) => {
1515
// CodeTailor support
1616
enableCodeTailor: data.enableCodeTailor,
1717
parsonspersonalize: data.parsonspersonalize,
18-
parsonsexample: data.parsonsexample
18+
parsonsexample: data.parsonsexample,
19+
enableCodelens: data.enableCodelens
1920
}),
2021
...(data.question_type === "shortanswer" && {
2122
attachment: data.attachment,
@@ -94,7 +95,8 @@ export const getDefaultQuestionJson = (languageOptions: TableDropdownOption[]) =
9495
// CodeTailor support
9596
enableCodeTailor: false,
9697
parsonspersonalize: "",
97-
parsonsexample: ""
98+
parsonsexample: "",
99+
enableCodelens: true
98100
});
99101

100102
export const mergeQuestionJsonWithDefaults = (

0 commit comments

Comments
 (0)