EduploneLearningSequence EduploneLearningSequence.py,1.9,1.10

Daniel Nouri <[email protected]>
Newsgroups gmane.comp.web.zope.eduplone.cvs
Message-ID <[email protected]>
Update of /cvsroot/eduplone/EduploneLearningSequence
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17840

Modified Files:
	EduploneLearningSequence.py 
Log Message:
Added TeamSpace groundwork for EduploneLearningSequence.


Index: EduploneLearningSequence.py
===================================================================
RCS file: /cvsroot/eduplone/EduploneLearningSequence/EduploneLearningSequence.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** EduploneLearningSequence.py	4 Jul 2004 10:21:35 -0000	1.9
--- EduploneLearningSequence.py	4 Jul 2004 12:20:00 -0000	1.10
***************
*** 67,72 ****
      # student selection
      #        
      def getTutorsAndStudentsByTeam(self, team_id):
!         team = getTeamById(team_id)
          if team == None:
              raise ValueError, "No such team: %s" % team_id
--- 67,77 ----
      # student selection
      #        
+     security.declareProtected('Start Learning Sequence',
+                               'getTutorsAndStudentsByTeam')
      def getTutorsAndStudentsByTeam(self, team_id):
!         """Given a team identification, this returns a tuple of the form
!         (tutors, students), where both items are lists of member objects."""
!         
!         team = self._getTeamById(team_id)
          if team == None:
              raise ValueError, "No such team: %s" % team_id
***************
*** 74,80 ****
          tutors = []
          students = []
!         import pdb;pdb.set_trace()
!         for member in team.getMembers():
!             pass
  
      def _getTeamById(self, id):
--- 79,112 ----
          tutors = []
          students = []
!         memberships = team.getMemberships()
!         for ms in team.getMemberships():
!             if 'eduploneTutor' in ms.getTeamRoles():
!                 tutors.append(ms.getMember())
!             if 'eduploneLearner' in ms.getTeamRoles():
!                 students.append(ms.getMember())
!         return tutors, students
!         
!     def getQualifiedTeams(self):
!         """Returns a list of (team id, team title) for teams that contain
!         at least one tutor and one learner."""
! 
!         try:
!             teams = self.getTeams()
!         except AttributeError:
!             return []
! 
!         v = []
!         for t in teams:
!             foundTutor = None
!             foundStudent = None
!             for mship in t.getMemberships():
!                 if 'eduploneTutor' in mship.getTeamRoles():
!                     foundTutor = 1
!                 if 'eduploneLearner' in mship.getTeamRoles():
!                     foundStudent = 1
!                 if foundTutor and foundStudent:
!                     v.append((t.getId(), t.Title()))
!                     break
!         return v
  
      def _getTeamById(self, id):
***************
*** 83,92 ****
          team = None
          for t in teams:
!             if t.getId() == team_id:
                  team = t
                  break
          return team
      
!     def getMembersWithRole(self, role):
          """ get a sorted list of members with a particular role for a given object """
          membership_tool = getToolByName(self, 'portal_membership')
--- 115,131 ----
          team = None
          for t in teams:
!             if t.getId() == id:
                  team = t
                  break
          return team
      
!     security.declareProtected('Start Learning Sequence',
!                               'getAllTutorsAndStudents')
!     def getAllTutorsAndStudents(self):
!         return self._getMembersWithRole('eduploneTutor'), \
!                self._getMembersWithRole('eduploneLearner')
!     
!     # XXX this is ugly and needs to be redone
!     def _getMembersWithRole(self, role):
          """ get a sorted list of members with a particular role for a given object """
          membership_tool = getToolByName(self, 'portal_membership')
***************
*** 106,116 ****
                  break
              o = o.getParentNode()
          user_list = users.keys()        
          user_list.sort()
          for u in user_list:
              m = membership_tool.getMemberById(u)
              # the follwing line is a hack to make it with CMFMember working
              u = hasattr(m, 'isGroup') and m or m.getUser()
!             if u.isGroup():
                  group = u.getGroupUsers()
                  for guser in group:
--- 145,163 ----
                  break
              o = o.getParentNode()
+ 
+         # XXX listMembers() doesn't seem to work?!
+         for member in membership_tool.searchForMembers():
+             if role in member.getRoles():
+                 users[member.getId()] = 1
+ 
          user_list = users.keys()        
          user_list.sort()
+ 
          for u in user_list:
              m = membership_tool.getMemberById(u)
              # the follwing line is a hack to make it with CMFMember working
              u = hasattr(m, 'isGroup') and m or m.getUser()
!             # XXX FIXME: strange behaviour due to workaround code?!
!             if hasattr(u, 'isGroup') and u.isGroup():
                  group = u.getGroupUsers()
                  for guser in group:
***************
*** 123,139 ****
          return members
  
-     security.declareProtected('Start Learning Sequence', 'getStudents')
-     def getStudents(self) :
-         """ Returns users that are students 
-         """
-         learnerids = self.getMembersWithRole('eduploneLearner')
-         return learnerids
- 
      security.declarePublic('isReadyToGo')
      def isReadyToGo(self) :
!         """ Returns if there are students and actions available
!         """
!         go = self.getStudents() and 1
!         return go 
      
      #############
--- 170,185 ----
          return members
  
      security.declarePublic('isReadyToGo')
      def isReadyToGo(self) :
!         """Both tutors and students must exist for the "Start Course" tab to
!         be available."""
!         if self.getQualifiedTeams():
!             return 1
!         else:
!             tutors, students = self.getAllTutorsAndStudents()
!             if tutors and students:
!                 return 1
!             else:
!                 return 0
      
      #############



-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.