~azzar1/unity/add-show-desktop-key

1099.1.212 by Nick Chadwick
Added a new page to display exercises. This will then be modified to
1
<html xmlns="http://www.w3.org/1999/xhtml"
1099.7.7 by William Grant
Start a trial of templating out widgets in the exercise editor.
2
      xmlns:py="http://genshi.edgewall.org/"
3
      xmlns:iw="http://www.ivle.org/2009/widgets">
1099.1.212 by Nick Chadwick
Added a new page to display exercises. This will then be modified to
4
  <head>
5
    <title>Edit - ${exercise.name}</title>
6
    <!-- These let the javascript know which worksheet is open -->
7
    <script type="text/javascript">
1099.1.216 by Nick Chadwick
Started adding in add and save options in the exercise edit view, to
8
      exercise = '${exercise.id}';
1099.1.212 by Nick Chadwick
Added a new page to display exercises. This will then be modified to
9
    </script>
10
  </head>
11
  <body>
1099.7.7 by William Grant
Start a trial of templating out widgets in the exercise editor.
12
    <!--! iw:textarea: A textarea widget wrapper.
13
          Generates a textarea in a div with a label. Define iw_prefix earlier
14
          to automatically give a prefix to the name. -->
15
    <div py:match="iw:textarea" py:with="name=((iw_prefix + '_') or '') + str(select('@name'))">
16
      <label for="${name}">${select('@desc')}:</label>
1099.7.10 by William Grant
The root exercise widgets are now also templated out.
17
      <br py:if="defined('iw_label_linebreak') and iw_label_linebreak" />
1099.7.7 by William Grant
Start a trial of templating out widgets in the exercise editor.
18
      <textarea id="${name}" cols="${select('@cols')}" rows="${select('@rows')}">${select('*|text()')}</textarea>
19
    </div>
20
1099.7.9 by William Grant
Test case addition/editing widgets are templated.
21
    <div py:match="iw:text" py:with="name=((iw_prefix + '_') or '') + str(select('@name'))">
22
      <label for="${name}">${select('@desc')}:</label>
1099.7.10 by William Grant
The root exercise widgets are now also templated out.
23
      <br py:if="defined('iw_label_linebreak') and iw_label_linebreak" />
1099.7.9 by William Grant
Test case addition/editing widgets are templated.
24
      <input type="text" id="${name}" value="${select('*|text()')}" />
25
    </div>
26
1420 by William Grant
Redo the exercise test part type (check/norm) selection, with radio buttons. Also add an exact match option, as yet unfunctional.
27
    <div py:match="iw:radio" py:with="name=((iw_prefix + '_') or '') + str(select('@name')); id=name + '_' + str(select('@value'))">
1428 by William Grant
Enable, disable, and set default code in the test part code widget when the test type is changed.
28
      <input type="radio" name="${name}" id="${id}"
29
             value="${str(select('@value'))}" onchange="${iw_onchange if defined('iw_onchange') else None}"
1420 by William Grant
Redo the exercise test part type (check/norm) selection, with radio buttons. Also add an exact match option, as yet unfunctional.
30
             py:attrs="{'checked': 'checked'} if str(select('@current')) == str(select('@value')) else {}" />
31
      <label for="${id}">${select('@desc')}</label>
32
    </div>
33
1099.7.15 by William Grant
Extract delete links into iw:delete, giving them titles and alts.
34
    <a py:match="iw:delete" href="javascript:${select('@action')}"><img title="Delete" alt="Delete" src="${mediapath}cross.png"/></a>
35
1394.2.15 by William Grant
Prettify ExerciseEditView a bit.
36
    <h1>Edit ${exercise.name}</h1>
1099.1.212 by Nick Chadwick
Added a new page to display exercises. This will then be modified to
37
    <div id="ivle_padding">
1394.2.15 by William Grant
Prettify ExerciseEditView a bit.
38
      <div py:with="iw_prefix='exercise'; iw_label_linebreak=True"
39
           class="stackedform">
1463.1.5 by William Grant
Rebrand lots of exercise fields.
40
        <iw:text name="name" desc="Display name">${exercise.name}</iw:text>
41
        <iw:text name="id" desc="URL name">${exercise.id}</iw:text>
42
        <iw:text name="num_rows" desc="Predicted code line count">${exercise.num_rows}</iw:text>
43
        <iw:textarea name="desc" desc="Description (reStructuredText)" cols="80" rows="10">${exercise.description}</iw:textarea>
44
        <iw:textarea name="solution" desc="Full solution (Python)" cols="80" rows="5">${exercise.solution}</iw:textarea>
45
        <iw:textarea name="partial" desc="Partial solution (Python, provided to students)" cols="80" rows="5">${exercise.partial}</iw:textarea>
46
        <iw:textarea name="include" desc="Included code (Python)" cols="80" rows="5">${exercise.include}</iw:textarea>
1099.7.11 by William Grant
Turn all of the exercise editor's submit inputs into buttons, drop some
47
        <input type="button" value="Save" onclick="edit_exercise()" />
1099.7.10 by William Grant
The root exercise widgets are now also templated out.
48
      </div>
49
1099.7.19 by William Grant
Box in the contents of suites.
50
      <ul class="test_suites">
1099.1.213 by Nick Chadwick
Modifief exercise view, so that exercises can now be viewed in an
51
        <py:for each="test_suite in exercise.test_suites">
52
          <li>
1099.7.4 by William Grant
Wrap some exercise admin heading HTML to be a bit less unreadable.
53
            <h3>
54
              <a id="suite_header_${test_suite.suiteid}"
1099.7.34 by William Grant
Put the suite description in quotes.
55
                 onclick="tog('suite_data_${test_suite.suiteid}')">Suite ${test_suite.seq_no + 1}: &ldquo;${test_suite.description}&rdquo;</a>
1099.7.15 by William Grant
Extract delete links into iw:delete, giving them titles and alts.
56
              <iw:delete action="delete_suite('${test_suite.suiteid}')" />
1099.7.4 by William Grant
Wrap some exercise admin heading HTML to be a bit less unreadable.
57
            </h3>
1099.1.213 by Nick Chadwick
Modifief exercise view, so that exercises can now be viewed in an
58
            
59
            <div class="testsuite" id="suite_data_${test_suite.suiteid}">
1099.7.8 by William Grant
Suite editing widgets are templated.
60
              <div class="test_suite_vals"
1428.1.3 by William Grant
Apply the function input changes to the stdin input, and add a linebreak after the 'Description' label.
61
                   py:with="iw_prefix='test_suite_%d' % test_suite.suiteid; iw_label_linebreak=True">
1099.7.8 by William Grant
Suite editing widgets are templated.
62
                <iw:textarea name="description" desc="Description" cols="80" rows="1">${test_suite.description}</iw:textarea>
1428.1.2 by William Grant
Make the test suite function widget a little nicer, by adding a checkbox and more description.
63
                <div>
64
                  <input type="checkbox" id="test_suite_${test_suite.suiteid}_function_enabled"
65
                         py:attrs="{'checked': 'checked'} if test_suite.function else {}"
1428.1.3 by William Grant
Apply the function input changes to the stdin input, and add a linebreak after the 'Description' label.
66
                         onchange="test_suite_checkbox_toggled('function', '${test_suite.suiteid}')"/>
1428.1.2 by William Grant
Make the test suite function widget a little nicer, by adding a checkbox and more description.
67
                  <label for="test_suite_${test_suite.suiteid}_function">Call this function:</label>
68
                  <input type="text" id="test_suite_${test_suite.suiteid}_function"
69
                         value="${test_suite.function}"
70
                         py:attrs="{} if test_suite.function else {'disabled': 'disabled'}" />
71
                </div>
1428.1.3 by William Grant
Apply the function input changes to the stdin input, and add a linebreak after the 'Description' label.
72
                <div>
73
                  <input type="checkbox" id="test_suite_${test_suite.suiteid}_stdin_enabled"
74
                         py:attrs="{'checked': 'checked'} if test_suite.stdin else {}"
75
                         onchange="test_suite_checkbox_toggled('stdin', '${test_suite.suiteid}')"/>
76
                  <label for="test_suite_${test_suite.suiteid}_stdin">Send this as standard input:</label>
77
                  <br />
78
                  <textarea id="test_suite_${test_suite.suiteid}_stdin" cols="80" rows="4"
79
                         py:attrs="{} if test_suite.stdin else {'disabled': 'disabled'}">${test_suite.stdin}</textarea>
80
                </div>
1099.7.11 by William Grant
Turn all of the exercise editor's submit inputs into buttons, drop some
81
                <input type="button" value="Save Suite" onclick="edit_suite('${test_suite.suiteid}')" />
1099.1.214 by Nick Chadwick
The skeleton for editing an exercise has now been created. The next
82
              </div>
1099.1.212 by Nick Chadwick
Added a new page to display exercises. This will then be modified to
83
          
1099.7.20 by William Grant
Show variables and test cases by default.
84
              <h4>Variables</h4>
1099.1.213 by Nick Chadwick
Modifief exercise view, so that exercises can now be viewed in an
85
                <div class="test_variables" id="variables_${test_suite.suiteid}">
1099.7.27 by William Grant
Turn variable lists into real <ul>s rather than <br>-separated <span>s.
86
                  <ul>
87
                    <li py:for="variable in test_suite.variables">
1099.7.15 by William Grant
Extract delete links into iw:delete, giving them titles and alts.
88
                      <iw:delete action="delete_var('${variable.varid}', '${test_suite.suiteid}')" />
1099.1.213 by Nick Chadwick
Modifief exercise view, so that exercises can now be viewed in an
89
                      <label for="var_type_${variable.varid}">Type:</label>
90
                      <select name="Variable Type" id="var_type_${variable.varid}">
91
                        <py:for each="var_type in var_types">
1394.1.8 by William Grant
Prettify part/test/var types.
92
                          <option py:if="var_type == variable.var_type" selected="selected" value="${var_type}">${var_types[var_type]}</option>
93
                          <option py:if="var_type != variable.var_type" value="${var_type}">${var_types[var_type]}</option>
1099.1.213 by Nick Chadwick
Modifief exercise view, so that exercises can now be viewed in an
94
                        </py:for>
95
                      </select>
96
                      <label for="var_name_${variable.varid}">Var Name:</label>
97
                      <input type="text" id="var_name_${variable.varid}" value="${variable.var_name}" />
98
                      <label for="var_val_${variable.varid}">Var Value:</label>
99
                      <input type="text" id="var_val_${variable.varid}" value="${variable.var_value}"/>
100
                      <label for="var_argno_${variable.varid}">Arg Num:</label>
101
                      <input size="5" type="text" id="var_argno_${variable.varid}" value="${variable.arg_no}" />
1099.7.12 by William Grant
Merge from trunk.
102
                      <input type="button" value="Save Variable" onclick="edit_var('${variable.varid}', '${test_suite.suiteid}')" />
1099.7.27 by William Grant
Turn variable lists into real <ul>s rather than <br>-separated <span>s.
103
                    </li>
104
                  </ul>
1099.7.36 by William Grant
Retitle the buttons to add parts and variables.
105
                  <a onclick="tog('add_variable_${test_suite.suiteid}')">New variable</a>
1099.1.217 by Nick Chadwick
working on making the exercise editor complete
106
                  <div class="add_variable" id="add_variable_${test_suite.suiteid}">
107
                    <label for="new_var_type_${test_suite.suiteid}">Type:</label>
108
                    <select name="Variable Type" id="new_var_type_${test_suite.suiteid}">
109
                      <py:for each="var_type in var_types">
1394.1.8 by William Grant
Prettify part/test/var types.
110
                        <option  value="${var_type}">${var_types[var_type]}</option>
1099.1.217 by Nick Chadwick
working on making the exercise editor complete
111
                      </py:for>
112
                    </select>
1463.1.8 by William Grant
Rename some of the variable fields to be very slightly less unobvious.
113
                    <label for="new_var_name_${test_suite.suiteid}">Name:</label>
1099.1.217 by Nick Chadwick
working on making the exercise editor complete
114
                    <input type="text" id="new_var_name_${test_suite.suiteid}" />
1463.1.8 by William Grant
Rename some of the variable fields to be very slightly less unobvious.
115
                    <label for="new_var_val_${test_suite.suiteid}">Value (Python, will be eval'd):</label>
1099.1.217 by Nick Chadwick
working on making the exercise editor complete
116
                    <input type="text" id="new_var_val_${test_suite.suiteid}" />
1463.1.8 by William Grant
Rename some of the variable fields to be very slightly less unobvious.
117
                    <label for="new_var_argno_${test_suite.suiteid}">Argument index:</label>
1099.1.217 by Nick Chadwick
working on making the exercise editor complete
118
                    <input size="5" type="text" id="new_var_argno_${test_suite.suiteid}" />
1099.7.11 by William Grant
Turn all of the exercise editor's submit inputs into buttons, drop some
119
                    <input type="button" value="Add Variable" onclick="add_var('${test_suite.suiteid}')" />
1099.1.217 by Nick Chadwick
working on making the exercise editor complete
120
                  </div>
1099.1.213 by Nick Chadwick
Modifief exercise view, so that exercises can now be viewed in an
121
                </div>
1099.7.4 by William Grant
Wrap some exercise admin heading HTML to be a bit less unreadable.
122
1099.1.213 by Nick Chadwick
Modifief exercise view, so that exercises can now be viewed in an
123
              <div class="test_cases" id="test_cases_${test_suite.suiteid}">    
124
                <ul>
125
                  <py:for each="test_case in test_suite.test_cases">
126
                    <li>
1099.7.4 by William Grant
Wrap some exercise admin heading HTML to be a bit less unreadable.
127
                      <h5>
128
                        <a onclick="tog('test_case_${test_case.testid}_${test_suite.suiteid}')"
1099.7.33 by William Grant
Include the test case pass message in the test case heading.
129
                           id="case_header_${test_case.testid}">Test Case ${test_case.seq_no + 1}: &ldquo;${test_case.passmsg}&rdquo;</a>
1099.7.15 by William Grant
Extract delete links into iw:delete, giving them titles and alts.
130
                        <iw:delete action="delete_testcase('${test_case.testid}','${test_suite.suiteid}')" />
1099.7.4 by William Grant
Wrap some exercise admin heading HTML to be a bit less unreadable.
131
                      </h5>
1099.7.9 by William Grant
Test case addition/editing widgets are templated.
132
                      <div py:with="iw_prefix='test_case_%d_%d' % (test_case.testid, test_suite.suiteid)"
133
                           class="test_case" id="${iw_prefix}">
1394.1.5 by William Grant
Drop TestSuite file match default from the UI -- we don't support file tests any more.
134
                        <iw:text name="pass" desc="Pass message">${test_case.passmsg}</iw:text>
135
                        <iw:text name="fail" desc="Fail message">${test_case.failmsg}</iw:text>
1099.7.11 by William Grant
Turn all of the exercise editor's submit inputs into buttons, drop some
136
                        <input type="button" onclick="edit_test_case('${test_case.testid}','${test_suite.suiteid}')" value="Save Case" />
1099.7.9 by William Grant
Test case addition/editing widgets are templated.
137
1099.6.1 by Nick Chadwick
Exercise-ui is now able to create an entire exercise.
138
                        <h5>Test Case Parts</h5>
1099.7.26 by William Grant
Reclass the test case part container, unhide it, and fix padding.
139
                        <ul class="test_case_parts" id="test_case_parts_${test_case.testid}_${test_suite.suiteid}">
1099.7.14 by William Grant
Template out bits of the TestCasePart editor.
140
                          <li py:for="test_part in test_case.parts"
141
                              py:with="iw_prefix='test_part_%d' % test_part.partid">
1420 by William Grant
Redo the exercise test part type (check/norm) selection, with radio buttons. Also add an exact match option, as yet unfunctional.
142
                            <iw:delete action="delete_testpart('${test_part.partid}','${test_case.testid}','${test_suite.suiteid}')" />
143
                            <label for="test_part_${test_part.partid}_part_type">Test the solution and attempt</label>
1099.7.14 by William Grant
Template out bits of the TestCasePart editor.
144
                            <select name="Part Type" id="test_part_${test_part.partid}_part_type">
1099.1.217 by Nick Chadwick
working on making the exercise editor complete
145
                              <py:for each="part_type in part_types">
1394.1.8 by William Grant
Prettify part/test/var types.
146
                                <option py:if="part_type==test_part.part_type" selected="selected" value="${part_type}">${part_types[part_type]}</option>
147
                                <option py:if="part_type!=test_part.part_type" value="${part_type}">${part_types[part_type]}</option>
1099.1.217 by Nick Chadwick
working on making the exercise editor complete
148
                              </py:for>
149
                            </select>
1428 by William Grant
Enable, disable, and set default code in the test part code widget when the test type is changed.
150
                            <div py:with="iw_prefix='test_part_%d' % test_part.partid; iw_onchange='test_part_type_changed(%d)' % test_part.partid">
1420 by William Grant
Redo the exercise test part type (check/norm) selection, with radio buttons. Also add an exact match option, as yet unfunctional.
151
                              <iw:radio name="test_type" desc="for an exact match, with no normalisation" value="match" current="${test_part.test_type}" />
152
                              <iw:radio name="test_type" desc="for an exact match, after passing each through the following normalisation function" value="norm" current="${test_part.test_type}" />
153
                              <iw:radio name="test_type" desc="using the following comparison function" value="check" current="${test_part.test_type}" />
154
                            </div>
1428 by William Grant
Enable, disable, and set default code in the test part code widget when the test type is changed.
155
                            <textarea id="test_part_${test_part.partid}_data" cols="80" rows="2"
156
                                      py:attrs="{'disabled': 'disabled'} if test_part.test_type == 'match' else {}">${test_part.data}</textarea>
1394.1.9 by William Grant
Prettify testcasepart UI a bit.
157
                            <br />
1099.7.11 by William Grant
Turn all of the exercise editor's submit inputs into buttons, drop some
158
                            <input type="button" value="Save Part" onclick="edit_test_part('${test_part.partid}', '${test_case.testid}', ${test_suite.suiteid})" />
1099.7.13 by William Grant
Move test case parts into <li>s, and indent their content.
159
                          </li>
1099.7.38 by William Grant
Template bits of the test case part addition form.
160
                          <li py:with="iw_prefix='test_part_new'">
1099.7.37 by William Grant
Move the new test case part form into the list.
161
                            <a onclick="tog('new_test_part_${test_case.testid}')">New test case part</a>
162
                            <div class="add_new_part" id="new_test_part_${test_case.testid}">
1420 by William Grant
Redo the exercise test part type (check/norm) selection, with radio buttons. Also add an exact match option, as yet unfunctional.
163
                              <label for="test_part_new_part_type_${test_case.testid}">Test the solution and attempt</label>
1099.7.38 by William Grant
Template bits of the test case part addition form.
164
                              <select name="Part Type" id="test_part_new_part_type_${test_case.testid}">
1099.7.37 by William Grant
Move the new test case part form into the list.
165
                                <py:for each="part_type in part_types">
1394.1.8 by William Grant
Prettify part/test/var types.
166
                                  <option value="${part_type}">${part_types[part_type]}</option>
1099.7.37 by William Grant
Move the new test case part form into the list.
167
                                </py:for>
168
                              </select>
1428 by William Grant
Enable, disable, and set default code in the test part code widget when the test type is changed.
169
                              <div py:with="iw_prefix='test_part_new_%d' % test_case.testid; iw_onchange='test_part_type_changed(\'new_%d\')' % test_case.testid">
170
                                <iw:radio name="test_type" desc="for an exact match, with no normalisation" value="match" current="match" />
1420 by William Grant
Redo the exercise test part type (check/norm) selection, with radio buttons. Also add an exact match option, as yet unfunctional.
171
                                <iw:radio name="test_type" desc="for an exact match, after passing each through the following normalisation function" value="norm" />
172
                                <iw:radio name="test_type" desc="using the following comparison function" value="check" />
173
                              </div>
1428 by William Grant
Enable, disable, and set default code in the test part code widget when the test type is changed.
174
                              <textarea id="test_part_new_${test_case.testid}_data" disabled="disabled" cols="80" rows="2"></textarea>
1394.1.9 by William Grant
Prettify testcasepart UI a bit.
175
                              <br />
1099.7.37 by William Grant
Move the new test case part form into the list.
176
                              <input type="button" value="Create Part" onclick="add_test_part('${test_case.testid}', '${test_suite.suiteid}')" id="new_test_part_save_${test_case.testid}" />
177
                            </div>
178
                          </li>
1099.7.13 by William Grant
Move test case parts into <li>s, and indent their content.
179
                        </ul>
1099.1.213 by Nick Chadwick
Modifief exercise view, so that exercises can now be viewed in an
180
                      </div>
181
                    </li>
182
                  </py:for>
1099.7.31 by William Grant
Also fade new test cases.
183
                  <li class="new">
1099.7.32 by William Grant
Turn the test case addition form into something rather more like the edit form.
184
                    <h5><a onclick="tog('new_test_case_${test_suite.suiteid}')">New test case</a></h5>
1099.7.9 by William Grant
Test case addition/editing widgets are templated.
185
                    <div py:with="iw_prefix='new_test_case_%d' % (test_suite.suiteid)"
1099.7.32 by William Grant
Turn the test case addition form into something rather more like the edit form.
186
                         class="test_case" id="${iw_prefix}">
1394.1.5 by William Grant
Drop TestSuite file match default from the UI -- we don't support file tests any more.
187
                        <iw:text name="pass" desc="Pass message" />
188
                        <iw:text name="fail" desc="Fail message" />
1099.7.16 by William Grant
Redo the new test case stuff to show and hide well.
189
                        <input type="button" value="Create Case" onclick="add_test_case('${test_suite.suiteid}')" />
1099.1.221 by Nick Chadwick
added in extra parts to the exercise edit view. Now almost all
190
                    </div>
191
                  </li>
1099.1.213 by Nick Chadwick
Modifief exercise view, so that exercises can now be viewed in an
192
                </ul>
193
              </div>
194
              
195
            </div>
196
          </li>
197
        </py:for>
1099.7.29 by William Grant
Redo the suite addition form in a manner much more like the suite edit form.
198
        <li class="new">
199
          <h3><a onclick="tog('suite_data_new')">New test suite</a></h3>
200
          <div class="testsuite" id="suite_data_new">
1428.1.3 by William Grant
Apply the function input changes to the stdin input, and add a linebreak after the 'Description' label.
201
          <div class="test_suite_vals" py:with="iw_prefix='test_suite_new'; iw_label_linebreak=True">
1099.7.7 by William Grant
Start a trial of templating out widgets in the exercise editor.
202
            <iw:textarea name="description" desc="Description" cols="80" rows="1" />
1428.1.2 by William Grant
Make the test suite function widget a little nicer, by adding a checkbox and more description.
203
            <div>
1428.1.3 by William Grant
Apply the function input changes to the stdin input, and add a linebreak after the 'Description' label.
204
              <input type="checkbox" id="test_suite_new_function_enabled" onchange="test_suite_checkbox_toggled('function', 'new')"/>
1428.1.2 by William Grant
Make the test suite function widget a little nicer, by adding a checkbox and more description.
205
              <label for="test_suite_new_function">Call this function:</label>
206
              <input type="text" id="test_suite_new_function" value="" disabled="disabled" />
207
            </div>
1428.1.3 by William Grant
Apply the function input changes to the stdin input, and add a linebreak after the 'Description' label.
208
            <div>
209
              <input type="checkbox" id="test_suite_new_stdin_enabled"
210
                     onchange="test_suite_checkbox_toggled('stdin', 'new')"/>
211
              <label for="test_suite_new_stdin">Send this as standard input:</label>
212
              <br />
213
              <textarea id="test_suite_new_stdin" cols="80" rows="4" disabled="disabled"></textarea>
214
            </div>
1099.7.11 by William Grant
Turn all of the exercise editor's submit inputs into buttons, drop some
215
            <input type="button" value="Create Suite" onclick="add_suite()" />
1099.7.2 by William Grant
Move the test suite creation stuff into the suite <ul>.
216
          </div>
1099.7.29 by William Grant
Redo the suite addition form in a manner much more like the suite edit form.
217
          </div>
1099.7.2 by William Grant
Move the test suite creation stuff into the suite <ul>.
218
        </li>
1099.1.213 by Nick Chadwick
Modifief exercise view, so that exercises can now be viewed in an
219
      </ul>
1099.1.228 by Nick Chadwick
Merged from trunk.
220
      
221
      <p><a href="/+exercises">Back To Exercise Listing</a></p>
222
      
1099.1.212 by Nick Chadwick
Added a new page to display exercises. This will then be modified to
223
    </div>
1099.1.213 by Nick Chadwick
Modifief exercise view, so that exercises can now be viewed in an
224
    
1099.1.212 by Nick Chadwick
Added a new page to display exercises. This will then be modified to
225
  </body>
226
</html>