diff --git a/student/assets/images/Ac7_function1.svg b/student/assets/images/Ac6_function1.svg
similarity index 89%
copy from student/assets/images/Ac7_function1.svg
copy to student/assets/images/Ac6_function1.svg
index 6e15a67..246461b 100644
--- a/student/assets/images/Ac7_function1.svg
+++ b/student/assets/images/Ac6_function1.svg
@@ -1,205 +1,208 @@
diff --git a/student/assets/images/Ac7_function1.svg b/student/assets/images/Ac6_function2.svg
similarity index 90%
copy from student/assets/images/Ac7_function1.svg
copy to student/assets/images/Ac6_function2.svg
index 6e15a67..e9cae19 100644
--- a/student/assets/images/Ac7_function1.svg
+++ b/student/assets/images/Ac6_function2.svg
@@ -1,205 +1,208 @@
diff --git a/student/assets/images/Ac7_function1.svg b/student/assets/images/Ac6_function3.svg
similarity index 90%
copy from student/assets/images/Ac7_function1.svg
copy to student/assets/images/Ac6_function3.svg
index 6e15a67..c16c310 100644
--- a/student/assets/images/Ac7_function1.svg
+++ b/student/assets/images/Ac6_function3.svg
@@ -1,205 +1,208 @@
diff --git a/student/assets/images/Ac7_function1.svg b/student/assets/images/Ac7_function1.svg
index 6e15a67..37e2254 100644
--- a/student/assets/images/Ac7_function1.svg
+++ b/student/assets/images/Ac7_function1.svg
@@ -1,205 +1,208 @@
diff --git a/student/assets/images/Ac7_function2.svg b/student/assets/images/Ac7_function2.svg
index 8ff326b..5850e89 100644
--- a/student/assets/images/Ac7_function2.svg
+++ b/student/assets/images/Ac7_function2.svg
@@ -1,99 +1,101 @@
diff --git a/student/assets/images/Ac7_function3.svg b/student/assets/images/Ac7_function3.svg
index b3475da..dda36be 100644
--- a/student/assets/images/Ac7_function3.svg
+++ b/student/assets/images/Ac7_function3.svg
@@ -1,205 +1,207 @@
diff --git a/student/assets/images/Ac8_function1.svg b/student/assets/images/Ac8_function1.svg
index c973d43..cbbe495 100644
--- a/student/assets/images/Ac8_function1.svg
+++ b/student/assets/images/Ac8_function1.svg
@@ -1,205 +1,208 @@
diff --git a/student/assets/images/Ac8_function2.svg b/student/assets/images/Ac8_function2.svg
index 1cc6ef9..e18e64e 100644
--- a/student/assets/images/Ac8_function2.svg
+++ b/student/assets/images/Ac8_function2.svg
@@ -1,205 +1,207 @@
diff --git a/student/assets/images/Ac8_function3.svg b/student/assets/images/Ac8_function3.svg
index 642b6ac..7f4afc3 100644
--- a/student/assets/images/Ac8_function3.svg
+++ b/student/assets/images/Ac8_function3.svg
@@ -1,205 +1,207 @@
diff --git a/student/assets/images/CelluloGridMAp2.pdf b/student/assets/images/CelluloGridMAp2.pdf
new file mode 100644
index 0000000..748bb0e
Binary files /dev/null and b/student/assets/images/CelluloGridMAp2.pdf differ
diff --git a/student/assets/images/CelluloGridMap1.pdf b/student/assets/images/CelluloGridMap1.pdf
new file mode 100644
index 0000000..5cdede8
Binary files /dev/null and b/student/assets/images/CelluloGridMap1.pdf differ
diff --git a/student/assets/images/Grid_Ac6_Map.pdf b/student/assets/images/Grid_Ac6_Map.pdf
new file mode 100644
index 0000000..1dccb45
Binary files /dev/null and b/student/assets/images/Grid_Ac6_Map.pdf differ
diff --git a/student/assets/images/Grid_Ac7_Map.svg b/student/assets/images/Grid_Ac6_Map.pdf.2020_09_17_17_35_09.0.svg
similarity index 82%
copy from student/assets/images/Grid_Ac7_Map.svg
copy to student/assets/images/Grid_Ac6_Map.pdf.2020_09_17_17_35_09.0.svg
index a94e393..98cfafe 100644
--- a/student/assets/images/Grid_Ac7_Map.svg
+++ b/student/assets/images/Grid_Ac6_Map.pdf.2020_09_17_17_35_09.0.svg
@@ -1,869 +1,858 @@
diff --git a/student/assets/images/Grid_Ac6_Map.svg b/student/assets/images/Grid_Ac6_Map.svg
index 9111fc7..8a8c8b8 100644
--- a/student/assets/images/Grid_Ac6_Map.svg
+++ b/student/assets/images/Grid_Ac6_Map.svg
@@ -1,973 +1,831 @@
diff --git a/student/assets/images/Grid_Ac6_MapDotted.pdf b/student/assets/images/Grid_Ac6_MapDotted.pdf
new file mode 100644
index 0000000..5cdede8
Binary files /dev/null and b/student/assets/images/Grid_Ac6_MapDotted.pdf differ
diff --git a/student/assets/images/Grid_Ac7_Screen.svg b/student/assets/images/Grid_Ac6_Screen.svg
similarity index 89%
copy from student/assets/images/Grid_Ac7_Screen.svg
copy to student/assets/images/Grid_Ac6_Screen.svg
index cb2ace5..ea2ce18 100644
--- a/student/assets/images/Grid_Ac7_Screen.svg
+++ b/student/assets/images/Grid_Ac6_Screen.svg
@@ -1,809 +1,809 @@
diff --git a/student/assets/images/Grid_Ac7_Map.pdf b/student/assets/images/Grid_Ac7_Map.pdf
index 4217e21..2b815c8 100644
Binary files a/student/assets/images/Grid_Ac7_Map.pdf and b/student/assets/images/Grid_Ac7_Map.pdf differ
diff --git a/student/assets/images/Grid_Ac7_Map.svg b/student/assets/images/Grid_Ac7_Map.svg
index a94e393..b393309 100644
--- a/student/assets/images/Grid_Ac7_Map.svg
+++ b/student/assets/images/Grid_Ac7_Map.svg
@@ -1,869 +1,839 @@
diff --git a/student/assets/images/Grid_Ac7_MapDotted.pdf b/student/assets/images/Grid_Ac7_MapDotted.pdf
new file mode 100644
index 0000000..748bb0e
Binary files /dev/null and b/student/assets/images/Grid_Ac7_MapDotted.pdf differ
diff --git a/student/assets/images/Grid_Ac7_Screen.svg b/student/assets/images/Grid_Ac7_Screen.svg
index cb2ace5..71b0476 100644
--- a/student/assets/images/Grid_Ac7_Screen.svg
+++ b/student/assets/images/Grid_Ac7_Screen.svg
@@ -1,809 +1,787 @@
diff --git a/student/assets/images/Grid_Ac8_Screen.svg b/student/assets/images/Grid_Ac8_Screen.svg
index e626dff..b04995b 100644
--- a/student/assets/images/Grid_Ac8_Screen.svg
+++ b/student/assets/images/Grid_Ac8_Screen.svg
@@ -1,900 +1,834 @@
diff --git a/student/assets/images/chilli.svg b/student/assets/images/chilli.svg
new file mode 100644
index 0000000..f5cee69
--- /dev/null
+++ b/student/assets/images/chilli.svg
@@ -0,0 +1,68 @@
+
+
+
diff --git a/student/lib/Activities/Ac1.dart b/student/lib/Activities/Ac1.dart
index 91e199c..7df1502 100644
--- a/student/lib/Activities/Ac1.dart
+++ b/student/lib/Activities/Ac1.dart
@@ -1,603 +1,604 @@
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:student/widgets/onlineRobotMap.Dart';
import 'package:student/widgets/celluloMap.Dart';
import 'dart:async';
import 'dart:convert';
import 'package:student/Database.dart';
import 'package:student/model/Group.dart';
import 'package:student/model/Cellulo.dart';
import 'package:student/widgets/showAlertDialog.Dart';
import 'package:student/widgets/membersBar.Dart';
import 'package:student/widgets/inactivityDetector.Dart';
import 'package:flutter_appavailability/flutter_appavailability.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong/latlong.dart';
import 'package:map_controller/map_controller.dart';
import 'package:student/widgets/mapShapeMaker.dart';
import 'dart:math' as math;
class Ac1 extends StatefulWidget {
Ac1({Key key}) : super(key: key);
@override
_Ac1State createState() => _Ac1State();
}
class _Ac1State extends State {
// Activity_Independent
var elapseTimer = new Stopwatch();
Timer timerCelluloPosition;
Timer timerCheckCelluloGame;
int currentTurn = 1;
bool enterBorderX = false;
bool enterBorderY = false;
// Celulo
var celluloxPosition = [0.0, 0.0];
var celluloyPosition = [0.0, 0.0];
var prevcelluloxPosition = [0.0, 0.0];
var prevcelluloyPosition = [0.0, 0.0];
var celluloxVelocity = [0.0, 0.0];
var celluloyVelocity = [0.0, 0.0];
List celluloxPositiontopaint = [0.0, 0.0];
List celluloyPositiontopaint = [0.0, 0.0];
bool addtoprint;
AnimationController controllerRobotPath;
Animation animationRobotPath;
// Learning
List mistakesSlope = [0, 0, 0];
List mistakesIntrepet = [0, 0, 0];
List mistakesInitialPosition = [0, 0, 0];
List trapped = [0];
int scoreX = 6;
int scoreY = 6;
int trappedCircleX;
int trappedCircleY;
//Activity Dependent
double radiuosStart = 45;
String activityTitle = 'Activity 1';
var linesPath = [
'assets/images/Ac7_function1.svg',
'assets/images/Ac7_function2.svg',
'assets/images/Ac7_function3.svg',
'assets/images/GridOnlyPositive.svg',
];
// map-related
final double mapSizeWidth = 860;
final double mapSizeHeight = 860;
double coeffScreenMapWidth;
double coeffScreenMapHeight;
final String mapPath = 'assets/images/GridOnlyPositive.svg';
var overlayPolygons = [
Polygon(points: [
LatLng(0.0, 0.0),
LatLng(30.0, 0.0),
LatLng(30.0, 30.0),
LatLng(0.0, 30.0)
], color: Colors.blue)
];
var mapShape = [
{
'numCircles': 4,
'originCircles': [
Offset(390, 300),
Offset(160, 70),
Offset(60, 360),
Offset(560, 690)
],
'radiuosCircles': [60.0, 50.0, 50.0, 40.0],
'numRectangles': 2,
'originRectangles': [Offset(300, 30), Offset(300, 560)],
'widthRectangles': [150.0, 100.0],
'heightRectangles': [50.0, 250.0],
'numPolygons': 5,
'sidesofPolygon': [3, 3, 5, 4, 4],
'radiusPolygon': [30.0, 40.0, 40.0, 40.0, 50.0],
'centerPolygon': [
Offset(40, 130),
Offset(700, 90),
Offset(600, 200),
Offset(600, 500),
Offset(780, 400)
],
'startCenter': Offset(60, 760),
'endCenter': Offset(800, 100)
},
{
'numCircles': 2,
'originCircles': [
Offset(490, 300),
Offset(160, 270),
],
'radiuosCircles': [60.0, 70.0],
'numRectangles': 3,
'originRectangles': [
Offset(100, 500),
Offset(700, 560),
Offset(300, 360)
],
'widthRectangles': [150.0, 100.0, 30.0],
'heightRectangles': [50.0, 250.0, 230.0],
'numPolygons': 5,
'sidesofPolygon': [6, 3, 5, 4, 4],
'radiusPolygon': [30.0, 50.0, 40.0, 40.0, 50.0],
'centerPolygon': [
Offset(40, 130),
Offset(300, 90),
Offset(700, 60),
Offset(600, 500),
Offset(780, 300)
],
'startCenter': Offset(60, 760),
'endCenter': Offset(800, 100)
},
{
'numCircles': 4,
'originCircles': [
Offset(290, 200),
Offset(160, 170),
Offset(490, 560),
Offset(690, 590)
],
'radiuosCircles': [30.0, 80.0, 50.0, 60.0],
'numRectangles': 2,
'originRectangles': [Offset(300, 30), Offset(300, 560)],
'widthRectangles': [150.0, 100.0],
'heightRectangles': [50.0, 250.0],
'numPolygons': 3,
'sidesofPolygon': [3, 4, 4],
'radiusPolygon': [70.0, 70.0, 40.0],
'centerPolygon': [
Offset(40, 630),
Offset(70, 390),
Offset(620, 220),
],
'startCenter': Offset(60, 760),
'endCenter': Offset(800, 100)
},
];
@override
void initState() {
super.initState();
dbRef.child('groups').child(group.id).child('tabletStatus').set("YES");
dbRef.child('groups').child(group.id).child('currentActivity').set("Ac1");
elapseTimer.start();
timerCelluloPosition =
new Timer.periodic(new Duration(milliseconds: 100), (time) {
if (totalRobots() > 1) {
// print(cellulox.getrobotKidnapped().toString());
// print(celluloy.getrobotKidnapped().toString());
cellulox.getrobotx().then((val) => setState(() {
if (val != null) {
celluloxPosition[0] = val;
// print(celluloxPosition[0]);
if (addtoprint == true) celluloxPositiontopaint.add(val);
}
// print(addtoprint.toString());
}));
cellulox.getroboty().then((val) => setState(() {
if (val != null) {
celluloxPosition[1] = val;
}
}));
celluloy.getrobotx().then((val) => setState(() {
if (val != null) {
celluloyPosition[0] = val;
}
}));
celluloy.getroboty().then((val) => setState(() {
if (val != null) {
celluloyPosition[1] = val;
if (addtoprint == true) celluloyPositiontopaint.add(val);
}
}));
if (celluloxPosition[0] > 800 || celluloyPosition[1] > 800) {
cellulox.setVelocity(0, 0);
celluloy.setVelocity(0, 0);
}
}
});
timerCheckCelluloGame =
new Timer.periodic(new Duration(milliseconds: 500), (time) {
setState(() {
checkCelluloGame(
mapShape[currentTurn - 1],
Offset((celluloxPosition[0]), (celluloxPosition[1])),
Offset(celluloxPosition[0], celluloxPosition[1]),
Offset(celluloyPosition[0], celluloyPosition[1]),
0);
checkCelluloGame(
mapShape[currentTurn - 1],
Offset((celluloyPosition[0]), (celluloyPosition[1])),
Offset(celluloxPosition[0], celluloxPosition[1]),
Offset(celluloyPosition[0], celluloyPosition[1]),
1);
});
});
}
void checkCelluloGame(var mapShape, Offset celluloTargetPosition,
Offset celluloXPosition, Offset celluloYPosition, int id) {
var insideBorder = false;
var insideShape = false;
final double coeffHaptic = 10;
double radiuosBorder = 40;
bool enterShape = false;
var XVelocityCelluloX;
var YVelocityCelluloX;
var XVelocityCelluloY;
var YVelocityCelluloY;
double celluloXYdistances = math.sqrt(
math.pow((celluloXPosition.dx - celluloYPosition.dx), 2) +
math.pow((celluloXPosition.dy - celluloYPosition.dy), 2));
double distanceThreshold = 120;
//print(score.toString());
//print(enterBorder.toString());
var distancePointCenter = math.sqrt(math.pow(
(celluloTargetPosition.dx - mapShape['startCenter'].dx), 2) +
math.pow((celluloTargetPosition.dy - mapShape['startCenter'].dy), 2));
if (distancePointCenter <= radiuosStart) {
if (id == 0) {
scoreX = 6;
}
if (id == 1) {
scoreY = 6;
}
}
print('enterX' + enterBorderX.toString());
for (int i = 0; i < mapShape['numCircles']; i++) {
var distancePointCenter = math.sqrt(math.pow(
(celluloTargetPosition.dx - mapShape['originCircles'][i].dx), 2) +
math.pow(
(celluloTargetPosition.dy - mapShape['originCircles'][i].dy), 2));
if (distancePointCenter <=
mapShape['radiuosCircles'][i] + radiuosBorder) {
insideBorder = true;
XVelocityCelluloX = coeffHaptic *
(celluloXPosition.dx - mapShape['originCircles'][i].dx);
YVelocityCelluloX = coeffHaptic *
(celluloXPosition.dy - mapShape['originCircles'][i].dy);
XVelocityCelluloY = coeffHaptic *
(celluloYPosition.dx - mapShape['originCircles'][i].dx);
YVelocityCelluloY = coeffHaptic *
(celluloYPosition.dy - mapShape['originCircles'][i].dy);
if (id == 0) cellulox.setVelocity(XVelocityCelluloX, YVelocityCelluloX);
if (id == 1) celluloy.setVelocity(XVelocityCelluloY, YVelocityCelluloY);
if (id == 0) {
if (enterBorderX == false) {
scoreX = scoreX - 1;
enterBorderX = true;
}
trappedCircleX = i;
}
if (id == 1) {
if (enterBorderY == false) {
scoreY = scoreY - 1;
enterBorderY = true;
}
trappedCircleY = i;
}
break;
} else if (id == 0 && i == trappedCircleX) {
enterBorderX = false;
} else if (id == 1 && i == trappedCircleY) {
enterBorderY = false;
}
/*
insideBorder = false;
if (distancePointCenter <= mapShape['radiuosCircles'][i]) {
insideShape = true;
} else {
insideShape = false;
enterShape = false;
}
if (insideShape == true) {
if (enterShape == false) {
score = score - 1;
enterShape = true;
}
}
*/
if (id == 0) cellulox.clearrobot();
if (id == 1) celluloy.clearrobot();
}
colorRobots();
if (celluloXYdistances < distanceThreshold) {
cellulox.robotVibrate(10, 10, 0, 100, 100);
celluloy.robotVibrate(10, 10, 0, 100, 100);
cellulox.setVelocity(-celluloxVelocity[0], -celluloxVelocity[1]);
celluloy.setVelocity(-celluloyVelocity[0], -celluloyVelocity[1]);
} else {
cellulox.clearrobot();
celluloy.clearrobot();
}
/*
for (int i = 0; i < mapShape['numPolygons']; i++) {
double distancePointCenter = math.sqrt(math.pow(
(celluloTargetPosition.dx - mapShape['centerPolygon'][i].dx), 2) +
math.pow(
(celluloTargetPosition.dy - mapShape['centerPolygon'][i].dy), 2));
//print('radious' + distancePointCenter.toString());
if (distancePointCenter + radiuosBorder <= mapShape['radiusPolygon'][i]) {
insideBorder = true;
} else {
enterBorder = false;
}
if (distancePointCenter <= mapShape['radiusPolygon'][i]) {
insideShape = true;
} else {
enterShape = false;
}
if (insideBorder == true) {
XVelocityCelluloX =
coeffHaptic * (celluloXPosition.dx - mapShape['centerPolygon'][i].dx);
YVelocityCelluloX =
coeffHaptic * (celluloXPosition.dy - mapShape['centerPolygon'][i].dy);
XVelocityCelluloY =
coeffHaptic * (celluloYPosition.dx - mapShape['centerPolygon'][i].dx);
YVelocityCelluloY =
coeffHaptic * (celluloYPosition.dy - mapShape['centerPolygon'][i].dy);
//cellulox.setVelocity(hapticXVelocityCelluloX, hapticYVelocityCelluloX);
//celluloy.setVelocity(hapticXVelocityCelluloY, hapticYVelocityCelluloY);
if (enterBorder == false) {
score = score - 1;
enterBorder = true;
}
break;
}
if (insideShape == true) {
if (enterShape == false) {
score = score - 1;
enterShape = true;
}
}
}
for (int i = 0; i < mapShape['numRectangles']; i++) {
if (Rect.fromCenter(
center: mapShape['originRectangles'][i],
width: mapShape['widthRectangles'][i],
height: mapShape['heightRectangles'][i])
.contains(celluloTargetPosition)) {
insideBorder = true;
} else {
enterBorder = false;
}
if (Rect.fromCenter(
center: mapShape['originRectangles'][i],
width: mapShape['widthRectangles'][i],
height: mapShape['heightRectangles'][i])
.contains(celluloTargetPosition)) {
insideShape = true;
} else {
enterShape = false;
}
if (insideBorder == true) {
XVelocityCelluloX = coeffHaptic *
(celluloXPosition.dx - mapShape['originRectangles'][i].dx);
YVelocityCelluloX = coeffHaptic *
(celluloXPosition.dy - mapShape['originRectangles'][i].dy);
XVelocityCelluloY = coeffHaptic *
(celluloYPosition.dx - mapShape['originRectangles'][i].dx);
YVelocityCelluloY = coeffHaptic *
(celluloYPosition.dy - mapShape['originRectangles'][i].dy);
//cellulox.setVelocity(hapticXVelocityCelluloX, hapticYVelocityCelluloX);
//celluloy.setVelocity(hapticXVelocityCelluloY, hapticYVelocityCelluloY);
if (enterBorder == false) {
score = score - 1;
enterBorder = true;
}
break;
}
if (insideShape == true) {
if (enterShape == false) {
score = score - 1;
enterShape = true;
}
}
}
*/
}
void colorRobots() {
for (int i = 0; i < 6; i++) {
cellulox.setColor(0, 0, 0, 0, 0);
}
for (int i = 0; i < scoreX; i++) {
cellulox.setColor(0, 255, 0, 1, i);
}
for (int i = 0; i < 6; i++) {
celluloy.setColor(0, 0, 0, 0, 0);
}
for (int i = 0; i < scoreY; i++) {
celluloy.setColor(0, 0, 255, 1, i);
}
}
void calcVelocity() {
celluloxVelocity[0] = celluloxPosition[0] - prevcelluloxPosition[0];
celluloxVelocity[1] = celluloxPosition[1] - prevcelluloxPosition[1];
celluloyVelocity[0] = celluloyPosition[0] - prevcelluloyPosition[0];
celluloyVelocity[1] = celluloyPosition[1] - prevcelluloyPosition[1];
prevcelluloxPosition = celluloxPosition;
prevcelluloyPosition = celluloyPosition;
}
@override
void dispose() {
cellulox.resetrobot();
celluloy.resetrobot();
timerCelluloPosition.cancel();
+timerCheckCelluloGame.cancel();
elapseTimer.stop();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Activity 1: Semi-Mathematical Control'),
),
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Column(children: [
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Container(
height: 100,
width: 600,
child: Stack(children: [
Card(
child: ListTile(
title: Text(
'Choose the two points that your robots start from there and also how much the blue robot should move. '),
),
)
])),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(100)),
color: Colors.blue),
child: FlatButton(
child: Text(
"Run Robots",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 18),
),
// tooltip: 'Run the Robots',
onPressed: () => {
{
// cellulox.setGoalPosition(originCoordinates[0], 600),
// celluloy.setGoalPosition(100, originCoordinates[1]),
// controllerRobotPath.reset(),
// controllerRobotPath.forward(),
// celluloy.setColor(0, 100, 255, 6),
}
},
)),
SizedBox(width: 20),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(100)),
color: Colors.blue),
child: FlatButton(
child: Text(
"Next Turn",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 18),
),
onPressed: () => {
if (currentTurn <= 2)
setState(() {
currentTurn = currentTurn + 1;
}),
},
)),
]),
Container(
width: MediaQuery.of(context).size.width * 0.9,
height: MediaQuery.of(context).size.height * 0.65,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(100)),
// color: Colors.blue
),
child: Stack(
children: [
Container(
width: MediaQuery.of(context).size.width * 0.9,
height: MediaQuery.of(context).size.height * 0.65,
child: CustomPaint(
//size: Size(200, 200),
painter:
//LinePainter2(celluloxPositiontopaint, celluloyPositiontopaint),
MapShapeMaker(
MediaQuery.of(context).size.width *
0.9 /
mapSizeWidth,
MediaQuery.of(context).size.height *
0.65 /
mapSizeHeight,
mapShape[currentTurn - 1]['numRectangles'],
mapShape[currentTurn - 1]['originRectangles'],
mapShape[currentTurn - 1]['widthRectangles'],
mapShape[currentTurn - 1]['heightRectangles'],
mapShape[currentTurn - 1]['numCircles'],
mapShape[currentTurn - 1]['originCircles'],
mapShape[currentTurn - 1]['radiuosCircles'],
mapShape[currentTurn - 1]['numPolygons'],
mapShape[currentTurn - 1]['sidesofPolygon'],
mapShape[currentTurn - 1]['radiusPolygon'],
mapShape[currentTurn - 1]['centerPolygon'],
mapShape[currentTurn - 1]['startCenter'],
mapShape[currentTurn - 1]['endCenter']),
),
),
Container(
width: MediaQuery.of(context).size.width * 0.9,
height: MediaQuery.of(context).size.height * 0.65,
child: Align(
alignment: Alignment(
2 * ((celluloxPosition[0]) / mapSizeWidth) - 1,
2 * ((celluloxPosition[1]) / mapSizeHeight) - 1),
child: Card(
child: SvgPicture.asset("assets/images/celluloRed.svg",
height: 60, width: 60),
),
),
),
Container(
width: MediaQuery.of(context).size.width * 0.9,
height: MediaQuery.of(context).size.height * 0.65,
child: Align(
alignment: Alignment(
2 * ((celluloyPosition[0]) / mapSizeWidth) - 1,
2 * ((celluloyPosition[1]) / mapSizeHeight) - 1),
child: Card(
child: SvgPicture.asset("assets/images/celluloBlue.svg",
height: 60, width: 60),
),
),
)
],
)),
SizedBox(
height: 15,
),
MembersBar(),
])));
}
}
diff --git a/student/lib/Activities/Ac3.dart b/student/lib/Activities/Ac3.dart
index 059f383..fd44877 100644
--- a/student/lib/Activities/Ac3.dart
+++ b/student/lib/Activities/Ac3.dart
@@ -1,269 +1,270 @@
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:student/widgets/onlineRobotMap.Dart';
import 'dart:async';
import 'dart:convert';
import 'package:student/Database.dart';
import 'package:student/model/Group.dart';
import 'package:student/model/Cellulo.dart';
import 'package:student/widgets/showAlertDialog.Dart';
import 'package:student/widgets/membersBar.Dart';
import 'package:student/widgets/inactivityDetector.Dart';
import 'package:flutter_appavailability/flutter_appavailability.dart';
import 'package:student/widgets/mapShapeMaker.dart';
class Ac3 extends StatefulWidget {
Ac3({Key key}) : super(key: key);
@override
_Ac3State createState() => _Ac3State();
}
class _Ac3State extends State {
// Activity_Independent
int currentTurn = 1;
var elapseTimer = new Stopwatch();
AnimationController controllerRobotPath;
Animation animationRobotPath;
Timer timerCelluloPosition;
// Celulo
var celluloxPosition = [0.0, 0.0];
var celluloyPosition = [0.0, 0.0];
// Learning
List mistakesSlope = [0, 0, 0];
List mistakesIntrepet = [0, 0, 0];
List mistakesInitialPosition = [0, 0, 0];
// ACTIVITY Dependent
final double mapSizeWidth = 860;
final double mapSizeHeight = 860;
double coeffScreenMapWidth;
double coeffScreenMapHeight;
var mapShape = [
{
'numCircles': 0,
'originCircles': [Offset(0, 0)],
'radiuosCircles': [0.0],
'numRectangles': 7,
'originRectangles': [
Offset(300, 30),
Offset(300, 560),
Offset(600, 630),
Offset(780, 360),
Offset(300, 300),
Offset(300, 560),
Offset(300, 560)
],
'widthRectangles': [150.0, 100.0, 30.0, 50.0, 150.0, 100.0, 100.0],
'heightRectangles': [40.0, 100.0, 200.0, 300.0, 40.0, 400.0, 200.0],
'numPolygons': 0,
'sidesofPolygon': [0],
'radiusPolygon': [0.0],
'centerPolygon': [Offset(0, 0)],
'startCenter': Offset(60, 760),
'endCenter': Offset(800, 100)
},
{
'numCircles': 0,
'originCircles': [Offset(0, 0)],
'radiuosCircles': [0],
'numRectangles': 6,
'originRectangles': [
Offset(300, 30),
Offset(300, 560),
Offset(300, 30),
Offset(300, 760),
Offset(60, 230),
Offset(300, 560)
],
'widthRectangles': [150.0, 100.0, 200.0, 100.0, 210.0],
'heightRectangles': [50.0, 250.0, 50.0, 250.0, 50.0, 350.0],
'numPolygons': 0,
'sidesofPolygon': [3, 3, 5, 4, 4],
'radiusPolygon': [30.0, 40.0, 40.0, 40.0, 50.0],
'centerPolygon': [
Offset(40, 130),
Offset(700, 90),
Offset(600, 200),
Offset(600, 500),
Offset(780, 400)
],
'startCenter': Offset(60, 760),
'endCenter': Offset(800, 100)
},
{
'numCircles': 0,
'originCircles': [
Offset(390, 300),
Offset(160, 70),
Offset(60, 360),
Offset(560, 690)
],
'radiuosCircles': [60.0, 50.0, 50.0, 40.0],
'numRectangles': 8,
'originRectangles': [
Offset(300, 30),
Offset(300, 560),
Offset(200, 430),
Offset(400, 100),
Offset(100, 730),
Offset(500, 760),
Offset(100, 730),
Offset(400, 460)
],
'widthRectangles': [160.0, 90.0, 150.0, 100.0, 150.0, 40.0, 350.0, 50.0],
'heightRectangles': [30.0, 270.0, 50.0, 250.0, 50.0, 250.0, 50.0, 250.0],
'numPolygons': 0,
'sidesofPolygon': [0],
'radiusPolygon': [0],
'centerPolygon': [Offset(0, 0)],
'startCenter': Offset(60, 760),
'endCenter': Offset(800, 100)
},
];
var mapShapeScreen;
@override
void initState() {
super.initState();
dbRef.child('groups').child(group.id).child('tabletStatus').set("YES");
dbRef.child('groups').child(group.id).child('currentActivity').set("Ac3");
elapseTimer.start();
timerCelluloPosition =
new Timer.periodic(new Duration(milliseconds: 500), (time) {});
}
@override
void dispose() {
elapseTimer.stop();
super.dispose();
- timerCelluloPosition.cancel();
+ timerCelluloPosition.cancel(); //
+// timerCheckCelluloGame.cancel();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Activity 3: Semi-Mathematical Control'),
),
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Column(children: [
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Container(
height: 100,
width: 600,
child: Stack(children: [
Card(
child: ListTile(
title: Text(
'Choose the two points that your robots start from there and also how much the blue robot should move. '),
),
),
])),
SizedBox(
width: 15,
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(100)),
color: Colors.blue),
child: FlatButton(
child: Text(
"Run Robots",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 18),
),
// tooltip: 'Run the Robots',
onPressed: () => {
{
setState(() {
mapShape = mapShape;
}),
// cellulox.setGoalPosition(originCoordinates[0], 600),
// celluloy.setGoalPosition(100, originCoordinates[1]),
controllerRobotPath.reset(),
controllerRobotPath.forward(),
}
},
)),
SizedBox(width: 20),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(100)),
color: Colors.blue),
child: FlatButton(
child: Text(
"Next Turn",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 18),
),
onPressed: () => {
if (currentTurn <= 2)
setState(() {
currentTurn = currentTurn + 1;
}),
},
),
)
]),
Container(
width: MediaQuery.of(context).size.width * 0.9,
height: MediaQuery.of(context).size.height * 0.65,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(100)),
// color: Colors.blue
),
child: Stack(
children: [
CustomPaint(
//size: Size(200, 200),
painter:
//LinePainter2(celluloxPositiontopaint, celluloyPositiontopaint),
MapShapeMaker(
MediaQuery.of(context).size.width *
0.9 /
mapSizeWidth,
MediaQuery.of(context).size.height *
0.65 /
mapSizeHeight,
mapShape[currentTurn - 1]['numRectangles'],
mapShape[currentTurn - 1]['originRectangles'],
mapShape[currentTurn - 1]['widthRectangles'],
mapShape[currentTurn - 1]['heightRectangles'],
mapShape[currentTurn - 1]['numCircles'],
mapShape[currentTurn - 1]['originCircles'],
mapShape[currentTurn - 1]['radiuosCircles'],
mapShape[currentTurn - 1]['numPolygons'],
mapShape[currentTurn - 1]['sidesofPolygon'],
mapShape[currentTurn - 1]['radiusPolygon'],
mapShape[currentTurn - 1]['centerPolygon'],
mapShape[currentTurn - 1]['startCenter'],
mapShape[currentTurn - 1]['endCenter']),
),
Align(
alignment: Alignment(
2 * (celluloxPosition[0] / mapSizeWidth) - 1,
2 * (celluloyPosition[1] / mapSizeHeight) - 1),
child: Card(
child: SvgPicture.asset("assets/images/celluloPurple.svg",
height: 60, width: 60),
),
),
],
)),
SizedBox(
height: 15,
),
MembersBar(),
])));
}
}
diff --git a/student/lib/Activities/Ac5.dart b/student/lib/Activities/Ac5.dart
index 64cd363..29c97dc 100644
--- a/student/lib/Activities/Ac5.dart
+++ b/student/lib/Activities/Ac5.dart
@@ -1,150 +1,157 @@
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:student/widgets/onlineRobotMap.Dart';
import 'dart:async';
import 'dart:convert';
import 'package:student/Database.dart';
import 'package:student/model/Group.dart';
import 'package:student/model/Cellulo.dart';
import 'package:student/widgets/showAlertDialog.Dart';
import 'package:student/widgets/membersBar.Dart';
import 'package:student/widgets/inactivityDetector.Dart';
import 'package:flutter_appavailability/flutter_appavailability.dart';
import 'package:student/widgets/celluloMap.Dart';
class Ac5 extends StatefulWidget {
Ac5({Key key}) : super(key: key);
@override
_Ac5State createState() => _Ac5State();
}
class _Ac5State extends State {
// Activity_Independent
var elapseTimer = new Stopwatch();
Timer timerCelluloPosition;
var celluloxPosition = [0.0, 0.0];
var celluloyPosition = [0.0, 0.0];
- List celluloxPositiontopaint = [0.0, 0.0];
- List celluloyPositiontopaint = [0.0, 0.0];
+ List> celluloxPositiontopaint =
+ new List.generate(3, (int index) => List(2), growable: true);
+ List> celluloyPositiontopaint =
+ new List.generate(3, (int index) => List(2), growable: true);
bool addtoprint;
AnimationController controllerRobotPath;
Animation animationRobotPath;
int currentTurn = 1;
// Learning
var linesPath = [
'assets/images/Ac7_function1.svg',
'assets/images/Ac7_function2.svg',
'assets/images/Ac7_function3.svg',
'assets/images/GridOnlyPositive.svg',
];
List mistakesSlope = [0, 0, 0];
List mistakesIntrepet = [0, 0, 0];
List mistakesInitialPosition = [0, 0, 0];
-
+ var xlabelposition = [0, 1];
+ var ylabelposition = [-1, 0];
+ var lineallow = [false, false, false];
// Activity Dependent
final String celluloxpath = 'assets/images/cellulox.svg';
final String celluloypath = 'assets/images/celluloy.svg';
final double mapSizeWidth = 860;
final double mapSizeHeight = 860;
final String mapPath = 'assets/images/GridOnlyPositive.svg';
@override
void initState() {
super.initState();
dbRef.child('groups').child(group.id).child('tabletStatus').set("YES");
dbRef.child('groups').child(group.id).child('currentActivity').set("Ac5");
elapseTimer.start();
}
@override
void dispose() {
elapseTimer.stop();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Activity 5: Semi-Mathematical Control'),
),
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Column(children: [
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Container(
height: 100,
width: 600,
child: Stack(children: [
Card(
child: ListTile(
title: Text(
'Choose the two points that your robots start from there and also how much the blue robot should move. '),
),
),
])),
SizedBox(
width: 15,
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(100)),
color: Colors.blue),
child: FlatButton(
child: Text(
"Run Robots",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 18),
),
// tooltip: 'Run the Robots',
onPressed: () => {
{
// cellulox.setGoalPosition(originCoordinates[0], 600),
// celluloy.setGoalPosition(100, originCoordinates[1]),
// controllerRobotPath.reset(),
// controllerRobotPath.forward(),
}
},
)),
SizedBox(width: 20),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(100)),
color: Colors.blue),
child: FlatButton(
child: Text(
"Next Turn",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 18),
),
onPressed: () => {},
),
)
]),
SizedBox(
height: 15,
),
celluloMap(
context,
celluloxPositiontopaint,
celluloyPositiontopaint,
celluloxPosition,
celluloyPosition,
mapPath,
celluloxpath,
celluloypath,
linesPath[currentTurn - 1],
mapSizeWidth,
mapSizeHeight,
'X',
- 'Y'),
+ 'Y',
+ xlabelposition,
+ ylabelposition,
+ lineallow),
MembersBar(),
])));
}
}
diff --git a/student/lib/Activities/Ac6.dart b/student/lib/Activities/Ac6.dart
index dcd69a2..10580ad 100644
--- a/student/lib/Activities/Ac6.dart
+++ b/student/lib/Activities/Ac6.dart
@@ -1,511 +1,635 @@
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:student/widgets/celluloMap.Dart';
import 'dart:async';
import 'dart:convert';
import 'package:student/Database.dart';
import 'package:student/model/Group.dart';
import 'package:student/model/Cellulo.dart';
import 'package:student/widgets/showAlertDialog.Dart';
import 'package:student/widgets/membersBar.Dart';
import 'package:student/widgets/inactivityDetector.Dart';
import 'package:flutter_appavailability/flutter_appavailability.dart';
-import 'package:student/widgets/showAlertDialog.Dart';
+
+import 'dart:math' as math;
class Ac6 extends StatefulWidget {
Ac6({Key key}) : super(key: key);
@override
_Ac6State createState() => _Ac6State();
}
class _Ac6State extends State
with SingleTickerProviderStateMixin, WidgetsBindingObserver {
// Timers
Timer timerCelluloPosition;
Timer timerslopedetection;
Timer timercleartracking;
- Timer timerprevCelluloPosition;
+ Timer timerCelluloPositionPaint;
Timer timerInactivityDetector;
- Timer timerprevCelluloPositiontoserver;
+ Timer timerCelluloPositionPainttoserver;
final acID = 7;
final maxLiitCellulo = 800;
// UI parameters
bool celluloxSwitch1 = true;
bool celluloySwitch1 = false;
bool celluloxSwitch2 = true;
bool celluloySwitch2 = false;
var onStop = false;
bool mode = false;
int wrongcounts = 0;
double _progress = 0.0;
final celluloSize = 60;
final ScrollController _scrollController = ScrollController();
final functionFormulas = ['X ⟼ Y', 'X+1 ⟼ Y', 'X+2 ⟼ Y', '2*X ⟼ Y', '-X ⟼ Y'];
Offset beginpath = Offset(0, 0);
Offset endpath = Offset(10, 100);
AnimationController controllerTrial;
AnimationController controllerTurn;
Animation animation;
Animation animationNextTurn;
TextEditingController controllerinitialX = TextEditingController();
TextEditingController controllerinitialY = TextEditingController();
TextEditingController controllerXslope = TextEditingController();
TextEditingController controllerYslope = TextEditingController();
var counterfunctionImage = 0;
//Activity Dependent
var linesPath = [
- 'assets/images/Ac7_function1.svg',
- 'assets/images/Ac7_function2.svg',
- 'assets/images/Ac7_function3.svg',
- 'assets/images/GridOnlyPositive.svg',
+ 'assets/images/Ac6_function1.svg',
+ 'assets/images/Ac6_function2.svg',
+ 'assets/images/Ac6_function3.svg',
+ 'assets/images/Grid_Ac6_Screen.svg',
];
+ var lineallow = [false, false, false];
var linesSlope = [1, 2, 3];
var initialPoint = [0, 0, 0];
// map-related
final double mapSizeWidth = 860;
final double mapSizeHeight = 860;
- final String mapPath = 'assets/images/Grid_Ac7_Screen.svg';
+ final double screenSizeWidth = 500;
+ final double screenSizeHeight = 500;
+ final String mapPath = 'assets/images/Grid_Ac6_Screen.svg';
final String celluloxpath = 'assets/images/celluloRed.svg';
final String celluloypath = 'assets/images/celluloBlue.svg';
var onTap = [false, false, false, false, false];
// var onTap=[false,false,false,false,false];
-
+ final names = [group.member1name, group.member2name, group.member3name];
var currentTurn = 1;
var currentTap = 0;
var tapCounter = 0;
int simulationVelCoeff = 1;
// Learning
List progress = [0, -2, -2];
// zero: undergoing, -1: not accomplished, 1: accomplished
bool waitforanimation = false;
List mistakesSlope = [0, 0, 0];
List mistakesIntrepet = [0, 0, 0];
List mistakesInitialPosition = [0, 0, 0];
List progressElpasedTime = [0, 0, 0];
var inactivity = 0;
+ bool checkend = true;
var prevcelluloxPositionSlope = 0.0;
var prevcelluloyPositionSlope = 0.0;
// robot related
var elapseTimer = new Stopwatch();
- bool setRun = false;
+ bool allowPaint = false;
var celluloxPosition = [0.0, 0.0];
var celluloyPosition = [0.0, 0.0];
var xHaptic;
var yHaptic;
+ bool runHaptic = false;
+ var xcelluloy = 820;
+ var ycellulox = 45;
var celluloTargetPosition = [0.0, 0.0];
- List celluloxPositiontopaint = [0.0, 0.0];
- List celluloyPositiontopaint = [0.0, 0.0];
+ List> celluloxPositiontopaint =
+ new List.generate(3, (int index) => [0.0, 0.0], growable: true);
+ List> celluloyPositiontopaint =
+ new List.generate(3, (int index) => [0.0, 0.0], growable: true);
+ var xlabelposition = [1.0, 1.0];
+ var ylabelposition = [-0.6, -1.0];
var prevcelluloxPosition = [0.0, 0.0];
var prevcelluloyPosition = [0.0, 0.0];
// screen-related
- var originCoordinates = [303.08, 563.08];
+ var originCoordinates = [123.5, 736.5];
var correctAnswer = [
- {"initialPointX": 0, "initialPointY": 0, "slope": 1},
- {"initialPointX": 0, "initialPointY": 1, "slope": 1},
- {"initialPointX": 0, "initialPointY": 0, "slope": 2}
+ {"initialPointX": 1, "initialPointY": 1, "slope": 1},
+ {"initialPointX": 0, "initialPointY": 0, "slope": 2},
+ {"initialPointX": 0, "initialPointY": 6, "slope": -1}
];
void calcHaptic() {
- var slopeHaptic = -1 * linesSlope[currentTurn - 1];
- var initialHaptic =
- celluloTargetPosition[1] - slopeHaptic * celluloTargetPosition[0];
+ var slopeHaptic = -1 / linesSlope[currentTurn - 1];
+ var initialHaptic = (originCoordinates[1] - celluloyPosition[1]) / 100 -
+ slopeHaptic * (celluloxPosition[0] - originCoordinates[0]) / 100;
+ // print('initialhaptic' + initialHaptic.toString());
setState(() {
xHaptic = (initialHaptic - initialPoint[currentTurn - 1]) /
(linesSlope[currentTurn - 1] - slopeHaptic);
- yHaptic = (linesSlope[currentTurn - 1]) * xHaptic +
- initialPoint[currentTurn - 1];
+ yHaptic = ((linesSlope[currentTurn - 1]) * xHaptic +
+ initialPoint[currentTurn - 1]);
});
+ // print('xcelluloy' + xcelluloy.toDouble().toString());
+// print('yhaptic' + yHaptic.toString());
+ // print('xhaptic' + xHaptic.toString());
+ cellulox.setGoalPosition(
+ xHaptic * 100 + originCoordinates[0], xcelluloy.toDouble(), 150);
+ celluloy.setGoalPosition(
+ ycellulox.toDouble(), originCoordinates[1] - (100 * yHaptic), 150);
}
@override
void initState() {
+ cellulox.setColor(0, 255, 0, 0, 0);
+
+ celluloy.setColor(0, 0, 255, 0, 0);
+
+ cellulox.clearrobot();
+ celluloy.clearrobot();
WidgetsBinding.instance.addObserver(this);
dbRef.child('groups').child(group.id).child('tabletStatus').set("YES");
dbRef.child('groups').child(group.id).child('currentActivity').set("Ac6");
elapseTimer.start();
onDataSend();
controllerTrial = AnimationController(
duration: Duration(milliseconds: 30000), vsync: this);
animation = Tween(begin: 0.0, end: 1.0).animate(controllerTrial)
..addListener(() {
_progress = animation.value;
if (_progress < 0.2) {
//print('uuh');
- cellulox.setGoalPosition(originCoordinates[0], 600);
- celluloy.setGoalPosition(100, originCoordinates[1]);
- setState(() {
- setRun = true;
- });
+ cellulox.setGoalPosition(originCoordinates[0], 700, 150);
+ celluloy.setGoalPosition(80, originCoordinates[1], 150);
}
if (_progress > 0.22) {
+ setState(() {
+ allowPaint = true;
+ });
// }
//if (celluloxPosition[0] > 700 ||
// celluloyPosition[1] < 100) {
// cellulox.resetrobot();
// celluloy.resetrobot();
- calcHaptic();
- cellulox.setGoalPosition(xHaptic, 0);
+ // calcHaptic();
+ // cellulox.setGoalPosition(xHaptic, 0);
- celluloy.setGoalPosition(0, yHaptic);
+ // celluloy.setGoalPosition(0, yHaptic);
}
if (_progress == 1.0) {
// cellulox.setGoalPosition(770, 600);
// celluloy.setGoalPosition(100, 80);
setState(() {
- setRun = false;
+ allowPaint = false;
});
- cellulox.setVelocity(0, 0);
- celluloy.setVelocity(0, 0);
+ // cellulox.setVelocity(0, 0);
+ // celluloy.setVelocity(0, 0);
}
if (celluloxPosition[0] > 800 ||
celluloyPosition[1] < 50 ||
celluloyPosition[1] > 800) {
cellulox.setVelocity(0, 0);
celluloy.setVelocity(0, 0);
}
});
super.initState();
// cellulox.resetrobot();
// celluloy.resetrobot();
timerCelluloPosition =
new Timer.periodic(new Duration(milliseconds: 500), (time) {
if (totalRobots() > 1) {
cellulox.getrobotx().then((val) => setState(() {
celluloxPosition[0] = val;
- print(celluloxPosition[0]);
- if (setRun == true)
- celluloxPositiontopaint.add(val * 500 / mapSizeWidth);
+ // print(celluloxPosition[0]);
+ // if (allowPaint == true)
+ // celluloxPositiontopaint.add(val * 500 / mapSizeWidth);
- // print(setRun.toString());
+ // print(allowPaint.toString());
}));
cellulox.getroboty().then((val) => setState(() {
celluloxPosition[1] = val;
- if (setRun == true) prevcelluloxPosition[1] = celluloxPosition[1];
+ //if (allowPaint == true) prevcelluloxPosition[1] = celluloxPosition[1];
}));
celluloy.getrobotx().then((val) => setState(() {
celluloyPosition[0] = val;
- if (setRun == true) prevcelluloyPosition[0] = celluloyPosition[0];
+ // if (allowPaint == true) prevcelluloyPosition[0] = celluloyPosition[0];
}));
celluloy.getroboty().then((val) => setState(() {
celluloyPosition[1] = val;
- if (setRun == true)
- celluloyPositiontopaint.add(val * 500 / mapSizeHeight);
+ // if (allowPaint == true)
+ // celluloyPositiontopaint.add(val * 500 / mapSizeHeight);
}));
-
- if (celluloxPosition[0] > 800 || celluloyPosition[1] > 800) {
- cellulox.setVelocity(0, 0);
- celluloy.setVelocity(0, 0);
+ if (checkend == true) {
+ if (celluloxPosition[0] > 800 ||
+ celluloyPosition[1] > 800 ||
+ celluloxPosition[0] < 50 ||
+ celluloyPosition[1] < 50) {
+ cellulox.clearrobot();
+ celluloy.clearrobot();
+ runHaptic = false;
+ showAlertDialog(context, '', 'Make sure robots are on the map');
+ checkend = false;
+ }
}
}
+ if (true) {
+ var distancePointStartX = math.sqrt(
+ math.pow((celluloxPosition[0] - originCoordinates[0]), 2) +
+ math.pow((celluloxPosition[1] - xcelluloy), 2));
+ var distancePointStartY = math.sqrt(
+ math.pow((celluloyPosition[0] - ycellulox), 2) +
+ math.pow((celluloyPosition[1] - originCoordinates[1]), 2));
+
+ if (distancePointStartY < 10 && distancePointStartX < 10) {
+ celluloy.clearrobot();
+ cellulox.clearrobot();
+ setState(() {
+ allowPaint = true;
+ runHaptic = true;
+ });
+ }
+ }
+
+ if (runHaptic == true) {
+ calcHaptic();
+ }
});
- timerprevCelluloPositiontoserver =
+ timerCelluloPositionPainttoserver =
new Timer.periodic(new Duration(milliseconds: 800), (time) {
- if (setRun == true) {
+ if (allowPaint == true) {
dbRef.child("celluloPosition").push().set(json.encode({
"x": celluloxPosition[0],
"y": celluloyPosition[1],
"acID": "Ac6",
"turn": currentTurn,
"groupID": group.id,
}));
}
});
- timerprevCelluloPosition =
- new Timer.periodic(new Duration(seconds: 40), (time) {
+ timerCelluloPositionPaint =
+ new Timer.periodic(new Duration(seconds: 1), (time) {
setState(() {
- if (setRun == true) {
- prevcelluloxPosition[0] = celluloxPosition[0];
- prevcelluloxPosition[1] = celluloxPosition[1];
- prevcelluloyPosition[0] = celluloyPosition[0];
- prevcelluloyPosition[1] = celluloyPosition[1];
+ if (allowPaint == true) {
+ celluloxPositiontopaint[tapCounter - 1]
+ .add(celluloxPosition[0] * screenSizeWidth / mapSizeWidth);
+ celluloyPositiontopaint[tapCounter - 1]
+ .add(celluloyPosition[1] * screenSizeHeight / mapSizeHeight);
}
});
});
timerInactivityDetector =
new Timer.periodic(new Duration(seconds: 60), (time) {
onInactivityTimer();
});
///
/// Ask to be notified when messages related to the game
/// are sent by the server
///
}
void onDataSend() {
dbRef.child('attempts').push().set(json.encode({
"numAttempts": tapCounter,
"groupID": group.id,
"acID": "Ac6",
"elpasedTime": elapseTimer.elapsedMilliseconds -
progressElpasedTime[currentTurn - 1],
"progress": {
"turn1": progress[0],
"turn2": progress[1],
"turn3": progress[2]
},
"progressElpasedTime": {
"turn1": progressElpasedTime[0],
"turn2": progressElpasedTime[1],
"turn3": progressElpasedTime[2],
},
"currentTurn": currentTurn,
"inactivity": inactivity,
"mistakes": {
"turn1": {
"slope": mistakesSlope[0],
"initialPoint": mistakesInitialPosition[0]
},
"turn2": {
"slope": mistakesSlope[1],
"initialPoint": mistakesInitialPosition[1]
},
"turn3": {
"slope": mistakesSlope[2],
"initialPoint": mistakesInitialPosition[2]
},
}
}));
}
void slopeDtectionTimer() {
timerslopedetection = new Timer.periodic(new Duration(seconds: 1), (time) {
print("prev" +
(((celluloxPosition[0] - prevcelluloxPositionSlope).roundToDouble() >
0)
.toString()));
// print("currwnt" + celluloxPosition[0].toString());
controllerXslope.text = 1.0.toString();
if ((celluloxPosition[0] - prevcelluloxPositionSlope).abs() < 10) {
controllerYslope.text = "You sould move the RED robot faster";
} else {
controllerYslope.text =
(((prevcelluloyPositionSlope - celluloyPosition[1])) /
(celluloxPosition[0] - prevcelluloxPositionSlope))
.roundToDouble()
.toString();
}
prevcelluloxPositionSlope = celluloxPosition[0];
prevcelluloyPositionSlope = celluloyPosition[1];
// print(int.parse(controllerXslope.text) > 0);
print("cur" +
(((celluloxPosition[0] - prevcelluloxPositionSlope).roundToDouble() >
0)
.toString()));
if ((celluloxPosition[0] - prevcelluloxPositionSlope).roundToDouble() >
1) {
setState(() {
celluloxSwitch2 = true;
print(celluloxSwitch2);
});
}
if (((celluloxPosition[0] - prevcelluloxPositionSlope) / 100)
.roundToDouble() <
-1) {
setState(() {
celluloxSwitch2 = false;
print(celluloxSwitch2);
});
}
if (celluloyPosition[1] - prevcelluloyPositionSlope > 0) {
setState(() {
celluloySwitch2 = true;
print(celluloySwitch2);
});
}
if (celluloyPosition[1] - prevcelluloyPositionSlope < 1.0) {
setState(() {
celluloySwitch2 = false;
print(celluloySwitch2);
});
}
});
}
void onInactivityTimer() {
group.inactivity = group.inactivity + 1;
}
@override
void dispose() {
- cellulox.resetrobot();
- celluloy.resetrobot();
+ cellulox.clearrobot();
+ celluloy.clearrobot();
timer.cancel();
timerCelluloPosition.cancel();
+ timerCelluloPositionPaint.cancel();
+ timerCelluloPositionPainttoserver.cancel();
controllerTrial.dispose();
super.dispose();
}
AppLifecycleState _notification;
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.resumed) {
dbRef.child('groups').child(group.id).child('tabletStatus').set("YES");
} else {
dbRef.child('groups').child(group.id).child('tabletStatus').set("NO");
}
setState(() {
_notification = state;
});
}
void nextPLayer() {
setState(() {
currentTurn = currentTurn + 1;
// celluloyPositiontopaint = [0.0, 0.0];
// celluloxPositiontopaint = [0.0, 0.0];
});
}
void animationRunner(progress) {}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Move your robots'),
),
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Column(children: [
Container(
// margin: const EdgeInsets.all(15.0),
padding: const EdgeInsets.all(5.0),
decoration: BoxDecoration(),
- height: 190.0,
+ height: 290.0,
child: Column(children: [
Card(
+ color: Colors.blue,
child: ListTile(
title: Text(
- ' Take the robots in each of your hands and try to follow the line'),
+ ' Each of you Take the robots in your hands and try to follow the red line',
+ style: new TextStyle(
+ color: Colors.white,
+ fontSize: 20,
+ ),
+ ),
),
),
+ SizedBox(
+ height: 10,
+ ),
Row(
//mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 470,
child: Card(
+ color: Colors.blue,
child: ListTile(
- title:
- Text(' When you are ready Start the game.'),
+ title: Text(
+ ' When you are ready Start the game.',
+ style: new TextStyle(
+ color: Colors.white,
+ fontSize: 20,
+ ),
+ ),
),
)),
- SizedBox(width: 25),
+ SizedBox(width: 40),
Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(100)),
- color: Colors.blue),
+ color: Colors.green),
child: FlatButton(
child: Text(
"Start",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 18),
),
// tooltip: 'Run the Robots',
onPressed: () => {
- tapCounter = tapCounter + 1,
// avgActivation=
- setState(() {
- setRun = false;
- }),
- onDataSend(),
- controllerTrial.reset(),
- controllerTrial.forward(),
+ if (tapCounter < 3)
+ {
+ setState(() {
+ checkend = true;
+ allowPaint = false;
+ runHaptic = false;
+ lineallow[tapCounter] = true;
+ tapCounter = tapCounter + 1;
+ }),
+ cellulox.setGoalPosition(
+ originCoordinates[0], 820, 150),
+ celluloy.setGoalPosition(
+ 45, originCoordinates[1], 150),
+
+ // onDataSend(),
+ }
+ else
+ {
+ showAlertDialog(
+ context,
+ 'Lets go to next turn',
+ 'Lets try a new line'),
+ },
+
+ // onDataSend(),
+ // controllerTrial.reset(),
+ // controllerTrial.forward(),
},
)),
SizedBox(width: 15),
+ ]),
+ Row(
+ //mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Container(
+ width: 470,
+ child: Card(
+ color: Colors.blue,
+ child: ListTile(
+ title: Text(
+ ' When you all tried, go to next turn.',
+ style: new TextStyle(
+ color: Colors.white,
+ fontSize: 20,
+ ),
+ ),
+ ),
+ )),
+ SizedBox(width: 25),
+ SizedBox(width: 15),
Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(100)),
color: Colors.blue),
child: FlatButton(
child: Text(
"Next Turn",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 18),
),
onPressed: () => {
- setState(() {
- tapCounter = 0;
- currentTurn = currentTurn + 1;
- if (currentTurn == 2) {
- progressElpasedTime[0] =
- elapseTimer.elapsedMilliseconds;
- } else {
- progressElpasedTime[currentTurn - 2] =
- elapseTimer.elapsedMilliseconds -
- progressElpasedTime[currentTurn - 3];
- }
- }),
- if (progress[currentTurn - 2] == 0)
- progress[currentTurn - 2] = -1,
if (currentTurn < 4)
{
- celluloxPositiontopaint = [0, 0],
- celluloyPositiontopaint = [0, 0],
+ setState(() {
+ tapCounter = 0;
+ currentTurn = currentTurn + 1;
+ lineallow = [false, false, false];
+ runHaptic = false;
+ if (currentTurn == 2) {
+ progressElpasedTime[0] =
+ elapseTimer.elapsedMilliseconds;
+ } else {
+ progressElpasedTime[currentTurn - 2] =
+ elapseTimer.elapsedMilliseconds -
+ progressElpasedTime[
+ currentTurn - 3];
+ }
+ celluloxPositiontopaint[0] = [0, 0];
+ celluloyPositiontopaint[0] = [0, 0];
+ celluloxPositiontopaint[1] = [0, 0];
+ celluloyPositiontopaint[1] = [0, 0];
+ celluloxPositiontopaint[2] = [0, 0];
+ celluloyPositiontopaint[2] = [0, 0];
+ }),
+ if (progress[currentTurn - 2] == 0)
+ progress[currentTurn - 2] = -1,
+
// controller.reset(),
- cellulox.setGoalPosition(
- originCoordinates[0], 600),
- celluloy.setGoalPosition(
- 100, originCoordinates[1]),
+
setState(() {
- setRun = false;
+ allowPaint = false;
}),
progress[currentTurn - 1] = 0,
- onDataSend(),
+ // onDataSend(),
+ }
+ else
+ {
+ showAlertDialog(context, 'Wait for teacher',
+ 'Game has finished! '),
},
},
)),
]),
])),
SizedBox(
- height: 5,
+ height: 70,
),
celluloMap(
context,
celluloxPositiontopaint,
celluloyPositiontopaint,
celluloxPosition,
celluloyPosition,
mapPath,
linesPath[currentTurn - 1],
celluloxpath,
celluloypath,
mapSizeWidth,
mapSizeHeight,
'Right Hand',
- 'Left Hand'),
+ 'Left Hand',
+ xlabelposition,
+ ylabelposition,
+ lineallow),
SizedBox(
- height: 15,
+ height: 125,
),
MembersBar(
curTurn: currentTurn,
),
])));
}
}
diff --git a/student/lib/Activities/Ac7.Dart b/student/lib/Activities/Ac7.Dart
index 8a61304..c6308f8 100644
--- a/student/lib/Activities/Ac7.Dart
+++ b/student/lib/Activities/Ac7.Dart
@@ -1,688 +1,796 @@
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:student/widgets/celluloMap.Dart';
import 'dart:async';
import 'dart:convert';
import 'package:student/Database.dart';
import 'package:student/model/Group.dart';
import 'package:student/model/Cellulo.dart';
import 'package:student/widgets/showAlertDialog.Dart';
import 'package:student/widgets/membersBar.Dart';
import 'package:student/widgets/inactivityDetector.Dart';
import 'package:flutter_appavailability/flutter_appavailability.dart';
-import 'package:student/widgets/showAlertDialog.Dart';
+
+import 'dart:math' as math;
class Ac7 extends StatefulWidget {
Ac7({Key key}) : super(key: key);
@override
_Ac7State createState() => _Ac7State();
}
class _Ac7State extends State
with SingleTickerProviderStateMixin, WidgetsBindingObserver {
// Timers
Timer timerCelluloPosition;
Timer timerslopedetection;
+ Timer timerCelluloPositionPaint;
Timer timercleartracking;
Timer timerprevCelluloPosition;
Timer timerInactivityDetector;
Timer timerprevCelluloPositiontoserver;
final acID = 7;
final maxLiitCellulo = 800;
// UI parameters
bool celluloxSwitch1 = true;
bool celluloySwitch1 = false;
bool celluloxSwitch2 = true;
bool celluloySwitch2 = false;
var onStop = false;
bool mode = false;
int wrongcounts = 0;
double _progress = 0.0;
final celluloSize = 60;
final ScrollController _scrollController = ScrollController();
- final functionFormulas = ['X ⟼ Y', 'X+1 ⟼ Y', 'X+2 ⟼ Y', '2*X ⟼ Y', '-X ⟼ Y'];
Offset beginpath = Offset(0, 0);
Offset endpath = Offset(10, 100);
AnimationController controllerTrial;
AnimationController controllerTurn;
Animation animation;
Animation animationNextTurn;
TextEditingController controllerinitialX = TextEditingController();
TextEditingController controllerinitialY = TextEditingController();
TextEditingController controllerXslope = TextEditingController();
TextEditingController controllerYslope = TextEditingController();
var counterfunctionImage = 0;
//Activity Dependent
var linesPath = [
'assets/images/Ac7_function1.svg',
'assets/images/Ac7_function2.svg',
'assets/images/Ac7_function3.svg',
- 'assets/images/GridOnlyPositive.svg',
+ 'assets/images/Grid_Ac7_Screen.svg',
];
// map-related
final double mapSizeWidth = 860;
final double mapSizeHeight = 860;
+ final double screenSizeWidth = 500;
+ final double screenSizeHeight = 500;
final String mapPath = 'assets/images/Grid_Ac7_Screen.svg';
final String celluloxpath = 'assets/images/celluloRed.svg';
final String celluloypath = 'assets/images/celluloBlue.svg';
var onTap = [false, false, false, false, false];
// var onTap=[false,false,false,false,false];
-
+ bool checkorigin;
var currentTurn = 1;
var currentTap = 0;
var tapCounter = 0;
int simulationVelCoeff = 1;
// Learning
List progress = [0, -2, -2];
// zero: undergoing, -1: not accomplished, 1: accomplished
bool waitforanimation = false;
List mistakesSlope = [0, 0, 0];
List mistakesIntrepet = [0, 0, 0];
List mistakesInitialPosition = [0, 0, 0];
List progressElpasedTime = [0, 0, 0];
var inactivity = 0;
var prevcelluloxPositionSlope = 0.0;
var prevcelluloyPositionSlope = 0.0;
// robot related
var elapseTimer = new Stopwatch();
- bool setRun = false;
+ bool allowPaint = false;
var celluloxPosition = [0.0, 0.0];
var celluloyPosition = [0.0, 0.0];
- List celluloxPositiontopaint = [0.0, 0.0];
- List celluloyPositiontopaint = [0.0, 0.0];
+ List> celluloxPositiontopaint =
+ new List.generate(3, (int index) => [0.0, 0.0], growable: true);
+ List> celluloyPositiontopaint =
+ new List.generate(3, (int index) => [0.0, 0.0], growable: true);
var prevcelluloxPosition = [0.0, 0.0];
var prevcelluloyPosition = [0.0, 0.0];
-
+ var xlabelposition = [1.0, 0.7];
+ var ylabelposition = [-1.0, -1.0];
+ var lineallow = [true, false, false];
+ bool sendtoend = false;
+ bool checkend = true;
// screen-related
- var originCoordinates = [303.08, 563.08];
-
+ static var originCoordinates = [225.5, 633.5];
+
+ List beginpathlist = [
+ Offset(originCoordinates[0] - 300, originCoordinates[1] + 300),
+ Offset(originCoordinates[0] - 300, originCoordinates[1] + 200),
+ Offset(originCoordinates[0] - 300, originCoordinates[1] + 100),
+ Offset(originCoordinates[0] - 200, originCoordinates[1] + 400),
+ Offset(originCoordinates[0] - 300, originCoordinates[1] - 300),
+ ];
+ List endpathlist = [
+ Offset(originCoordinates[0] + 600, originCoordinates[1] - 400),
+ Offset(originCoordinates[0] + 400, originCoordinates[1] - 600),
+ Offset(originCoordinates[0] + 200, originCoordinates[1] - 400),
+ Offset(originCoordinates[0] + 200, originCoordinates[1] - 400),
+ Offset(originCoordinates[0] + 300, originCoordinates[1] + 300),
+ ];
+ var xcelluloy = 760;
+ var ycellulox = 45;
var correctAnswer = [
- {"initialPointX": 0, "initialPointY": 0, "slope": 1},
- {"initialPointX": 0, "initialPointY": 1, "slope": 1},
- {"initialPointX": 0, "initialPointY": 0, "slope": 2}
+ {"initialPointX": 2, "initialPointY": 0, "slope": 1},
+ {"initialPointX": 0, "initialPointY": 2, "slope": 1},
+ {"initialPointX": 0, "initialPointY": 5, "slope": -1}
];
@override
void initState() {
+ cellulox.setColor(0, 255, 0, 0, 0);
+
+ celluloy.setColor(0, 0, 255, 0, 0);
+ cellulox.clearrobot();
+ celluloy.clearrobot();
WidgetsBinding.instance.addObserver(this);
dbRef.child('groups').child(group.id).child('tabletStatus').set("YES");
dbRef.child('groups').child(group.id).child('currentActivity').set("Ac7");
elapseTimer.start();
onDataSend();
controllerTrial = AnimationController(
duration: Duration(milliseconds: 30000), vsync: this);
animation = Tween(begin: 0.0, end: 1.0).animate(controllerTrial)
..addListener(() {
_progress = animation.value;
if (_progress < 0.2) {
//print('uuh');
cellulox.setGoalPosition(
originCoordinates[0] + 100 * int.parse(controllerinitialX.text),
- 600);
- celluloy.setGoalPosition(100,
- originCoordinates[1] - 100 * int.parse(controllerinitialY.text));
+ 600,
+ 150);
+ celluloy.setGoalPosition(
+ 100,
+ originCoordinates[1] - 100 * int.parse(controllerinitialY.text),
+ 150);
}
if (_progress > 0.22) {
setState(() {
- setRun = true;
+ allowPaint = true;
});
// cellulox.setGoalPosition(770, 600);
// celluloy.setGoalPosition(100, 80);
- cellulox.setVelocity(50.0 * simulationVelCoeff, 0);
- if (celluloySwitch1 == false)
- celluloy.setVelocity(0,
- -50.0 * simulationVelCoeff * int.parse(controllerYslope.text));
- if (celluloySwitch1 == true)
- celluloy.setVelocity(0,
- 50.0 * simulationVelCoeff * int.parse(controllerYslope.text));
+
+ if (celluloxPosition[0] > 700 ||
+ celluloyPosition[1] < 100 ||
+ celluloyPosition[1] > 700) {}
// }
//if (celluloxPosition[0] > 700 ||
// celluloyPosition[1] < 100) {
// cellulox.resetrobot();
// celluloy.resetrobot();
}
if (_progress == 1.0) {
// cellulox.setGoalPosition(770, 600);
// celluloy.setGoalPosition(100, 80);
cellulox.setVelocity(0, 0);
celluloy.setVelocity(0, 0);
}
- if (celluloxPosition[0] > 800 ||
- celluloyPosition[1] < 50 ||
- celluloyPosition[1] > 800) {
- cellulox.setVelocity(0, 0);
- celluloy.setVelocity(0, 0);
- }
});
super.initState();
+
// cellulox.resetrobot();
//celluloy.resetrobot();
timerCelluloPosition =
new Timer.periodic(new Duration(milliseconds: 500), (time) {
if (totalRobots() > 1) {
cellulox.getrobotx().then((val) => setState(() {
celluloxPosition[0] = val;
print(celluloxPosition[0]);
- if (setRun == true) celluloxPositiontopaint.add(val * 500 / 860);
+ // if (allowPaint == true) celluloxPositiontopaint.add(val * 500 / 860);
- // print(setRun.toString());
+ // print(allowPaint.toString());
}));
cellulox.getroboty().then((val) => setState(() {
celluloxPosition[1] = val;
- if (setRun == true) prevcelluloxPosition[1] = celluloxPosition[1];
+ if (allowPaint == true)
+ prevcelluloxPosition[1] = celluloxPosition[1];
}));
celluloy.getrobotx().then((val) => setState(() {
celluloyPosition[0] = val;
- if (setRun == true) prevcelluloyPosition[0] = celluloyPosition[0];
+ if (allowPaint == true)
+ prevcelluloyPosition[0] = celluloyPosition[0];
}));
celluloy.getroboty().then((val) => setState(() {
celluloyPosition[1] = val;
- if (setRun == true) celluloyPositiontopaint.add(val * 500 / 860);
+ // if (allowPaint == true) celluloyPositiontopaint.add(val * 500 / 860);
}));
+ }
- if (celluloxPosition[0] > 800 || celluloyPosition[1] > 800) {
- cellulox.setVelocity(0, 0);
- celluloy.setVelocity(0, 0);
+ if (checkend) {
+ if (celluloxPosition[0] > 800 ||
+ celluloyPosition[1] > 800 ||
+ celluloyPosition[1] < 100) {
+ cellulox.clearrobot();
+ celluloy.clearrobot();
+ showAlertDialog(context, '', 'Make sure robots are on the map');
+ checkend = false;
+ }
+ }
+
+ if (checkorigin) {
+ var distancePointStartX = math.sqrt(math.pow(
+ (celluloxPosition[0] -
+ (originCoordinates[0] +
+ 100 * int.parse(controllerinitialX.text))),
+ 2) +
+ math.pow((celluloxPosition[1] - xcelluloy), 2));
+ var distancePointStartY = math.sqrt(
+ math.pow((celluloyPosition[0] - ycellulox), 2) +
+ math.pow(
+ (celluloyPosition[1] -
+ (originCoordinates[1] -
+ 100 * int.parse(controllerinitialY.text))),
+ 2));
+
+ if (distancePointStartX < 10 && distancePointStartY < 10) {
+ cellulox.clearrobot();
+ celluloy.clearrobot();
+ setState(() {
+ allowPaint = true;
+ checkorigin = false;
+ sendToEnd();
+ //runHaptic = true;
+ });
}
}
});
+ timerCelluloPositionPaint =
+ new Timer.periodic(new Duration(seconds: 1), (time) {
+ setState(() {
+ if (allowPaint == true) {
+ celluloxPositiontopaint[0]
+ .add(celluloxPosition[0] * screenSizeWidth / mapSizeWidth);
+ celluloyPositiontopaint[0]
+ .add(celluloyPosition[1] * screenSizeHeight / mapSizeHeight);
+ }
+ });
+ });
+
timerprevCelluloPositiontoserver =
new Timer.periodic(new Duration(milliseconds: 800), (time) {
- if (setRun == true) {
+ if (allowPaint == true) {
dbRef.child("celluloPosition").push().set(json.encode({
"x": celluloxPosition[0],
"y": celluloyPosition[1],
"acID": "Ac7",
"turn": currentTurn,
"groupID": group.id,
}));
}
});
timerprevCelluloPosition =
new Timer.periodic(new Duration(seconds: 40), (time) {
setState(() {
- if (setRun == true) {
+ if (allowPaint == true) {
prevcelluloxPosition[0] = celluloxPosition[0];
prevcelluloxPosition[1] = celluloxPosition[1];
prevcelluloyPosition[0] = celluloyPosition[0];
prevcelluloyPosition[1] = celluloyPosition[1];
}
});
});
timerInactivityDetector =
new Timer.periodic(new Duration(seconds: 60), (time) {
onInactivityTimer();
});
///
/// Ask to be notified when messages related to the game
/// are sent by the server
///
}
+ void sendToEnd() {
+ setState(() {
+ checkend = true;
+ });
+ cellulox.setVelocity(50.0 * simulationVelCoeff, 0);
+ if (celluloySwitch1 == false)
+ celluloy.setVelocity(
+ 0, -50.0 * simulationVelCoeff * int.parse(controllerYslope.text));
+ if (celluloySwitch1 == true)
+ celluloy.setVelocity(
+ 0, 50.0 * simulationVelCoeff * int.parse(controllerYslope.text));
+ }
+
void onDataSend() {
dbRef.child('attempts').push().set(json.encode({
"numAttempts": tapCounter,
"groupID": group.id,
"acID": "Ac7",
"elpasedTime": elapseTimer.elapsedMilliseconds -
progressElpasedTime[currentTurn - 1],
"progress": {
"turn1": progress[0],
"turn2": progress[1],
"turn3": progress[2]
},
"progressElpasedTime": {
"turn1": progressElpasedTime[0],
"turn2": progressElpasedTime[1],
"turn3": progressElpasedTime[2],
},
"currentTurn": currentTurn,
"inactivity": inactivity,
"mistakes": {
"turn1": {
"slope": mistakesSlope[0],
"initialPoint": mistakesInitialPosition[0]
},
"turn2": {
"slope": mistakesSlope[1],
"initialPoint": mistakesInitialPosition[1]
},
"turn3": {
"slope": mistakesSlope[2],
"initialPoint": mistakesInitialPosition[2]
},
}
}));
}
void slopeDtectionTimer() {
timerslopedetection = new Timer.periodic(new Duration(seconds: 1), (time) {
print("prev" +
(((celluloxPosition[0] - prevcelluloxPositionSlope).roundToDouble() >
0)
.toString()));
// print("currwnt" + celluloxPosition[0].toString());
controllerXslope.text = 1.0.toString();
if ((celluloxPosition[0] - prevcelluloxPositionSlope).abs() < 10) {
controllerYslope.text = "You sould move the RED robot faster";
} else {
controllerYslope.text =
(((prevcelluloyPositionSlope - celluloyPosition[1])) /
(celluloxPosition[0] - prevcelluloxPositionSlope))
.roundToDouble()
.toString();
}
prevcelluloxPositionSlope = celluloxPosition[0];
prevcelluloyPositionSlope = celluloyPosition[1];
// print(int.parse(controllerXslope.text) > 0);
print("cur" +
(((celluloxPosition[0] - prevcelluloxPositionSlope).roundToDouble() >
0)
.toString()));
if ((celluloxPosition[0] - prevcelluloxPositionSlope).roundToDouble() >
1) {
setState(() {
celluloxSwitch2 = true;
print(celluloxSwitch2);
});
}
if (((celluloxPosition[0] - prevcelluloxPositionSlope) / 100)
.roundToDouble() <
-1) {
setState(() {
celluloxSwitch2 = false;
print(celluloxSwitch2);
});
}
if (celluloyPosition[1] - prevcelluloyPositionSlope > 0) {
setState(() {
celluloySwitch2 = true;
print(celluloySwitch2);
});
}
if (celluloyPosition[1] - prevcelluloyPositionSlope < 1.0) {
setState(() {
celluloySwitch2 = false;
print(celluloySwitch2);
});
}
});
}
void onInactivityTimer() {
group.inactivity = group.inactivity + 1;
}
@override
void dispose() {
- cellulox.resetrobot();
- celluloy.resetrobot();
+ cellulox.clearrobot();
+ celluloy.clearrobot();
timer.cancel();
timerCelluloPosition.cancel();
+ timerprevCelluloPositiontoserver.cancel();
controllerTrial.dispose();
super.dispose();
}
AppLifecycleState _notification;
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.resumed) {
dbRef.child('groups').child(group.id).child('tabletStatus').set("YES");
} else {
dbRef.child('groups').child(group.id).child('tabletStatus').set("NO");
}
setState(() {
_notification = state;
});
}
void nextPLayer() {
setState(() {
currentTurn = currentTurn + 1;
// celluloyPositiontopaint = [0.0, 0.0];
// celluloxPositiontopaint = [0.0, 0.0];
});
}
void animationRunner(progress) {}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
+ backgroundColor: Colors.lightBlue,
title: const Text('Control your robots'),
),
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Column(children: [
Container(
// margin: const EdgeInsets.all(15.0),
padding: const EdgeInsets.all(5.0),
decoration: BoxDecoration(),
- height: 390.0,
+ height: 420.0,
child: Column(children: [
Card(
+ color: Colors.lightBlue,
child: ListTile(
title: Text(
- 'Choose the two points that your robots start from: '),
+ 'Choose the two points that your robots start from: ',
+ style: new TextStyle(
+ color: Colors.white,
+ fontSize: 18,
+ fontWeight: FontWeight.bold,
+ ),
+ ),
),
),
+ SizedBox(
+ height: 20,
+ ),
Row(
// crossAxisAlignment: CrossAxisAlignment.start,
- // mainAxisAlignment: MainAxisAlignment.spaceAround,
+ mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 250,
child: new TextFormField(
controller: controllerinitialX,
keyboardType: TextInputType.number,
decoration: new InputDecoration(
labelText: "RED starts at this position:",
fillColor: Colors.red,
border: new OutlineInputBorder(
borderRadius: new BorderRadius.circular(25.0),
borderSide: new BorderSide(),
),
//fillColor: Colors.green
),
validator: (val) {
if (val.length == 0) {
return "Email cannot be empty";
} else {
return null;
}
},
style: new TextStyle(
fontFamily: "Poppins",
),
),
),
- SizedBox(width: 158),
+ SizedBox(width: 38),
Container(
width: 250,
child: new TextFormField(
controller: controllerinitialY,
keyboardType: TextInputType.number,
decoration: new InputDecoration(
labelText: "BLUE starts at this position:",
fillColor: Colors.blue,
border: new OutlineInputBorder(
borderRadius: new BorderRadius.circular(25.0),
borderSide: new BorderSide(),
),
//fillColor: Colors.green
),
validator: (val) {
if (val.length == 0) {
return "Email cannot be empty";
} else {
return null;
}
},
style: new TextStyle(
fontFamily: "Poppins",
),
),
),
]),
+ SizedBox(
+ height: 20,
+ ),
Card(
+ color: Colors.lightBlue,
child: ListTile(
title: Text(
- ' Choose how much the blue robot should move when the red robot has moved by one.'),
- ),
- ),
- Row(children: [
- Container(
- width: 250,
- child: new TextFormField(
- enabled: false,
- // controller: controllerXslope,
- decoration: new InputDecoration(
- labelText: "When RED moves by 1",
- fillColor: Colors.red,
- border: new OutlineInputBorder(
- borderRadius: new BorderRadius.circular(25.0),
- borderSide: new BorderSide(),
- ),
- //fillColor: Colors.green
- ),
- validator: (val) {
- if (val.length == 0) {
- return "Email cannot be empty";
- } else {
- return null;
- }
- },
- keyboardType: TextInputType.text,
+ ' Choose how much the blue robot should move when the red robot has moved by one.',
style: new TextStyle(
- fontFamily: "Poppins",
+ color: Colors.white,
+ fontSize: 18,
+ fontWeight: FontWeight.bold,
),
),
),
- Column(children: [
- Container(
- child: Switch(
- value: celluloxSwitch1,
- onChanged: (value) {
- setState(() {
- // celluloxSwitch1 = value;
- });
- },
- activeTrackColor: Colors.lightGreenAccent,
- activeColor: Colors.green,
- inactiveTrackColor: Colors.lightGreenAccent,
- inactiveThumbColor: Colors.green,
- )),
- Text(celluloxSwitch1 ? 'Right' : 'Left')
- ]),
- SizedBox(width: 100),
- Container(
- width: 250,
- child: new TextFormField(
- controller: controllerYslope,
- keyboardType: TextInputType.number,
- decoration: new InputDecoration(
- labelText: "Then Blue should move by:",
- fillColor: Colors.blue,
- border: new OutlineInputBorder(
- borderRadius: new BorderRadius.circular(25.0),
- borderSide: new BorderSide(),
- ),
- //fillColor: Colors.green
- ),
- validator: (val) {
- if (val.length == 0) {
- return "Email cannot be empty";
- } else {
- return null;
- }
- },
- style: new TextStyle(
- fontFamily: "Poppins",
- ),
- )),
- Column(children: [
- RotatedBox(
- quarterTurns: 1,
- child: Switch(
- value: celluloySwitch1,
- onChanged: (value) {
- setState(() {
- celluloySwitch1 = value;
- });
- },
- activeTrackColor: Colors.lightGreenAccent,
- activeColor: Colors.green,
- inactiveTrackColor: Colors.lightGreenAccent,
- inactiveThumbColor: Colors.green,
- )),
- Text(celluloySwitch1 ? 'Down' : 'Up')
- ]),
- ]),
+ ),
+ SizedBox(
+ height: 20,
+ ),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Container(
+ width: 250,
+ child: new TextFormField(
+ controller: controllerYslope,
+ keyboardType: TextInputType.number,
+ decoration: new InputDecoration(
+ labelText: "Then Blue should move by:",
+ fillColor: Colors.blue,
+ border: new OutlineInputBorder(
+ borderRadius: new BorderRadius.circular(25.0),
+ borderSide: new BorderSide(),
+ ),
+ //fillColor: Colors.green
+ ),
+ validator: (val) {
+ if (val.length == 0) {
+ return "Email cannot be empty";
+ } else {
+ return null;
+ }
+ },
+ style: new TextStyle(
+ fontFamily: "Poppins",
+ ),
+ )),
+ SizedBox(width: 25),
+ Column(children: [
+ RotatedBox(
+ quarterTurns: 1,
+ child: Switch(
+ value: celluloySwitch1,
+ onChanged: (value) {
+ setState(() {
+ celluloySwitch1 = value;
+ });
+ },
+ activeTrackColor: Colors.lightGreenAccent,
+ activeColor: Colors.green,
+ inactiveTrackColor: Colors.lightGreenAccent,
+ inactiveThumbColor: Colors.green,
+ )),
+ Text(celluloySwitch1 ? 'Down' : 'Up')
+ ]),
+ ]),
SizedBox(
height: 5,
),
Row(
//mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 470,
child: Card(
+ color: Colors.lightBlue,
child: ListTile(
title: Text(
- ' Run the Robots to see if your answer matches the Red Line.'),
+ ' Run the Robots to see if your answer matches the Red Line.',
+ style: new TextStyle(
+ color: Colors.white,
+ fontSize: 18,
+ fontWeight: FontWeight.bold,
+ ),
+ ),
),
)),
SizedBox(width: 25),
Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(100)),
- color: Colors.blue),
+ color: Colors.green),
child: FlatButton(
child: Text(
"Run Robots",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 18),
),
// tooltip: 'Run the Robots',
onPressed: () => {
- tapCounter = tapCounter + 1,
+ if (controllerinitialX.text != '' &&
+ controllerinitialY.text != '' &&
+ controllerYslope.text != '')
+ {
+ celluloxPositiontopaint[0] = [0, 0],
+ celluloyPositiontopaint[0] = [0, 0],
+ cellulox.setGoalPosition(
+ originCoordinates[0] +
+ 100 *
+ int.parse(
+ controllerinitialX.text),
+ xcelluloy.toDouble(),
+ 150),
+ celluloy.setGoalPosition(
+ ycellulox.toDouble(),
+ originCoordinates[1] -
+ 100 *
+ int.parse(
+ controllerinitialY.text),
+ 150),
+ setState(() {
+ tapCounter = tapCounter + 1;
+ checkorigin = true;
+ checkend = false;
+ }),
+ }
+ else
+ {
+ showAlertDialog(context, '',
+ 'Dont forget to fill all fileds please!'),
+ },
+
// avgActivation=
if (controllerinitialX.text !=
correctAnswer[currentTurn - 1]
['initialPointX']
.toString() ||
controllerinitialY.text !=
correctAnswer[currentTurn - 1]
['initialPointY']
.toString())
{
mistakesInitialPosition[currentTurn - 1] =
mistakesInitialPosition[currentTurn - 1] +
1,
},
if (controllerYslope.text !=
correctAnswer[currentTurn - 1]['slope']
.toString())
{
mistakesSlope[currentTurn - 1] =
mistakesSlope[currentTurn - 1] + 1,
},
if (controllerinitialX.text ==
correctAnswer[currentTurn - 1]
['initialPointX']
.toString() &&
controllerinitialY.text ==
correctAnswer[currentTurn - 1]
['initialPointY']
.toString() &&
controllerYslope.text ==
correctAnswer[currentTurn - 1]['slope']
.toString())
{
progress[currentTurn - 1] = 1,
},
onDataSend(),
- controllerTrial.reset(),
- controllerTrial.forward(),
+
+ // controllerTrial.reset(),
+ // controllerTrial.forward(),
},
)),
SizedBox(width: 15),
Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(100)),
color: Colors.blue),
child: FlatButton(
child: Text(
"Next Turn",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 18),
),
onPressed: () => {
- setState(() {
- tapCounter = 0;
- currentTurn = currentTurn + 1;
- if (currentTurn == 2) {
- progressElpasedTime[0] =
- elapseTimer.elapsedMilliseconds;
- } else {
- progressElpasedTime[currentTurn - 2] =
- elapseTimer.elapsedMilliseconds -
- progressElpasedTime[currentTurn - 3];
- }
- }),
- if (progress[currentTurn - 2] == 0)
- progress[currentTurn - 2] = -1,
if (currentTurn < 4)
{
- celluloxPositiontopaint = [0, 0],
- celluloyPositiontopaint = [0, 0],
+ setState(() {
+ tapCounter = 0;
+ currentTurn = currentTurn + 1;
+ if (currentTurn == 2) {
+ progressElpasedTime[0] =
+ elapseTimer.elapsedMilliseconds;
+ } else {
+ progressElpasedTime[currentTurn - 2] =
+ elapseTimer.elapsedMilliseconds -
+ progressElpasedTime[
+ currentTurn - 3];
+ }
+ celluloxPositiontopaint[0] = [0, 0];
+ celluloyPositiontopaint[0] = [0, 0];
+ }),
+ if (progress[currentTurn - 2] == 0)
+ progress[currentTurn - 2] = -1,
+
// controller.reset(),
- cellulox.setGoalPosition(
- originCoordinates[0] +
- 100 *
- int.parse(
- controllerinitialX.text),
- 600),
- celluloy.setGoalPosition(
- 100,
- originCoordinates[1] -
- 100 *
- int.parse(
- controllerinitialY.text)),
- setRun = false,
+ allowPaint = false,
progress[currentTurn - 1] = 0,
onDataSend(),
+ }
+ else
+ {
+ showAlertDialog(context, 'Wait for teacher',
+ 'Game has finished! '),
},
},
)),
]),
])),
SizedBox(
height: 5,
),
celluloMap(
context,
celluloxPositiontopaint,
celluloyPositiontopaint,
celluloxPosition,
celluloyPosition,
mapPath,
linesPath[currentTurn - 1],
celluloxpath,
celluloypath,
mapSizeWidth,
- mapSizeHeight,'Ali','Sina'),
+ mapSizeHeight,
+ group.member1name,
+ group.member2name,
+ xlabelposition,
+ ylabelposition,
+ lineallow),
SizedBox(
height: 15,
),
MembersBar(
curTurn: currentTurn,
),
])));
}
}
diff --git a/student/lib/Activities/Ac8.Dart b/student/lib/Activities/Ac8.Dart
index c9f7ef8..8a89a01 100644
--- a/student/lib/Activities/Ac8.Dart
+++ b/student/lib/Activities/Ac8.Dart
@@ -1,417 +1,464 @@
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'dart:convert';
import 'dart:core';
import 'package:student/widgets/linePainter.Dart';
import 'dart:async';
import 'package:student/Data/data.dart';
import 'package:student/Database.dart';
import 'package:student/model/Group.dart';
import 'package:student/widgets/showAlertDialog.Dart';
import 'package:student/widgets/membersBar.Dart';
+import 'package:student/model/Cellulo.dart';
class Ac8 extends StatefulWidget {
Ac8({Key key}) : super(key: key);
@override
_Ac8State createState() => _Ac8State();
}
class _Ac8State extends State
with SingleTickerProviderStateMixin, WidgetsBindingObserver {
//Learning Parameters
// UI parameters
// Cellulo Simulation Parameters
Timer timer;
final acID = 8;
final acIDstring = 'Ac8';
var onStop = false;
int wrongcounts = 0;
double _progress = 0.0;
final celluloSize = 60;
final ScrollController _scrollController = ScrollController();
final functionFormulas = ['X ⟼ Y', 'X+1 ⟼ Y', 'X+2 ⟼ Y', '2*X ⟼ Y', '-X ⟼ Y'];
Offset beginpath = Offset(0, 0);
Offset endpath = Offset(10, 100);
- List beginpathlist = [
- Offset(150, 430),
- Offset(100, 432),
- Offset(100, 390),
- Offset(215, 490),
- Offset(110, 50),
- ];
- List endpathlist = [
- Offset(540, 40),
- Offset(480, 52),
- Offset(480, 10),
- Offset(425, 40),
- Offset(500, 430),
- ];
+
AnimationController controller;
Animation animation;
TextEditingController controller1 = TextEditingController();
TextEditingController controller2 = TextEditingController();
TextEditingController controller3 = TextEditingController();
List mistakesSlope = [0, 0, 0];
List mistakesIntercept = [0, 0, 0];
List mistakesInitialPosition = [0, 0, 0];
List progressElpasedTime = [0, 0, 0];
var counterfunctionImage = 0;
var imagespath = [
'assets/images/Ac8_function1.svg',
'assets/images/Ac8_function2.svg',
'assets/images/Ac8_function3.svg',
- 'assets/images/Grid.svg',
+ 'assets/images/Grid_Ac8_Screen.svg',
];
var correctAnswer = [
1,
3,
4,
- 1,
+ 4,
+ 4,
];
var onTap = [false, false, false, false, false];
// var onTap=[false,false,false,false,false];
-
+ static var originCoordinates = [427.3, 429.3];
+ List beginpathlist = [
+ Offset(originCoordinates[0] - 300, originCoordinates[1] + 300),
+ Offset(originCoordinates[0] - 300, originCoordinates[1] + 200),
+ Offset(originCoordinates[0] - 300, originCoordinates[1] + 100),
+ Offset(originCoordinates[0] - 200, originCoordinates[1] + 400),
+ Offset(originCoordinates[0] - 300, originCoordinates[1] - 300),
+ ];
+ List endpathlist = [
+ Offset(originCoordinates[0] + 300, originCoordinates[1] - 300),
+ Offset(originCoordinates[0] + 300, originCoordinates[1] - 400),
+ Offset(originCoordinates[0] + 200, originCoordinates[1] - 400),
+ Offset(originCoordinates[0] + 200, originCoordinates[1] - 400),
+ Offset(originCoordinates[0] + 300, originCoordinates[1] + 300),
+ ];
var currentTurn = 1;
var currentTap = 0;
var tapCounter = 0;
List progress = [0, -2, -2];
bool waitforanimation = false;
var mistakesSlopematrix = [
[0, 0, 0, 1, 1],
[0, 0, 0, 1, 1],
[1, 1, 1, 0, 1]
];
var mistakesInterceptmatrix = [
[0, 1, 1, 0, 0],
[1, 1, 0, 1, 1],
[0, 1, 1, 0, 0]
];
-
var inactivity = 0;
var elapseTimer = new Stopwatch();
AppLifecycleState _notification;
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.resumed) {
dbRef.child('groups').child(group.id).child('tabletStatus').set("YES");
} else {
dbRef.child('groups').child(group.id).child('tabletStatus').set("NO");
}
setState(() {
_notification = state;
});
}
@override
void initState() {
+ cellulox.setColor(0, 255, 0, 0, 0);
+
+ celluloy.setColor(0, 0, 255, 0, 0);
+ cellulox.clearrobot();
+ celluloy.clearrobot();
WidgetsBinding.instance.addObserver(this);
elapseTimer.start();
dbRef.child('groups').child(group.id).child('tabletStatus').set("YES");
dbRef.child('groups').child(group.id).child('currentActivity').set("Ac8");
onDataSend();
super.initState();
// group.numCurrentActivity = 8;
controller = AnimationController(
duration: Duration(milliseconds: 7000), vsync: this);
///
/// Ask to be notified when messages related to the game
/// are sent by the server
///
inactivityDtectionTimer();
}
@override
void dispose() {
elapseTimer.stop();
timer.cancel();
super.dispose();
}
void onDataSend() {
print(mistakesSlope);
dbRef.child('attempts').push().set(json.encode({
"numAttempts": tapCounter,
"groupID": group.id,
"acID": acIDstring,
"elpasedTime": elapseTimer.elapsedMilliseconds -
progressElpasedTime[currentTurn - 1],
"progress": {
"turn1": progress[0],
"turn2": progress[1],
"turn3": progress[2]
},
"progressElpasedTime": {
"turn1": progressElpasedTime[0],
"turn2": progressElpasedTime[1],
"turn3": progressElpasedTime[2],
},
"currentTurn": currentTurn,
"mistakes": {
"turn1": {
"slope": mistakesSlope[0],
"initialPoint": mistakesInitialPosition[0],
"intercept": mistakesIntercept[0]
},
"turn2": {
"slope": mistakesSlope[1],
"initialPoint": mistakesInitialPosition[1],
"intercept": mistakesIntercept[1]
},
"turn3": {
"slope": mistakesSlope[2],
"initialPoint": mistakesInitialPosition[2],
"intercept": mistakesIntercept[2]
},
}
}));
}
_onCorrectAnswer(BuildContext context) {
- if (currentTurn <= 2) {
+ if (currentTurn <= 3) {
showAlertDialog(context, 'Congrats',
'your answer was correct. Now its next player turn');
+ currentTurn = currentTurn + 1;
}
- currentTurn = currentTurn + 1;
- if (currentTurn >= 4) {
+ print(currentTurn);
+ if (currentTurn > 3) {
+ setState(() {
+ waitforanimation = false;
+ });
showAlertDialog(context, 'The Game has Finished', '');
// Navigator.pushNamed(context, '/second');
}
onTap = [false, false, false, false, false];
}
_onWrongAnswer(BuildContext context) {
// _onCorrectAnswer();
// play the animation
// go to next player
debugPrint("wroganswer");
wrongcounts = 0;
// debugPrint(currentTurn.toString());
// currentTurn = currentTurn + 1;
if (currentTurn >= 4) {
//currentTurn = 1;
}
// debugPrint(currentTurn.toString());
}
void inactivityDtectionTimer() {
timer = new Timer.periodic(new Duration(seconds: 10), (time) {
inactivity = inactivity + 1;
// dbRefonTapAll
// .child(group.id)
// .child("activity 8")
//.child("inactivity")
// .push()
// .set(inactivity);
});
// Start the periodic timer which prints something every 1 seconds
}
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Simulate your robot'),
),
backgroundColor: Colors.white,
body: Builder(
- builder: (context) => Column(children: [
+ builder: (context) => SingleChildScrollView(
+ child: Column(children: [
Card(
+ color: Colors.blue,
child: ListTile(
title: Text(
- 'Choose the option that describes the red line, you have only THREE attempts:'),
+ 'Choose the option that matches with the red line, try to :',
+ style: new TextStyle(
+ color: Colors.white,
+ ),
+ ),
),
),
Container(
margin: const EdgeInsets.all(15.0),
padding: const EdgeInsets.all(3.0),
decoration: BoxDecoration(border: Border.all()),
height: 250.0,
child: Scrollbar(
controller: _scrollController,
isAlwaysShown: true,
child: Container(
child: ListView.builder(
controller: _scrollController,
itemCount: 5,
itemBuilder: (context, int position) {
return Card(
child: ListTile(
onTap: () {
if (!waitforanimation) {
// Find the Scaffold in the widget tree and use
// it to show a SnackBar.
// timer.cancel();
// inactivityDtectionTimer();
currentTap = position + 1;
//inactivity = inactivity - 1;
onTap[currentTap - 1] = true;
- beginpath = beginpathlist[position];
- endpath = endpathlist[position];
+
+ setState(() {
+ beginpath = beginpathlist[position];
+ endpath = endpathlist[position];
+ });
+
controller.reset();
tapCounter = tapCounter + 1;
- if (currentTap ==
- correctAnswer[currentTurn - 1]) {
- wrongcounts = wrongcounts + 1;
- }
- if (wrongcounts == 3) {
- _onWrongAnswer(context);
- }
+
animation = Tween(begin: 0.0, end: 1.0)
.animate(controller)
..addListener(() {
setState(() {
_progress = animation.value;
});
})
..addStatusListener(
(AnimationStatus status) {
if (status ==
AnimationStatus.completed) {
waitforanimation = false;
if (currentTap ==
correctAnswer[
currentTurn - 1]) {
- progress[currentTurn - 1] = 1;
- progress[currentTurn] = 0;
+ if (currentTurn < 3) {
+ progress[currentTurn - 1] = 1;
+
+ progress[currentTurn] = 0;
+ }
tapCounter = 0;
+
_onCorrectAnswer(context);
// controller.reverse();
endpath = beginpath;
}
//print('completed');
} else {
waitforanimation = true;
}
});
controller.forward();
mistakesSlope[currentTurn - 1] =
mistakesSlope[currentTurn - 1] +
mistakesSlopematrix[currentTurn - 1]
[currentTap - 1];
mistakesIntercept[currentTurn - 1] =
mistakesIntercept[currentTurn - 1] +
mistakesInterceptmatrix[
currentTurn - 1]
[currentTap - 1];
setState(() {});
if (currentTap ==
correctAnswer[currentTurn - 1]) {
- progress[currentTurn - 1] = 1;
- progress[currentTurn] = 0;
- tapCounter = 0;
+ if (currentTurn < 3) {
+ progress[currentTurn - 1] = 1;
+ progress[currentTurn] = 0;
+ tapCounter = 0;
+ }
}
onDataSend();
}
},
leading: (currentTap == position + 1)
? ((_progress > 0 && _progress < 1)
? Icon(Icons.pause_circle_filled)
: Icon(Icons.play_circle_filled))
: Icon(Icons.play_circle_filled),
title: Text(functionFormulas[position],
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
)),
trailing: onTap[position]
? (position ==
correctAnswer[currentTurn - 1] - 1)
? Icon(Icons.check_circle)
: Icon(Icons.cancel)
: Icon(Icons.more_vert),
),
);
},
))),
),
SizedBox(
height: 20,
),
Container(
height: 500,
width: 500,
- decoration: BoxDecoration(border: Border.all()),
+ // decoration: BoxDecoration(border: Border.all()),
child: Stack(children: [
Container(
height: 500,
width: 500,
child:
SvgPicture.asset(imagespath[currentTurn - 1])),
Container(
height: 500,
width: 500,
child: SvgPicture.asset(
"assets/images/Grid_Ac8_Screen.svg")),
Align(
alignment: Alignment(
2 *
(beginpath.dx +
_progress *
(endpath.dx - beginpath.dx)) /
- 500 -
+ 860 -
1,
0),
child: Card(
child: SvgPicture.asset(
"assets/images/cellulox.svg",
- height: 60,
- width: 60),
+ height: 48,
+ width: 48),
),
),
Align(
alignment: Alignment(
-0.07,
2 *
(beginpath.dy +
_progress *
(endpath.dy - beginpath.dy)) /
- 500 -
+ 860 -
1),
child: Card(
child: SvgPicture.asset(
"assets/images/celluloy.svg",
- height: 60,
- width: 60),
+ height: 48,
+ width: 48),
+ ),
+ ),
+ Align(
+ alignment: Alignment(
+ 2 *
+ (beginpath.dx +
+ _progress *
+ (endpath.dx - beginpath.dx)) /
+ 860 -
+ 1,
+ 2 *
+ (beginpath.dy +
+ _progress *
+ (endpath.dy - beginpath.dy)) /
+ 860 -
+ 1),
+ child: Card(
+ child: SvgPicture.asset(
+ "assets/images/celluloPurple.svg",
+ height: 48,
+ width: 48),
),
),
CustomPaint(
- size: Size(300, 500),
+ size: Size(500, 500),
painter: LinePainter(_progress, beginpath, endpath),
),
Align(
- alignment: Alignment(-1, 1),
- child: Card(
- child: ListTile(
- title: Text('X'),
- ))),
+ alignment: Alignment(1, 0.1),
+ child: Text(
+ 'X',
+ style: new TextStyle(
+ color: Colors.black,
+ fontWeight: FontWeight.bold,
+ fontSize: 20,
+ ),
+ ),
+ ),
Align(
- alignment: Alignment(1, 1),
- child: Card(
- child: ListTile(
- title: Text('Y'),
- ))),
+ alignment: Alignment(0.05, -1),
+ child: Text(
+ 'Y',
+ style: new TextStyle(
+ color: Colors.black,
+ fontWeight: FontWeight.bold,
+ fontSize: 20,
+ ),
+ ),
+ ),
])),
SizedBox(
height: 20,
),
- Card(
- child: ListTile(
- title: Text('Map NUmber: 3'),
- ),
- ),
MembersBar(
curTurn: currentTurn,
),
- ])));
+ ]))));
}
}
diff --git a/student/lib/Activities/templateAc.Dart b/student/lib/Activities/templateAc.Dart
index 8e23702..63f7a13 100644
--- a/student/lib/Activities/templateAc.Dart
+++ b/student/lib/Activities/templateAc.Dart
@@ -1,137 +1,146 @@
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:student/widgets/onlineRobotMap.Dart';
import 'package:student/widgets/celluloMap.Dart';
import 'dart:async';
import 'dart:convert';
import 'package:student/Database.dart';
import 'package:student/model/Group.dart';
import 'package:student/model/Cellulo.dart';
import 'package:student/widgets/showAlertDialog.Dart';
import 'package:student/widgets/membersBar.Dart';
import 'package:student/widgets/inactivityDetector.Dart';
import 'package:flutter_appavailability/flutter_appavailability.dart';
class TempAc extends StatefulWidget {
TempAc({Key key}) : super(key: key);
@override
_TempAcState createState() => _TempAcState();
}
class _TempAcState extends State {
// Activity_Independent
var elapseTimer = new Stopwatch();
Timer timerCelluloPosition;
int currentTurn = 1;
// Celulo
var celluloxPosition = [0.0, 0.0];
var celluloyPosition = [0.0, 0.0];
- List celluloxPositiontopaint = [0.0, 0.0];
- List celluloyPositiontopaint = [0.0, 0.0];
+ var xlabelposition = [0, 1];
+ var ylabelposition = [-1, 0];
+ List> celluloxPositiontopaint =
+ new List.generate(3, (int index) => List(2), growable: true);
+ List> celluloyPositiontopaint =
+ new List.generate(3, (int index) => List(2), growable: true);
bool addtoprint;
-
+ var lineallow = [false, false, false];
// Learning
List mistakesSlope = [0, 0, 0];
List mistakesIntrepet = [0, 0, 0];
List mistakesInitialPosition = [0, 0, 0];
//Activity Dependent
String activityTitle = 'Activity 6';
var linesPath = [
'assets/images/Ac7_function1.svg',
'assets/images/Ac7_function2.svg',
'assets/images/Ac7_function3.svg',
'assets/images/GridOnlyPositive.svg',
];
// map-related
final double mapSizeWidth = 860;
final double mapSizeHeight = 860;
final String mapPath = 'assets/images/GridOnlyPositive.svg';
final String celluloxpath = 'assets/images/cellulox.svg';
final String celluloypath = 'assets/images/celluloy.svg';
@override
void initState() {
super.initState();
dbRef.child('groups').child(group.id).child('tabletStatus').set("YES");
dbRef.child('groups').child(group.id).child('currentActivity').set("Ac6");
elapseTimer.start();
timerCelluloPosition =
new Timer.periodic(new Duration(milliseconds: 500), (time) {
if (totalRobots() > 1) {
print(cellulox.getrobotKidnapped().toString());
print(celluloy.getrobotKidnapped().toString());
cellulox.getrobotx().then((val) => setState(() {
if (val != null) {
celluloxPosition[0] = val;
- if (addtoprint == true)
- celluloxPositiontopaint.add(val * 500 / 860);
+ // if (addtoprint == true)
+ // celluloxPositiontopaint.add(val * 500 / 860);
}
// print(addtoprint.toString());
}));
cellulox.getroboty().then((val) => setState(() {
if (val != null) {
celluloxPosition[1] = val;
}
}));
celluloy.getrobotx().then((val) => setState(() {
if (val != null) {
celluloyPosition[0] = val;
}
}));
celluloy.getroboty().then((val) => setState(() {
if (val != null) {
celluloyPosition[1] = val;
- if (addtoprint == true)
- celluloyPositiontopaint.add(val * 500 / 860);
+ // if (addtoprint == true)
+ // celluloyPositiontopaint.add(val * 500 / 860);
}
}));
if (celluloxPosition[0] > 800 || celluloyPosition[1] > 800) {
cellulox.setVelocity(0, 0);
celluloy.setVelocity(0, 0);
}
}
});
}
@override
void dispose() {
timerCelluloPosition.cancel();
elapseTimer.stop();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Activity 7: Semi-Mathematical Control'),
),
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Column(children: [
celluloMap(
context,
celluloxPositiontopaint,
celluloyPositiontopaint,
celluloxPosition,
celluloyPosition,
mapPath,
celluloxpath,
celluloypath,
linesPath[currentTurn - 1],
mapSizeWidth,
- mapSizeHeight,'X','Y'),
+ mapSizeHeight,
+ 'X',
+ 'Y',
+ xlabelposition,
+ ylabelposition,
+ lineallow),
SizedBox(
height: 15,
),
MembersBar(),
])));
}
}
diff --git a/student/lib/loginpage_names.dart b/student/lib/loginpage_names.dart
index b3c49ff..99be60e 100644
--- a/student/lib/loginpage_names.dart
+++ b/student/lib/loginpage_names.dart
@@ -1,171 +1,176 @@
import 'package:flutter/material.dart';
import 'package:student/loginpage_robots.dart';
import 'dart:convert';
import 'package:student/Data/data.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:student/Database.dart';
import 'package:student/model/Group.dart';
import 'package:student/model/Cellulo.dart';
import 'package:student/Game.dart';
import 'package:student/Database.dart';
import 'package:firebase_database/firebase_database.dart';
class LoginPage extends StatefulWidget {
LoginPage({Key key}) : super(key: key);
@override
_LoginPageState createState() => _LoginPageState();
}
class _LoginPageState extends State {
TextEditingController controller1 = TextEditingController();
TextEditingController controller2 = TextEditingController();
TextEditingController controller3 = TextEditingController();
TextEditingController controller4 = TextEditingController();
TextEditingController controllersessionID = TextEditingController();
final teamname = "1";
@override
void initState() {
+ cellulox.setColor(0, 255, 0, 0, 0);
+
+ celluloy.setColor(0, 0, 255, 0, 0);
+ cellulox.clearrobot();
+ celluloy.clearrobot();
super.initState();
}
@override
void dispose() {
super.dispose();
}
Widget nextButton() {
return InkWell(
onTap: () {
group.sessionID = controllersessionID.text;
//print(controller4.text);
group.member1name = controller1.text;
group.member2name = controller2.text;
group.member3name = controller3.text;
group.id = controller4.text;
- group.currentActivity = 'Ac2';
+ group.currentActivity = 'Ac8';
final dbRef =
FirebaseDatabase.instance.reference().child(group.sessionID);
dbRef.child('groups').child(controller4.text).set(group.toJson());
group.setupDatabse();
group.cellulox = cellulox;
group.celluloy = celluloy;
cellulox.setup(); //setting up the robots
- Navigator.pushReplacement(
+ Navigator.push(
context, MaterialPageRoute(builder: (context) => Game()));
},
child: Container(
width: MediaQuery.of(context).size.width,
padding: EdgeInsets.symmetric(vertical: 13),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(5)),
boxShadow: [
BoxShadow(
color: Color(0xffdf8e33).withAlpha(100),
offset: Offset(2, 4),
blurRadius: 8,
spreadRadius: 2)
],
color: Colors.white),
child: Text(
'Lets go',
style: TextStyle(fontSize: 20, color: Color(0xfff7892b)),
),
),
);
}
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Login'),
),
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.all(30.0),
child: Column(children: [
Container(
padding: EdgeInsets.all(8.0),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(color: Colors.grey[100]))),
child: TextField(
controller: controller1,
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Member 1: Enter your name",
hintStyle: TextStyle(color: Colors.grey[400])),
),
),
SizedBox(
height: 100,
),
Container(
padding: EdgeInsets.all(8.0),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(color: Colors.grey[100]))),
child: TextField(
controller: controller2,
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Member 2: Enter your name",
hintStyle: TextStyle(color: Colors.grey[400])),
),
),
SizedBox(
height: 100,
),
Container(
padding: EdgeInsets.all(8.0),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(color: Colors.grey[100]))),
child: TextField(
controller: controller3,
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Member 3: Enter your name",
hintStyle: TextStyle(color: Colors.grey[400])),
),
),
SizedBox(
height: 100,
),
Container(
padding: EdgeInsets.all(8.0),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(color: Colors.grey[100]))),
child: TextField(
controller: controller4,
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Enter your group name",
hintStyle: TextStyle(color: Colors.grey[400])),
),
),
SizedBox(
height: 50,
),
Container(
padding: EdgeInsets.all(8.0),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(color: Colors.grey[100]))),
child: TextField(
controller: controllersessionID,
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Enter session ID",
hintStyle: TextStyle(color: Colors.grey[400])),
),
),
nextButton()
]))));
}
}
diff --git a/student/lib/model/Cellulo.dart b/student/lib/model/Cellulo.dart
index 59ba747..4d8acd6 100644
--- a/student/lib/model/Cellulo.dart
+++ b/student/lib/model/Cellulo.dart
@@ -1,178 +1,178 @@
import 'dart:async';
import 'dart:ffi'; // For FFI
import 'dart:io'; // For Platform.isX
Cellulo cellulox = new Cellulo(0);
Cellulo celluloy = new Cellulo(1);
class Cellulo {
int robotID = 0;
bool colorset = false;
bool velocityset = false;
static var robots = [];
int robot = -1;
Cellulo(this.robotID);
setup() async {
print(totalRobots());
// print("thisis the current robot" + _robot.toString());
// robot = _robot;
for (var i = 0; i < totalRobots(); i++) {
int _robot = newRobotfromPool();
robots.add(_robot);
}
cellulox.resetrobot();
celluloy.resetrobot();
cellulox.setColor(0, 255, 0, 0, 0);
celluloy.setColor(0, 0, 255, 0, 0);
}
void remainingrobots() async {
// print("remaining" + robotsRemaining().toString());
// print("total" + totalRobots().toString());
}
void setColor(
int greencode, int redcode, int bluecode, int effect, int code) async {
setVisualEffect(
robots[robotID], effect, redcode, greencode, bluecode, code);
}
void resetrobot() async {
reset(robots[robotID]);
}
void clearrobot() async {
clear(robots[robotID]);
}
Future getrobotx() async {
//print(robots[robotID]);
return getX(robots[robotID]);
}
Future getroboty() async {
//print(robots[robotID]);
return getY(robots[robotID]);
}
Future getrobottetha() async {
//print(robots[robotID]);
return getTheta(robots[robotID]);
}
Future getrobotKidnapped() async {
//print(robots[robotID]);
return getKidnapped(robots[robotID]);
}
Future setVelocity(double vx, double vy) async {
setGoalVelocity(robots[robotID], vx, vy, 0);
}
Future robotVibrate(
double vx, double vy, double vtheta, int period, int duration) async {
vibrate(robots[robotID], vx, vy, vtheta, period, duration);
}
- Future setGoalPosition(double x, double y) async {
- setGoalPose(robots[robotID], x, y, 0, 150, 150);
+ Future setGoalPosition(double x, double y, double v) async {
+ setGoalPose(robots[robotID], x, y, 0, v, 150);
}
}
final DynamicLibrary nativeAddLib = Platform.isAndroid
? DynamicLibrary.open("libnative_add.so")
: DynamicLibrary.process();
final DynamicLibrary nativeCellulolib = Platform.isAndroid
? DynamicLibrary.open("libcellulo-library.so")
: DynamicLibrary.process();
final int Function(int x, int y) nativeAdd = nativeAddLib
.lookup>("native_add")
.asFunction();
final int Function(int x, int y) nativeAddCellulo = nativeCellulolib
.lookup>("test_native_add")
.asFunction();
final int Function() initialize = nativeCellulolib
.lookup>("initialize")
.asFunction();
final void Function(int robot) reset = nativeCellulolib
.lookup>("reset")
.asFunction();
final void Function(int robot) clear = nativeCellulolib
.lookup>("clearTracking")
.asFunction();
final int Function() newRobotfromPool = nativeCellulolib
.lookup>("newRobotFromPool")
.asFunction();
final void Function() destroyRobot = nativeCellulolib
.lookup>("destroyRobot")
.asFunction();
final void Function(int robot, int effect, int r, int g, int b, int value)
setVisualEffect = nativeCellulolib
.lookup<
NativeFunction<
Void Function(Int64 robot, Int64 effect, Int64 r, Int64 g,
Int64 b, Int64 value)>>("setVisualEffect")
.asFunction();
//setGoalVelocity(int64_t robot, float vx, float vy, float w)
final void Function(int robot, double vx, double vy, double w) setGoalVelocity =
nativeCellulolib
.lookup<
NativeFunction<
Void Function(Int64 robot, Float vx, Float vy,
Float w)>>("setGoalVelocity")
.asFunction();
final void Function(
int robot, double x, double y, double theta, double v, double w)
setGoalPose = nativeCellulolib
.lookup<
NativeFunction<
Void Function(Int64 robot, Float x, Float y, Float theta,
Float v, Float w)>>("setGoalPose")
.asFunction();
final void Function(
int robot, double x, double y, double theta, int period, int duration)
vibrate = nativeCellulolib
.lookup<
NativeFunction<
Void Function(Int64 robot, Float iX, Float iY, Float iTheta,
Int64 period, Int64 duration)>>("simpleVibrate")
.asFunction();
final int Function() totalRobots = nativeCellulolib
.lookup>("totalRobots")
.asFunction();
final int Function() robotsRemaining = nativeCellulolib
.lookup>("robotsRemaining")
.asFunction();
final double Function(int robot) getX = nativeCellulolib
.lookup>("getX")
.asFunction();
final double Function(int robot) getY = nativeCellulolib
.lookup>("getY")
.asFunction();
final double Function(int robot) getTheta = nativeCellulolib
.lookup>("getTheta")
.asFunction();
final int Function(int robot) getKidnapped = nativeCellulolib
.lookup>("getKidnapped")
.asFunction();
diff --git a/student/lib/model/Group.dart b/student/lib/model/Group.dart
index 68ff245..5e6e1c5 100644
--- a/student/lib/model/Group.dart
+++ b/student/lib/model/Group.dart
@@ -1,106 +1,106 @@
import 'package:firebase_database/firebase_database.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:student/model/Cellulo.dart';
import 'package:provider/provider.dart';
import 'dart:async';
import 'dart:convert';
import 'package:student/widgets/showAlertDialog.Dart';
Group group = new Group("1", "", "", "");
class Group extends ChangeNotifier {
String sessionID = 'test';
String id = "1";
String tabletStatus = 'YES';
// String _title;
// String _description;
int inactivity = 0;
String member1name;
String member2name;
String member3name;
int robot1code = 0;
int robot2code = 0;
bool ispaused = false;
Cellulo cellulox;
Cellulo celluloy;
- String currentActivity = 'Ac3';
+ String currentActivity = 'Ac7';
String robotName = "Cellulo";
final GlobalKey navigatorKeygame =
new GlobalKey();
final FirebaseDatabase _database = FirebaseDatabase.instance;
StreamSubscription _ongroupChangedSubscription;
StreamSubscription _onattemptAddedSubscription;
// Time timeJoined;
Group(this.id, this.member1name, this.member2name, this.member3name);
void switchactivity() {
navigatorKeygame.currentState.pushReplacementNamed(group.currentActivity);
}
void setupDatabse() {
_ongroupChangedSubscription = _database
.reference()
.child(group.sessionID)
.child("groups")
.child(group.id)
.onChildChanged
.listen(onGroupChanged);
//Query _todoQuery;
}
onGroupChanged(Event event) {
//thisClass.groups.add(Group.fromSnapshot(event.snapshot));
// group.ispaused = (event.snapshot.value)[
// 'isPaused']; // print("group" + currentGroup.toString().toString());
if (event.snapshot.key == 'currentActivity') {
group.currentActivity = ((event.snapshot.value));
print(group.currentActivity);
group.switchactivity();
}
if (event.snapshot.key == 'isPaused') {
// navigatorKeygame.currentState.pushReplacementNamed(group.currentActivity);
group.ispaused = ((event.snapshot.value));
if (group.ispaused == true) {
showPauseDialog(navigatorKeygame.currentState.context);
}
// if (group.ispaused == false) {
// Navigator.of(navigatorKeygame.currentState.overlay.context,
// rootNavigator: true)
// .pop();
// }
}
// setState(() {});
notifyListeners();
}
toJson() {
return {
"member1name": member1name,
"member2name": member2name,
"member3name": member3name,
"robotName": robotName,
"robot1code": robot1code,
"robot2code": robot2code,
"currentActivity": currentActivity,
"tabletStatus": tabletStatus,
"isPaused": ispaused,
//"inactivity": inactivity,
"id": id,
//"Ac8": {"progress": 0, "mistaesSlope": 0, "mistaesIntercept": 0},
//"Ac7": {"progress": 0, "mistaesSlope": 0, "mistaesIntercept": 0},
//"cellulox": {"x": 0, "y": 0, "tetha": 0},
//"celluloy": {"x": 0, "y": 0, "tetha": 0}
};
}
Group.fromSnapshot(DataSnapshot snapshot) {
// _id = snapshot.key;
member1name = snapshot.value['member1name'];
member2name = snapshot.value['member2name'];
member3name = snapshot.value['member3name'];
}
}
diff --git a/student/lib/ui/router.dart b/student/lib/ui/router.dart
index b29ca5f..f420dea 100644
--- a/student/lib/ui/router.dart
+++ b/student/lib/ui/router.dart
@@ -1,44 +1,45 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:student/ui/router.dart';
import 'package:student/Activities/Ac7.Dart';
import 'package:student/Activities/Ac8.Dart';
import 'package:student/Activities/Ac6.dart';
import 'package:student/Activities/Ac5.dart';
import 'package:student/Activities/Ac4.dart';
import 'package:student/Activities/Ac3.dart';
import 'package:student/Activities/Ac2.dart';
import 'package:student/Activities/Ac1.dart';
import 'package:student/model/Group.dart';
//import 'package:Teacher_Dashboard/screens/bottom_nav_screen.dart';
class Router {
static Route generateRoute(RouteSettings settings) {
switch (group.currentActivity) {
case 'Ac7':
return MaterialPageRoute(builder: (_) => Ac7());
case 'Ac8':
return MaterialPageRoute(builder: (_) => Ac8());
case 'Ac6':
return MaterialPageRoute(builder: (_) => Ac6());
case 'Ac5':
return MaterialPageRoute(builder: (_) => Ac5());
case 'Ac4':
return MaterialPageRoute(builder: (_) => Ac4());
case 'Ac3':
return MaterialPageRoute(builder: (_) => Ac3());
case 'Ac2':
return MaterialPageRoute(builder: (_) => Ac2());
case 'Ac1':
return MaterialPageRoute(builder: (_) => Ac1());
-
+ case 'Idle':
+ return MaterialPageRoute(builder: (_) => Ac7());
default:
return MaterialPageRoute(
builder: (_) => Scaffold(
body: Center(
child: Text('No route defined for '),
),
));
}
}
}
diff --git a/student/lib/welcomePage.dart b/student/lib/welcomePage.dart
index ad7176e..a0fc844 100644
--- a/student/lib/welcomePage.dart
+++ b/student/lib/welcomePage.dart
@@ -1,126 +1,137 @@
import 'package:flutter/material.dart';
import 'package:student/loginpage_names.dart';
import 'package:google_fonts/google_fonts.dart';
-
+import 'package:flutter_svg/flutter_svg.dart';
import 'dart:convert';
class WelcomePage extends StatefulWidget {
WelcomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_WelcomePageState createState() => _WelcomePageState();
}
class _WelcomePageState extends State {
@override
void initState() {
super.initState();
///
/// Ask to be notified when messages related to the game
/// are sent by the server
///
}
Widget _submitButton() {
return InkWell(
onTap: () {
Navigator.push(
context, MaterialPageRoute(builder: (context) => LoginPage()));
},
child: SingleChildScrollView(
child: Container(
width: MediaQuery.of(context).size.width,
padding: EdgeInsets.symmetric(vertical: 13),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(5)),
boxShadow: [
BoxShadow(
color: Color(0xffdf8e33).withAlpha(100),
offset: Offset(2, 4),
blurRadius: 8,
spreadRadius: 2)
],
color: Colors.white),
child: Text(
'Lets go',
style: TextStyle(fontSize: 20, color: Color(0xfff7892b)),
),
),
));
}
Widget _title() {
return RichText(
textAlign: TextAlign.center,
text: TextSpan(
text: 'C',
style: GoogleFonts.portLligatSans(
textStyle: Theme.of(context).textTheme.display1,
- fontSize: 30,
+ fontSize: 60,
fontWeight: FontWeight.w700,
- color: Colors.white,
+ color: Colors.blue,
),
children: [
TextSpan(
text: 'ell',
- style: TextStyle(color: Colors.black, fontSize: 30),
+ style: TextStyle(color: Colors.black, fontSize: 60),
),
TextSpan(
text: 'ulo',
- style: TextStyle(color: Colors.white, fontSize: 30),
+ style: TextStyle(color: Colors.blue, fontSize: 60),
),
]),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 20),
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(5)),
boxShadow: [
BoxShadow(
color: Colors.grey.shade200,
offset: Offset(2, 4),
blurRadius: 5,
spreadRadius: 2)
],
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Color(0xfffbb448), Color(0xffe46b10)])),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
height: 100,
),
_title(),
SizedBox(
height: 80,
),
+ Image.asset('assets/images/cellulo.png'),
+ SizedBox(
+ height: 180,
+ ),
_submitButton(),
SizedBox(
- height: 500,
+ height: 60,
),
- Text('Powered by CHILI',
- style: TextStyle(
- color: Colors.white,
- fontSize: 24,
- fontWeight: FontWeight.w500))
+ Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Text('Powered by CHILI',
+ style: TextStyle(
+ color: Colors.white,
+ fontSize: 34,
+ fontWeight: FontWeight.w500)),
+ SvgPicture.asset('assets/images/chilli.svg',
+ height: 60, width: 60),
+ ],
+ )
],
),
),
),
);
}
}
diff --git a/student/lib/widgets/celluloMap.Dart b/student/lib/widgets/celluloMap.Dart
index 125e212..1c57b07 100644
--- a/student/lib/widgets/celluloMap.Dart
+++ b/student/lib/widgets/celluloMap.Dart
@@ -1,76 +1,114 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:student/widgets/onlineRobotMap.Dart';
Widget celluloMap(
- BuildContext context,
- List celluloxPositiontopaint,
- List celluloyPositiontopaint,
- celluloxPosition,
- celluloyPosition,
- String workspacePath,
- String targetLinePath,
- String celluloXPath,
- String celluloYPath,
- double mapSizeWidth,
- double mapSizeHeight,
- String xlabel,
- String ylabel) {
+ BuildContext context,
+ List> celluloxPositiontopaint,
+ List> celluloyPositiontopaint,
+ celluloxPosition,
+ celluloyPosition,
+ String workspacePath,
+ String targetLinePath,
+ String celluloXPath,
+ String celluloYPath,
+ double mapSizeWidth,
+ double mapSizeHeight,
+ String xlabel,
+ String ylabel,
+ var xlabelposition,
+ var ylabelposition,
+ var lineallow,
+) {
final double mapSizeScreenWidth = 500;
final double mapSizeScreenHeight = 500;
+ final double celluloSize = 48;
final double scaleWidth = mapSizeScreenWidth / mapSizeWidth;
final double scaleHeight = mapSizeScreenHeight / mapSizeHeight;
return Container(
height: mapSizeScreenWidth,
width: mapSizeScreenHeight,
decoration: BoxDecoration(),
child: Stack(children: [
Container(
height: mapSizeScreenWidth,
width: mapSizeScreenHeight,
child: SvgPicture.asset(targetLinePath)),
Container(
height: mapSizeScreenWidth,
width: mapSizeScreenHeight,
child: SvgPicture.asset(workspacePath)),
Align(
alignment: Alignment(
2 * (celluloxPosition[0] * scaleWidth / mapSizeScreenWidth) - 1,
1),
child: Card(
- child: SvgPicture.asset(celluloXPath, height: 60, width: 60),
+ child: SvgPicture.asset(celluloXPath,
+ height: celluloSize, width: celluloSize),
),
),
Align(
alignment: Alignment(
- -1,
+ 2 * (celluloxPosition[0] * scaleWidth / mapSizeScreenWidth) - 1,
2 * (celluloyPosition[1] * scaleHeight / mapSizeScreenHeight) -
1),
child: Card(
- child: SvgPicture.asset(celluloYPath, height: 60, width: 60),
+ child: SvgPicture.asset('assets/images/celluloPurple.svg',
+ height: celluloSize, width: celluloSize),
),
),
Align(
- alignment: Alignment(-1, 1),
- child: Card(
- child: ListTile(
- title: Text(xlabel),
- ))),
+ alignment: Alignment(
+ -1,
+ 2 * (celluloyPosition[1] * scaleHeight / mapSizeScreenHeight) -
+ 1),
+ child: Card(
+ child: SvgPicture.asset(celluloYPath,
+ height: celluloSize, width: celluloSize),
+ ),
+ ),
Align(
- alignment: Alignment(1, 1),
- child: Card(
- child: ListTile(
- title: Text(ylabel),
- ))),
- CustomPaint(
- size: Size(mapSizeScreenWidth, mapSizeScreenHeight),
- painter:
- LinePainter2(celluloxPositiontopaint, celluloyPositiontopaint),
+ alignment: Alignment(xlabelposition[0], xlabelposition[1]),
+ child: Text(
+ xlabel,
+ style: new TextStyle(
+ color: Colors.black,
+ fontSize: 20,
+ fontWeight: FontWeight.bold,
+ ),
+ ),
),
- CustomPaint(
- size: Size(mapSizeScreenWidth, mapSizeScreenHeight),
- painter:
- LinePainter2(celluloxPositiontopaint, celluloyPositiontopaint),
+ Align(
+ alignment: Alignment(ylabelposition[0], ylabelposition[1]),
+ child: Text(
+ ylabel,
+ style: new TextStyle(
+ color: Colors.black,
+ fontWeight: FontWeight.bold,
+ fontSize: 20,
+ ),
+ ),
),
+ (lineallow[0])
+ ? CustomPaint(
+ size: Size(mapSizeScreenWidth, mapSizeScreenHeight),
+ painter: LinePainter2(celluloxPositiontopaint[0],
+ celluloyPositiontopaint[0], Colors.blue),
+ )
+ : Text(''),
+ (lineallow[1])
+ ? CustomPaint(
+ size: Size(mapSizeScreenWidth, mapSizeScreenHeight),
+ painter: LinePainter2(celluloxPositiontopaint[1],
+ celluloyPositiontopaint[1], Colors.green),
+ )
+ : Text(''),
+ (lineallow[2])
+ ? CustomPaint(
+ size: Size(mapSizeScreenWidth, mapSizeScreenHeight),
+ painter: LinePainter2(celluloxPositiontopaint[2],
+ celluloyPositiontopaint[2], Colors.yellow),
+ )
+ : Text(''),
]));
}
diff --git a/student/lib/widgets/linePainter.Dart b/student/lib/widgets/linePainter.Dart
index f47e531..66eee46 100644
--- a/student/lib/widgets/linePainter.Dart
+++ b/student/lib/widgets/linePainter.Dart
@@ -1,27 +1,28 @@
import 'package:flutter/material.dart';
class LinePainter extends CustomPainter {
Paint _paint;
double _progress;
Offset beginpath;
Offset endpath;
+ double scale = 500 / 860;
LinePainter(this._progress, this.beginpath, this.endpath) {
_paint = Paint()
..color = Colors.green
..strokeWidth = 6.0;
}
@override
void paint(Canvas canvas, Size size) {
canvas.drawLine(
- beginpath,
- Offset(beginpath.dx + _progress * (endpath.dx - beginpath.dx),
- beginpath.dy + _progress * (endpath.dy - beginpath.dy)),
+ Offset(beginpath.dx * scale, beginpath.dy * scale),
+ Offset(scale * (beginpath.dx + _progress * (endpath.dx - beginpath.dx)),
+ scale * (beginpath.dy + _progress * (endpath.dy - beginpath.dy))),
_paint);
}
@override
bool shouldRepaint(LinePainter oldDelegate) {
return oldDelegate._progress != _progress;
}
}
diff --git a/student/lib/widgets/onlineRobotMap.Dart b/student/lib/widgets/onlineRobotMap.Dart
index c73580c..bd1bf1f 100644
--- a/student/lib/widgets/onlineRobotMap.Dart
+++ b/student/lib/widgets/onlineRobotMap.Dart
@@ -1,63 +1,64 @@
import 'package:flutter/material.dart';
class LinePainter extends CustomPainter {
Paint _paint;
Offset beginpath;
Offset endpath;
var path = Path();
//var patendpathh=path();
LinePainter(this.beginpath, this.endpath) {
_paint = Paint()
..color = Colors.blue
..strokeWidth = 8.0
..style = PaintingStyle.stroke;
}
@override
void paint(Canvas canvas, Size size) {
// path.moveTo(0, 0);
path.moveTo(beginpath.dx, beginpath.dy);
path.lineTo(endpath.dx, endpath.dy);
canvas.drawPath(path, _paint);
// canvas.saveLayer(bounds, paint);
}
@override
bool shouldRepaint(LinePainter oldDelegate) {
return true;
}
}
class LinePainter2 extends CustomPainter {
Paint _paint;
double _progress;
List x;
List y;
+ Color linecolor;
var path = Path();
//var patendpathh=path();
- LinePainter2(this.x, this.y) {
+ LinePainter2(this.x, this.y, this.linecolor) {
_paint = Paint()
- ..color = Colors.blue
+ ..color = this.linecolor
..strokeWidth = 8.0
..style = PaintingStyle.stroke;
}
@override
void paint(Canvas canvas, Size size) {
// path.moveTo(0, 0);
for (int i = 4; i < x.length; i++) {
path.moveTo(x[i - 2], y[i - 2]);
path.lineTo(x[i - 1], y[i - 1]);
canvas.drawPath(path, _paint);
}
}
@override
bool shouldRepaint(LinePainter2 oldDelegate) {
return true;
}
}
LinePainter linepainter = new LinePainter(Offset(0, 0), Offset(0, 10));