Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Fabian Nuraddin Alexander Gabel
webwork-utils
Commits
f60101a1
Commit
f60101a1
authored
Apr 25, 2021
by
Fabian Nuraddin Alexander Gabel
💬
Browse files
Merge branch 'la2-classlist' into 'main'
bug fixes in sendNotification routine See merge request
!1
parents
24bd890e
926c57d7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
create_classlist/create_classlist.py
create_classlist/create_classlist.py
+9
-6
No files found.
create_classlist/create_classlist.py
View file @
f60101a1
...
...
@@ -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_
id
status
=-
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')
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment