Changeset 3073 for trunk


Ignore:
Timestamp:
10/31/10 03:50:43 (9 years ago)
Author:
jukka
Message:

Still working with exercises

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/FieldsWidgets.py

    r3072 r3073  
    424424            question=form.get('choice_question') 
    425425            answers=[] 
    426             answer_count=form.get('choice_answer_count') 
     426            answer_count=int(form.get('choice_answer_count')) 
    427427            for i in range(0, answer_count): 
    428428                answer={} 
  • trunk/skins/lemill/master.js

    r3072 r3073  
    223223 
    224224function previewMultipleChoice(index) { 
    225     here=$('div#preview_'+index); 
     225    here=$('div#preview'); 
    226226    chapter=here.parents('div.chapter_edit:first'); 
    227     question=chapter.find('#chapter_'+index+'_question').val(); 
     227    question=chapter.find('#choice_question').val(); 
    228228    choices=[]; 
    229229    chapter.find('textarea.multiple_choice_answer').each(function(){ 
     
    242242    s+='</td></tr></table>'; 
    243243    here.find('div.innermost').html(s); 
    244     backlink=here.find('a.backlink'); 
    245     backlink.unbind('click'); 
    246     backlink.click(function(event){ 
    247         event.preventDefault(); 
    248         event.stopImmediatePropagation() 
    249         questionWizard(4, index); 
    250     }); 
    251244} 
    252245 
  • trunk/skins/lemill/widget_exercise.pt

    r3072 r3073  
    262262  <metal:edit_open_ended use-macro="here/widget_exercise/macros/edit_open_ended" /> 
    263263  <metal:upload_hot_potatoes use-macro="here/widget_exercise/macros/upload_hot_potatoes" /> 
    264   <div class="inner_edit" style="display:none;position:absolute;" id="preview"> 
     264  <div class="inner_edit" id="preview"> 
    265265    <label align="center"><tal:block i18n:translate="preview">Preview</tal:block>:</label> 
    266     <div class="innermost" style="width:700px;">replaced text</div> 
    267     <a href="void(0)" onclick="previewQuestion();" class="backlink" style="align:left" >&lt; <tal:block i18n:translate="link_edit_exercise">Edit exercise</tal:block></a> 
     266    <div class="innermost" style="width:700px;height:290px;">replaced text</div> 
     267    <a href="javascript:previewQuestion();void(0)" class="backlink" style="align:left" >&lt; <tal:block i18n:translate="link_edit_exercise">Edit exercise</tal:block></a> 
    268268  </div> 
    269269 </div> 
     
    273273<metal:question_selection define-macro="question_selection"> 
    274274  <div class="inner_edit" id="question_selection" tal:attributes="style python:test(chapter['type']=='exercise','display:block','')"> 
    275    <input type="hidden" id="chapter_type" name="chapter_type" value="" tal:attributes="value chapter/type" /> 
    276    <table width="90%"> 
     275   <table width="90%" height="290"> 
    277276     <tr><th><label i18n:translate="label_select_exercise_type">Select the exercise type:</label></th></tr> 
    278277     <tr height="200"><td> 
    279         <ul> 
     278        <ul style="line-height:24px;"> 
    280279           <li><label><a href="javascript:editQuestion('multiple_choices');void(0);"><tal:block i18n:translate="label_exercise_multiple_choice_question">Multiple choice question</tal:block>...</a></label></li> 
    281280           <li><label><a href="javascript:editQuestion('fill_in_the_blanks');void(0);"><tal:block i18n:translate="label_exercise_fill_in_the_blanks">Fill-in-the-blanks exercise</tal:block>...</a></label></li> 
    282281           <li><label><a href="javascript:editQuestion('open_ended');void(0);"><tal:block i18n:translate="label_exercise_open_ended">Open-ended question</tal:block>...</a></label></li> 
    283            <li><label><a href="javascript:editQuestion('potatoes_upload');void(0);"><tal:block i18n:translate="upload_questions_from_hot_potatoes">Upload questions from Hot Potatoes</tal:block>...</a></label></li> 
     282           <li><label><a href="javascript:editQuestion('hot_potatoes');void(0);"><tal:block i18n:translate="upload_questions_from_hot_potatoes">Upload questions from Hot Potatoes</tal:block>...</a></label></li> 
    284283        </ul> 
    285284      </td></tr> 
     
    328327        <div class="formHelp" i18n:translate="desc_exercise_fill_in_the_blanks">Write the correct answers inside braces like this: {answer}. The word will be replaced with an empty box. If there are more than one correct answer you can write multiple braces like this: The Eiffel tower is the most famous building of {Paris}{France}.</div> 
    329328        <div class="translatedText" tal:condition="translation"><metal:tra use-macro="here/widget_chapter/macros/original_text" /></div> 
    330         <textarea cols="40" rows="13" id="fill_blanks" name="fill_blanks" 
     329        <textarea style="width:98%" cols="40" rows="13" id="fill_blanks" name="fill_blanks" 
    331330            tal:attributes="tabindex tabindex/next;" tal:content="text"></textarea> 
    332331      </td></tr> 
     
    334333      <a href="javascript:questionSelection();void(0);" style="align:left" >&lt; 
    335334      <tal:block i18n:translate="exercise_types">Exercise types</tal:block></a></td> 
    336       <td align="right"><a href="javascript:previewFillTheBlanks();previewQuestion();void(0);" style="align:right"><tal:block i18n:translate="preview">Preview</tal:block>&gt; </a> 
     335      <td align="right"><a href="javascript:previewFillTheBlanks();previewQuestion();void(0);" style="align:right"><tal:block i18n:translate="preview">Preview</tal:block> &gt;</a>  
    337336     </td></tr> 
    338337  </table> 
     
    349348     <div class="formHelp" i18n:translate="desc_exercise_open_ended">Enter here a question that requires free-form answer.</div> 
    350349     <div class="translatedText" tal:condition="translation"><metal:tra use-macro="here/widget_chapter/macros/original_text" /></div> 
    351      <textarea cols="40" rows="4" id="open_field" name="open_field"  
     350     <textarea style="width:98%" cols="40" rows="4" id="open_field" name="open_field"  
    352351      tal:attributes="tabindex tabindex/next;" tal:content="text"></textarea> 
    353352 </td></tr> 
    354353  <tr><td align="left">   
    355       <a href="void(0);" style="align:left" onclick="questionSelection();">&lt; <tal:block i18n:translate="exercise_types">Exercise types</tal:block></a></td> 
    356       <td align="right"><a href="javascript:previewOpenEnded();previewQuestion();void(0);" style="align:right"><tal:block i18n:translate="preview">Preview</tal:block>&gt; </a> 
     354      <a href="javascript:questionSelection();void(0);" style="align:left">&lt; <tal:block i18n:translate="exercise_types">Exercise types</tal:block></a></td> 
     355      <td align="right"><a href="javascript:previewOpenEnded();previewQuestion();void(0);" style="align:right"><tal:block i18n:translate="preview">Preview</tal:block> &gt; </a>  
    357356   </td></tr> 
    358357  </table> 
     
    372371    <td> 
    373372     <div class="translatedText" tal:condition="translation"><metal:tra use-macro="here/widget_chapter/macros/original_text" /></div> 
    374          <textarea rows="3" id="choice_question" name="choice_question" tal:attributes="tabindex tabindex/next;" tal:content="chapter/text"></textarea> 
     373         <textarea rows="3" style="width:96%" id="choice_question" name="choice_question" tal:attributes="tabindex tabindex/next;" tal:content="chapter/text"></textarea> 
    375374     </td></tr> 
    376375    <tr><td width="40%">  
     
    379378     </td> 
    380379     <td width="60%"> 
    381      <input type="hidden" id="choice_answer_count" name="choice_answer_count" value="3" /> 
    382      <table width="100%" class="choices_list sortable" style="table-layout: fixed" > 
     380     <table width="100%" class="choices_list sortable" style="table-layout: fixed" tal:define="choices python:chapter.get('choices',[('',1),('',0),('',0)])" > 
    383381      <tr> 
    384382       <td width="22"><img src="images/tick.gif" width="20" height="20" alt="Correct" /></td> 
    385383       <td width="22"><img src="images/cross.gif" id="cross" width="20" height="20" alt="Incorrect" /></td> 
    386384       <td><div class="formHelp" i18n:translate="desc_answer">Answer</div></td> 
    387        <td width="10"></td> 
     385       <td width="10"><input type="hidden" id="choice_answer_count" name="choice_answer_count" value="3" tal:attributes="value python:len(choices)" /></td> 
    388386    </tr> 
    389       <tr class="sortable_row"> 
    390        <td><input type="radio" value="1" name="answer_0_correct" id="answer_0_correct" checked="1"/></td>  
    391        <td><input type="radio" value="0" name="answer_0_correct" id="answer_0_correct"/></td> 
     387     <tal:loop repeat="choicetuple choices"> 
     388      <tr class="sortable_row" tal:define="index repeat/choicetuple/index"> 
     389       <td><input type="radio" value="1" name="answer_0_correct" id="answer_0_correct" tal:attributes="name string:answer_${index}_correct; id string:answer_${index}_correct; checked python:choicetuple[1];"/></td>  
     390       <td><input type="radio" value="0" name="answer_0_correct" id="answer_0_correct" tal:attributes="name string:answer_${index}_correct; id string:answer_${index}_correct; checked python:not choicetuple[1];"/></td> 
    392391       <td> 
    393 <textarea rows="2" style="height:3em;float:left;" cols="40" class="multiple_choice_answer" name="choice_answer_0" id="choice_answer_0"></textarea></td> 
     392<textarea rows="2" style="height:3em;float:left;" cols="40" class="multiple_choice_answer" name="choice_answer_0" id="choice_answer_0" tal:attributes="name string:choice_answer_${index}; id string:choice_answer_${index}" tal:content="python:choicetuple[0]"></textarea></td> 
    394393       <td valign="top"><span class="handle handle_small">&nbsp;</span> 
    395        <input type="hidden" class="orderkeeper" value="0" name="choice_order_0" id="choice_order_0"/></td>  
     394       <input type="hidden" class="orderkeeper" value="0" name="choice_order_0" id="choice_order_0" tal:attributes="name string:choice_order_${index}; id string:choice_order_${index}"/></td>  
    396395      </tr> 
    397       <tr class="sortable_row">        
    398        <td><input type="radio" value="1" name="answer_1_correct" id="answer_1_correct"/></td>  
    399        <td><input type="radio" value="0" name="answer_1_correct" id="answer_1_correct" checked="1"/></td> 
    400        <td><textarea rows="2" style="height:3em;" cols="40" class="multiple_choice_answer" name="choice_answer_1" id="choice_answer_1"></textarea></td> 
    401        <td valign="top"><span class="handle handle_small">&nbsp;</span> 
    402        <input type="hidden" class="orderkeeper" value="1" name="choice_order_1" id="choice_order_1"/></td>  
    403       </tr> 
    404       <tr class="sortable_row">       
    405        <td><input type="radio" value="1" name="answer_2_correct" id="answer_2_correct"/></td>  
    406        <td><input type="radio" value="0" name="answer_2_correct" id="answer_2_correct" checked="1"/></td> 
    407        <td><textarea rows="2" style="height:3em;" cols="40" class="multiple_choice_answer" name="choice_answer_2" id="choice_answer_2"></textarea></td> 
    408        <td valign="top"><span class="handle handle_small">&nbsp;</span> 
    409        <input type="hidden" class="orderkeeper" value="2" name="choice_order_2" id="choice_order_2"/></td>  
    410       </tr> 
     396     </tal:loop> 
    411397      <tr> 
    412398       <td></td><td></td><td align="right"><input type="button" i18n:attributes="value button_add_choices" value="Add choices" align="right" onclick="addAnswer(this);" /></td><td></td> 
     
    416402    </td> 
    417403    </tr> 
    418     <tr> 
    419     <td colspan="2"> 
    420      <label i18n:translate="label_polling_question">This is a polling question:</label> <input type="checkbox" tal:attributes="tabindex tabindex/next;" value="1" onclick="javascript:questionnairePollingCheck(this);" onload="javascript:questionnairePollingCheck(this);"/> 
    421  
    422      <div class="formHelp" i18n:translate="desc_polling_question">Polling questions are not evaluated as correct or incorrect; any choice is acceptable.</div> 
    423      </td> 
    424      </tr>    
    425404     <tr><td align="left">   
    426405        <a href="javascript:void(0)" style="align:left" onclick="questionSelection();">&lt; <tal:block i18n:translate="exercise_types">Exercise types</tal:block></a></td> 
    427         <td align="right"><a href="javascript:previewMultipleChoice();previewQuestion();void(0)" style="align:right"><tal:block i18n:translate="preview">Preview</tal:block>&gt; </a> 
     406        <td align="right"><a href="javascript:previewMultipleChoice();previewQuestion();void(0)" style="align:right"><tal:block i18n:translate="preview">Preview</tal:block> &gt;</a>  
    428407     </td></tr> 
    429408  </table> 
Note: See TracChangeset for help on using the changeset viewer.