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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:iw="http://www.ivle.org/2009/widgets">
  <head>
    <title>Edit - ${exercise.name}</title>
    <!-- These let the javascript know which worksheet is open -->
    <script type="text/javascript">
      exercise = '${exercise.id}';
    </script>
  </head>
  <body>
    <!--! iw:textarea: A textarea widget wrapper.
          Generates a textarea in a div with a label. Define iw_prefix earlier
          to automatically give a prefix to the name. -->
    <div py:match="iw:textarea" py:with="name=((iw_prefix + '_') or '') + str(select('@name'))">
      <label for="${name}">${select('@desc')}:</label>
      <br py:if="defined('iw_label_linebreak') and iw_label_linebreak" />
      <textarea id="${name}" cols="${select('@cols')}" rows="${select('@rows')}">${select('*|text()')}</textarea>
    </div>

    <div py:match="iw:text" py:with="name=((iw_prefix + '_') or '') + str(select('@name'))">
      <label for="${name}">${select('@desc')}:</label>
      <br py:if="defined('iw_label_linebreak') and iw_label_linebreak" />
      <input type="text" id="${name}" value="${select('*|text()')}" />
    </div>

    <div py:match="iw:radio" py:with="name=((iw_prefix + '_') or '') + str(select('@name')); id=name + '_' + str(select('@value'))">
      <input type="radio" name="${name}" id="${id}"
             value="${str(select('@value'))}" onchange="${iw_onchange if defined('iw_onchange') else None}"
             py:attrs="{'checked': 'checked'} if str(select('@current')) == str(select('@value')) else {}" />
      <label for="${id}">${select('@desc')}</label>
    </div>

    <a py:match="iw:delete" href="javascript:${select('@action')}"><img title="Delete" alt="Delete" src="${mediapath}cross.png"/></a>

    <h1>Edit ${exercise.name}</h1>
    <div id="ivle_padding">
      <div py:with="iw_prefix='exercise'; iw_label_linebreak=True"
           class="stackedform">
        <iw:text name="name" desc="Display name">${exercise.name}</iw:text>
        <div><label for="exercise_id">URL name:</label><br /><span id="exercise_id">${exercise.id}</span></div>
        <iw:text name="num_rows" desc="Predicted code line count">${exercise.num_rows}</iw:text>
        <iw:textarea name="desc" desc="Description (reStructuredText)" cols="80" rows="10">${exercise.description}</iw:textarea>
        <iw:textarea name="solution" desc="Full solution (Python)" cols="80" rows="5">${exercise.solution}</iw:textarea>
        <iw:textarea name="partial" desc="Partial solution (Python, provided to students)" cols="80" rows="5">${exercise.partial}</iw:textarea>
        <iw:textarea name="include" desc="Code available in test cases (Python)" cols="80" rows="5">${exercise.include}</iw:textarea>
        <input type="button" value="Save" onclick="edit_exercise()" />
      </div>

      <ul class="test_suites">
        <py:for each="test_suite in exercise.test_suites">
          <li>
            <h3>
              <a id="suite_header_${test_suite.suiteid}" class="fakelink"
                 onclick="tog('suite_data_${test_suite.suiteid}')">Suite ${test_suite.seq_no + 1}: &ldquo;${test_suite.description}&rdquo;</a>
              <iw:delete action="delete_suite('${test_suite.suiteid}')" />
            </h3>
            
            <div class="testsuite" id="suite_data_${test_suite.suiteid}">
              <div class="test_suite_vals"
                   py:with="iw_prefix='test_suite_%d' % test_suite.suiteid; iw_label_linebreak=True">
                <iw:textarea name="description" desc="Description" cols="80" rows="1">${test_suite.description}</iw:textarea>
                <div>
                  <input type="checkbox" id="test_suite_${test_suite.suiteid}_function_enabled"
                         py:attrs="{'checked': 'checked'} if test_suite.function else {}"
                         onchange="test_suite_checkbox_toggled('function', '${test_suite.suiteid}')"/>
                  <label for="test_suite_${test_suite.suiteid}_function">Call this function:</label>
                  <input type="text" id="test_suite_${test_suite.suiteid}_function"
                         value="${test_suite.function}"
                         py:attrs="{} if test_suite.function else {'disabled': 'disabled'}" />
                </div>
                <div>
                  <input type="checkbox" id="test_suite_${test_suite.suiteid}_stdin_enabled"
                         py:attrs="{'checked': 'checked'} if test_suite.stdin else {}"
                         onchange="test_suite_checkbox_toggled('stdin', '${test_suite.suiteid}')"/>
                  <label for="test_suite_${test_suite.suiteid}_stdin">Send this as standard input:</label>
                  <br />
                  <textarea id="test_suite_${test_suite.suiteid}_stdin" cols="80" rows="4"
                         py:attrs="{} if test_suite.stdin else {'disabled': 'disabled'}">${test_suite.stdin}</textarea>
                </div>
                <input type="button" value="Save Suite" onclick="edit_suite('${test_suite.suiteid}')" />
              </div>
          
              <h4>Variables</h4>
                <div class="test_variables" id="variables_${test_suite.suiteid}">
                  <ul>
                    <li py:for="variable in test_suite.variables">
                      <iw:delete action="delete_var('${variable.varid}', '${test_suite.suiteid}')" />
                      <label for="var_type_${variable.varid}">Type:</label>
                      <select name="Variable Type" id="var_type_${variable.varid}">
                        <py:for each="var_type in var_types">
                          <option py:if="var_type == variable.var_type" selected="selected" value="${var_type}">${var_types[var_type]}</option>
                          <option py:if="var_type != variable.var_type" value="${var_type}">${var_types[var_type]}</option>
                        </py:for>
                      </select>
                      <label for="var_name_${variable.varid}">Var Name:</label>
                      <input type="text" id="var_name_${variable.varid}" value="${variable.var_name}" />
                      <label for="var_val_${variable.varid}">Var Value:</label>
                      <input type="text" id="var_val_${variable.varid}" value="${variable.var_value}"/>
                      <label for="var_argno_${variable.varid}">Arg Num:</label>
                      <input size="5" type="text" id="var_argno_${variable.varid}" value="${variable.arg_no}" />
                      <input type="button" value="Save Variable" onclick="edit_var('${variable.varid}', '${test_suite.suiteid}')" />
                    </li>
                  </ul>
                  <a onclick="tog('add_variable_${test_suite.suiteid}')">New variable</a>
                  <div class="add_variable" id="add_variable_${test_suite.suiteid}">
                    <label for="new_var_type_${test_suite.suiteid}">Type:</label>
                    <select name="Variable Type" id="new_var_type_${test_suite.suiteid}">
                      <py:for each="var_type in var_types">
                        <option  value="${var_type}">${var_types[var_type]}</option>
                      </py:for>
                    </select>
                    <label for="new_var_name_${test_suite.suiteid}">Name:</label>
                    <input type="text" id="new_var_name_${test_suite.suiteid}" />
                    <label for="new_var_val_${test_suite.suiteid}">Value (Python, will be eval'd):</label>
                    <input type="text" id="new_var_val_${test_suite.suiteid}" />
                    <label for="new_var_argno_${test_suite.suiteid}">Argument index:</label>
                    <input size="5" type="text" id="new_var_argno_${test_suite.suiteid}" />
                    <input type="button" value="Add Variable" onclick="add_var('${test_suite.suiteid}')" />
                  </div>
                </div>

              <div class="test_cases" id="test_cases_${test_suite.suiteid}">    
                <ul>
                  <py:for each="test_case in test_suite.test_cases">
                    <li>
                      <h5>
                        <a onclick="tog('test_case_${test_case.testid}_${test_suite.suiteid}')"
                           id="case_header_${test_case.testid}" class="fakelink">
                          Test Case ${test_case.seq_no + 1}: &ldquo;${test_case.passmsg}&rdquo;
                        </a>
                        <iw:delete action="delete_testcase('${test_case.testid}','${test_suite.suiteid}')" />
                      </h5>
                      <div py:with="iw_prefix='test_case_%d_%d' % (test_case.testid, test_suite.suiteid)"
                           class="test_case" id="${iw_prefix}">
                        <iw:text name="pass" desc="Pass message">${test_case.passmsg}</iw:text>
                        <iw:text name="fail" desc="Fail message">${test_case.failmsg}</iw:text>
                        <input type="button" onclick="edit_test_case('${test_case.testid}','${test_suite.suiteid}')" value="Save Case" />

                        <h5>Test Case Parts</h5>
                        <ul class="test_case_parts" id="test_case_parts_${test_case.testid}_${test_suite.suiteid}">
                          <li py:for="test_part in test_case.parts"
                              py:with="iw_prefix='test_part_%d' % test_part.partid">
                            <iw:delete action="delete_testpart('${test_part.partid}','${test_case.testid}','${test_suite.suiteid}')" />
                            <label for="test_part_${test_part.partid}_part_type">Test the solution and attempt</label>
                            <select name="Part Type" id="test_part_${test_part.partid}_part_type">
                              <py:for each="part_type in part_types">
                                <option py:if="part_type==test_part.part_type" selected="selected" value="${part_type}">${part_types[part_type]}</option>
                                <option py:if="part_type!=test_part.part_type" value="${part_type}">${part_types[part_type]}</option>
                              </py:for>
                            </select>
                            <div py:with="iw_prefix='test_part_%d' % test_part.partid; iw_onchange='test_part_type_changed(%d)' % test_part.partid">
                              <iw:radio name="test_type" desc="for an exact match, with no normalisation" value="match" current="${test_part.test_type}" />
                              <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}" />
                              <iw:radio name="test_type" desc="using the following comparison function" value="check" current="${test_part.test_type}" />
                            </div>
                            <textarea id="test_part_${test_part.partid}_data" cols="80" rows="2"
                                      py:attrs="{'disabled': 'disabled'} if test_part.test_type == 'match' else {}">${test_part.data}</textarea>
                            <br />
                            <input type="button" value="Save Part" onclick="edit_test_part('${test_part.partid}', '${test_case.testid}', ${test_suite.suiteid})" />
                          </li>
                          <li py:with="iw_prefix='test_part_new'">
                            <a onclick="tog('new_test_part_${test_case.testid}')">New test case part</a>
                            <div class="add_new_part" id="new_test_part_${test_case.testid}">
                              <label for="test_part_new_part_type_${test_case.testid}">Test the solution and attempt</label>
                              <select name="Part Type" id="test_part_new_part_type_${test_case.testid}">
                                <py:for each="part_type in part_types">
                                  <option value="${part_type}">${part_types[part_type]}</option>
                                </py:for>
                              </select>
                              <div py:with="iw_prefix='test_part_new_%d' % test_case.testid; iw_onchange='test_part_type_changed(\'new_%d\')' % test_case.testid">
                                <iw:radio name="test_type" desc="for an exact match, with no normalisation" value="match" current="match" />
                                <iw:radio name="test_type" desc="for an exact match, after passing each through the following normalisation function" value="norm" />
                                <iw:radio name="test_type" desc="using the following comparison function" value="check" />
                              </div>
                              <textarea id="test_part_new_${test_case.testid}_data" disabled="disabled" cols="80" rows="2"></textarea>
                              <br />
                              <input type="button" value="Create Part" onclick="add_test_part('${test_case.testid}', '${test_suite.suiteid}')" id="new_test_part_save_${test_case.testid}" />
                            </div>
                          </li>
                        </ul>
                      </div>
                    </li>
                  </py:for>
                  <li class="new">
                    <h5><a onclick="tog('new_test_case_${test_suite.suiteid}')" class="fakelink">New test case</a></h5>
                    <div py:with="iw_prefix='new_test_case_%d' % (test_suite.suiteid)"
                         class="test_case" id="${iw_prefix}">
                        <iw:text name="pass" desc="Pass message" />
                        <iw:text name="fail" desc="Fail message" />
                        <input type="button" value="Create Case" onclick="add_test_case('${test_suite.suiteid}')" />
                    </div>
                  </li>
                </ul>
              </div>
              
            </div>
          </li>
        </py:for>
        <li class="new">
          <h3><a onclick="tog('suite_data_new')" class="fakelink">New test suite</a></h3>
          <div class="testsuite" id="suite_data_new">
          <div class="test_suite_vals" py:with="iw_prefix='test_suite_new'; iw_label_linebreak=True">
            <iw:textarea name="description" desc="Description" cols="80" rows="1" />
            <div>
              <input type="checkbox" id="test_suite_new_function_enabled" onchange="test_suite_checkbox_toggled('function', 'new')"/>
              <label for="test_suite_new_function">Call this function:</label>
              <input type="text" id="test_suite_new_function" value="" disabled="disabled" />
            </div>
            <div>
              <input type="checkbox" id="test_suite_new_stdin_enabled"
                     onchange="test_suite_checkbox_toggled('stdin', 'new')"/>
              <label for="test_suite_new_stdin">Send this as standard input:</label>
              <br />
              <textarea id="test_suite_new_stdin" cols="80" rows="4" disabled="disabled"></textarea>
            </div>
            <input type="button" value="Create Suite" onclick="add_suite()" />
          </div>
          </div>
        </li>
      </ul>
    </div>
  </body>
</html>