Esempio n. 1
0
def make_test_exam(number):
    test_file = open('test.txt', 'w+')
    test_file.write('This is a test file.')
    test_exam = Exam(course_instance=CourseInstance.objects.get(pk=number),
                     exam_number=Exam.MT1,
                     exam_type=Exam.EXAM,
                     verified=True,
                     exam_file=File(test_file))
    test_exam.save()
    test_exam.course.department.save()
    test_exam.course.save()
    test_exam.course_instance.save()
    return test_exam
Esempio n. 2
0
 def setUp(self):
     self.dept_cs = Department(long_name='Computer Science',
                               short_name='CS',
                               abbreviation='COMPSCI')
     self.dept_cs.save()
     self.dept_ee = Department(long_name='Electrical Engineering',
                               short_name='EE',
                               abbreviation='EL ENG')
     self.dept_ee.save()
     self.course_cs_1 = Course(department=self.dept_cs, number='1')
     self.course_cs_1.save()
     self.course_ee_1 = Course(department=self.dept_ee, number='1')
     self.course_ee_1.save()
     self.instructor_cs = Instructor(first_name='Tau',
                                     last_name='Bate',
                                     department=self.dept_cs)
     self.instructor_cs.save()
     self.instructor_ee = Instructor(first_name='Pi',
                                     last_name='Bent',
                                     department=self.dept_ee)
     self.instructor_ee.save()
     self.term = Term(term='sp', year=2013, current=True)
     self.term.save()
     self.course_instance_cs_1 = CourseInstance(term=self.term,
                                                course=self.course_cs_1)
     self.course_instance_cs_1.save()
     self.course_instance_cs_1.instructors.add(self.instructor_cs)
     self.course_instance_cs_1.save()
     self.course_instance_ee_1 = CourseInstance(term=self.term,
                                                course=self.course_ee_1)
     self.course_instance_ee_1.save()
     self.course_instance_ee_1.instructors.add(self.instructor_ee)
     self.course_instance_ee_1.save()
     self.user = get_user_model().objects.create_user(
         username='******',
         email='tbp.berkeley.edu',
         password='******',
         first_name='tbp',
         last_name='user')
     self.user.save()
     self.survey_cs_1 = Survey(course=self.course_cs_1,
                               term=self.term,
                               instructor=self.instructor_cs,
                               prof_rating=5,
                               course_rating=5,
                               time_commitment=5,
                               comments='Test comments',
                               submitter=self.user,
                               published=True)
     self.survey_cs_1.save()
     self.survey_cs_1_b = Survey(course=self.course_cs_1,
                                 term=self.term,
                                 instructor=self.instructor_cs,
                                 prof_rating=0,
                                 course_rating=5,
                                 time_commitment=0,
                                 comments='Test comments',
                                 submitter=self.user,
                                 published=True)
     self.survey_cs_1_b.save()
     self.exam_ee_1 = Exam(course_instance=self.course_instance_ee_1,
                           submitter=self.user,
                           exam_number=Exam.FINAL,
                           exam_type=Exam.EXAM,
                           file_ext='.pdf',
                           verified=True)
     self.exam_ee_1.save()
Esempio n. 3
0
    def setUp(self):
        self.candidate_group = Group.objects.create(name='Current Candidate')
        self.member_group = Group.objects.create(name='Member')

        user_model = get_user_model()
        # Create candidate
        self.user = user_model.objects.create_user(
            username='******',
            email='*****@*****.**',
            password='******',
            first_name='Random',
            last_name='Candidate')
        self.term = Term(term=Term.SPRING, year=2012, current=True)
        self.term.save()
        self.candidate = Candidate(user=self.user, term=self.term)
        self.candidate.save()

        # Create officer
        officer_user = user_model.objects.create_user(
            username='******',
            email='*****@*****.**',
            password='******',
            first_name='Joe',
            last_name='Officer')
        committee = OfficerPosition(
            short_name='IT_test',
            long_name='Information Technology (test)',
            rank=2,
            mailing_list='IT')
        committee.save()
        self.officer = Officer(user=officer_user, position=committee,
                               term=self.term, is_chair=False)
        self.officer.save()

        # Create some manual candidate requirements
        self.manual_req1 = ManualCandidateRequirement(
            name='Manual 1',
            requirement_type=CandidateRequirement.MANUAL,
            credits_needed=2,
            term=self.term)
        self.manual_req1.save()
        self.manual_req2 = ManualCandidateRequirement(
            name='Manual 2',
            requirement_type=CandidateRequirement.MANUAL,
            credits_needed=5,
            term=self.term)
        self.manual_req2.save()

        # Create a challenge type
        self.individual_challenge_type = ChallengeType(name='Individual')
        self.individual_challenge_type.save()

        # Create a challenge requirement
        self.challenge_req = ChallengeCandidateRequirement(
            challenge_type=self.individual_challenge_type,
            credits_needed=3,
            term=self.term)
        self.challenge_req.save()

        # Create some events and event requirement
        self.event_type1 = EventType(name='Fun')
        self.event_type1.save()
        self.event_type2 = EventType(name='Not Fun')
        self.event_type2.save()
        self.fun_event1 = Event(name='Fun Event',
                                event_type=self.event_type1,
                                start_datetime=timezone.now(),
                                end_datetime=timezone.now(),
                                term=self.term,
                                location='A test location',
                                contact=officer_user,
                                committee=committee)
        self.fun_event1.save()
        self.fun_event2 = Event(name='Big Fun Event',
                                event_type=self.event_type1,
                                start_datetime=timezone.now(),
                                end_datetime=timezone.now(),
                                requirements_credit=2,
                                term=self.term,
                                location='A test location',
                                contact=officer_user,
                                committee=committee)
        self.fun_event2.save()
        self.notfun_event = Event(name='Not Fun Event',
                                  event_type=self.event_type2,
                                  start_datetime=timezone.now(),
                                  end_datetime=timezone.now(),
                                  term=self.term,
                                  location='A test location',
                                  contact=officer_user,
                                  committee=committee)
        self.notfun_event.save()
        self.event_req = EventCandidateRequirement(
            event_type=self.event_type1,
            credits_needed=4,
            term=self.term)
        self.event_req.save()

        # Create some exam files and exam files requirement
        test_file = open('test.txt', 'w+')
        test_file.write('This is a test file.')
        self.test_exam1 = Exam(
            course_instance=CourseInstance.objects.get(pk=10000),
            exam_number=Exam.MT1,
            exam_type=Exam.EXAM, verified=True, exam_file=File(test_file))
        self.test_exam1.save()
        self.test_exam1.course_instance.course.department.save()
        self.test_exam2 = Exam(
            course_instance=CourseInstance.objects.get(pk=20000),
            exam_number=Exam.MT1,
            exam_type=Exam.EXAM, verified=True, exam_file=File(test_file))
        self.test_exam2.save()
        self.test_exam2.course_instance.course.department.save()
        self.exam_req = ExamFileCandidateRequirement(
            credits_needed=2,
            term=self.term)
        self.exam_req.save()
Esempio n. 4
0
 def setUp(self):
     self.dept_cs = Department(long_name='Computer Science',
                               short_name='CS',
                               abbreviation='COMPSCI')
     self.dept_cs.save()
     self.dept_ee = Department(long_name='Electrical Engineering',
                               short_name='EE',
                               abbreviation='EL ENG')
     self.dept_ee.save()
     self.course_cs_1 = Course(department=self.dept_cs, number='1')
     self.course_cs_1.save()
     self.course_ee_1 = Course(department=self.dept_ee, number='1')
     self.course_ee_1.save()
     self.instructor_cs = Instructor(first_name='Tau',
                                     last_name='Bate',
                                     department=self.dept_cs)
     self.instructor_cs.save()
     self.instructor_ee = Instructor(first_name='Pi',
                                     last_name='Bent',
                                     department=self.dept_ee)
     self.instructor_ee.save()
     self.instructor_ee_2 = Instructor(first_name='Bau',
                                       last_name='Tate',
                                       department=self.dept_ee)
     self.instructor_ee_2.save()
     self.term = Term(term='sp', year=2013, current=True)
     self.term.save()
     self.term2 = Term(term='sp', year=2014, current=False)
     self.term2.save()
     self.course_instance_cs_1 = CourseInstance(term=self.term,
                                                course=self.course_cs_1)
     self.course_instance_cs_1.save()
     self.course_instance_cs_1.instructors.add(self.instructor_cs)
     self.course_instance_cs_1.save()
     self.course_instance_ee_1 = CourseInstance(term=self.term,
                                                course=self.course_ee_1)
     self.course_instance_ee_1.save()
     self.course_instance_ee_1.instructors.add(self.instructor_ee)
     self.course_instance_ee_1.save()
     self.course_instance_ee_2 = CourseInstance(term=self.term2,
                                                course=self.course_ee_1)
     self.course_instance_ee_2.save()
     self.course_instance_ee_2.instructors.add(self.instructor_ee)
     self.course_instance_ee_2.save()
     self.course_instance_ee_3 = CourseInstance(term=self.term2,
                                                course=self.course_ee_1)
     self.course_instance_ee_3.save()
     self.course_instance_ee_3.instructors.add(self.instructor_ee_2)
     self.course_instance_ee_3.save()
     self.user = get_user_model().objects.create_user(
         username='******',
         email='tbp.berkeley.edu',
         password='******',
         first_name='tbp',
         last_name='user')
     self.user.save()
     self.syllabus_cs_1 = Syllabus(
         course_instance=self.course_instance_cs_1,
         submitter=self.user,
         file_ext='.pdf',
         verified=True)
     self.syllabus_cs_1.save()
     # Create exams:
     # ee_1: Course ee1, instr 1 final exam
     # ee_2: Course ee1, instr 1 final solution
     # ee_3: Course ee1, instr 1 final exam
     # ee_4: Course ee1, instr 2 final exam
     self.exam_ee_1 = Exam(course_instance=self.course_instance_ee_1,
                           submitter=self.user,
                           exam_number=Exam.FINAL,
                           exam_type=Exam.EXAM,
                           file_ext='.pdf',
                           verified=True)
     self.exam_ee_1.save()
     self.exam_ee_2 = Exam(course_instance=self.course_instance_ee_1,
                           submitter=self.user,
                           exam_number=Exam.FINAL,
                           exam_type=Exam.SOLN,
                           file_ext='.pdf',
                           verified=True)
     self.exam_ee_2.save()
     self.exam_ee_3 = Exam(course_instance=self.course_instance_ee_2,
                           submitter=self.user,
                           exam_number=Exam.FINAL,
                           exam_type=Exam.EXAM,
                           file_ext='.pdf',
                           verified=True)
     self.exam_ee_3.save()
     self.exam_ee_4 = Exam(course_instance=self.course_instance_ee_3,
                           submitter=self.user,
                           exam_number=Exam.FINAL,
                           exam_type=Exam.EXAM,
                           file_ext='.pdf',
                           verified=True)
     self.exam_ee_4.save()