Resolve WES-181 "Missing code doc"

This commit is contained in:
Dries Van Schuylenbergh
2023-05-14 20:18:29 +00:00
committed by Louis Adriaens
parent 7505ae7262
commit 3d99184717
67 changed files with 686 additions and 198 deletions

View File

@@ -93,6 +93,9 @@ public class CoursesController : AbstractFeedback
/// </summary>
private Image feedbackProgressImage;
/// <summary>
/// Reference to the video player
/// </summary>
public VideoPlayer videoPlayer;
/// <summary>
@@ -206,7 +209,7 @@ public class CoursesController : AbstractFeedback
/// </summary>
public void StartCourseController()
{
// Setting up course
course = courselist.courses[courselist.currentCourseIndex];
maxWords = course.theme.learnables.Count;
@@ -333,9 +336,10 @@ public class CoursesController : AbstractFeedback
private GameObject SetupPanel()
{
if (corruptPanelId == true)
{
{
(currentWordIndex, panelId) = (1, CorruptedPanelIDValue);
} else
}
else
{
(currentWordIndex, panelId) = FetchSign().ToValueTuple();
}
@@ -432,7 +436,7 @@ public class CoursesController : AbstractFeedback
if (currentWordIndex < course.theme.learnables.Count && panelId != 1 && !hasAnswered)
{
// Get current sign
Learnable sign = course.theme.learnables[currentWordIndex];
string currentSign = sign.name.ToUpper().Replace(" ", "-");
@@ -552,6 +556,10 @@ public class CoursesController : AbstractFeedback
}
/// <summary>
/// Wait 0.75 seconds and proceed to the next sign
/// </summary>
/// <returns></returns>
private IEnumerator WaitNextSign()
{
// Wait for 0.75 seconds
@@ -588,7 +596,7 @@ public class CoursesController : AbstractFeedback
UserList.Save();
SystemController.GetInstance().BackToPreviousScene();
}
/// <summary>
/// Returns panelId for testing
/// </summary>
@@ -597,6 +605,7 @@ public class CoursesController : AbstractFeedback
{
return panelId;
}
/// <summary>
/// Returns currentSign for testing
/// </summary>
@@ -606,6 +615,7 @@ public class CoursesController : AbstractFeedback
Learnable sign = course.theme.learnables[currentWordIndex];
return sign.name.ToUpper().Replace(" ", "-");
}
/// <summary>
/// Used for testing an out of bounds PanelId
/// </summary>
@@ -642,6 +652,4 @@ public class CoursesController : AbstractFeedback
CorruptedPanelIDValue = 1;
yield return CRNextSign();
}
}

View File

@@ -1,12 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;
using System.Linq;
/// <summary>
/// Class to handle panel with multiple choice options
/// </summary>
public class PanelMultipleChoice : MonoBehaviour
{
/// <summary>
@@ -108,7 +110,7 @@ public class PanelMultipleChoice : MonoBehaviour
}
List<Learnable> randomSigns = new List<Learnable>();
foreach(var sign in test.Take(3))
foreach (var sign in test.Take(3))
{
randomSigns.Add(signs[sign.index]);
}
@@ -152,7 +154,6 @@ public class PanelMultipleChoice : MonoBehaviour
}
});
}
}
/// <summary>
@@ -211,13 +212,11 @@ public class PanelMultipleChoice : MonoBehaviour
playButton.sprite = pauseSprite;
videoPlayer.Play();
}
else
{
// Pause video and and switch sprite of button
playButton.sprite = playSprite;
videoPlayer.Pause();
}
}
}

View File

@@ -3,10 +3,24 @@ using TMPro;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// Class to handle panel with only image and webcam
/// </summary>
public class PanelWithImage : MonoBehaviour
{
/// <summary>
/// Reference to the feedback progress bar
/// </summary>
public GameObject feedbackProgressObject;
/// <summary>
/// Reference to the object containing the message for when the course is loaded in preview mode
/// </summary>
public GameObject previewMessage;
/// <summary>
/// True if the course is loaded in preview mode, false otherwise
/// </summary>
public bool isPreview;
/// <summary>
@@ -14,8 +28,14 @@ public class PanelWithImage : MonoBehaviour
/// </summary>
public Transform signImageContainer;
/// <summary>
/// Reference to the prefab for displaying the image
/// </summary>
public GameObject signImagePrefab;
/// <summary>
/// Reference to the webcam
/// </summary>
public RawImage webcamScreen;
/// <summary>
@@ -33,9 +53,19 @@ public class PanelWithImage : MonoBehaviour
/// </summary>
public Image feedbackProgressImage;
/// <summary>
/// Reference to the list of learnables
/// </summary>
public List<Learnable> signs;
/// <summary>
/// Index of the current learnable in the list with learnables
/// </summary>
public int currentSignIndex;
/// <summary>
/// Update the display of this panel
/// </summary>
public void Display()
{
Learnable currentSign = signs[currentSignIndex];

View File

@@ -4,20 +4,49 @@ using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;
/// <summary>
/// Class to handle panel with image, video and webcam
/// </summary>
public class PanelWithVideoAndImage : MonoBehaviour
{
/// <summary>
/// Reference to the feedback progress bar
/// </summary>
public GameObject feedbackProgressObject;
/// <summary>
/// Reference to the object containing the message for when the course is loaded in preview mode
/// </summary>
public GameObject previewMessage;
/// <summary>
/// True if the course is loaded in preview mode, false otherwise
/// </summary>
public bool isPreview;
/// <summary>
/// Video 'play' sprite
/// </summary>
public Sprite playSprite;
/// <summary>
/// Video 'pause' sprite
/// </summary>
public Sprite pauseSprite;
/// <summary>
/// Reference to instructional video player
/// </summary>
public VideoPlayer videoPlayer;
/// <summary>
/// Refrence to the video play/pause button
/// </summary>
public Image playButton;
/// <summary>
/// Reference to the webcam
/// </summary>
public RawImage webcamScreen;
/// <summary>
@@ -25,6 +54,9 @@ public class PanelWithVideoAndImage : MonoBehaviour
/// </summary>
public Transform signImageContainer;
/// <summary>
/// Reference to the prefab for displaying the image
/// </summary>
public GameObject signImagePrefab;
/// <summary>
@@ -42,9 +74,19 @@ public class PanelWithVideoAndImage : MonoBehaviour
/// </summary>
public Image feedbackProgressImage;
/// <summary>
/// Reference to the list of learnables
/// </summary>
public List<Learnable> signs;
/// <summary>
/// Index of the current learnable in the list with learnables
/// </summary>
public int currentSignIndex;
/// <summary>
/// Update the display of this panel
/// </summary>
public void Display()
{
Learnable currentSign = signs[currentSignIndex];
@@ -79,13 +121,11 @@ public class PanelWithVideoAndImage : MonoBehaviour
playButton.sprite = pauseSprite;
videoPlayer.Play();
}
else
{
// Pause video and and switch sprite of button
playButton.sprite = playSprite;
videoPlayer.Pause();
}
}
}

View File

@@ -1,20 +1,20 @@
using NUnit.Framework;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using UnityEngine.TestTools;
/// <summary>
/// Test the PanelMultipleChoice, PanelWithImage, and PanelWithVideoAndImage classes
/// </summary>
[TestFixture]
public class PaneTests
public class CoursePanelsTests
{
/// <summary>
/// Setup the environment before each test
/// </summary>
/// <returns></returns>
[UnitySetUp]
public IEnumerator SetupFunction()
{
@@ -45,11 +45,12 @@ public class PaneTests
yield return null;
}
/// <summary>
/// Cleanup after testing
/// </summary>
[TearDown]
public void TearDown_PaneTests()
public void TearDown_PanelTests()
{
PersistentDataController.PATH = null;
}
@@ -57,7 +58,6 @@ public class PaneTests
/// <summary>
/// Test pausing/resuming the video in all course panels
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator PlayPauseTest()
{
@@ -71,10 +71,10 @@ public class PaneTests
panel.TogglePlayPause();
yield return null;
Assert.IsTrue(panel.videoPlayer.isPlaying == false);
Assert.IsFalse(panel.videoPlayer.isPlaying);
panel.TogglePlayPause();
yield return null;
Assert.IsTrue(panel.videoPlayer.isPlaying == true);
Assert.IsTrue(panel.videoPlayer.isPlaying);
yield return coursesController.SummonMultipleChoice();
@@ -83,11 +83,10 @@ public class PaneTests
panel2.TogglePlayPause();
yield return null;
Assert.IsTrue(panel2.videoPlayer.isPlaying == false);
Assert.IsFalse(panel2.videoPlayer.isPlaying);
panel2.TogglePlayPause();
yield return null;
Assert.IsTrue(panel2.videoPlayer.isPlaying == true);
Assert.IsTrue(panel2.videoPlayer.isPlaying);
yield return null;
}
}

View File

@@ -4,17 +4,19 @@ using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using UnityEngine.TestTools;
using UnityEngine.UI;
/// <summary>
/// Test the CoursesController class
/// </summary>
[TestFixture]
public class CoursesControllerTests
{
/// <summary>
/// Setup the environment before each test
/// </summary>
/// <returns></returns>
[UnitySetUp]
public IEnumerator SetupFunction()
{
@@ -31,7 +33,6 @@ public class CoursesControllerTests
var mainMenuScreen = GameObject.FindObjectOfType<MainMenuScreen>();
mainMenuScreen.GotoCourses();
yield return null;
}
/// <summary>
@@ -42,13 +43,13 @@ public class CoursesControllerTests
{
PersistentDataController.PATH = null;
}
/// <summary>
/// Function used to Spoof the sign predictor. The it uses 0f as certainty so the sign is "perfect".
/// Function used to spoof the sign predictor. It uses 0.0f as certainty so the sign is "perfect".
/// </summary>
/// <param name="sign"></param>
/// <param name="signPredictor"></param>
/// <returns></returns>
public IEnumerator SignLetter(string sign, SignPredictor signPredictor)
private IEnumerator SignLetter(string sign, SignPredictor signPredictor)
{
signPredictor.learnableProbabilities = new Dictionary<string, float>();
// Loop through all capital letters of the alphabet
@@ -66,11 +67,10 @@ public class CoursesControllerTests
yield return listener.ProcessIncomingCall();
}
}
/// <summary>
/// Simulates a little playtrough of a course
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator PlaytroughTest()
{
@@ -115,6 +115,7 @@ public class CoursesControllerTests
coursesController.ReturnToActivityScreen();
yield return new WaitForSeconds(1.0f);
}
/// <summary>
/// Tests a preview course
/// </summary>
@@ -208,10 +209,10 @@ public class CoursesControllerTests
yield return coursesController.CallSetupPanel();
yield return new WaitForSeconds(0.2f);
}
/// <summary>
/// Tests what happens when the sign is correct but not certain enough
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator UnconfidentTest()
{
@@ -251,10 +252,10 @@ public class CoursesControllerTests
yield return new WaitForSeconds(1.0f);
Assert.AreEqual(coursesController.GetCurrentSign(), "A");
}
/// <summary>
/// Test what happens when an incorrect sign is signed
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator IncorrectSignTest()
{
@@ -280,10 +281,10 @@ public class CoursesControllerTests
yield return new WaitForSeconds(1.0f);
Assert.AreEqual(coursesController.GetCurrentSign(), "A");
}
/// <summary>
/// Test what happens when there is no sign being signed
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator NoSignTest()
{
@@ -309,10 +310,10 @@ public class CoursesControllerTests
yield return new WaitForSeconds(1.0f);
Assert.AreEqual(coursesController.GetCurrentSign(), "A");
}
/// <summary>
/// Tests what happens when a wrong sign is performed twice but with a long enough interval
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator TwoWrongFastTest()
{
@@ -345,10 +346,10 @@ public class CoursesControllerTests
Assert.AreEqual(coursesController.GetCurrentSign(), "A");
}
/// <summary>
/// Tests what happens when the sign can not be processed but the Feedback is not Null
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator FeedbackNotNullTest()
{