[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-edu-devel
Subject:    Fwd: Re: [kde-edu-devel] a new feature that is a bugfix...
From:       Klas Kalass <klas.kalass () gmx ! de>
Date:       2002-12-22 22:41:50
[Download RAW message or body]

Hi Dirk,

I maintain KEduca and because I am not the original Author it came to my 
attention only 3  days ago that there is a feature which is half implemented 
since KDE 3.0 in a way I regard as a bug. The fix is not overly huge and does 
not contain new strings or such, but it is not a one-liner and I can 
understand if it was classified a new feature.

I want the patch to be in KDE 3.1. The reason I mail you is because no-one 
objected to my mail on kde-edu-devel but it was pointed out by Scott that 
this is release Dude stuff and he thinks approval of the edu team does not 
mean much.

Please read the forwarded mails for details and let us know your opinion.

Greetings,
  Klas


----------  Weitergeleitete Nachricht  ----------
(I re-inserted quote of the original mails) 

Subject: Re: [kde-edu-devel] a new feature that is a bugfix...
Date: Fri, 20 Dec 2002 10:42:23 +0100
From: Klas Kalass <klas.kalass@gmx.de>
To: kde-edu-devel@mail.kde.org

Am Freitag, 20. Dezember 2002 09:22 schrieb Robert Gogolok:
> On Thursday 19 December 2002 21:58, Klas Kalass wrote:
> > Hi all!
> >
> > This time it is me who has a problem: In keduca there is the possibility
> > to set a timeout for each question. The author of the book about Linux at
> > school apparently saw this and mentions in the script that with KEduca
> > one can constrain the time that is allowed for someone to answer.
> > The problem is: This has never been implemented! The gui strongly
> > suggests that this feature is there because one can set a timeout and
> > this timeout is also saved to the file, but in the quiz the time will
> > never be out :-(
> >
> > Now I have to choose my poison:
> >  1) Change the gui (remove the timeout option)
> >  2) keep quiet and hope nobody notices it (too late...)
> >  3) Commit a new feature to the branch
> >
> > I think that 3) is the way to go, but I would like to have someones
> > approval. I am willing to post a patch for this first, if anyone wants
> > that.
>
> I would have time to test (look at) the patch during weekend.
> Can you put it somewhere?

I attached it.

> On the other hand, what's wrong with removing it from the gui. I think it's
> the better way to go than to achieve the expectations from a book, and a
> patched version is easy to publish on apps.kde.com and put some words on
> the edu.kde.org page?

The problem is that this gui option has been there for some time and because
 I did not write the app and nobody noticed until now, I simply overlooked
 it. It was certainly there in KDE 3.0. If this "option" had not been
 released previously I would have quietly gone for 1) and asked the author to
 remove his remark.

But I think that also other people might expect this to work.

Klas

-------------------------------------------------------


["timeout.patch" (text/x-diff)]

Index: keducaview.cpp
===================================================================
RCS file: /home/kde/kdeedu/keduca/keduca/keducaview.cpp,v
retrieving revision 1.8.2.1
diff -u -3 -p -b -r1.8.2.1 keducaview.cpp
--- keducaview.cpp	19 Dec 2002 20:28:43 -0000	1.8.2.1
+++ keducaview.cpp	20 Dec 2002 00:13:19 -0000
@@ -24,7 +24,10 @@
 #include <kaction.h>
 #include <kstdaction.h>
 
-KEducaView::KEducaView(QWidget *parent, const char *name ) : QWidget(parent,name)
+#include <qtimer.h>
+
+KEducaView::KEducaView(QWidget *parent, const char *name ) : QWidget(parent,name),
+                                                             _timeoutTimer(0L)
 {
 }
 
@@ -69,6 +72,13 @@ void KEducaView::init()
 /** Button Next action */
 void KEducaView::slotButtonNext()
 {
+    // stop the timer
+    if (_timeoutTimer)
+    {
+      _timeoutTimer->stop();
+      _questionText->countdown(0);
+    }
+
     if( _questionText->isVisible() )	setResults();
     _buttonGroup->clearAnswers();
 
@@ -122,7 +132,28 @@ bool KEducaView::showRecord()
         _keducaFile->recordAnswerNext();
     };
 
+    // start the timer
+    int timeout = _keducaFile->getQuestionInt(FileRead::QF_TIME);
+    if (timeout > 0)
+    {
+      if (!_timeoutTimer)
+      {
+        _timeoutTimer = new QTimer(this);
+        connect(_timeoutTimer, SIGNAL(timeout()),
+                this, SLOT(questionTimedOut()));
+      }
+      _timeoutTimer->start(1000*timeout);
+      _questionText->countdown(timeout);
+      _questionText->countdownVisible(true);
+    }else{
+      _questionText->countdownVisible(false);
+    }
     return true;
+}
+
+void KEducaView::questionTimedOut()
+{
+  slotButtonNext();
 }
 
 /** Show results */
Index: keducaview.h
===================================================================
RCS file: /home/kde/kdeedu/keduca/keduca/keducaview.h,v
retrieving revision 1.4
diff -u -3 -p -b -r1.4 keducaview.h
--- keducaview.h	10 May 2002 14:40:21 -0000	1.4
+++ keducaview.h	20 Dec 2002 00:13:19 -0000
@@ -30,6 +30,8 @@
 #include <qsplitter.h>
 #include <qtextview.h>
 
+class QTimer;
+
 /**Main view of keduca file (questions and answers)
    This is the widget for asking questions and allowing selection of answers
    as used by KEduca TestMaster (class KEduca)
@@ -86,10 +88,12 @@ private: // Private attributes
     QString _currentResults;
     /** Show results when finish? */
     bool _showResultFinish;
+    QTimer *_timeoutTimer;
 
 private slots: // Private slots
     /** Button Next action */
     void slotButtonNext();
+    void questionTimedOut();
 };
 
 #endif
Index: kquestion.cpp
===================================================================
RCS file: /home/kde/kdeedu/keduca/keduca/kquestion.cpp,v
retrieving revision 1.3
diff -u -3 -p -b -r1.3 kquestion.cpp
--- kquestion.cpp	26 Apr 2002 18:37:33 -0000	1.3
+++ kquestion.cpp	20 Dec 2002 00:13:19 -0000
@@ -22,8 +22,11 @@
 #include <qlayout.h>
 #include <qcolor.h>
 #include <qpixmap.h>
+#include <qtimer.h>
+#include <qprogressbar.h>
 
-KQuestion::KQuestion(QWidget *parent, const char *name ) : QFrame(parent,name)
+KQuestion::KQuestion(QWidget *parent, const char *name ) : QFrame(parent,name),
+                                                           _countdownTimer(0L)
 {
     initGUI();
 }
@@ -43,10 +46,19 @@ void KQuestion::initGUI()
     form1Layout->setSpacing( 0 );
     form1Layout->setMargin( 5 );
 
+    QVBoxLayout *picLayout=new QVBoxLayout(form1Layout);
+    picLayout->setSpacing(0);
+    picLayout->setMargin(0);
+
     _picture = new QLabel( this, "PixmapLabel1" );
     _picture->setScaledContents( FALSE );
     _picture->setPalette( QPalette( QColor(255, 255, 255) ) );
-    form1Layout->addWidget( _picture );
+    picLayout->addWidget( _picture );
+
+    _countdownWidget = new QProgressBar(this);
+    _countdownWidget->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
+                                                QSizePolicy::Preferred));
+    picLayout->addWidget(_countdownWidget);
 
     _view = new QTextView( this, "TextView1" );
     _view->setFrameShape( QTextView::NoFrame );
@@ -66,4 +78,43 @@ void KQuestion::setText( const QString &
 void KQuestion::setPixmap( const QString &pixmap)
 {
     _picture->setPixmap( QPixmap(pixmap) );
+}
+
+void KQuestion::countdown(int starttime)
+{
+  _totalCount = starttime;
+  _currentCount = starttime;
+  if (starttime > 0)
+  {
+    if (!_countdownTimer)
+    {
+      _countdownTimer = new QTimer(this);
+      connect(_countdownTimer, SIGNAL(timeout()),
+              this, SLOT(countDownOne()));
+    }
+    _countdownTimer->start(1000);
+    // make one step less than time passes by in seconds
+    // so that the user will see when time is up
+    _countdownWidget->setTotalSteps(starttime-1);
+  }else{
+    _countdownTimer->stop();
+    _countdownWidget->reset();
+  }
+}
+
+void KQuestion::countDownOne()
+{
+  _currentCount--;
+  _countdownWidget->setProgress(_totalCount - _currentCount);
+
+  if (_currentCount == 0)
+    _countdownTimer->stop();
+}
+
+void KQuestion::countdownVisible(bool visible)
+{
+  if (visible)
+    _countdownWidget->show();
+  else
+    _countdownWidget->hide();
 }
Index: kquestion.h
===================================================================
RCS file: /home/kde/kdeedu/keduca/keduca/kquestion.h,v
retrieving revision 1.3
diff -u -3 -p -b -r1.3 kquestion.h
--- kquestion.h	9 May 2002 15:25:21 -0000	1.3
+++ kquestion.h	20 Dec 2002 00:13:19 -0000
@@ -24,6 +24,9 @@
 #include <qtextview.h>
 #include <qlabel.h>
 
+class QTimer;
+class QProgressBar;
+
 /**Question view
  * The Widget that is used to display the Question.
  *@author Javier Campos Morales
@@ -40,6 +43,18 @@ public:
     /** Set text */
     void setText( const QString &text);
 
+    /** show a countdown, starting at "starttime" and counting
+        down to 0, each second one count.
+
+        0 disables the countdown.
+     */
+    void countdown(int starttime);
+
+    void countdownVisible(bool visible);
+
+private slots:
+  void countDownOne();
+
 private: // Private methods
     /** Init graphical interface */
     void initGUI();
@@ -49,6 +64,10 @@ private: // Private attributes
     QTextView *_view;
     /** Main Picture */
     QLabel *_picture;
+    QTimer *_countdownTimer;
+    QProgressBar *_countdownWidget;
+    int _currentCount;
+    int _totalCount;
 };
 
 #endif

_______________________________________________
kde-edu-devel mailing list
kde-edu-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-edu-devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic