[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/plasma/applets/kuickquiz
From: Ben Cooksley <sourtooth () gmail ! com>
Date: 2008-12-08 23:00:42
Message-ID: 1228777242.077598.29004.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 894612 by bcooksley:
Fix bug where multiple results from same user would always report highest score of \
that user
M +13 -10 kuickquiz.cpp
--- trunk/playground/base/plasma/applets/kuickquiz/kuickquiz.cpp #894611:894612
@@ -177,7 +177,7 @@
{ questionsAndAnswers[saveQuestions][itemSaved]=uiMain.TwQuestionList->item(saveQuestions,itemSaved)->text(); \
}
questionAnswers[saveQuestions] = \
uiMain.TwQuestionList->item(saveQuestions,5)->text().toInt(); }
- splash->header.setText( "Quiz for " + quizName );
+ refreshSplash();
}
void KuickQuiz::configClearScores()
@@ -187,8 +187,9 @@
/// Splash screen functions
void KuickQuiz::refreshSplash()
-{ QStringList topscorenames;
- QList<int> topscorevalues;
+{ QStringList topScoreNames;
+ QList<int> topScoreValues;
+ QStringList usedNames;
int questionDown;
int alreadyUsed;
QString resultList[5];
@@ -201,14 +202,16 @@
if( results.count() == 0 )
{ splash->results.setText("No scores have been entered yet! Do the quiz to receive \
some results"); } else
- { for( questionDown = 0; topscorenames.count() <= 5 && topscorenames.count() < \
results.count() ; questionDown = questionDown + 1 )
- { topscorenames = topscorenames + results.values(totalQuestions - questionDown); \
}
- for( int resultNumber = 0; resultNumber < 5 && resultNumber < \
topscorenames.count() ; resultNumber = resultNumber + 1 )
- { topscorevalues = results.keys( topscorenames[resultNumber] );
- qSort(topscorevalues.begin(), topscorevalues.end());
- sprintf(userScore, "%d", topscorevalues.last());
+ { for( questionDown = 0; topScoreNames.count() <= 5 && topScoreNames.count() < \
results.count() ; questionDown = questionDown + 1 ) + { topScoreNames = \
topScoreNames + results.values(totalQuestions - questionDown); } + for( int \
resultNumber = 0; resultNumber < 5 && resultNumber < topScoreNames.count() ; \
resultNumber = resultNumber + 1 ) + { topScoreValues = results.keys( \
topScoreNames[resultNumber] ); + alreadyUsed = usedNames.count( \
topScoreNames[resultNumber] ); + qSort(topScoreValues.begin(), \
topScoreValues.end()); + sprintf(userScore, "%d", \
topScoreValues.at(topScoreValues.count() - alreadyUsed - 1)); sprintf(userPosition, \
"%d", resultNumber + 1 );
- resultList[resultNumber]="Position " + QString(userPosition) + ": " + \
QString(userScore) + " points scored by '" + topscorenames[resultNumber] + "'\n"; + \
resultList[resultNumber]="Position " + QString(userPosition) + ": " + \
QString(userScore) + " points scored by '" + topScoreNames[resultNumber] + "'\n"; + \
usedNames.append( topScoreNames[resultNumber] ); }
splash->results.setText( resultList[0] + resultList[1] + resultList[2] + \
resultList[3] + resultList[4] ); }
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic