Skip to content

SessionView Component

Jeremy Jung edited this page Mar 14, 2021 · 5 revisions

SessionView Component

SessionView is the container for any office hour or review session. It is the container for any information about the session, including the time of the session, how many people are ahead, and any questions that have been added to the queue.

Props and State

As a container for the session, many of the props passed down to SessionView are there to pass down to descendants of SessionView, such as SessionQuestionsContainer, the container for all of the questions. However, one important prop that is used in SessionView is questions, which is the array of all the questions for the session and is used several times within the component's code.

Notable states that are kept track of include prevQuestSet, which keeps track of the set of previous questions. This is used as a comparison to execute code whenever new questions are added to the queue. showNotifBanner is a boolean, which, if set to true and the user does not have notifications enabled, allows for a view to be shown that asks the user to enable notifications to know when their question is up.

Component structure (just notable parts for better understanding)

[StudentSessionView]: The wrapper for the session

  • [SessionNotification]: View that displays only when user does not have notifications enabled and asks for user to enable notifications
  • [SessionInformationHeader]: Component that displays information about the session. This includes the time in which the session is held, the number of people ahead, and the zoom link (if applicable).
  • [SessionQuestionsContainer]: Component that contains all of the questions for a session.

Functions

updateSessionProfile

  • Parameters: virtualLocation: string
  • Runtime: O(n)
  • Returns: none

Sets any questions that are assigned to have its answerer location property as the virtual location of the person who answers the question (e.g. a TA).

isOpen

  • Parameters: s: FireSession, interval: number
  • Runtime: O(1)
  • Returns: boolean

Checks if the current session is open. The interval gives a period of time before TAs and professors start answering questions in which users can add questions, so users who come early can put their questions in the queue before the session starts. It checks if the current time is between the start time, adjusted by the interval, and the end time.

isPast

  • Parameters: s: FireSession
  • Runtime: O(1)
  • Returns: boolean

Checks if the session is over based on the current time and the session's end time.

getOpeningTime

  • Parameters: s: FireSession, interval: number
  • Runtime: O(1)
  • Returns: Date

Returns a date object giving the time at which students can start adding questions in the queue. The interval determines how early before the official start time of the session students can start putting their questions.

Functions currently not in use (to the best of Jeremy's knowledge)

triggerUndo

This function used to be called by the question component through an on click handler, but it is no longer called.

dismissUndo

As triggerUndo is no longer called, dismissUndo has no current use as well.

Variables

myQuestion

Contains a user's question that was asked earliest and is either unresolved or currently assigned to a TA or professor.

Hook calls

useEffect

Whenever the useEffect hook is called, the function that is passed into it first checks to see if there are any new questions. If there are none, it returns. It then notifies any TAs and professors that new questions have been added to the queue. It then filters for a user's questions that a user has asked in the queue, and it gets the most recently asked question from these questions. It also sets the absent state, but as far as I (Jeremy) know, setting the absent state does not do anything currently.