Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
21_22-J 38
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
21_22-J 38
21_22-J 38
Commits
935e189f
Commit
935e189f
authored
May 02, 2022
by
Lihinikaduwa D.N.R.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get Level by userId Done
parent
93e39e4e
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
105 additions
and
58 deletions
+105
-58
API/__pycache__/app.cpython-39.pyc
API/__pycache__/app.cpython-39.pyc
+0
-0
API/app.py
API/app.py
+23
-7
API/model/__pycache__/readModel.cpython-39.pyc
API/model/__pycache__/readModel.cpython-39.pyc
+0
-0
API/model/readModel.py
API/model/readModel.py
+8
-3
frontend/src/component/reading/ReadCategory.js
frontend/src/component/reading/ReadCategory.js
+28
-22
frontend/src/screen/Read.js
frontend/src/screen/Read.js
+34
-1
frontend/src/screen/reading/basic/ReadActivityGo.js
frontend/src/screen/reading/basic/ReadActivityGo.js
+0
-16
frontend/src/screen/reading/basic/ReadActivityNo.js
frontend/src/screen/reading/basic/ReadActivityNo.js
+12
-9
No files found.
API/__pycache__/app.cpython-39.pyc
View file @
935e189f
No preview for this file type
API/app.py
View file @
935e189f
...
...
@@ -191,9 +191,10 @@ def logout():
return
make_response
(
body
)
@
app
.
route
(
"/readingSession"
,
methods
=
[
'POST'
])
def
reading_session
():
token
=
save_session_details
(
1
)
@
app
.
route
(
"/readingSession/<userId>"
,
methods
=
[
'POST'
])
def
reading_session
(
userId
):
assert
userId
==
request
.
view_args
[
'userId'
]
token
=
save_session_details
(
userId
,
1
)
response
=
{
"token"
:
token
,
"message"
:
"Success"
,
...
...
@@ -203,11 +204,11 @@ def reading_session():
return
make_response
(
body
)
@
app
.
route
(
"/readingSession/<
readingToken
>"
,
methods
=
[
'PUT'
])
@
app
.
route
(
"/readingSession/<
userId
>"
,
methods
=
[
'PUT'
])
def
reading_session_status_update
(
readingToken
):
assert
readingToken
==
request
.
view_args
[
'readingToken'
]
token
=
readingToken
token
=
update_session_status
(
token
)
update_session_status
(
token
)
response
=
{
"message"
:
"Success"
,
"status"
:
200
...
...
@@ -219,14 +220,29 @@ def reading_session_status_update(readingToken):
@
app
.
route
(
"/reading/<readingToken>"
,
methods
=
[
'POST'
])
def
save_reading
(
readingToken
):
assert
readingToken
==
request
.
view_args
[
'readingToken'
]
token
=
readingToken
req
=
request
.
get_json
()
word
=
req
[
'word'
]
userId
=
req
[
'userId'
]
level
=
req
[
'level'
]
triedCount
=
req
[
'triedCount'
]
result
=
save_activity_details
(
userId
,
word
,
token
,
level
,
triedCount
)
result
=
save_activity_details
(
userId
,
word
,
readingToken
,
level
,
triedCount
)
response
=
{
"message"
:
"Success"
,
"status"
:
200
}
body
=
jsonify
(
response
)
return
make_response
(
body
)
@
app
.
route
(
"/level/<userId>"
,
methods
=
[
'GET'
])
def
get_completed_levels
(
userId
):
assert
userId
==
request
.
view_args
[
'userId'
]
level
=
get_completed_levels_by_user
(
userId
)
x
=
level
[
0
]
y
=
level
[
1
]
response
=
{
"level1"
:
x
[
0
],
"level2"
:
y
[
0
],
"message"
:
"Success"
,
"status"
:
200
}
...
...
API/model/__pycache__/readModel.cpython-39.pyc
View file @
935e189f
No preview for this file type
API/model/readModel.py
View file @
935e189f
...
...
@@ -27,10 +27,10 @@ def save_activity_details(userId, word, token, level, triedCount):
return
result
def
save_session_details
(
status
):
def
save_session_details
(
userId
,
status
):
token
=
getUUID
()
qry
=
'INSERT INTO readingSession (id,
token,status) VALUES (NULL
,
%
s,
%
s)'
args
=
(
token
,
status
)
qry
=
'INSERT INTO readingSession (id,
userId,token,status) VALUES (NULL,
%
s
,
%
s,
%
s)'
args
=
(
userId
,
token
,
status
)
insert
(
qry
,
args
)
return
token
...
...
@@ -38,3 +38,8 @@ def save_session_details(status):
def
update_session_status
(
token
):
qry
=
'UPDATE readingSession SET status = 0 WHERE token = "{}"'
.
format
(
token
)
return
update_data
(
qry
)
def
get_completed_levels_by_user
(
userId
):
qry
=
'SELECT level FROM readingSession WHERE userId = "{}"'
.
format
(
userId
)
return
get_data
(
qry
)
frontend/src/component/reading/ReadCategory.js
View file @
935e189f
...
...
@@ -13,7 +13,7 @@ import Client from '../../screen/client/Client';
import
AsyncStorage
from
'
@react-native-async-storage/async-storage
'
;
const
ReadCategory
=
props
=>
{
const
{
title
,
image
,
i
d
,
color
,
path
}
=
props
;
const
{
title
,
image
,
i
sDisable
,
path
}
=
props
;
const
navigation
=
useNavigation
();
...
...
@@ -21,10 +21,8 @@ const ReadCategory = props => {
AsyncStorage
.
getItem
(
'
readingSession
'
)
.
then
(
value
=>
{
if
(
value
==
null
)
{
console
.
log
(
'
bfxcvbfvfdxv
'
,
value
);
getReadingSession
(
value
);
createReadingSession
(
value
);
}
else
{
console
.
log
(
'
bfxcvbfvfdxv
'
);
navigation
.
navigate
(
path
);
}
})
...
...
@@ -33,34 +31,42 @@ const ReadCategory = props => {
});
};
const
getReadingSession
=
()
=>
{
Client
.
post
(
'
readingSession
'
,
{
headers
:
{
Accept
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
},
})
.
then
(
res
=>
{
console
.
log
(
res
.
data
);
if
(
res
.
status
==
200
)
{
console
.
log
(
res
.
data
);
const
token
=
res
.
data
.
token
;
try
{
AsyncStorage
.
setItem
(
'
readingSession
'
,
token
);
}
catch
(
error
)
{
const
createReadingSession
=
()
=>
{
AsyncStorage
.
getItem
(
'
userId
'
)
.
then
(
userId
=>
{
Client
.
post
(
'
readingSession/
'
+
userId
,
{
headers
:
{
Accept
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
},
})
.
then
(
res
=>
{
console
.
log
(
res
.
data
);
if
(
res
.
status
==
200
)
{
const
token
=
res
.
data
.
token
;
try
{
AsyncStorage
.
setItem
(
'
readingSession
'
,
token
);
}
catch
(
error
)
{
console
.
log
(
error
);
}
navigation
.
navigate
(
path
);
}
})
.
catch
(
error
=>
{
console
.
log
(
error
);
}
navigation
.
navigate
(
path
);
}
});
})
.
catch
(
error
=>
{
console
.
log
(
error
);
});
};
return
(
<
View
style
=
{
styles
.
gameItem
}
>
<
TouchableOpacity
disabled
=
{
false
}
onPress
=
{()
=>
{
checkReadingSession
();
}}
>
...
...
frontend/src/screen/Read.js
View file @
935e189f
...
...
@@ -21,9 +21,12 @@ import ImageButton from '../component/ImageButton';
import
ButtonView
from
'
../component/buttonView
'
;
import
ReadCategory
from
'
../component/reading/ReadCategory
'
;
import
{
ImagePaths
}
from
'
../assets/read/data/ReadData
'
;
import
AsyncStorage
from
'
@react-native-async-storage/async-storage
'
;
import
Client
from
'
./client/Client
'
;
export
default
function
Read
()
{
const
[
activity
,
setActivity
]
=
useState
([]);
const
[
level1
,
setLevel1
]
=
useState
([]);
const
[
level2
,
setLevel2
]
=
useState
([]);
const
navigation
=
useNavigation
();
...
...
@@ -39,6 +42,35 @@ export default function Read() {
return
unsubscribe
;
},
[
navigation
]);
useEffect
(()
=>
{
getCompletedLevel
();
},
[
navigation
]);
const
getCompletedLevel
=
()
=>
{
AsyncStorage
.
getItem
(
'
userId
'
)
.
then
(
value
=>
{
Client
.
get
(
'
level/
'
+
value
,
{
headers
:
{
Accept
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
},
})
.
then
(
res
=>
{
console
.
log
(
res
.
data
);
setLevel1
(
res
.
data
.
level1
);
setLevel2
(
res
.
data
.
level2
);
})
.
catch
(
error
=>
{
console
.
log
(
error
);
});
})
.
catch
(
error
=>
{
console
.
log
(
error
);
});
console
.
log
(
'
getCompletedLevel
'
,
level1
,
level2
);
};
return
(
<
SafeAreaView
>
<
ScrollView
>
...
...
@@ -51,6 +83,7 @@ export default function Read() {
</View> */
}
<
TouchableOpacity
style
=
{
styles
.
screen
}
>
<
ReadCategory
isDisable
=
{
''
}
title
=
{
'
Basic
'
}
image
=
{
ImagePaths
.
roundOne
}
path
=
{
'
ReadActivityNo
'
}
...
...
frontend/src/screen/reading/basic/ReadActivityGo.js
View file @
935e189f
...
...
@@ -84,14 +84,6 @@ export default function ReadActivityGo() {
}
};
const
stopRecording
=
async
()
=>
{
try
{
await
Voice
.
stop
();
}
catch
(
error
)
{
console
.
log
(
error
);
}
};
return
(
<
SafeAreaView
>
<
View
style
=
{{
flexDirection
:
'
column
'
}}
>
...
...
@@ -108,14 +100,6 @@ export default function ReadActivityGo() {
<
Text
style
=
{
styles
.
text
}
>
Pronounce
this
Word
!<
/Text
>
<
/View
>
<
/View
>
{
/* <View style={styles.textBody}>
<Text style={styles.text}>Pronounce this Word!</Text>
</View>
<View style={styles.robo}>
<Image
source={require('../../assets/read/activity-2-rob.png')}></Image>
</View> */
}
<
View
>
<
Image
style
=
{
styles
.
blackboard
}
source
=
{
ImagePaths
.
go
}
><
/Image
>
<
/View
>
...
...
frontend/src/screen/reading/basic/ReadActivityNo.js
View file @
935e189f
...
...
@@ -40,15 +40,7 @@ export default function ReadActivityNo() {
};
},
[]);
const
getToken
=
data
=>
{
AsyncStorage
.
getItem
(
'
readingSession
'
)
.
then
(
readingSession
=>
{
sendRedingData
(
data
,
readingSession
);
})
.
catch
(
error
=>
{
console
.
log
(
error
);
});
};
const
sendRedingData
=
(
data
,
readingSession
)
=>
{
Client
.
post
(
'
reading/
'
+
readingSession
,
JSON
.
stringify
(
data
),
{
...
...
@@ -104,6 +96,17 @@ export default function ReadActivityNo() {
console
.
log
(
'
count
'
,
count
);
};
const
getToken
=
data
=>
{
AsyncStorage
.
getItem
(
'
readingSession
'
)
.
then
(
readingSession
=>
{
console
.
log
(
'
correct
'
,
readingSession
);
sendRedingData
(
data
,
readingSession
);
})
.
catch
(
error
=>
{
console
.
log
(
error
);
});
};
const
startRecording
=
async
()
=>
{
try
{
await
Voice
.
start
(
'
en-US
'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment