From kde-commits Mon Jun 30 23:07:57 2008 From: "David Capel" Date: Mon, 30 Jun 2008 23:07:57 +0000 To: kde-commits Subject: Re: branches/work/soc-parley/parley/src/practice Message-Id: <304556ab0806301607j47f911bejee3eb47c7a539cf2 () mail ! gmail ! com> X-MARC-Message: https://marc.info/?l=kde-commits&m=121486733019162 On Mon, Jun 30, 2008 at 5:04 PM, Frederik Gladhorn wrote: > On Monday 30 June 2008 13:49:51 David Capel wrote: >> SVN commit 826307 by capel: >> >> Creation of multiple choice mode. It was amazingly easy to write (it was >> also amazingly similar to Q&A mode -- go figure). >> >> Todo on MC: make an option so that it only gives you possible answers of >> the same word type? Todo in general: how should we handle the seperator >> character (used for multiple translations)? Note: This MC mode avoids the >> duplicate answer bug. > > Hey, sounds good! Can you think of any other configurable parameters for Multiple Choice that I should add while I'm doing those? > Right now it only shows a white window to me :( > Maybe I have something old lying around... seems like it can't find any theme. > Let me know if you have any idea. Maybe you can make something out of this > debug output: > parley(13548)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::readConfig: > KCoreConfigSkeleton::readConfig() > parley(13548)/libkdegames KGameTheme::load: Attempting to load .desktop at "" > parley(13548) ParleyPracticeMainWindow::setupBase: kgametheme valid: false > parley(13548)/libkdegames KGameTheme::graphics: No theme file has been loaded. > KGameTheme::load() or KGameTheme::loadDefault() must be called. > parley(13548) ParleyPracticeMainWindow::setupBase: graphics svg path "" > parley(13548)/libkdegames KGameTheme::graphics: No theme file has been loaded. > KGameTheme::load() or KGameTheme::loadDefault() must be called. > QFSFileEngine::open: No file name specified > parley(13548) KEduVocDocument::KEduVocDocument: constructor done Ah, the problem is that I didn't add the mc files to cmake's install list. I'll update that. > > I'm sorry, real life kept me busy. Can you poke me on irc? (If possible early > in the morning ;)). Next time I see you I'll be sure to do that. > How are you doing? > I've been working on getting something for my diploma thesis done, but it's > not going as good as I hoped. I've been doing pretty good; I'm enjoying the summer. Out of curiousity, what topic is your thesis on? > I think you can fix that the windows are open at the same time (practice and > editor). > Let the practice emit a signal (eg practiceFinished()) when it's done. Connect > that to a ParleyApp slot and use ParleyApp::show in that slot (instead of the > show in startPractice()). > You get the idea. I'll do that tonight. > Let's simply set up a hotnewstuff repo on edu.kde.org since it seems that > Jeremy is just to busy right now, moving that will be no problem later. > There is a tutorial on techbase if you want to read up on it. > Look at parley.knsrc to get started. There is a link to the xml file providing > the link to the real lists of files. > If you write the same for the theme files I'll put it online. > edu.kde.org is kept in svn: > http://websvn.kde.org/trunk/www/sites/edu > > The hotnewstuff for Parley is: > http://websvn.kde.org/trunk/www/sites/edu/parley/newstuff/ > And also: > http://websvn.kde.org/trunk/www/sites/edu/contrib/kvtml2/ > > (see provider.xml and providers.xml) > > So you need to do a copy and paste job basically. > I'd suggest simply bzip2-ing the .desktop and .svgz file together. They can be > extracted automatically. Jeremy set up a repository, but it seems buggy still. I'll check out this way. Good luck, David > Greetings, > Frederik > >> >> M +91 -0 input.cpp >> M +24 -1 input.h >> M +10 -9 parleypracticemainwindow.cpp >> M +2 -2 parleypracticemainwindow.h >> M +1 -1 practiceentrymanager.cpp >> M +2 -1 practiceentrymanager.h >> M +1 -1 stdbuttons.cpp >> AM themes/default_theme_mc.svgz >> A themes/mc.desktop >> >> >> --- branches/work/soc-parley/parley/src/practice/input.cpp #826306:826307 >> @@ -20,9 +20,15 @@ >> >> *************************************************************************** >>/ #include "input.h" >> #include "statistics.h" >> +#include "practiceentry.h" >> +#include "prefs.h" >> >> #include >> #include >> +#include >> +#include >> +#include >> +#include >> >> TextualInput::TextualInput(KSvgRenderer * renderer, QGraphicsView * view, >> const QString& elementId, QWidget* parent) >> >> : QLineEdit(parent), >> >> @@ -74,4 +80,89 @@ >> } >> >> >> +MultipleChoiceInput::MultipleChoiceInput(KSvgRenderer * renderer, >> QGraphicsView * view, const QString& elementId, QWidget* parent) + : >> QGroupBox(parent), >> + m_renderer(renderer) >> +{ >> + if (!renderer->elementExists(elementId)) >> + { >> + setVisible(false); >> + kDebug() << "!! Element id doesn't exist:"; >> + kDebug() << elementId << ":" << >> renderer->elementExists(elementId); + } >> + >> + QRect bounds = m_renderer->boundsOnElement(elementId).toRect(); >> + setGeometry(view->mapToScene(bounds).boundingRect().toRect()); >> +} >> + >> + >> + >> +void MultipleChoiceInput::slotSetAnswers(PracticeEntry* currentEntry, >> const QList source) +{ >> + if (source.size() < 4) >> + { >> + kDebug() << "source list too short with " << source.size() << >> "entries. Aborted."; + return; >> + } >> + >> + >> + // clean up from last time >> + delete layout(); >> + >> + foreach(QRadioButton* b, findChildren()) >> + { >> + delete b; >> + } >> + >> + >> + // start fresh and new! >> + QVBoxLayout *vbox = new QVBoxLayout; >> + QString s; >> + QList list; >> + // TODO should size of question set be configurable? >> + int timeout = 0; >> + long r; >> + >> + >> list.append(currentEntry->expression()->translation(Prefs::solutionLanguage >>())->text()); + >> + while (list.size() < 4 && timeout < 50) // prevent infinite loop >> + { >> + ++timeout; >> + r = KRandom::random() % source.size(); >> + s = >> source[r]->expression()->translation(Prefs::solutionLanguage())->text(); + >> if (!list.contains(s)) >> + list.append(s); >> + } >> + >> + KRandomSequence(0).randomize(list); >> + >> + foreach(s, list) >> + { >> + vbox->addWidget(new QRadioButton(s)); >> + } >> + >> + vbox->addStretch(1); >> + setLayout(vbox); >> + >> +} >> + >> +MultipleChoiceInput::~MultipleChoiceInput() >> +{ >> + foreach(QRadioButton* b, findChildren()) >> + { >> + delete b; >> + } >> +} >> + >> +void MultipleChoiceInput::slotEmitAnswer() >> +{ >> + foreach(QRadioButton* b, findChildren()) >> + if (b->isChecked()) >> + { >> + kDebug() << "found it"; >> + emit signalAnswer(b->text()); >> + } >> + emit signalAnswer(""); // none were selected. >> +} >> + >> #include "input.moc" >> --- branches/work/soc-parley/parley/src/practice/input.h #826306:826307 >> @@ -21,10 +21,14 @@ >> >> #include >> #include >> +#include >> >> #include >> #include >> >> +class QString; >> +class PracticeEntry; >> + >> class TextualInput : public QLineEdit >> { >> Q_OBJECT >> @@ -39,10 +43,29 @@ >> void slotEmitAnswer(); >> >> signals: >> - void signalAnswer(const QString& input); >> + void signalAnswer(const QString& answer); >> >> private: >> KSvgRenderer* m_renderer; >> }; >> >> + >> +class MultipleChoiceInput : public QGroupBox >> +{ >> + Q_OBJECT; >> + public: >> + MultipleChoiceInput(KSvgRenderer * renderer, QGraphicsView * view, >> const QString& elementId, QWidget * parent = 0); + >> ~MultipleChoiceInput(); >> + >> + public slots: >> + void slotEmitAnswer(); >> + void slotSetAnswers(PracticeEntry*, QList); >> + >> + signals: >> + void signalAnswer(const QString& answer); >> + >> + private: >> + KSvgRenderer* m_renderer; >> +}; >> + >> #endif >> --- >> branches/work/soc-parley/parley/src/practice/parleypracticemainwindow.cpp >> #826306:826307 @@ -51,7 +51,7 @@ >> ParleyPracticeMainWindow::ParleyPracticeMainWindow(QWidget *parent) >> >> : KXmlGuiWindow(parent) >> >> { >> - setupBase(); >> + setupBase("mc.desktop"); >> setupActions(); >> setupModeSpecifics(); >> >> @@ -106,7 +106,7 @@ >> emit signalCheckAnswerContinueActionsToggled(m_state); >> } >> >> -void ParleyPracticeMainWindow::setupBase() >> +void ParleyPracticeMainWindow::setupBase(const QString& desktopFileName) >> { >> m_state = CheckAnswer; >> m_mode = Prefs::testType(); >> @@ -123,7 +123,7 @@ >> QGraphicsSvgItem * backgroundsvg = new QGraphicsSvgItem(); >> m_renderer = new KSvgRenderer(); >> KGameTheme kgtheme; >> - kDebug() << "kgametheme valid:" << >> kgtheme.load("parley/themes/default.desktop"); + kDebug() << >> "kgametheme valid:" << kgtheme.load("parley/themes/" + desktopFileName); >> kDebug() << "graphics svg path" << kgtheme.graphics(); >> m_renderer->load(kgtheme.graphics()); >> backgroundsvg->setSharedRenderer(m_renderer); >> @@ -135,7 +135,7 @@ >> m_manager = new PracticeEntryManager(this); >> >> m_stats = new Statistics(m_manager, this); >> - connect(m_manager, SIGNAL(signalEntryChanged(PracticeEntry*)), >> m_stats, SLOT(slotSetEntry(PracticeEntry*))); + connect(m_manager, >> SIGNAL(signalEntryChanged(PracticeEntry*, QList)), m_stats, >> SLOT(slotSetEntry(PracticeEntry*))); connect(m_manager, >> SIGNAL(signalSetFinished()), m_stats, SLOT(slotSetFinished())); //// >> Loading the Document -- temporary //// >> KEduVocDocument * doc = new KEduVocDocument(this); >> @@ -213,6 +213,8 @@ >> { >> if (m_mode == Prefs::EnumTestType::WrittenTest) >> setupWritten(); >> + else if (m_mode == Prefs::EnumTestType::MultipleChoiceTest) >> + setupMultipleChoice(); >> else >> kDebug() << "unhandled practice mode " << m_mode << " selected."; >> } >> @@ -302,13 +304,11 @@ >> connect(m_manager, SIGNAL(signalNewSound(const KUrl&)), sprompt, >> SLOT(slotSetSound(const KUrl&))); } >> >> - TextualInput * input = new TextualInput(m_renderer, m_view, >> "practice_text_translation_background"); + MultipleChoiceInput * input = >> new MultipleChoiceInput(m_renderer, m_view, >> "practice_text_translation_background"); m_scene->addWidget(input); >> connect(input, SIGNAL(signalAnswer(const QString&)), this, >> SLOT(slotCheckAnswer(const QString&))); - connect(m_validator, >> SIGNAL(signalCorrection(float, Statistics::ErrorType, const QString&)), >> input, SLOT(slotChangeAnswerColor(float))); - connect(this, >> SIGNAL(signalShowSolution(const QString&, int)), input, >> SLOT(slotShowSolution(const QString&))); >> connect(actionCollection()->action("check answer"), SIGNAL(triggered()), >> input, SLOT(slotEmitAnswer())); - >> connect(actionCollection()->action("continue"), SIGNAL(triggered()), input, >> SLOT(slotClear())); + connect(m_manager, >> SIGNAL(signalEntryChanged(PracticeEntry*, QList)), input, >> SLOT(slotSetAnswers(PracticeEntry*, QList))); >> >> SvgBarStatistics * barstats = new SvgBarStatistics(m_renderer, "bar", >> "bar_background"); m_scene->addItem(barstats); >> @@ -316,7 +316,8 @@ >> >> StdButton * stdbutton = new StdButton(i18n("Check Answer"), >> m_renderer, m_view, "check_answer_and_continue_button"); >> m_scene->addWidget(stdbutton); >> - connect(input, SIGNAL(returnPressed()), stdbutton, >> SLOT(slotActivated())); + // TODO somehow get some form of keyboard >> input working. >> + // connect(input, SIGNAL(returnPressed()), stdbutton, >> SLOT(slotActivated())); connect(this, >> SIGNAL(signalCheckAnswerContinueActionsToggled(int)), stdbutton, >> SLOT(slotToggleText(int))); connect(stdbutton, SIGNAL(signalCheckAnswer()), >> actionCollection()->action("check answer"), SIGNAL(triggered())); >> connect(stdbutton, SIGNAL(signalContinue()), >> actionCollection()->action("continue"), SIGNAL(triggered())); --- >> branches/work/soc-parley/parley/src/practice/parleypracticemainwindow.h >> #826306:826307 @@ -50,13 +50,13 @@ >> int m_state; >> Prefs::EnumTestType::type m_mode; >> >> - void setupBase(); >> + void setupBase(const QString& desktopFileFilename); >> void setupActions(); >> void setupModeSpecifics(); >> >> // Mode specific setup functions >> void setupWritten(); >> - void setupMultipleChoice(); >> + void setupMultipleChoice(); >> public slots: >> void slotCheckAnswer(const QString& input); >> void slotShowSolution(); >> --- branches/work/soc-parley/parley/src/practice/practiceentrymanager.cpp >> #826306:826307 @@ -122,7 +122,7 @@ >> emit signalNewImage(original->imageUrl()); >> emit signalNewSound(original->soundUrl()); >> >> - emit signalEntryChanged(m_entry); >> + emit signalEntryChanged(m_entry, m_entries); >> emit signalNewEntry(); >> --m_numberEntriesRemaining; >> } >> --- branches/work/soc-parley/parley/src/practice/practiceentrymanager.h >> #826306:826307 @@ -107,7 +107,8 @@ >> void signalNewSound(const KUrl&); >> /// Emitted when the question is changed. >> /// This is used so @class Statistics can update the grades and >> related information. - void signalEntryChanged(PracticeEntry*); >> + /// It is additionally used by some input widgets. >> + void signalEntryChanged(PracticeEntry*, QList); >> /// Used so various widgets will know to reset themselves. >> void signalNewEntry(); >> /// Emitted when the set of questions is finished. >> --- branches/work/soc-parley/parley/src/practice/stdbuttons.cpp >> #826306:826307 @@ -80,4 +80,4 @@ >> { >> setText(i18n("Continue")); >> } >> -} >> \ No newline at end of file >> +} >> ** >> branches/work/soc-parley/parley/src/practice/themes/default_theme_mc.svgz >> #property svn:mime-type + application/octet-stream > > -- > Frederik Gladhorn > > Parley - The Vocabulary Trainer > http://edu.kde.org/parley >