~s-cecilio/lenmus/v5.3

« back to all changes in this revision

Viewing changes to src/exercises/dialogs/lenmus_dlg_exercise_mode.cpp

  • Committer: Cecilio Salmeron
  • Date: 2012-11-25 14:37:10 UTC
  • Revision ID: s.cecilios@gmail.com-20121125143710-ohccpjc3pk7ut3u1
Added script po-statistics.pl to maintain website translations page. * Restored exercise modes (learning, practise, exam and quiz). * Added DlgExerciseMode. * Restored right/wrong sounds when answering an exercise. * Fixed bug #1074909. * Fixed bug #1082637.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//---------------------------------------------------------------------------------------
 
2
//    LenMus Phonascus: The teacher of music
 
3
//    Copyright (c) 2002-2012 LenMus project
 
4
//
 
5
//    This program is free software; you can redistribute it and/or modify it under the
 
6
//    terms of the GNU General Public License as published by the Free Software Foundation,
 
7
//    either version 3 of the License, or (at your option) any later version.
 
8
//
 
9
//    This program is distributed in the hope that it will be useful, but WITHOUT ANY
 
10
//    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 
11
//    PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 
12
//
 
13
//    You should have received a copy of the GNU General Public License along with this
 
14
//    program. If not, see <http://www.gnu.org/licenses/>.
 
15
//
 
16
//    For any comment, suggestion or feature request, please contact the manager of
 
17
//    the project at cecilios@users.sourceforge.net
 
18
//
 
19
//---------------------------------------------------------------------------------------
 
20
 
 
21
//lenmus
 
22
#include "lenmus_dlg_exercise_mode.h"
 
23
#include "lenmus_constrains.h"
 
24
 
 
25
//
 
26
////lomse
 
27
//#include "lomse_pitch.h"
 
28
//#include "lomse_internal_model.h"
 
29
//using namespace lomse;
 
30
 
 
31
//wxWidgets
 
32
#include <wx/wxprec.h>
 
33
#include <wx/wx.h>
 
34
#include <wx/dialog.h>
 
35
#include <wx/button.h>
 
36
 
 
37
 
 
38
namespace lenmus
 
39
{
 
40
 
 
41
//-----------------------------------------------------------------------------
 
42
// Event table: connect the events to the handler functions to process them
 
43
//-----------------------------------------------------------------------------
 
44
 
 
45
BEGIN_EVENT_TABLE(DlgExerciseMode, wxDialog)
 
46
   EVT_BUTTON(wxID_OK, DlgExerciseMode::OnAcceptClicked)
 
47
END_EVENT_TABLE()
 
48
 
 
49
 
 
50
 
 
51
//---------------------------------------------------------------------------------------
 
52
DlgExerciseMode::DlgExerciseMode(wxWindow* parent, int* pMode,
 
53
                                 ExerciseOptions* pConstrains)
 
54
    : wxDialog(parent, wxID_ANY, _("Choose the operation mode"),
 
55
#if (LENMUS_PLATFORM_UNIX == 1)
 
56
               //BUG BYPASS: In linux doesn't auto-resize. I don't know why
 
57
               wxDefaultPosition, wxSize(700, 520),
 
58
#else
 
59
               wxDefaultPosition, wxSize(700, -1),
 
60
#endif
 
61
               wxCAPTION | wxCLOSE_BOX | wxRESIZE_BORDER )
 
62
    , m_pMode(pMode)
 
63
    , m_pRadLearning(NULL)
 
64
    , m_pRadPractice(NULL)
 
65
    , m_pRadExam(NULL)
 
66
    , m_pRadQuiz(NULL)
 
67
    , m_pParent(parent)
 
68
    , m_pConstrains(pConstrains)
 
69
{
 
70
    create_controls();
 
71
    set_current_mode();
 
72
    CentreOnScreen();
 
73
}
 
74
 
 
75
//---------------------------------------------------------------------------------------
 
76
DlgExerciseMode::~DlgExerciseMode()
 
77
{
 
78
}
 
79
 
 
80
//---------------------------------------------------------------------------------------
 
81
void DlgExerciseMode::create_controls()
 
82
{
 
83
    //AWARE: Code created with wxFormBuilder and copied here.
 
84
    //Modifications:
 
85
    //added if-then blocks to control which buttons to create
 
86
    //added window style wxRB_GROUP to first radio button
 
87
 
 
88
        this->SetSizeHints( wxDefaultSize, wxDefaultSize );
 
89
 
 
90
        wxBoxSizer* pMainSizer;
 
91
        pMainSizer = new wxBoxSizer( wxVERTICAL );
 
92
 
 
93
    if (m_pConstrains->IsGenerationModeSupported(k_learning_mode))
 
94
    {
 
95
        m_pRadLearning = new wxRadioButton( this, wxID_ANY, _("Learning mode"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
 
96
        pMainSizer->Add( m_pRadLearning, 0, wxTOP|wxRIGHT|wxLEFT|wxBOTTOM, 10 );
 
97
 
 
98
        m_pLblLearning = new wxStaticText( this, wxID_ANY, _("The program will record and analyse your answers.  Questions will focus on those issues in wich the program detects that you are having more trouble. This mode minimizes your study time and optimises your learning rate. It is based on the 'Leitner' methodology, also known as 'spaced repetition'."), wxPoint( -1,-1 ), wxDefaultSize, 0 );
 
99
        m_pLblLearning->Wrap( 650 );
 
100
        pMainSizer->Add( m_pLblLearning, 0, wxLEFT, 30 );
 
101
    }
 
102
 
 
103
    if (m_pConstrains->IsGenerationModeSupported(k_practise_mode))
 
104
    {
 
105
        m_pRadPractice = new wxRadioButton( this, wxID_ANY, _("Practice mode"), wxDefaultPosition, wxDefaultSize, 0 );
 
106
        pMainSizer->Add( m_pRadPractice, 0, wxTOP|wxRIGHT|wxLEFT|wxBOTTOM, 10 );
 
107
 
 
108
        m_pLblPractice = new wxStaticText( this, wxID_ANY, _("The program uses your performance data, saved in learning mode, to choose questions. It selects questions at random but giving more probability to those that are troubling you. This mode is useful when you have finished your daily assignment in 'learning' mode and you would like to practise more."), wxPoint( -1,-1 ), wxDefaultSize, 0 );
 
109
        m_pLblPractice->Wrap( 650 );
 
110
        pMainSizer->Add( m_pLblPractice, 0, wxLEFT, 30 );
 
111
    }
 
112
 
 
113
    if (m_pConstrains->IsGenerationModeSupported(k_exam_mode))
 
114
    {
 
115
        m_pRadExam = new wxRadioButton( this, wxID_ANY, _("Exam mode"), wxDefaultPosition, wxDefaultSize, 0 );
 
116
        pMainSizer->Add( m_pRadExam, 0, wxTOP|wxRIGHT|wxLEFT|wxBOTTOM, 10 );
 
117
 
 
118
        m_pLblExam = new wxStaticText( this, wxID_ANY, _("Neither your saved performance data not your answers to previous questions are taken into account to formulate questions. At any moment, all possible questions have the same probability of being asked. This mode is useful for testing your knowledge before taking an examination, but is less useful for learning."), wxPoint( -1,-1 ), wxDefaultSize, 0 );
 
119
        m_pLblExam->Wrap( 650 );
 
120
        pMainSizer->Add( m_pLblExam, 0, wxLEFT, 30 );
 
121
    }
 
122
 
 
123
    if (m_pConstrains->IsGenerationModeSupported(k_quiz_mode))
 
124
    {
 
125
        m_pRadQuiz = new wxRadioButton( this, wxID_ANY, _("Quiz mode"), wxDefaultPosition, wxDefaultSize, 0 );
 
126
        pMainSizer->Add( m_pRadQuiz, 0, wxTOP|wxRIGHT|wxLEFT|wxBOTTOM, 10 );
 
127
 
 
128
        m_pLblQuiz = new wxStaticText( this, wxID_ANY, _("This mode is similar to the 'exam' mode but two answer counters are displayed and questions are accounted in both counters: one in the first counter and the next one in the second counter. This mode is useful to work in pairs or in teams at classroom."), wxPoint( -1,-1 ), wxDefaultSize, 0 );
 
129
        m_pLblQuiz->Wrap( 650 );
 
130
        pMainSizer->Add( m_pLblQuiz, 0, wxBOTTOM|wxLEFT, 30 );
 
131
    }
 
132
 
 
133
        wxBoxSizer* pButtonSizer;
 
134
        pButtonSizer = new wxBoxSizer( wxHORIZONTAL );
 
135
 
 
136
 
 
137
        pButtonSizer->Add( 0, 0, 1, wxEXPAND, 5 );
 
138
 
 
139
        m_pBtnAccept = new wxButton( this, wxID_OK, _("Accept"), wxDefaultPosition, wxDefaultSize, 0 );
 
140
        pButtonSizer->Add( m_pBtnAccept, 0, wxBOTTOM, 5 );
 
141
 
 
142
 
 
143
        pButtonSizer->Add( 0, 0, 1, wxEXPAND, 5 );
 
144
 
 
145
        pMainSizer->Add( pButtonSizer, 1, wxEXPAND|wxBOTTOM, 20 );
 
146
 
 
147
        this->SetSizer( pMainSizer );
 
148
        this->Layout();
 
149
 
 
150
}
 
151
 
 
152
//---------------------------------------------------------------------------------------
 
153
void DlgExerciseMode::set_current_mode()
 
154
{
 
155
    if (*m_pMode == k_learning_mode)
 
156
        m_pRadLearning->SetValue(true);
 
157
    else if (*m_pMode == k_practise_mode)
 
158
        m_pRadPractice->SetValue(true);
 
159
    else if (*m_pMode == k_exam_mode)
 
160
        m_pRadExam->SetValue(true);
 
161
    else
 
162
        m_pRadQuiz->SetValue(true);
 
163
}
 
164
 
 
165
//---------------------------------------------------------------------------------------
 
166
void DlgExerciseMode::OnAcceptClicked(wxCommandEvent& WXUNUSED(event))
 
167
{
 
168
    if (m_pRadLearning && m_pRadLearning->GetValue())
 
169
        *m_pMode = k_learning_mode;
 
170
    else if (m_pRadPractice && m_pRadPractice->GetValue())
 
171
        *m_pMode = k_practise_mode;
 
172
    else if (m_pRadQuiz && m_pRadQuiz->GetValue())
 
173
        *m_pMode = k_quiz_mode;
 
174
    else
 
175
        *m_pMode = k_exam_mode;
 
176
 
 
177
    //terminate the dialog
 
178
    EndModal(wxID_OK);
 
179
}
 
180
 
 
181
 
 
182
}   //namespace lenmus