Fixed course freezing and other course-ending bugs

This commit is contained in:
CoudronJerome
2023-05-08 20:57:09 +02:00
parent c3ebf48cdc
commit ae29ef9835
8 changed files with 22 additions and 50 deletions

View File

@@ -216,7 +216,7 @@ MonoBehaviour:
thumbnail: {fileID: 4959898009379617328} thumbnail: {fileID: 4959898009379617328}
title: {fileID: 4959898009362012447} title: {fileID: 4959898009362012447}
button: {fileID: 4959898007614330355} button: {fileID: 4959898007614330355}
slider: {fileID: 3971139188485731716} slider: {fileID: 5742510687904928776}
completed: {fileID: 8032316393302770855} completed: {fileID: 8032316393302770855}
--- !u!95 &5637671876400780781 --- !u!95 &5637671876400780781
Animator: Animator:

View File

@@ -69,7 +69,7 @@ public class CourseItem : MonoBehaviour
progress = Mathf.Clamp01(progress); progress = Mathf.Clamp01(progress);
completed.SetActive(1.0f <= progress); completed.SetActive(1.0f <= progress);
slider.SetActive(0.0f <= progress && progress < 1.0f); slider.SetActive(0.0f <= progress && progress < 1.0f);
slider.GetComponent<SlicedSlider>().fillAmount = progress; slider.GetComponentInChildren<SlicedSlider>().fillAmount = progress;
// Add click functionality // Add click functionality
button.onClick.AddListener(() => button.onClick.AddListener(() =>

View File

@@ -1545,7 +1545,7 @@ MonoBehaviour:
m_Calls: m_Calls:
- m_Target: {fileID: 1122267056} - m_Target: {fileID: 1122267056}
m_TargetAssemblyTypeName: CoursesController, CourseScripts m_TargetAssemblyTypeName: CoursesController, CourseScripts
m_MethodName: StartCourseController m_MethodName: ReturnToActivityScreen
m_Mode: 1 m_Mode: 1
m_Arguments: m_Arguments:
m_ObjectArgument: {fileID: 0} m_ObjectArgument: {fileID: 0}

View File

@@ -196,6 +196,7 @@ public class CoursesController : AbstractFeedback
/// </summary> /// </summary>
public void StartCourseController() public void StartCourseController()
{ {
// Setting up course // Setting up course
course = courselist.courses[courselist.currentCourseIndex]; course = courselist.courses[courselist.currentCourseIndex];
maxWords = course.theme.learnables.Count; 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, // This function is also called (async) when pressing the 'Gebaar overslaan' button,
// so check for condition so we don't skip multiple signs // so check for condition so we don't skip multiple signs
if (isNextSignInTransit || maxWords <= progress.completedLearnables) //if (isNextSignInTransit || maxWords < progress.completedLearnables)
return; if (isNextSignInTransit) return;
progress.progress = (float)progress.completedLearnables / (float)maxWords; progress.progress = (float)progress.completedLearnables / (float)maxWords;
progressBar.fillAmount = progress.progress; progressBar.fillAmount = progress.progress;
@@ -284,7 +285,7 @@ public class CoursesController : AbstractFeedback
StartCoroutine(CRNextSign()); StartCoroutine(CRNextSign());
} }
// Finish course and record progress // Finish course and record progress
if (progress.completedLearnables == maxWords) else
{ {
FinishCourse(); FinishCourse();
} }

View File

@@ -4,6 +4,7 @@ using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using UnityEngine.Video; using UnityEngine.Video;
using System.Linq;
public class PanelMultipleChoice : MonoBehaviour public class PanelMultipleChoice : MonoBehaviour
@@ -95,15 +96,21 @@ public class PanelMultipleChoice : MonoBehaviour
/// <returns></returns> /// <returns></returns>
public List<Learnable> GetWrongOptions(int notThisIndex) public List<Learnable> GetWrongOptions(int notThisIndex)
{ {
List<Learnable> randomSigns = new List<Learnable>(); var test = progress.learnables.FindAll((l) => l.index != notThisIndex && l.inUse);
// TODO: find more koosjer way to do this
while (randomSigns.Count < 3) for (int i = test.Count - 1; i > 0; i--)
{ {
int index = progress.GetRandomLearnable().index; // Generate a random index between 0 and i (inclusive)
if (index != notThisIndex && !randomSigns.Contains(signs[index])) int j = UnityEngine.Random.Range(0, i + 1);
{
randomSigns.Add(signs[index]); // 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; return randomSigns;

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: b0fcd1404d38ac94aace1c5b3564cc04
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,20 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 63770b348488e4a3983eb57792523f54, type: 3}
m_Name: NatMLHub
m_EditorClassIdentifier:
accessKey:
user:
email:
username:
billing:
plan:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 327974eea6e413e418ae0fddd61a0e00
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant: