Commit b74d265e authored by Sandro Andrade's avatar Sandro Andrade

Move answerLength to collected property

parent 40c065e5
......@@ -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",
......
......@@ -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",
......
......@@ -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",
......
......@@ -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",
......
......@@ -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",
......
......@@ -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",
......
......@@ -28,8 +28,7 @@ namespace Minuet
{
IExerciseController::IExerciseController(QObject *parent)
: QObject(parent),
m_answerLength(1)
: QObject(parent)
{
qmlRegisterInterface<IExerciseController>("IExerciseController");
}
......
......@@ -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;
};
......
......@@ -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();
......
......@@ -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)
......
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