Skip to content

Commit a21e6b0

Browse files
authored
Merge pull request #291 from STEM-C/contentCreatorUi
Content creator UI
2 parents 79fbfb8 + ace241d commit a21e6b0

File tree

27 files changed

+1679
-1114
lines changed

27 files changed

+1679
-1114
lines changed

client/src/App.js

Lines changed: 78 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,84 @@
1-
import React from 'react'
2-
import { Route, Switch, useHistory } from 'react-router-dom'
1+
import React from 'react';
2+
import { Route, Switch, useHistory } from 'react-router-dom';
33
import PrivateRoute from './Utils/PrivateRoute';
44

5-
import Home from "./views/Home/Home"
6-
import About from "./views/About/About"
7-
import Workspace from "./views/Workspace/Workspace"
8-
import Dashboard from "./views/Dashboard/Dashboard"
9-
import Student from "./views/Student/Student"
10-
import NotFound from "./views/NotFound"
11-
import NotChrome from './views/NotChrome'
12-
import StudentLogin from "./views/StudentLogin/StudentLogin";
13-
import Sandbox from "./views/Sandbox/Sandbox"
14-
import Day from "./views/Day/Day";
15-
import Classroom from "./views/Classroom/Classroom"
16-
import TeacherLogin from "./views/TeacherLogin/TeacherLogin"
17-
import ContentCreator from './views/ContentCreator/ContentCreator'
18-
import UnitCreator from './views/ContentCreator/UnitCreator/UnitCreator'
19-
import UploadBlocks from './views/UploadBlocks/UploadBlocks'
5+
import Home from './views/Home/Home';
6+
import About from './views/About/About';
7+
import Workspace from './views/Workspace/Workspace';
8+
import Dashboard from './views/Dashboard/Dashboard';
9+
import Student from './views/Student/Student';
10+
import NotFound from './views/NotFound';
11+
// import NotChrome from './views/NotChrome'
12+
import StudentLogin from './views/StudentLogin/StudentLogin';
13+
import Sandbox from './views/Sandbox/Sandbox';
14+
import Day from './views/Day/Day';
15+
import Classroom from './views/Classroom/Classroom';
16+
import TeacherLogin from './views/TeacherLogin/TeacherLogin';
17+
import ContentCreator from './views/ContentCreator/ContentCreator';
18+
import UnitCreator from './views/ContentCreator/UnitCreator/UnitCreator';
19+
import UploadBlocks from './views/UploadBlocks/UploadBlocks';
2020

2121
const App = () => {
22-
let history = useHistory();
23-
const isChrome = !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime);
22+
let history = useHistory();
23+
// const isChrome = !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime);
2424

25-
if(!isChrome){
26-
return <Route component={NotChrome}></Route>
27-
}
28-
return (
29-
<div>
30-
<Switch>
31-
<Route exact path="/">
32-
<Home />
33-
</Route>
34-
<Route exact path="/about">
35-
<About/>
36-
</Route>
37-
<Route exact path="/teacherlogin">
38-
<TeacherLogin history={history}/>
39-
</Route>
40-
<Route exact path="/login">
41-
<StudentLogin history={history} />
42-
</Route>
43-
<PrivateRoute exact path="/dashboard" render={() => <Dashboard history={history}/>}/>
44-
<PrivateRoute exact path="/student" render={() => <Student history={history} /> } />
45-
<Route path="/workspace">
46-
<Workspace history={history} />
47-
</Route>
48-
<Route path="/sandbox">
49-
<Sandbox history={history}/>
50-
</Route>
51-
<PrivateRoute exact path="/day" render={() => <Day history={history} /> } />
52-
<PrivateRoute path="/classroom/:id" render={() => <Classroom history={history} /> } />
53-
<Route exact path="/ccdashboard">
54-
<ContentCreator history={history} />
55-
</Route>
56-
<Route exact path="/unitcreator">
57-
<UnitCreator history={history} />
58-
</Route>
59-
<Route exact path="/addblocks">
60-
<UploadBlocks history={history} />
61-
</Route>
62-
63-
<Route component={NotFound}/>
64-
</Switch>
65-
</div>
66-
)
67-
}
25+
// if(!isChrome){
26+
// return <Route component={NotChrome}></Route>
27+
// }
28+
return (
29+
<div>
30+
<Switch>
31+
<Route exact path='/'>
32+
<Home />
33+
</Route>
34+
<Route exact path='/about'>
35+
<About />
36+
</Route>
37+
<Route exact path='/teacherlogin'>
38+
<TeacherLogin history={history} />
39+
</Route>
40+
<Route exact path='/login'>
41+
<StudentLogin history={history} />
42+
</Route>
43+
<PrivateRoute
44+
exact
45+
path='/dashboard'
46+
render={() => <Dashboard history={history} />}
47+
/>
48+
<PrivateRoute
49+
exact
50+
path='/student'
51+
render={() => <Student history={history} />}
52+
/>
53+
<Route path='/workspace'>
54+
<Workspace history={history} />
55+
</Route>
56+
<Route path='/sandbox'>
57+
<Sandbox history={history} />
58+
</Route>
59+
<PrivateRoute
60+
exact
61+
path='/day'
62+
render={() => <Day history={history} />}
63+
/>
64+
<PrivateRoute
65+
path='/classroom/:id'
66+
render={() => <Classroom history={history} />}
67+
/>
68+
<Route exact path='/ccdashboard'>
69+
<ContentCreator history={history} />
70+
</Route>
71+
<Route exact path='/unitcreator'>
72+
<UnitCreator history={history} />
73+
</Route>
74+
<Route exact path='/addblocks'>
75+
<UploadBlocks history={history} />
76+
</Route>
6877

69-
export default App
78+
<Route component={NotFound} />
79+
</Switch>
80+
</div>
81+
);
82+
};
83+
84+
export default App;

client/src/Utils/requests.js

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export const getLearningStandardcount = async () =>
179179
export const getLearningStandardAll = async () =>
180180
makeRequest({
181181
method: GET,
182-
path: `${server}/learning-standards`,
182+
path: `${server}/learning-standards?_sort=unit.name:ASC,name:ASC`,
183183
auth: true,
184184
error: 'Failed to retrieve learning standard.',
185185
});
@@ -302,17 +302,19 @@ export const createLearningStandard = async (
302302
name,
303303
number,
304304
unit,
305-
teks
305+
teks,
306+
link
306307
) =>
307308
makeRequest({
308309
method: POST,
309310
path: `${server}/learning-standards`,
310311
data: {
311312
expectations: description,
312-
name: name,
313-
number: number,
314-
unit: unit,
315-
teks: teks,
313+
name,
314+
number,
315+
unit,
316+
teks,
317+
link,
316318
},
317319
auth: true,
318320
error: 'Login failed.',
@@ -371,14 +373,21 @@ export const getGrade = async (grade) =>
371373
error: 'Grade could not be retrieved',
372374
});
373375

374-
export const updateLearningStandard = async (id, name, expectations, teks) =>
376+
export const updateLearningStandard = async (
377+
id,
378+
name,
379+
expectations,
380+
teks,
381+
link
382+
) =>
375383
makeRequest({
376384
method: PUT,
377385
path: `${server}/learning-standards/${id}`,
378386
data: {
379387
name,
380388
teks,
381389
expectations,
390+
link,
382391
},
383392
auth: true,
384393
error: 'Failed to update unit',
@@ -388,20 +397,38 @@ export const updateDayDetails = async (
388397
id,
389398
description,
390399
TekS,
391-
scienceObj,
392-
makingObj,
393-
ComputationObj
394-
) => {
395-
const objectives = [scienceObj, makingObj, ComputationObj];
400+
link,
401+
scienceDesc,
402+
makingDesc,
403+
computationDesc
404+
) =>
396405
makeRequest({
397406
method: PUT,
398407
path: `${server}/days/${id}`,
399408
data: {
400409
description,
401410
TekS,
402-
objectives,
411+
link,
412+
scienceDesc,
413+
makingDesc,
414+
computationDesc,
403415
},
404416
auth: true,
405417
error: 'Failed to update unit',
406418
});
407-
};
419+
420+
export const getLearningStandardDays = async (lsId) =>
421+
makeRequest({
422+
method: GET,
423+
path: `${server}/days?learning_standard.id=${lsId}`,
424+
auth: true,
425+
error: 'Day cannot be retrived',
426+
});
427+
428+
export const getDay = async (id) =>
429+
makeRequest({
430+
method: GET,
431+
path: `${server}/days/${id}`,
432+
auth: true,
433+
error: 'Day cannot be retrived',
434+
});
Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,46 @@
1-
import React from "react"
2-
import {Tabs} from 'antd';
3-
import "./Classroom.less"
1+
import React from 'react';
2+
import { Tabs } from 'antd';
3+
import './Classroom.less';
44

5-
import NavBar from "../../components/NavBar/NavBar";
6-
import Roster from "./Roster/Roster";
7-
import Home from "./Home/Home";
5+
import NavBar from '../../components/NavBar/NavBar';
6+
import Roster from './Roster/Roster';
7+
import Home from './Home/Home';
88

9-
const {TabPane} = Tabs;
9+
const { TabPane } = Tabs;
1010

1111
export default function Classroom(props) {
12-
const {handleLogout, history, selectedActivity, setSelectedActivity} = props;
13-
const path = history.location.pathname.split('/');
14-
const classroomId = parseInt(path[path.length - 1]);
15-
const hash = history.location.hash.split('#');
16-
const tab = hash[1];
17-
const viewing = parseInt(hash[2]);
12+
const { handleLogout, history, selectedActivity, setSelectedActivity } =
13+
props;
14+
const path = history.location.pathname.split('/');
15+
const classroomId = parseInt(path[path.length - 1]);
16+
const hash = history.location.hash.split('#');
17+
const tab = hash[1];
18+
const viewing = parseInt(hash[2]);
1819

19-
20-
21-
return (
22-
<div className="container nav-padding">
23-
<NavBar isMentor={true}/>
24-
<Tabs
25-
defaultActiveKey={tab ? tab : "home"}
26-
onChange={key => history.push(`#${key}`)}
27-
>
28-
<TabPane tab="Home" key="home">
29-
<Home classroomId={classroomId} history={history} selectedActivity={selectedActivity}
30-
setSelectedActivity={setSelectedActivity} viewing={viewing}/>
31-
</TabPane>
32-
<TabPane tab="Roster" key="roster">
33-
<Roster history={history} handleLogout={handleLogout} classroomId={classroomId}/>
34-
</TabPane>
35-
</Tabs>
36-
</div>
37-
);
38-
39-
}
20+
return (
21+
<div className='container nav-padding'>
22+
<NavBar isMentor={true} />
23+
<Tabs
24+
defaultActiveKey={tab ? tab : 'home'}
25+
onChange={(key) => history.push(`#${key}`)}
26+
>
27+
<TabPane tab='Home' key='home'>
28+
<Home
29+
classroomId={classroomId}
30+
history={history}
31+
selectedActivity={selectedActivity}
32+
setSelectedActivity={setSelectedActivity}
33+
viewing={viewing}
34+
/>
35+
</TabPane>
36+
<TabPane tab='Roster' key='roster'>
37+
<Roster
38+
history={history}
39+
handleLogout={handleLogout}
40+
classroomId={classroomId}
41+
/>
42+
</TabPane>
43+
</Tabs>
44+
</div>
45+
);
46+
}

client/src/views/Classroom/Home/Home.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ export default function Home(props) {
6767
/>
6868
</div>
6969
<p id='learning-standard-expectations'>{`Expectations: ${activeLearningStandard.expectations}`}</p>
70+
{activeLearningStandard.link ? (
71+
<p>
72+
Addtional resources to the lesson:{' '}
73+
<a
74+
href={activeLearningStandard.link}
75+
target='_blank'
76+
rel='noreferrer'
77+
>
78+
{activeLearningStandard.link}
79+
</a>
80+
</p>
81+
) : null}
7082
<div id='btn-container' className='flex space-between'>
7183
{activeLearningStandard.days.map((day) => (
7284
<div
@@ -78,8 +90,16 @@ export default function Home(props) {
7890
>
7991
<h3 id='view-day-title'>{`View Day ${day.number}`}</h3>
8092
<div id='view-day-description'>
81-
<p>Science Module</p>
82-
<p>More infomation here</p>
93+
<p>TekS: {day.TekS}</p>
94+
<p>Description: {day.description}</p>
95+
{day.link ? (
96+
<p>
97+
Link to Additional Information:{' '}
98+
<a href={day.link} target='_blank' rel='noreferrer'>
99+
{day.link}
100+
</a>
101+
</p>
102+
) : null}
83103
</div>
84104
</div>
85105
))}

0 commit comments

Comments
 (0)