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

List:       kde-commits
Subject:    kdeedu/kwordquiz/src
From:       Peter Hedlund <peter () peterandlinda ! com>
Date:       2004-11-13 23:29:42
Message-ID: 20041113232942.D61CA16DC6 () office ! kde ! org
[Download RAW message or body]

CVS commit by hedlund: 

Highlight (make bold) the part of a typed answer that is incorrect.
BUG:82354


  M +29 -2     qaview.cpp   1.10


--- kdeedu/kwordquiz/src/qaview.cpp  #1.9:1.10
@@ -28,4 +28,30 @@
 #include "kwordquiz.h"
 
+QString highlightError(const QString & c, const QString & e)
+{
+  QString result = "<qt>";
+  int i = 0;
+  while (c[i] == e[i])
+    result.append(e[i++]);
+  result.append("<b>");
+  QString result2 = "</qt>";
+  int j = c.length() - 1;
+  int k = e.length() - 1;
+  while (c[j] == e[k])
+  {
+    result2.prepend(e[k]);
+    j--;
+    k--;
+  }
+  result2.prepend("</b>");
+
+  for (int m = i; m <= k; m++)
+    result.append(e[m]);
+
+  result.append(result2);
+  return result;
+}
+
+
 QAView::QAView(QWidget *parent, const char *name, WFlags f):QAViewBase(parent, name, \
f)  {
@@ -107,4 +133,5 @@ void QAView::slotCheck()
 
       picYourAnswer->setPixmap(KGlobal::iconLoader()->loadIcon("check", \
KIcon::Panel)); +      lblYourAnswer->setText(m_quiz->yourAnswer(m_question, \
txtAnswer->text()));  lblCorrectHeader->clear();
       picCorrectAnswer->clear();
@@ -119,5 +146,5 @@ void QAView::slotCheck()
 
       picYourAnswer->setPixmap(KGlobal::iconLoader()->loadIcon("error", \
                KIcon::Panel));
-
+      lblYourAnswer->setText(highlightError(m_quiz->answer(m_question), \
m_quiz->yourAnswer(m_question, txtAnswer->text())));  \
lblCorrect->setText(m_quiz->answer(m_question));  \
//lblCorrect->setFont(m_quiz->fontAnswer(m_question)); @@ -135,5 +162,5 @@ void \
QAView::slotCheck()  
     lblYourAnswerHeader->setText(i18n("Your Answer"));
-    lblYourAnswer->setText(m_quiz->yourAnswer(m_question, txtAnswer->text()));
+    
     //lblYourAnswer->setFont(m_quiz->fontAnswer(m_question));
 


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

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