Skip to content

Commit

Permalink
added startTime and SubjectId to data dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinlim committed Mar 4, 2021
1 parent 03a2fc3 commit 31f1257
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
7 changes: 5 additions & 2 deletions lib/Maze.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:uuid/uuid.dart';
import 'userIDD.dart';

var uuid = Uuid();
DateTime startTime = DateTime.now();

class gameButton extends StatefulWidget {
int id;
Expand Down Expand Up @@ -159,9 +160,11 @@ class gameButtonState extends State<gameButton> {
});
//ending condition- if move is correct AND the last square on the path then game should display message congratulating them
if(widget.id==99) {
var dict = {"path":path, "moves": moves, "errors": errors, "times": times};
var dict = {"path":path, "moves": moves, "errors": errors, "times": times,
"subjectID": subjectId, "startTime": startTime.toString(),
"trial": attemptNum.toString() };
String data = json.encode(dict);
createData("GMLT-10x10", uuid.v1().toString(), data, id + "-" + attemptNum.toString());
createData("GMLT-10x10", uuid.v1().toString(), data, "1.0.0");
attemptNum++;
showDialog(
context: context,
Expand Down
7 changes: 5 additions & 2 deletions lib/MazeTest.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var uuid = Uuid();

//initialize new maze
maze maze2= new maze();
DateTime startTime = DateTime.now();
Color color1 = Colors.grey;
int lastMove = 0; //records last CORRECT move of user
bool lastMoveIncorrect = true; //true if user's last move was correct, false otherwise
Expand Down Expand Up @@ -194,9 +195,11 @@ class gameButtonState extends State<gameButton> {
});
//ending condition- if move is correct AND the last square on the path then game should display message congratulating them
if(widget.id==35) {
var dict2 = {"path":path2, "moves": moves2, "errors": errors2, "times": times2};
var dict2 = {"path":path2, "moves": moves2, "errors": errors2, "times": times2,
"subjectId": subjectId, "startTime": startTime.toIso8601String(),
"trial": attemptNum.toString() };
String data = json.encode(dict2);
createData("GMLT-5x5", uuid.v1().toString(), data, id);
createData("GMLT-6x6", uuid.v1().toString(), data, "1.0.0");

showDialog(
context: context,
Expand Down
5 changes: 2 additions & 3 deletions lib/userIDD.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import 'package:uuid/uuid.dart';
import 'startingScreen.dart';
//import 'package:shared_preferences/shared_preferences.dart';

String id;
String subjectId;

class SubjectIDPage extends StatefulWidget {
@override
SubjectIDPageState createState() => SubjectIDPageState();
}

class SubjectIDPageState extends State<SubjectIDPage> {
String subjectId;

showAlertDialog(BuildContext context) {
// set up the button
Expand Down Expand Up @@ -60,7 +60,6 @@ class SubjectIDPageState extends State<SubjectIDPage> {
hintText: 'Enter Subject ID'),
onChanged: (value) {
subjectId = value;
id=value;
},
),
height: MediaQuery.of(context).size.width * 0.25,
Expand Down

0 comments on commit 31f1257

Please sign in to comment.