Skip to content

Fix issue #810 - When creating new exercises in the new assignment builder - need to make it public or private #850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 30, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const CreateView = ({
topic: data.topic,
points: data.points,
is_reading: false,
is_private: data.is_private ?? false,
assignment_id: assignmentId!
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useGetSectionsForChapterQuery } from "@store/dataset/dataset.logic.api"
import { Chips } from "primereact/chips";
import { Dropdown } from "primereact/dropdown";
import { InputNumber, InputNumberChangeEvent } from "primereact/inputnumber";
import { InputSwitch } from "primereact/inputswitch";
import { InputText } from "primereact/inputtext";
import { ReactNode, useCallback, useEffect, useState } from "react";

Expand All @@ -19,6 +20,7 @@ export interface BaseExerciseSettings {
tags: string;
points: number;
difficulty: number;
is_private: boolean;
}

export interface BaseExerciseSettingsContentProps<T extends BaseExerciseSettings> {
Expand All @@ -44,7 +46,8 @@ export const BaseExerciseSettingsContent = <T extends BaseExerciseSettings>({
subchapter: initialData?.subchapter ?? "",
tags: initialData?.tags ?? "",
points: initialData?.points ?? 1,
difficulty: initialData?.difficulty ?? 3
difficulty: initialData?.difficulty ?? 3,
is_private: initialData?.is_private ?? false
} as T);

// Handler to update a specific setting field
Expand Down Expand Up @@ -237,6 +240,21 @@ export const BaseExerciseSettingsContent = <T extends BaseExerciseSettings>({
</div>
</div>

<div className={styles.settingsGridFull}>
<div className={styles.formField}>
<div className="flex align-items-center gap-2">
<InputSwitch
id="is_private"
checked={settings.is_private}
onChange={(e) => updateSetting("is_private", e.value)}
/>
<label htmlFor="is_private" className="font-medium">
Private Exercise
</label>
</div>
</div>
</div>

{/* Render additional fields if provided */}
{additionalFields && <div className={styles.settingsGridFull}>{additionalFields}</div>}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export type Exercise = {
difficulty: number;
author: string;
description: string;
is_private: boolean;
from_source: boolean;
};

Expand Down Expand Up @@ -112,6 +113,7 @@ export type CreateExercisesPayload = {
topic: string;
points: number;
is_reading: boolean;
is_private: boolean;
assignment_id: number;
};

Expand Down
2 changes: 1 addition & 1 deletion bases/rsptx/assignment_server_api/routers/instructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ async def get_assignment_questions(
aq["topic"] = q["topic"]
aq["author"] = q["author"]
aq["difficulty"] = q["difficulty"]
aq["is_private"] = q["is_private"]
qlist.append(aq)

rslogger.debug(f"qlist: {qlist}")
Expand Down Expand Up @@ -1276,7 +1277,6 @@ async def question_creation(
**question_data,
base_course=course.base_course,
timestamp=canonical_utcnow(),
is_private=False,
practice=False,
from_source=False,
review_flag=False,
Expand Down
1 change: 1 addition & 0 deletions components/rsptx/validation/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ class CreateExercisesPayload(BaseModel):
difficulty: Optional[float] = None
topic: Optional[str] = None
points: Optional[int] = None
is_private: Optional[bool] = None

is_reading: bool
assignment_id: int