Skip to content

Commit

Permalink
chore: bring changes up - merge branch 'feat-integrate-handwriting' i…
Browse files Browse the repository at this point in the history
…nto feat-store-handwriting
  • Loading branch information
Gum-Joe committed Jul 16, 2024
2 parents 54cd8d9 + 07eae83 commit 0301b3e
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/api/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const routes = {
studentMarks: (studentID: string) => `/${studentID}/marks`,
question: (number: number) => `/questions/${number}`,
questionAnswers: (number: number, username: string) => `/answers/${username}/question/${number}`,
getMathPixToken: '/proxy/mathpix-token',
}

export default routes
2 changes: 1 addition & 1 deletion src/components/questionStructure/Task/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export enum TaskType {
FLAG = 'FLAG',
MULTIPLE_CHOICE_SELECT_ONE = 'MULTIPLE_CHOICE_SELECT_ONE',
MULTIPLE_CHOICE_SELECT_SEVERAL = 'MULTIPLE_CHOICE_SELECT_SEVERAL',
MATHS_SINGLE_ANSWER = 'MATHS_SINGLE_ANSWER',
PROCESSED_HANDWRITING = 'PROCESSED_HANDWRITING',
}
2 changes: 1 addition & 1 deletion src/components/questionStructure/Task/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const taskComponentMap = {
[TaskType.FLAG]: FlagTask,
[TaskType.MULTIPLE_CHOICE_SELECT_ONE]: MCQOneTask,
[TaskType.MULTIPLE_CHOICE_SELECT_SEVERAL]: MCQMultiTask,
[TaskType.MATHS_SINGLE_ANSWER]: HandwritingTask,
[TaskType.PROCESSED_HANDWRITING]: HandwritingTask,
} as const

type TaskComponent = FC<TaskProps & { instructions?: string }>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import './index.scss'
import { HandwritingAnswer } from './types'

export interface HandwritingTaskProps extends TaskBaseProps<HandwritingAnswer> {
type: TaskType.MATHS_SINGLE_ANSWER
type: TaskType.PROCESSED_HANDWRITING
questionText: string
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import axios, { AxiosError } from 'axios'
import { useCallback, useEffect, useRef, useState } from 'react'

import axiosInstance from '../../../../../api/axiosInstance'
import routes from '../../../../../api/routes'

// Constant
/** Time to wait with user putting no stroks on the pages before API call */
Expand Down Expand Up @@ -91,10 +92,10 @@ const useLiveUpdates = (username: string, setLatex: (latex: string) => void): Li

// Get a token for a mathpix session for this user
const getToken = useCallback(() => {
axiosInstance.get(`/handwriting/${username}/mathpix-token`).then((res) => {
axiosInstance.get(routes.getMathPixToken).then((res) => {
setToken(res.data)
})
}, [username])
}, [])

// Get token on startup (or username change)
useEffect(getToken, [getToken])
Expand Down
2 changes: 1 addition & 1 deletion src/utils/answers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function parseAnswer(answer: string, targetTaskType: TaskType) {
return answer === '' ? answer : Number(answer)
case TaskType.MULTIPLE_CHOICE_SELECT_SEVERAL:
return answer === '' ? [] : answer.split(',')
case TaskType.MATHS_SINGLE_ANSWER:
case TaskType.PROCESSED_HANDWRITING:
return answer === '' ? { excalidraw: null, latex: '' } : JSON.parse(answer)
default:
return answer
Expand Down

0 comments on commit 0301b3e

Please sign in to comment.