Skip to content
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

procenten afgerond + opgavebestanden verwijderbaar gemaakt #324

Merged
merged 5 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -15,6 +15,7 @@ import { Submission } from '../pages/submissionPage/SubmissionPage.tsx'
import { t } from 'i18next'
import dayjs from 'dayjs'
import { EvenlySpacedRow } from './CustomComponents.tsx'
import { Project } from '../pages/scoresPage/ProjectScoresPage.tsx'

interface SubmissionListItemTeacherPageProps {
group_name: string
Expand Down Expand Up @@ -53,6 +54,7 @@ export function SubmissionListItemTeacherPage({
// State for submitted data and score
const [submitted, setSubmitted] = useState<Submission>()
const [score, setScore] = useState<Score>()
const [assignment, setAssignment] = useState<Project>()
useEffect(() => {
async function fetchData() {
try {
Expand Down Expand Up @@ -107,6 +109,11 @@ export function SubmissionListItemTeacherPage({
setScore(scoreResponse.data[scoreResponse.data.length - 1])
console.log(score?.score)
}

const assignmentResponse = await instance.get(
`/projecten/${assignment_id}/`
)
setAssignment(assignmentResponse.data)
} catch (error) {
console.error('Error fetching data:', error)
}
Expand Down Expand Up @@ -168,7 +175,11 @@ export function SubmissionListItemTeacherPage({
<ListItemText
primary={
score
? `${Number(score.score)}` + '/20'
? `${Number(score.score)}` +
'/' +
(assignment
? assignment.max_score
: '20')
: t('no_score_yet')
}
/>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,14 @@ export function AddChangeAssignmentPage() {
// Upload the assignment to the API. patch if it is an edit, post if it is a new assignment.
const uploadAssignment = async () => {
let optionalFile: File | null = null
const formData = new FormData()

if (assignmentFile !== undefined) {
optionalFile = assignmentFile
} else {
formData.append('opgave_bestand', '')
}
const formData = new FormData()

formData.append('titel', title)
formData.append('beschrijving', description)
formData.append('vak', parseInt(courseId as string).toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ export function AssignmentPage() {
color={'text.primary'}
>
{score
? `${score.score}/${assignment?.max_score} (${(100 * score.score) / Number(assignment?.max_score)}%)`
? `${score.score}/${assignment?.max_score} (${Math.round((100 * score.score) / Number(assignment?.max_score))}%)`
: t('no_score_yet')}
</Typography>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export function AssignmentListItemSubjectsPage({
<ListItemText
primary={
score
? `${score.score}/${maxScore} (${(100 * score.score) / maxScore}%)`
? `${score.score}/${maxScore} (${Math.round((100 * score.score) / maxScore)}%)`
: t('no_score_yet')
}
/>
Expand Down
Loading