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
74018e38
Commit
74018e38
authored
May 02, 2022
by
Lihinikaduwa D.N.R.
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'it18257632' into 'master'
It18257632 See merge request
!178
parents
a82d7ac4
b66bac08
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 @
74018e38
No preview for this file type
API/app.py
View file @
74018e38
...
@@ -153,9 +153,10 @@ def logout():
...
@@ -153,9 +153,10 @@ def logout():
return
make_response
(
body
)
return
make_response
(
body
)
@
app
.
route
(
"/readingSession"
,
methods
=
[
'POST'
])
@
app
.
route
(
"/readingSession/<userId>"
,
methods
=
[
'POST'
])
def
reading_session
():
def
reading_session
(
userId
):
token
=
save_session_details
(
1
)
assert
userId
==
request
.
view_args
[
'userId'
]
token
=
save_session_details
(
userId
,
1
)
response
=
{
response
=
{
"token"
:
token
,
"token"
:
token
,
"message"
:
"Success"
,
"message"
:
"Success"
,
...
@@ -165,11 +166,11 @@ def reading_session():
...
@@ -165,11 +166,11 @@ def reading_session():
return
make_response
(
body
)
return
make_response
(
body
)
@
app
.
route
(
"/readingSession/<
readingToken
>"
,
methods
=
[
'PUT'
])
@
app
.
route
(
"/readingSession/<
userId
>"
,
methods
=
[
'PUT'
])
def
reading_session_status_update
(
readingToken
):
def
reading_session_status_update
(
readingToken
):
assert
readingToken
==
request
.
view_args
[
'readingToken'
]
assert
readingToken
==
request
.
view_args
[
'readingToken'
]
token
=
readingToken
token
=
readingToken
token
=
update_session_status
(
token
)
update_session_status
(
token
)
response
=
{
response
=
{
"message"
:
"Success"
,
"message"
:
"Success"
,
"status"
:
200
"status"
:
200
...
@@ -181,14 +182,29 @@ def reading_session_status_update(readingToken):
...
@@ -181,14 +182,29 @@ def reading_session_status_update(readingToken):
@
app
.
route
(
"/reading/<readingToken>"
,
methods
=
[
'POST'
])
@
app
.
route
(
"/reading/<readingToken>"
,
methods
=
[
'POST'
])
def
save_reading
(
readingToken
):
def
save_reading
(
readingToken
):
assert
readingToken
==
request
.
view_args
[
'readingToken'
]
assert
readingToken
==
request
.
view_args
[
'readingToken'
]
token
=
readingToken
req
=
request
.
get_json
()
req
=
request
.
get_json
()
word
=
req
[
'word'
]
word
=
req
[
'word'
]
userId
=
req
[
'userId'
]
userId
=
req
[
'userId'
]
level
=
req
[
'level'
]
level
=
req
[
'level'
]
triedCount
=
req
[
'triedCount'
]
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
=
{
response
=
{
"level1"
:
x
[
0
],
"level2"
:
y
[
0
],
"message"
:
"Success"
,
"message"
:
"Success"
,
"status"
:
200
"status"
:
200
}
}
...
...
API/model/__pycache__/readModel.cpython-39.pyc
View file @
74018e38
No preview for this file type
API/model/readModel.py
View file @
74018e38
...
@@ -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
(
status
):
def
save_session_details
(
userId
,
status
):
token
=
getUUID
()
token
=
getUUID
()
qry
=
'INSERT INTO readingSession (id,
token,status) VALUES (NULL
,
%
s,
%
s)'
qry
=
'INSERT INTO readingSession (id,
userId,token,status) VALUES (NULL,
%
s
,
%
s,
%
s)'
args
=
(
token
,
status
)
args
=
(
userId
,
token
,
status
)
insert
(
qry
,
args
)
insert
(
qry
,
args
)
return
token
return
token
...
@@ -38,3 +38,8 @@ def save_session_details(status):
...
@@ -38,3 +38,8 @@ def save_session_details(status):
def
update_session_status
(
token
):
def
update_session_status
(
token
):
qry
=
'UPDATE readingSession SET status = 0 WHERE token = "{}"'
.
format
(
token
)
qry
=
'UPDATE readingSession SET status = 0 WHERE token = "{}"'
.
format
(
token
)
return
update_data
(
qry
)
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 @
74018e38
...
@@ -13,7 +13,7 @@ import Client from '../../screen/client/Client';
...
@@ -13,7 +13,7 @@ import Client from '../../screen/client/Client';
import
AsyncStorage
from
'
@react-native-async-storage/async-storage
'
;
import
AsyncStorage
from
'
@react-native-async-storage/async-storage
'
;
const
ReadCategory
=
props
=>
{
const
ReadCategory
=
props
=>
{
const
{
title
,
image
,
i
d
,
color
,
path
}
=
props
;
const
{
title
,
image
,
i
sDisable
,
path
}
=
props
;
const
navigation
=
useNavigation
();
const
navigation
=
useNavigation
();
...
@@ -21,10 +21,8 @@ const ReadCategory = props => {
...
@@ -21,10 +21,8 @@ const ReadCategory = props => {
AsyncStorage
.
getItem
(
'
readingSession
'
)
AsyncStorage
.
getItem
(
'
readingSession
'
)
.
then
(
value
=>
{
.
then
(
value
=>
{
if
(
value
==
null
)
{
if
(
value
==
null
)
{
console
.
log
(
'
bfxcvbfvfdxv
'
,
value
);
createReadingSession
(
value
);
getReadingSession
(
value
);
}
else
{
}
else
{
console
.
log
(
'
bfxcvbfvfdxv
'
);
navigation
.
navigate
(
path
);
navigation
.
navigate
(
path
);
}
}
})
})
...
@@ -33,34 +31,42 @@ const ReadCategory = props => {
...
@@ -33,34 +31,42 @@ const ReadCategory = props => {
});
});
};
};
const
getReadingSession
=
()
=>
{
const
createReadingSession
=
()
=>
{
Client
.
post
(
'
readingSession
'
,
{
AsyncStorage
.
getItem
(
'
userId
'
)
headers
:
{
.
then
(
userId
=>
{
Accept
:
'
application/json
'
,
Client
.
post
(
'
readingSession/
'
+
userId
,
{
'
Content-Type
'
:
'
application/json
'
,
headers
:
{
},
Accept
:
'
application/json
'
,
})
'
Content-Type
'
:
'
application/json
'
,
.
then
(
res
=>
{
},
console
.
log
(
res
.
data
);
})
if
(
res
.
status
==
200
)
{
.
then
(
res
=>
{
console
.
log
(
res
.
data
);
console
.
log
(
res
.
data
);
const
token
=
res
.
data
.
token
;
if
(
res
.
status
==
200
)
{
try
{
const
token
=
res
.
data
.
token
;
AsyncStorage
.
setItem
(
'
readingSession
'
,
token
);
try
{
}
catch
(
error
)
{
AsyncStorage
.
setItem
(
'
readingSession
'
,
token
);
}
catch
(
error
)
{
console
.
log
(
error
);
}
navigation
.
navigate
(
path
);
}
})
.
catch
(
error
=>
{
console
.
log
(
error
);
console
.
log
(
error
);
}
});
navigation
.
navigate
(
path
);
}
})
})
.
catch
(
error
=>
{
.
catch
(
error
=>
{
console
.
log
(
error
);
console
.
log
(
error
);
});
});
};
};
return
(
return
(
<
View
style
=
{
styles
.
gameItem
}
>
<
View
style
=
{
styles
.
gameItem
}
>
<
TouchableOpacity
<
TouchableOpacity
disabled
=
{
false
}
onPress
=
{()
=>
{
onPress
=
{()
=>
{
checkReadingSession
();
checkReadingSession
();
}}
>
}}
>
...
...
frontend/src/screen/Read.js
View file @
74018e38
...
@@ -21,9 +21,12 @@ import ImageButton from '../component/ImageButton';
...
@@ -21,9 +21,12 @@ import ImageButton from '../component/ImageButton';
import
ButtonView
from
'
../component/buttonView
'
;
import
ButtonView
from
'
../component/buttonView
'
;
import
ReadCategory
from
'
../component/reading/ReadCategory
'
;
import
ReadCategory
from
'
../component/reading/ReadCategory
'
;
import
{
ImagePaths
}
from
'
../assets/read/data/ReadData
'
;
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
()
{
export
default
function
Read
()
{
const
[
activity
,
setActivity
]
=
useState
([]);
const
[
level1
,
setLevel1
]
=
useState
([]);
const
[
level2
,
setLevel2
]
=
useState
([]);
const
navigation
=
useNavigation
();
const
navigation
=
useNavigation
();
...
@@ -39,6 +42,35 @@ export default function Read() {
...
@@ -39,6 +42,35 @@ export default function Read() {
return
unsubscribe
;
return
unsubscribe
;
},
[
navigation
]);
},
[
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
(
return
(
<
SafeAreaView
>
<
SafeAreaView
>
<
ScrollView
>
<
ScrollView
>
...
@@ -51,6 +83,7 @@ export default function Read() {
...
@@ -51,6 +83,7 @@ export default function Read() {
</View> */
}
</View> */
}
<
TouchableOpacity
style
=
{
styles
.
screen
}
>
<
TouchableOpacity
style
=
{
styles
.
screen
}
>
<
ReadCategory
<
ReadCategory
isDisable
=
{
''
}
title
=
{
'
Basic
'
}
title
=
{
'
Basic
'
}
image
=
{
ImagePaths
.
roundOne
}
image
=
{
ImagePaths
.
roundOne
}
path
=
{
'
ReadActivityNo
'
}
path
=
{
'
ReadActivityNo
'
}
...
...
frontend/src/screen/reading/basic/ReadActivityGo.js
View file @
74018e38
...
@@ -84,14 +84,6 @@ export default function ReadActivityGo() {
...
@@ -84,14 +84,6 @@ export default function ReadActivityGo() {
}
}
};
};
const
stopRecording
=
async
()
=>
{
try
{
await
Voice
.
stop
();
}
catch
(
error
)
{
console
.
log
(
error
);
}
};
return
(
return
(
<
SafeAreaView
>
<
SafeAreaView
>
<
View
style
=
{{
flexDirection
:
'
column
'
}}
>
<
View
style
=
{{
flexDirection
:
'
column
'
}}
>
...
@@ -108,14 +100,6 @@ export default function ReadActivityGo() {
...
@@ -108,14 +100,6 @@ export default function ReadActivityGo() {
<
Text
style
=
{
styles
.
text
}
>
Pronounce
this
Word
!<
/Text
>
<
Text
style
=
{
styles
.
text
}
>
Pronounce
this
Word
!<
/Text
>
<
/View
>
<
/View
>
<
/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
>
<
View
>
<
Image
style
=
{
styles
.
blackboard
}
source
=
{
ImagePaths
.
go
}
><
/Image
>
<
Image
style
=
{
styles
.
blackboard
}
source
=
{
ImagePaths
.
go
}
><
/Image
>
<
/View
>
<
/View
>
...
...
frontend/src/screen/reading/basic/ReadActivityNo.js
View file @
74018e38
...
@@ -40,15 +40,7 @@ export default function ReadActivityNo() {
...
@@ -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
)
=>
{
const
sendRedingData
=
(
data
,
readingSession
)
=>
{
Client
.
post
(
'
reading/
'
+
readingSession
,
JSON
.
stringify
(
data
),
{
Client
.
post
(
'
reading/
'
+
readingSession
,
JSON
.
stringify
(
data
),
{
...
@@ -104,6 +96,17 @@ export default function ReadActivityNo() {
...
@@ -104,6 +96,17 @@ export default function ReadActivityNo() {
console
.
log
(
'
count
'
,
count
);
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
()
=>
{
const
startRecording
=
async
()
=>
{
try
{
try
{
await
Voice
.
start
(
'
en-US
'
);
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