diff options
author | Alex <acj3840@rit.edu> | 2010-08-03 18:27:54 (GMT) |
---|---|---|
committer | Alex <acj3840@rit.edu> | 2010-08-03 18:27:54 (GMT) |
commit | 305e74d1979fd8171493834730685ac4d5abb9a4 (patch) | |
tree | 9c580880b4063f16b72211f8f1e21e4d9ff40fca | |
parent | f48f260556b794fd4ee969d397606eb3818facff (diff) |
now sorts by column when you click on them
see NEWS for more
-rw-r--r-- | NEWS | 6 | ||||
-rw-r--r-- | popquiz.py | 31 |
2 files changed, 34 insertions, 3 deletions
@@ -1,3 +1,9 @@ +8-3-2010 +added sortability for the teachers stat screen +just click on the column that you want to sort by +currently details doesnt do anything but maybe i'll figure out what else is going to be useful and add stuff to it +also, there may be some additional networking code added, i dont remember + 7-26-2010 added some code that i think is needed for networking. using hellomesh as well as ActivitiesGuideSugar to help guide this reworked the code so teacher and student are no longer classes, they are methods that call appropriate _teacher methods or _student methods @@ -14,6 +14,7 @@ from sugar.presence.tubeconn import TubeConnection from sugar.activity.widgets import * from dbus.gobject_service import ExportedGObject from dbus.service import method, signal +from operator import itemgetter import gtk import threading @@ -40,7 +41,7 @@ WRONG1ANSWER = "wrong1answer" WRONG2ANSWER = "wrong2answer" WRONG3ANSWER = "wrong3answer" TIMER = 10 -STUDENTS = [ [ "Student1" ], [ "Student2" ], [ "Student3" ], [ "Student4" ], [ "Student5" ] ] +STUDENTS = [ [ "Student1", "15.2", "Yes" ], [ "Student2", "17.3", "Yes" ], [ "Student3", "5.6", "No" ], [ "Student4", "4.5", "Yes" ], [ "Student5", "22.1", "No" ] ] SELECTEDSTUDENT = "Student0" class PopQuiz(activity.Activity): @@ -271,7 +272,7 @@ class PopQuiz(activity.Activity): vboxholdsall = gtk.VBox() vboxholdsall.show() - title = [ "Student Names" ] + title = [ "Student Names", "Time To Answer Question", "Correct" ] #get list of students and stats ###### @@ -282,8 +283,10 @@ class PopQuiz(activity.Activity): scrollwindow.show() #set up clist - clist = gtk.CList(1, title) + clist = gtk.CList(3, title) clist.connect("select_row", self._teacher_student_selected) + clist.column_titles_active() + clist.connect("click_column", self._sort_by_selection) clist.show() #add students to clist @@ -308,6 +311,28 @@ class PopQuiz(activity.Activity): vboxholdsall.pack_start(hboxbuttons, False, True, 10) self.vboxholdsall = vboxholdsall self._update_canvas(self.vboxholdsall) + + def _sort_by_selection(self, clist, column): + global STUDENTS + logging.debug(str(column)) + if column == 0: + clist.clear() + STUDENTS.sort(key=itemgetter(0)) + for index in range(len(STUDENTS)): + clist.append(STUDENTS[index]) + elif column == 1: + clist.clear() + for i in range(len(STUDENTS)): + STUDENTS[i][1] = float(STUDENTS[i][1]) + STUDENTS.sort(key=itemgetter(1)) + for index in range(len(STUDENTS)): + STUDENTS[index][1] = str(STUDENTS[index][1]) + clist.append(STUDENTS[index]) + elif column == 2: + clist.clear() + STUDENTS.sort(key=itemgetter(2), reverse=True) + for index in range(len(STUDENTS)): + clist.append(STUDENTS[index]) def _teacher_student_selected(self, clist, row, column, event, data=None): global STUDENTS |