forked from loochek/schoolproject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditGroupStats.py
More file actions
73 lines (62 loc) · 1.86 KB
/
editGroupStats.py
File metadata and controls
73 lines (62 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from api import *
import cgi
import cgitb
cgitb.enable()
print("Content-type: text/html\n\n")
# Edit group stats
# GET arguments:
# gid - group id
# eid - exercise id
# week - number of week
template = """
<!DOCTYPE HTML>
<html>
<head>
<title>Редактирование</title>
</head>
<body>
<h1>%s</h1>
<form action="saveStats.py">
<input type="hidden" name="gid" value="">
<input type="hidden" name="eid" value="">
<input type="hidden" name="week" value="">
<script>
function $_GET( name ){
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
}
document.getElementsByName('eid')[0].value = $_GET('eid');
document.getElementsByName('gid')[0].value = $_GET('gid');
document.getElementsByName('week')[0].value = $_GET('week');
</script>
<table border="1" width="25%%" cellpadding="5">
<tr>
<th>Испытуемый</th>
<th>Результат</th>
</tr>
%s
</table>
<input type="submit" value="Обновить результаты">
</form>
</body>
</html>
"""
rowTemplate = '<tr><td>%s</td><td><input maxlength="25" size="8" name="%d" value="%s"></td></tr>'
def generateEditPage(eid, gid, week):
gInfo = getGroupInfo(gid)
table = ""
for i in range(len(gInfo.members)):
stat = getUserStats(gInfo.members[i], eid)[week]
table += rowTemplate % (getUserName(gInfo.members[i]), i, stat if stat != None else '')
title = gInfo.name + ' ' + getExerciseInfo(eid).name + ' Неделя ' + str(week + 1)
return template % (title, table)
form = cgi.FieldStorage()
print(generateEditPage(int(form.getvalue("eid")), int(form.getvalue("gid")), int(form.getvalue("week"))))