Skip to content

Commit

Permalink
Version 2.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
hbiede committed Feb 22, 2021
1 parent d4f5477 commit fce1ba1
Show file tree
Hide file tree
Showing 16 changed files with 118 additions and 21 deletions.
1 change: 0 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"plugins": [
"typescript-sort-keys",
"button-label-required",
"flowtype",
"jsx-a11y",
"react",
"react-hooks",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "la-feedback-system",
"version": "2.0.3",
"version": "2.0.4",
"private": true,
"license": "Apache-2.0",
"description": "A website to gather feedback from students after interactions with LAs",
Expand Down
12 changes: 12 additions & 0 deletions public/courseList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

/*------------------------------------------------------------------------------
- Copyright (c) 2020.
-
- File created by Hundter Biede for the UNL CSE Learning Assistant Program
-----------------------------------------------------------------------------*/

// To get list of courses in the program:
// Call with a GET call. Result will be an array of strings

echo file_get_contents("./data/courses.json");
6 changes: 6 additions & 0 deletions public/data/courses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
"101",
"155E",
"155N",
"156"
]
1 change: 1 addition & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function App() {
isAdmin: state.isAdmin,
response: state.response,
setResponse: state.setResponse,
username: state.username,
}),
shallow
);
Expand Down
1 change: 1 addition & 0 deletions src/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"changes": [
"## 2.0.4\n- Prevent course accounts from logging interactions\n- Move course list to an API call",
"## 2.0.3\n- Add appropriate cursors to sortable table headers",
"## 2.0.2\n- Shows the number of interactions with each student to the expended interaction section\n- Adds weekly interactions to the admin table",
"## 2.0.1\n- Change session interaction count button style and disable requirements\n- Fix un-removable student bug\n- Clear students on course selection change",
Expand Down
10 changes: 5 additions & 5 deletions src/components/AnnouncementEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import Button from 'react-bootstrap/Button';

import shallow from 'zustand/shallow';

import { COURSES } from 'statics/Types';
import { ALERT_CLASSES, ResponseClass } from 'redux/modules/Types';

import Redux, { AppReduxState } from 'redux/modules';
Expand All @@ -31,9 +30,10 @@ const CLASS_LABEL = 'Alert Type';
* A screen on which an admin can create announcements viewable by the LAs
*/
const AnnouncementEditor = () => {
const { clearAnnouncements, setAnnouncements } = Redux(
const { clearAnnouncements, courses, setAnnouncements } = Redux(
(state: AppReduxState) => ({
clearAnnouncements: state.clearAnnouncements,
courses: state.courses,
setAnnouncements: state.setAnnouncements,
}),
shallow
Expand Down Expand Up @@ -115,7 +115,7 @@ const AnnouncementEditor = () => {
hidden
aria-hidden
selected={
courseRecord !== null && !COURSES.includes(courseRecord)
courseRecord !== null && !courses.includes(courseRecord)
}
>
(choose)
Expand All @@ -127,7 +127,7 @@ const AnnouncementEditor = () => {
>
{ALL_COURSE_OPTION}
</option>
{COURSES.map((c) => (
{courses.map((c) => (
<option
value={c}
selected={c === courseRecord}
Expand Down Expand Up @@ -156,7 +156,7 @@ const AnnouncementEditor = () => {
value="choose"
hidden
aria-hidden
selected={alertType !== null && !COURSES.includes(alertType)}
selected={alertType !== null && !courses.includes(alertType)}
>
(choose)
</option>
Expand Down
35 changes: 33 additions & 2 deletions src/components/SettingsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import shallow from 'zustand/shallow';

import Redux, { api, AppReduxState } from 'redux/modules';

import { COURSES } from 'statics/Types';
import ServiceInterface from '../statics/ServiceInterface';

type Props = {
closeModal: () => void;
Expand All @@ -42,6 +42,7 @@ const SettingsForm = ({ closeModal }: Props) => {
name,
setName,
course,
courses,
setCourse,
isAdmin,
setResponse,
Expand All @@ -52,6 +53,7 @@ const SettingsForm = ({ closeModal }: Props) => {
name: state.name,
setName: state.setName,
course: state.course,
courses: state.courses,
setCourse: state.setCourse,
isAdmin: state.isAdmin,
setResponse: state.setResponse,
Expand Down Expand Up @@ -170,6 +172,35 @@ const SettingsForm = ({ closeModal }: Props) => {
isAdmin &&
(!selectedUsernameRecord || selectedUsernameRecord.trim().length === 0));

if (/^cse\d/.test(selectedUsername)) {
return (
<>
<h2>May not login as a course account</h2>
<Button
id="settingsLogoutButton"
type="reset"
variant={isAdmin ? 'outline-danger' : 'danger'}
value="Logout"
onClick={ServiceInterface.logout}
>
Logout
</Button>
{isAdmin && (
<Button
id="submitButton"
type="reset"
variant="primary"
value="Change LA"
onClick={changeLA}
style={{ marginLeft: 10 }}
>
Change LA
</Button>
)}
</>
);
}

return (
<>
<h2>
Expand Down Expand Up @@ -217,7 +248,7 @@ const SettingsForm = ({ closeModal }: Props) => {
custom
>
<option value="choose">(choose)</option>
{COURSES.map((c) => (
{courses.map((c) => (
<option value={c} selected={course === c}>
{c}
</option>
Expand Down
30 changes: 30 additions & 0 deletions src/redux/actions/GetCourses.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*------------------------------------------------------------------------------
- Copyright (c) 2020.
-
- File created by Hundter Biede for the UNL CSE Learning Assistant Program
-----------------------------------------------------------------------------*/

import ServiceInterface from 'statics/ServiceInterface';

/**
* Gets the current announcements. If more than one announcement exists,
* the most specific course announcement will be received.
*/
const getCourses = async (): Promise<string[]> => {
const requestOptions = {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
};

let result: string[] = [];
await fetch(`${ServiceInterface.getPath()}/courseList.php`, requestOptions)
.then((response: Response) => response.json())
.then((json) => {
result = json;
});
return result;
};

export default getCourses;
6 changes: 6 additions & 0 deletions src/redux/actions/GetUsername.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ const getUsername = async (set: SetState<AppReduxState>): Promise<void> => {
ServiceInterface.login();
} else {
set(() => ({ username: text }));
if (/^cse\d/.test(text)) {
api.getState().setResponse({
class: 'danger',
content: 'Cannot log interactions as a course',
});
}
}
})
.catch((error) => {
Expand Down
9 changes: 8 additions & 1 deletion src/redux/actions/LogInteraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,21 @@ const LogInteraction = (
multiples = false,
interactionType: string | null = null
) => {
const { setResponse } = api.getState();
const { setResponse, username } = api.getState();
if (studentID === null) {
setResponse({
class: 'danger',
content: 'Must set a username',
});
return;
}
if (/^cse\d/.test(username)) {
setResponse({
class: 'danger',
content: 'You may not log interactions as a course',
});
return;
}

ServiceInterface.logInteraction(studentID, course, interactionType)
.then((response) => {
Expand Down
1 change: 1 addition & 0 deletions src/redux/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export { default as ClearAnnouncements } from './ClearAnnouncements';
export { default as CourseRest } from './CourseRest';
export { default as GetAnnouncements } from './GetAnnouncements';
export { default as GetCounts } from './GetCounts';
export { default as GetCourses } from './GetCourses';
export { default as GetInteractionBreakdowns } from './GetInteractionBreakdowns';
export { default as GetInteractions } from './GetInteractions';
export { default as GetRatings } from './GetRatings';
Expand Down
7 changes: 7 additions & 0 deletions src/redux/modules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
CourseRest,
GetAnnouncements,
GetCounts,
GetCourses,
GetInteractionBreakdowns,
GetInteractions,
GetRatings,
Expand Down Expand Up @@ -45,6 +46,10 @@ export type AppReduxState = {
* The current course for the currently selected user
*/
course: string;
/**
* All courses in the program
*/
courses: string[];
/**
* Gets the current announcements. If more than one announcement exists,
* the most specific course announcement will be received.
Expand Down Expand Up @@ -203,6 +208,7 @@ export const [useStore, api] = create<AppReduxState>((set, get) => ({
username: '',
startUp: () => {
GetUsername(set).then(() => {
GetCourses().then((courses) => set({ courses }));
get().getName();
get().getCourse();
get().getInteractions();
Expand All @@ -217,6 +223,7 @@ export const [useStore, api] = create<AppReduxState>((set, get) => ({
NameRest(args.name).then(() => set(() => ({ name: args.name })));
}
},
courses: [],
course: '',
getCourse: () =>
CourseRest().then((result) => set(() => ({ course: result }))),
Expand Down
5 changes: 3 additions & 2 deletions src/screens/AdminTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import SentimentText from 'components/SentimentText';
import Redux, { AppReduxState } from 'redux/modules';
import { DEFAULT_COURSE_NAME } from 'redux/modules/Types';

import { COURSES } from 'statics/Types';
import LASummaryTable from 'components/LASummaryTable';
import LADetailTable from 'components/LADetailTable';
import FeedbackTimeText from 'components/FeedbackTimeText';
Expand Down Expand Up @@ -55,6 +54,7 @@ const AdminTable = ({ style }: Props) => {
setSelectedUsername,
name,
setName,
courses,
course,
setCourse,
} = Redux(
Expand All @@ -67,6 +67,7 @@ const AdminTable = ({ style }: Props) => {
setSelectedUsername: state.setSelectedUsername,
name: state.name,
setName: state.setName,
courses: state.courses,
course: state.course,
setCourse: state.setCourse,
}),
Expand Down Expand Up @@ -204,7 +205,7 @@ const AdminTable = ({ style }: Props) => {
aria-expanded="false"
title={courseRecord}
>
{COURSES.map((c) => (
{courses.map((c) => (
<Dropdown.Item
type="button"
value={c}
Expand Down
8 changes: 4 additions & 4 deletions src/screens/FeedbackForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import shallow from 'zustand/shallow';

import Redux, { api, AppReduxState } from 'redux/modules';

import { COURSES } from 'statics/Types';

import { Student } from '../redux/modules/Types';
import StudentSelectionTypeahead from '../components/StudentSelectionTypeahead';

Expand All @@ -50,6 +48,7 @@ const FeedbackForm = ({ style }: Props) => {
username,
selectedUsername,
setSelectedUsername,
courses,
course,
isAdmin,
incrementSessionInteractions,
Expand All @@ -61,6 +60,7 @@ const FeedbackForm = ({ style }: Props) => {
username: state.username,
selectedUsername: state.selectedUsername,
setSelectedUsername: state.setSelectedUsername,
courses: state.courses,
course: state.course,
isAdmin: state.isAdmin,
incrementSessionInteractions: state.incrementSessionInteractions,
Expand Down Expand Up @@ -260,12 +260,12 @@ const FeedbackForm = ({ style }: Props) => {
hidden
aria-hidden
selected={
courseRecord !== null && !COURSES.includes(courseRecord)
courseRecord !== null && !courses.includes(courseRecord)
}
>
(choose)
</option>
{COURSES.map((c) => (
{courses.map((c) => (
<option
value={c}
selected={c === (courseRecord ?? course)}
Expand Down
5 changes: 0 additions & 5 deletions src/statics/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@ export type StyleDef<T extends string | number | symbol> = Record<
StyleTypes
>;

/**
* All current courses
*/
export const COURSES = ['101', '155E', '155N', '156'];

/**
* The characters used to display sort order
*/
Expand Down

0 comments on commit fce1ba1

Please sign in to comment.