Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Version updates #130

Merged
merged 29 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
333e23b
with node 22.2.0, i seem to be able to npm install with no issues. th…
hcientist May 20, 2024
e035b95
'use client' directive is attempting to opt us out of server side ren…
hcientist May 25, 2024
94829a8
update react bootstrap
hcientist May 25, 2024
6e56318
somehow these were using the wrong url param
hcientist May 25, 2024
d8054db
don't try to continue the action if we don't have all the info
hcientist May 25, 2024
e642300
default the RTE to empty or else the student would have to delete the…
hcientist May 25, 2024
bb47081
it's more correct to set textareas by value prop
hcientist May 25, 2024
4065a22
alwaysOpen seems to require the array of keys
hcientist May 25, 2024
32ebd0e
there's some change to the NextJS Link component that requires we als…
hcientist May 25, 2024
060b63b
isLoading was overloaded
hcientist May 25, 2024
0c33f31
looks like activity body moved...
hcientist May 25, 2024
6c5f58f
not sure... probably because we changed how the API responds?
hcientist May 25, 2024
46f009f
lets keep package-lock
hcientist May 26, 2024
da596d7
apparently the .env.local should end up in .gitignore...
hcientist May 29, 2024
77b23fb
auth-token endpoint should have trailing slash
hcientist May 31, 2024
4c8277b
not sure what this rewrite was for, but it seems like we don't need it
hcientist May 31, 2024
fc12ea6
drop the rails config, add in logging
hcientist May 31, 2024
fda2366
change to csrf, not sure it make sense, but i lke it better than what…
hcientist May 31, 2024
731a196
Remove assignment sorting in frontend as it has been moved to the bac…
Adamv27 Apr 3, 2024
3d7ac19
Reroute users with next-auth router
Adamv27 Mar 27, 2024
86d588b
Create componenet dropdown for selecting instruments
Adamv27 Apr 10, 2024
44118f1
Toggle displaying instrument selector is can edit instrument attribut…
Adamv27 Apr 10, 2024
6a9fd7f
Add request to backend to change instrument. Only display instrument …
Adamv27 Apr 18, 2024
582d83b
Make generic fetch method to backend
Adamv27 Apr 22, 2024
e055251
Remove global variable
Adamv27 Apr 22, 2024
db17ae9
Return async function from getStudentAssignments
Adamv27 Apr 22, 2024
81e538f
Refactor the rest of the api functions
Adamv27 May 1, 2024
7b486b6
that's not how you call functions with default params in js lol
hcientist Jun 1, 2024
66c8671
Merge branch 'main' into version-updates
hcientist Jun 1, 2024
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
2 changes: 2 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
NEXT_PUBLIC_BACKEND_HOST="http://localhost:8000"
SECRET=idkjustpleasehavesomethingfortesting
NEXTAUTH_URL="http://localhost:3000"
4 changes: 2 additions & 2 deletions .env.local
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
SECRET=idkjustpleasehavesomethingfortesting
NEXTAUTH_URL="http://localhost:3000"
# this one shoudl end up in .gitignore?
# https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables#default-environment-variables
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,4 @@ yarn-error.log*
# vercel
.vercel

#stewart battle
yarn.lock
package-lock.json

.vscode
6 changes: 5 additions & 1 deletion actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export function logoutUser() {
const {
currentUser: { token },
} = getState();
fetch(`${process.env.NEXT_PUBLIC_BACKEND_HOST}/auth-token`, {
fetch(`${process.env.NEXT_PUBLIC_BACKEND_HOST}/auth-token/`, {
method: 'DELETE',
headers: {
Authorization: `Token ${token}`,
Expand Down Expand Up @@ -600,6 +600,10 @@ export function postRespond({ slug, assignmentId, response }) {
const {
currentUser: { token },
} = getState();
if (!slug || !assignmentId || !response) {
console.error('missing requirements to submit', slug, assignmentId, response)
return;
}
dispatch(beginUpload(assignmentId));
const body = JSON.stringify({ content: JSON.stringify(response) });
return fetch(
Expand Down
22 changes: 15 additions & 7 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ export function getAllPieces(slug) {
export function mutateAssignPiece(slug) {
return async (piecePlanId) => {
const endpoint = `courses/${slug}/assign_piece_plan/`
const json = await makeRequest(endpoint, method='POST', body={piece_id: piecePlanId})
const json = await makeRequest(endpoint, 'POST', {piece_id: piecePlanId})
return json
}
}

export function mutateUnassignPiece(slug) {
return async (piece) => {
const endpoint = `courses/${slug}/unassign/`
const json = await makeRequest(endpoint, method='POST', body={piece_id: piece.id});
const endpoint = `courses/${slug}/unassign/`
const json = await makeRequest(endpoint, 'POST', {piece_id: piece.id});
return json
}
}
Expand All @@ -97,7 +97,9 @@ export function mutateGradeSubmission(slug) {
expression,
grader
};
const json = await makeRequest(endpoint, method='POST', body=body);

const json = await makeRequest(endpoint, 'POST', body);

return json;
}
}
Expand All @@ -106,7 +108,9 @@ export function mutateGradeSubmission(slug) {
export function mutateCreateSubmission({ slug }) {
return async (submission, assignmentId) => {
const endpoint = `courses/${slug}/assignments/${assignmentId}/submissions/`
const json = await makeRequest(endpoint, method='POST', body=submission)

const json = await makeRequest(endpoint, 'POST', submission)

return json;
}
}
Expand All @@ -121,15 +125,19 @@ export function mutateCourse(slug) {
// expecting params to be any subset of name, start_date, end_date, slug
return async (params) => {
const endpoint = `courses/${slug}/`
const json = await makeRequest(endpoint, method='PATCH', body=params);

const json = await makeRequest(endpoint, 'PATCH', params);

return json;
}
}

export async function mutateAssignmentInstrument(slug, pieceId, instrument) {
const endpoint = `courses/${slug}/change_piece_instrument/`;
const body = {piece_id: pieceId, instrument_id: instrument.id};
const json = await makeRequest(endpoint, method='PATCH', body=body);

const json = await makeRequest(endpoint, 'PATCH', body);

return json;
}

Expand Down
100 changes: 48 additions & 52 deletions components/enrollments.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,60 +25,56 @@ export default function Enrollments({ children }) {
<div className="course-list">
{enrollments &&
enrollments.map((enrollment) => (
<Link href={`/courses/${enrollment.course.slug}`} key={enrollment.course.url}>
<a className="course-item">
<Card className={new Date(enrollment.course.end_date) < new Date() ? 'opacity-50' : ''}>
<Card.Img variant="top" as="div" className="card-color" />
<Card.Body>
<Card.Title>{enrollment.course.name}</Card.Title>
<Card.Text>
{/* <FaCalendar /> */}
<span className="ml-3">{format(new Date(enrollment.course.start_date), 'MMM d')}</span>&nbsp;-&nbsp;
{/* <br /> */}
{/* <FaFlagCheckered /> */}
<span className="ml-3">{format(new Date(enrollment.course.end_date), 'MMM d')}</span>
</Card.Text>
</Card.Body>
{/* <Card.Footer className="text-muted d-flex justify-content-between">
<Link href={`/courses/${enrollment.course.slug}`}>
<Button variant="primary">
View <FaLocationArrow />
</Button>
</Link>
<Link href={`/courses/${enrollment.course.slug}/edit`}>
<Button variant="primary">
Edit <FaEdit />
</Button>
</Link>
</Card.Footer> */}
</Card>
</a>
<Link href={`/courses/${enrollment.course.slug}`} key={enrollment.course.url} className="course-item">
<Card className={new Date(enrollment.course.end_date) < new Date() ? 'opacity-50' : ''}>
<Card.Img variant="top" as="div" className="card-color" />
<Card.Body>
<Card.Title>{enrollment.course.name}</Card.Title>
<Card.Text>
{/* <FaCalendar /> */}
<span className="ml-3">{format(new Date(enrollment.course.start_date), 'MMM d')}</span>&nbsp;-&nbsp;
{/* <br /> */}
{/* <FaFlagCheckered /> */}
<span className="ml-3">{format(new Date(enrollment.course.end_date), 'MMM d')}</span>
</Card.Text>
</Card.Body>
{/* <Card.Footer className="text-muted d-flex justify-content-between">
<Link href={`/courses/${enrollment.course.slug}`}>
<Button variant="primary">
View <FaLocationArrow />
</Button>
</Link>
<Link href={`/courses/${enrollment.course.slug}/edit`}>
<Button variant="primary">
Edit <FaEdit />
</Button>
</Link>
</Card.Footer> */}
</Card>
</Link>
))}
{ groups && groups.some(gName=>gName==="Teacher") && <Link href="/courses/new">
<a className="course-item">
<Card>
<Card.Img variant="top" as="div" className="card-color" />
<Card.Body>
<Card.Title>Add New Course</Card.Title>
{/* <Card.Text>

</Card.Text> */}
</Card.Body>
{/* <Card.Footer className="text-muted d-flex justify-content-between">
<Link href={`/courses/${enrollment.course.slug}`}>
<Button variant="primary">
View <FaLocationArrow />
</Button>
</Link>
<Link href={`/courses/${enrollment.course.slug}/edit`}>
<Button variant="primary">
Edit <FaEdit />
</Button>
</Link>
</Card.Footer> */}
</Card>
</a>
{groups && groups.some(gName => gName === "Teacher") && <Link href="/courses/new" className="course-item">
<Card>
<Card.Img variant="top" as="div" className="card-color" />
<Card.Body>
<Card.Title>Add New Course</Card.Title>
{/* <Card.Text>

</Card.Text> */}
</Card.Body>
{/* <Card.Footer className="text-muted d-flex justify-content-between">
<Link href={`/courses/${enrollment.course.slug}`}>
<Button variant="primary">
View <FaLocationArrow />
</Button>
</Link>
<Link href={`/courses/${enrollment.course.slug}/edit`}>
<Button variant="primary">
Edit <FaEdit />
</Button>
</Link>
</Card.Footer> */}
</Card>
</Link> }
</div>
);
Expand Down
1 change: 1 addition & 0 deletions components/layout.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client';
import Container from 'react-bootstrap/Container';
import Head from 'next/head';
import { useRouter } from 'next/router';
Expand Down
4 changes: 2 additions & 2 deletions components/loginout.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ function LoginOut() {
const currentUserInfo = useSelector((state) => state.currentUser);
// const loginStatus = useSelector((state) => state.loginStatus);
return session ? (
<Link href="/api/auth/signout" passHref>
<Link href="/api/auth/signout" passHref legacyBehavior>
<Nav.Link>Logout
{
currentUserInfo.loaded ? ` ${currentUserInfo.username}` : ""
}
</Nav.Link>
</Link>
) : (
<Link href="/auth/signin?callbackUrl=/courses" passHref>
<Link href="/auth/signin?callbackUrl=/courses" passHref legacyBehavior>
<Nav.Link>Login</Nav.Link>
</Link>
);
Expand Down
5 changes: 3 additions & 2 deletions components/nav.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client';
import Nav from 'react-bootstrap/Nav';
import Navbar from 'react-bootstrap/Navbar';
import Container from 'react-bootstrap/Container';
Expand Down Expand Up @@ -27,7 +28,7 @@ function Navigation() {
<Nav className="me-auto">
{enrollments ? <CourseSelector /> :
<Nav.Item>
<Link href="/courses" passHref>
<Link href="/courses" passHref legacyBehavior>
<Nav.Link>Courses</Nav.Link>
</Link>
</Nav.Item>
Expand All @@ -36,7 +37,7 @@ function Navigation() {
{piece && <NavActivityPicker />}
</Nav>
<Nav>
<Link href="/about" passHref>
<Link href="/about" passHref legacyBehavior>
<Nav.Link>About</Nav.Link>
</Link>
<LoginOut />
Expand Down
10 changes: 5 additions & 5 deletions components/student/activityPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function ActivityPicker (assignment) {
return <ListGroup>
<Link
href={`/courses/${slug}/${piece}/Perform/Melody`}
passHref
passHref legacyBehavior
>
<ListGroup.Item
action
Expand All @@ -49,7 +49,7 @@ return <ListGroup>
</Link>
<Link
href={`/courses/${slug}/${piece}/Perform/Bassline`}
passHref
passHref legacyBehavior
>
<ListGroup.Item
action
Expand All @@ -65,7 +65,7 @@ return <ListGroup>
</span>
</ListGroup.Item>
</Link>
<Link href={`/courses/${slug}/${piece}/Create`} passHref>
<Link href={`/courses/${slug}/${piece}/Create`} passHref legacyBehavior>
<ListGroup.Item
action
eventKey="Create"
Expand All @@ -78,7 +78,7 @@ return <ListGroup>
</span>
</ListGroup.Item>
</Link>
<Link href={`/courses/${slug}/${piece}/Respond`} passHref>
<Link href={`/courses/${slug}/${piece}/Respond`} passHref legacyBehavior>
<ListGroup.Item
action
eventKey="Respond"
Expand All @@ -95,7 +95,7 @@ return <ListGroup>
{hasCompose && (
<Link
href={`/courses/${slug}/${piece}/${connectLink}`}
passHref
passHref legacyBehavior
>
<ListGroup.Item
action
Expand Down
2 changes: 1 addition & 1 deletion components/student/assignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default function StudentAssignment({ children, assignment }) {
`${actCategory} `}
{assignment?.activity?.activity_type?.name} Activity
</h1>
<Instructions body={assignment?.activity_body} />
<Instructions body={assignment?.activity_body ?? assignment?.activity?.body} />
{assignment.submissions.length > 0 ? (
<Accordion defaultActiveKey="0" alwaysOpen className="cpr-create">
<Accordion.Item eventKey="0">
Expand Down
2 changes: 1 addition & 1 deletion components/student/pieceAssignments.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function PieceAssignments({ piece, canEditInstruments }) {
className="d-flex justify-content-between"
>
<Link
passHref
passHref legacyBehavior
href={`/courses/${slug}/${assignment.piece_slug
}/${assnToKey(assignment, 'debug str this is from pieceAssignments')}`}
>
Expand Down
3 changes: 1 addition & 2 deletions components/student/recentSubmission.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ export default function RecentSubmission(assn) {
) : ctgy === 'Respond' ? (
<Row>
<Col md={9}>
<textarea rows={5} readOnly className="respond-preview">
{JSON.parse(content).reflection}
<textarea rows={5} readOnly className="respond-preview" value={JSON.parse(content).reflection} disabled>
</textarea>
</Col>
<Col>
Expand Down
6 changes: 3 additions & 3 deletions components/student/respond.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export default function RespondActivity() {
const assignmentId =
loadedActivities &&
activities &&
activities?.[slug] &&
activities?.[slug].filter(
activities?.[piece] &&
activities?.[piece].filter(
(assn) =>
assn.piece_slug === piece && assn.activity_type_category === actCategory
)?.[0]?.id;
Expand Down Expand Up @@ -66,7 +66,7 @@ export default function RespondActivity() {
/>
<RTE submission={{ id: assignmentId }} submitAction={submitAction} />
<h3>Rating Scales</h3>
<Accordion defaultActiveKey="0" alwaysOpen className="cpr-create">
<Accordion defaultActiveKey={["0", "1", "2"]} alwaysOpen className="cpr-create">
<Accordion.Item eventKey="0">
<Accordion.Header>Rhythm</Accordion.Header>
<Accordion.Body>
Expand Down
Loading