Skip to content

Commit db6cf53

Browse files
authored
Detect unfinished form state & 1st semester students (#36)
* Update prediction page for 1st semester students * Shows form pages if the user left app before submitting it
1 parent 73e612b commit db6cf53

File tree

5 files changed

+245
-129
lines changed

5 files changed

+245
-129
lines changed

assets/baby.png

16.3 KB
Loading

lib/entities/course/PredictedCourse.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ class PredictedCourse {
1414
final double distribution;
1515

1616
factory PredictedCourse.fromJson(Map<String, dynamic> json) {
17+
double gradePredictionValue = -1;
18+
if(json.containsKey('gradePrediction')){
19+
gradePredictionValue = double.parse(json['gradePrediction'].toString());
20+
}
21+
1722
return PredictedCourse(
1823
courseID: json['id'],
19-
gradePrediction: double.parse(json['gradePrediction'].toString()),
24+
gradePrediction: gradePredictionValue,
2025
distribution: double.parse(json['distribution'].toString()));
2126
}
2227

lib/pages/HomeScreen.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
44
import 'package:grade_plus_plus/DataFetcher.dart';
55
import 'package:grade_plus_plus/entities/course/Course.dart';
66
import 'package:grade_plus_plus/entities/user/Teacher.dart';
7+
import 'package:grade_plus_plus/pages/authentication/forms/PersonalForm.dart';
78

89
import '../LocalKeyValuePersistence.dart';
910
import '../entities/course/PredictedCourse.dart';
@@ -41,8 +42,9 @@ class _HomeScreenState extends State<HomeScreen> {
4142

4243
courses = DataFetcher.fetchCourses();
4344
teachers = DataFetcher.fetchTeachers();
44-
predictedCourses = DataFetcher.fetchPredictedCourses();
4545
userData = DataFetcher.fetchUserData();
46+
predictedCourses = DataFetcher.fetchPredictedCourses();
47+
4648

4749
_loadLocalData(); // See the to-do below
4850
}
@@ -73,6 +75,9 @@ class _HomeScreenState extends State<HomeScreen> {
7375
builder: (BuildContext context, AsyncSnapshot<Merged> snapshot) {
7476
List<Widget> children;
7577
if (snapshot.hasData) {
78+
if (snapshot.data.userData.name == null){
79+
return PersonalForm();
80+
}
7681
pages = <AbstractPage>[
7782
GradePredict(
7883
predictedCourses: snapshot.data.predictedCourses,

0 commit comments

Comments
 (0)