Changeset 3074 for trunk


Ignore:
Timestamp:
10/31/10 20:47:03 (9 years ago)
Author:
jukka
Message:

Exercises seem to be working now.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/ExerciseMaterial.py

    r3045 r3074  
    4343        default_output_type = 'text/x-html-captioned', 
    4444        default_content_type = 'text/html', 
    45         default=[{'type':'guidelines', 'text':''}], 
     45        default=[{'type':'text_block', 'text':''}], 
    4646        widget=ExerciseWidget(label = "Body text", 
    4747            label_msgid = "label_bodytext", 
     
    8282        for piece in re.split(blanks, text): 
    8383            if piece.startswith('{'): 
    84                 answer=piece.strip('{} ') 
     84                answer=to_unicode(piece.strip('{} ')) 
    8585                if previous_was_blank: 
    8686                    answers[-1].append(answer) 
     
    8888                    answers.append([answer]) 
    8989            else: 
    90                 pieces.append(piece) 
     90                pieces.append(to_unicode(piece)) 
    9191        return pieces, answers 
    9292             
     
    104104            else: 
    105105                answer="" 
    106             a="""<input type="text" value="%s"%s name="exercise_%s_answer_%s" id="exercise_%s_answer_%s" />""" % (answer, readonly, index, i, index, i) 
     106            a=u"""<input type="text" value="%s"%s name="exercise_%s_answer_%s" id="exercise_%s_answer_%s" />""" % (to_unicode(answer), readonly, index, i, index, i) 
    107107            inputs.append(a) 
    108108        for piece in pieces: 
  • trunk/FieldsWidgets.py

    r3073 r3074  
    419419            return changes,empty 
    420420        chapter_type=changes['chapter_type']                 
    421         if chapter_type=='guidelines': 
     421        if chapter_type=='guidelines':  
     422            # this should be deprecated, but I keep this still here because I cannot now think if there  
     423            # are any bad consequences from removing it. Too tired. 
    422424            changes['text']=form.get('chapter') 
     425        elif chapter_type=='exercise': 
     426            # exercises are question chapters that don't have yet chosen any specific type for themselves. They should be empty. 
     427            changes['text']=''             
    423428        elif chapter_type in ['choice','multiple_choices','poll']: 
    424429            question=form.get('choice_question') 
    425430            answers=[] 
    426             answer_count=int(form.get('choice_answer_count')) 
     431            answer_count=int(form.get('choice_answer_count',0)) 
    427432            for i in range(0, answer_count): 
    428433                answer={} 
    429434                answer['text']=form.get('choice_answer_%s' % i, '') 
    430435                answer['is_correct']= chapter_type=='poll' or int(form.get('answer_%s_correct' % i, '')) 
    431                 answer['order']=int(form.get('choice_order_%s' % i, 0))                 
    432                 answers.append(answer) 
    433                 # put sorting here!!! 
     436                answer['order']=int(form.get('choice_order_%s' % i, 0)) 
     437                if answer['text']:  # empty answers are deleted by ignoring them  
     438                    answers.append(answer) 
     439            answers.sort(cmp=lambda x,y: cmp(x['order'], y['order'])) 
    434440            changes['question']=question 
    435             changes['answers']=answers 
     441            changes['answers']=answers or [{'text':'','is_correct':1,'order':0}] 
    436442        elif chapter_type=='fill_in_the_blanks': 
    437443            changes['text']=form.get('fill_blanks','') 
    438444        elif chapter_type=='open_ended': 
    439             changes['text']=form.get('open_ended','') 
     445            changes['text']=form.get('open_field','') 
    440446        # Buttons  
    441447        if form.get('add_exercise', None): 
    442448            changes['new_chapters']=[{'text':'','type':'exercise'}] 
     449            count=changes['count'] 
    443450            form.update({'chapter_edited':count, 'chapter_anchor':count, 'stay':1}) 
    444451        elif form.get('import_potatoes', None): 
     
    754761     
    755762    security = ClassSecurityInfo() 
    756     chapter_names={'text_block':_('text chapter'), 'media_piece':_('media piece'), 'embed_block':_('embedded content'), 'multiple_choices':_('multiple choices'), 'choices':_('choices'), 'fill_in_the_blanks':_('fill in the blanks'), 'open_ended':_('open ended question')} 
     763    chapter_names={'text_block':_('text chapter'), 'media_piece':_('media piece'), 'embed_block':_('embedded content'), 'multiple_choices':_('multiple choices'), 'choices':_('choices'), 'fill_in_the_blanks':_('fill in the blanks'), 'open_ended':_('open ended question'), 'exercise':_('new exercise'), 'guidelines':_('text chapter')} 
    757764 
    758765    def getChapterNames(self): 
  • trunk/skins/lemill/button_macros.pt

    r3070 r3074  
    4747</metal:save> 
    4848 
     49 
     50<metal:save_buttons define-macro="save_and_move_buttons"> 
     51 
     52<div style="margin-top:20px"> 
     53    <tal:if_translation condition="translation"> 
     54    <input type="hidden" 
     55        name="translation" 
     56        value="1" 
     57        /> 
     58    <input type="hidden" 
     59        name="translation_of" 
     60        tal:attributes="value source/UID" 
     61        /> 
     62    </tal:if_translation> 
     63    <metal:eula_def use-macro="here/button_macros/macros/eula"/> 
     64</div> 
     65    <div class="form_submit"> 
     66    <input class="save" 
     67        tabindex="" 
     68        type="submit" 
     69        name="form.button.save_and_move" 
     70        value="Save" i18n:domain="plone" 
     71        i18n:attributes="value label_save;" 
     72        tal:attributes="tabindex tabindex/next;" 
     73        /> 
     74    <input class="cancel" 
     75        tabindex="" 
     76        type="submit" 
     77        name="cancel" 
     78        value="Cancel" i18n:domain="plone"  
     79        i18n:attributes="value label_cancel;" 
     80        tal:attributes="tabindex tabindex/next" 
     81        /> 
     82    </div> 
     83    <div class="required_notes"> 
     84        <ul id="req_list" tal:repeat="req context/getRequiredFieldNames"> 
     85        <li tal:attributes="id string:required_${req}; onclick string:focusToField('${req}'); onmouseover string:showFieldHint(this, '${req}'); onmouseout string:hideFieldHint(this, '${req}');" class="req_link"><span class="hint_label" tal:content="req" i18n:translate="" /> <span i18n:translate="is_required">is required</span></li> 
     86        </ul> 
     87    </div> 
     88    <input type="hidden" name="form.submitted" value="1" /> 
     89</metal:save_buttons> 
     90 
     91 
     92 
    4993</html> 
  • trunk/skins/lemill/collection_add.cpt

    r3069 r3074  
    3535                <div id="save_button" style="display:inline"> 
    3636                    <input class="save" 
     37                    style="width:200px" 
    3738                    tabindex="" 
    3839                    type="submit" 
  • trunk/skins/lemill/exercisematerial_edit.cpt

    r3072 r3074  
    1919                </tal:block> 
    2020                <tal:block metal:use-macro="here/multimediamaterial_edit/macros/minor_edit"/> 
    21                 <metal:buttons use-macro="here/button_macros/macros/save_buttons" />                                         
     21                <metal:buttons use-macro="here/button_macros/macros/save_and_move_buttons" /> 
    2222            </form> 
    2323        </metal:macro> 
  • trunk/skins/lemill/lemill_grid.css

    r3072 r3074  
    679679} 
    680680 
     681span.handle_small { 
     682    position:relative; 
     683    left:-100px; 
     684    top:-0.7em; 
     685    width: 100px; 
     686    height:10px; 
     687} 
     688 
     689span.handle { 
     690    background:#eeeeff url('images/pattern.png') no-repeat left top; 
     691    border:1px solid #8cacbb; 
     692    cursor: move; 
     693    font-size:11px; 
     694    color:transparent; 
     695    display: block; 
     696}     
     697 
     698 
    681699fieldset { 
    682700    border: 1px solid #8cacbb; 
     
    746764div.selected_tab_sheet { 
    747765    display:block; 
     766} 
     767.hidden { 
     768    display:none; 
    748769} 
    749770 
  • trunk/skins/lemill/master.js

    r3073 r3074  
    204204    check_me= (is_correct) ? last_row.find('input:radio:first') : last_row.find('input:radio:last'); 
    205205    check_me.attr('checked', '1'); 
    206     $('input#choice_answer_count').val(row_index); 
     206    $('input#choice_answer_count').val(row_index+1); 
    207207    //new_row.fadeIn();     
    208208    outer_div=here.parents('.chapter_edit'); 
     
    263263    textarea=$('textarea#open_field'); 
    264264    s='<p>'+textarea.val()+'</p>'; 
    265     s+='<textarea cols="40" rows="8"></textarea>' 
     265    s+='<textarea cols="40" rows="8" style="width:95%"></textarea>' 
    266266    here.find('div.innermost').html(s); 
    267267} 
  • trunk/skins/lemill/multimediamaterial_edit.cpt

    r3069 r3074  
    3434                </metal:minor_edit> 
    3535 
    36         <div style="margin-top:20px"> 
    37         <tal:if_translation condition="translation"> 
    38         <input type="hidden" 
    39             name="translation" 
    40             value="1" 
    41             /> 
    42         <input type="hidden" 
    43             name="translation_of" 
    44             tal:attributes="value source/UID" 
    45             /> 
    46         </tal:if_translation> 
    47         <metal:eula_def define-macro="eula"> 
    48         <p>If you do not want your writing to be edited, used, and redistributed at will, then do not submit it here. All text that you did not write yourself, except brief excerpts, must be available under terms consistent with LeMill's Terms of Use before you submit it.</p> 
    49         </metal:eula_def> 
    50         </div> 
    51         <metal:save_buttons define-macro="chapteredit_save_buttons"> 
    52         <div class="form_submit"> 
    53         <input class="save" 
    54             tabindex="" 
    55             type="submit" 
    56             name="form.button.save_and_move" 
    57             value="Save" i18n:domain="plone" 
    58             i18n:attributes="value label_save;" 
    59             tal:attributes="tabindex tabindex/next;" 
    60             /> 
    61         <input class="cancel" 
    62             tabindex="" 
    63             type="submit" 
    64             name="cancel" 
    65             value="Cancel" i18n:domain="plone"  
    66             i18n:attributes="value label_cancel;" 
    67             tal:attributes="tabindex tabindex/next" 
    68             /> 
    69         </div> 
    70         <div class="required_notes"> 
    71           <ul id="req_list" tal:repeat="req context/getRequiredFieldNames"> 
    72             <li tal:attributes="id string:required_${req}; onclick string:focusToField('${req}'); onmouseover string:showFieldHint(this, '${req}'); onmouseout string:hideFieldHint(this, '${req}');" class="req_link"><span class="hint_label" tal:content="req" i18n:translate="" /> <span i18n:translate="is_required">is required</span></li> 
    73           </ul> 
    74         </div> 
    75         <input type="hidden" name="form.submitted" value="1" /> 
    76         </metal:save_buttons> 
     36        <metal:buttons use-macro="here/button_macros/macros/save_and_move_buttons" /> 
    7737        </form> 
    7838            </metal:macro> 
  • trunk/skins/lemill/widget_chapter.pt

    r3072 r3074  
    223223<tal:edit_embed_block metal:define-macro="edit_embed_block">     
    224224<div class="formHelp" i18n:translate="embed_block_helptext">Paste embed code here.</div>       
    225 <textarea rows="3" id="embed_textarea" name="embed_textarea" tal:content="chapter/embed | python:''"></textarea>     
     225<textarea rows="3" style="width:95%" id="embed_textarea" name="embed_textarea" tal:content="chapter/embed | python:''"></textarea>     
    226226</tal:edit_embed_block> 
    227227 
     
    242242                        coverImage piece/getCoverImage | nothing;"> 
    243243    <div id="piece-edit-box" tal:attributes="style python:test(piece_url, 'background-image:url(%s/image_large)' % piece_url, 'background-image:none')"> 
    244     <div id="piece-edit-controls" style="display:inline-block"> 
    245         <div style="height:20px" class="visualClear">&nbsp;</div> 
    246         <div tal:attributes="class python:test(piece and isImage, 'contrast','')"><tal:block tal:condition="python: piece_type=='image'" i18n:translate="label_upload_image_file">Upload image file</tal:block> 
     244    <div style="display:inline-block"> 
     245        <div style="height:20px" class="visualClear">&nbsp;</div> 
     246        <div id="piece-edit-controls" tal:attributes="class python:test(piece and isImage, 'contrast','')"><tal:block tal:condition="python: piece_type=='image'" i18n:translate="label_upload_image_file">Upload image file</tal:block> 
    247247        <tal:block tal:condition="python: piece_type=='audio'" i18n:translate="label_upload_audio">Upload audio file</tal:block> 
    248248        <tal:block tal:condition="python: piece_type not in ['audio','image']" i18n:translate="label_upload_a_file">Upload a file</tal:block>... 
     
    269269        </div> 
    270270    </div> 
    271     <div id="tab_spacer" style="height:300px">&nbsp;</div> 
     271    <div id="tab_spacer" style="height:300px" tal:attributes="class python:test(not piece, 'hidden', '')">&nbsp;</div> 
    272272    <div> 
    273     <div class="tab" id="tab_search" i18n:translate="label_or_search_from_pieces" onclick="clickedTab(this,'tab_sheet_search')">... or search from media pieces</div> 
     273    <div class="tab" id="tab_search" tal:attributes="class python:test(not piece, 'tab selected_tab', 'tab')" i18n:translate="label_or_search_from_pieces" onclick="clickedTab(this,'tab_sheet_search')">... or search from media pieces</div> 
    274274    <div class="tab" id="tab_pieces" i18n:translate="label_browse_your_media" onclick="clickedTab(this,'tab_sheet_pieces')">browse your media</div> 
    275275    <div class="tab" id="tab_collections" i18n:translate="label_browse_from_your_collections" onclick="clickedTab(this,'tab_sheet_collections')">browse from your collections</div> 
    276276 
    277     <div class="tab_sheet" id="tab_sheet_search"> 
     277    <div class="tab_sheet" id="tab_sheet_search" tal:attributes="class python:test(not piece, 'tab_sheet selected_tab_sheet', 'tab_sheet')"> 
    278278    <p> 
    279279    <input id="piece-search"  
  • trunk/skins/lemill/widget_exercise.pt

    r3073 r3074  
    6666<div tal:replace="structure text" /> 
    6767</metal:view_guidelines> 
     68 
     69<metal:view_exercise define-macro="view_exercise"> 
     70</metal:view_exercise> 
    6871     
    6972<metal:view_multiple_choices define-macro="view_multiple_choices"> 
     
    113116            tabindex="" 
    114117            type="submit" 
    115             name="add_question" 
     118            name="add_exercise" 
    116119            value="Add question" 
    117120            i18n:attributes="value label_add_question;" 
     
    122125            tabindex="" 
    123126            type="submit" 
    124             name="add_mediapiece" 
     127            name="add_media_piece" 
    125128            value="Add media piece" 
    126129            i18n:attributes="value label_add_media_piece;" 
     
    130133            tabindex="" 
    131134            type="submit" 
    132             name="add_textarea" 
     135            name="add_text_block" 
    133136            value="Add text block" 
    134137            i18n:attributes="value label_add_textarea;" 
     
    138141            tabindex="" 
    139142            type="submit" 
    140             name="add_embedblock" 
     143            name="add_embed_block" 
    141144            value="Add an embedded section" 
    142145            i18n:attributes="value label_add_embed_block;" 
     
    156159</metal:edit_view_guidelines> 
    157160 
    158 <metal:edit_view_guidelines define-macro="edit_view_exercise"> 
    159     <div tal:replace="structure cleaned_chapter" /> 
    160 </metal:edit_view_guidelines> 
     161<metal:edit_view_exercise define-macro="edit_view_exercise"> 
     162    <div> 
     163    <p i18n:translate="exercise_under_construction=" class="formHelp">This question is unfinished and it is hidden for students.</p> 
     164</metal:edit_view_exercise> 
    161165 
    162166 
    163167<metal:edit_view_poll define-macro="edit_view_poll"> 
    164 <label><tal:block i18n:translate="label_exercise_poll_question">Poll question</tal:block>:</label><br /><br /> 
    165168<metal:use use-macro="radio_choice" /> 
    166169</metal:edit_view_poll> 
    167170 
    168171<metal:edit_view_choice define-macro="edit_view_choice"> 
    169 <label><tal:block i18n:translate="label_exercise_choice_question">Choice question</tal:block>:</label><br /><br /> 
    170172<metal:radio_choice define-macro="radio_choice"><table> 
    171173  <tr> 
     
    190192 
    191193<metal:edit_view_multiple_choices define-macro="edit_view_multiple_choices"> 
    192 <label><tal:block i18n:translate="label_exercise_multiple_choice_question">Multiple choice question</tal:block>:</label><br /><br /> 
    193194<table> 
    194195  <tr> 
     
    212213 
    213214<metal:edit_view_fill_in_the_blanks define-macro="edit_view_fill_in_the_blanks"> 
    214 <label><tal:block i18n:translate="label_exercise_fill_in_the_blanks">Fill-in-the-blanks exercise</tal:block>:</label> 
    215 <p tal:content="structure python:context.replace_blanks_with_input_tag(cleaned_chapter['text'],index,readonly=True)">PLACEHOLDER</p> 
     215<p tal:content="structure python:context.replaceBlanksWithInputTag(cleaned_chapter['text'], index, readonly=True, give_answers=True)">PLACEHOLDER</p> 
    216216</metal:edit_view_fill_in_the_blanks> 
    217217 
    218218<metal:edit_view_open_ended define-macro="edit_view_open_ended"> 
    219 <label><tal:block i18n:translate="label_exercise_open_ended">Open-ended question</tal:block>:</label> 
    220219  <p tal:content="structure cleaned_chapter/text">PLACEHOLDER</p> 
    221220  <textarea cols="40" rows="8" value="" disabled="1"></textarea> 
     
    254253</metal:edit_multiple_choices> 
    255254 
     255<metal:edit_fill_in_the_blanks define-macro="edit_fill_in_the_blanks"> 
     256<metal:use use-macro="here/widget_exercise/macros/edit_exercise" /> 
     257</metal:edit_fill_in_the_blanks> 
     258 
     259<metal:edit_open_ended define-macro="edit_open_ended"> 
     260<metal:use use-macro="here/widget_exercise/macros/edit_exercise" /> 
     261</metal:edit_open_ended> 
     262 
    256263 
    257264<metal:edit_question define-macro="edit_exercise"> 
     
    259266  <metal:question_selection use-macro="here/widget_exercise/macros/question_selection" /> 
    260267  <metal:multiple_questions use-macro="here/widget_exercise/macros/multiple_questions_edit" /> 
    261   <metal:edit_fill_in_the_blanks use-macro="here/widget_exercise/macros/edit_fill_in_the_blanks" /> 
    262   <metal:edit_open_ended use-macro="here/widget_exercise/macros/edit_open_ended" /> 
     268  <metal:edit_fill_in_the_blanks use-macro="here/widget_exercise/macros/fill_in_the_blanks_edit" /> 
     269  <metal:edit_open_ended use-macro="here/widget_exercise/macros/open_ended_edit" /> 
    263270  <metal:upload_hot_potatoes use-macro="here/widget_exercise/macros/upload_hot_potatoes" /> 
    264271  <div class="inner_edit" id="preview"> 
     
    318325</metal:upload_hot_potatoes> 
    319326 
    320  
    321 <metal:edit_fill_in_the_blanks define-macro="edit_fill_in_the_blanks"> 
     327<metal:fill_blanks define-macro="fill_in_the_blanks_edit"> 
    322328 <div class="inner_edit" id="fill_in_the_blanks_edit" tal:attributes="style python:test(chapter['type']=='fill_in_the_blanks','display:block','')"> 
    323329   <table width="100%"> 
     
    337343  </table> 
    338344 </div> 
    339 </metal:edit_fill_in_the_blanks> 
    340  
    341  
    342  
    343 <metal:edit_open_ended define-macro="edit_open_ended"> 
     345</metal:fill_blanks> 
     346 
     347<metal:open_ended define-macro="open_ended_edit"> 
    344348 <div class="inner_edit" id="open_ended_edit" tal:attributes="style python:test(chapter['type']=='open_ended','display:block','')"> 
    345349 <table width="100%"><tr> 
     
    357361  </table> 
    358362 </div> 
    359 </metal:edit_open_ended> 
    360  
     363</metal:open_ended> 
    361364 
    362365 
Note: See TracChangeset for help on using the changeset viewer.