Skip to content

Commit 09deb17

Browse files
committed
fixed task navbar color and single target grading format
1 parent 7340e0e commit 09deb17

File tree

11 files changed

+119
-221
lines changed

11 files changed

+119
-221
lines changed

src/Components/LinearProgressWithLabel/ObjectiveDropDown.tsx

Lines changed: 99 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState } from 'react';
2-
import { makeStyles, Theme, createStyles } from '@material-ui/core/styles';
2+
import { makeStyles, Theme, createStyles, withStyles } from '@material-ui/core/styles';
33
import styled from 'styled-components';
44
import List from '@material-ui/core/List';
55
import ListItem from '@material-ui/core/ListItem';
@@ -8,6 +8,7 @@ import Collapse from '@material-ui/core/Collapse';
88
import ExpandLess from '@material-ui/icons/ExpandLess';
99
import ExpandMore from '@material-ui/icons/ExpandMore';
1010
import { Link } from 'react-router-dom';
11+
import { Box, LinearProgress } from '@material-ui/core';
1112
import LinearProgressWithLabel from './LinearProgressWithLabel';
1213
import {
1314
Task,
@@ -30,6 +31,71 @@ const useStyles = makeStyles((theme: Theme) =>
3031
},
3132
})
3233
);
34+
const MasteredProgress = withStyles((theme: Theme) =>
35+
createStyles({
36+
root: {
37+
height: 25,
38+
borderRadius: 5,
39+
},
40+
colorPrimary: {
41+
backgroundColor: '#30CC30',
42+
},
43+
bar: {
44+
borderRadius: 5,
45+
backgroundColor: '#30CC30',
46+
},
47+
})
48+
)(LinearProgress);
49+
50+
const NotStartedProgress = withStyles((theme: Theme) =>
51+
createStyles({
52+
root: {
53+
height: 25,
54+
borderRadius: 5,
55+
display: 'flex',
56+
justifyContent: 'right',
57+
},
58+
colorPrimary: {
59+
backgroundColor: '#E0E0E0',
60+
},
61+
bar: {
62+
borderRadius: 5,
63+
backgroundColor: '#E0E0E0',
64+
},
65+
})
66+
)(LinearProgress);
67+
68+
const NotMasteredProgress = withStyles((theme: Theme) =>
69+
createStyles({
70+
root: {
71+
height: 25,
72+
borderRadius: 5,
73+
},
74+
colorPrimary: {
75+
backgroundColor: '#EA6868',
76+
},
77+
bar: {
78+
borderRadius: 5,
79+
backgroundColor: '#EA6868',
80+
},
81+
})
82+
)(LinearProgress);
83+
84+
const AlmostMasteredProgress = withStyles((theme: Theme) =>
85+
createStyles({
86+
root: {
87+
height: 25,
88+
borderRadius: 5,
89+
},
90+
colorPrimary: {
91+
backgroundColor: '#F2C94C',
92+
},
93+
bar: {
94+
borderRadius: 5,
95+
backgroundColor: '#F2C94C',
96+
},
97+
})
98+
)(LinearProgress);
3399

34100
const DoublePaddedDiv = styled.div`
35101
padding-left: 40px;
@@ -42,6 +108,19 @@ export interface ObjectiveDropDownProps {
42108
tasks: TaskObjectiveProgress[];
43109
}
44110

111+
function getProgressBar(status: number) {
112+
if (status === 0) {
113+
return <NotStartedProgress />;
114+
}
115+
if (status < 0.75) {
116+
return <NotMasteredProgress />;
117+
}
118+
if (status >= 0.75 && status < 1) {
119+
return <AlmostMasteredProgress />;
120+
}
121+
return <MasteredProgress />;
122+
}
123+
45124
// Handles state to open and close dropdown
46125
function handleClick(
47126
openObjectBool: boolean,
@@ -54,42 +133,43 @@ function getObjectivePercent(tasks: TaskObjectiveProgress[]) {
54133
let count = 0;
55134
for (const task of tasks) {
56135
const mastery = getTaskPercent(task.mastery);
57-
if (mastery === 100) {
136+
if (mastery === 1) {
58137
count++;
59138
}
60139
}
61-
return count;
140+
if (tasks.length === 0) {
141+
return 0;
142+
}
143+
return count / tasks.length;
62144
}
63145

64146
function getTaskPercent(mastery: string) {
65147
if (mastery === 'NOT_GRADED') {
66148
return 0;
67149
}
68150
if (mastery === 'NOT_MASTERED') {
69-
return 50;
151+
return 0.5;
70152
}
71153
if (mastery === 'ALMOST_MASTERED') {
72-
return 75;
154+
return 0.75;
73155
}
74-
return 100;
156+
return 1;
75157
}
76158

77-
export default function TargetDropDown({ name, tasks }: ObjectiveDropDownProps) {
159+
export default function ObjectiveDropDown({ name, tasks }: ObjectiveDropDownProps) {
78160
const classes = useStyles();
79161
const [open, setOpen] = useState(false);
80162

81-
const TASK_PERCENT = 100;
82-
const OBJECTIVE_PERCENT = 50;
83-
84163
return (
85164
<List component="div" disablePadding style={{ justifyContent: 'right', width: '100%' }}>
86165
<ListItem button onClick={() => handleClick(open, setOpen)} divider>
87166
{open ? <ExpandLess /> : <ExpandMore />}
88167
<ListItemText primary={name} />
89-
<LinearProgressWithLabel
90-
className={classes.progressBar}
91-
value={getObjectivePercent(tasks)}
92-
/>
168+
<Box display="flex" style={{ justifyContent: 'right' }} width="80%">
169+
<Box width="100%" mr={1} ml={1}>
170+
{getProgressBar(getObjectivePercent(tasks))}
171+
</Box>
172+
</Box>
93173
</ListItem>
94174

95175
<Collapse in={open} timeout="auto" unmountOnExit>
@@ -100,10 +180,11 @@ export default function TargetDropDown({ name, tasks }: ObjectiveDropDownProps)
100180
<DoublePaddedDiv>
101181
<ListItem button className={classes.nested} divider>
102182
<ListItemText primary={task.task.name} />
103-
<LinearProgressWithLabel
104-
className={classes.progressBar}
105-
value={getTaskPercent(task.mastery)}
106-
/>
183+
<Box display="flex" alignItems="center" width="80%">
184+
<Box width="100%" mr={1} ml={1}>
185+
{getProgressBar(getTaskPercent(task.mastery))}
186+
</Box>
187+
</Box>
107188
</ListItem>
108189
</DoublePaddedDiv>
109190
</div>

src/Components/LinearProgressWithLabel/StarRating.tsx

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/Components/LinearProgressWithLabel/TargetDropDown.tsx

Lines changed: 0 additions & 92 deletions
This file was deleted.

src/Components/SingleStudentMasteryOverview/SingleStudentMasteryOverview.tsx

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -343,38 +343,25 @@
343343
/* eslint-disable @typescript-eslint/no-explicit-any */
344344
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
345345
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
346-
import { useQuery } from '@apollo/client';
347346
import { makeStyles, Theme, createStyles } from '@material-ui/core/styles';
348347
import List from '@material-ui/core/List';
349348
import ListItem from '@material-ui/core/ListItem';
350-
import ListItemText from '@material-ui/core/ListItemText';
351349
import styled from 'styled-components';
352-
import { Link, useHistory } from 'react-router-dom';
353-
import { Button } from 'react-bootstrap';
354-
import { Divider, Typography } from '@material-ui/core';
350+
import { useHistory } from 'react-router-dom';
351+
import { Divider } from '@material-ui/core';
355352
import StudentPicture from '../../assets/images/images-1.png';
356353
import { User } from '../../interfaces/User';
357-
import LinearProgressWithLabel from '../LinearProgressWithLabel/LinearProgressWithLabel';
358-
import MissionDropDown from '../LinearProgressWithLabel/MissionDropDown';
359-
import { GET_USERS } from '../../queries/user-queries';
360354
// import {
361355
// CourseInfoFieldsFragment,
362356
// TaskStats,
363357
// useGetMissionProgressQuery,
364358
// } from '../../__generated__/types';
365359
// import TargetDropDown from '../LinearProgressWithLabel/TargetDropDown';
366360
import {
367-
Objective,
368-
ObjectiveFieldsFragmentDoc,
369-
ObjectiveProgress,
370361
ObjectiveProgressFieldsFragment,
371-
TargetProgress,
372-
TaskFieldsFragmentDoc,
373-
TaskObjectiveProgress,
374362
TaskObjectiveProgressFieldsFragment,
375363
useGetTargetProgressQuery,
376364
} from '../../__generated__/types';
377-
import CircularProgressWithLabel from '../LinearProgressWithLabel/CircularProgressWithLabel';
378365
import TargetMasteryCard from './TargetMasteryCard';
379366

380367
const StudentDiv = styled.div`
@@ -541,18 +528,15 @@ function SingleStudentMasteryOverview() {
541528
console.log(targetData);
542529

543530
return (
544-
<div
545-
className="container d-inline-block "
546-
style={{ marginLeft: '5px', marginRight: '5px', backgroundColor: 'white' }}
547-
>
531+
<div className="container" style={{ backgroundColor: 'white' }}>
548532
<HeaderDiv className="row">
549533
<TargetDiv className="col-8">
550534
<List>
551535
<ListItem>Target Progress</ListItem>
552536
</List>
553537
</TargetDiv>
554538
<StudentDiv className="col-4">
555-
<ColumnDiv className="container d-inline-block">
539+
<ColumnDiv className="container">
556540
<StudentNameDiv className="container-sm">
557541
{inputUser.firstName}
558542
{inputUser.lastName}

src/Components/SingleStudentMasteryOverview/TargetMasteryCard.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ function getStatusTitle(status: number) {
104104
if (status <= 0.75) {
105105
return 'Not Mastered';
106106
}
107-
if (status >= 0.75) {
107+
if (status > 0.75) {
108108
return 'Almost Mastered';
109109
}
110110
return 'Mastered';
@@ -113,6 +113,7 @@ function getStatusTitle(status: number) {
113113
export default function MasteryCard({ name, status, user }: Props) {
114114
console.log(status);
115115
const history = useHistory();
116+
116117
return (
117118
<Link to={{ pathname: `/singleTargetOverview/${name}`, state: user }}>
118119
<div className="mission-card">

0 commit comments

Comments
 (0)