Commit f60101a1 authored by Fabian Nuraddin Alexander Gabel's avatar Fabian Nuraddin Alexander Gabel 💬
Browse files

Merge branch 'la2-classlist' into 'main'

bug fixes in sendNotification routine

See merge request !1
parents 24bd890e 926c57d7
...@@ -2,6 +2,7 @@ import mysql.connector ...@@ -2,6 +2,7 @@ import mysql.connector
import getpass import getpass
import sys import sys
from sqlconfig import * from sqlconfig import *
#from sqlconfig_de import *
from studip import Studip from studip import Studip
#useful references: #useful references:
...@@ -72,7 +73,7 @@ def sendLogin(mydb,lang='en'): ...@@ -72,7 +73,7 @@ def sendLogin(mydb,lang='en'):
print(mycursor.rowcount, "record(s) affected") print(mycursor.rowcount, "record(s) affected")
print('Done.') 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 """Send notification to students in database
Keyword arguments: Keyword arguments:
...@@ -99,8 +100,8 @@ def sendNotification(mydb,template_file,subject,fields='student_id',user_idstatu ...@@ -99,8 +100,8 @@ def sendNotification(mydb,template_file,subject,fields='student_id',user_idstatu
# query database # query database
mycursor = mydb.cursor() mycursor = mydb.cursor()
if status != -1: if user_status != -1:
mycursor.execute("SELECT " + fields + " FROM classlist WHERE mailstatus=" + status) mycursor.execute("SELECT " + fields + " FROM classlist WHERE mailstatus=" + str(user_status))
else: else:
mycursor.execute("SELECT " + fields + " FROM classlist") mycursor.execute("SELECT " + fields + " FROM classlist")
...@@ -119,12 +120,14 @@ def sendNotification(mydb,template_file,subject,fields='student_id',user_idstatu ...@@ -119,12 +120,14 @@ def sendNotification(mydb,template_file,subject,fields='student_id',user_idstatu
# update database with update_status # update database with update_status
if update_status != -1: 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() mydb.commit()
print(mycursor.rowcount, "record(s) affected") print(mycursor.rowcount, "record(s) affected")
print('Done.') print('Done.')
#main two routines #main two routines
generateClasslist(mydb) #generateClasslist(mydb)
sendLogin(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