Resolve WES-117 "Persistent data handling"
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
"InterfacesScripts",
|
||||
"SignPredictor",
|
||||
"NatML.ML",
|
||||
"SystemArchitecture",
|
||||
"Tween"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
|
||||
@@ -39,11 +39,6 @@ public class CoursesController : AbstractFeedback
|
||||
/// </summary>
|
||||
public TMP_Text title;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to user list to get current user
|
||||
/// </summary>
|
||||
public UserList userList;
|
||||
|
||||
/// <summary>
|
||||
/// The current user
|
||||
/// </summary>
|
||||
@@ -52,7 +47,7 @@ public class CoursesController : AbstractFeedback
|
||||
/// <summary>
|
||||
/// Current user progress for this course
|
||||
/// </summary>
|
||||
private Progress progress = null;
|
||||
private PersistentDataController.SavedCourseProgress progress = null;
|
||||
|
||||
/// <summary>
|
||||
/// ScriptableObject with list of all courses
|
||||
@@ -169,17 +164,17 @@ public class CoursesController : AbstractFeedback
|
||||
previewMessage.SetActive(course.theme.modelIndex == ModelIndex.NONE);
|
||||
|
||||
// Create entry in current user for keeping track of progress
|
||||
userList.Load();
|
||||
user = userList.GetCurrentUser();
|
||||
//PersistentDataController pdc = PersistentDataController.GetInstance();
|
||||
//pdc.Load();
|
||||
user = UserList.GetCurrentUser();
|
||||
progress = user.GetCourseProgress(course.index);
|
||||
if (progress == null)
|
||||
{
|
||||
progress = new Progress();
|
||||
progress.AddOrUpdate<CourseIndex>("courseIndex", course.index);
|
||||
progress.AddOrUpdate<float>("courseProgress", -1.0f);
|
||||
user.courses.Add(progress);
|
||||
progress = new PersistentDataController.SavedCourseProgress();
|
||||
progress.courseIndex = course.index;
|
||||
user.AddCourseProgress(progress);
|
||||
}
|
||||
userList.Save();
|
||||
UserList.Save();
|
||||
|
||||
// Force the videoplayer to add bars to preserve aspect ratio
|
||||
player.aspectRatio = VideoAspectRatio.FitInside;
|
||||
@@ -260,8 +255,8 @@ public class CoursesController : AbstractFeedback
|
||||
|
||||
// TODO: fix correct word count
|
||||
correctWords++;
|
||||
progress.AddOrUpdate<float>("courseProgress", (float)correctWords / (float)maxWords);
|
||||
userList.Save();
|
||||
progress.progress = (float)correctWords / (float)maxWords;
|
||||
UserList.Save();
|
||||
|
||||
// Update UI if course is not finished yet
|
||||
if (currentWordIndex < maxWords)
|
||||
@@ -297,8 +292,8 @@ public class CoursesController : AbstractFeedback
|
||||
// Link button
|
||||
CoursesButton.onClick.AddListener(() => { SystemController.GetInstance().BackToPreviousScene(); });
|
||||
|
||||
progress.AddOrUpdate<float>("courseProgress", 1f);
|
||||
userList.Save();
|
||||
progress.progress = 1.0f;
|
||||
UserList.Save();
|
||||
}
|
||||
/// <summary>
|
||||
/// The updateFunction that is called when new probabilities become available
|
||||
|
||||
Reference in New Issue
Block a user