EduploneExam/questions BaseExamQuestion.py,1.17,1.18 MatchingQuestion.py,1.15,1.16 MathQuestion.py,1.15,1.16 SingleChoiceQuestion.py,1.15,1.16 TextTaskQuestion.py,1.15,1.16 TrueFalseQuestion.py,1.15,1.16

Nils Haagen <[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-serv23993/questions

Modified Files:
	BaseExamQuestion.py MatchingQuestion.py MathQuestion.py 
	SingleChoiceQuestion.py TextTaskQuestion.py 
	TrueFalseQuestion.py 
Log Message:
processResponse for questions

Index: TrueFalseQuestion.py
===================================================================
RCS file: /cvsroot/eduplone/EduploneExam/questions/TrueFalseQuestion.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** TrueFalseQuestion.py	15 Dec 2004 14:37:02 -0000	1.15
--- TrueFalseQuestion.py	15 Dec 2004 15:55:16 -0000	1.16
***************
*** 71,74 ****
--- 71,102 ----
  
      #Methods
+     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(['TrueFalseAnswer'])
+         
+         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
+         possibleCorrect=len(answerObjects) #is not the case for i.e. maching
+         score=self.getMaxScore() / possibleCorrect * correctCounter
+         responseObj.setScore(score)
+     
  
  

Index: MathQuestion.py
===================================================================
RCS file: /cvsroot/eduplone/EduploneExam/questions/MathQuestion.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** MathQuestion.py	15 Dec 2004 14:37:02 -0000	1.15
--- MathQuestion.py	15 Dec 2004 15:55:16 -0000	1.16
***************
*** 71,74 ****
--- 71,101 ----
  
      #Methods
+     def processResponse(self, REQUEST):
+         ''' 
+         '''
+         #get an responseObject from BaseExamQuestion
+         #context and question are set
+         responseObj=BaseExamQuestion.processResponse(self, REQUEST)
+         
+         kw={} #Dict
+         possibleCorrect=0
+         score=0
+         answerObjects=self.objectValues(['MathAnswer'])
+         
+         sUID=self.UID() 
+         kw[sUID]=REQUEST.get(sUID, '')
+         
+         #with a text/math-input, answers are not mandatory
+         if len(answerObjects)>0:
+             answerObject=answerObjects[1]
+             possibleCorrect=1
+             #process Answer (see, if correct)
+             if answerObject.processValue(kw[sUID]):
+                 score=self.getMaxScore()
+                 
+         #fill in actual user-input as answer and set score
+         responseObj.setResponseValues(kw)
+         responseObj.setScore(score)
+         
  
  

Index: MatchingQuestion.py
===================================================================
RCS file: /cvsroot/eduplone/EduploneExam/questions/MatchingQuestion.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** MatchingQuestion.py	15 Dec 2004 14:37:02 -0000	1.15
--- MatchingQuestion.py	15 Dec 2004 15:55:16 -0000	1.16
***************
*** 71,74 ****
--- 71,101 ----
  
      #Methods
+     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(['MatchingAnswer'])
+         
+         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
+         possibleCorrect=len(answerObjects) #is not the case for i.e. maching
+         score=self.getMaxScore() / possibleCorrect * correctCounter
+         responseObj.setScore(score)
  
  

Index: TextTaskQuestion.py
===================================================================
RCS file: /cvsroot/eduplone/EduploneExam/questions/TextTaskQuestion.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** TextTaskQuestion.py	15 Dec 2004 14:37:02 -0000	1.15
--- TextTaskQuestion.py	15 Dec 2004 15:55:16 -0000	1.16
***************
*** 71,75 ****
  
      #Methods
! 
  
      # uncomment lines below when you need
--- 71,104 ----
  
      #Methods
!     
!     def processResponse(self, REQUEST):
!         ''' 
!         '''
!         #get an responseObject from BaseExamQuestion
!         #context and question are set
!         responseObj=BaseExamQuestion.processResponse(self, REQUEST)
!         
!         kw={} #Dict
!         possibleCorrect=0
!         score=0
!         answerObjects=self.objectValues(['TextTaskAnswer'])
!         
!         sUID=self.UID() 
!         kw[sUID]=REQUEST.get(sUID, '')
!         
!         #with a text-input, answers are not mandatory
!         if len(answerObjects)>0:
!             answerObject=answerObjects[1]
!             possibleCorrect=1
!             #process Answer (see, if correct)
!             if answerObject.processValue(kw[sUID]):
!                 score=self.getMaxScore()
!                 
!         #fill in actual user-input as answer and set score
!         responseObj.setResponseValues(kw)
!         responseObj.setScore(score)
!         
!         
!         
  
      # uncomment lines below when you need

Index: SingleChoiceQuestion.py
===================================================================
RCS file: /cvsroot/eduplone/EduploneExam/questions/SingleChoiceQuestion.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** SingleChoiceQuestion.py	15 Dec 2004 14:37:02 -0000	1.15
--- SingleChoiceQuestion.py	15 Dec 2004 15:55:16 -0000	1.16
***************
*** 71,75 ****
--- 71,103 ----
  
      #Methods
+     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(['SingleChoiceAnswer'])
+         
+         userAnswer=REQUEST.get(self.UID(), False)
+         for answer in answerObjects:
+             awUId=answer.UID()
+             kw[awUId]= (userAnswer==awUId)
+             
+             #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
+         possibleCorrect=len(answerObjects) #is not the case for i.e. maching
+         score=self.getMaxScore() / possibleCorrect * correctCounter
+         responseObj.setScore(score)
+         
+         
  
      # uncomment lines below when you need

Index: BaseExamQuestion.py
===================================================================
RCS file: /cvsroot/eduplone/EduploneExam/questions/BaseExamQuestion.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** BaseExamQuestion.py	15 Dec 2004 14:37:02 -0000	1.17
--- BaseExamQuestion.py	15 Dec 2004 15:55:15 -0000	1.18
***************
*** 173,178 ****
          return self.archetype_name
  
!     #manually created methods
! 
  
      # uncomment lines below when you need
--- 173,177 ----
          return self.archetype_name
  
!    
  
      # uncomment lines below when you need



-------------------------------------------------------
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.