Skip to content

Commit 442a6f7

Browse files
committed
fixed bugs
1 parent 0d78f6e commit 442a6f7

File tree

17 files changed

+125
-90
lines changed

17 files changed

+125
-90
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"react-dnd": "^14.0.2",
3232
"react-dnd-html5-backend": "^14.0.0",
3333
"react-dom": "^17.0.1",
34+
"react-keyboard": "^1.0.8",
3435
"react-router-dom": "^5.2.0",
3536
"react-scripts": "^4.0.2",
3637
"react-spring": "^9.0.0",
@@ -79,4 +80,4 @@
7980
"target": "deb"
8081
}
8182
}
82-
}
83+
}

public/electron.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ function createWindow(windowState) {
2222
webPreferences: {
2323
preload: path.join(__dirname, 'preload.js'),
2424
nodeIntegration: true,
25-
enableRemoteModule: true
25+
enableRemoteModule: true,
26+
webSecurity: false
2627
},
2728
preload: path.join(__dirname, "preload.js")
2829
})
@@ -56,12 +57,13 @@ app.whenReady().then(() => {
5657

5758
// allow the window state to be managed
5859
windowState.manage(win)
59-
60+
/*
6061
// register the custom file protocol for getting images dynamically
61-
protocol.registerFileProtocol('imgid', (request, callback) => {
62-
const url = request.url.substring(8) //get the path to the requested image
62+
protocol.registerFileProtocol('file', (request, callback) => {
63+
const url = decodeURI(request.url.replace('file://', '')) //get the path to the requested image
6364
callback({ path: path.join(dataFolder, ".images", url) }) // return the requested image
6465
})
66+
*/
6567

6668
// boilerplate for MacOS
6769
app.on('activate', function () {

src/Components/CreateListFab.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function CreateListFab(props) {
8888
return (
8989
<div>
9090
{/* BUTTON */}
91-
<Fab variant="extended" style={{ backgroundColor: "white" }} onClick={OpenMenu}>
91+
<Fab variant="extended" style={{ backgroundColor: "white", left: "17vw", position: "absolute" }} onClick={OpenMenu}>
9292
<AddIcon style={{ opacity: 0.7 }} />
9393
Create
9494
</Fab>

src/Components/ListGrid.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function ListGrid(props) {
3636
<DndProvider backend={HTML5Backend}> {/* Allow for drag and drop using react-dnd */}
3737
{/* display the "ListItem" component for each item, first looping through rows and then looping through each item in that row */}
3838
{items.map((row, i) => (
39-
<Grid container spacing={3} style={{ top: `${props.top + (i * (height + verticalSpacing))}%`, position: "absolute", height: `${height}%` }}>
39+
<Grid container spacing={0} style={{ top: `${props.top + (i * (height + verticalSpacing))}%`, position: "absolute", height: `${height}%` }}>
4040
<Grid item xs={2}></Grid>
4141

4242
{row.map((item, j) => (

src/Components/ListItem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ function ListItem(props) {
170170
{props.name}
171171
</span>
172172
</Box>
173-
<Box style={{ width: '3.18vh', height: '3.18vh', backgroundColor: "white", position: "absolute", top: "10%", left: "70%", borderBottomRightRadius: "50%", borderTopRightRadius: "50%" }} ></Box>
173+
<Box style={{ width: '3.19vh', height: '3.19vh', backgroundColor: "white", position: "absolute", top: "10%", left: "70%", borderBottomRightRadius: "50%", borderTopRightRadius: "50%" }} ></Box>
174174
<IconButton onClick={openMenu} style={{ position: "absolute", right: "-5%", top: "5%" }}>
175175
<MoreVertIcon />
176176
</IconButton>

src/Components/MultiAnswer.js

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import React from 'react'
22
import { Grid, Fab, Paper } from '@material-ui/core'
3+
import { HotKeys, Handlers } from 'react-keyboard'
4+
5+
const keyMap = {
6+
selectOne: "1",
7+
selectTwo: "2",
8+
selectThree: "3",
9+
selectFour: "4"
10+
}
311

412
// colour setup to dynamically draw the colour of an item
513
const colors = {
614
standard: "#ffffff",
7-
selected: "#548BDF"
815
}
916

1017
/**
@@ -13,44 +20,46 @@ const colors = {
1320
* @return {JSX} - the JSX of the component
1421
*/
1522
function MultiAnswer(props) {
16-
const [selected, setSelected] = React.useState(null) // state for storing the selected item
1723

18-
const submit = (e) => { // function that handles when an answer is submitted
19-
let s = selected
20-
setSelected(null)
24+
const submit = (index) => { // function that handles when an answer is submitted
25+
let s = index
2126
let correct = (s === props.question["CORRECT"])
2227
props.correctAnswer(correct)
2328
}
2429

2530
const handleSelect = (index) => { // function that handles when an answer is selected
26-
if (selected === index) { // if it is already selected, deselect it
27-
setSelected(null)
28-
} else { // otherwise change the highlighted item to the clicked one
29-
setSelected(index)
31+
if (props.question["ANSWERS"].length > index) {
32+
submit(index)
3033
}
3134
}
3235

36+
const handlers = {
37+
selectOne: () => handleSelect(0),
38+
selectTwo: () => handleSelect(1),
39+
selectThree: () => handleSelect(2),
40+
selectFour: () => handleSelect(3),
41+
}
42+
3343
return (
34-
<Grid container style={{ position: "absolute", bottom: "15%" }}>
35-
<Grid item xs={4}></Grid>
36-
<Grid item container spacing={3} xs={4}>
37-
{props.question["ANSWERS"].map((answer, i) => {
38-
return (
39-
<Grid item xs={6}>
40-
<Paper onClick={() => (handleSelect(i))} elevation={3} style={{ width: "100%", height: "5vh", borderRadius: "10px", backgroundColor: selected === i ? colors.selected : colors.standard }}>
41-
<p style={{ fontSize: 20, paddingTop: "1.4vh" }}>
42-
{answer}
43-
</p>
44-
</Paper>
45-
</Grid>
46-
)
47-
})}
48-
</Grid>
49-
<Grid item xs={1}></Grid>
50-
<Grid item xs={1}>
51-
<div style={{ paddingTop: "2vh" }}><Fab variant="extended" onClick={submit} style={{ backgroundColor: "white" }}>Submit</Fab></div>
44+
<HotKeys keyMap={keyMap} handlers={handlers}>
45+
<Grid container style={{ position: "absolute", bottom: "15%" }}>
46+
<Grid item xs={4}></Grid>
47+
<Grid item container spacing={3} xs={4}>
48+
{props.question["ANSWERS"].map((answer, i) => {
49+
return (
50+
<Grid item xs={6}>
51+
<Paper onClick={() => (handleSelect(i))} elevation={3} style={{ width: "100%", height: "5vh", borderRadius: "10px", backgroundColor: colors.standard }}>
52+
<p style={{ position: "absolute", paddingLeft: "1vw", opacity: 0.7 }}>{i + 1}</p>
53+
<p style={{ fontSize: 20, paddingTop: "1vh" }}>
54+
{answer}
55+
</p>
56+
</Paper>
57+
</Grid>
58+
)
59+
})}
60+
</Grid>
5261
</Grid>
53-
</Grid>
62+
</HotKeys>
5463
)
5564
}
5665

src/Components/QuestionMulti.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react'
22
import { Grid, TextField, Fab, Menu, MenuItem } from '@material-ui/core'
33
import ArrowLeftIcon from '@material-ui/icons/ArrowLeft'
4+
import { HotKeys, Handlers } from 'react-keyboard';
45

56
/**
67
* @function QuestionMulti - Component that handles the creation of multiple choice answers
@@ -27,16 +28,13 @@ function QuestionMulti(props) {
2728
setSelected(i)
2829
}
2930

30-
// const keyPress = (e, i) => {
31-
// if (e.key === 'Enter' && e.shiftKey) {
32-
// e.preventDefault()
33-
// props.addQuestion()
34-
// } else if (e.key === 'Enter') {
35-
// e.preventDefault()
36-
// props.addAnswer()
37-
// // refs[i + 1].current.focus()
38-
// }
39-
// }
31+
const keyPress = (e) => {
32+
if (e.key === 'Enter') {
33+
e.preventDefault()
34+
props.addQuestion()
35+
// refs[i + 1].current.focus()
36+
}
37+
}
4038

4139
const onFocus = (e, i) => {
4240

src/Components/SaveButton.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
import { Fab } from '@material-ui/core';
23
import SaveIcon from '@material-ui/icons/Save';
34

@@ -6,12 +7,17 @@ import SaveIcon from '@material-ui/icons/Save';
67
* @return {JSX} - The JSX for the component
78
*/
89
function SaveButton() {
9-
return (
10-
<Fab type="sumbit" variant="extended" size="small" style={{ backgroundColor: "white", top: "2%", right: "5%", position: "absolute" }}>
11-
<SaveIcon style={{ opacity: 0.7 }} />
12-
Save
13-
</Fab>
14-
)
10+
return (
11+
<Fab
12+
type="sumbit"
13+
variant="extended"
14+
size="small"
15+
style={{ backgroundColor: "white", top: "2%", right: "5%", position: "absolute" }}
16+
>
17+
<SaveIcon style={{ opacity: 0.7 }} />
18+
Save
19+
</Fab>
20+
)
1521
}
1622

1723
export default SaveButton;

src/Components/SortMenu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function SortMenu(props) {
3535

3636
return (
3737
<div style={{ backgroundColor: "white", paddingRight: "3%" }}>
38-
<Fab variant="extended" style={{ backgroundColor: "white", width: 150, fontSize: 14 }} onClick={openMenu}>
38+
<Fab variant="extended" style={{ backgroundColor: "white", width: 150, fontSize: 14, position: "absolute", right: "20vw" }} onClick={openMenu}>
3939
<SortByAlphaIcon style={{ position: "absolute", left: 10, opacity: 0.7 }} />
4040
<p style={{ textAlign: "center" }}>{sortOptions[selectedIndex]}</p>
4141
<ArrowLeftIcon style={{ position: 'absolute', right: 10, opacity: 0.7 }} />

src/Components/Welcome.js

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

0 commit comments

Comments
 (0)