<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>138132</bug_id>
          
          <creation_ts>2006-11-30 08:39:36 +0000</creation_ts>
          <short_desc>incorrect number of questions</short_desc>
          <delta_ts>2006-11-30 23:05:46 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>kwordquiz</product>
          <component>general</component>
          <version>unspecified</version>
          <rep_platform>unspecified</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Richard van Schaik">richard.dev</reporter>
          <assigned_to name="Peter Hedlund">peter</assigned_to>
          
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>490601</commentid>
    <comment_count>0</comment_count>
    <who name="Richard van Schaik">richard.dev</who>
    <bug_when>2006-11-30 08:39:37 +0000</bug_when>
    <thetext>Version:           0.8.1 (using KDE 3.5.5, Kubuntu (edgy) 4:3.5.5-0ubuntu3)
Compiler:          Target: i486-linux-gnu
OS:                Linux (i686) release 2.6.17-10-386

Reproduce:
- Open two files simultaneously
- Do a question and answer session with the first file (40 questions)
- Then with the second (13 questions)
- Restart the first, and you&apos;ll be asked only to answer 13 questions instead of 40

I hope this is enough information.
Thank you,

Richard van Schaik</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>490811</commentid>
    <comment_count>1</comment_count>
    <who name="Peter Hedlund">peter</who>
    <bug_when>2006-11-30 23:03:49 +0000</bug_when>
    <thetext>SVN commit 609467 by hedlund:

Make sure a quiz is correctly restarted when several vocabularies are open.

BUG:138132

 M  +67 -61    wqquiz.cpp  
 M  +6 -4      wqquiz.h  


--- branches/KDE/3.5/kdeedu/kwordquiz/src/wqquiz.cpp #609466:609467
@@ -23,52 +23,44 @@
 #include &quot;wqquiz.h&quot;
 #include &quot;prefs.h&quot;
 
-QPtrList&lt;WQListItem&gt; *WQQuiz::m_list = 0L;
-QPtrList&lt;WQListItem&gt; *WQQuiz::m_errorList = 0L;
-QPtrList&lt;WQListItem&gt; *WQQuiz::m_quizList = 0L;
-
 WQQuiz::WQQuiz(KWordQuizView * parent, const char *name) : QObject(parent, name)
 {
   m_table = parent;
 
-  m_list = new QPtrList&lt;WQListItem&gt;();
-  m_errorList = new QPtrList&lt;WQListItem&gt;();
-  m_quizList = new QPtrList&lt;WQListItem&gt;();
+  m_list.clear();
+  m_errorList.clear();
+  m_quizList.clear();
 }
 
-WQQuiz::~WQQuiz()
-{
-}
-
 void WQQuiz::activateErrorList()
 {
-  m_list-&gt;clear();
+  m_list.clear();
 
-  WQListItem *l;
-  for (l = m_errorList-&gt;first(); l; l = m_errorList-&gt;next())
-  {
-    m_list-&gt;append(l);
-  }
+  WQListItem l;
 
-  m_errorList-&gt;clear();
-  m_questionCount = m_list-&gt;count();
+  QuizList::iterator it;
+  for ( it = m_errorList.begin(); it != m_errorList.end(); ++it )
+    m_list.append(*it);
 
+  m_errorList.clear();
+  m_questionCount = m_list.count();
+
 }
 
 void WQQuiz::activateBaseList()
 {
-  m_list-&gt;clear();
+  m_list.clear();
 
   if (m_quizMode &gt; 2)
   {
     listRandom();
   };
 
-  WQListItem *l;
-  for (l = m_quizList-&gt;first(); l; l = m_quizList-&gt;next())
-    m_list-&gt;append(l);
+  QuizList::iterator it;
+  for (it = m_quizList.begin(); it != m_quizList.end(); ++it)
+    m_list.append(*it);
 
-  m_questionCount = m_list-&gt;count();
+  m_questionCount = m_list.count();
 
 }
 
@@ -116,7 +108,7 @@
       li-&gt;setThreeOp(b);
 
     }
-    m_quizList-&gt;append(li);
+    m_quizList.append(*li);
 
   }
 
@@ -177,13 +169,13 @@
     //
     break;  
   case qtFlash:
-    result = (m_quizList -&gt; count() &gt; 0);
+    result = (m_quizList.count() &gt; 0);
     break;
   case qtQA:
-    result = (m_quizList -&gt; count() &gt; 0);
+    result = (m_quizList.count() &gt; 0);
     break;
   case qtMultiple:
-    result = (m_quizList -&gt; count() &gt; 2);
+    result = (m_quizList.count() &gt; 2);
     break;
   }
 
@@ -206,16 +198,30 @@
 
 void WQQuiz::listRandom()
 {
-  KRandomSequence *rs = new KRandomSequence(0);
-  rs-&gt;randomize(m_quizList);
+  QPtrList&lt;void&gt; list;
+
+  for(int i = 0; i &lt; m_quizList.count(); i++)
+    list.append((void*) i);
+
+  KRandomSequence seq;
+  seq.randomize(&amp;list);
+
+  QuizList items;
+  for(int i = 0; i &lt; m_quizList.count(); i++)
+    items.append(m_quizList[(long) list.take()]);
+
+  m_quizList.clear();
+
+  for(int i = 0; i &lt; items.count(); i++)
+    m_quizList.append(items[i]);
 }
 
 bool WQQuiz::checkAnswer(int i, const QString &amp; a)
 {
   bool result = false;
-  WQListItem *li = m_list-&gt;at(i);
+  WQListItem li = m_list[i];
   int j;
-  if (li-&gt;question() == 0)
+  if (li.question() == 0)
   {
     j = 1;
   }
@@ -224,7 +230,7 @@
     j= 0;
   }
   QString ans = a;
-  QString tTemp = m_table -&gt; text(li-&gt;oneOp(), j);
+  QString tTemp = m_table -&gt; text(li.oneOp(), j);
   tTemp = tTemp.stripWhiteSpace();
   ans = ans.stripWhiteSpace();
 
@@ -280,7 +286,7 @@
 
   if (!result)
   {
-    m_errorList -&gt; append(li);
+    m_errorList.append(li);
   }
 
   return result;
@@ -290,14 +296,14 @@
 {
   QString *s;
   QStringList Result;
-  WQListItem *li = m_list-&gt;at(i);
+  WQListItem li = m_list[i];
 
   typedef QPtrList&lt;QString&gt; LS;
   LS *ls;
   ls = new QPtrList&lt;QString&gt;();
 
   int j;
-  if (li-&gt;question() == 0)
+  if (li.question() == 0)
   {
     j = 1;
   }
@@ -306,7 +312,7 @@
     j= 0;
   }
 
-  s= new QString(m_table-&gt;text(li-&gt;oneOp(), j)); 
+  s= new QString(m_table-&gt;text(li.oneOp(), j)); 
   if (Prefs::enableBlanks())
   {
     s-&gt;remove(&quot;[&quot;);
@@ -314,7 +320,7 @@
   }
   ls-&gt;append(s);
 
-  s = new QString(m_table-&gt;text(li-&gt;twoOp(), j));
+  s = new QString(m_table-&gt;text(li.twoOp(), j));
   if (Prefs::enableBlanks())
   {
     s-&gt;remove(&quot;[&quot;);
@@ -322,7 +328,7 @@
   }
   ls-&gt;append(s);
 
-  s = new QString(m_table-&gt;text(li-&gt;threeOp(), j));
+  s = new QString(m_table-&gt;text(li.threeOp(), j));
   if (Prefs::enableBlanks())
   {
     s-&gt;remove(&quot;[&quot;);
@@ -330,8 +336,8 @@
   }
   ls-&gt;append(s);
 
-  KRandomSequence *rs = new KRandomSequence(0);
-  rs-&gt;randomize(ls);
+  KRandomSequence rs;
+  rs.randomize(ls);
 
   while (ls-&gt;count())
   {
@@ -344,10 +350,10 @@
 QString WQQuiz::quizIcon(int i, QuizIcon ico)
 {
   QString s;
-  WQListItem *li = m_list-&gt;at(i);
+  WQListItem li = m_list[i];
   if (ico == qiLeftCol)
   {
-    if (li-&gt;question() == 0)
+    if (li.question() == 0)
       s = &quot;question&quot;;
     else
       s = &quot;answer&quot;;
@@ -355,7 +361,7 @@
 
   if (ico == qiRightCol)
   {
-    if (li-&gt;question() == 0)
+    if (li.question() == 0)
       s = &quot;answer&quot;;
     else
       s = &quot;question&quot;;
@@ -424,8 +430,8 @@
 
 QString WQQuiz::question(int i)
 {
-  WQListItem *li = m_list-&gt;at(i);
-  QString s = m_table-&gt;text(li-&gt;oneOp(), li-&gt;question());
+  WQListItem li = m_list[i];
+  QString s = m_table-&gt;text(li.oneOp(), li.question());
   if (Prefs::enableBlanks())
   {
     s.remove(&quot;[&quot;);
@@ -433,12 +439,12 @@
   }
   if (m_quizType != qtFlash &amp;&amp; i &gt; 0)
   {
-    WQListItem *li2 = m_list-&gt;at(i - 1);
-    emit checkingAnswer(li2-&gt;oneOp());
+    WQListItem li2 = m_list[i - 1];
+    emit checkingAnswer(li2.oneOp());
   }
   else
-    emit checkingAnswer(li-&gt;oneOp());  
-  
+    emit checkingAnswer(li.oneOp());
+
   return s;
 }
 
@@ -452,9 +458,9 @@
 
   if (m_quizType == qtQA &amp;&amp; Prefs::enableBlanks())
   {
-    WQListItem *li = m_list-&gt;at(i);
+    WQListItem li = m_list[i];
     int j;
-    if (li-&gt;question() == 0)
+    if (li.question() == 0)
     {
       j = 1;
     }
@@ -462,7 +468,7 @@
     {
       j= 0;
     }
-    tTemp = m_table-&gt;text(li-&gt;oneOp(), j);
+    tTemp = m_table-&gt;text(li.oneOp(), j);
     r = tTemp;
     QRegExp rx;
     rx.setMinimal(true);
@@ -494,9 +500,9 @@
 QString WQQuiz::answer(int i)
 {
   QString s;
-  WQListItem *li = m_list-&gt;at(i);
+  WQListItem li = m_list[i];
   int j;
-  if (li-&gt;question() == 0)
+  if (li.question() == 0)
   {
     j = 1;
   }
@@ -508,7 +514,7 @@
 
   if (m_quizType == qtQA)
   {
-    s = m_table-&gt;text(li-&gt;oneOp(), j);
+    s = m_table-&gt;text(li.oneOp(), j);
     if (Prefs::enableBlanks())
     {
       s.replace(&quot;[&quot;, &quot;&lt;u&gt;&quot;);
@@ -519,7 +525,7 @@
   }
   else
   {
-    s = m_table-&gt;text(li-&gt;oneOp(), j);
+    s = m_table-&gt;text(li.oneOp(), j);
     if (Prefs::enableBlanks())
     {
       s.remove(&quot;[&quot;);
@@ -531,17 +537,17 @@
 
 QString WQQuiz::langQuestion(int i)
 {
-  WQListItem *li = m_list-&gt;at(i);
-  return m_table-&gt;horizontalHeader()-&gt;label(li-&gt;question());
+  WQListItem li = m_list[i];
+  return m_table-&gt;horizontalHeader()-&gt;label(li.question());
 }
 
 QString WQQuiz::langAnswer(int i)
 {
 
-  WQListItem *li = m_list-&gt;at(i);
+  WQListItem li = m_list[i];
 
   int j;
-  if (li-&gt;question() == 0)
+  if (li.question() == 0)
   {
     j = 1;
   }
--- branches/KDE/3.5/kdeedu/kwordquiz/src/wqquiz.h #609466:609467
@@ -28,6 +28,8 @@
 @author Peter Hedlund
 */
 
+typedef QValueList&lt;WQListItem&gt; QuizList;
+
 class WQQuiz : public QObject
 {
   Q_OBJECT
@@ -36,7 +38,7 @@
     enum QuizIcon {qiLeftCol, qiRightCol, qiQuestion, qiCorrect, qiError};
 
     WQQuiz(KWordQuizView * parent, const char * name=0);
-    ~WQQuiz();
+
     void activateErrorList();
     void activateBaseList();
 
@@ -70,9 +72,9 @@
     KWordQuizView *m_table;
     int m_quizMode;
     int m_questionCount;
-    static QPtrList&lt;WQListItem&gt; *m_list;
-    static QPtrList&lt;WQListItem&gt; *m_errorList;
-    static QPtrList&lt;WQListItem&gt; *m_quizList;
+    QuizList m_list;
+    QuizList m_errorList;
+    QuizList m_quizList;
 
     QuizType m_quizType;
     QString m_correctBlank;
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>490813</commentid>
    <comment_count>2</comment_count>
    <who name="Peter Hedlund">peter</who>
    <bug_when>2006-11-30 23:05:46 +0000</bug_when>
    <thetext>*** Bug 138160 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>