~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
<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>

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

    <h1>Edit Exercise - ${exercise.id}</h1>
    <div id="ivle_padding">
      <h3>Exercise Values:</h3>
      <div py:with="iw_prefix='exercise'; iw_label_linebreak=True">
        <iw:text name="id" desc="Identifier">${exercise.id}</iw:text>
        <iw:text name="name" desc="Name">${exercise.name}</iw:text>
        <iw:text name="num_rows" desc="Number of Rows">${exercise.num_rows}</iw:text>
        <iw:textarea name="desc" desc="Description (RST)" cols="80" rows="10">${exercise.description}</iw:textarea>
        <iw:textarea name="solution" desc="Solution" cols="80" rows="5">${exercise.solution}</iw:textarea>
        <iw:textarea name="partial" desc="Partial Solution" cols="80" rows="5">${exercise.partial}</iw:textarea>
        <iw:textarea name="include" desc="Included Code" 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}"
                 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:textarea name="description" desc="Description" cols="80" rows="1">${test_suite.description}</iw:textarea>
                <iw:textarea name="function" desc="Function" cols="80" rows="1">${test_suite.function}</iw:textarea>
                <iw:textarea name="stdin" desc="Stdin" cols="80" rows="4">${test_suite.stdin}</iw:textarea>
                <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_type}</option>
                          <option py:if="var_type != variable.var_type" value="${var_type}">${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_type}</option>
                      </py:for>
                    </select>
                    <label for="new_var_name_${test_suite.suiteid}">Var Name:</label>
                    <input type="text" id="new_var_name_${test_suite.suiteid}" />
                    <label for="new_var_val_${test_suite.suiteid}">Var Value:</label>
                    <input type="text" id="new_var_val_${test_suite.suiteid}" />
                    <label for="new_var_argno_${test_suite.suiteid}">Arg Num:</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}">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>
                        <iw:text name="default" desc="Default Mode">${test_case.test_default}</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">
                            <label for="test_part_${test_part.partid}_part_type">Part Type:</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_type}</option>
                                <option py:if="part_type!=test_part.part_type" value="${part_type}">${part_type}</option>
                              </py:for>
                            </select>
                            <label for="test_part_${test_part.partid}_test_type">Test Type</label>
                            <select name="Test Type" id="test_part_${test_part.partid}_test_type">
                              <py:for each="test_type in test_types">
                                <option py:if="test_type==test_part.test_type" selected="selected" value="${test_type}">${test_type}</option>
                                <option py:if="test_type!=test_part.test_type" value="${test_type}">${test_type}</option>
                              </py:for>
                            </select>
                            <iw:delete action="delete_testpart('${test_part.partid}','${test_case.testid}','${test_suite.suiteid}')" />
                            <iw:textarea name="data" desc="Test" rows="2" cols="80">${test_part.data}</iw:textarea>
                            <iw:text name="file" desc="Filename">${test_part.filename}</iw:text>
                            <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}">Part Type:</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_type}</option>
                                </py:for>
                              </select>
                              <label for="test_part_new_test_type_${test_case.testid}">Test Type:</label>
                              <select name="Test Type" id="test_part_new_test_type_${test_case.testid}">
                                <py:for each="test_type in test_types">
                                  <option value="${test_type}">${test_type}</option>
                                </py:for>
                              </select>
                              <iw:textarea name="data" desc="Test" rows="2" cols="80" />
                              <iw:text name="file" desc="Filename" />
                              <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}')">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" />
                        <iw:text name="default" desc="Default Mode" />
                        <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')">New test suite</a></h3>
          <div class="testsuite" id="suite_data_new">
          <div class="test_suite_vals" py:with="iw_prefix='new_test_suite'">
            <iw:textarea name="description" desc="Description" cols="80" rows="1" />
            <iw:textarea name="function" desc="Function" cols="80" rows="1" />
            <iw:textarea name="stdin" desc="Stdin" cols="80" rows="4" />
            <input type="button" value="Create Suite" onclick="add_suite()" />
          </div>
          </div>
        </li>
      </ul>
      
      <p><a href="/+exercises">Back To Exercise Listing</a></p>
      
    </div>
    
  </body>
</html>