fixade feedback #33

Merged
nisa9769 merged 1 commits from newnewFeedback into master 2022-05-23 15:04:34 +02:00
3 changed files with 62 additions and 32 deletions

File diff suppressed because one or more lines are too long

View File

@ -12,8 +12,6 @@ Color _colorContainerHappy = _backgroundColor;
Color _colorContainerMediumHappy = _backgroundColor;
Color _colorContainerUpset = _backgroundColor;
var timestamp;
Map<String, bool> _satisfactionBoolean = {
"VeryHappy": false,
@ -54,14 +52,13 @@ class FormForFeedbackState extends State<FormForFeedback> {
var dataBase = mysql();
Future<void> feedbackVerification(String satisfaction, String typeOfFeedback, String writtenFeedback, String timestamp ) async {
Future<void> feedbackVerification(String satisfaction, String typeOfFeedback, String writtenFeedback) async {
await dataBase.getConnection().then((conn) async {
String sql = "INSERT INTO maen0574.User_feedback (id, Satisfaction, Type_of_feedback, Written_feedback, timestamp) VALUES (null, '$satisfaction', '$typeOfFeedback', '$writtenFeedback', '$timestamp);";
String sql = "INSERT INTO maen0574.User_feedback (Satisfaction, Type_of_feedback, Written_feedback) VALUES ('$satisfaction', '$typeOfFeedback', '$writtenFeedback');";
await conn.query(sql).then((results) {
for(var row in results) {
print(row[0].toString());
setState(() {});
form(row[0].toString(), row[1].toString(), row[2].toString(), row[3]);
form(row[0].toString(), row[1].toString(), row[2].toString(), row[3].toString());
}
});
});
@ -339,31 +336,48 @@ class FormForFeedbackState extends State<FormForFeedback> {
InkWell(
onTap: () async {
print(writtenFeedback.text);
if (writtenFeedback.text.contains("'")) {
print('not allowed to use atrophies');
return;
}
timestamp = DateTime.now().millisecondsSinceEpoch.toString();
await feedbackVerification(satisfaction.text, typeOfFeedback.text, writtenFeedback.text, timestamp);
if (_formKey.currentState!.validate()) {
await feedbackVerification(satisfaction.text, typeOfFeedback.text, writtenFeedback.text);
print(satisfaction.text);
print(typeOfFeedback.text);
print(writtenFeedback.text);
print(timestamp);
//pop-up thank you for answering
showDialog<String>(
context: context,
builder: (BuildContext context) =>
AlertDialog(
title: const Text('Thank you'),
content: const Text('Thank you for your feedback, '
'you will now be sent back to the map'),
actions: <Widget>[
TextButton(
child: const Text('Ok'),
onPressed: () =>
Navigator.push(
context,
MaterialPageRoute(builder: (context) =>
BottomNavPage()), //Replace Container() with call to account-page.
BottomNavPage()),
//Replace Container() with call to account-page.
),
),
],
),
);
}
pressedEmojiColor("clear");
pressedTypeOfFeedback("clear");
writtenFeedback.text = '';
},
child: Container(
color: _colorContainerHappy,
color: Colors.purple,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const <Widget>[
@ -383,13 +397,9 @@ class FormForFeedbackState extends State<FormForFeedback> {
],
),
),
),
);
}
}
@ -441,6 +451,17 @@ void pressedEmojiColor (String s) {
_satisfactionBoolean["Upset"] == false;
_colorContainerUpset = _backgroundColor;
}
if(s == "clear"){
_satisfactionBoolean["VeryHappy"] = false;
_colorContainerVeryHappy = _backgroundColor;
_satisfactionBoolean["MediumHappy"] == false;
_colorContainerMediumHappy = _backgroundColor;
_satisfactionBoolean["Happy"] == false;
_colorContainerHappy = _backgroundColor;
_satisfactionBoolean["Upset"] == false;
_colorContainerUpset = _backgroundColor;
}
}
void pressedTypeOfFeedback(String s) {
@ -487,4 +508,15 @@ void pressedTypeOfFeedback(String s) {
_typeOfFeedback["Compliment"] == false;
check1 = false;
}
if (s == "clear") {
_typeOfFeedback["Mistake in sun accuracy"] == false;
check4 = false;
_typeOfFeedback["Complaint"] == false;
check2 = false;
_typeOfFeedback["Bug"] == false;
check3 = false;
_typeOfFeedback["Compliment"] == false;
check1 = false;
}
}

View File

@ -2,12 +2,10 @@ class form {
late String satisfaction;
late String typeOfFeedback;
late String writtenFeedback;
late String timestamp;
form(String satisfaction, String typeOfFeedback, String writtenFeedback, String timestamp){
this.satisfaction = satisfaction;
this.typeOfFeedback = typeOfFeedback;
this.writtenFeedback = writtenFeedback;
this.timestamp = timestamp;
}
}