diff --git a/database.py b/database.py
index 1d59c52..666c936 100644
--- a/database.py
+++ b/database.py
@@ -29,6 +29,21 @@ class Database(object):
ORDER BY grade DESC, finish_time DESC;'''
return c.execute(cmd, [test_id]).fetchall()
+ # return list of students and their results for a given test
+ def test_grades2(self, test_id):
+ with sqlite3.connect(self.db) as c:
+ # with all tests done by each student:
+ # cmd = 'SELECT student_id,name,grade FROM students INNER JOIN tests ON students.number=tests.student_id WHERE test_id==? ORDER BY grade DESC;'
+
+ # only the best result for each student
+ cmd = '''
+ SELECT student_id, name, grade, start_time, finish_time
+ FROM students INNER JOIN tests
+ ON students.number=tests.student_id
+ WHERE test_id==?
+ ORDER BY finish_time ASC;'''
+ return c.execute(cmd, [test_id]).fetchall()
+
# get list of students in the database
def get_students(self):
with sqlite3.connect(self.db) as c:
diff --git a/serve.py b/serve.py
index cbad33d..070273f 100755
--- a/serve.py
+++ b/serve.py
@@ -17,7 +17,6 @@ except ImportError:
try:
from mako.lookup import TemplateLookup
- import djks
except ImportError:
print('The package "mako" is missing. See README.md for instructions.')
sys.exit(1)
@@ -78,9 +77,11 @@ class Root(object):
for num in reset_pw:
cherrypy.log.error('Password updated for student %s.' % str(num), 'APPLICATION')
+ grades = self.database.test_grades2(self.testconf['ref'])
students = self.database.get_students()
+
template = self.templates.get_template('/students.html')
- return template.render(students=students, tags=self.tags)
+ return template.render(students=students, tags=self.tags, grades=grades)
# --- RESULTS ------------------------------------------------------------
@cherrypy.expose
diff --git a/templates/students.html b/templates/students.html
index 7a66a8f..2a6debe 100644
--- a/templates/students.html
+++ b/templates/students.html
@@ -33,46 +33,102 @@
- ${len(tags['online'])} online ${len(tags['finished'])} finished
+ ${len(tags['finished'])} Terminado(s)
-
-
-
-
- Tags |
- Número |
- Nome |
- Password |
-
-
-
- % for r in students:
+
+
+
-
- % if r[0] in tags['online']:
- online
- % endif
+ | Número |
+ Nome |
+ Login |
+ Logout |
+ Nota |
+
+
+
+ % for r in grades:
+
% if r[0] in tags['finished']:
- finished
+ ${r[0]} |
+ ${r[1]} |
+ ${r[3][:19]} |
+ ${r[4][:19]} |
+ ${r[2]} |
+
% endif
-
- ${r[0]} |
- ${r[1]} |
-
-
- |
+
+ % endfor
+
+
+
+
+
+
+
+ ${len(tags['online'])} Activo(s)
+
+
+
+
+
+ Número |
+ Nome |
+
- % endfor
-
-
-
+
+
+ % for r in students:
+
+ % if r[0] in tags['online']:
+ ${r[0]} |
+ ${r[1]} |
+ % endif
+
+ % endfor
+
+
+
+
+
+
+
+
+ ${len(students)-len(tags['online'])} Inactivo(s)
+
+
+
+
+
+
+ Número |
+ Nome |
+ Password |
+
+
+
+ % for r in students:
+
+ % if r[0] not in tags['online']:
+ ${r[0]} |
+ ${r[1]} |
+
+
+ |
+ % endif
+
+ % endfor
+
+
+
+