# This file is part of ReportTool # ReportTool (Felicity) is copyright 2004-8 Steve Butterfill. # # ReportTool is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # ReportTool is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with ReportTool. If not, see . # # If you want to use ReportTool under a difference licence, email # s.butterfill@warwick.ac.uk. import model from model import * import time import file_upload def make_tables(): """creates tables from db in correct order. needs to be updated when model.py is updated""" for clz in model.model_objects_in_creation_order: print "creating %s" % clz clz.createTable() clz._connection.commit() def create_feedback_format(): f0 = ReportField(name="I. The module as a a whole", field_type="heading") f1 = ReportField(field_type="slider", slider_left_text="module handouts were clear, accurate & informative", slider_right_text = "handouts were not clear, accurate & informative", slider_steps=5) f2 = ReportField(field_type="slider", slider_left_text="module was too difficult", slider_right_text="too easy", slider_steps=5) f3 = ReportField(field_type="slider", slider_left_text = "module tutor was impossible to see outside lectures/seminars", slider_right_text = "module tutor was readily available outside lectures/seminars", slider_steps=5) f4 = ReportField(name="Any coments?", field_type="text", size=5, label_above=True) f5 = ReportField(name="II. Lectures (complete where appropriate)", field_type="heading") f6 = ReportField(field_type="slider", slider_left_text="unclear presentation", slider_right_text="very clear presentation", slider_steps=5) f7 = ReportField(field_type="slider", slider_left_text="paced too fast", slider_right_text="paced too slow", slider_steps=5) f8 = ReportField(field_type="slider", slider_left_text="failed to convey enthusiasm and stimulate interest", slider_right_text="conveyed enthusiasm and stimulated interest", slider_steps=5) f9 = ReportField(name="General comments (What did you find valuable? Do you have any suggestions for improvements?)", field_type="text", size=5, label_above=True) fa = ReportField(name="III. Seminars/tutorials (complete where appropriate)", field_type="heading") fb = ReportField(field_type="slider", slider_left_text="failed to create atmosphere for discussion", slider_right_text="created atmosphere for discussion", slider_steps=5) fc = ReportField(field_type="slider", slider_left_text="you spoke in most seminars", slider_right_text="you spoke in hardly any seminars", slider_steps=5) fd = ReportField(field_type="slider", slider_left_text="failed to convey enthusiasm and stimulate interest", slider_right_text="conveyed enthusiasm and stimulated interest", slider_steps=5) fe = ReportField(name="Any comments?", field_type="text", size=5, label_above=True) ff = ReportField(name="IV. Written work (complete where appropriate)", field_type="heading") fg = ReportField(field_type="slider", slider_left_text="titles and reading lists most helpful", slider_right_text="titles and reading lists of little help", slider_steps=5) fh = ReportField(field_type="slider", slider_left_text="feedback not helpful", slider_right_text="feedback very helpful", slider_steps=5) fi = ReportField(name="General comments", field_type="text", size=5, label_above=True) fj = ReportField(name="V. Resources (complete where appropriate)", field_type="heading") fk = ReportField(field_type="slider", slider_left_text="It was easy to get hold of recommended texts", slider_right_text="Recommended text were difficult to get hold of", slider_steps=5) fl = ReportField(field_type="slider", slider_left_text="Module webpage was unhelpful", slider_right_text="Module webpage was clear and useful", slider_steps=5) fm = ReportField(name="Comments on resources. Which resources did you make most use of (e.g., library standard loan, SRC, learning grid, Warwick-based electronic resources, other webresources, etc.), and which do you think are most important?", field_type="text", size=5, label_above=True) rf = FeedbackFormat(name="Warwick.philosophy", fields=[f0,f1,f2,f3,f4,f5,f6,f7,f8,f9,fa,fb,fc,fd,fe,ff,fg,fh,fi,fj,fk,fl,fm]) def create_new_data(): """creates some basic data to get started with. Assumes database is empty, will do horrible things if it isn't. use: tg-admin shell >>> import util >>> util.create_new_data() """ #user, groups permissions u1 = User(display_name='steve', user_name='steve', password='abc', email_address='stephen.butterfill@gmail.com') u2= User(display_name='manish', user_name='manish', password='abc', email_address='m.maisuria@warwick.ac.uk') lect = Group(group_name='lecturer', display_name='lecturer') admin = Group(group_name='admin', display_name='admin') config = Group(group_name='config', display_name='config') student_group = Group(group_name='student', display_name='student') for x in [lect, admin, config]: u1.addGroup(x) u2.addGroup(x) p1 = Permission(description='view_students', permission_name='view_students', ) for x in [lect, admin]: p1.addGroup(x) p2 = Permission(description='edit_students', permission_name='edit_students', ) p2.addGroup(admin) p3 = Permission(description='create single reports', permission_name='create_report', ) p5 = Permission(description='permission to view reports not your own', permission_name='view_reports') for x in [lect, admin]: p3.addGroup(x) p5.addGroup(x) p3 = Permission(description='upload files (to add to database)', permission_name='upload', ) p3.addGroup(admin) p4 = Permission(description="view students' notes", permission_name='view_stud_notes', ) p4.addGroup(admin) p4.addGroup(lect) #dept, staff d = Dept(code='PH', name='Philosophy') staff = Staff(firstname='Steve', lastname='Butterfill', code='P123', dept=d) staff.user=u1 s2 = Staff(firstname='Manish', lastname='Maisuria', code='P983', dept=d) s2.user=u2 #time Term(current=False, ordering=1, name='Autumn') Term(current=True, ordering=2, name='Spring', ) Term(current=False, ordering=3, name='Summer', ) Year(current=False, ordering=1, name='89/90', start_date= '1989-10-31') Year(current=False, ordering=2, name='90/91', start_date= '1990-10-31') Year(current=False, ordering=3, name='91/92', start_date= '1991-10-31') Year(current=False, ordering=4, name='92/93', start_date= '1992-10-31') Year(current=False, ordering=5, name='93/94', start_date= '1993-10-31') Year(current=False, ordering=6, name='94/95', start_date= '1994-10-31') Year(current=False, ordering=7, name='95/96', start_date= '1995-10-31') Year(current=False, ordering=8, name='96/97', start_date= '1996-10-31') Year(current=False, ordering=9, name='97/98', start_date= '1997-10-31') Year(current=False, ordering=10, name='98/99', start_date= '1998-10-31') Year(current=False, ordering=11, name='99/00', start_date= '1999-10-31') Year(current=False, ordering=12, name='00/01', start_date= '2000-10-31') Year(current=False, ordering=13, name='01/02', start_date= '2001-10-31') Year(current=False, ordering=14, name='02/03', start_date= '2002-10-31') Year(current=False, ordering=15, name='03/04', start_date= '2003-10-31') Year(current=False, ordering=16, name='04/05', start_date= '2004-10-31') Year(current=False, ordering=17, name='05/06', start_date= '2005-10-31') Year(current=True, ordering=18, name='06/07', start_date= '2006-10-31') Year(current=False, ordering=19, name='07/08', start_date='2007-10-31') Year(current=False, ordering=20, name='08/09', start_date='2008-10-31') Year(current=False, ordering=21, name='09/10', start_date='2009-10-31') Year(current=False, ordering=22, name='10/11', start_date='2010-10-31') Module(code='PH319', name='Philosophy of Thought and Language', ) Module(code='PH329', name='Philosophy of Logic', ) Module(code="PH128", name="") Module(code="PH129", name="") Module(code="PH130", name="") #report format field0 = ReportField(name="Attendance") field1 = ReportField(name="Written work",size=3) field2 = ReportField(name="Predicted grade",field_type="select-one", options=["[unspecified]","I predict a first-class grade", "I predict a second-class grade", "I predict a third-class grade", "I have no view"]) rf_test = ReportFormat(name="Warwick.test", fields=[field0, field1, field2]) f0 = ReportField(name="Attendance at Lectures") f1 = ReportField(name="Attendance at Seminars") f2 = ReportField(name="Contribution to Seminars", size=3) f3 = ReportField(name="Written Work", size=3) f4 = ReportField(name="Other Comments", size=3) f5 = ReportField(name="Recommended Action", field_type="select-one", options=["I have no particular views", "I recommend a letter is written", "I recommend a letter is not written", ]) rf = ReportFormat(name="Warwick.philosophy", fields=[f0,f1,f2,f3,f4,f5]) create_feedback_format() #student and note student = Student(firstname="Joan",lastname="of Arc",code="S123456789") note = StudentNote(student=student,staff=staff, subject="test note", body="body of test note") def _fix_year_start_dates(): "temporary function to add start dates onto years" for x in range(89,99): name=str(x)+"/"+str(x+1) y=Year.byName(name) #print name,y.start_date y.start_date= '19'+str(x)+'-10-31' #datetime.date(datetime(x,10,31)) y=Year.byName("99/00") y.start_date='1999-10-31' for x in range(0,9): name="0"+str(x)+"/"+"0"+str(x+1) y=Year.byName(name) print name,y.start_date y.start_date= '200'+str(x)+'-10-31' #datetime.date(datetime(x,10,31)) y=Year.byName("09/10") y.start_date='2009-10-31' y=Year.byName("10/11") y.start_date='2010-10-31' dict(name='10/11', start_date= time.strptime('31-10-10','%d-%m-%y') ) def upload_all(): """uploads a bunch of files to get started""" print "depts" file = open("warwick data/import-dept-degree.csv") print file_upload.depts(file,delimiter=",") print "degrees" file = open("warwick data/import-dept-degree.csv") print file_upload.degrees(file,delimiter=",") print "modules 1" file = open("warwick data/allModules-bar.txt") print file_upload.modules(file,delimiter="|") print "modules 2" file = open("warwick data/cam_mod.bar") print file_upload.modules(file,delimiter="|") print "sits spr" file = open("warwick data/cam_spr.bar") print file_upload.sits_spr(file,delimiter="|") print "omr 1" file = open("warwick data/dept phil pt1.txt") print file_upload.omr(file,delimiter="|") print "omr 2" #first create missing modules missing_codes = ['LL130', 'PH244', 'PH246', 'PH248', 'PH249', 'MA251', 'MA249', 'PH335', 'PH334', 'PH245', 'PH330', 'SO236', 'CS246', 'CS242', 'CS245', 'CS239', 'EC334', 'EC333', 'EC228', 'LL228', 'EN234', 'EN334', 'HA244', 'HA248', 'EN336', 'EN335', 'PS201', 'LL227'] for code in missing_codes: Module(code=code, name="unknown") file = open("warwick data/dept phil pt2.txt") print file_upload.omr(file,delimiter="|")