Fixed course freezing and other course-ending bugs
This commit is contained in:
@@ -196,6 +196,7 @@ public class CoursesController : AbstractFeedback
|
||||
/// </summary>
|
||||
public void StartCourseController()
|
||||
{
|
||||
|
||||
// Setting up course
|
||||
course = courselist.courses[courselist.currentCourseIndex];
|
||||
maxWords = course.theme.learnables.Count;
|
||||
@@ -271,8 +272,8 @@ public class CoursesController : AbstractFeedback
|
||||
{
|
||||
// This function is also called (async) when pressing the 'Gebaar overslaan' button,
|
||||
// so check for condition so we don't skip multiple signs
|
||||
if (isNextSignInTransit || maxWords <= progress.completedLearnables)
|
||||
return;
|
||||
//if (isNextSignInTransit || maxWords < progress.completedLearnables)
|
||||
if (isNextSignInTransit) return;
|
||||
|
||||
progress.progress = (float)progress.completedLearnables / (float)maxWords;
|
||||
progressBar.fillAmount = progress.progress;
|
||||
@@ -284,7 +285,7 @@ public class CoursesController : AbstractFeedback
|
||||
StartCoroutine(CRNextSign());
|
||||
}
|
||||
// Finish course and record progress
|
||||
if (progress.completedLearnables == maxWords)
|
||||
else
|
||||
{
|
||||
FinishCourse();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Video;
|
||||
using System.Linq;
|
||||
|
||||
|
||||
public class PanelMultipleChoice : MonoBehaviour
|
||||
@@ -95,15 +96,21 @@ public class PanelMultipleChoice : MonoBehaviour
|
||||
/// <returns></returns>
|
||||
public List<Learnable> GetWrongOptions(int notThisIndex)
|
||||
{
|
||||
List<Learnable> randomSigns = new List<Learnable>();
|
||||
// TODO: find more koosjer way to do this
|
||||
while (randomSigns.Count < 3)
|
||||
var test = progress.learnables.FindAll((l) => l.index != notThisIndex && l.inUse);
|
||||
|
||||
for (int i = test.Count - 1; i > 0; i--)
|
||||
{
|
||||
int index = progress.GetRandomLearnable().index;
|
||||
if (index != notThisIndex && !randomSigns.Contains(signs[index]))
|
||||
{
|
||||
randomSigns.Add(signs[index]);
|
||||
}
|
||||
// Generate a random index between 0 and i (inclusive)
|
||||
int j = UnityEngine.Random.Range(0, i + 1);
|
||||
|
||||
// Swap the values at indices i and j
|
||||
(test[j], test[i]) = (test[i], test[j]);
|
||||
}
|
||||
|
||||
List<Learnable> randomSigns = new List<Learnable>();
|
||||
foreach(var sign in test.Take(3))
|
||||
{
|
||||
randomSigns.Add(signs[sign.index]);
|
||||
}
|
||||
|
||||
return randomSigns;
|
||||
|
||||
Reference in New Issue
Block a user