EduploneExam_QOrder/skins/EduploneExam_QOrder exam_order.pt,1.4,1.5
Nils Haagen <[email protected]> Mon, 12 Dec 2005 22:16:05 +0000
| Newsgroups | gmane.comp.web.zope.eduplone.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/eduplone/EduploneExam_QOrder/skins/EduploneExam_QOrder
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10511/skins/EduploneExam_QOrder
Modified Files:
exam_order.pt
Log Message:
up-down buttons instead of radios
Index: exam_order.pt
===================================================================
RCS file: /cvsroot/eduplone/EduploneExam_QOrder/skins/EduploneExam_QOrder/exam_order.pt,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** exam_order.pt 15 Nov 2005 10:15:09 -0000 1.4
--- exam_order.pt 12 Dec 2005 22:16:03 -0000 1.5
***************
*** 2,5 ****
--- 2,88 ----
<div metal:define-macro="view"
tal:omit-tag="">
+
+
+
+ <script language="javascript">
+
+ function aEntry(id,t,h){
+ this.id=id;
+ this.top=t;
+ this.height=h;
+ }
+
+ function getAnswersForQuestion(qId){
+ v=document['eXamForm'].elements['answers_' +qId].value.split('##')
+ eList=new Array();
+ for(i=0; i<v.length; i++) {
+ eId=qId + '##' + v[i];
+ e_tmp=document.getElementById(eId);
+
+ smaller=new Array()
+ bigger=new Array()
+ for(i=0; i<eList.length; i++) {
+ if(eList[i].top < e_tmp.offsetTop){
+ smaller.push(eList[i])
+ }else{
+ bigger.push(eList[i])
+ }
+ }
+ smaller.push(new aEntry(eId, e_tmp.offsetTop, e_tmp.offsetHeight));
+ eList=smaller.concat(bigger)
+ }
+ return eList
+ }
+
+ function realMove(id, newTop){
+ e=document.getElementById(id)
+ oldTop=e.offsetTop
+
+ if(oldTop > newTop){
+ increment=-1
+ }else{
+ increment=1
+ }
+ pos=0;
+ while(e.offsetTop != newTop){
+ e.style.top=pos + 'px';
+ pos=pos+increment
+ }
+ }
+
+
+ function swapPositions(Pos1, Pos2, eList){
+ realMove(eList[Pos1].id, eList[Pos2].top)
+ realMove(eList[Pos2].id, eList[Pos1].top)
+ //höhe berechnen
+ document.forms['eXamForm'].elements[eList[Pos1].id].value=Pos2
+ document.forms['eXamForm'].elements[eList[Pos2].id].value=Pos1
+ }
+
+
+ function moveAnswer(qId, aId, direction){
+ selfId=qId + '##' + aId;
+ eList=getAnswersForQuestion(qId);
+
+ for(i=0; i<eList.length; i++) {
+ if (eList[i].id==selfId){
+ selfPos=i;
+ alterPos=i-direction;
+ }
+ }
+ swapPositions(selfPos, alterPos, eList)
+ }
+
+
+
+ function alertArray(eList){
+ a=""
+ for(i=0; i<eList.length; i++) {
+ a=a+"\n" + eList[i].id + " -- " + eList[i].top
+ }
+ alert (a)
+ }
+ </script>
+
<div>
***************
*** 7,43 ****
- <table border="0" cellspacing="0" cellpadding="0"
- tal:define="responseObj python: context.deliverResponse(currentQuestion, create=False)">
-
- <tal:repeat repeat="answer python:currentQuestion.contentValues()">
- <tr>
- <td>
-
- <div tal:condition="python:answer.getField('picture').get_size(answer) > 0"
- tal:content="structure python: answer.getPicture()"/>
! <br />
! <span tal:content="python: answer.getChallenge()" />
! <br />
! </td>
! <td width="10"></td>
<td>
! <nobr>
! <tal:rep tal:repeat="answerAlternative python:currentQuestion.objectValues()">
! <tal tal:define="no repeat/answerAlternative/number">
! <input type="radio" tal:attributes="name python:'##'.join([currentQuestion.UID(), answer.UID()]);
! value no;
! checked python:test(str(responseObj[answer.UID()])==str(no), 'checked', None)" />
!
! <span tal:replace="repeat/answerAlternative/number" />
! </tal>
- </tal:rep>
- </nobr>
</td>
! </tr>
</tal:repeat>
! </table>
</div>
--- 90,133 ----
! <div tal:define="responseObj python: context.deliverResponse(currentQuestion, create=False)">
!
! <input type="hidden"
! tal:attributes="name python:'answers_%s' % currentQuestion.UID();
! value python:'##'.join(currentQuestion.objectUIDs())" />
! <tal:repeat repeat="answer python:currentQuestion.contentValues()">
!
! <div tal:attributes="id python:'%s##%s' % (currentQuestion.UID(), answer.UID())" style="position:relative; display:block;">
! <table border=0>
! <tr>
<td>
! <div tal:condition="python:answer.getField('picture').get_size(answer) > 0"
! tal:content="structure python: answer.getPicture()"/>
!
! <br />
!
! <span tal:content="python: answer.getChallenge()" />
!
! <br />
! </td>
!
! <td width="10"></td>
! <td>
!
! <input type="hidden" tal:attributes="name python:'##'.join([currentQuestion.UID(), answer.UID()]);
! value python:responseObj[answer.UID()]" />
!
! <br />
! <a tal:attributes="href python:'javascript:moveAnswer(\'%s\',\'%s\', 1)'% (currentQuestion.UID(), answer.UID())">up</a> |
! <a tal:attributes="href python:'javascript:moveAnswer(\'%s\',\'%s\',-1)'% (currentQuestion.UID(), answer.UID())">down</a>
</td>
! </tr>
! </table>
! </div>
!
</tal:repeat>
! </div>
</div>
***************
*** 46,49 ****
--- 136,141 ----
+
+
<div metal:define-macro="eval"
tal:omit-tag=""
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click