Commit 36f5e697 authored by Lihinikaduwa D.N.R.  's avatar Lihinikaduwa D.N.R.

Created a API to Get Read Result

parent 3863768c
......@@ -10,8 +10,6 @@ import random
import os
from API.model.readModel import *
from API.model.userModel import *
from API.model.readModel import get_reading_activities
from API.routers.router import funtion_one
# from backend.IT18218640.keyword_spotting_service import Keyword_Spotting_service
......@@ -164,7 +162,7 @@ def reading_session(userId):
return make_response(body)
@app.route("/readingSession/<readingToken>", methods=['PUT'])
@app.route("/updateSession/<readingToken>", methods=['PUT'])
def reading_session_status_update(readingToken):
assert readingToken == request.view_args['readingToken']
token = readingToken
......@@ -211,5 +209,19 @@ def get_completed_levels(userId):
return make_response(body)
@app.route("/result/<userId>", methods=['GET'])
def reading_result(userId):
assert userId == request.view_args['userId']
result = get_reading_result(userId)
response = {
"data": result,
"message": "Success",
"status": 200
}
body = jsonify(response)
return make_response(body)
if __name__ == "__main__":
app.run(host='192.168.1.101')
......@@ -3,21 +3,9 @@ from flask import jsonify
from API.util.util import getUUID
def get_reading_activities():
data_dic = []
qry = 'SELECT * FROM reading'
result = get_all_data(qry)
for row in result:
ob = {
"id": row[0],
"round": row[1],
}
data_dic.append(ob)
return jsonify(data_dic)
def get_reading_result(userId):
qry = 'SELECT * FROM reading WHERE userId = "{}"'.format(userId)
return get_data(qry)
def save_activity_details(userId, word, token, level, triedCount):
......
......@@ -71,6 +71,8 @@ import AdvanceLevelStart from '../screen/memory/AdvanceLevelStart';
import Sam from '../screen/sample/sam';
import Progress from '../screen/Progress';
import ReadActivityFish from '../screen/reading/advanced/ReadActivityFish';
import ReadActivityDog from '../screen/reading/advanced/ReadActivityDog';
const Stack = createNativeStackNavigator();
......@@ -181,6 +183,16 @@ const AppRouter = () => {
name="ReadActivityBird"
component={ReadActivityBird}
/>
<Stack.Screen
options={{headerShown: false}}
name="ReadActivityFish"
component={ReadActivityFish}
/>
<Stack.Screen
options={{headerShown: false}}
name="ReadActivityDog"
component={ReadActivityDog}
/>
<Stack.Screen
options={{headerShown: false}}
name="ColorResult"
......@@ -192,7 +204,7 @@ const AppRouter = () => {
options={{
title: 'Memory Games',
headerTintColor: 'white',
headerStyle: {backgroundColor: Colors.primary}
headerStyle: {backgroundColor: Colors.primary},
}}
/>
<Stack.Screen
......@@ -276,44 +288,44 @@ const AppRouter = () => {
}}
/>
<Stack.Screen
name='MemoryResult'
name="MemoryResult"
component={MemoryResult}
options={{
options={{
headerShown: true,
title: 'Results',
headerTintColor: 'white',
headerStyle: {backgroundColor: Colors.primary},
}}
}}
/>
<Stack.Screen
name='GameLevel'
name="GameLevel"
component={GameLevel}
options={{
options={{
headerShown: true,
title: 'Levels',
headerTintColor: 'white',
headerStyle: {backgroundColor: Colors.primary},
}}
}}
/>
<Stack.Screen
name='MediumLevelStart'
name="MediumLevelStart"
component={MediumLevelStart}
options={{
options={{
headerShown: true,
title: 'Medium Level',
headerTintColor: 'white',
headerStyle: {backgroundColor: Colors.primary},
}}
}}
/>
<Stack.Screen
name='AdvanceLevelStart'
name="AdvanceLevelStart"
component={AdvanceLevelStart}
options={{
options={{
headerShown: true,
title: 'Advance Level',
headerTintColor: 'white',
headerStyle: {backgroundColor: Colors.primary},
}}
}}
/>
<Stack.Screen
options={{headerShown: false}}
......
......@@ -87,25 +87,25 @@ export default function Read() {
image={ImagePaths.roundOne}
path={'ReadActivityNo'}
/>
{level1 == 0 && (
<>
{/* {level1 == 0 && (
<> */}
<ReadCategory
title={'Advanced'}
image={ImagePaths.roundTwo}
path={'ReadActivityDog'}
/>
</>
)}
{/* </>
)} */}
{level2 == 0 && (
<>
{/* {level2 == 0 && (
<> */}
<ReadCategory
title={'Result & Summery'}
image={ImagePaths.summery}
path={'ReadActivity'}
/>
</>
)}
{/* </>
)} */}
</TouchableOpacity>
</ScrollView>
</SafeAreaView>
......
......@@ -46,6 +46,23 @@ export default function ReadActivityFish() {
},
})
.then(res => {
updateReadingSession(readingSession);
})
.catch(error => {
console.log(error);
});
};
const updateReadingSession = readingSession => {
Client.put('updateSession/' + readingSession, {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
})
.then(res => {
// AsyncStorage.removeItem('readingSession');
alert('Basic Level Completed');
navigation.navigate('Read');
})
.catch(error => {
......
......@@ -55,14 +55,14 @@ export default function ReadActivityHe() {
const updateReadingSession = readingSession => {
console.log('fuck');
Client.put('readingSession/' + readingSession, {
Client.put('updateSession/' + readingSession, {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
})
.then(res => {
AsyncStorage.removeItem('readingSession');
// AsyncStorage.removeItem('readingSession');
alert('Basic Level Completed');
navigation.navigate('Read');
})
......
import React, {useEffect, useState} from 'react';
import {
StyleSheet,
View,
Text,
Pressable,
ImageBackground,
TouchableOpacity,
Image,
ScrollView,
StatusBar,
} from 'react-native';
import {SafeAreaView} from 'react-native-safe-area-context';
import Orientation from 'react-native-orientation-locker';
import {useNavigation} from '@react-navigation/native';
import BackButton from '../../component/BackButton';
import TableList from '../../component/TableList';
import axios from 'axios';
import Client from '../../client/Client';
const webUrel = 'http://192.168.8.100:5000/getColorActivitiesResult';
export default function ReadResults() {
const navigation = useNavigation();
function getColorResult() {
Client.get('reading')
.then(response => {
// setNames(response.data);
console.log(response.data);
})
.catch(err => {
console.log(err);
});
}
React.useEffect(() => {
StatusBar.setHidden(true);
// getColorResult();
const unsubscribe = navigation.addListener('focus', () => {
// The screen is focused
// Call any action
Orientation.unlockAllOrientations();
Orientation.lockToLandscape();
});
return unsubscribe;
}, [navigation]);
return (
<SafeAreaView style={{marginBottom: -150}}>
<ScrollView>
<View>
<ImageBackground
style={styles.image}
source={require('../../assets/result/21.jpg')}>
<View>
<BackButton path="Color" />
</View>
<View style={styles.container}>
<Image
style={styles.logo}
source={require('../../assets/result/title.png')}
/>
</View>
<View style={{marginTop: -70}}>
<TableList />
</View>
</ImageBackground>
</View>
</ScrollView>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
image: {
width: '100%',
height: '100%',
},
container: {
// backgroundColor : '#fff',
marginTop: -130,
justifyContent: 'center',
alignItems: 'center',
},
logo: {
marginTop: 80,
width: '30%',
height: '30%',
},
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment