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
28cba3bb
Commit
28cba3bb
authored
May 01, 2022
by
Lihinikaduwa D.N.R.
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'it18257632' into 'master'
It18257632 See merge request
!174
parents
6ba28c5f
93e39e4e
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
85 additions
and
60 deletions
+85
-60
API/app.py
API/app.py
+3
-5
API/model/__pycache__/readModel.cpython-39.pyc
API/model/__pycache__/readModel.cpython-39.pyc
+0
-0
API/model/readModel.py
API/model/readModel.py
+3
-3
frontend/src/component/reading/ReadCategory.js
frontend/src/component/reading/ReadCategory.js
+18
-5
frontend/src/screen/auth/Login.js
frontend/src/screen/auth/Login.js
+2
-1
frontend/src/screen/client/Client.js
frontend/src/screen/client/Client.js
+1
-1
frontend/src/screen/reading/advanced/ReadActivityBird.js
frontend/src/screen/reading/advanced/ReadActivityBird.js
+1
-8
frontend/src/screen/reading/basic/ReadActivityNo.js
frontend/src/screen/reading/basic/ReadActivityNo.js
+57
-37
No files found.
API/app.py
View file @
28cba3bb
...
@@ -193,9 +193,7 @@ def logout():
...
@@ -193,9 +193,7 @@ def logout():
@
app
.
route
(
"/readingSession"
,
methods
=
[
'POST'
])
@
app
.
route
(
"/readingSession"
,
methods
=
[
'POST'
])
def
reading_session
():
def
reading_session
():
req
=
request
.
get_json
()
token
=
save_session_details
(
1
)
userId
=
req
[
'userId'
]
token
=
save_session_details
(
userId
,
1
)
response
=
{
response
=
{
"token"
:
token
,
"token"
:
token
,
"message"
:
"Success"
,
"message"
:
"Success"
,
...
@@ -219,7 +217,7 @@ def reading_session_status_update(readingToken):
...
@@ -219,7 +217,7 @@ def reading_session_status_update(readingToken):
@
app
.
route
(
"/reading/<readingToken>"
,
methods
=
[
'POST'
])
@
app
.
route
(
"/reading/<readingToken>"
,
methods
=
[
'POST'
])
def
reading
(
readingToken
):
def
save_
reading
(
readingToken
):
assert
readingToken
==
request
.
view_args
[
'readingToken'
]
assert
readingToken
==
request
.
view_args
[
'readingToken'
]
token
=
readingToken
token
=
readingToken
req
=
request
.
get_json
()
req
=
request
.
get_json
()
...
@@ -237,4 +235,4 @@ def reading(readingToken):
...
@@ -237,4 +235,4 @@ def reading(readingToken):
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
app
.
run
(
host
=
'192.168.1.10
0
'
)
app
.
run
(
host
=
'192.168.1.10
1
'
)
API/model/__pycache__/readModel.cpython-39.pyc
View file @
28cba3bb
No preview for this file type
API/model/readModel.py
View file @
28cba3bb
...
@@ -27,10 +27,10 @@ def save_activity_details(userId, word, token, level, triedCount):
...
@@ -27,10 +27,10 @@ def save_activity_details(userId, word, token, level, triedCount):
return
result
return
result
def
save_session_details
(
userId
,
status
):
def
save_session_details
(
status
):
token
=
getUUID
()
token
=
getUUID
()
qry
=
'INSERT INTO readingSession (id,
userId,token,status) VALUES (NULL,
%
s
,
%
s,
%
s)'
qry
=
'INSERT INTO readingSession (id,
token,status) VALUES (NULL
,
%
s,
%
s)'
args
=
(
userId
,
token
,
status
)
args
=
(
token
,
status
)
insert
(
qry
,
args
)
insert
(
qry
,
args
)
return
token
return
token
...
...
frontend/src/component/reading/ReadCategory.js
View file @
28cba3bb
...
@@ -17,11 +17,24 @@ const ReadCategory = props => {
...
@@ -17,11 +17,24 @@ const ReadCategory = props => {
const
navigation
=
useNavigation
();
const
navigation
=
useNavigation
();
const
checkReadingSession
=
()
=>
{
AsyncStorage
.
getItem
(
'
readingSession
'
)
.
then
(
value
=>
{
if
(
value
==
null
)
{
console
.
log
(
'
bfxcvbfvfdxv
'
,
value
);
getReadingSession
(
value
);
}
else
{
console
.
log
(
'
bfxcvbfvfdxv
'
);
navigation
.
navigate
(
path
);
}
})
.
catch
(
error
=>
{
console
.
log
(
error
);
});
};
const
getReadingSession
=
()
=>
{
const
getReadingSession
=
()
=>
{
const
data
=
{
Client
.
post
(
'
readingSession
'
,
{
userId
:
1
,
};
Client
.
post
(
'
readingSession
'
,
JSON
.
stringify
(
data
),
{
headers
:
{
headers
:
{
Accept
:
'
application/json
'
,
Accept
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
...
@@ -49,7 +62,7 @@ const ReadCategory = props => {
...
@@ -49,7 +62,7 @@ const ReadCategory = props => {
<
View
style
=
{
styles
.
gameItem
}
>
<
View
style
=
{
styles
.
gameItem
}
>
<
TouchableOpacity
<
TouchableOpacity
onPress
=
{()
=>
{
onPress
=
{()
=>
{
get
ReadingSession
();
check
ReadingSession
();
}}
>
}}
>
<
View
>
<
View
>
{
/* <View style={{...styles.gameItemRow, ...styles.gameItemHeader}}> */
}
{
/* <View style={{...styles.gameItemRow, ...styles.gameItemHeader}}> */
}
...
...
frontend/src/screen/auth/Login.js
View file @
28cba3bb
...
@@ -74,6 +74,7 @@ const Login = () => {
...
@@ -74,6 +74,7 @@ const Login = () => {
};
};
const
submitForm
=
()
=>
{
const
submitForm
=
()
=>
{
AsyncStorage
.
setItem
(
'
userId
'
,
'
1
'
);
navigation
.
navigate
(
'
Start
'
);
navigation
.
navigate
(
'
Start
'
);
// if (isValidForm()) {
// if (isValidForm()) {
// loginFun(userInfo);
// loginFun(userInfo);
...
@@ -100,7 +101,7 @@ const Login = () => {
...
@@ -100,7 +101,7 @@ const Login = () => {
const
userToken
=
res
.
data
.
token
;
const
userToken
=
res
.
data
.
token
;
const
userId
=
res
.
data
.
userId
;
const
userId
=
res
.
data
.
userId
;
AsyncStorage
.
setItem
(
'
userToken
'
,
userToken
);
AsyncStorage
.
setItem
(
'
userToken
'
,
userToken
);
AsyncStorage
.
setItem
(
'
userId
'
,
userId
);
AsyncStorage
.
setItem
(
'
userId
'
,
1
);
return
navigation
.
navigate
(
'
Start
'
);
return
navigation
.
navigate
(
'
Start
'
);
}
}
})
})
...
...
frontend/src/screen/client/Client.js
View file @
28cba3bb
...
@@ -2,6 +2,6 @@ import axios from 'axios';
...
@@ -2,6 +2,6 @@ import axios from 'axios';
// export default axios.create({ baseURL: 'http://192.168.8.102:5000/', timeout: 15000, });
// export default axios.create({ baseURL: 'http://192.168.8.102:5000/', timeout: 15000, });
export
default
axios
.
create
({
export
default
axios
.
create
({
baseURL
:
'
http://192.168.1.10
0
:5000/
'
,
baseURL
:
'
http://192.168.1.10
1
:5000/
'
,
timeout
:
15000
,
timeout
:
15000
,
});
});
frontend/src/screen/reading/advanced/ReadActivityBird.js
View file @
28cba3bb
...
@@ -14,7 +14,7 @@ import {
...
@@ -14,7 +14,7 @@ import {
TouchableHighlight
,
TouchableHighlight
,
}
from
'
react-native
'
;
}
from
'
react-native
'
;
import
Voice
from
'
@react-native-voice/voice
'
;
import
Voice
from
'
@react-native-voice/voice
'
;
import
{
DummyReadResult
}
from
'
../../../assets/read/data/ReadData
'
;
import
{
DummyReadResult
,
ImagePaths
}
from
'
../../../assets/read/data/ReadData
'
;
import
AudioRecord
from
'
react-native-audio-record
'
;
import
AudioRecord
from
'
react-native-audio-record
'
;
import
Client
from
'
../../client/Client
'
;
import
Client
from
'
../../client/Client
'
;
import
AsyncStorage
from
'
@react-native-async-storage/async-storage
'
;
import
AsyncStorage
from
'
@react-native-async-storage/async-storage
'
;
...
@@ -24,7 +24,6 @@ export default function ReadActivityBird() {
...
@@ -24,7 +24,6 @@ export default function ReadActivityBird() {
// const userToken = Authorize();
// const userToken = Authorize();
const
navigation
=
useNavigation
();
const
navigation
=
useNavigation
();
const
[
error
,
setError
]
=
useState
(
''
);
const
[
readingData
,
setReadingData
]
=
useState
({
activity
:
''
});
const
[
readingData
,
setReadingData
]
=
useState
({
activity
:
''
});
// let user = AsyncStorage.getItem('readingSession');
// let user = AsyncStorage.getItem('readingSession');
// useEffect(() => {
// useEffect(() => {
...
@@ -34,7 +33,6 @@ export default function ReadActivityBird() {
...
@@ -34,7 +33,6 @@ export default function ReadActivityBird() {
useEffect
(()
=>
{
useEffect
(()
=>
{
Voice
.
onSpeechStart
=
onSpeechStartHandler
;
Voice
.
onSpeechStart
=
onSpeechStartHandler
;
Voice
.
onSpeechEnd
=
onSpeechEndHandler
;
Voice
.
onSpeechResults
=
onSpeechResultsHandler
;
Voice
.
onSpeechResults
=
onSpeechResultsHandler
;
Voice
.
onSpeechError
=
onSpeechError
;
Voice
.
onSpeechError
=
onSpeechError
;
...
@@ -75,16 +73,11 @@ export default function ReadActivityBird() {
...
@@ -75,16 +73,11 @@ export default function ReadActivityBird() {
console
.
log
(
'
start handler =>>
'
,
e
);
console
.
log
(
'
start handler =>>
'
,
e
);
};
};
const
onSpeechEndHandler
=
e
=>
{
console
.
log
(
'
end handler =>>
'
,
e
);
};
const
onSpeechResultsHandler
=
e
=>
{
const
onSpeechResultsHandler
=
e
=>
{
console
.
log
(
'
result handler =>>
'
,
e
);
console
.
log
(
'
result handler =>>
'
,
e
);
};
};
const
onSpeechError
=
e
=>
{
const
onSpeechError
=
e
=>
{
setError
(
JSON
.
stringify
(
e
.
error
));
const
result
=
DummyReadResult
.
value
;
const
result
=
DummyReadResult
.
value
;
const
data
=
{
const
data
=
{
word
:
'
bird
'
,
word
:
'
bird
'
,
...
...
frontend/src/screen/reading/basic/ReadActivityNo.js
View file @
28cba3bb
...
@@ -15,40 +15,60 @@ import {
...
@@ -15,40 +15,60 @@ import {
}
from
'
react-native
'
;
}
from
'
react-native
'
;
import
Voice
from
'
@react-native-voice/voice
'
;
import
Voice
from
'
@react-native-voice/voice
'
;
import
{
DummyReadResult
,
ImagePaths
}
from
'
../../../assets/read/data/ReadData
'
;
import
{
DummyReadResult
,
ImagePaths
}
from
'
../../../assets/read/data/ReadData
'
;
import
AsyncStorage
from
'
@react-native-async-storage/async-storage
'
;
import
{
Authorize
}
from
'
../../auth/AuthenticateUser
'
;
import
Client
from
'
../../client/Client
'
;
export
default
function
ReadActivityNo
()
{
export
default
function
ReadActivityNo
()
{
const
navigation
=
useNavigation
();
const
navigation
=
useNavigation
();
const
[
pitch
,
setPitch
]
=
useState
(
''
);
const
[
readingData
,
setReadingData
]
=
useState
({
const
[
error
,
setError
]
=
useState
(
''
);
word
:
''
,
const
[
end
,
setEnd
]
=
useState
(
''
);
userId
:
''
,
const
[
started
,
setStarted
]
=
useState
(
''
);
level
:
1
,
const
[
results
,
setResults
]
=
useState
([]);
triedCount
:
1
,
const
[
partialResults
,
setPartialResults
]
=
useState
([]);
});
const
[
count
,
setCount
]
=
useState
(
1
);
useEffect
(()
=>
{
Voice
.
destroy
().
then
(
Voice
.
removeAllListeners
);
},
[]);
useEffect
(()
=>
{
useEffect
(()
=>
{
Voice
.
onSpeechStart
=
onSpeechStartHandler
;
Voice
.
onSpeechStart
=
onSpeechStartHandler
;
Voice
.
onSpeechEnd
=
onSpeechEndHandler
;
Voice
.
onSpeechResults
=
onSpeechResultsHandler
;
Voice
.
onSpeechResults
=
onSpeechResultsHandler
;
Voice
.
onSpeechError
=
onSpeechError
;
Voice
.
onSpeechError
=
onSpeechError
;
Voice
.
onSpeechPartialResults
=
onSpeechPartialResults
;
Voice
.
onSpeechVolumeChanged
=
onSpeechVolumeChanged
;
return
()
=>
{
return
()
=>
{
Voice
.
destroy
().
then
(
Voice
.
removeAllListeners
);
Voice
.
destroy
().
then
(
Voice
.
removeAllListeners
);
};
};
},
[]);
},
[]);
const
onSpeechStartHandler
=
e
=>
{
const
getToken
=
data
=>
{
console
.
log
(
'
start handler =>>
'
,
e
);
AsyncStorage
.
getItem
(
'
readingSession
'
)
.
then
(
readingSession
=>
{
sendRedingData
(
data
,
readingSession
);
})
.
catch
(
error
=>
{
console
.
log
(
error
);
});
};
};
const
onSpeechEndHandler
=
e
=>
{
const
sendRedingData
=
(
data
,
readingSession
)
=>
{
console
.
log
(
'
end handler =>>
'
,
e
);
Client
.
post
(
'
reading/
'
+
readingSession
,
JSON
.
stringify
(
data
),
{
headers
:
{
Accept
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
},
})
.
then
(
res
=>
{
console
.
log
(
res
.
data
);
// AsyncStorage.removeItem('readingSession');
navigation
.
navigate
(
'
ReadActivityGo
'
);
})
.
catch
(
error
=>
{
console
.
log
(
error
);
});
};
const
onSpeechStartHandler
=
e
=>
{
console
.
log
(
'
start handler =>>
'
,
e
);
};
};
const
onSpeechResultsHandler
=
e
=>
{
const
onSpeechResultsHandler
=
e
=>
{
...
@@ -57,23 +77,31 @@ export default function ReadActivityNo() {
...
@@ -57,23 +77,31 @@ export default function ReadActivityNo() {
const
onSpeechError
=
e
=>
{
const
onSpeechError
=
e
=>
{
console
.
log
(
'
onSpeechError:
'
,
e
);
console
.
log
(
'
onSpeechError:
'
,
e
);
setError
(
JSON
.
stringify
(
e
.
error
));
const
result
=
DummyReadResult
.
value
;
const
result
=
DummyReadResult
.
value
;
if
(
result
.
includes
(
'
hello
'
))
{
if
(
result
.
includes
(
'
hello
'
))
{
console
.
log
(
'
correct
'
);
AsyncStorage
.
getItem
(
'
userId
'
)
navigation
.
navigate
(
'
ReadActivityGo
'
);
.
then
(
userId
=>
{
const
data
=
{
word
:
'
no
'
,
userId
:
userId
,
level
:
1
,
triedCount
:
count
,
};
console
.
log
(
'
correct
'
,
data
);
getToken
(
data
);
})
.
catch
(
error
=>
{
console
.
log
(
error
);
});
}
else
{
setCount
(
count
+
1
);
Voice
.
start
(
'
en-US
'
);
}
}
};
const
onSpeechPartialResults
=
e
=>
{
console
.
log
(
'
count
'
,
count
);
console
.
log
(
'
onSpeechPartialResults:
'
,
e
);
setPartialResults
(
e
.
value
);
};
const
onSpeechVolumeChanged
=
e
=>
{
console
.
log
(
'
count
'
,
count
);
console
.
log
(
'
onSpeechVolumeChanged:
'
,
e
);
setPitch
(
e
.
value
);
};
};
const
startRecording
=
async
()
=>
{
const
startRecording
=
async
()
=>
{
...
@@ -84,14 +112,6 @@ export default function ReadActivityNo() {
...
@@ -84,14 +112,6 @@ export default function ReadActivityNo() {
}
}
};
};
const
stopRecording
=
async
()
=>
{
try
{
await
Voice
.
stop
();
}
catch
(
error
)
{
console
.
log
(
error
);
}
};
return
(
return
(
<
SafeAreaView
>
<
SafeAreaView
>
<
View
style
=
{{
flexDirection
:
'
column
'
}}
>
<
View
style
=
{{
flexDirection
:
'
column
'
}}
>
...
...
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