EduploneExam/questions BaseExamQuestion.py,1.20,1.21 MultipleChoiceQuestion.py,1.16,1.17

Jens Klein <[email protected]>
Newsgroups gmane.comp.web.zope.eduplone.cvs
Message-ID <[email protected]>
Update of /cvsroot/eduplone/EduploneExam/questions
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13902/questions

Modified Files:
	BaseExamQuestion.py MultipleChoiceQuestion.py 
Log Message:
mc saves 


Index: MultipleChoiceQuestion.py
===================================================================
RCS file: /cvsroot/eduplone/EduploneExam/questions/MultipleChoiceQuestion.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** MultipleChoiceQuestion.py	16 Dec 2004 13:28:20 -0000	1.16
--- MultipleChoiceQuestion.py	16 Dec 2004 14:43:17 -0000	1.17
***************
*** 12,16 ****
  #
  # GNU General Public Licence (GPL)
! # 
  # This program is free software; you can redistribute it and/or modify it under
  # the terms of the GNU General Public License as published by the Free Software
--- 12,16 ----
  #
  # GNU General Public Licence (GPL)
! #
  # This program is free software; you can redistribute it and/or modify it under
  # the terms of the GNU General Public License as published by the Free Software
***************
*** 45,50 ****
      '''
      security = ClassSecurityInfo()
!     portal_type = meta_type = 'MultipleChoiceQuestion' 
!     archetype_name = 'MultipleChoiceQuestion'   #this name appears in the 'add' box 
      allowed_content_types = ['MultipleChoiceAnswer'] + getattr(BaseExamQuestion,'allowed_content_types',[])
  
--- 45,50 ----
      '''
      security = ClassSecurityInfo()
!     portal_type = meta_type = 'MultipleChoiceQuestion'
!     archetype_name = 'MultipleChoiceQuestion'   #this name appears in the 'add' box
      allowed_content_types = ['MultipleChoiceAnswer'] + getattr(BaseExamQuestion,'allowed_content_types',[])
  
***************
*** 63,67 ****
              ),
          ),
!         
          StringField('title',
              accessor='''Title''',
--- 63,67 ----
              ),
          ),
! 
          StringField('title',
              accessor='''Title''',
***************
*** 74,78 ****
              ),
          ),
!         
      ),
      )
--- 74,78 ----
              ),
          ),
! 
      ),
      )
***************
*** 82,106 ****
  
      def processResponse(self, REQUEST):
!         ''' 
          '''
          #get an responseObject from BaseExamQuestion
          #context and question are set
          responseObj=BaseExamQuestion.processResponse(self, REQUEST)
!         
          kw={} #Dict
          correctCounter=0
          answerObjects=self.objectValues(['MultipleChoiceAnswer'])
!         
          for answer in answerObjects:
              awUId=answer.UID()
!             reqKey='##'.join((self.UID(), awUId))         
              kw[awUId]=REQUEST.get(reqKey, False)
!             
              #process Answer (see, if correct and increase counter if so)
!             if self[awUId].processValue(kw[awUId]):
                  correctCounter += 1
!             
          #fill in actual user-input as answers
!         responseObj.setResponseValues(kw)
  
          #now calculate and set score
--- 82,107 ----
  
      def processResponse(self, REQUEST):
!         '''
          '''
          #get an responseObject from BaseExamQuestion
          #context and question are set
          responseObj=BaseExamQuestion.processResponse(self, REQUEST)
! 
          kw={} #Dict
          correctCounter=0
          answerObjects=self.objectValues(['MultipleChoiceAnswer'])
! 
          for answer in answerObjects:
              awUId=answer.UID()
!             reqKey='##'.join((self.UID(), awUId))
              kw[awUId]=REQUEST.get(reqKey, False)
! 
              #process Answer (see, if correct and increase counter if so)
!             answer=self._lookupUID(awUId)
!             if answer.processValue(kw[awUId]):
                  correctCounter += 1
! 
          #fill in actual user-input as answers
!         responseObj.setResponseValues(**kw)
  
          #now calculate and set score
***************
*** 121,130 ****
          }
  
!         
      actions=  (
!         
  
            )
!         
  
  registerType(MultipleChoiceQuestion)
--- 122,131 ----
          }
  
! 
      actions=  (
! 
  
            )
! 
  
  registerType(MultipleChoiceQuestion)
***************
*** 134,137 ****
  registerQuestionType(MultipleChoiceQuestion)
  ##/code-section module-footer
- 
- 
--- 135,136 ----

Index: BaseExamQuestion.py
===================================================================
RCS file: /cvsroot/eduplone/EduploneExam/questions/BaseExamQuestion.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** BaseExamQuestion.py	16 Dec 2004 13:28:20 -0000	1.20
--- BaseExamQuestion.py	16 Dec 2004 14:43:17 -0000	1.21
***************
*** 12,16 ****
  #
  # GNU General Public Licence (GPL)
! # 
  # This program is free software; you can redistribute it and/or modify it under
  # the terms of the GNU General Public License as published by the Free Software
--- 12,16 ----
  #
  # GNU General Public Licence (GPL)
! #
  # This program is free software; you can redistribute it and/or modify it under
  # the terms of the GNU General Public License as published by the Free Software
***************
*** 38,41 ****
--- 38,43 ----
  
  ##code-section module-header #fill in your manual code here
+ from Products.CMFCore.utils import getToolByName
+ from Products.Archetypes.config import UID_CATALOG
  ##/code-section module-header
  
***************
*** 43,49 ****
  class BaseExamQuestion(BaseContent):
      security = ClassSecurityInfo()
!     portal_type = meta_type = 'BaseExamQuestion' 
!     archetype_name = 'BaseExamQuestion'   #this name appears in the 'add' box 
!     allowed_content_types = [] 
  
      __implements__ = getattr(BaseContent,'__implements__',()) + (IExamNotifier,IExamQuestion,)
--- 45,51 ----
  class BaseExamQuestion(BaseContent):
      security = ClassSecurityInfo()
!     portal_type = meta_type = 'BaseExamQuestion'
!     archetype_name = 'BaseExamQuestion'   #this name appears in the 'add' box
!     allowed_content_types = []
  
      __implements__ = getattr(BaseContent,'__implements__',()) + (IExamNotifier,IExamQuestion,)
***************
*** 61,65 ****
              ),
          ),
!         
          StringField('title',
              accessor='''Title''',
--- 63,67 ----
              ),
          ),
! 
          StringField('title',
              accessor='''Title''',
***************
*** 72,76 ****
              ),
          ),
!         
          TextField('question',
              widget=TextAreaWidget(description='Enter a value for question.',
--- 74,78 ----
              ),
          ),
! 
          TextField('question',
              widget=TextAreaWidget(description='Enter a value for question.',
***************
*** 81,85 ****
              ),
          ),
!         
          TextField('instruction',
              widget=TextAreaWidget(description='Enter a value for instruction.',
--- 83,87 ----
              ),
          ),
! 
          TextField('instruction',
              widget=TextAreaWidget(description='Enter a value for instruction.',
***************
*** 90,94 ****
              ),
          ),
!         
          IntegerField('maxScore',
              widget=IntegerWidget(description='Enter a value for maxScore.',
--- 92,96 ----
              ),
          ),
! 
          IntegerField('maxScore',
              widget=IntegerWidget(description='Enter a value for maxScore.',
***************
*** 99,103 ****
              ),
          ),
!         
          BooleanField('strict',
              widget=BooleanWidget(description='Enter a value for strict.',
--- 101,105 ----
              ),
          ),
! 
          BooleanField('strict',
              widget=BooleanWidget(description='Enter a value for strict.',
***************
*** 108,112 ****
              ),
          ),
!         
          ImageField('picture',
              storage=AttributeStorage(),
--- 110,114 ----
              ),
          ),
! 
          ImageField('picture',
              storage=AttributeStorage(),
***************
*** 118,122 ****
              ),
          ),
!         
      ),
      )
--- 120,124 ----
              ),
          ),
! 
      ),
      )
***************
*** 175,178 ****
--- 177,190 ----
          return self.archetype_name
  
+     def _lookupUID(self, uid):
+         tool = getToolByName(self, UID_CATALOG)
+         brains = tool(UID=uid)
+         for brain in brains:
+             obj = brain.getObject()
+             if obj is not None:
+                 return obj
+         else:
+             return None
+ 
  
  
***************
*** 187,196 ****
          }
  
!         
      actions=  (
!         
  
            )
!         
  
  registerType(BaseExamQuestion)
--- 199,208 ----
          }
  
! 
      actions=  (
! 
  
            )
! 
  
  registerType(BaseExamQuestion)
***************
*** 199,202 ****
  ##code-section module-footer #fill in your manual code here
  ##/code-section module-footer
- 
- 
--- 211,212 ----



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.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.