Ejemplo n.º 1
0
    def testUserEnrolled(self):

        course = self.coursews.getCourseById("course"+self.random)
        self.assertTrue(course)
        
        courseMemberships = self.courseMembershipWs.getCourseMembershipsByCourse(course)
        found = False
        mem = CourseMembershipVO()
        
        for mem in courseMemberships:
            if mem.userId == self.userId[0]:
                found = True
                self.assertTrue(mem.available)
                self.assertEquals(mem.courseId,self.courseid)
                self.assertEquals(mem.roleId,"S")
                
        self.assertTrue(found)
Ejemplo n.º 2
0
    def setUp(self):
        logging.basicConfig()
        log=logging.getLogger()
        log.setLevel(logging.WARN)
        context = ContextWS("https://dev.bblearn.nau.edu")
        success = context.loginTool("NAU", "PythonFeed", "*****")
        if not success:
            log.error("Login was not successful!")
            self.fail("Login was not successful!")

        self.userws = context.getUserWS()
        self.coursews = context.getCourseWS()
        self.courseMembershipWs = context.getCourseMembershipWS()
        
        self.random = string.lower(''.join(random.choice(string.letters) for i in xrange(5)))
        
        ## Create user to play with
        self.userId = self.userws.createSimpleUser(True, 
                                               self.random, 
                                               "7777777" + self.random, 
                                               "*****@*****.**", 
                                               "familyName" , 
                                               "givenName")
        self.assertTrue(self.userId)
        
        ## Create course to play with
        self.begin = datetime.date.today()
        self.end = datetime.date.today()+datetime.timedelta(days=1)
        self.courseid = self.coursews.createSimpleCourse(True,
                                         "batch"+self.random, # course batch id
                                         "course"+self.random, # course id
                                         "Testing " + self.random + " description", # description
                                         "name"+self.random, # course name
                                         time.mktime(self.begin.timetuple()),
                                         time.mktime(self.end.timetuple()))
        self.assertTrue(self.courseid)
        
        ## Enroll user in class
        membership = CourseMembershipVO()
        membership.available=True
        membership.courseId=self.courseid
        membership.roleId="S"
        membership.userId=self.userId
        
        self.memberships = self.courseMembershipWs.saveCourseMemberships(self.courseid, [membership])
        self.assertTrue(self.memberships)
Ejemplo n.º 3
0
 def testChangeEnrollment(self):
     course = self.coursews.getCourseById("course"+self.random)
     self.assertTrue(course)
     
     courseMemberships = self.courseMembershipWs.getCourseMembershipsByCourse(course)
     mem = CourseMembershipVO()
     
     for mem in courseMemberships:
         if mem.userId == self.userId[0]:
             self.assertTrue(mem.available)
             self.assertEquals(mem.courseId,self.courseid)
             self.assertEquals(mem.roleId,"S")
             mem.roleId="B"
             
             self.memberships = self.courseMembershipWs.saveCourseMemberships(self.courseid, [mem])
             self.assertTrue(self.memberships)
             
     found = False
     courseMemberships = self.courseMembershipWs.getCourseMembershipsByCourse(course)
     mem = CourseMembershipVO()
     
     for mem in courseMemberships:
         if mem.userId == self.userId[0]:
             found = True
             self.assertTrue(mem.available)
             self.assertEquals(mem.courseId,self.courseid)
             self.assertEquals(mem.roleId,"B")
             mem.roleId="Secondary-Instructor"
             self.memberships = self.courseMembershipWs.saveCourseMemberships(self.courseid, [mem])
             self.assertTrue(self.memberships)
             
     self.assertTrue(found)
     
     found = False
     courseMemberships = self.courseMembershipWs.getCourseMembershipsByCourse(course)
     for mem in courseMemberships:
         if mem.userId == self.userId[0]:
             self.assertTrue(mem.available)
             self.assertEquals(mem.courseId,self.courseid)
             self.assertEquals(mem.roleId,"Secondary-Instructor")
Ejemplo n.º 4
0
            "CourseMembership.WS:getCourseMembership",
            "CourseMembership.WS:saveCourseMembership",
            "CourseMembership.WS:initializeCourseMembershipWS", "user.authinfo"
        ]
        success = context.registerTool("NAU", "PythonFeed", "*****",
                                       "PythonFeed", toolMethods, None)
    else:
        success = context.loginTool("NAU", "PythonFeed", "lemtein")
        if not success:
            log.error("Login was not successful!")
            sys.exit()

        #userws = context.getUserWS()
        courseWs = context.getCourseWS()
        userWs = context.getUserWS()
        courseMembershipWs = context.getCourseMembershipWS()

        course = courseWs.getCourseByBatchId(
            "1107-NAU00-NUR-424-SEC801-11685.NAU-PSSIS")
        memberships = courseMembershipWs.getCourseMembershipsByCourse(course)
        user = userWs.getUserByUserId("cdg2")
        membership = CourseMembershipVO()
        for membership in memberships:
            if membership.userId == user.id:
                membership.available = True
                membership.userId = user.id
                membership.roleId = "B"

                courseMembershipWs.saveCourseMemberships(
                    course.id, memberships)
Ejemplo n.º 5
0
     success = context.loginTool("NAU", "PythonFeed", "lemtein")
     if not success:
         log.error("Login was not successful!")
         sys.exit()
         
     #userws = context.getUserWS()
     courseWs = context.getCourseWS()
     userWs = context.getUserWS()
     courseMembershipWs = context.getCourseMembershipWS()
     
     
     
     course = courseWs.getCourseByBatchId("1107-NAU00-NUR-424-SEC801-11685.NAU-PSSIS")
     memberships = courseMembershipWs.getCourseMembershipsByCourse(course)
     user = userWs.getUserByUserId("cdg2")
     membership = CourseMembershipVO()
     for membership in memberships:
         if membership.userId == user.id:
             membership.available=True
             membership.userId=user.id
             membership.roleId="B"
             
             courseMembershipWs.saveCourseMemberships(course.id, memberships)