Skip to content

Commit d3bc2ed

Browse files
committed
remind stewart the URL and claude tries to fix reflection bug
1 parent b31971e commit d3bc2ed

3 files changed

Lines changed: 19 additions & 15 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,7 @@ This is the frontend for MusicCPR.org
3939
## GitHub Container Registry (GHCR)
4040

4141
**Note:** For the workflow to push packages, you may need to ensure your repository settings allow GitHub Actions to create packages. Go to Settings → Actions → General → Workflow permissions and ensure "Read and write permissions" is enabled.
42+
43+
## DAW Testing
44+
45+
Go here Stewart! http://localhost:3000/courses/6th-grade-band/freedom-2040-band-1/Perform/Melody/activity/1

components/activity/ActivityInstructions.jsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { Card, Form, Alert } from 'react-bootstrap';
88
import { FaCheckCircle, FaLock } from 'react-icons/fa';
9-
import { useState, useEffect } from 'react';
9+
import { useState, useRef, useCallback } from 'react';
1010

1111
export default function ActivityInstructions({
1212
step,
@@ -17,22 +17,22 @@ export default function ActivityInstructions({
1717
onResponseChange,
1818
}) {
1919
const [localResponses, setLocalResponses] = useState(questionResponses);
20+
const debounceTimers = useRef({});
2021

21-
useEffect(() => {
22-
setLocalResponses(questionResponses);
23-
}, [questionResponses]);
24-
25-
const handleChange = (questionId, value) => {
22+
const handleChange = useCallback((questionId, value) => {
2623
setLocalResponses((prev) => ({
2724
...prev,
2825
[questionId]: value,
2926
}));
3027

31-
// Debounce the save
28+
// Debounce the API save to avoid excessive requests
3229
if (onResponseChange) {
33-
onResponseChange(questionId, value);
30+
clearTimeout(debounceTimers.current[questionId]);
31+
debounceTimers.current[questionId] = setTimeout(() => {
32+
onResponseChange(questionId, value);
33+
}, 500);
3434
}
35-
};
35+
}, [onResponseChange]);
3636

3737
const isQuestionUnlocked = (question) => {
3838
if (!question.requiredOperation) return true;

hooks/useActivityProgress.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,16 @@ export function useActivityProgress({ slug, assignmentId, initialStep = 1, email
125125
const saveResponse = useCallback(async (questionId, response) => {
126126
if (!slug || !assignmentId) return;
127127

128+
// Update local state optimistically before the API call
129+
setQuestionResponses(prev => ({
130+
...prev,
131+
[questionId]: response,
132+
}));
133+
128134
try {
129135
const saveResponseFn = mutateSaveQuestionResponse({ slug, assignmentId });
130136
const updatedProgress = await saveResponseFn({ questionId, response });
131137

132-
// Update local state
133-
setQuestionResponses(prev => ({
134-
...prev,
135-
[questionId]: response,
136-
}));
137-
138138
return updatedProgress;
139139
} catch (error) {
140140
console.error('Failed to save response:', error);

0 commit comments

Comments
 (0)