summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandro S. Andrade <[email protected]>2016-07-05 15:55:19 -0300
committerSandro S. Andrade <[email protected]>2016-07-05 15:55:19 -0300
commitb74d265e150980307037e394b4442b233e8be9cd (patch)
treed56b1e828bb65a3711d1f4cd0a1657c07f263a33
parent40c065e5b4300bc3d8518ed0da7fe539bcdc1512 (diff)
Move answerLength to collected property
-rw-r--r--data/exercises/chords-root-position-exercises.json1
-rw-r--r--data/exercises/intervals-ascending-melodic-exercises.json1
-rw-r--r--data/exercises/intervals-descending-melodic-exercises.json1
-rw-r--r--data/exercises/rhythm-easy.json1
-rw-r--r--data/exercises/rhythm-medium.json1
-rw-r--r--data/exercises/scales-major-and-its-modes-exercises.json1
-rw-r--r--src/interfaces/iexercisecontroller.cpp3
-rw-r--r--src/interfaces/iexercisecontroller.h2
-rw-r--r--src/shell/exercisecontroller.cpp3
-rw-r--r--src/shell/qml/ExerciseView.qml1
10 files changed, 9 insertions, 6 deletions
diff --git a/data/exercises/chords-root-position-exercises.json b/data/exercises/chords-root-position-exercises.json
index e3ae067..22a50c4 100644
--- a/data/exercises/chords-root-position-exercises.json
+++ b/data/exercises/chords-root-position-exercises.json
@@ -5,6 +5,7 @@
"root": "21..104",
"playMode": "chord",
"userMessage": "Hear the chord and then choose an answer from options below",
+ "numberOfSelectedOptions": 1,
"children": [
{
"name": "Root Position",
diff --git a/data/exercises/intervals-ascending-melodic-exercises.json b/data/exercises/intervals-ascending-melodic-exercises.json
index 8e1e181..7b175b9 100644
--- a/data/exercises/intervals-ascending-melodic-exercises.json
+++ b/data/exercises/intervals-ascending-melodic-exercises.json
@@ -5,6 +5,7 @@
"root": "21..104",
"playMode": "scale",
"userMessage": "Hear the interval and then choose an answer from options below",
+ "numberOfSelectedOptions": 1,
"children": [
{
"name": "Ascending Melodic Intervals",
diff --git a/data/exercises/intervals-descending-melodic-exercises.json b/data/exercises/intervals-descending-melodic-exercises.json
index 71d1ff6..6b60796 100644
--- a/data/exercises/intervals-descending-melodic-exercises.json
+++ b/data/exercises/intervals-descending-melodic-exercises.json
@@ -5,6 +5,7 @@
"root": "21..104",
"playMode": "scale",
"userMessage": "Hear the interval and then choose an answer from options below",
+ "numberOfSelectedOptions": 1,
"children": [
{
"name": "Descending Melodic Intervals",
diff --git a/data/exercises/rhythm-easy.json b/data/exercises/rhythm-easy.json
index 9005edc..e810cee 100644
--- a/data/exercises/rhythm-easy.json
+++ b/data/exercises/rhythm-easy.json
@@ -5,6 +5,7 @@
"playMode": "rhythm",
"userMessage": "Hear the rhythm and then choose an answer from options below",
"template": "lilypond-templates/rhythm.ly.tmpl",
+ "numberOfSelectedOptions": 4,
"children": [
{
"name": "Easy",
diff --git a/data/exercises/rhythm-medium.json b/data/exercises/rhythm-medium.json
index e09f806..7ca00ec 100644
--- a/data/exercises/rhythm-medium.json
+++ b/data/exercises/rhythm-medium.json
@@ -5,6 +5,7 @@
"playMode": "rhythm",
"userMessage": "Hear the rhythm and then choose an answer from options below",
"template": "lilypond-templates/rhythm.ly.tmpl",
+ "numberOfSelectedOptions": 4,
"children": [
{
"name": "Medium",
diff --git a/data/exercises/scales-major-and-its-modes-exercises.json b/data/exercises/scales-major-and-its-modes-exercises.json
index d01bc63..f82c7cf 100644
--- a/data/exercises/scales-major-and-its-modes-exercises.json
+++ b/data/exercises/scales-major-and-its-modes-exercises.json
@@ -5,6 +5,7 @@
"root": "21..104",
"playMode": "scale",
"userMessage": "Hear the scale and then choose an answer from options below",
+ "numberOfSelectedOptions": 1,
"children": [
{
"name": "Major Scale and its Modes",
diff --git a/src/interfaces/iexercisecontroller.cpp b/src/interfaces/iexercisecontroller.cpp
index d0ba6de..1995aeb 100644
--- a/src/interfaces/iexercisecontroller.cpp
+++ b/src/interfaces/iexercisecontroller.cpp
@@ -28,8 +28,7 @@ namespace Minuet
{
IExerciseController::IExerciseController(QObject *parent)
- : QObject(parent),
- m_answerLength(1)
+ : QObject(parent)
{
qmlRegisterInterface<IExerciseController>("IExerciseController");
}
diff --git a/src/interfaces/iexercisecontroller.h b/src/interfaces/iexercisecontroller.h
index 17296bd..50d01a7 100644
--- a/src/interfaces/iexercisecontroller.h
+++ b/src/interfaces/iexercisecontroller.h
@@ -37,7 +37,6 @@ class MINUETINTERFACES_EXPORT IExerciseController : public QObject
Q_OBJECT
Q_PROPERTY(QJsonArray exercises READ exercises)
Q_PROPERTY(QJsonObject currentExercise MEMBER m_currentExercise NOTIFY currentExerciseChanged)
- Q_PROPERTY(quint8 answerLength MEMBER m_answerLength)
Q_PROPERTY(QJsonArray selectedExerciseOptions READ selectedExerciseOptions NOTIFY selectedExerciseOptionsChanged)
public:
@@ -57,7 +56,6 @@ protected:
explicit IExerciseController(QObject *parent = 0);
QJsonObject m_currentExercise;
- quint8 m_answerLength;
QJsonArray m_selectedExerciseOptions;
};
diff --git a/src/shell/exercisecontroller.cpp b/src/shell/exercisecontroller.cpp
index 46ae835..5507c5a 100644
--- a/src/shell/exercisecontroller.cpp
+++ b/src/shell/exercisecontroller.cpp
@@ -72,7 +72,8 @@ void ExerciseController::randomlySelectExerciseOptions()
int minNote = INT_MAX;
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();
quint8 chosenExerciseOption = qrand() % exerciseOptions.size();
diff --git a/src/shell/qml/ExerciseView.qml b/src/shell/qml/ExerciseView.qml
index ed4f033..0c575bc 100644
--- a/src/shell/qml/ExerciseView.qml
+++ b/src/shell/qml/ExerciseView.qml
@@ -106,7 +106,6 @@ Item {
onClicked: {
exerciseView.state = "waitingForAnswer"
var playMode = core.exerciseController.currentExercise["playMode"]
- core.exerciseController.answerLength = (playMode == "rhythm") ? 4:1
core.exerciseController.randomlySelectExerciseOptions()
var selectedExerciseOptions = core.exerciseController.selectedExerciseOptions
core.soundBackend.prepareFromExerciseOptions(selectedExerciseOptions, playMode)