diff --git a/data/default.json b/data/default.json index e43e44c1..c413c7e0 100644 --- a/data/default.json +++ b/data/default.json @@ -14,7 +14,7 @@ "_id": "5b56e70ab253020033364411" } ], - "lightUsers": [ + "users": [ { "id": "5b56e70ab253020033364416", "name": "juan carlos", diff --git a/src/components/modes/teacher/Response.js b/src/components/modes/teacher/Response.js index bad33244..6439ecc8 100644 --- a/src/components/modes/teacher/Response.js +++ b/src/components/modes/teacher/Response.js @@ -16,6 +16,7 @@ import { } from '../../../actions'; import { FEEDBACK } from '../../../config/appInstanceResourceTypes'; import FormDialog from '../../common/FormDialog'; +import { showErrorToast } from '../../../utils/toasts'; class Response extends Component { state = { @@ -77,11 +78,20 @@ class Response extends Component { dispatchPostAppInstanceResource, dispatchPatchAppInstanceResource, } = this.props; + + const { id } = student; + + if (!id) { + showErrorToast( + 'Currently we do not support giving feedback to anonymous users.' + ); + } + // if no feedback resource yet, create it, otherwise, update it if (_.isEmpty(feedbackResource)) { dispatchPostAppInstanceResource({ data: feedback, - userId: student.id, + userId: id, type: FEEDBACK, }); } else { diff --git a/src/components/modes/teacher/Responses.js b/src/components/modes/teacher/Responses.js index 906305cb..a31fc7a3 100644 --- a/src/components/modes/teacher/Responses.js +++ b/src/components/modes/teacher/Responses.js @@ -63,9 +63,14 @@ class Responses extends Component { ); } + const anonymousUser = { + name: t('Anonymous'), + }; + // map each app instance resource to a row in the table return appInstanceResources.map(({ _id, user, data }) => { - const studentObject = students.find(student => student.id === user) || {}; + const studentObject = + students.find(student => student.id === user) || anonymousUser; return ( ); diff --git a/src/config/api.js b/src/config/api.js index bd0f04f9..47e1ca4d 100644 --- a/src/config/api.js +++ b/src/config/api.js @@ -7,7 +7,7 @@ export const APP_INSTANCE_RESOURCES_ENDPOINT = '/app-instance-resources'; export const SPACES_ENDPOINT = '/spaces'; // users endpoint is currently used in conjunction with spaces endpoint // e.g. `${SPACES_ENDPOINT}/${spaceId}/${USERS_ENDPOINT}` -export const USERS_ENDPOINT = 'light-users'; +export const USERS_ENDPOINT = 'users'; // request defaults const DEFAULT_REQUEST = {