Commit a9c4163c authored by W.D.R.P. Sandeepa's avatar W.D.R.P. Sandeepa

change route

parent 2464f719
...@@ -5,7 +5,7 @@ import mysql ...@@ -5,7 +5,7 @@ import mysql
from flask import Flask, redirect, url_for, render_template, request, jsonify, make_response from flask import Flask, redirect, url_for, render_template, request, jsonify, make_response
import random import random
import os import os
from API.model.colorModel import get_color_activities1, get_color_activities2, get_color_activity_result from API.model.colorModel import get_color_activities1, get_color_activities2, get_color_activity_result, storeResult
from API.model.readModel import get_reading_activities from API.model.readModel import get_reading_activities
from API.model.userModel import getStudentByName from API.model.userModel import getStudentByName
from API.routers.router import funtion_one from API.routers.router import funtion_one
...@@ -125,6 +125,17 @@ def predict(): ...@@ -125,6 +125,17 @@ def predict():
# return jsonify("print") # return jsonify("print")
# return "Print" # return "Print"
@app.route("/store", methods=["POST"])
def store():
req = request.get_json()
value = req['value']
date = req['date']
result = "Good"
time = "2S"
usersId = 1
response = storeResult(value, date, result, time, usersId)
# Read Function Route (IT) # Read Function Route (IT)
......
from flask import jsonify from flask import jsonify
from API.db.dbConnection import get_all_data from API.db.dbConnection import get_all_data, insert_data_json, insert_data
def get_color_activities1(): def get_color_activities1():
data_dic = [] data_dic = []
...@@ -42,6 +43,14 @@ def get_color_activities2(): ...@@ -42,6 +43,14 @@ def get_color_activities2():
return jsonify(data_dic) return jsonify(data_dic)
def storeResult(value, date, result, time, usersId):
qry = 'INSERT INTO coloractivityresult VALUES (NULL, % s, % s, % s, % s, % s)', (date, result, time, usersId, value)
response = insert_data(qry)
return response
def get_color_activity_result(): def get_color_activity_result():
data_dic = [] data_dic = []
...@@ -51,7 +60,7 @@ def get_color_activity_result(): ...@@ -51,7 +60,7 @@ def get_color_activity_result():
for row in result: for row in result:
ob = { ob = {
"idcoloractivityresult": row[0], "idColorActivityResult": row[0],
"idcolorActivities": row[1], "idcolorActivities": row[1],
"date": row[2], "date": row[2],
"time": row[3], "time": row[3],
......
...@@ -7,8 +7,6 @@ import CountDown from 'react-native-countdown-component'; ...@@ -7,8 +7,6 @@ import CountDown from 'react-native-countdown-component';
import client from "../client/Client"; import client from "../client/Client";
import Voice from '@react-native-voice/voice'; import Voice from '@react-native-voice/voice';
import BackButton from "../../component/BackButton" import BackButton from "../../component/BackButton"
export default function Black() { export default function Black() {
...@@ -61,26 +59,57 @@ export default function Black() { ...@@ -61,26 +59,57 @@ export default function Black() {
const value = e.value; const value = e.value;
if(value.includes(backColor) == true){ if (value.includes(backColor) == true) {
var color = "Red";
console.log('Your Answer is Correct'); console.log('Your Answer is Correct');
sendData(color)
showAlert = () => { showAlert = () => {
this.setState({ this.setState({
showAlert: true showAlert: true
}); });
}; };
}else{
} else {
console.log('Your Answer is Incorrect', value); console.log('Your Answer is Incorrect', value);
} }
}; };
function sendData(value) {
var date = new Date().getDate();
var month = new Date().getMonth() + 1;
var year = new Date().getFullYear();
var todayData = date + '-' + month + '-' + year;
var data = {
value: value,
date: todayData
}
data = JSON.stringify(data);
client.post('store', data, {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
}).then((response) => {
console.log(response.data);
}).catch(err => {
console.log(err);
})
}
const onSpeechPartialResults = e => { const onSpeechPartialResults = e => {
// console.log('onSpeechPartialResults: ', e); // console.log('onSpeechPartialResults: ', e);
...@@ -88,15 +117,15 @@ export default function Black() { ...@@ -88,15 +117,15 @@ export default function Black() {
// console.log(value.length) // console.log(value.length)
// setPartialResults(e.value); // setPartialResults(e.value);
}; };
const onFinishCD = () => { const onFinishCD = () => {
Alert.alert('Countdown Finished...'); Alert.alert('Countdown Finished...');
} }
const onPressCD = () => { const onPressCD = () => {
Alert.alert('Countdown Component Pressed...'); Alert.alert('Countdown Component Pressed...');
} }
const startRecording = async () => { const startRecording = async () => {
...@@ -154,10 +183,10 @@ export default function Black() { ...@@ -154,10 +183,10 @@ export default function Black() {
</TouchableOpacity> </TouchableOpacity>
</View> </View>
<View style={{ marginLeft: -100, marginTop:-15 }}> <View style={{ marginLeft: -100, marginTop: -15 }}>
<TouchableOpacity onPress={() => { }} <TouchableOpacity onPress={() => { }}
style={{ width: "60%", height: "50%", borderRadius: 50 }}> style={{ width: "60%", height: "50%", borderRadius: 50 }}>
<Image source={require('../../assets/game/finish.png')} resizeMode='contain' style={{ flex: .9, marginLeft: -150 }} /> <Image source={require('../../assets/game/finish.png')} resizeMode='contain' style={{ flex: .9, marginLeft: -120 }} />
</TouchableOpacity> </TouchableOpacity>
</View> </View>
......
...@@ -157,7 +157,7 @@ export default function White() { ...@@ -157,7 +157,7 @@ export default function White() {
<View style={{ marginLeft: -100, marginTop:-15 }}> <View style={{ marginLeft: -100, marginTop:-15 }}>
<TouchableOpacity onPress={() => { }} <TouchableOpacity onPress={() => { }}
style={{ width: "60%", height: "50%", borderRadius: 50 }}> style={{ width: "60%", height: "50%", borderRadius: 50 }}>
<Image source={require('../../assets/game/finish.png')} resizeMode='contain' style={{ flex: .9, marginLeft: -150, }} /> <Image source={require('../../assets/game/finish.png')} resizeMode='contain' style={{ flex: .9, marginLeft: -120, }} />
</TouchableOpacity> </TouchableOpacity>
</View> </View>
......
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