Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import InformedConsent from './src/InformedConsent';
import InitialSurvey from './src/InitialSurvey';
import PuzzleManager from './src/PuzzleManager';
import Tutorial from './src/Tutorial';
import Debug from './debug';
// import Debug from './debug';
import CategoryInput from './src/CategoryInput';
import ViewPuzzles from './src/ViewPuzzles';
import HomePage from './src/home';
Expand Down Expand Up @@ -75,7 +75,7 @@ let PlayPuzzle = () => {
const param = queryParameters.get("puzzle")


try{
try {
const decom = lzString.decompressFromEncodedURIComponent(param)
console.log("decom" + decom)
puzzleObj = JSON.parse(decom)
Expand Down
633 changes: 626 additions & 7 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,34 @@
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"web": "expo start --web",
"predeploy": "expo export -p web",
"deploy-hosting": "npm run predeploy && firebase deploy --only hosting"
"deploy-hosting": "npm run predeploy && firebase deploy --only hosting"
},
"dependencies": {
"@cyntler/react-doc-viewer": "^1.14.1",
"@emotion/styled": "^11.14.0",
"@expo/metro-runtime": "~3.1.3",
"@mui/material": "^6.4.6",
"@react-native-firebase/app": "^19.0.1",
"@react-pdf-viewer/core": "^3.12.0",
"@react-pdf/renderer": "^3.4.1",
"axios": "^1.6.7",
"expo": "^50.0.7",
"expo-status-bar": "~1.11.1",
"firebase": "^10.9.0",
"lz-string": "^1.5.0",
"mui": "^0.0.1",
"pdfjs-dist": "^3.4.120",
"pspdfkit": "^2024.2.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.73.4",
"react-native-web": "~0.19.6",
"react-pdf": "^7.7.1",
"reactjs-popup": "^2.0.6"
"react-to-print": "^3.0.5",
"reactjs-popup": "^2.0.6",
"string-similarity-js": "^2.1.4"
},
"devDependencies": {
"@babel/core": "^7.20.0"
Expand Down
17 changes: 14 additions & 3 deletions src/API/GetFromApi.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {api, API_URL, SAMPLE_CAT_URL, GET_LIKED_PUZZLES, GET_UNUSED_GRAMMARS, GET_TEMPLATE, GET_BRAINSTORMS, GET_SCEN, ADD_CLICK, NEW_SESSION} from './config'

import {api, API_URL, SAMPLE_CAT_URL, GET_LIKED_PUZZLES, GET_AVAILABLE_MOVES, GET_UNUSED_GRAMMARS, GET_TEMPLATE, GET_BRAINSTORMS, GET_SCEN, ADD_CLICK, NEW_SESSION} from './config'

let getLikedPuzzles = async(user) => {
if (user == null){
Expand All @@ -15,6 +14,17 @@ let getLikedPuzzles = async(user) => {
}
}

let getAvailableMoves = async(puzzleDesc, currGrid) => {
response = await api.post(GET_AVAILABLE_MOVES, {puzzle: puzzleDesc, currGrid: currGrid})

if (response.status <= 300){
return response.data
}else{

return null
}
}

let get_unused_grammar = async(cats, user=null) => {

response = await api.post(GET_UNUSED_GRAMMARS, {cats:cats, username:user})
Expand Down Expand Up @@ -98,4 +108,5 @@ let get_before_brainstorm = async(cat1, cat2, num_cat, user) => {



export {getSampleCategories, getLikedPuzzles, get_unused_grammar, get_is_template, get_not_template, get_before_template, get_or_template, get_before_brainstorm, get_is_brainstorm, get_not_brainstorm,get_or_brainstorm, getScenarios}

export { get_before_brainstorm, get_before_template, get_is_brainstorm, get_is_template, get_not_brainstorm, get_not_template, get_or_brainstorm, get_or_template, get_unused_grammar, getLikedPuzzles, getSampleCategories, getAvailableMoves, getScenarios }
4 changes: 0 additions & 4 deletions src/API/SendToApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ let add_cat = async (cat, user) => {
request = {"user": user, "category": cat}
response = await api.post(ADD_CATEGORY, request)
return response



}


Expand Down Expand Up @@ -181,7 +178,6 @@ let add_or = async (cat1, cat2, is_cat, template, user) => {
}



let add_is_brain = async (cat1, cat2, template, user) => {
request = {"user": user, "cat1": cat1, "cat2": cat2, "template": template, type:"is"}
response = await api.post(ADD_BRAINSTORM, request)
Expand Down
3 changes: 2 additions & 1 deletion src/API/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const LIKE_PUZZLE = API_URL + "/like_puzzle"
const REMOVE_PUZZLE = API_URL + "/remove_puzzle"
const UPDATE_PUZZLE = API_URL + "/update_puzzle"
const GET_LIKED_PUZZLES = API_URL + "/get_liked_puzzles"
const GET_AVAILABLE_MOVES = API_URL + "/get_available_moves"
const ITER_EVOLVE = API_URL + "/iterate_map_evolve"
const GET_UNUSED_GRAMMARS = API_URL + "/get_unused_grammar"
const ADD_GRAMMAR_RULE = API_URL + "/add_grammar_rule"
Expand Down Expand Up @@ -40,5 +41,5 @@ const api = _axios.create( {credentials: false});
api.interceptors.request.use(handleRes, handleErr);
api.interceptors.response.use(handleRes, handleErr);

export { API_URL, EVOLVE_URL, REMOVE_PUZZLE, UPDATE_PUZZLE, SAMPLE_CAT_URL, ADD_ACCOUNT_URL, LIKE_PUZZLE, GET_LIKED_PUZZLES, ITER_EVOLVE, GET_UNUSED_GRAMMARS, ADD_GRAMMAR_RULE, ADD_CATEGORY, GET_TEMPLATE, GET_PUBLIC_KEY, api, GET_BRAINSTORMS, ADD_BRAINSTORM, GET_SCEN, ADD_SCEN, NEW_SESSION, ADD_CLICK };
export { API_URL, EVOLVE_URL, REMOVE_PUZZLE, UPDATE_PUZZLE, SAMPLE_CAT_URL, ADD_ACCOUNT_URL, LIKE_PUZZLE, GET_LIKED_PUZZLES, ITER_EVOLVE, GET_UNUSED_GRAMMARS, ADD_GRAMMAR_RULE, ADD_CATEGORY, GET_TEMPLATE, GET_PUBLIC_KEY, api, GET_BRAINSTORMS, ADD_BRAINSTORM, GET_SCEN, ADD_SCEN, NEW_SESSION, ADD_CLICK, GET_AVAILABLE_MOVES };

1 change: 0 additions & 1 deletion src/CategoryInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ let CategoryMaker = ({categories, setCategories, index, numEntities, sessionId,
let save_categories = () => {
add_cat(categories[index], user)
can_save = false

}


Expand Down
2 changes: 1 addition & 1 deletion src/EditBrainstorm.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ let EditBefore = ({categories, user, sessionId, sessionStart}) => {
let catNames = categories.map((value, idx) => {return <option key={idx} value={value.name}>{value.name}</option>})
catNames = [<option key={-1} value={null}>Select....</option>].concat(catNames)

let numCatName = categories.filter((value) => value.is_numerical = true).map((value, idx) => {return <option key={idx} value={value.name}>{value.name}</option>})
let numCatName = categories.filter((value) => value.is_numeric = true).map((value, idx) => {return <option key={idx} value={value.name}>{value.name}</option>})
numCatName = [<option key={-1} value={null}>Select....</option>].concat(numCatName)

create = <div>
Expand Down
2 changes: 1 addition & 1 deletion src/EditTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ let EditBefore = ({empty, categories, user, update, sessionId, sessionStart}) =>
let catNames = categories.map((value, idx) => {return <option key={idx} value={value.name}>{value.name}</option>})
catNames = [<option key={-1} value={null}>Select....</option>].concat(catNames)

let numCatName = categories.filter((value) => value.is_numerical = true && value.name != cat1 && value.name != cat2).map((value, idx) => {return <option key={idx} value={value.name}>{value.name}</option>})
let numCatName = categories.filter((value) => value.is_numeric = true && value.name != cat1 && value.name != cat2).map((value, idx) => {return <option key={idx} value={value.name}>{value.name}</option>})
numCatName = [<option key={-1} value={null}>Select....</option>].concat(numCatName)

create = <div>
Expand Down
8 changes: 5 additions & 3 deletions src/EndPuzzleButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let CorrectPop = ({isCorrect, time}) => {
</div>)
};

export default FinishButtons = ({ giveUp, isCorrect, clearPuzzle, puzzle, finish,instanceId, time}) => {
export default FinishButtons = ({ giveUp, isCorrect, clearPuzzle, showNextMove, puzzle, finish,instanceId, time}) => {

let checkSolution = () => {

Expand All @@ -34,8 +34,10 @@ export default FinishButtons = ({ giveUp, isCorrect, clearPuzzle, puzzle, finish
<button onClick = {checkSolution}> Check my Solution</button>

<button onClick={clearPuzzle}>Clear Solution</button>



<button onClick={showNextMove}>Show Next Move</button>

<br/>
</div>)
let resetButtons = () => {
setShowPopup(false)
Expand Down
2 changes: 1 addition & 1 deletion src/PuzzleManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function createPuzzle(data) {
let categories = []
for (cat in data.categories) {
cat = data.categories[cat]
categories.push(new Category(cat.name, cat.entities))
categories.push(new Category(cat.name, cat.entities, cat.is_numeric))
}

return new PuzzleModel(categories, data.hints, data.solution, data.id)
Expand Down
4 changes: 3 additions & 1 deletion src/SelectedPuzzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ export default selectedPuzzle = ({puzzle, setPuzzle, user, r, appMode, sessionId

let [mode, setMode] = useState("view")
let [puzzleToEdit, setPuzzleToEdit] = useState(null)

console.log(puzzle)


let model = createPuzzle(puzzle)

let [playable, setPlayable] = useState(<Puzzle className="playable" p={model}/>)
let [playable, setPlayable] = useState(<Puzzle className="playable" p={model} />)
let [content, setContent] = useState(playable)

useEffect(()=>{
Expand Down
4 changes: 2 additions & 2 deletions src/ViewPuzzles.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ let CreateHintFilter = ({filter, setFilter, categories}) => {
}else if (attr == "num_cat"){
idx = 4

catNames = [<option value={""}>{"Select category"}</option>].concat(categories.filter((value) => value.is_numerical = true).map((value, idx) => {return <option key={idx} value={value.name}>{value.name}</option>}))
catNames = [<option value={""}>{"Select category"}</option>].concat(categories.filter((value) => value.is_numeric = true).map((value, idx) => {return <option key={idx} value={value.name}>{value.name}</option>}))
}

return <select value={attrs[idx]} onChange={(e) => {
Expand Down Expand Up @@ -240,7 +240,7 @@ export default ViewPuzzles = ({puzzles, user, setPuzzles, mode, sessionId, sessi
setHintRange(newValue);
};

console.log(hasHints(hintFilters, puzzles))
console.log(puzzles)


let puzzleList = filterBySolution(filter, hasHints(hintFilters, puzzles)).filter((puzzle) => (puzzle.diff >= diffRange[0] && puzzle.diff <= diffRange[1]) && (puzzle.hints.length >= hintRange[0] && puzzle.hints.length <= hintRange[1]))
Expand Down
3 changes: 2 additions & 1 deletion src/categoryModel.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export default class Category{
constructor(name, entities){
constructor(name, entities, is_numeric){
this.entities = entities;
this.name = name;
this.length = entities.length;
this.is_numeric = is_numeric;
}
}
15 changes: 13 additions & 2 deletions src/cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ let toggleState = (s, setState, select) => {
export default Cell = ({ state, setState, mousedown = false, topText = "", leftText = "", select = "*" }) => {

let className = "";
let text = ""
let text = "";
let locked = false;

if (state == "X") {
className = "notlinked"
Expand All @@ -31,8 +32,18 @@ export default Cell = ({ state, setState, mousedown = false, topText = "", leftT
className = "notlinkedUnsure"
text = "X"
}
else if (state == "x") {
className = "linkedLocked"
text = "X"
locked = true
} else if (state == "o") {
className = "notLinkedLocked"
text = "O"
locked = true
}


return (<div className="cell" onMouseDown={() => { toggleState(state, setState, select) }} onMouseEnter={() => { if (mousedown) { toggleState(state, setState, select) } }}>
return (<div className="cell" onMouseDown={() => { toggleState(state, setState, select) }} onMouseEnter={locked? () => {} : () => { if (mousedown) { toggleState(state, setState, select) } }}>

<span className={className}> {text}</span>

Expand Down
Loading