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
Text responses tab: add textResponsesRedux #22304
Conversation
…to rest of response object
…hanged and scope by scriptId rather than sectionId+scriptId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
const FINISH_LOADING_RESPONSES = 'textResponses/FINISH_LOADING_RESPONSES'; | ||
|
||
// Action creators | ||
export const setTextResponses = (sectionId, scriptId, responseData) => ({ type: SET_TEXT_RESPONSES, sectionId, scriptId, responseData}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this is pretty long - should be broken up into two.
url: PropTypes.string.isRequired | ||
}); | ||
|
||
// Initial state of textResponsesRedux |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be useful to have a comment explaining that responseData is an object where the key is a script, and the value is etc.
In progress, we appended "byScript" to our names to make it a bit more clear: https://github.com/code-dot-org/code-dot-org/blob/staging/apps/src/templates/sectionProgress/sectionProgressRedux.js#L153
In order to convert the "text responses" tab in teacher dashboard to react, we will want student text response data to be available in redux. This PR creates the reducer with a way to pull responses into redux from
dashboardapi
and controls loading states since the former action is asynchronous.Since a teacher will always be viewing text responses in the scope of a section and a script, the
responseData
object in redux state looks as follows (some response properties removed for clarity):responseData
is then cleared when the teacher switches sections. This structure 1) allows the reducer to keep track of which scripts it has already loaded and will not re-request that data from the server if it already has it, and 2) makes rendering the response table more straightforward.