Commit b74d265e authored by Sandro Andrade's avatar Sandro Andrade

Move answerLength to collected property

parent 40c065e5
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
"root": "21..104", "root": "21..104",
"playMode": "chord", "playMode": "chord",
"userMessage": "Hear the chord and then choose an answer from options below", "userMessage": "Hear the chord and then choose an answer from options below",
"numberOfSelectedOptions": 1,
"children": [ "children": [
{ {
"name": "Root Position", "name": "Root Position",
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
"root": "21..104", "root": "21..104",
"playMode": "scale", "playMode": "scale",
"userMessage": "Hear the interval and then choose an answer from options below", "userMessage": "Hear the interval and then choose an answer from options below",
"numberOfSelectedOptions": 1,
"children": [ "children": [
{ {
"name": "Ascending Melodic Intervals", "name": "Ascending Melodic Intervals",
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
"root": "21..104", "root": "21..104",
"playMode": "scale", "playMode": "scale",
"userMessage": "Hear the interval and then choose an answer from options below", "userMessage": "Hear the interval and then choose an answer from options below",
"numberOfSelectedOptions": 1,
"children": [ "children": [
{ {
"name": "Descending Melodic Intervals", "name": "Descending Melodic Intervals",
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
"playMode": "rhythm", "playMode": "rhythm",
"userMessage": "Hear the rhythm and then choose an answer from options below", "userMessage": "Hear the rhythm and then choose an answer from options below",
"template": "lilypond-templates/rhythm.ly.tmpl", "template": "lilypond-templates/rhythm.ly.tmpl",
"numberOfSelectedOptions": 4,
"children": [ "children": [
{ {
"name": "Easy", "name": "Easy",
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
"playMode": "rhythm", "playMode": "rhythm",
"userMessage": "Hear the rhythm and then choose an answer from options below", "userMessage": "Hear the rhythm and then choose an answer from options below",
"template": "lilypond-templates/rhythm.ly.tmpl", "template": "lilypond-templates/rhythm.ly.tmpl",
"numberOfSelectedOptions": 4,
"children": [ "children": [
{ {
"name": "Medium", "name": "Medium",
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
"root": "21..104", "root": "21..104",
"playMode": "scale", "playMode": "scale",
"userMessage": "Hear the scale and then choose an answer from options below", "userMessage": "Hear the scale and then choose an answer from options below",
"numberOfSelectedOptions": 1,
"children": [ "children": [
{ {
"name": "Major Scale and its Modes", "name": "Major Scale and its Modes",
......
...@@ -28,8 +28,7 @@ namespace Minuet ...@@ -28,8 +28,7 @@ namespace Minuet
{ {
IExerciseController::IExerciseController(QObject *parent) IExerciseController::IExerciseController(QObject *parent)
: QObject(parent), : QObject(parent)
m_answerLength(1)
{ {
qmlRegisterInterface<IExerciseController>("IExerciseController"); qmlRegisterInterface<IExerciseController>("IExerciseController");
} }
......
...@@ -37,7 +37,6 @@ class MINUETINTERFACES_EXPORT IExerciseController : public QObject ...@@ -37,7 +37,6 @@ class MINUETINTERFACES_EXPORT IExerciseController : public QObject
Q_OBJECT Q_OBJECT
Q_PROPERTY(QJsonArray exercises READ exercises) Q_PROPERTY(QJsonArray exercises READ exercises)
Q_PROPERTY(QJsonObject currentExercise MEMBER m_currentExercise NOTIFY currentExerciseChanged) Q_PROPERTY(QJsonObject currentExercise MEMBER m_currentExercise NOTIFY currentExerciseChanged)
Q_PROPERTY(quint8 answerLength MEMBER m_answerLength)
Q_PROPERTY(QJsonArray selectedExerciseOptions READ selectedExerciseOptions NOTIFY selectedExerciseOptionsChanged) Q_PROPERTY(QJsonArray selectedExerciseOptions READ selectedExerciseOptions NOTIFY selectedExerciseOptionsChanged)
public: public:
...@@ -57,7 +56,6 @@ protected: ...@@ -57,7 +56,6 @@ protected:
explicit IExerciseController(QObject *parent = 0); explicit IExerciseController(QObject *parent = 0);
QJsonObject m_currentExercise; QJsonObject m_currentExercise;
quint8 m_answerLength;
QJsonArray m_selectedExerciseOptions; QJsonArray m_selectedExerciseOptions;
}; };
......
...@@ -72,7 +72,8 @@ void ExerciseController::randomlySelectExerciseOptions() ...@@ -72,7 +72,8 @@ void ExerciseController::randomlySelectExerciseOptions()
int minNote = INT_MAX; int minNote = INT_MAX;
int maxNote = INT_MIN; int maxNote = INT_MIN;
for (quint8 i = 0; i < m_answerLength; ++i) { quint8 numberOfSelectedOptions = m_currentExercise[QStringLiteral("numberOfSelectedOptions")].toInt();
for (quint8 i = 0; i < numberOfSelectedOptions; ++i) {
QJsonArray exerciseOptions = m_currentExercise[QStringLiteral("options")].toArray(); QJsonArray exerciseOptions = m_currentExercise[QStringLiteral("options")].toArray();
quint8 chosenExerciseOption = qrand() % exerciseOptions.size(); quint8 chosenExerciseOption = qrand() % exerciseOptions.size();
......
...@@ -106,7 +106,6 @@ Item { ...@@ -106,7 +106,6 @@ Item {
onClicked: { onClicked: {
exerciseView.state = "waitingForAnswer" exerciseView.state = "waitingForAnswer"
var playMode = core.exerciseController.currentExercise["playMode"] var playMode = core.exerciseController.currentExercise["playMode"]
core.exerciseController.answerLength = (playMode == "rhythm") ? 4:1
core.exerciseController.randomlySelectExerciseOptions() core.exerciseController.randomlySelectExerciseOptions()
var selectedExerciseOptions = core.exerciseController.selectedExerciseOptions var selectedExerciseOptions = core.exerciseController.selectedExerciseOptions
core.soundBackend.prepareFromExerciseOptions(selectedExerciseOptions, playMode) core.soundBackend.prepareFromExerciseOptions(selectedExerciseOptions, playMode)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment