Skip to content

Commit 2fdeb9b

Browse files
committed
Merge branch 'morozov-av-issue-814'
2 parents f3c934e + ffaf919 commit 2fdeb9b

File tree

33 files changed

+1913
-134
lines changed

33 files changed

+1913
-134
lines changed

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: 24.4.2
4+
hooks:
5+
- id: black
6+
types: [python]
7+
files: ^(bases|components)/
8+
9+
- repo: https://github.com/astral-sh/ruff-pre-commit
10+
rev: v0.4.4
11+
hooks:
12+
- id: ruff
13+
types: [python]
14+
files: ^(bases|components)/

bases/rsptx/admin_server_api/routers/instructor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,7 @@ async def _copy_one_assignment(
10811081
course=target_course.id,
10821082
name=old_assignment.name,
10831083
duedate=due_date,
1084+
updated_date=datetime.datetime.now(),
10841085
description=old_assignment.description,
10851086
points=old_assignment.points,
10861087
threshold_pct=old_assignment.threshold_pct,

bases/rsptx/admin_server_api/routers/lti1p3.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
fetch_instructor_courses,
7878
validate_user_credentials,
7979
)
80+
from rsptx.db.crud.assignment import is_assignment_visible_to_students
8081

8182
from rsptx.configuration import settings
8283
from rsptx.logging import rslogger
@@ -445,7 +446,10 @@ async def launch(request: Request):
445446
status_code=400, detail=f"Assignment {lineitem_assign_id} not found"
446447
)
447448

448-
if not rs_assign.visible and not message_launch.check_teacher_access():
449+
if (
450+
not is_assignment_visible_to_students(rs_assign)
451+
and not message_launch.check_teacher_access()
452+
):
449453
raise HTTPException(
450454
status_code=400,
451455
detail=f"Assignment {rs_assign.name} is not open for students",

bases/rsptx/assignment_server_api/assignment_builder/package-lock.json

Lines changed: 94 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bases/rsptx/assignment_server_api/assignment_builder/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"prismjs": "^1.30.0",
5555
"quill": "^2.0.3",
5656
"react": "^18.2.0",
57+
"react-datepicker": "^7.6.0",
5758
"react-dom": "^18.2.0",
5859
"react-hook-form": "^7.53.2",
5960
"react-hot-toast": "^2.4.1",

bases/rsptx/assignment_server_api/assignment_builder/src/components/routes/AssignmentBuilder/AssignmentBuilder.module.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,6 @@
329329
.formField textarea,
330330
.formField :global(.p-inputtext),
331331
.formField :global(.p-inputtextarea),
332-
.formField :global(.p-calendar),
333332
.formField :global(.p-inputnumber),
334333
.formField :global(.p-selectbutton) {
335334
width: 100%;

bases/rsptx/assignment_server_api/assignment_builder/src/components/routes/AssignmentBuilder/AssignmentBuilder.tsx

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export const AssignmentBuilder = () => {
9696
// Event handlers
9797
const handleCreateNew = () => {
9898
navigateToCreate("basic");
99-
reset(defaultAssignment);
99+
reset(defaultAssignment as unknown as Assignment);
100100
};
101101

102102
const handleEdit = (assignment: Assignment) => {
@@ -108,18 +108,6 @@ export const AssignmentBuilder = () => {
108108
await duplicateAssignment(assignment.id);
109109
};
110110

111-
const handleVisibilityChange = async (assignment: Assignment, visible: boolean) => {
112-
try {
113-
await updateAssignment({
114-
...assignment,
115-
visible
116-
});
117-
toast.success(`Assignment ${visible ? "visible" : "hidden"} for students`);
118-
} catch (error) {
119-
toast.error("Failed to update assignment visibility");
120-
}
121-
};
122-
123111
const handleReleasedChange = async (assignment: Assignment, released: boolean) => {
124112
try {
125113
await updateAssignment({
@@ -144,6 +132,21 @@ export const AssignmentBuilder = () => {
144132
}
145133
};
146134

135+
const handleVisibilityChange = async (
136+
assignment: Assignment,
137+
data: { visible: boolean; visible_on: string | null; hidden_on: string | null }
138+
) => {
139+
try {
140+
await updateAssignment({
141+
...assignment,
142+
...data
143+
});
144+
toast.success("Visibility updated");
145+
} catch (error) {
146+
toast.error("Failed to update visibility");
147+
}
148+
};
149+
147150
const handleWizardComplete = async () => {
148151
const formValues = getValues();
149152
const payload: CreateAssignmentPayload = {
@@ -156,7 +159,9 @@ export const AssignmentBuilder = () => {
156159
nofeedback: formValues.nofeedback,
157160
nopause: formValues.nopause,
158161
peer_async_visible: formValues.peer_async_visible,
159-
visible: false,
162+
visible: formValues.visible,
163+
visible_on: formValues.visible_on || null,
164+
hidden_on: formValues.hidden_on || null,
160165
released: true,
161166
enforce_due: formValues.enforce_due || false
162167
};
@@ -192,9 +197,9 @@ export const AssignmentBuilder = () => {
192197
onCreateNew={handleCreateNew}
193198
onEdit={handleEdit}
194199
onDuplicate={handleDuplicate}
195-
onVisibilityChange={handleVisibilityChange}
196200
onReleasedChange={handleReleasedChange}
197201
onEnforceDueChange={handleEnforceDueChange}
202+
onVisibilityChange={handleVisibilityChange}
198203
onRemove={onRemove}
199204
/>
200205
)}
@@ -205,13 +210,21 @@ export const AssignmentBuilder = () => {
205210
nameError={nameError}
206211
canProceed={canProceed}
207212
onBack={() => {
208-
if (wizardStep === "type") {
213+
if (wizardStep === "visibility") {
214+
updateWizardStep("type");
215+
} else if (wizardStep === "type") {
209216
updateWizardStep("basic");
210217
} else {
211218
navigateToList();
212219
}
213220
}}
214-
onNext={() => updateWizardStep("type")}
221+
onNext={() => {
222+
if (wizardStep === "basic") {
223+
updateWizardStep("type");
224+
} else if (wizardStep === "type") {
225+
updateWizardStep("visibility");
226+
}
227+
}}
215228
onComplete={handleWizardComplete}
216229
onNameChange={handleNameChange}
217230
onTypeSelect={(type) => handleTypeSelect(type, setValue)}

bases/rsptx/assignment_server_api/assignment_builder/src/components/routes/AssignmentBuilder/components/AssignmentBuilderCreate.tsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
useCreateAssignmentMutation,
33
useGetAssignmentsQuery
44
} from "@store/assignment/assignment.logic.api";
5-
import { useParams } from "react-router-dom";
5+
import { useParams, useNavigate } from "react-router-dom";
66

77
import { CreateAssignmentPayload } from "@/types/assignment";
88

@@ -16,6 +16,7 @@ import { AssignmentWizard } from "./wizard/AssignmentWizard";
1616

1717
export const AssignmentBuilderCreate = () => {
1818
const { step } = useParams<{ step?: string }>();
19+
const navigate = useNavigate();
1920
const { isLoading, isError, data: assignments = [] } = useGetAssignmentsQuery();
2021
const [createAssignment] = useCreateAssignmentMutation();
2122

@@ -32,18 +33,24 @@ export const AssignmentBuilderCreate = () => {
3233
watch
3334
});
3435

35-
const wizardStep = step === "type" ? "type" : "basic";
36-
36+
const wizardStep = step === "type" ? "type" : step === "visibility" ? "visibility" : "basic";
37+
console.log(step, wizardStep);
3738
const handleBack = () => {
38-
if (wizardStep === "type") {
39-
window.location.href = "/builder/create";
40-
} else {
41-
window.location.href = "/builder";
39+
if (wizardStep === "basic") {
40+
navigate("/builder");
41+
} else if (wizardStep === "type") {
42+
navigate("/builder/create");
43+
} else if (wizardStep === "visibility") {
44+
navigate("/builder/create/type");
4245
}
4346
};
4447

4548
const handleNext = () => {
46-
window.location.href = "/builder/create/type";
49+
if (wizardStep === "basic") {
50+
navigate("/builder/create/type");
51+
} else if (wizardStep === "type") {
52+
navigate("/builder/create/visibility");
53+
}
4754
};
4855

4956
const handleWizardComplete = () => {
@@ -58,13 +65,15 @@ export const AssignmentBuilderCreate = () => {
5865
nofeedback: formValues.nofeedback,
5966
nopause: formValues.nopause,
6067
peer_async_visible: formValues.peer_async_visible,
61-
visible: false,
68+
visible: formValues.visible,
69+
visible_on: formValues.visible_on || null,
70+
hidden_on: formValues.hidden_on || null,
6271
released: true,
6372
enforce_due: formValues.enforce_due || false
6473
};
6574

6675
createAssignment(payload);
67-
window.location.href = "/builder";
76+
navigate("/builder");
6877
};
6978

7079
if (isLoading) {

0 commit comments

Comments
 (0)