EduploneExam/skins/EduploneExam exam_fillgap_process.cpy,NONE,1.1

"Fabian K." <[email protected]> Sat, 02 Apr 2005 13:40:40 +0000
Newsgroups gmane.comp.web.zope.eduplone.cvs
Message-ID <[email protected]>
Update of /cvsroot/eduplone/EduploneExam/skins/EduploneExam
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27959/skins/EduploneExam

Added Files:
	exam_fillgap_process.cpy 
Log Message:
Added move gap feature for fillgap question types

--- NEW FILE: exam_fillgap_process.cpy ---
# Controller Python Script "exam_fillgap_process"
request = context.REQUEST
answerId = request.get("id")
answerTitle = request.get("title")
answerCorrect = request.get("correct")
answerCaseSensitive = request.get("caseSensitive")
answer = context[answerId]
gapWordIndex = int(request.get("gapWordIndex"))
basetext = context.getBasetextAsList()

# Re-render basetext with newly added gap.
basetext_new = []
for i in xrange(len(basetext)):
    # Check if gap position has changed and move gap if so.
    if context.getGapPosition(answerId) != gapWordIndex and basetext[i] == "<id='%s'>" % answerId:
        basetext_new.append(answer.getCorrect()[0])
    else:
        if gapWordIndex == i:
            basetext_new.append("<id='%s'>" % answerId)
        else:
            basetext_new.append(basetext[i])

# Save settings
context.setBasetext(" ".join(basetext_new))
answer.setTitle(answerTitle)
answer.setCorrect(answerCorrect)
#answer.setCaseSensitive(answerCaseSensitive)

# Return to fillgap task
request.RESPONSE.redirect("%s" % context.absolute_url())


-------------------------------------------------------
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://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click