Exemplo n.º 1
0
 def test_view_ta_assignments_single_ta_multiple_course_as_ta(self):
     self.ui.login("usrTA", "password")
     test_ta2 = Account(user="******", password="******", role="TA")
     test_ta2.save()
     test_course = Course(name="CS103",
                          section="222",
                          days_of_week="M/W/F",
                          start_time="12:00",
                          end_time="13:00",
                          instructor=self.tst_instructor,
                          lab="333")
     test_course.save()
     test_course.tas.add(self.tst_ta)
     test_course2 = Course(name="CS104",
                           section="223",
                           days_of_week="M/W/F",
                           start_time="14:00",
                           end_time="15:00",
                           instructor=self.tst_instructor,
                           lab="363")
     test_course2.save()
     test_course2.tas.add(test_ta2)
     expected_output = "<p>Course: " + test_course.name + ", Section: " + test_course.section + \
                       ", TA(s): " + self.tst_ta.user + " </p><br />" + \
                       "<p>Course: " + test_course2.name + ", Section: " + test_course2.section + \
                       ", TA(s): " + test_ta2.user + " </p><br />"
     actual_output = self.ui.view_ta_assignments()
     self.assertEqual(expected_output, actual_output)
Exemplo n.º 2
0
def usercourse():

    u = User.query.filter_by(user_name="alireza").first()
    cour1 = Course(course_title="ساختمان داده",
                   course_description="ساختمان داده ارائه شده در این ترم",
                   course_date="پاییز-96")

    u.course_auth.append(cour1)
    db.session.add(cour1)
    db.session.commit()
Exemplo n.º 3
0
 def test_view_course_assignments_no_instructor_as_administrator(self):
     self.ui.login('usrAdministrator', 'password')
     test_course = Course(name="CS103",
                          section="222",
                          days_of_week="M/W/F",
                          start_time="12:00",
                          end_time="13:00",
                          lab="333")
     test_course.save()
     test_course2 = Course(name="CS104",
                           section="223",
                           days_of_week="M/W/F",
                           start_time="14:00",
                           end_time="15:00",
                           instructor=self.tst_instructor,
                           lab="363")
     test_course2.save()
     expected_output = "<p>Course: " + test_course2.name + ", Instructor: " + self.tst_instructor.user + "</p><br />"
     actual_output = self.ui.view_course_assignments()
     self.assertEqual(expected_output, actual_output)
Exemplo n.º 4
0
 def test_view_ta_assignments_single_ta_single_course_as_administrator(self):
     self.ui.login("usrAdministrator", "password")
     test_course = Course(name="CS103",
                          section="222",
                          days_of_week="M/W/F",
                          start_time="12:00",
                          end_time="13:00",
                          instructor=self.tst_instructor,
                          lab="333")
     test_course.save()
     test_course.tas.add(self.tst_ta)
     expected_output = "<p>Course: " + test_course.name + ", Section: " + test_course.section + ", TA(s): " + self.tst_ta.user + " </p><br />"
     actual_output = self.ui.view_ta_assignments()
     self.assertEqual(expected_output, actual_output)
Exemplo n.º 5
0
 def test_view_course_assignments_multiple_courses_multiple_instructors_as_administrator(self):
     self.ui.login('usrAdministrator', 'password')
     test_instructor2 = Account(user='******', password='******', role='Instructor')
     test_instructor2.save()
     test_course1 = Course(name="CS103",
                           section="222",
                           days_of_week="M/W/F",
                           start_time="12:00",
                           end_time="13:00",
                           instructor=self.tst_instructor,
                           lab="333")
     test_course1.save()
     test_course2 = Course(name="CS104",
                           section="223",
                           days_of_week="M/W/F",
                           start_time="14:00",
                           end_time="15:00",
                           instructor=test_instructor2,
                           lab="363")
     test_course2.save()
     expected_output = "<p>Course: " + test_course1.name + ", Instructor: " + self.tst_instructor.user + "</p><br />" + \
                       "<p>Course: " + test_course2.name + ", Instructor: " + test_instructor2.user + "</p><br />"
     actual_output = self.ui.view_course_assignments()
     self.assertEqual(expected_output, actual_output)
Exemplo n.º 6
0
    def create_course(self, name="", section="", days="", time="", labs=""):
        cur_user_role = self.get_current_user().role
        if cur_user_role != "Supervisor" and cur_user_role != "Administrator":
            return "You do not have permissions to create courses"
        if name == "" or section == "" or days == "" or time == "" or labs == "":
            return "Please input valid arguments for all fields to create a course"
        else:
            d = days.split("/")
            valid1 = True
            for day in d:
                if day not in ["M", "T", "W", "R", "F", "S", "U", "O"]:
                    valid1 = False

            times = time.split("-")
            stl = times[0].split(":")
            etl = times[1].split(":")

            valid2 = True
            ls = labs.split("/")
            for lab in ls:
                if len(lab) > 3 or not lab.isnumeric():
                    valid2 = False

            if Course.objects.filter(name=name).exists():
                return "Course " + name + " - " + section + " already exists in the data base"
            elif len(section) > 3 or not section.isnumeric():
                return "Section must be a three digit number"
            elif not valid1:
                return "Days of week are noted as M, T, W, R, F, S, U, O"
            elif len(times[0]) > 5 or int(stl[0]) > 23 or int(stl[1]) > 59:
                return "valid start time is 00:00 to 23:59"
            elif len(times[1]) > 5 or int(etl[0]) > 23 or int(etl[1]) > 59:
                return "valid end time is 00:00 to 23:59"
            elif stl[0] > etl[0] or (stl[0] == etl[0] and stl[1] > etl[1]):
                return "end time can not be earlier than start time"
            elif not valid2:
                return "Lab sections must be a three digit number"
            else:
                o = Course(name=name,
                           section=section,
                           days_of_week=days,
                           start_time=times[0],
                           end_time=times[1])
                o.save()
                for lab in ls:
                    Lab(course=o, section=lab).save()
            return "Course " + name + " has been added to the data base with lab sections " + labs
Exemplo n.º 7
0
    def setUp(self):
        self.ui = Commands()
        self.tst_supervisor = Account(user='******',
                                      password='******',
                                      role='Supervisor')
        self.tst_administrator = Account(user='******',
                                         password='******',
                                         role='Administrator')
        self.tst_instructor = Account(user='******',
                                      password='******',
                                      role='Instructor')
        self.tst_ta = Account(user='******', password='******', role='TA')
        self.tst_supervisor.save()
        self.tst_administrator.save()
        self.tst_instructor.save()
        self.tst_ta.save()

        self.tst_course = Course(name="EE-554",
                                 section="004",
                                 days_of_week="M/W/F",
                                 start_time="11:00",
                                 end_time="11:50")
        self.tst_course.save()
Exemplo n.º 8
0
def buildCourse():

    u1 = User(user_name="اضعر فرهادی")
    cour1 = Course(course_title="برنامه سازی پیشرفته",
                   course_description="جاوا",
                   author=u1,
                   course_date="پاییز-96")
    db.session.add(cour1)
    file1 = SharedFile(shared_file_title="book", shared_file_path="book.pdf")
    db.session.add(file1)
    syllab = Syllabes(syllabes_title="10 نمره پروژه", course_syllabes=cour1)
    db.session.add(syllab)
    assign = Assignments(
        assignments_title="سوال هفته",
        assignments_description=
        "برنامه ایی بنویسید که لیست صورت حساب ها را نشان بدهد.",
        course_assignments=cour1)
    db.session.add(assign)
    reourse = Resources(resources_title="کتاب",
                        sharedfile=file1,
                        course_resources=cour1)
    db.session.add(reourse)
    db.session.commit()