Skip to content
This repository has been archived by the owner on Dec 25, 2022. It is now read-only.

Commit

Permalink
Add exam mode, Update detail page
Browse files Browse the repository at this point in the history
  • Loading branch information
Nguyen Manh Tung committed Aug 11, 2022
1 parent 35af6a5 commit a5e01fa
Show file tree
Hide file tree
Showing 8 changed files with 658 additions and 39 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This service is for student learn in FPT University.
- Free all time.
- Import from quizlet.
- Export to quizlet.
- Exam mode.

## Installation

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": "quizlet-learn",
"version": "1.0.1",
"version": "1.0.3",
"private": true,
"dependencies": {
"@nextui-org/react": "^1.0.0-beta.9",
Expand Down
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ function App() {
<Route path={'/create'} element={<CreateScreen title={'Create course | AdonisGM'}/>} />
<Route path={'/course/:id'} element={<DetailCourseScreen title={'Detail course | AdonisGM'}/>} />
<Route path={'/learn/:id'} element={<LearnScreen title={'Detail course | AdonisGM'}/>} />
<Route path={'/course/:id/exam'} element={<ExamScreen title={'ExamScreen | AdonisGM'}/>} />
</Route>
<Route path={'/course/:id/exam'} element={<ExamScreen title={'ExamScreen | AdonisGM'}/>} />
<Route path={'*'} element={<NotFoundScreen title={'Not found | AdonisGM'}/>} />
</Routes>
);
Expand Down
87 changes: 61 additions & 26 deletions src/components/DetailCourse/DetailCourse.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import {
Input,
Loading,
Modal,
Dropdown,
Button,
} from '@nextui-org/react';
import classes from './DetailCourse.module.css';
import { RiEyeLine } from 'react-icons/ri';
import { MdKeyboardBackspace } from 'react-icons/md';
import { FcGraduationCap, FcReading, FcFullTrash } from 'react-icons/fc';

function toLowerCaseNonAccentVietnamese(str) {
str = str.toLowerCase();
Expand All @@ -37,7 +39,6 @@ const DetailCourse = () => {
const [searching, setSearching] = useState(false);
const [showModal, setShowModal] = useState(false);
const [selectQuestion, setSelectQuestion] = useState(undefined);
const [statusDelete, setStatusDelete] = useState(1);

const { id } = useParams();
const navigate = useNavigate();
Expand Down Expand Up @@ -78,15 +79,8 @@ const DetailCourse = () => {
};

const handleDelete = () => {
if (statusDelete === 1) {
setStatusDelete(2);
return;
}

if (statusDelete === 2) {
localStorage.removeItem(id);
navigate('/');
}
localStorage.removeItem(id);
navigate('/');
};

const handleButtonLearnPress = () => {
Expand Down Expand Up @@ -132,21 +126,58 @@ const DetailCourse = () => {
List course
</Button>
<div className={classes.buttonHeader}>
<Button
size={'xs'}
auto
flat={statusDelete === 1}
color={'error'}
onPress={handleDelete}
>
Delete
</Button>
<Button auto color={'success'} onPress={handleButtonLearnPress}>
{course.length > 0 &&
course.filter((item) => item.learned === false).length === 0
? 'Reset & learn'
: 'Learn'}
</Button>
<Dropdown disableAnimation>
<Dropdown.Button flat color="secondary">
Actions
</Dropdown.Button>
<Dropdown.Menu
aria-label="Actions"
css={{ $$dropdownMenuWidth: '280px' }}
onAction={(e) => {
switch (e) {
case 'Learn':
handleButtonLearnPress();
break;
case 'Exam':
navigate('/course/' + id + '/exam');
break;
case 'Delete':
handleDelete();
default:
break;
}
}}
>
<Dropdown.Section title={'Actions'}>
<Dropdown.Item
key="Learn"
description="Learn course multiple choice"
color="success"
icon={<FcReading size={20} />}
>
Learn
</Dropdown.Item>
<Dropdown.Item
key="Exam"
description="Exam course with layout EOS 🤣"
color="warning"
icon={<FcGraduationCap size={20} />}
>
Take exam
</Dropdown.Item>
</Dropdown.Section>
<Dropdown.Section title={'Danger Zone'}>
<Dropdown.Item
key="Delete"
description="Delete course, can't be undone"
color="error"
icon={<FcFullTrash size={20} />}
>
Delete
</Dropdown.Item>
</Dropdown.Section>
</Dropdown.Menu>
</Dropdown>
</div>
</div>
{infoCourse !== undefined && courseSearch !== undefined && (
Expand Down Expand Up @@ -177,7 +208,11 @@ const DetailCourse = () => {
}}
squared="true"
size="sm"
value={(course.filter((item) => item.learned === true)).length / (course.length === 0 ? 1 : course.length) * 100}
value={
(course.filter((item) => item.learned === true).length /
(course.length === 0 ? 1 : course.length)) *
100
}
shadow
color="gradient"
status="primary"
Expand Down
Loading

0 comments on commit a5e01fa

Please sign in to comment.