diff options
author | Aneesh Dogra <lionaneesh@gmail.com> | 2012-12-22 16:58:18 (GMT) |
---|---|---|
committer | Aneesh Dogra <lionaneesh@gmail.com> | 2012-12-22 16:59:08 (GMT) |
commit | 4131c75d3982224e6313b55782f628068b8413f5 (patch) | |
tree | dd1794df0b0ffefbc2ea3ae052ec1eae7a062ac6 | |
parent | 34f220f70b4e7be0ade04fece12f64b1d34d72fc (diff) |
Decide the difficulty level on the basis of no of questions answered correctly.
Also fix reset_results.
-rw-r--r-- | ConstellationsFlashCards.py | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/ConstellationsFlashCards.py b/ConstellationsFlashCards.py index 847d9a8..6c1a8a9 100644 --- a/ConstellationsFlashCards.py +++ b/ConstellationsFlashCards.py @@ -267,6 +267,8 @@ class ChartDisplay(Gtk.DrawingArea): labelr4.set_label(str(correct_second_count) + _(" correct on second try.")) elif data == 'reset_results': + score = 0 + seen = 0 quiz_count = 0 correct_first_count = 0 correct_second_count = 0 @@ -602,43 +604,47 @@ class ChartDisplay(Gtk.DrawingArea): def fill_names_combobox(self): + global correct_first_count cbq1.remove_all() -# Create a list of five names, initialized to "" - names = ["", "", "", "", ""] - numbers = [-1, -1, -1, -1, -1] - for i in range(5): - try: - cbq1.remove_text(4 - i) - except: - pass +# Decide the NUMBER_OF_CHOICES + if correct_first_count > 0: + NUMBER_OF_CHOICES = int(10 * float(correct_first_count / \ + len(constellations))) + if NUMBER_OF_CHOICES < 4: + NUMBER_OF_CHOICES = 4 + + print NUMBER_OF_CHOICES, "\n\n\n" + +# Create a list of NUMBER_OF_CHOICES names, initialized to "" + names = [""] * NUMBER_OF_CHOICES + numbers = [-1] * NUMBER_OF_CHOICES # Now set one of these names to self.cname. - k = random.randrange(5) + k = random.randrange(NUMBER_OF_CHOICES) names[k] = self.cname numbers[k] = self.cnumber -# Choose four additional constellation names (by random choice). Add these names to the -# list, being sure not to overwrite any non-blank value or use the same name twice. +# Choose len(names) - 1 additional constellation names (by random choice). +# Add these names to the list, being sure not to overwrite any non-blank value +# or use the same name twice. i = 0 - while (i < 4): + for i in range(NUMBER_OF_CHOICES): r = random.randrange(len(constellations)) if not (r in numbers): id = constellations[r] cname = name_from_abbrev[id] - for j in range(5): + for j in range(NUMBER_OF_CHOICES): if (names[j] == ""): names[j] = cname numbers[j] = r i = i + 1 break - -# Fill cbq1 with the five strings. - for i in range(5): + for i in range(NUMBER_OF_CHOICES): cbq1.append_text(names[i]) def cleararea(self): |