• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

parley

  • sources
  • kde-4.12
  • kdeedu
  • parley
  • src
  • practice
abstractbackendmode.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 Copyright 2009 Frederik Gladhorn <gladhorn@kde.org>
3 ***************************************************************************/
4 
5 /***************************************************************************
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 ***************************************************************************/
13 
14 
15 #include "abstractbackendmode.h"
16 
17 using namespace Practice;
18 
19 AbstractBackendMode::AbstractBackendMode(const PracticeOptions& practiceOptions, Practice::AbstractFrontend* frontend, QObject *parent)
20  :QObject(parent)
21  ,m_practiceOptions(practiceOptions)
22  ,m_frontend(frontend)
23  ,m_current(0)
24 {
25 }
26 
27 bool AbstractBackendMode::setTestEntry(TestEntry* current)
28 {
29  m_current = current;
30  // this default implementation sets up the frontend with the normal word
31  m_frontend->setQuestion(m_current->entry()->translation(m_practiceOptions.languageFrom())->text());
32  m_frontend->setSolution(m_current->entry()->translation(m_practiceOptions.languageTo())->text());
33  m_frontend->setQuestionSound(m_current->entry()->translation(m_practiceOptions.languageFrom())->soundUrl());
34  m_frontend->setSolutionSound(m_current->entry()->translation(m_practiceOptions.languageTo())->soundUrl());
35  m_frontend->setQuestionPronunciation(m_current->entry()->translation(m_practiceOptions.languageFrom())->pronunciation());
36  m_frontend->setSolutionPronunciation(m_current->entry()->translation(m_practiceOptions.languageTo())->pronunciation());
37 
38  return true;
39 }
40 
41 grade_t Practice::AbstractBackendMode::currentGradeForEntry()
42 {
43  return m_current->entry()->translation(m_practiceOptions.languageTo())->grade();
44 }
45 
46 void Practice::AbstractBackendMode::updateGrades()
47 {
48  KEduVocTranslation* translation = m_current->entry()->translation(m_practiceOptions.languageTo());
49  kDebug() << "Update Grades Default Implementation: " << m_frontend->resultState() << " for " << translation->text()
50  << " grade: " << m_current->entry()->translation(m_practiceOptions.languageTo())->grade();
51 
52  translation->incPracticeCount();
53  translation->setPracticeDate( QDateTime::currentDateTime() );
54 
55  if (m_frontend->resultState() == AbstractFrontend::AnswerCorrect) {
56  if (m_current->statisticBadCount() == 0) {
57  translation->incGrade();
58  }
59  } else {
60  translation->setGrade(KV_LEV1_GRADE);
61  translation->incBadCount();
62  }
63  kDebug() << "new grade: " << m_current->entry()->translation(m_practiceOptions.languageTo())->grade();
64 }
65 
66 #include "abstractbackendmode.moc"
Practice::PracticeOptions
Definition: practiceoptions.h:22
Practice::AbstractFrontend::setQuestion
virtual void setQuestion(const QVariant &question)=0
Practice::PracticeOptions::languageFrom
int languageFrom() const
Definition: practiceoptions.h:27
Practice::AbstractBackendMode::AbstractBackendMode
AbstractBackendMode(const PracticeOptions &practiceOptions, AbstractFrontend *frontend, QObject *parent)
Definition: abstractbackendmode.cpp:19
Practice::AbstractFrontend::setSolution
virtual void setSolution(const QVariant &solution)=0
QObject
Practice::AbstractBackendMode::m_frontend
AbstractFrontend * m_frontend
Definition: abstractbackendmode.h:83
Practice::AbstractBackendMode::m_current
TestEntry * m_current
Definition: abstractbackendmode.h:84
Practice::AbstractFrontend::setQuestionPronunciation
virtual void setQuestionPronunciation(const QString &pronunciationText)=0
abstractbackendmode.h
Practice::AbstractBackendMode::updateGrades
virtual void updateGrades()
Change the grades for the current entry.
Definition: abstractbackendmode.cpp:46
Practice::PracticeOptions::languageTo
int languageTo() const
Definition: practiceoptions.h:28
Practice::AbstractBackendMode::setTestEntry
virtual bool setTestEntry(TestEntry *current)
start practicing a new word.
Definition: abstractbackendmode.cpp:27
Practice::AbstractFrontend::AnswerCorrect
Definition: abstractfrontend.h:41
Practice::AbstractFrontend::setSolutionSound
virtual void setSolutionSound(const KUrl &soundUrl)=0
Practice::AbstractFrontend
Definition: abstractfrontend.h:25
Practice::AbstractBackendMode::currentGradeForEntry
virtual grade_t currentGradeForEntry()
The grade of the current entry - this has an default implementation to return the grade for the curre...
Definition: abstractbackendmode.cpp:41
Practice::AbstractBackendMode::m_practiceOptions
PracticeOptions m_practiceOptions
Definition: abstractbackendmode.h:82
Practice::AbstractFrontend::setQuestionSound
virtual void setQuestionSound(const KUrl &soundUrl)=0
Practice::AbstractFrontend::setSolutionPronunciation
virtual void setSolutionPronunciation(const QString &pronunciationText)=0
TestEntry::entry
KEduVocExpression * entry()
Definition: testentry.cpp:134
TestEntry
Definition: testentry.h:22
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:42:05 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

parley

Skip menu "parley"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal