Skip to content

Commit

Permalink
fix: show all users, including graasp and session users
Browse files Browse the repository at this point in the history
closes #12
  • Loading branch information
juancarlosfarah committed May 23, 2019
1 parent c09757a commit 19ce1df
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion data/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"_id": "5b56e70ab253020033364411"
}
],
"lightUsers": [
"users": [
{
"id": "5b56e70ab253020033364416",
"name": "juan carlos",
Expand Down
12 changes: 11 additions & 1 deletion src/components/modes/teacher/Response.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion src/components/modes/teacher/Responses.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Response _id={_id} key={_id} student={studentObject} data={data} />
);
Expand Down
2 changes: 1 addition & 1 deletion src/config/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 19ce1df

Please sign in to comment.