def create_greg(unit): baker = Person(emplid="123456789", userid="ggbaker", first_name="Greg", last_name="Baker") baker.config['privacy_date'] = date(2008,9,9) baker.config['privacy_version'] = 1 baker.save() for role_tuple in ROLE_CHOICES: role = Role(person=baker, role=role_tuple[0], unit=unit) role.save() return baker
def test_roles(self): # create person an give sysadmin role p1 = Person(emplid=210012345, userid="test1", last_name="Lname", first_name="Fname", pref_first_name="Fn", middle_name="M") p1.save() unit = Unit.objects.get(label="UNIV") r = Role(person=p1, role="SYSA", unit=unit, expiry=TEST_ROLE_EXPIRY) r.save() self.assertEqual(str(r), "Lname, Fname (System Administrator, UNIV)") # check the front end client = Client() client.login_user("test1") url = reverse('sysadmin:role_list') response = basic_page_tests(self, client, url) self.assertContains( response, 'Lname, Fname</a></td>\n <td>System Administrator</td>') # add a new role with the front end oldcount = Role.objects.filter(role='FAC').count() url = reverse('sysadmin:new_role') response = basic_page_tests(self, client, url) response = client.post(url, { 'person': '33333333', 'role': 'FAC', 'unit': 2 }) self.assertEqual(response.status_code, 200) validate_content(self, response.content, url) self.assertTrue( b"could not import DB2 module" in response.content or b"could not connect to reporting database" in response.content or b"Could not find this emplid." in response.content or b"Reporting database access has been disabled" in response.content or b"Could not communicate with reporting database" in response.content) response = client.post( url, { 'person': p1.emplid, 'role': 'FAC', 'unit': unit.id, 'expiry': str(TEST_ROLE_EXPIRY) }) self.assertEqual(response.status_code, 302) # make sure the role is now there self.assertEqual(Role.objects.filter(role='FAC').count(), oldcount + 1)
def missing_instructors(request, unit_slug): unit = get_object_or_404(Unit, slug=unit_slug) if unit not in Unit.sub_units(request.units): return ForbiddenResponse(request, "Not an admin for this unit") # build a set of all instructors that don't have an instructor-appropriate role roles = dict(((r.person, r.role) for r in Role.objects.filter( unit=unit, role__in=INSTR_ROLES).select_related('person'))) missing = set() long_ago = datetime.date.today() - datetime.timedelta(days=365 * 3) instructors = Member.objects.filter(role="INST", offering__owner=unit, offering__semester__start__gte=long_ago) \ .exclude(offering__component='CAN') \ .exclude(person__userid=None) \ .select_related('person') for i in instructors: if i.person not in roles: missing.add(i.person) missing = list(missing) missing.sort() initial = [{'person': p, 'role': None} for p in missing] if request.method == 'POST': formset = InstrRoleFormSet(request.POST, initial=initial) if formset.is_valid(): count = 0 for f in formset.forms: p = f.cleaned_data['person'] r = f.cleaned_data['role'] if r == "NONE" or p not in missing: continue r = Role(person=p, role=r, unit=unit) r.save() count += 1 #LOG EVENT# l = LogEntry(userid=request.user.username, description=("new role: %s as %s") % (p.userid, r), related_object=r) l.save() messages.success(request, 'Set instructor roles for %i people.' % (count)) return HttpResponseRedirect(reverse('coredata.views.unit_admin')) else: formset = InstrRoleFormSet(initial=initial) context = {'formset': formset, 'unit': unit} return render(request, 'coredata/missing_instructors.html', context)
def index(request): userid = request.user.username memberships, excluded = Member.get_memberships(userid) staff_memberships = [ m for m in memberships if m.role in ['INST', 'TA', 'APPR'] ] # for docs link news_list = _get_news_list(userid, 5) roles = Role.all_roles(userid) is_grad = GradStudent.objects.filter( person__userid=userid, current_status__in=STATUS_ACTIVE).exists() has_grads = Supervisor.objects.filter(supervisor__userid=userid, supervisor_type='SEN', removed=False).exists() form_groups = FormGroup.objects.filter( members__userid=request.user.username).exists() has_ras = RAAppointment.objects.filter( hiring_faculty__userid=request.user.username, deleted=False).exists() #messages.add_message(request, messages.SUCCESS, 'Success message.') #messages.add_message(request, messages.WARNING, 'Warning message.') #messages.add_message(request, messages.INFO, 'Info message.') #messages.add_message(request, messages.ERROR, 'Error message.') context = { 'memberships': memberships, 'staff_memberships': staff_memberships, 'news_list': news_list, 'roles': roles, 'is_grad': is_grad, 'has_grads': has_grads, 'has_ras': has_ras, 'excluded': excluded, 'form_groups': form_groups } return render(request, "dashboard/index.html", context)
def student_search(request): # check permissions roles = Role.all_roles(request.user.username) allowed = set(['ADVS', 'ADMN', 'GRAD', 'FUND', 'SYSA']) if not(roles & allowed) and not has_formgroup(request): # doesn't have any allowed roles return ForbiddenResponse(request, "Not permitted to do student search.") if 'term' not in request.GET: return ForbiddenResponse(request, "Must provide 'term' query.") term = request.GET['term'] response = HttpResponse(content_type='application/json') # do the query with Haystack # experimentally, score >= 1 seems to correspond to useful things student_qs = SearchQuerySet().models(Person).filter(text=term)[:20] data = [{'value': r.emplid, 'label': r.search_display} for r in student_qs if r and r.score >= 1 and unicode(r.emplid) not in EXCLUDE_EMPLIDS] # non-haystack version of the above query if len(student_qs) == 0: studentQuery = get_query(term, ['userid', 'emplid', 'first_name', 'last_name']) students = Person.objects.filter(studentQuery)[:20] data = [{'value': s.emplid, 'label': s.search_label_value()} for s in students if unicode(s.emplid) not in EXCLUDE_EMPLIDS] if 'nonstudent' in request.GET and 'ADVS' in roles: nonStudentQuery = get_query(term, ['first_name', 'last_name', 'pref_first_name']) nonStudents = NonStudent.objects.filter(nonStudentQuery)[:10] data.extend([{'value': n.slug, 'label': n.search_label_value()} for n in nonStudents]) #data.sort(key = lambda x: x['label']) json.dump(data, response, indent=1) return response
def index(request): userid = request.user.username memberships, excluded = Member.get_memberships(userid) staff_memberships = [m for m in memberships if m.role in ['INST', 'TA', 'APPR']] # for docs link is_instructor = len([m for m in memberships if m.role == 'INST']) > 0 # For TUGs link news_list = _get_news_list(userid, 5) roles = Role.all_roles(userid) is_grad = GradStudent.objects.filter(person__userid=userid, current_status__in=STATUS_ACTIVE).exists() has_grads = Supervisor.objects.filter(supervisor__userid=userid, supervisor_type='SEN', removed=False).exists() form_groups = FormGroup.objects.filter(members__userid=request.user.username).exists() has_ras = RAAppointment.objects.filter(hiring_faculty__userid=request.user.username, deleted=False).exists() # Only CMPT admins should see the one different TA module. Only non-CMPT TA Admins should see the other. # re-factored to take into account the very few people who should see both (mainly FAS Departmental Admins) cmpt_taadmn = Role.objects_fresh.filter(person__userid=userid, role='TAAD', unit__label='CMPT').exists() other_taadmn = Role.objects_fresh.filter(person__userid=userid, role='TAAD').exclude(unit__label='CMPT').exists() context = {'memberships': memberships, 'staff_memberships': staff_memberships, 'news_list': news_list, 'roles': roles, 'is_grad':is_grad, 'has_grads': has_grads, 'has_ras': has_ras, 'excluded': excluded, 'form_groups': form_groups, 'cmpt_taadmn': cmpt_taadmn, 'other_taadmn': other_taadmn, 'is_instructor': is_instructor} return render(request, "dashboard/index.html", context)
def index(request): userid = request.user.username memberships, excluded = Member.get_memberships(userid) staff_memberships = [m for m in memberships if m.role in ['INST', 'TA', 'APPR']] # for docs link is_instructor = len([m for m in memberships if m.role == 'INST']) > 0 # For TUGs link news_list = _get_news_list(userid, 5) roles = Role.all_roles(userid) is_grad = GradStudent.objects.filter(person__userid=userid, current_status__in=STATUS_ACTIVE).exists() has_grads = Supervisor.objects.filter(supervisor__userid=userid, supervisor_type='SEN', removed=False).exists() form_groups = FormGroup.objects.filter(members__userid=request.user.username).exists() has_ras = RAAppointment.objects.filter(hiring_faculty__userid=request.user.username, deleted=False).exists() # Only CMPT admins should see the one different TA module. Only non-CMPT TA Admins should see the other. # re-factored to take into account the very few people who should see both (mainly FAS Departmental Admins) cmpt_taadmn = Role.objects_fresh.filter(person__userid=userid, role='TAAD', unit__label__in=['CMPT', 'SEE']).exists() other_taadmn = Role.objects_fresh.filter(person__userid=userid, role='TAAD').exclude(unit__label__in=['CMPT', 'SEE']).exists() context = {'memberships': memberships, 'staff_memberships': staff_memberships, 'news_list': news_list, 'roles': roles, 'is_grad':is_grad, 'has_grads': has_grads, 'has_ras': has_ras, 'excluded': excluded, 'form_groups': form_groups, 'cmpt_taadmn': cmpt_taadmn, 'other_taadmn': other_taadmn, 'is_instructor': is_instructor} return render(request, "dashboard/index.html", context)
def missing_instructors(request, unit_slug): unit = get_object_or_404(Unit, slug=unit_slug) if unit not in Unit.sub_units(request.units): return ForbiddenResponse(request, "Not an admin for this unit") # build a set of all instructors that don't have an instructor-appropriate role roles = dict(((r.person, r.role) for r in Role.objects.filter(unit=unit, role__in=INSTR_ROLES).select_related('person'))) missing = set() long_ago = datetime.date.today() - datetime.timedelta(days=365*3) instructors = Member.objects.filter(role="INST", offering__owner=unit, offering__semester__start__gte=long_ago) \ .exclude(offering__component='CAN') \ .exclude(person__userid=None) \ .select_related('person') for i in instructors: if i.person not in roles: missing.add(i.person) missing = list(missing) missing.sort() initial = [{'person': p, 'role': None} for p in missing] if request.method == 'POST': formset = InstrRoleFormSet(request.POST, initial=initial) if formset.is_valid(): count = 0 for f in formset.forms: p = f.cleaned_data['person'] r = f.cleaned_data['role'] if r == "NONE" or p not in missing: continue r = Role(person=p, role=r, unit=unit) r.save() count += 1 #LOG EVENT# l = LogEntry(userid=request.user.username, description=("new role: %s as %s") % (p.userid, r), related_object=r) l.save() messages.success(request, 'Set instructor roles for %i people.' % (count)) return HttpResponseRedirect(reverse('coredata.views.unit_admin')) else: formset = InstrRoleFormSet(initial=initial) context = {'formset': formset, 'unit': unit} return render(request, 'coredata/missing_instructors.html', context)
def config(request): users = Person.objects.filter(userid=request.user.username) if users.count() == 1: user = users[0] else: return NotFoundResponse(request, errormsg="Your account is not known to this system. There is nothing to configure.") # calendar config config = _get_calendar_config(user) if 'token' not in config: caltoken = None else: caltoken = config['token'] # feed config configs = UserConfig.objects.filter(user=user, key="feed-token") if not configs: newstoken = None else: newstoken = configs[0].value['token'] # news config configs = UserConfig.objects.filter(user=user, key="newsitems") # By default, users get emails for news items unless they specifically opted-out. The value here doesn't # change any data, it just displays the same thing as if someone had a UserConfig where they specifically set # email to True. if not configs: newsconfig = {'email': True} else: newsconfig = configs[0].value # advisor note API config advisortoken = None advisor = False if has_role('ADVS', request): advisor = True configs = UserConfig.objects.filter(user=user, key='advisor-token') if len(configs) > 0: advisortoken = configs[0].value['token'] # ID photo agreement instructor = False photo_agreement = False if Member.objects.filter(person=user, role__in=['INST', 'TA']).count() > 0: instructor = True configs = UserConfig.objects.filter(user=user, key='photo-agreement') if len(configs) > 0: photo_agreement = configs[0].value['agree'] # privacy config roles = Role.all_roles(user.userid) roles_with_privacy = [r for r in roles if r in PRIVACY_ROLES] privacy_visible = len(roles_with_privacy) > 0 context={'caltoken': caltoken, 'newstoken': newstoken, 'newsconfig': newsconfig, 'advisor': advisor, 'advisortoken': advisortoken, 'instructor': instructor, 'photo_agreement': photo_agreement, 'userid': user.userid, 'server_url': settings.BASE_ABS_URL, 'privacy_visible': privacy_visible} return render(request, "dashboard/config.html", context)
def create_true_core(): """ Just enough data to bootstrap a minimal environment. """ import_semester_info(dry_run=False, verbose=False, long_long_ago=True, bootstrap=True) p = find_person('ggbaker') p.emplid = '200000100' p.save() u = Unit(label='UNIV', name='Simon Fraser University') u.save() r = Role(person=p, role='SYSA', unit=u) r.save() return itertools.chain( Semester.objects.filter(name__gt=SEMESTER_CUTOFF), Person.objects.filter(userid='ggbaker'), Unit.objects.all(), Role.objects.all(), )
def search_scholarships_by_student(request, student_id): #check permissions roles = Role.all_roles(request.user.username) allowed = set(['FUND']) if not (roles & allowed): return ForbiddenResponse(request, "Not permitted to search scholarships by student.") scholarships = Scholarship.objects.filter(student__person__emplid=student_id) response = HttpResponse(content_type="application/json") data = [{'value': s.pk, 'display': s.scholarship_type.unit.label + ": " + s.scholarship_type.name + " (" + s.start_semester.name + " to " + s.end_semester.name + ")"} for s in scholarships] json.dump(data, response, indent=1) return response
def create_true_core(): """ Just enough data to bootstrap a minimal environment. """ import_semester_info(dry_run=False, verbose=False, long_long_ago=True, bootstrap=True) p = find_person('ggbaker') p.emplid = '200000100' p.first_name = 'Gregorʏ' p.pref_first_name = 'Greg' p.save() u = Unit(label='UNIV', name='Simon Fraser University') u.save() r = Role(person=p, role='SYSA', unit=u, expiry=role_expiry) r.save() return itertools.chain( Semester.objects.filter(name__gt=SEMESTER_CUTOFF), Person.objects.filter(userid='ggbaker'), Unit.objects.all(), Role.objects.all(), )
def test_roles(self): # create person an give sysadmin role p1 = Person(emplid=210012345, userid="test1", last_name="Lname", first_name="Fname", pref_first_name="Fn", middle_name="M") p1.save() unit = Unit.objects.get(label="UNIV") r = Role(person=p1, role="SYSA", unit=unit) r.save() self.assertEqual( str(r), "Lname, Fname (System Administrator, UNIV)") # check the front end client = Client() client.login_user("test1") url = reverse('coredata.views.role_list') response = basic_page_tests(self, client, url) self.assertContains(response, 'Lname, Fname</a></td><td>System Administrator</td>') # add a new role with the front end oldcount = Role.objects.filter(role='FAC').count() url = reverse('coredata.views.new_role') response = basic_page_tests(self, client, url) response = client.post(url, {'person':'33333333', 'role':'FAC', 'unit': 2}) self.assertEquals(response.status_code, 200) validate_content(self, response.content, url) self.assertTrue("could not import DB2 module" in response.content or "could not connect to reporting database" in response.content or "Could not find this emplid." in response.content or "Reporting database access has been disabled" in response.content or "Could not communicate with reporting database" in response.content) response = client.post(url, {'person':p1.emplid, 'role':'FAC', 'unit':unit.id}) self.assertEquals(response.status_code, 302) # make sure the role is now there self.assertEquals( Role.objects.filter(role='FAC').count(), oldcount+1)
def index(request): userid = request.user.username memberships, excluded = Member.get_memberships(userid) staff_memberships = [ m for m in memberships if m.role in ['INST', 'TA', 'APPR'] ] # for docs link is_instructor = len([m for m in memberships if m.role == 'INST' ]) > 0 # For TUGs link news_list = _get_news_list(userid, 5) roles = Role.all_roles(userid) is_grad = GradStudent.objects.filter( person__userid=userid, current_status__in=STATUS_ACTIVE).exists() has_grads = Supervisor.objects.filter( supervisor__userid=userid, supervisor_type__in=['SEN', 'COM', 'COS'], removed=False).exists() form_groups = FormGroup.objects.filter( members__userid=request.user.username).exists() has_ras = RAAppointment.objects.filter( hiring_faculty__userid=request.user.username, deleted=False).exists() has_ra_requests = RARequest.objects.filter( Q(supervisor__userid=request.user.username) | Q(author__userid=request.user.username), deleted=False, draft=False).exists() has_reports = AccessRule.objects.filter( person__userid=request.user.username).exists() # Only CMPT admins should see the one different TA module. They can now also see the other module as we hope to # transition them over. cmpt_taadmn = Role.objects_fresh.filter(person__userid=userid, role='TAAD', unit__label='CMPT').exists() context = { 'memberships': memberships, 'staff_memberships': staff_memberships, 'news_list': news_list, 'roles': roles, 'is_grad': is_grad, 'has_grads': has_grads, 'has_ras': has_ras, 'has_ra_requests': has_ra_requests, 'excluded': excluded, 'form_groups': form_groups, 'cmpt_taadmn': cmpt_taadmn, 'is_instructor': is_instructor, 'has_reports': has_reports } return render(request, "dashboard/index.html", context)
def XXX_sims_person_search(request): # check permissions roles = Role.all_roles(request.user.username) allowed = set(['ADVS', 'ADMN', 'GRAD', 'FUND']) if not(roles & allowed): # doesn't have any allowed roles return ForbiddenResponse(request, "Not permitted to do person search.") if 'emplid' not in request.GET: return ForbiddenResponse(request, "Must provide 'emplid' query.") emplid = request.GET['emplid'] response = HttpResponse(content_type='application/json') data = find_person(emplid) json.dump(data, response, indent=1) return response
def student_search(request): # check permissions roles = Role.all_roles(request.user.username) allowed = set(['ADVS', 'ADMN', 'GRAD', 'FUND', 'SYSA']) if not (roles & allowed) and not has_formgroup(request): # doesn't have any allowed roles return ForbiddenResponse(request, "Not permitted to do student search.") if 'term' not in request.GET: return ForbiddenResponse(request, "Must provide 'term' query.") term = request.GET['term'] response = HttpResponse(content_type='application/json') # do the query with Haystack # experimentally, score >= 1 seems to correspond to useful things student_qs = SearchQuerySet().models(Person).filter(text=term)[:20] data = [{ 'value': r.emplid, 'label': r.search_display } for r in student_qs if r and r.score >= 1 and unicode(r.emplid) not in EXCLUDE_EMPLIDS] # non-haystack version of the above query if len(student_qs) == 0: studentQuery = get_query( term, ['userid', 'emplid', 'first_name', 'last_name']) students = Person.objects.filter(studentQuery)[:20] data = [{ 'value': s.emplid, 'label': s.search_label_value() } for s in students if unicode(s.emplid) not in EXCLUDE_EMPLIDS] if 'nonstudent' in request.GET and 'ADVS' in roles: nonStudentQuery = get_query( term, ['first_name', 'last_name', 'pref_first_name']) nonStudents = NonStudent.objects.filter(nonStudentQuery)[:10] data.extend([{ 'value': n.slug, 'label': n.search_label_value() } for n in nonStudents]) #data.sort(key = lambda x: x['label']) json.dump(data, response, indent=1) return response
def XXX_sims_person_search(request): # check permissions roles = Role.all_roles(request.user.username) allowed = set(['ADVS', 'ADMN', 'GRAD', 'FUND']) if not (roles & allowed): # doesn't have any allowed roles return ForbiddenResponse(request, "Not permitted to do person search.") if 'emplid' not in request.GET: return ForbiddenResponse(request, "Must provide 'emplid' query.") emplid = request.GET['emplid'] response = HttpResponse(content_type='application/json') data = find_person(emplid) json.dump(data, response, indent=1) return response
def create_others(): """ Create other users for the test data set """ p = Person(emplid=fake_emplid(), first_name="Susan", last_name="Kindersley", pref_first_name="sumo", userid="sumo") p.save() Role(person=p, role="GRPD", unit=Unit.objects.get(slug='cmpt')).save() p = Person(emplid=fake_emplid(), first_name="Danyu", last_name="Zhao", pref_first_name="Danyu", userid="dzhao") p.save() Role(person=p, role="ADVS", unit=Unit.objects.get(slug='cmpt')).save() Role(person=p, role="TAAD", unit=Unit.objects.get(slug='cmpt')).save() Role(person=p, role="GRAD", unit=Unit.objects.get(slug='cmpt')).save() Role(person=p, role="FUND", unit=Unit.objects.get(slug='cmpt')).save() Role(person=p, role="ADMN", unit=Unit.objects.get(slug='cmpt')).save()
def index(request): userid = request.user.username memberships, excluded = Member.get_memberships(userid) staff_memberships = [m for m in memberships if m.role in ['INST', 'TA', 'APPR']] # for docs link news_list = _get_news_list(userid, 5) roles = Role.all_roles(userid) is_grad = GradStudent.objects.filter(person__userid=userid, current_status__in=STATUS_ACTIVE).count() > 0 has_grads = Supervisor.objects.filter(supervisor__userid=userid, supervisor_type='SEN', removed=False).count() > 0 form_groups = FormGroup.objects.filter(members__userid=request.user.username).count() > 0 #messages.add_message(request, messages.SUCCESS, 'Success message.') #messages.add_message(request, messages.WARNING, 'Warning message.') #messages.add_message(request, messages.INFO, 'Info message.') #messages.add_message(request, messages.ERROR, 'Error message.') context = {'memberships': memberships, 'staff_memberships': staff_memberships, 'news_list': news_list, 'roles': roles, 'is_grad':is_grad, 'has_grads': has_grads, 'excluded': excluded, 'form_groups': form_groups} return render(request, "dashboard/index.html", context)
def create_others(): """ Create other users for the test data set """ p = Person(emplid=fake_emplid(), first_name="Susan", last_name="Kindersley", pref_first_name="sumo", userid="sumo") p.save() r = Role(person=p, role="GRAD", unit=Unit.objects.get(slug='cmpt')) r.save() p = Person(emplid=fake_emplid(), first_name="Danyu", last_name="Zhao", pref_first_name="Danyu", userid="dzhao") p.save() set_privacy_signed(p) r = Role(person=p, role="ADVS", unit=Unit.objects.get(slug='cmpt')) r.save() r = Role(person=Person.objects.get(userid='dixon'), role="PLAN", unit=Unit.objects.get(slug='cmpt')) r.save() r = Role(person=Person.objects.get(userid='ggbaker'), role="FAC", unit=Unit.objects.get(slug='cmpt')) r.save() r = Role(person=Person.objects.get(userid='dixon'), role="FAC", unit=Unit.objects.get(slug='cmpt')) r.save() r = Role(person=Person.objects.get(userid='diana'), role="FAC", unit=Unit.objects.get(slug='cmpt')) r.save() p = Person.objects.get(userid='ggbaker') set_privacy_signed(p) r = Role(person=p, role="GRAD", unit=Unit.objects.get(slug='cmpt')) r.save() r = Role(person=p, role="ADMN", unit=Unit.objects.get(slug='cmpt')) r.save() r = Role(person=p, role="TAAD", unit=Unit.objects.get(slug='cmpt')) r.save() r = Role(person=p, role="FUND", unit=Unit.objects.get(slug='cmpt')) r.save() r = Role(person=Person.objects.get(userid='popowich'), role="GRPD", unit=Unit.objects.get(slug='cmpt')) r.save()
def create_more_data(): """ More data for the unit tests and general usabilty of a test system """ templates = [ {"field": "contact_email_text", "label": "generic", "text": "DESCRIPTION OF INCIDENT. This does not usually occur unless there is a violation of SFU's Code of Academic Integrity and Good Conduct, Policy S10.01. I take academic honesty very seriously and intend to pursue this apparent violation of SFU's standards for academic honesty.\r\n\r\nAs required by SFU Policy S10.02, Principles and Procedures for Academic Discipline, I am offering you the opportunity to meet with me to discuss this incident. You are not required to accept this offer. If you would like to meet, please contact me to make an appointment outside of my regular office hours.\r\n\r\nYou may wish to refer to SFU's policies and procedures on academic integrity,\r\n http://www.sfu.ca/policies/Students/index.html .\r\nYou can also contact the Office of the Ombudsperson for assistance in navigating University procedures.\r\n"}, {"field": "contact_email_text", "label": "not your work", "text": "Your submission for {{ACTIVITIES}} contains work that does not appear to be your own. This indicates that there is a violation of SFU's Code of Academic Integrity and Good Conduct, Policy S10.01. I take academic honesty very seriously and intend to pursue this apparent violation of SFU's standards for academic honesty.\r\n\r\nAs required by SFU Policy S10.02, Principles and Procedures for Academic Discipline, I am offering you the opportunity to meet with me to discuss this incident. You are not required to accept this offer. If you would like to meet, please contact me to make an appointment outside of my regular office hours.\r\n\r\nYou may wish to refer to SFU's policies and procedures on academic integrity,\r\n http://www.sfu.ca/policies/Students/index.html .\r\nYou can also contact the Office of the Ombudsperson for assistance in navigating University procedures.\r\n"}, {"field": "facts", "label": "attachment", "text": "See details in attached file facts.pdf."}, {"field": "contact_email_text", "label": "simiar work (group)", "text": "You and other students submitted very similar work on {{ACTIVITIES}}. This level of similarity does not usually occur unless collaboration exceeds the limits allowed by SFU's Code of Academic Integrity and Good Conduct, Policy S10.01. I take academic honesty very seriously and intend to pursue this apparent violation of SFU's standards for academic honesty.\r\n\r\nAs required by SFU Policy S10.02, Principles and Procedures for Academic Discipline, I am offering you the opportunity to meet with me to discuss this incident. You are not required to accept this offer. If you would like to meet, please contact me to make an appointment outside of my regular office hours.\r\n\r\nYou may wish to refer to SFU's policies and procedures on academic integrity,\r\n http://www.sfu.ca/policies/Students/index.html .\r\nYou can also contact the Office of the Ombudsperson for assistance in navigating University procedures.\r\n"}, {"field": "facts", "label": "copied (other knew)", "text": "{{FNAME}} was given a solution to {{ACTIVITIES}} by another student. The other student seems to have completed the work independently. Both students submitted the work as their own."}, {"field": "facts", "label": "copied (without knowledge)", "text": "{{FNAME}} copied the work of another student on {{ACTIVITIES}} without his/her knowledge. Both students submitted the work as their own."}, {"field": "meeting_summary", "label": "admitted", "text": "The student admitted academic dishonesty as described below in \u201cfacts of the case\u201d."}, {"field": "meeting_summary", "label": "quote email", "text": "The student explained the situation in his/her email:\r\n\r\nbq. PASTE QUOTE HERE"}, {"field": "meeting_summary", "label": "explained", "text": "{{FNAME}} explained that..."}, ] for data in templates: t = DisciplineTemplate(**data) t.save() cmpt = Unit.objects.get(slug='cmpt') a = Account(account_number=12345, position_number=12345, title='MSc TA', unit=cmpt) a.save() a = Account(account_number=12346, position_number=12346, title='PhD TA', unit=cmpt) a.save() a = Account(account_number=12347, position_number=12347, title='External TA', unit=cmpt) a.save() a = Account(account_number=12348, position_number=12348, title='Undergrad TA', unit=cmpt) a.save() uc = UserConfig(user=Person.objects.get(userid='dzhao'), key='advisor-token', value={'token': '30378700c0091f34412ec9a082dca267'}) uc.save() uc = UserConfig(user=Person.objects.get(userid='ggbaker'), key='advisor-token', value={'token': '082dca26730378700c0091f34412ec9a'}) uc.save() p = Person(userid='probadmn', emplid='200002387', first_name='Problem', last_name='Admin') p.save() uc = UserConfig(user=p, key='problems-token', value={'token': '30378700c0091f34412ec9a082dca268'}) uc.save() p = Person(userid='teachadm', emplid='200002388', first_name='Teaching', last_name='Admin') p.save() r = Role(person=p, role="TADM", unit=Unit.objects.get(slug='cmpt')) r.save() #sp = SemesterPlan(semester=Semester.objects.get(name=TEST_SEMESTER), name='Test Plan', unit=Unit.objects.get(slug='cmpt'), slug='test-plan') #sp.save() #o = PlannedOffering(plan=sp, course=Course.objects.get(slug='cmpt-102'), section='D100', campus='BRNBY', enrl_cap=100) #o.save() #PlanningCourse.create_for_unit(Unit.objects.get(slug='cmpt')) #te = TeachingEquivalent(pk=1, instructor=Person.objects.get(userid='ggbaker'), semester=Semester.objects.get(name=TEST_SEMESTER), credits_numerator=1, credits_denominator=1, summary="Foo", status='UNCO') #te.save() #ti = TeachingIntention(instructor=Person.objects.get(userid='ggbaker'), semester=Semester.objects.get(name=TEST_SEMESTER), count=2) #ti.save() #tc = TeachingCapability(instructor=Person.objects.get(userid='ggbaker'), course=Course.objects.get(slug='cmpt-102'), note='foo') #tc.save() p = Person(userid='classam', emplid='200002389', first_name='Curtis', last_name='Lassam') p.save() r = Role(person=p, role="TECH", unit=Unit.objects.get(slug='cmpt')) r.save() r = Role(person=p, role="SYSA", unit=Unit.objects.get(slug='cmpt')) r.save() # create some faculty roles members = Member.objects.filter(role='INST', offering__owner__slug='cmpt') instr = set(m.person for m in members) faculty = random.sample(instr, 10) for p in faculty: Role.objects.get_or_create(person=p, role='FAC', unit=cmpt)
def expiring_roles(): if settings.DO_IMPORTING_HERE: Role.warn_expiring() Role.purge_expired()
def create_ta_ra(): """ Build test data for the ta and ra modules. """ from ta.models import CourseDescription, TAPosting, TAApplication, CoursePreference, TAContract, TACourse from ta.models import TAKEN_CHOICES, EXPER_CHOICES from ra.models import Account, Project, SemesterConfig, RAAppointment from ra.models import HIRING_CATEGORY_CHOICES, HIRING_CATEGORY_DISABLED # TAs d = Person.objects.get(userid='dzhao') unit = Unit.objects.get(slug='cmpt') r1 = Role(person=d, role='TAAD', unit=unit, expiry=role_expiry) r1.save() r2 = Role(person=d, role='FUND', unit=unit, expiry=role_expiry) r2.save() s = Semester.current().next_semester() admin = Person.objects.get(userid='dixon') CourseDescription(unit=unit, description="Office/Marking", labtut=False).save() CourseDescription(unit=unit, description="Office/Marking/Lab", labtut=True).save() a = Account(account_number=12345, position_number=12345, title='MSc TA', unit=unit) a.save() a = Account(account_number=12346, position_number=12346, title='PhD TA', unit=unit) a.save() a = Account(account_number=12347, position_number=12347, title='External TA', unit=unit) a.save() a = Account(account_number=12348, position_number=12348, title='Undergrad TA', unit=unit) a.save() post = TAPosting(semester=s, unit=unit) post.opens = s.start - datetime.timedelta(100) post.closes = s.start - datetime.timedelta(20) post.set_salary([972, 972, 972, 972]) post.set_scholarship([135, 340, 0, 0]) post.set_accounts([ Account.objects.get(account_number=12345).id, Account.objects.get(account_number=12346).id, Account.objects.get(account_number=12347).id, Account.objects.get(account_number=12348).id ]) post.set_start(s.start) post.set_end(s.end) post.set_deadline(s.start - datetime.timedelta(10)) post.set_payperiods(7.5) post.set_contact(admin.id) post.set_offer_text( "This is **your** TA öffer.\n\nThere are various conditions that are töö numerous to list here." ) post.save() offerings = list(post.selectable_offerings()) for p in Person.objects.filter(last_name='Grad'): app = TAApplication(posting=post, person=p, category=random.choice(['GTA1', 'GTA2']), current_program='CMPT', sin='123456789', base_units=random.choice([3, 4, 5])) app.save() will_ta = [] for i, o in enumerate(random.sample(offerings, 5)): t = random.choice(TAKEN_CHOICES)[0] e = random.choice(EXPER_CHOICES)[0] cp = CoursePreference(app=app, course=o.course, rank=i + 1, taken=t, exper=e) cp.save() if random.random() < 0.07 * (5 - i): will_ta.append(o) if will_ta and random.random() < 0.75: c = TAContract(status=random.choice(['NEW', 'OPN', 'ACC'])) c.first_assign(app, post) c.save() for o in will_ta: tac = TACourse(course=o, contract=c, bu=app.base_units) tac.description = tac.default_description() tac.save() # RAs s = Semester.current() superv = list( m.person for m in Member.objects.filter(role='INST').select_related('person')) empl = list( itertools.chain( Person.objects.filter(last_name='Grad'), random.sample(Person.objects.filter(last_name='Student'), 10))) cats = [ c for c, d in HIRING_CATEGORY_CHOICES if c not in HIRING_CATEGORY_DISABLED ] config = SemesterConfig.get_config([unit], s) acct = Account(account_number=12349, position_number=12349, title='NSERC RA', unit=unit) acct.save() proj1 = Project(project_number=987654, fund_number=31, unit=unit) proj1.save() proj2 = Project(project_number=876543, fund_number=13, unit=unit) proj2.save() for i in range(30): p = random.choice(empl) s = random.choice(superv) c = random.choice(cats) freq = random.choice(['B', 'L']) if freq == 'B': payargs = { 'lump_sum_pay': 10000, 'biweekly_pay': 1250, 'pay_periods': 8, 'hourly_pay': 31, 'hours': 40 } else: payargs = { 'lump_sum_pay': 4000, 'biweekly_pay': 0, 'pay_periods': 8, 'hourly_pay': 0, 'hours': 0 } ra = RAAppointment(person=p, sin=123456789, hiring_faculty=s, unit=unit, hiring_category=c, project=random.choice([proj1, proj2]), account=acct, pay_frequency=freq, start_date=config.start_date(), end_date=config.end_date(), **payargs) ra.set_use_hourly(random.choice([True, False])) ra.save() return itertools.chain( [r1, r2], Account.objects.all(), Project.objects.all(), SemesterConfig.objects.all(), RAAppointment.objects.all(), TAPosting.objects.all(), CourseDescription.objects.all(), TAApplication.objects.all(), CoursePreference.objects.all(), TAContract.objects.all(), TACourse.objects.all(), )
def create_grad(): """ Test data for grad, ta, ra """ from grad.models import GradProgram, GradStudent, GradProgramHistory, GradStatus, ScholarshipType, Scholarship, \ OtherFunding, Promise, GradRequirement, CompletedRequirement, LetterTemplate, GradFlag, GradFlagValue, Supervisor cmpt = Unit.objects.get(slug='cmpt') ensc = Unit.objects.get(slug='ensc') mse = Unit.objects.get(slug='mse') # some admin roles d = Person.objects.get(userid='dzhao') r1 = Role(person=d, role='GRAD', unit=cmpt, expiry=role_expiry) r1.save() r2 = Role(person=Person.objects.get(userid='popowich'), role="GRPD", unit=cmpt, expiry=role_expiry) r2.save() roles = [r1, r2] # departmental data st1 = ScholarshipType(unit=cmpt, name='Scholarship-o-rama', eligible=False) st1.save() st2 = ScholarshipType(unit=cmpt, name='Generic Scholarship #8', eligible=True) st2.save() scholarship_types = [st1, st2] templates = [ { "unit": cmpt, "label": "offer", "content": u"Congratulations, {{first_name}}, we would like to offer you admission to the {{program}} program in Computing Science at SFU.\r\n\r\nThis is gööd news. Really." }, { "unit": cmpt, "label": "visa", "content": "This is to confirm that {{title}} {{first_name}} {{last_name}} is currently enrolled as a full time student in the {{program}} in the School of Computing Science at SFU." }, { "unit": cmpt, "label": "Funding", "content": "This is to confirm that {{title}} {{first_name}} {{last_name}} is a student in the School of Computing Science's {{program}} program. {{He_She}} has been employed as follows:\r\n\r\n{% if tafunding %}Teaching assistant responsibilities include providing tutorials, office hours and marking assignments. {{title}} {{last_name}}'s assignments have been:\r\n\r\n{{ tafunding }}{% endif %}\r\n{% if rafunding %}Research assistants assist/provide research services to faculty. {{title}} {{last_name}}'s assignments have been:\r\n\r\n{{ rafunding }}{% endif %}\r\n{% if scholarships %}{{title}} {{last_name}} has received the following scholarships:\r\n\r\n{{ scholarships }}{% endif %}\r\n\r\n{{title}} {{last_name}} is making satisfactory progress." }, ] for data in templates: t = LetterTemplate(**data) t.save() p = GradProgram(unit=cmpt, label='MSc Course', description='MSc Course option') p.save() p = GradProgram(unit=cmpt, label='MSc Proj', description='MSc Project option') p.save() p = GradProgram(unit=cmpt, label='MSc Thesis', description='MSc Thesis option') p.save() p = GradProgram(unit=cmpt, label='PhD', description='Doctor of Philosophy') p.save() p = GradProgram(unit=cmpt, label='Qualifying', description='Qualifying student') p.save() p = GradProgram(unit=cmpt, label='Special', description='Special Arrangements') p.save() gr = GradRequirement(program=p, description='Achieved Speciality') gr.save() for p in GradProgram.objects.filter(unit=cmpt): gr = GradRequirement(program=p, description='Found campus') gr.save() gf = GradFlag(unit=cmpt, label='Dual Degree Program') gf.save() gf = GradFlag(unit=cmpt, label='Co-op') gf.save() grads = list(Person.objects.filter(last_name='Grad')) programs = list(GradProgram.objects.all()) today = datetime.date.today() starts = Semester.objects.filter(start__gt=today - datetime.timedelta(1000), start__lt=today) supervisors = list( set([ m.person for m in Member.objects.filter( role='INST').select_related('person') ])) # create GradStudents (and associated data) in a vaguely realistic way for g in grads + random.sample(grads, 5): # put a few in two programs p = random.choice(programs) start = random.choice(starts) sstart = start.start if random.randint(1, 2) == 1: end = start.offset(random.randint(3, 9)) else: end = None gs = GradStudent(person=g, program=p, research_area=randname(8) + 'ology', campus=random.choice([x for x, _ in CAMPUS_CHOICES]), is_canadian=randnullbool()) gs.save() gph = GradProgramHistory(student=gs, program=p, start_semester=start) gph.save() if random.randint(1, 3) == 1: p2 = random.choice( [p2 for p2 in programs if p != p2 and p.unit == p2.unit]) gph = GradProgramHistory(student=gs, program=p2, start_semester=start.offset( random.randint(1, 4))) gph.save() s = GradStatus(student=gs, status='COMP', start=start, start_date=sstart - datetime.timedelta(days=100)) s.save() if random.randint(1, 4) == 1: s = GradStatus(student=gs, status='REJE', start=start, start_date=sstart - datetime.timedelta(days=80)) s.save() else: s = GradStatus(student=gs, status='OFFO', start=start, start_date=sstart - datetime.timedelta(days=80)) s.save() s = GradStatus(student=gs, status='ACTI', start=start, start_date=sstart) s.save() if end: if random.randint(1, 3): s = GradStatus(student=gs, status='WIDR', start=end, start_date=end.start) s.save() else: s = GradStatus(student=gs, status='GRAD', start=end, start_date=end.start) s.save() gs.update_status_fields() # give some money sch = Scholarship(student=gs, scholarship_type=random.choice(scholarship_types)) sch.amount = 2000 sch.start_semester = start sch.end_semester = start.offset(2) sch.save() of = OtherFunding(student=gs, semester=start.offset(3)) of.amount = 1300 of.description = "Money fell from the sky" of.save() # promise p = Promise(student=gs, start_semester=start, end_semester=start.offset(2), amount=10000) p.save() p = Promise(student=gs, start_semester=start.offset(3), end_semester=start.offset(5), amount=10000) p.save() # flags if random.randint(1, 3) == 1: cr = CompletedRequirement(requirement=gr, student=gs, semester=start.offset(1)) cr.save() if random.randint(1, 4) == 1: gfv = GradFlagValue(flag=gf, student=gs, value=True) gfv.save() # supervisors if random.randint(1, 3) != 1: p = random.choice(supervisors) s = Supervisor(student=gs, supervisor=p, supervisor_type='POT') s.save() if random.randint(1, 2) == 1: s = Supervisor(student=gs, supervisor=p, supervisor_type='SEN') s.save() s = Supervisor(student=gs, supervisor=random.choice(supervisors), supervisor_type='COM') s.save() return itertools.chain( roles, programs, scholarship_types, GradRequirement.objects.all(), LetterTemplate.objects.all(), GradFlag.objects.all(), GradStudent.objects.all(), GradProgramHistory.objects.all(), GradStatus.objects.all(), Scholarship.objects.all(), OtherFunding.objects.all(), Promise.objects.all(), CompletedRequirement.objects.all(), GradFlagValue.objects.all(), Supervisor.objects.all(), )
def create_coredata(): """ Create enough of the coredata.models stuff to run basic tests """ create_units() # restore ggbaker's real emplid so import_offerings will match p = find_person('ggbaker') p.emplid = find_emplid('ggbaker') # import a few more people we definitely need later find_person('popowich') find_person('dixon') find_person('diana') find_person('dzhao') find_person('pba7') # import a limited set of course offerings offerings = import_offerings( import_semesters=import_strms, extra_where="(subject='CMPT' AND (catalog_nbr LIKE '%% 12%%')) " "OR (subject='CMPT' AND (catalog_nbr LIKE '%% 16%%')) " "OR (subject='ENSC' AND (catalog_nbr LIKE '%% 10%%')) ") offerings = list(offerings) offerings.sort() if not CourseOffering.objects.filter(slug=TEST_COURSE_SLUG): o = CourseOffering.objects.filter(subject='CMPT', semester__name=import_strms()[0]) \ .order_by('number', 'section').first() raise ValueError, "courselib.testing.TEST_COURSE_SLUG isn't an offering we have. Maybe use '%s'." % ( o.slug) # import instructors for o in offerings: import_offering_members(o, students=False) # try to guess instructors' userids for p in Person.objects.filter(userid__isnull=True): p.userid = guess_userid(p.emplid) p.save() fake_emplids() # use/import no real emplids after this # create some fake undergrad/grad students for i in range(20): userid = "0aaa%i" % (i) fname = randname(8) p = random.randint(1, 2) if p == 1: pref = fname[:4] else: pref = fname p = Person(emplid=300000300 + i, userid=userid, last_name='Student', first_name=fname, middle_name=randname(6), pref_first_name=pref) p.save() userid = "0ggg%i" % (i) fname = randname(8) p = random.randint(1, 2) if p == 1: pref = fname[:4] else: pref = fname p = Person(emplid=300000500 + i, userid=userid, last_name='Grad', first_name=fname, middle_name=randname(6), pref_first_name=pref) p.config['gender'] = random.choice(('M', 'F', 'U')) p.config['gpa'] = round(random.triangular(0.0, 4.33, 2.33), 2) p.config['visa'] = random.choice([x for x, _ in VISA_STATUSES]) p.config['citizen'] = random.choice(('Canadian', 'OtherCountrian')) p.save() # some memberships/roles/etc assumed by tests o = CourseOffering.objects.get(slug=TEST_COURSE_SLUG) ensure_member(Person.objects.get(userid='ggbaker'), o, "INST", 0, "AUTO", "NONS") ensure_member(Person.objects.get(userid='0ggg0'), o, "TA", 0, "AUTO", "NONS") ensure_member(Person.objects.get(userid='0aaa0'), o, "STUD", 3, "AUTO", "UGRD") ensure_member(Person.objects.get(userid='0aaa1'), o, "STUD", 3, "AUTO", "UGRD") d = Person.objects.get(userid='dzhao') set_privacy_signed(d) u = Unit.objects.get(slug='cmpt') r1 = Role(person=d, role='ADVS', unit=u, expiry=role_expiry) r1.save() r2 = Role(person=d, role='ADMN', unit=u, expiry=role_expiry) r2.save() r3 = Role(person=Person.objects.get(userid='pba7'), role='SYSA', unit=Unit.objects.get(slug='univ'), expiry=role_expiry) r3.save() r4 = Role(person=d, role='INV', unit=u, expiry=role_expiry) r4.save() r5 = Role(person=d, role='OUTR', unit=u, expiry=role_expiry) r5.save() # ensures course appears in menu for students a = NumericActivity(offering=o, name=u'Assignmenț 1', short_name='A1', status='URLS', position=1, percent=10, max_grade=10, due_date=(o.semester.start + datetime.timedelta(days=60))) a.save() return itertools.chain( SemesterWeek.objects.filter(semester__name__gt=SEMESTER_CUTOFF), Unit.objects.all(), Course.objects.all(), CourseOffering.objects.all(), Person.objects.order_by('emplid'), Member.objects.all(), [r1, r2, r3, r4, r5, a.activity_ptr, a], )
def create_coredata(): """ Create enough of the coredata.models stuff to run basic tests """ create_units() # restore ggbaker's real emplid so import_offerings will match p = find_person('ggbaker') p.emplid = find_emplid('ggbaker') # import a few more people we definitely need later find_person('popowich') find_person('dixon') find_person('diana') find_person('dzhao') find_person('pba7') # import a limited set of course offerings offerings = import_offerings(import_semesters=import_strms, extra_where= "(subject='CMPT' AND (catalog_nbr LIKE '%% 12%%')) " "OR (subject='ENSC' AND (catalog_nbr LIKE '%% 10%%')) " ) offerings = list(offerings) offerings.sort() if not CourseOffering.objects.filter(slug=TEST_COURSE_SLUG): o = CourseOffering.objects.filter(subject='CMPT', semester__name=import_strms()[0]) \ .order_by('number', 'section').first() raise ValueError, "courselib.testing.TEST_COURSE_SLUG isn't an offering we have. Maybe use '%s'." % (o.slug) # import instructors for o in offerings: import_offering_members(o, students=False) # try to guess instructors' userids for p in Person.objects.filter(userid__isnull=True): p.userid = guess_userid(p.emplid) p.save() fake_emplids() # use/import no real emplids after this # create some fake undergrad/grad students for i in range(20): userid = "0aaa%i" % (i) fname = randname(8) p = random.randint(1,2) if p == 1: pref = fname[:4] else: pref = fname p = Person(emplid=300000300+i, userid=userid, last_name='Student', first_name=fname, middle_name=randname(6), pref_first_name=pref) p.save() userid = "0ggg%i" % (i) fname = randname(8) p = random.randint(1,2) if p == 1: pref = fname[:4] else: pref = fname p = Person(emplid=300000500+i, userid=userid, last_name='Grad', first_name=fname, middle_name=randname(6), pref_first_name=pref) p.config['gender'] = random.choice(('M','F','U')) p.config['gpa'] = round(random.triangular(0.0, 4.33, 2.33), 2) p.config['visa'] = random.choice([x for x,_ in VISA_STATUSES]) p.config['citizen'] = random.choice(('Canadian', 'OtherCountrian')) p.save() # some memberships/roles/etc assumed by tests o = CourseOffering.objects.get(slug=TEST_COURSE_SLUG) ensure_member(Person.objects.get(userid='ggbaker'), o, "INST", 0, "AUTO", "NONS") ensure_member(Person.objects.get(userid='0ggg0'), o, "TA", 0, "AUTO", "NONS") ensure_member(Person.objects.get(userid='0aaa0'), o, "STUD", 3, "AUTO", "UGRD") ensure_member(Person.objects.get(userid='0aaa1'), o, "STUD", 3, "AUTO", "UGRD") d = Person.objects.get(userid='dzhao') set_privacy_signed(d) r1 = Role(person=d, role='ADVS', unit=Unit.objects.get(slug='cmpt')) r1.save() r2 = Role(person=d, role='ADMN', unit=Unit.objects.get(slug='cmpt')) r2.save() r3 = Role(person=Person.objects.get(userid='pba7'), role='SYSA', unit=Unit.objects.get(slug='univ')) r3.save() # ensures course appears in menu for students a = NumericActivity(offering=o, name='Assignment 1', short_name='A1', status='URLS', position=1, percent=10, max_grade=10, due_date=(o.semester.start + datetime.timedelta(days=60))) a.save() return itertools.chain( SemesterWeek.objects.filter(semester__name__gt=SEMESTER_CUTOFF), Unit.objects.all(), Course.objects.all(), CourseOffering.objects.all(), Person.objects.order_by('emplid'), Member.objects.all(), [r1, r2, r3, a.activity_ptr, a], )
def create_grad(): """ Test data for grad, ta, ra """ from grad.models import GradProgram, GradStudent, GradProgramHistory, GradStatus, ScholarshipType, Scholarship, \ OtherFunding, Promise, GradRequirement, CompletedRequirement, LetterTemplate, GradFlag, GradFlagValue, Supervisor cmpt = Unit.objects.get(slug='cmpt') ensc = Unit.objects.get(slug='ensc') mse = Unit.objects.get(slug='mse') # some admin roles d = Person.objects.get(userid='dzhao') r1 = Role(person=d, role='GRAD', unit=cmpt) r1.save() r2 = Role(person=Person.objects.get(userid='popowich'), role="GRPD", unit=cmpt) r2.save() roles = [r1, r2] # departmental data st1 = ScholarshipType(unit=cmpt, name='Scholarship-o-rama', eligible=False) st1.save() st2 = ScholarshipType(unit=cmpt, name='Generic Scholarship #8', eligible=True) st2.save() scholarship_types = [st1, st2] templates = [ {"unit": cmpt, "label": "offer", "content": "Congratulations, {{first_name}}, we would like to offer you admission to the {{program}} program in Computing Science at SFU.\r\n\r\nThis is good news. Really." }, {"unit": cmpt, "label": "visa", "content": "This is to confirm that {{title}} {{first_name}} {{last_name}} is currently enrolled as a full time student in the {{program}} in the School of Computing Science at SFU." }, {"unit": cmpt, "label": "Funding", "content": "This is to confirm that {{title}} {{first_name}} {{last_name}} is a student in the School of Computing Science's {{program}} program. {{He_She}} has been employed as follows:\r\n\r\n{% if tafunding %}Teaching assistant responsibilities include providing tutorials, office hours and marking assignments. {{title}} {{last_name}}'s assignments have been:\r\n\r\n{{ tafunding }}{% endif %}\r\n{% if rafunding %}Research assistants assist/provide research services to faculty. {{title}} {{last_name}}'s assignments have been:\r\n\r\n{{ rafunding }}{% endif %}\r\n{% if scholarships %}{{title}} {{last_name}} has received the following scholarships:\r\n\r\n{{ scholarships }}{% endif %}\r\n\r\n{{title}} {{last_name}} is making satisfactory progress." }, ] for data in templates: t = LetterTemplate(**data) t.save() p = GradProgram(unit=cmpt, label='MSc Course', description='MSc Course option') p.save() p = GradProgram(unit=cmpt, label='MSc Proj', description='MSc Project option') p.save() p = GradProgram(unit=cmpt, label='MSc Thesis', description='MSc Thesis option') p.save() p = GradProgram(unit=cmpt, label='PhD', description='Doctor of Philosophy') p.save() p = GradProgram(unit=cmpt, label='Qualifying', description='Qualifying student') p.save() p = GradProgram(unit=cmpt, label='Special', description='Special Arrangements') p.save() gr = GradRequirement(program=p, description='Achieved Speciality') gr.save() for p in GradProgram.objects.filter(unit=cmpt): gr = GradRequirement(program=p, description='Found campus') gr.save() gf = GradFlag(unit=cmpt, label='Dual Degree Program') gf.save() gf = GradFlag(unit=cmpt, label='Co-op') gf.save() grads = list(Person.objects.filter(last_name='Grad')) programs = list(GradProgram.objects.all()) today = datetime.date.today() starts = Semester.objects.filter(start__gt=today-datetime.timedelta(1000), start__lt=today) supervisors = list(set([m.person for m in Member.objects.filter(role='INST').select_related('person')])) # create GradStudents (and associated data) in a vaguely realistic way for g in grads + random.sample(grads, 5): # put a few in two programs p = random.choice(programs) start = random.choice(starts) sstart = start.start if random.randint(1,2) == 1: end = start.offset(random.randint(3,9)) else: end = None gs = GradStudent(person=g, program=p, research_area=randname(8)+'ology', campus=random.choice([x for x,_ in CAMPUS_CHOICES]), is_canadian=randnullbool()) gs.save() gph = GradProgramHistory(student=gs, program=p, start_semester=start) gph.save() if random.randint(1,3) == 1: p2 = random.choice([p2 for p2 in programs if p != p2 and p.unit == p2.unit]) gph = GradProgramHistory(student=gs, program=p2, start_semester=start.offset(random.randint(1,4))) gph.save() s = GradStatus(student=gs, status='COMP', start=start, start_date=sstart-datetime.timedelta(days=100)) s.save() if random.randint(1,4) == 1: s = GradStatus(student=gs, status='REJE', start=start, start_date=sstart-datetime.timedelta(days=80)) s.save() else: s = GradStatus(student=gs, status='OFFO', start=start, start_date=sstart-datetime.timedelta(days=80)) s.save() s = GradStatus(student=gs, status='ACTI', start=start, start_date=sstart) s.save() if end: if random.randint(1,3): s = GradStatus(student=gs, status='WIDR', start=end, start_date=end.start) s.save() else: s = GradStatus(student=gs, status='GRAD', start=end, start_date=end.start) s.save() gs.update_status_fields() # give some money sch = Scholarship(student=gs, scholarship_type=random.choice(scholarship_types)) sch.amount = 2000 sch.start_semester = start sch.end_semester = start.offset(2) sch.save() of = OtherFunding(student=gs, semester=start.offset(3)) of.amount = 1300 of.description = "Money fell from the sky" of.save() # promise p = Promise(student=gs, start_semester=start, end_semester=start.offset(2), amount=10000) p.save() p = Promise(student=gs, start_semester=start.offset(3), end_semester=start.offset(5), amount=10000) p.save() # flags if random.randint(1,3) == 1: cr = CompletedRequirement(requirement=gr, student=gs, semester=start.offset(1)) cr.save() if random.randint(1,4) == 1: gfv = GradFlagValue(flag=gf, student=gs, value=True) gfv.save() # supervisors if random.randint(1,3) != 1: p = random.choice(supervisors) s = Supervisor(student=gs, supervisor=p, supervisor_type='POT') s.save() if random.randint(1,2) == 1: s = Supervisor(student=gs, supervisor=p, supervisor_type='SEN') s.save() s = Supervisor(student=gs, supervisor=random.choice(supervisors), supervisor_type='COM') s.save() return itertools.chain( roles, programs, scholarship_types, GradRequirement.objects.all(), LetterTemplate.objects.all(), GradFlag.objects.all(), GradStudent.objects.all(), GradProgramHistory.objects.all(), GradStatus.objects.all(), Scholarship.objects.all(), OtherFunding.objects.all(), Promise.objects.all(), CompletedRequirement.objects.all(), GradFlagValue.objects.all(), Supervisor.objects.all(), )
def create_ta_ra(): """ Build test data for the ta and ra modules. """ from ta.models import CourseDescription, TAPosting, TAApplication, CoursePreference, TAContract, TACourse from ta.models import TAKEN_CHOICES, EXPER_CHOICES from ra.models import Account, Project, SemesterConfig, RAAppointment from ra.models import HIRING_CATEGORY_CHOICES, HIRING_CATEGORY_DISABLED # TAs d = Person.objects.get(userid='dzhao') unit = Unit.objects.get(slug='cmpt') r1 = Role(person=d, role='TAAD', unit=unit) r1.save() r2 = Role(person=d, role='FUND', unit=unit) r2.save() s = Semester.current().next_semester() admin = Person.objects.get(userid='dixon') CourseDescription(unit=unit, description="Office/Marking", labtut=False).save() CourseDescription(unit=unit, description="Office/Marking/Lab", labtut=True).save() a = Account(account_number=12345, position_number=12345, title='MSc TA', unit=unit) a.save() a = Account(account_number=12346, position_number=12346, title='PhD TA', unit=unit) a.save() a = Account(account_number=12347, position_number=12347, title='External TA', unit=unit) a.save() a = Account(account_number=12348, position_number=12348, title='Undergrad TA', unit=unit) a.save() post = TAPosting(semester=s, unit=unit) post.opens = s.start - datetime.timedelta(100) post.closes = s.start - datetime.timedelta(20) post.set_salary([972,972,972,972]) post.set_scholarship([135,340,0,0]) post.set_accounts([Account.objects.get(account_number=12345).id, Account.objects.get(account_number=12346).id, Account.objects.get(account_number=12347).id, Account.objects.get(account_number=12348).id]) post.set_start(s.start) post.set_end(s.end) post.set_deadline(s.start - datetime.timedelta(10)) post.set_payperiods(7.5) post.set_contact(admin.id) post.set_offer_text("This is **your** TA offer.\n\nThere are various conditions that are too numerous to list here.") post.save() offerings = list(post.selectable_offerings()) for p in Person.objects.filter(last_name='Grad'): app = TAApplication(posting=post, person=p, category=random.choice(['GTA1','GTA2']), current_program='CMPT', sin='123456789', base_units=random.choice([3,4,5])) app.save() will_ta = [] for i,o in enumerate(random.sample(offerings, 5)): t = random.choice(TAKEN_CHOICES)[0] e = random.choice(EXPER_CHOICES)[0] cp = CoursePreference(app=app, course=o.course, rank=i+1, taken=t, exper=e) cp.save() if random.random() < 0.07*(5-i): will_ta.append(o) if will_ta and random.random() < 0.75: c = TAContract(status=random.choice(['NEW','OPN','ACC'])) c.first_assign(app, post) c.save() for o in will_ta: tac = TACourse(course=o, contract=c, bu=app.base_units) tac.description = tac.default_description() tac.save() # RAs s = Semester.current() superv = list(m.person for m in Member.objects.filter(role='INST').select_related('person')) empl = list(itertools.chain(Person.objects.filter(last_name='Grad'), random.sample(Person.objects.filter(last_name='Student'), 10))) cats = [c for c,d in HIRING_CATEGORY_CHOICES if c not in HIRING_CATEGORY_DISABLED] config = SemesterConfig.get_config([unit], s) acct = Account(account_number=12349, position_number=12349, title='NSERC RA', unit=unit) acct.save() proj1 = Project(project_number=987654, fund_number=31, unit=unit) proj1.save() proj2 = Project(project_number=876543, fund_number=13, unit=unit) proj2.save() for i in range(30): p = random.choice(empl) s = random.choice(superv) c = random.choice(cats) freq = random.choice(['B', 'L']) if freq == 'B': payargs = {'lump_sum_pay': 10000, 'biweekly_pay': 1250, 'pay_periods': 8, 'hourly_pay': 31, 'hours': 40} else: payargs = {'lump_sum_pay': 4000, 'biweekly_pay': 0, 'pay_periods': 8, 'hourly_pay': 0, 'hours': 0} ra = RAAppointment(person=p, sin=123456789, hiring_faculty=s, unit=unit, hiring_category=c, project=random.choice([proj1,proj2]), account=acct, pay_frequency=freq, start_date=config.start_date(), end_date=config.end_date(), **payargs) ra.set_use_hourly(random.choice([True, False])) ra.save() return itertools.chain( [r1, r2], Account.objects.all(), Project.objects.all(), SemesterConfig.objects.all(), RAAppointment.objects.all(), TAPosting.objects.all(), CourseDescription.objects.all(), TAApplication.objects.all(), CoursePreference.objects.all(), TAContract.objects.all(), TACourse.objects.all(), )
def create_more_data(): """ More data for the unit tests and general usabilty of a test system """ templates = [ { "field": "contact_email_text", "label": "generic", "text": "DESCRIPTION OF INCIDENT. This does not usually occur unless there is a violation of SFU's Code of Academic Integrity and Good Conduct, Policy S10.01. I take academic honesty very seriously and intend to pursue this apparent violation of SFU's standards for academic honesty.\r\n\r\nAs required by SFU Policy S10.02, Principles and Procedures for Academic Discipline, I am offering you the opportunity to meet with me to discuss this incident. You are not required to accept this offer. If you would like to meet, please contact me to make an appointment outside of my regular office hours.\r\n\r\nYou may wish to refer to SFU's policies and procedures on academic integrity,\r\n http://www.sfu.ca/policies/Students/index.html .\r\nYou can also contact the Office of the Ombudsperson for assistance in navigating University procedures.\r\n" }, { "field": "contact_email_text", "label": "not your work", "text": "Your submission for {{ACTIVITIES}} contains work that does not appear to be your own. This indicates that there is a violation of SFU's Code of Academic Integrity and Good Conduct, Policy S10.01. I take academic honesty very seriously and intend to pursue this apparent violation of SFU's standards for academic honesty.\r\n\r\nAs required by SFU Policy S10.02, Principles and Procedures for Academic Discipline, I am offering you the opportunity to meet with me to discuss this incident. You are not required to accept this offer. If you would like to meet, please contact me to make an appointment outside of my regular office hours.\r\n\r\nYou may wish to refer to SFU's policies and procedures on academic integrity,\r\n http://www.sfu.ca/policies/Students/index.html .\r\nYou can also contact the Office of the Ombudsperson for assistance in navigating University procedures.\r\n" }, { "field": "facts", "label": "attachment", "text": "See details in attached file facts.pdf." }, { "field": "contact_email_text", "label": "simiar work (group)", "text": "You and other students submitted very similar work on {{ACTIVITIES}}. This level of similarity does not usually occur unless collaboration exceeds the limits allowed by SFU's Code of Academic Integrity and Good Conduct, Policy S10.01. I take academic honesty very seriously and intend to pursue this apparent violation of SFU's standards for academic honesty.\r\n\r\nAs required by SFU Policy S10.02, Principles and Procedures for Academic Discipline, I am offering you the opportunity to meet with me to discuss this incident. You are not required to accept this offer. If you would like to meet, please contact me to make an appointment outside of my regular office hours.\r\n\r\nYou may wish to refer to SFU's policies and procedures on academic integrity,\r\n http://www.sfu.ca/policies/Students/index.html .\r\nYou can also contact the Office of the Ombudsperson for assistance in navigating University procedures.\r\n" }, { "field": "facts", "label": "copied (other knew)", "text": "{{FNAME}} was given a solution to {{ACTIVITIES}} by another student. The other student seems to have completed the work independently. Both students submitted the work as their own." }, { "field": "facts", "label": "copied (without knowledge)", "text": "{{FNAME}} copied the work of another student on {{ACTIVITIES}} without his/her knowledge. Both students submitted the work as their own." }, { "field": "meeting_summary", "label": "admitted", "text": u"The student admitted academic dishonesty as described below in \u201cfacts of the case\u201d." }, { "field": "meeting_summary", "label": "quote email", "text": "The student explained the situation in his/her email:\r\n\r\nbq. PASTE QUOTE HERE" }, { "field": "meeting_summary", "label": "explained", "text": "{{FNAME}} explained that..." }, ] for data in templates: t = DisciplineTemplate(**data) t.save() cmpt = Unit.objects.get(slug='cmpt') a = Account(account_number=12345, position_number=12345, title='MSc TA', unit=cmpt) a.save() a = Account(account_number=12346, position_number=12346, title='PhD TA', unit=cmpt) a.save() a = Account(account_number=12347, position_number=12347, title='External TA', unit=cmpt) a.save() a = Account(account_number=12348, position_number=12348, title='Undergrad TA', unit=cmpt) a.save() uc = UserConfig(user=Person.objects.get(userid='dzhao'), key='advisor-token', value={'token': '30378700c0091f34412ec9a082dca267'}) uc.save() uc = UserConfig(user=Person.objects.get(userid='ggbaker'), key='advisor-token', value={'token': '082dca26730378700c0091f34412ec9a'}) uc.save() p = Person(userid='probadmn', emplid='200002387', first_name='Problem', last_name='Admin') p.save() uc = UserConfig(user=p, key='problems-token', value={'token': '30378700c0091f34412ec9a082dca268'}) uc.save() p = Person(userid='teachadm', emplid='200002388', first_name='Teaching', last_name='Admin') p.save() r = Role(person=p, role="TADM", unit=Unit.objects.get(slug='cmpt')) r.save() #sp = SemesterPlan(semester=Semester.objects.get(name=TEST_SEMESTER), name='Test Plan', unit=Unit.objects.get(slug='cmpt'), slug='test-plan') #sp.save() #o = PlannedOffering(plan=sp, course=Course.objects.get(slug='cmpt-102'), section='D100', campus='BRNBY', enrl_cap=100) #o.save() #PlanningCourse.create_for_unit(Unit.objects.get(slug='cmpt')) #te = TeachingEquivalent(pk=1, instructor=Person.objects.get(userid='ggbaker'), semester=Semester.objects.get(name=TEST_SEMESTER), credits_numerator=1, credits_denominator=1, summary="Foo", status='UNCO') #te.save() #ti = TeachingIntention(instructor=Person.objects.get(userid='ggbaker'), semester=Semester.objects.get(name=TEST_SEMESTER), count=2) #ti.save() #tc = TeachingCapability(instructor=Person.objects.get(userid='ggbaker'), course=Course.objects.get(slug='cmpt-102'), note='foo') #tc.save() p = Person(userid='classam', emplid='200002389', first_name='Curtis', last_name='Lassam') p.save() r = Role(person=p, role="TECH", unit=Unit.objects.get(slug='cmpt')) r.save() r = Role(person=p, role="SYSA", unit=Unit.objects.get(slug='cmpt')) r.save() # create some faculty roles members = Member.objects.filter(role='INST', offering__owner__slug='cmpt') instr = set(m.person for m in members) faculty = random.sample(instr, 10) for p in faculty: Role.objects.get_or_create(person=p, role='FAC', unit=cmpt)
def handle(self, *args, **options): assert settings.DEPLOY_MODE != 'production' # import public data dumped from production with transaction.atomic(): for obj in serializers.deserialize( 'json', open(options['data_file'], 'rt', encoding='utf8').read()): obj.save() # create fake students and a TA in every offering with transaction.atomic(): fake_students = [ Person(emplid=str(500000000 + i), userid='fake%03i' % (i, ), last_name='Fake', first_name=random_name(8), middle_name=random_name(5), title=random.choice(['Mr', 'M', 'Ms', 'Dr'])) for i in range(n_fake_students) ] for p in fake_students: p.pref_first_name = random.choice([None, p.first_name[:4]]) p.save() fake_grads = [ Person(emplid=str(510000000 + i), userid='grad%03i' % (i, ), last_name='Grad', first_name=random_name(8), middle_name=random_name(5), title=random.choice(['Mr', 'M', 'Ms', 'Dr'])) for i in range(n_fake_grads) ] for p in fake_grads: p.pref_first_name = random.choice([None, p.first_name[:4]]) p.save() for o in CourseOffering.objects.all(): ta_person = random.choice(fake_grads) m = Member(person=ta_person, offering=o, role='TA', added_reason='AUTO', credits=0, career='NONS') m.save() student_people = set( random.choices(fake_students, k=students_per_class)) for p in student_people: m = Member(person=p, offering=o, role='STUD', added_reason='AUTO', credits=3, career='UGRD') m.save() r = Role(person=Person.objects.get(userid='ggbaker'), role='SYSA', unit=Unit.objects.get(label='UNIV'), expiry=datetime.date.today() + datetime.timedelta(days=730)) r.save()