Commit 926c57d7 authored by Fabian Gabel's avatar Fabian Gabel
Browse files

bug fixes in sendNotification routine

parent 24bd890e
......@@ -2,6 +2,7 @@ import mysql.connector
import getpass
import sys
from sqlconfig import *
#from sqlconfig_de import *
from studip import Studip
#useful references:
......@@ -72,7 +73,7 @@ def sendLogin(mydb,lang='en'):
print(mycursor.rowcount, "record(s) affected")
print('Done.')
def sendNotification(mydb,template_file,subject,fields='student_id',user_idstatus=-1,update_status=-1):
def sendNotification(mydb,template_file,subject,fields='student_id',user_status=-1,update_status=-1):
"""Send notification to students in database
Keyword arguments:
......@@ -99,8 +100,8 @@ def sendNotification(mydb,template_file,subject,fields='student_id',user_idstatu
# query database
mycursor = mydb.cursor()
if status != -1:
mycursor.execute("SELECT " + fields + " FROM classlist WHERE mailstatus=" + status)
if user_status != -1:
mycursor.execute("SELECT " + fields + " FROM classlist WHERE mailstatus=" + str(user_status))
else:
mycursor.execute("SELECT " + fields + " FROM classlist")
......@@ -119,12 +120,14 @@ def sendNotification(mydb,template_file,subject,fields='student_id',user_idstatu
# update database with update_status
if update_status != -1:
mycursor.execute("UPDATE classlist SET mailstatus=" + update_status + " WHERE student_id='" + kerberos + "'")
mycursor.execute("UPDATE classlist SET mailstatus=" + str(update_status) + " WHERE student_id='" + kerberos + "'")
mydb.commit()
print(mycursor.rowcount, "record(s) affected")
print('Done.')
#main two routines
generateClasslist(mydb)
sendLogin(mydb)
#generateClasslist(mydb)
sendNotification(mydb,'woche3.txt','[WeBWorK] Geometrische Vielfachheit und Bestimmung einer Eigenraumbasis','student_id,first_name',1,-1)
#sendLogin(mydb,'en')
#sendLogin(mydb,'de')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment