BuildmLearn Toolkit  2.0.4
BuildmLearn Toolkit is an easy-to-use program that helps users make mobile apps without any knowledge of application development.
 All Classes Functions Enumerations Groups Pages
quizeditor.h
1 /*
2  Copyright (c) 2012, BuildmLearn Contributors listed at http://buildmlearn.org/people/
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice, this
9  list of conditions and the following disclaimer.
10 
11  * Redistributions in binary form must reproduce the above copyright notice,
12  this list of conditions and the following disclaimer in the documentation
13  and/or other materials provided with the distribution.
14 
15  * Neither the name of the BuildmLearn nor the names of its
16  contributors may be used to endorse or promote products derived from
17  this software without specific prior written permission.
18 
19  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30 
31 #ifndef QUIZEDITOR_H
32 #define QUIZEDITOR_H
33 
34 #include "core/templateeditor.h"
35 
36 #include "ui_quizeditor.h"
37 #include "templates/quiz/quizquestion.h"
38 
39 #include <QIcon>
40 
41 
42 namespace Ui {
43  class QuizEditor;
44 }
45 
46 class QuizSimulator;
47 class QShowEvent;
48 
49 /// \brief Editor for Quiz.
50 /// \ingroup template-quiz
51 class QuizEditor : public TemplateEditor {
52  Q_OBJECT
53 
54  friend class QuizSimulator;
55  friend class QuizCore;
56 
57  public:
58  // Constructors and destructors.
59  explicit QuizEditor(TemplateCore *core, QWidget *parent = 0);
60  virtual ~QuizEditor();
61 
62  QString generateBundleData();
64  bool loadBundleData(const QString &bundle_data);
65 
66  /// \brief Access to list of added questions.
67  /// \return Returns list of added questions.
68  QList<QuizQuestion> activeQuestions() const;
69 
70  QString projectName();
71  QString authorName();
72 
73  private slots:
74  void updateQuestionCount();
75  void addQuestion(const QString &question, const QStringList &answers, int correct_answer);
76  void addQuestion();
77  void loadQuestion(int index);
78  void removeQuestion();
79  void saveQuestion();
80  void moveQuestionUp();
81  void moveQuestionDown();
82 
83  void configureUpDown();
84  void setEditorsEnabled(bool enabled);
85 
86  void checkName();
87  void checkAuthor();
88 
89  void updateNameStatus();
90  void updateAuthorStatus();
91 
92  private:
93  QuizQuestion m_activeQuestion;
94  Ui::QuizEditor *m_ui;
95  QIcon m_iconYes;
96  QIcon m_iconNo;
97 };
98 
99 #endif // QUIZEDITOR_H
Editor for Quiz.
Definition: quizeditor.h:51
QString projectName()
Access to project name of current editor.
Definition: quizeditor.cpp:151
bool canGenerateApplications()
Specifies if template can generate applications or not.
Definition: quizeditor.cpp:416
Simulator for Quiz template.
Definition: quizsimulator.h:50
QString generateBundleData()
Generates RAW data which represent data of this template.
Definition: quizeditor.cpp:462
Main core of Quiz template.
Definition: quizcore.h:47
TemplateCore * core() const
Access to associated template core.
Represents the editor of the template.
QList< QuizQuestion > activeQuestions() const
Access to list of added questions.
Definition: quizeditor.cpp:141
bool loadBundleData(const QString &bundle_data)
Loads editor state from XML bundle.
Definition: quizeditor.cpp:423
The core class container for single template.
Definition: templatecore.h:43
QString authorName()
Access to author name of current editor.
Definition: quizeditor.cpp:155
Container for one question.
Definition: quizquestion.h:41