Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
frostyfan109 committed Aug 13, 2024
1 parent 489547d commit efbc7a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ArrowBackSharp } from '@material-ui/icons'
import moment from 'moment'
import pluralize from 'pluralize'
import { assignmentInfoClass, assignmentInfoSectionClass, assignmentInfoSectionHeaderClass, assignmentInfoSectionWarningClass, assignmentNameClass, tagClass } from './style'
import { useAssignment, useCommands, useSnackbar } from '../../../contexts'
import { useAssignment, useCommands, } from '../../../contexts'
import { DateFormat } from '../../../utils'

const MS_IN_HOURS = 3.6e6
Expand All @@ -16,7 +16,6 @@ interface AssignmentInfoProps {
export const AssignmentInfo = ({ }: AssignmentInfoProps) => {
const { assignment, student, course, studentNotebookExists } = useAssignment()!
const commands = useCommands()
const snackbar = useSnackbar()!
if (!student || !assignment || !course) return null

const hoursUntilDue = useMemo(() => (
Expand Down Expand Up @@ -108,9 +107,8 @@ export const AssignmentInfo = ({ }: AssignmentInfoProps) => {

const openStudentNotebook = useCallback(async () => {
if (!commands || !assignment) return
const gradedNotebookPath = assignment.absoluteDirectoryPath + "/" + assignment.studentNotebookPath
const result = await commands.execute('docmanager:open', { path: gradedNotebookPath })
console.log(result)
const fullNotebookPath = assignment.absoluteDirectoryPath + "/" + assignment.studentNotebookPath
commands.execute('docmanager:open', { path: fullNotebookPath })
}, [commands, assignment])

return (
Expand Down Expand Up @@ -191,7 +189,8 @@ export const AssignmentInfo = ({ }: AssignmentInfoProps) => {
<Input
readOnly
value={ assignment.studentNotebookPath }
inputProps={{ style: { width: "100%", height: 32 } }}
inputProps={{ style: { height: 32 } }}
style={{ width: "100%" }}
/>
<FormHelperText style={{ color: "#1976d2" }}>
<a onClick={ openStudentNotebook } style={{ cursor: "pointer" }}>
Expand Down
7 changes: 5 additions & 2 deletions src/contexts/assignment-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const WEBSOCKET_URL = URLExt.join(
"ws"
)
const WEBSOCKET_REOPEN_DELAY = 1000
const POLL_DELAY = 15000

export const AssignmentContext = createContext<IAssignmentContext|undefined>(undefined)

Expand Down Expand Up @@ -127,7 +128,7 @@ export const AssignmentProvider = ({ fileBrowser, children }: IAssignmentProvide
setAssignments(undefined)
setCurrentAssignment(undefined)
}
timeoutId = window.setTimeout(poll, 2500)
timeoutId = window.setTimeout(poll, POLL_DELAY)
}
poll()
return () => {
Expand Down Expand Up @@ -161,7 +162,7 @@ export const AssignmentProvider = ({ fileBrowser, children }: IAssignmentProvide
setCourse(undefined)
setStudent(undefined)
}
timeoutId = window.setTimeout(poll, 2500)
timeoutId = window.setTimeout(poll, POLL_DELAY)
}
poll()
return () => {
Expand Down Expand Up @@ -192,6 +193,8 @@ export const AssignmentProvider = ({ fileBrowser, children }: IAssignmentProvide
} else {
setNotebookFiles(undefined)
}
// We don't use POLL_DELAY for fetching notebook files, since this needs to be reflected more rapidly
// to the user and also doesn't involve any API calls, only scanning the directory for ipynb files.
timeoutId = window.setTimeout(poll, 2500)
}
poll()
Expand Down

0 comments on commit efbc7a1

Please sign in to comment.