Example #1
0
 def createLaTeXFile( self ):
     courseName = Config.conf['CourseName']
     lecturer = self.getString( 'lecturer' ).strip().replace( ' ', '~' )
     semester = self.getString( 'semester' ).strip()
     date = self.getString( 'date' ).strip()
     if date == '':
         date = '\\today'
     # count number of registrations
     count = 0
     l = Utils.SortNumerAlpha( Data.people.keys() )
     for k in l:
         p = Data.people[k]
         if self.examnr < len( p.exams ) and \
            p.exams[self.examnr] != None and \
            p.exams[self.examnr].registration:
             count += 1
     # get people for which a Deckblatt should be created
     s = ''
     l = Utils.SortNumerAlpha( Data.people.keys() )
     for k in l:
         p = Data.people[k]
         if self.examnr < len( p.exams ) and \
            p.exams[self.examnr] != None and \
            p.exams[self.examnr].registration:
             for i in range( self.copies ):
                 s += ( r'\deckblatt{%s}{%s}{%s}{%s}{%s}{%s}' %
                     ( lecturer, semester, courseName, date,
                         p.lname + ', ' + p.fname, k ) )
                 s += '\n'
     latexInput = LatexHead + s + LatexFoot
     return latexInput
Example #2
0
 def headAndBody(self):
     courseName = Config.conf['CourseName']
     lecturer = self.getString('lecturer').strip().replace(' ', '~')
     semester = self.getString('semester').strip()
     benotet = (self.getString('benotet') == 'ja')
     date = self.getString('date').strip()
     if date == '':
         date = '\\today'
     # get people for which a Schein should be created
     s = ''
     l = Utils.SortNumerAlpha(Data.people.keys())
     for k in l:
         if self.getString('Schein' + k) == 'true':
             p = Data.people[k]
             if benotet:
                 grade = self.calculateGrade(p)
                 s += (r'\scheinMitNote{%s}{%s}{%s}{%s}{%s}{%s}{%s}' %
                       (lecturer, semester, courseName, date,
                        p.fname + ' ' + p.lname, k, grade))
             else:
                 s += (r'\schein{%s}{%s}{%s}{%s}{%s}{%s}' %
                       (lecturer, semester, courseName, date,
                        p.fname + ' ' + p.lname, k))
             s += '\n'
     latexInput = LatexHead + s + LatexFoot
     #        return ( { 'Content-type' : 'text/x-latex',                   'Content-Disposition' : 'attachment; filename="scheine.tex"'}, latexInput )
     pdf = LatexImage.LatexToPDF(latexInput)
     if not pdf:
         pdf = ''
     head = {
         'Content-type': 'application/pdf',
         'Content-Disposition': 'attachment; filename="scheine.pdf"'
     }
     return (head, pdf)
Example #3
0
 def parseValues(self):
     examnr = self.examnr
     # get the maxscore
     maxscore = self.getNumber('maxscore')
     if maxscore == None:
         return '<em>Error: Invalid maximal score.</em>'
     elif maxscore == '':
         return '<em>Error: Missing maximal score.</em>'
     else:
         self.maxscore = maxscore
     # get the individual scores
     self.scores = {}
     self.oldscores = {}
     l = Utils.SortNumerAlpha(Data.people.keys())
     for k in l:
         p = Data.people[k]
         if (examnr < len(p.exams) and p.exams[examnr] != None
                 and p.exams[examnr].registration == 1):
             score = self.getNumber('P' + str(examnr) + '_' + k, default=-1)
             if score == None:
                 return '<em>Error: Invalid score for ' + k + '.</em>'
             else:
                 if score > maxscore:
                     return ('<em>Error: Score for ' + k + ' exceeds the '
                             'maximal score.</em>')
                 self.scores[k] = [
                     score,
                     self.getString('S' + str(examnr) + '_' + k)
                 ]
                 self.oldscores[k] = [
                     self.getNumber('Pold' + str(examnr) + '_' + k,
                                    default=-1),
                     self.getString('Sold' + str(examnr) + '_' + k)
                 ]
Example #4
0
 def htmlCode(self):
     examnr = self.examnr
     if examnr < 0:
         return '<em>Error: Invalid exam number</em>'
     table = []
     table.append([
         '', 'Matr.-Nr.', 'Name', 'Punkte',
         'Punkte in den einzelnen Aufgaben'
     ])
     l = Utils.SortNumerAlpha(Data.people.keys())
     maxscore = 0
     counter = 0
     for k in l:
         p = Data.people[k]
         if (examnr < len(p.exams) and p.exams[examnr] != None):
             exam = p.exams[examnr]
             if (exam.maxscore != 0):
                 maxscore = exam.maxscore
             if (exam.registration == 1 and exam.totalscore != -1):
                 counter += 1
                 table.append([
                     str(counter), k,
                     Utils.CleanWeb(p.lname) + ', ' +
                     Utils.CleanWeb(p.fname),
                     locale.str(exam.totalscore),
                     Utils.CleanWeb(exam.scores)
                 ])
     s = ('<p>Maximal erreichbare Punktzahl: ' + locale.str(maxscore) +
          '</p>\n')
     s += createHTMLTable(table)
     return s
Example #5
0
 def createPDFFile(self):
     table = []
     l = Utils.SortNumerAlpha(Data.people.keys())
     for k in l:
         p = Data.people[k]
         if self.examnr < len( p.exams ) and \
            p.exams[self.examnr] != None and \
            p.exams[self.examnr].registration:
             table.append([k, p.lname + ', ' + p.fname])
     s = ('\\section*{Liste der Teilnehmer an Klausur ' + str(self.examnr) +
          '}\n')
     lines = '\\cline{1-3}\\cline{5-7}\n'
     linesshort = '\\hline\n'
     eol = '\\\\\n'
     tablehead = ('\\begin{tabular}{|r|c|l|l|r|c|l|}\n' + lines +
                  ' & Matr.-Nr. & Name & & & Matr.-Nr. & Name ' + eol +
                  lines)
     tableheadshort = ('\\begin{tabular}{|r|c|l|}\n' + linesshort +
                       ' & Matr.-Nr. & Name ' + eol + linesshort)
     tablefoot = lines + '\\end{tabular}\n'
     tablefootshort = linesshort + '\\end{tabular}\n'
     maxRows = 44
     offset = 0
     while offset < len(table):
         if offset > 0:
             s += '\\newpage\n'
         twoColumns = (offset + maxRows < len(table))
         if twoColumns:
             s += tablehead
         else:
             s += tableheadshort
         for i in range(offset, min(offset + maxRows, len(table))):
             s += str(i + 1) + ' & ' + table[i][0] + ' & ' + table[i][1]
             if twoColumns:
                 s += ' & & '
                 if i + maxRows < len(table):
                     s += (str(i + maxRows + 1) + ' & ' +
                           table[i + maxRows][0] + ' & ' +
                           table[i + maxRows][1])
                 else:
                     s += '& &'
             s += eol
         if twoColumns:
             s += tablefoot
         else:
             s += tablefootshort
         offset += 2 * maxRows
     latexInput = LatexTemplate % (s)
     pdf = LatexImage.LatexToPDF(latexInput)
     if not pdf:
         return ''
     return pdf
Example #6
0
 def createTextFile(self):
     s = '# All participants of exam number ' + str(self.examnr) + ':\n'
     s += '# ID:angemeldet?:name:fname\n'
     s += '# Time and date of export: ' + Utils.LocalTimeString() + '\n'
     l = Utils.SortNumerAlpha(Data.people.keys())
     for k in l:
         p = Data.people[k]
         if self.examnr < len( p.exams ) and \
             p.exams[self.examnr] != None and \
             p.exams[self.examnr].registration:
             s += (k + ':1:' + Utils.Protect(p.lname) + ':' +
                   Utils.Protect(p.fname) + '\n')
         else:
             s += (k + ':0:' + Utils.Protect(p.lname) + ':' +
                   Utils.Protect(p.fname) + '\n')
     return s
Example #7
0
 def htmlCode(self):
     s = '<h3>Liste der Teilnehmer an Klausur ' + str(
         self.examnr) + '</h3>\n'
     table = []
     table.append(['', 'Matr.-Nr.', 'Name'])
     l = Utils.SortNumerAlpha(Data.people.keys())
     i = 0
     for k in l:
         p = Data.people[k]
         if self.examnr < len( p.exams ) and \
             p.exams[self.examnr] != None and \
             p.exams[self.examnr].registration:
             i += 1
             table.append([
                 str(i), k,
                 Utils.CleanWeb(p.lname) + ', ' + Utils.CleanWeb(p.fname)
             ])
     s += createHTMLTable(table)
     return s
Example #8
0
 def createExamRegistrationMask(self):
     examnr = self.examnr
     s = '<h3>An-/Abmeldung von Klausur ' + str(examnr) + '</h3>\n'
     s += ('<form action="/AdminExtension" method="post">\n'
           '<div><input type="hidden" name="extension" value="' +
           self.name() + '" />\n'
           '<input type="hidden" name="state" value="1" />\n'
           '<input type="hidden" name="examnr" value="' + str(examnr) +
           '" /></div>\n')
     table = []
     table.append(['', 'Matr.-Nr.', 'Name', 'Klausurteilnahme'])
     l = Utils.SortNumerAlpha(Data.people.keys())
     counter = 0
     for k in l:
         counter += 1
         p = Data.people[k]
         checked = ''
         if (examnr < len(p.exams) and p.exams[examnr] != None
                 and p.exams[examnr].registration == 1):
             checked = 'checked="checked" '
         table.append([
             str(counter), k,
             Utils.CleanWeb(p.lname) + ', ' + Utils.CleanWeb(p.fname),
             '<input type="checkbox" name="T' + k + '" '
             'value="true" ' + checked + ' />'
         ])
     s += createHTMLTable(table)
     s += (
         '<p><input type="submit" name="Action" value="Send" />\n'
         # Not sure how I can make of the AdminPasswdField() method. OTOH, this method
         # only uses a global variable, so there's no reason for it to be a method of
         # a class.
         #               '' + handler.AdminPasswdField() + '\n'
         '<input type="password" size="16" maxlength="16" '
         'name="passwd" value="" /></p>\n'
         '</form>\n')
     return s
Example #9
0
    def createSuccessMessage(self):
        examnr = self.examnr
        # evaluate the changes
        registrations = {}
        l = Utils.SortNumerAlpha(Data.people.keys())
        for k in l:
            p = Data.people[k]
            wasRegistered = (examnr < len(p.exams) and p.exams[examnr] != None
                             and p.exams[examnr].registration == 1)
            shouldBeRegistered = self.options.has_key('T' + k)
            if wasRegistered != shouldBeRegistered:
                registrations[k] = int(shouldBeRegistered)

        # put the changes into the database
        registered = []
        unregistered = []
        Data.Lock.acquire()
        timestamp = int(time.time())
        for k in Utils.SortNumerAlpha(registrations.keys()):
            v = registrations[k]
            line = AsciiData.LineTuple(
                (k, str(examnr), str(v), str(timestamp)))
            try:
                Data.examregdesc.AppendLine(line)
            except:
                Data.Lock.release()
                Utils.Error('[' + Utils.LocalTimeString() +
                            '] Failed to register person for exam:\n' + line)
                return '<emph>Error: The changes could not be saved.</emph>'
            p = Data.people[k]
            while len(p.exams) < examnr + 1:
                p.exams.append(None)
            if p.exams[examnr] == None:
                p.exams[examnr] = Data.Exam()
            p.exams[examnr].timestamp = timestamp
            p.exams[examnr].registration = v
            if Data.Exam.maxexamnumber < examnr + 1:
                Data.Exam.maxexamnumber = examnr + 1
            line = (Utils.CleanWeb(p.lname) + ', ' + Utils.CleanWeb(p.fname) +
                    ' (' + k + ')')
            if v == 1:
                registered.append(line)
            else:
                unregistered.append(line)
        Data.Lock.release()

        Utils.Error('[' + Utils.LocalTimeString() + '] Changed registrations '
                    'for exam ' + str(examnr),
                    prefix='BulkExamRegistration: ')
        s = '<h3>An-/Abmeldung von Klausur ' + str(examnr) + '</h3>\n'
        if len(registered) > 0:
            s += ('<div>Die folgenden Personen wurden zur Klausur angemeldet:'
                  '</div>\n'
                  '<ul>\n<li>' + str('</li>\n<li>').join(registered) +
                  '</li>\n</ul>\n')
        if len(unregistered) > 0:
            s += ('<div>Die folgenden Personen wurden von der Klausur '
                  ' abgemeldet:</div>\n'
                  '<ul>\n<li>' + str('</li>\n<li>').join(unregistered) +
                  '</li>\n</ul>\n')
        return s
Example #10
0
 def htmlCode(self):
     lecturer = Config.conf['Lecturer']
     semester = Config.conf['Semester']
     s = ('<hr />\n'
          '<form action="/AdminExtension" method="post">\n'
          '<div><input type="hidden" name="extension" value="' +
          self.name() + '" />\n'
          '<input type="hidden" name="state" value="1" /></div>\n'
          '<p>'
          'Dozent: <input size="30" maxlength="40" name="lecturer" '
          'value="' + lecturer + '" /><br />\n'
          'Semester: <input size="30" maxlength="40" name="semester" '
          'value="' + semester + '" /><br />\n'
          'Scheine: <input type="radio" name="benotet" '
          'value="ja" />benotet / '
          '<input type="radio" name="benotet" '
          'value="nein" />unbenotet<br />\n'
          'Datum: <input size="20" maxlength="20" name="date" '
          'value="" /> (falls leer wird heutiges Datum genommen)'
          '</p>\n'
          '<p>Waehlen Sie diejenigen Kursteilnehmer aus, fuer die ein '
          'Schein generiert werden soll.</p>\n')
     table = []
     titleRow = ['', 'Schein', 'Matr.-Nr.', 'Name', 'Uebungspunkte']
     for i in range(Data.Exam.maxexamnumber):
         titleRow.append('Klausur ' + str(i))
     titleRow.append('Bemerkung')
     table.append(titleRow)
     nurScheinbedErf = (self.getString('nurScheinbedErf') == 'true')
     l = Utils.SortNumerAlpha(Data.people.keys())
     counter = 0
     for k in l:
         p = Data.people[k]
         if nurScheinbedErf and not self.ScheinbedingungErfuellt(p):
             continue
         counter += 1
         row = [str(counter)]
         if self.ScheinbedingungErfuellt(p):
             row.append('<input type="checkbox" name="Schein' + k + '" '
                        'value="true" />')
         else:
             row.append('-')
         row += [
             k,
             Utils.CleanWeb(p.lname + ', ' + p.fname),
             locale.str(p.TotalScore())
         ]
         for i in range(Data.Exam.maxexamnumber):
             if (len(p.exams) <= i or p.exams[i] == None
                     or p.exams[i].totalscore < 0):
                 row.append('-')
             else:
                 row.append(locale.str(p.exams[i].totalscore))
         if self.ScheinbedingungErfuellt(p):
             row.append('Scheinbedingung ist erfuellt')
         else:
             row.append('Scheinbedingung ist nicht erfuellt')
         table.append(row)
     s += createHTMLTable(table)
     s += (
         '<p><input type="submit" name="Action" value="Send" />\n'
         # Not sure how I can make use of the AdminPasswdField() method. OTOH, this
         # method only uses a global variable, so there's no reason for it to be a
         # method of a class.
         #               '' + handler.AdminPasswdField() + '\n'
         '<input type="password" size="16" maxlength="16" '
         'name="passwd" value="" /></p>\n'
         '</form>\n')
     return s
Example #11
0
 def __filteroutput(self, type="html"):
     tablerowbeforefirst = '<tr>\n'
     tablerowinbetween = '\n</tr>\n<tr>\n'
     tablerowafterlast = '\n</tr>\n'
     tablecellbeforefirst = '<td>'
     tablecellinbetween = '</td><td>'
     tablecellafterlast = '</td>'
     tableheadinbetween = '</th><th>'
     reltext = {
         'equal': '=',
         'greater': '&gt;',
         'greaterequal': '&gt;=',
         'less': '&lt;',
         'lessequal': '&lt;=',
         'notequal': 'not equal to',
         'begins': 'begins with',
         'contains': 'contains',
         'ends': 'ends with'
     }
     masklist = [('&', '&amp;'), ('<', '&lt;'), ('>', '&gt;')]
     if type == "text":
         tablerowbeforefirst = ''
         tablerowinbetween = '\n'
         tablerowafterlast = '\n'
         tablecellbeforefirst = ''
         tablecellinbetween = ':'
         tablecellafterlast = ''
         tableheadinbetween = ':'
         reltext = {
             'equal': '=',
             'greater': '>',
             'greaterequal': '>=',
             'less': '<',
             'lessequal': '<=',
             'notequal': 'not equal to',
             'begins': 'begins with',
             'contains': 'contains',
             'ends': 'ends with'
         }
         masklist = []
     if type == "csv":
         tablerowbeforefirst = ''
         tablerowinbetween = '\n'
         tablerowafterlast = '\n'
         tablecellbeforefirst = '"'
         tablecellinbetween = '";"'
         tablecellafterlast = '"'
         tableheadinbetween = '";"'
         reltext = {
             'equal': '=',
             'greater': '>',
             'greaterequal': '>=',
             'less': '<',
             'lessequal': '<=',
             'notequal': 'not equal to',
             'begins': 'begins with',
             'contains': 'contains',
             'ends': 'ends with'
         }
         masklist = []
     if type == "latex":
         tablerowbeforefirst = ''
         tablerowinbetween = ' \\\\\n'
         tablerowafterlast = '\n'
         tablecellbeforefirst = ''
         tablecellinbetween = ' & '
         tablecellafterlast = ''
         tableheadinbetween = '} & \\textbf{'
         reltext = {
             'equal': '$=$',
             'greater': '$>$',
             'greaterequal': '$\\geq$',
             'less': '$<$',
             'lessequal': '$\\leq$',
             'notequal': '$\\neq$',
             'begins': 'begins with',
             'contains': 'contains',
             'ends': 'ends with'
         }
         masklist = [('\\', '\\textbackslash '), ('{', '\\{'), ('}', '\\}'),
                     ('\\textbackslash ', '\\textbackslash{}'),
                     ('"', '\\textquotedbl{}'), ('#', '\\#'), ('$', '\\$'),
                     ('%', '\\%'), ('&', '\\&'), ('<', '\\textless{}'),
                     ('>', '\\textgreater{}'), ('[', '\\relax['),
                     (']', '\\relax]'), ('^', '\\^{}'), ('_', '\\_'),
                     ('|', '\\textbar{}'), ('~', '\\~{}')]
     totalcount = 0
     filtercount = 0
     resultlist = []
     for k in Utils.SortNumerAlpha(Data.people.keys()):
         p = Data.people[k]
         vardict = {}
         vardict["i"] = k
         vardict["n"] = p.lname
         vardict["f"] = p.fname
         vardict["s"] = p.sem
         vardict["g"] = p.group
         vardict["a"] = p.stud
         vardict["m"] = p.email
         totalintscore = 0.0
         for sheetnr, sheetname, sheet in Exercises.SheetList():
             if not sheet.IsClosed(): continue
             if not sheet.counts: continue
             vardict[str(sheetnr) + "c"] = -1
             if p.mcresults.has_key(sheetname):
                 vardict[str(sheetnr) + "c"] = p.mcresults[sheetname].score
                 totalintscore += p.mcresults[sheetname].score
         vardict["C"] = totalintscore
         totalhomescore = 0.0
         for sheetnr, sheetname, sheet in Exercises.SheetList():
             if not sheet.IsClosed(): continue
             if not sheet.counts: continue
             vardict[str(sheetnr) + "h"] = -1
             if p.homework.has_key(sheetname) and \
              p.homework[sheetname].totalscore <> -1:
                 vardict[str(sheetnr) +
                         "h"] = p.homework[sheetname].totalscore
                 totalhomescore += p.homework[sheetname].totalscore
         vardict["H"] = totalhomescore
         vardict["T"] = totalintscore + totalhomescore
         totalexamscore = 0.0
         for i in range(Data.Exam.maxexamnumber):
             if i >= len(p.exams) or p.exams[i] == None or \
              p.exams[i].totalscore < 0:
                 vardict[str(i) + "e"] = -1
             else:
                 vardict[str(i) + "e"] = p.exams[i].totalscore
                 totalexamscore += p.exams[i].totalscore
             vardict[str(i) + "r"] = "no"
             if i < len(p.exams) and p.exams[i] <> None:
                 if p.exams[i].registration == 1:
                     vardict[str(i) + "r"] = "yes"
         vardict["E"] = totalexamscore
         for i in range(len(self.__persondatakeys)):
             try:
                 vardict["%dd" % i] = p.persondata[self.__persondatakeys[i]]
             except:
                 vardict["%dd" % i] = ""
         filter = True
         for i in range(5):
             if self.__fieldlist[i] <> None:
                 val1 = vardict[self.__fieldlist[i]]
                 val2 = self.__vallist[i]
                 if len(val2) >= 2 and val2[0] == '"' and val2[-1] == '"':
                     val2 = val2[1:-1]
                     val1 = str(val1)
                 else:
                     try:
                         val1 = int(val1)
                         val2 = int(val2)
                     except:
                         try:
                             val1 = float(val1)
                             val2 = float(val2)
                         except:
                             pass
                 if self.__rellist[i] == "equal":
                     if not val1 == val2: filter = False
                 if self.__rellist[i] == "greater":
                     if not val1 > val2: filter = False
                 if self.__rellist[i] == "greaterequal":
                     if not val1 >= val2: filter = False
                 if self.__rellist[i] == "less":
                     if not val1 < val2: filter = False
                 if self.__rellist[i] == "lessequal":
                     if not val1 <= val2: filter = False
                 if self.__rellist[i] == "notequal":
                     if not val1 <> val2: filter = False
                 if self.__rellist[i] == "begins":
                     if not str(val1)[:len(str(val2))] == str(val2):
                         filter = False
                 if self.__rellist[i] == "contains":
                     if not str(val2) in str(val1): filter = False
                 if self.__rellist[i] == "ends":
                     if not str(val1)[-len(str(val2)):] == str(val2):
                         filter = False
         totalcount += 1
         if filter:
             filtercount += 1
             sortkey = self.__sortkey.replace("%%", "_!_/_")
             for var in vardict.keys():
                 sortkey = sortkey.replace("%%%s" % var, str(vardict[var]))
             sortkey = sortkey.replace("_!_/_", "%")
             sortkey = stringtosortkey(sortkey)
             msg = self.__msg.replace("%%", "_!_/_")
             for var in vardict.keys():
                 if var[-1:] in ["i", "n", "f", "a", "m", "r", "d"]:
                     msg = msg.replace('%%%s' % var,
                                       Utils.Protect(str(vardict[var])))
                 elif var[-1:] in ["s", "g"]:
                     msg = msg.replace("%%%s" % var, str(vardict[var]))
                 else:
                     msg = msg.replace("%%%s" % var,
                                       locale.str(vardict[var]))
             msg = outputstring(msg, masklist, deletecolon=False)
             msg = msg.replace(":", tablecellinbetween)
             msg = msg.replace("_!_/_", "%")
             resultlist.append([sortkey, (k, p.lname, p.fname, msg)])
     resultlist.sort()
     filteroutput = tablerowbeforefirst
     isfirst = True
     for sortkey, (k, ln, fn, msg) in resultlist:
         if not isfirst: filteroutput += tablerowinbetween
         isfirst = False
         filteroutput += tablecellbeforefirst
         #filteroutput += outputstring(k, masklist)
         #filteroutput += tablecellinbetween
         #filteroutput += outputstring(ln, masklist)
         #filteroutput += tablecellinbetween
         #filteroutput += outputstring(fn, masklist)
         if self.__msg <> "":
             #filteroutput += tablecellinbetween
             filteroutput += msg
         filteroutput += tablecellafterlast
     filteroutput += tablerowafterlast
     filterinfo = ["", "", "", "", filtercount, totalcount]
     #filterinfo[0] = '%i:%n:%f'
     #if self.__msg <> "": filterinfo[0] += ":" + self.__msg
     filterinfo[0] = self.__msg
     if not self.__shortcolhead:
         for var, fieldtitle in self.__vartofieldtitle.iteritems():
             filterinfo[0] = filterinfo[0].replace(
                 "%%%s" % var, Utils.Protect(fieldtitle))
     filterinfo[0] = outputstring(filterinfo[0],
                                  masklist,
                                  deletecolon=False)
     filterinfo[0] = filterinfo[0].replace(":", tableheadinbetween)
     filtercriteria = []
     for i in range(5):
         if self.__fieldlist[i] <> None and self.__rellist[i] <> None:
             filtercriteria.append \
              (outputstring(self.__vartofieldtitle[self.__fieldlist[i]], masklist))
             filtercriteria[-1] += " " + reltext[self.__rellist[i]]
             filtercriteria[-1] += " " + outputstring(
                 self.__vallist[i], masklist)
     if filtercriteria <> []:
         filterinfo[1] = " and ".join(filtercriteria)
     filterinfo[2] = self.__sortkey.replace(" ", ", ")
     for var, fieldtitle in self.__vartofieldtitle.iteritems():
         filterinfo[2] = filterinfo[2].replace(
             "%%%s" % var, outputstring(fieldtitle, masklist))
     filterinfo[3] = Utils.LocalTimeString()
     return filterinfo, filteroutput
Example #12
0
 def htmlCode(self):
     html = ''
     try:
         smtpserver = smtplib.SMTP(self.__server)
         if self.__username <> "" and self.__mailpw <> "":
             smtpserver.login(self.__username, self.__mailpw)
     except:
         smtpserver = None
         html += '<p>Error: Could not contact the server %s</p>\n' % self.__server
     html += '<p>'
     html += '(<a href="/adminmenu.html">back to administrator menu</a>)'
     html += '&nbsp;&nbsp;'
     html += '(<a href="/adminextensions.html">back to administrator ' + \
      'extensions</a>)'
     html += '</p>\n'
     varlist = ["i", "n", "f", "s", "g", "a", "m"]
     vartofieldtitle = {}
     vartofieldtitle["i"] = "ID"
     vartofieldtitle["n"] = "last name"
     vartofieldtitle["f"] = "first name"
     vartofieldtitle["s"] = "semester"
     vartofieldtitle["g"] = "group"
     vartofieldtitle["a"] = "field of studies"
     vartofieldtitle["m"] = "mail address"
     for sheetnr, sheetname, sheet in Exercises.SheetList():
         if not sheet.IsClosed(): continue
         if not sheet.counts: continue
         varlist.append(str(sheetnr) + "c")
         vartofieldtitle[str(sheetnr) + "c"] = "points from interactive " \
          "part of exercise sheet " + str(sheetnr)
     varlist.append("C")
     vartofieldtitle["C"] = "total points from interactive exercises"
     for sheetnr, sheetname, sheet in Exercises.SheetList():
         if not sheet.IsClosed(): continue
         if not sheet.counts: continue
         varlist.append(str(sheetnr) + "h")
         vartofieldtitle[str(sheetnr) + "h"] = "points from written homework " \
          "part of exercise sheet " + str(sheetnr)
     varlist.append("H")
     vartofieldtitle["H"] = "total points from written homework exercises"
     varlist.append("T")
     vartofieldtitle[
         "T"] = "total points from written and interactive exercises"
     for i in range(Data.Exam.maxexamnumber):
         varlist.append(str(i) + "e")
         vartofieldtitle[str(i) + "e"] = "points from exam " + str(i)
     varlist.append("E")
     vartofieldtitle["E"] = "total points from exams"
     for i in range(Data.Exam.maxexamnumber):
         varlist.append(str(i) + "r")
         vartofieldtitle[str(i) + "r"] = "registered for exam " + str(i) + \
          " (no/yes)"
     persondatakeys = []
     for k in Data.people.keys():
         for key in Data.people[k].persondata.keys():
             if key not in persondatakeys: persondatakeys.append(key)
     persondatakeys.sort()
     for i in range(len(persondatakeys)):
         varlist.append("%dd" % i)
         vartofieldtitle[varlist[-1]] = persondatakeys[i]
     if self.__state > 0 and smtpserver <> None:
         fullfrom = self.__from
         maillist = []
         if self.__fromname <> "":
             fullfrom = "%s <%s>" % (self.__fromname, self.__from)
         if self.__state % 2 == 1:
             html += '<p>Please confirm that the following participants should ' \
              'receive a mail.</p>\n'
         else:
             html += '<p>Tried to send last mail to the following ' \
              'participants:</p>\n'
         html += '<table>\n'
         html += '<tr>\n'
         html += \
          '<th>ID</th><th>last name</th><th>first name</th><th>status</th>\n'
         html += '</tr>\n'
         for k in Utils.SortNumerAlpha(Data.people.keys()):
             p = Data.people[k]
             vardict = {}
             vardict["i"] = k
             vardict["n"] = p.lname
             vardict["f"] = p.fname
             vardict["s"] = p.sem
             vardict["g"] = p.group
             vardict["a"] = p.stud
             vardict["m"] = p.email
             totalintscore = 0.0
             for sheetnr, sheetname, sheet in Exercises.SheetList():
                 if not sheet.IsClosed(): continue
                 if not sheet.counts: continue
                 vardict[str(sheetnr) + "c"] = -1
                 if p.mcresults.has_key(sheetname):
                     vardict[str(sheetnr) +
                             "c"] = p.mcresults[sheetname].score
                     totalintscore += p.mcresults[sheetname].score
             vardict["C"] = totalintscore
             totalhomescore = 0.0
             for sheetnr, sheetname, sheet in Exercises.SheetList():
                 if not sheet.IsClosed(): continue
                 if not sheet.counts: continue
                 vardict[str(sheetnr) + "h"] = -1
                 if p.homework.has_key(sheetname) and \
                  p.homework[sheetname].totalscore <> -1:
                     vardict[str(sheetnr) +
                             "h"] = p.homework[sheetname].totalscore
                     totalhomescore += p.homework[sheetname].totalscore
             vardict["H"] = totalhomescore
             vardict["T"] = totalintscore + totalhomescore
             totalexamscore = 0.0
             for i in range(Data.Exam.maxexamnumber):
                 if i >= len(p.exams) or p.exams[i] == None or \
                  p.exams[i].totalscore < 0:
                     vardict[str(i) + "e"] = -1
                 else:
                     vardict[str(i) + "e"] = p.exams[i].totalscore
                     totalexamscore += p.exams[i].totalscore
                 vardict[str(i) + "r"] = "no"
                 if i < len(p.exams) and p.exams[i] <> None:
                     if p.exams[i].registration == 1:
                         vardict[str(i) + "r"] = "yes"
             vardict["E"] = totalexamscore
             for i in range(len(persondatakeys)):
                 try:
                     vardict["%dd" % i] = p.persondata[persondatakeys[i]]
                 except:
                     vardict["%dd" % i] = ""
             filter = True
             for i in range(5):
                 if self.__fieldlist[i] <> None:
                     val1 = vardict[self.__fieldlist[i]]
                     val2 = self.__vallist[i]
                     if len(val2
                            ) >= 2 and val2[0] == '"' and val2[-1] == '"':
                         val2 = val2[1:-1]
                         val1 = str(val1)
                     else:
                         try:
                             val1 = int(val1)
                             val2 = int(val2)
                         except:
                             try:
                                 val1 = float(val1)
                                 val2 = float(val2)
                             except:
                                 pass
                     if self.__rellist[i] == "equal":
                         if not val1 == val2: filter = False
                     if self.__rellist[i] == "greater":
                         if not val1 > val2: filter = False
                     if self.__rellist[i] == "greaterequal":
                         if not val1 >= val2: filter = False
                     if self.__rellist[i] == "less":
                         if not val1 < val2: filter = False
                     if self.__rellist[i] == "lessequal":
                         if not val1 <= val2: filter = False
                     if self.__rellist[i] == "notequal":
                         if not val1 <> val2: filter = False
                     if self.__rellist[i] == "begins":
                         if not str(val1)[:len(str(val2))] == str(val2):
                             filter = False
                     if self.__rellist[i] == "contains":
                         if not str(val2) in str(val1): filter = False
                     if self.__rellist[i] == "ends":
                         if not str(val1)[-len(str(val2)):] == str(val2):
                             filter = False
             if filter and p.email <> "":
                 msg = "From: %s\r\n" % fullfrom
                 msg += "Subject: %s\r\n" % self.__subject
                 msg += "To: %s\r\n" % p.email
                 msg += "Content-type: text/plain; charset=iso-8859-15\r\n"
                 msg += "\r\n"
                 msg += self.__text
                 msg = msg.replace("%%", "_!_/_")
                 usedvar = False
                 for var in vardict.keys():
                     if ("%%%s" % var) in msg: usedvar = True
                     msg = msg.replace("%%%s" % var, str(vardict[var]))
                 msg = msg.replace("_!_/_", "%")
                 msg = msg.strip() + "\r\n"
                 html += '<tr>\n'
                 if self.__state % 2 == 1:
                     status = "not yet sent"
                 else:
                     status = "successful"
                     if usedvar:
                         try:
                             smtpserver.sendmail(fullfrom, p.email, msg)
                             time.sleep(self.__pause)
                         except:
                             status = "<strong>not successful</strong>"
                     else:
                         maillist.append(p.email)
                         status = "BCC"
                 html += '<td>%s</td><td>%s</td><td>%s</td><td>%s</td>\n' % (k, \
                  p.lname, p.fname, status)
                 html += '</tr>\n'
         html += '</table>\n'
         if maillist <> [] and self.__state % 2 == 0:
             msg = "From: %s\r\n" % fullfrom
             msg += "Subject: %s\r\n" % self.__subject
             msg += "To: %s\r\n" % fullfrom
             msg += "BCC: %s\r\n" % string.join(maillist, ", ")
             msg += "Content-type: text/plain; charset=iso-8859-15\r\n"
             msg += "\r\n"
             msg += self.__text
             msg = msg.replace("%%", "%")
             msg = msg.strip() + "\r\n"
             try:
                 smtpserver.sendmail(fullfrom, [fullfrom] + maillist, msg)
                 pass
             except:
                 html = html.replace("BCC",
                                     "<strong>not successful</strong>")
         smtpserver.quit()
     html += '<form action="/AdminExtension" method="post" ' + \
      'accept-charset="ISO-8859-15">\n'
     html += '<div>\n'
     html += '<input type="hidden" name="extension" value="%s" />\n' % \
      self.name()
     html += '<input type="hidden" name="state" value="%d" />\n' % \
      (self.__state + 1)
     html += '</div>\n'
     if self.__state % 2 == 0:
         html += '<p>\n'
         html += 'Select participants who should receive a mail.\n'
         html += 'The following conditions have all to be met simultaneously.\n'
         html += '(Please note that comparisons are interpreted as numerical '
         html += 'comparisons whenever it is possible. To force comparison of '
         html += 'texts, include the value in quotes ("..."))\n'
         html += 'If no condition is given, every participant will receive '
         html += 'a mail.\n'
         html += '</p>\n'
         html += '<table>\n'
         for i in range(5):
             html += '<tr>\n'
             html += '<td>\n'
             html += '<select name="field%d">\n' % i
             html += '<option value="none">field</option>\n'
             for var in varlist:
                 if self.__fieldlist[i] == var:
                     html += '<option value="%s" selected="selected">%s</option>\n' % \
                      (var, vartofieldtitle[var])
                 else:
                     html += '<option value="%s">%s</option>\n' % \
                      (var, vartofieldtitle[var])
             html += '</select>\n'
             html += '</td>\n'
             reqsel = ""
             rgtsel = ""
             rgesel = ""
             rltsel = ""
             rlesel = ""
             rnesel = ""
             rbgsel = ""
             rcosel = ""
             rensel = ""
             if self.__rellist[i] == "equal":
                 reqsel = ' selected="selected"'
             if self.__rellist[i] == "greater":
                 rgtsel = ' selected="selected"'
             if self.__rellist[i] == "greaterequal":
                 rgesel = ' selected="selected"'
             if self.__rellist[i] == "less": rltsel = ' selected="selected"'
             if self.__rellist[i] == "lessequal":
                 rlesel = ' selected="selected"'
             if self.__rellist[i] == "notequal":
                 rnesel = ' selected="selected"'
             if self.__rellist[i] == "begins":
                 rbgsel = ' selected="selected"'
             if self.__rellist[i] == "contains":
                 rcosel = ' selected="selected"'
             if self.__rellist[i] == "ends": rensel = ' selected="selected"'
             html += '<td>\n'
             html += '<select name="relation%s">\n' % i
             html += '<option value="none">relation</option>\n'
             html += '<option value="equal"%s>=</option>\n' % reqsel
             html += '<option value="greater"%s>&gt;</option>\n' % rgtsel
             html += '<option value="greaterequal"%s>&gt;=</option>\n' % rgesel
             html += '<option value="less"%s>&lt;</option>\n' % rltsel
             html += '<option value="lessequal"%s>&lt;=</option>\n' % rlesel
             html += '<option value="notequal"%s>not equal to</option>\n' % rnesel
             html += '<option value="begins"%s>begins with</option>\n' % rbgsel
             html += '<option value="contains"%s>contains</option>\n' % rcosel
             html += '<option value="ends"%s>ends with</option>\n' % rensel
             html += '</select>\n'
             html += '</td>\n'
             html += '<td>\n'
             html += '<input type="text" name="value%d" size="30" value="%s" />' % \
              (i, self.__vallist[i])
             html += '</td>\n'
             html += '</tr>\n'
         html += '</table>\n'
         html += ('<p>server:&nbsp;<input type="text" name="server" ' +
                  'size="40" value="%s" /></p>\n') % self.__server
         html += (
             '<p>user name for mail server (if needed):&nbsp;<input type=' +
             '"text" name="username" size="40" value="%s" /></p>\n'
         ) % self.__username
         html += ('<p>pause between two mails:&nbsp;<input type="text" ' + \
          'name="pause" size="5" value="%s" /> seconds</p>\n') % self.__pause
         html += ('<p>from address:&nbsp;<input type="text" name="from" ' +
                  'size="40" value="%s" /></p>\n') % self.__from
         html += ('<p>from name (optional):&nbsp;<input type="text" ' +
                  'name="fromname" size="40" value="%s" /></p>\n'
                  ) % self.__fromname
         html += '<p>\n'
         html += 'In the following text fields you may use variables, '
         html += 'which are set according to the participant the mail '
         html += 'is sent to.<br />\n'
         html += '<strong>%i</strong>: ID'
         html += '; <strong>%n</strong>: last name'
         html += '; <strong>%f</strong>: first name'
         html += '; <strong>%s</strong>: semester'
         html += '; <strong>%g</strong>: group'
         html += '; <strong>%a</strong>: field of studies'
         html += '; <strong>%m</strong>: email address'
         html += '; <strong>%1c</strong>, <strong>%2c</strong>, ...: points ' \
          'from interactive part of exercise sheet 1, 2, ...'
         html += '; <strong>%C</strong>: total points from interactive exercises'
         html += '; <strong>%1h</strong>, <strong>%2h</strong>, ...: points ' \
          'from written homework part of exercise sheet 1, 2, ...'
         html += '; <strong>%H</strong>: total points from written homework ' \
          'exercises'
         html += '; <strong>%T</strong>: total points from interactive and ' \
          'written homework exercises'
         html += '; <strong>%0e</strong>, <strong>%1e</strong>, ...: points ' \
          'from exam 0, 1, ...'
         html += '; <strong>%E</strong>: total points from exams'
         for i in range(len(persondatakeys)):
             html += '; <strong>%%%dd</strong>: %s' % (i, persondatakeys[i])
         html += '.\n'
         html += '(In order to produce a %-sign, type ' \
          '<strong>%%</strong>.)<br />\n'
         html += 'If no variables are used, only one mail will be sent &ndash; '
         html += 'addressed to the from address with all recipients in a BCC ' \
          'list.\n'
         html += '</p>\n'
         html += ('<p>subject:&nbsp;<input type="text" ' + 'name="subject" '
                  + 'size="40" value="%s" /></p>\n') % self.__subject
         html += '<p><textarea name="text" cols="50" rows="10">' + \
          self.__text + '</textarea></p>\n'
     else:
         html += '<table>\n'
         for i in range(5):
             html += '<tr>\n'
             if self.__fieldlist[i] in varlist:
                 html += '<td>\n'
                 html += '<input type="hidden" name="field%d" value="%s" />' % \
                  (i, self.__fieldlist[i])
                 html += vartofieldtitle[self.__fieldlist[i]] + "\n"
                 html += '</td>\n'
             else:
                 html += '<td>\n'
                 html += ('<input type="hidden" name="field%d" value="none" ' + \
                  '/>&nbsp;\n') % i
                 html += '</td>\n'
             html += '<td>\n'
             html += '<input type="hidden" name ="relation%d" value="%s" />' % \
              (i, self.__rellist[i])
             if self.__rellist[i] == "equal": html += "="
             if self.__rellist[i] == "greater": html += "&gt;"
             if self.__rellist[i] == "greaterequal": html += "&gt;="
             if self.__rellist[i] == "less": html += "&lt;"
             if self.__rellist[i] == "lessequal": html += "&lt;="
             if self.__rellist[i] == "notequal": html += "not equal to"
             if self.__rellist[i] == "begins": html += "begins with"
             if self.__rellist[i] == "contains": html += "contains"
             if self.__rellist[i] == "ends": html += "ends with"
             html += '\n</td>\n'
             html += '<td>\n'
             html += '<input type="hidden" name="value%d" value="%s" />%s\n' % \
              (i, self.__vallist[i], self.__vallist[i])
             html += '</td>\n'
             html += '</tr>\n'
         html += '</table>\n'
         html += ('<p>server:&nbsp;<input type="hidden" name="server" ' +
                  'value="%s" />%s</p>\n') % (self.__server, self.__server)
         html += (
             '<p>user name for mail server (if needed):&nbsp;<input type=' +
             '"hidden" name="username" value="%s" />%s</p>\n') % (
                 self.__username, self.__username)
         html += (
             '<p>password for mail server (if needed):&nbsp;<input type=' +
             '"password" name="mailpw" size="10" value="%s" /></p>\n'
         ) % self.__mailpw
         html += ('<p>pause between two mails:&nbsp;<input type="hidden" ' + \
          'name="pause" value="%s" />%s seconds</p>\n') % (self.__pause,
          self.__pause)
         html += ('<p>from address:&nbsp;<input type="hidden" name="from" '
                  + 'value="%s" />%s</p>\n') % (self.__from, self.__from)
         html += ('<p>from name (optional):&nbsp;<input type="hidden" ' +
                  'name="fromname" value="%s" />%s</p>\n') % (
                      self.__fromname, self.__fromname)
         html += ('<p>subject:&nbsp;<input type="hidden" ' +
                  'name="subject" ' + 'value="%s" />%s</p>\n') % (
                      self.__subject, self.__subject)
         html += '<p><textarea name="text" cols="50" rows="10" ' + \
          'readonly="readonly">' + self.__text + '</textarea></p>\n'
     html += '<p>administrator password: <input type="password" ' + \
      'size="16" maxlength="16" name="passwd" value="" />' + \
      '&nbsp;<input type="submit" /></p>\n'
     html += '</form>\n'
     return html
Example #13
0
    def createSummary(self):
        examnr = self.examnr
        maxscore = self.maxscore
        scores = self.scores
        oldscores = self.oldscores

        # put the changes into the database
        table = []
        table.append([
            '', 'Matr.-Nr.', 'Name', 'Punkte',
            'Punkte in den einzelnen Aufgaben'
        ])
        unchanged = []
        unchanged.append([
            '', 'Matr.-Nr.', 'Name', 'Punkte (alt)', 'Punkte (aktuell)',
            'Punkte (Ihre Angabe)', 'Details (alt)', 'Details (aktuell)',
            'Details (Ihre Angabe)'
        ])
        counter = 0
        unchangedcount = 0
        Data.Lock.acquire()
        for k in Utils.SortNumerAlpha(scores.keys()):
            p = Data.people[k]
            while len(p.exams) < examnr + 1:
                p.exams.append(None)
            exam = p.exams[examnr]
            newOrChanged = False
            # we only have to save non-default values for not yet existing
            # entries or changed values for existing entries
            newtotalscore = scores[k][0]
            newdetails = scores[k][1]
            oldtotalscore = oldscores[k][0]
            olddetails = oldscores[k][1]
            # if ( exam == None ):       # only needed for the following print
            #     curtotalscore = -1
            #     curdetails = '<None>'
            # else:
            #     curtotalscore = exam.totalscore
            #     curdetails = exam.scores
            # print ( k + ': totalscore (old/cur/new): ' + str(oldtotalscore) +
            #             '/' + str(curtotalscore) + '/' + str(newtotalscore) +
            #             ' -- details (old/cur/new): "' + olddetails + '"/"' +
            #             curdetails + '"/"' + newdetails + '"' )
            if (exam == None):
                # do we have non-default values?
                if (newtotalscore != -1 or newdetails != ''):
                    exam = Data.Exam()
                    newOrChanged = True
            else:
                # has the user made changes?
                valuesChanged = ((newtotalscore != oldtotalscore)
                                 or (newdetails != olddetails))
                # are there changes with respect to the currently stored values
                # (because of changes by another user while the first user editted
                # the values)
                needsSaving = ((newtotalscore != exam.totalscore)
                               or (newdetails != exam.scores))
                # have there been changes behind our back
                changedBehindBack = ((oldtotalscore != exam.totalscore)
                                     or (olddetails != exam.scores))
                if (valuesChanged and needsSaving and changedBehindBack):
                    # the user has changed a value and additionally this value has
                    # been changed by another user while the first user editted
                    # the values; in this case we don't save our values
                    unchangedcount += 1
                    if newtotalscore == -1:
                        newtotalscorestr = '-'
                    else:
                        newtotalscorestr = locale.str(newtotalscore)
                    if oldtotalscore == -1:
                        oldtotalscorestr = '-'
                    else:
                        oldtotalscorestr = locale.str(oldtotalscore)
                    if exam.totalscore == -1:
                        curtotalscorestr = '-'
                    else:
                        curtotalscorestr = locale.str(exam.totalscore)
                    unchanged.append([
                        str(unchangedcount), k,
                        Utils.CleanWeb(p.lname) + ', ' +
                        Utils.CleanWeb(p.fname), oldtotalscorestr,
                        curtotalscorestr, newtotalscorestr, olddetails,
                        exam.scores, newdetails
                    ])
                elif (valuesChanged):
                    newOrChanged = True
                elif (exam.maxscore != maxscore
                      and (oldtotalscore != -1 or olddetails != '')):
                    newOrChanged = True
            if newOrChanged:
                exam.totalscore = newtotalscore
                exam.scores = newdetails
                exam.maxscore = maxscore
                line = AsciiData.LineTuple((k, str(examnr), str(newtotalscore),
                                            str(maxscore), newdetails))
                try:
                    Data.examdesc.AppendLine(line)
                except:
                    Data.Lock.release()
                    Utils.Error('[' + Utils.LocalTimeString() +
                                '] Failed to store exam result:\n' + line)
                    return '<em>Error: The results could not be saved.</em>'
                p.exams[examnr] = exam
                counter += 1
                if newtotalscore == -1:
                    newtotalscorestr = '-'
                else:
                    newtotalscorestr = locale.str(newtotalscore)
                table.append([
                    str(counter), k,
                    Utils.CleanWeb(p.lname) + ', ' + Utils.CleanWeb(p.fname),
                    newtotalscorestr, newdetails
                ])
        Data.Lock.release()

        Utils.Error('[' + Utils.LocalTimeString() + '] Changed results '
                    'for exam ' + str(examnr),
                    prefix=self.name() + ': ')
        s = '<h3>Ergebnisse von Klausur ' + str(examnr) + '</h3>\n'
        if len(unchanged) > 1:
            s += (
                '<p>Einige Werte wurden geändert, während Sie die Werte editiert '
                'haben. Daher wurden die folgenden Änderungen <strong>nicht</strong> '
                'gespeichert.')
            s += createHTMLTable(unchanged)
        s += '<p>Die folgenden Änderungen wurden gespeichert.</p>'
        s += createHTMLTable(table)
        return s
Example #14
0
 def createExamResultInputMask(self):
     examnr = self.examnr
     s = '<h3>Eingabe der Ergebnisse von Klausur ' + str(examnr) + '</h3>\n'
     s += ('<p><em>Hinweis:</em> Es werden nur diejenigen '
           'Kursteilnehmer angezeigt, die zu dieser Klausur angemeldet '
           'sind.</p>')
     s += ('<form action="/AdminExtension" method="post">\n'
           '<div><input type="hidden" name="extension" value="' +
           self.name() + '" />\n'
           '<input type="hidden" name="state" value="1" />\n'
           '<input type="hidden" name="examnr" value="' + str(examnr) +
           '" /></div>\n')
     table = []
     table.append([
         '', 'Matr.-Nr.', 'Name', 'Punkte',
         'Punkte in den einzelnen Aufgaben'
     ])
     l = Utils.SortNumerAlpha(Data.people.keys())
     counter = 0
     oldmaxscore = ''
     for k in l:
         p = Data.people[k]
         checked = ''
         if (examnr < len(p.exams) and p.exams[examnr] != None):
             exam = p.exams[examnr]
             if (exam.maxscore != 0):
                 oldmaxscore = locale.str(exam.maxscore)
             if (exam.registration == 1):
                 counter += 1
                 oldtotalscore = ''
                 if (exam.totalscore != -1):
                     oldtotalscore = locale.str(exam.totalscore)
                 table.append([
                     str(counter), k,
                     Utils.CleanWeb(p.lname) + ', ' +
                     Utils.CleanWeb(p.fname), '<input type="hidden" '
                     'name="Pold' + str(examnr) + '_' + k + '" '
                     'value="' + oldtotalscore + '" />'
                     '<input size="6" maxlength="6" '
                     'name="P' + str(examnr) + '_' + k + '" '
                     'value="' + oldtotalscore + '" />',
                     '<input type="hidden" '
                     'name="Sold' + str(examnr) + '_' + k + '" '
                     'value="' + Utils.CleanWeb(exam.scores) + '" />'
                     '<input size="40" maxlength="100" '
                     'name="S' + str(examnr) + '_' + k + '" '
                     'value="' + Utils.CleanWeb(exam.scores) + '" />'
                 ])
     s += ('<p>Maximal erreichbare Punktzahl: '
           '<input name="maxscore" value="' + oldmaxscore + '" '
           'size="4" maxlength="4" /></p>\n')
     s += createHTMLTable(table)
     s += (
         '<p><input type="submit" name="Action" value="Send" />\n'
         # Not sure how I can make use of the AdminPasswdField() method. OTOH, this
         # method only uses a global variable, so there's no reason for it to be a
         # method of a class.
         #               '' + handler.AdminPasswdField() + '\n'
         '<input type="password" size="16" maxlength="16" '
         'name="passwd" value="" /></p>\n'
         '</form>\n')
     return s