Skip to content

Commit a739d75

Browse files
committed
Merge branch 'main' of github.com:RunestoneInteractive/rs
2 parents f850f53 + c811d1d commit a739d75

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const AssignmentReadingsTable = ({
4848
const getNumQuestionsOrDefault = (numQuestions: Nullable<number>): number => {
4949
const defaultNumQuestions = 1;
5050

51-
return numQuestions ?? defaultNumQuestions;
51+
return Math.max(numQuestions ?? 0, defaultNumQuestions);
5252
};
5353

5454
return (

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,20 @@ interface ActivitiesRequiredCellProps {
1111
itemId: number;
1212
}
1313

14+
const MIN_ACTIVITIES = 1;
15+
1416
export const ActivitiesRequiredCell = ({
1517
value,
1618
exercise,
1719
onUpdate,
1820
itemId
1921
}: ActivitiesRequiredCellProps) => {
2022
const { showToast } = useToastContext();
21-
const [currentValue, setCurrentValue] = useState(value || 0);
23+
const [currentValue, setCurrentValue] = useState(value || MIN_ACTIVITIES);
2224

2325
const handleValueChange = (newValue: number | null | undefined) => {
24-
const numValue = newValue ?? 0;
25-
const activityCount = exercise.numQuestions || 0;
26+
const numValue = newValue ?? MIN_ACTIVITIES;
27+
const activityCount = Math.max(exercise.numQuestions ?? 0, MIN_ACTIVITIES);
2628

2729
if (numValue > activityCount) {
2830
showToast({
@@ -31,7 +33,7 @@ export const ActivitiesRequiredCell = ({
3133
detail: `# required (${numValue}) must not exceed the activity count (${activityCount}).`
3234
});
3335

34-
setCurrentValue(value || 0);
36+
setCurrentValue(value || MIN_ACTIVITIES);
3537
return;
3638
}
3739

@@ -43,8 +45,8 @@ export const ActivitiesRequiredCell = ({
4345
<InputNumber
4446
value={currentValue}
4547
onValueChange={(e) => handleValueChange(e.value)}
46-
min={0}
47-
max={exercise.numQuestions || 0}
48+
min={MIN_ACTIVITIES}
49+
max={Math.max(exercise.numQuestions ?? 0, MIN_ACTIVITIES)}
4850
showButtons={false}
4951
style={{
5052
width: "100%",

bases/rsptx/assignment_server_api/routers/instructor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,9 +664,9 @@ async def get_assignment_questions(
664664

665665
if aq["reading_assignment"] == True: # noqa: E712
666666
try:
667-
aq["numQuestions"] = countd[q["chapter"]][q["subchapter"]]
667+
aq["numQuestions"] = max(countd[q["chapter"]][q["subchapter"]], 1)
668668
except KeyError:
669-
aq["numQuestions"] = 0
669+
aq["numQuestions"] = 1
670670

671671
# augment the assignment question with additional question data
672672
aq["name"] = q["name"]

0 commit comments

Comments
 (0)