Documentation for the Unity C# Library
Loading...
Searching...
No Matches
QuizData.cs
Go to the documentation of this file.
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Linq;
5using PixoVR.Event;
6using UnityEngine;
7using UnityEngine.Serialization;
8
9namespace PixoVR.Event
10{
11 [CreateAssetMenu(menuName = "Scenarios Data Menu/QuizData", fileName = "QuizData", order = 4)]
13 {
14 public List<Quiz> ListOfQuizzes;
15
16 public Quiz GetQuizItem(string quizID = "")
17 {
18 if (quizID.Trim() == string.Empty)
19 {
20 return null;
21 }
22
23 var quiz = ListOfQuizzes.FirstOrDefault(s => s.QuizId.Trim() == quizID);
24
25 return quiz;
26 }
27 }
28
29 [Serializable]
30 public class Quiz
31 {
32 public string QuizId;
33 [Space]
34 public List<QuestionInformation> Questions;
35 }
37 [Serializable]
38 public class ListAnswer
39 {
40 public List<int> Answers;
41 }
42
43 [Serializable]
44 public class QuestionInformation
45 {
46 public string Question;
47 [Space]
48 [SerializeField] public ItemsEnum BreakableObjectID;
49 public List<string> OptionsAnswers;
50 public int Scoring;
51 public string VO_ID_DescriptionForAnswer;
53 public List<int> CorrectAnswerID_Broken;
54 public List<ListAnswer> CorrectAnswersID_AdditionalBroken;
55 public string VO_ID_RightAnswer_NotBroken;
56 public string VO_ID_Incorrect_NotBroken;
57 public string VO_ID_RightAnswerBroken;
58 public string VO_ID_Incorrect_Broken;
59 public List<string> VO_ID_RightAnswersAdditionalBroken;
60 public List<string> VO_ID_Incorrect_AdditionalBroken;
61
62 [SerializeField] private string CorrectAnswer;
63 [SerializeField] private string SelectedAnswer;
65 public string GetSelectedAnswer()
66 {
67 return SelectedAnswer;
68 }
70 public string GetCorrectAnswer()
71 {
73 }
75 public void SetCorrectAnswer(string correct)
76 {
77 CorrectAnswer = correct;
78 }
80 public bool GetIsAnswerCorrect()
81 {
82 return SelectedAnswer == GetCorrectAnswer() && SelectedAnswer != string.Empty;
83 }
84
85 public int GetEarnedScoring()
86 {
87 return GetIsAnswerCorrect() ? Scoring : 0;
88 }
90 public void SetSelectedAnswer(string userAnswer)
91 {
92 SelectedAnswer = userAnswer;
93 }
94
95 public void ClearAnswers()
96 {
97 SelectedAnswer = string.Empty;
98 CorrectAnswer = string.Empty;
99 }
101}
[Serializable]
Definition QuizData.cs:51
List< int > Answers
Definition QuizData.cs:52
void SetSelectedAnswer(string userAnswer)
Definition QuizData.cs:120
void SetCorrectAnswer(string correct)
Definition QuizData.cs:105
string CorrectAnswer
[SerializeField]
Definition QuizData.cs:89
List< ListAnswer > CorrectAnswersID_AdditionalBroken
Definition QuizData.cs:75
List< string > VO_ID_Incorrect_AdditionalBroken
Definition QuizData.cs:81
List< string > VO_ID_RightAnswersAdditionalBroken
Definition QuizData.cs:80
List< int > CorrectAnswerID_IfNotBroken
Definition QuizData.cs:73
ItemsEnum BreakableObjectID
[SerializeField]
Definition QuizData.cs:69
string SelectedAnswer
[SerializeField]
Definition QuizData.cs:93
Quiz GetQuizItem(string quizID="")
Definition QuizData.cs:16
List< Quiz > ListOfQuizzes
Definition QuizData.cs:14
[Serializable]
Definition QuizData.cs:37
List< QuestionInformation > Questions
Definition QuizData.cs:40
ItemsEnum
Represents a list of ID for interactable objects.
Definition ItemsEnum.cs:11