gustafn
committed
on 20 Apr 22
Revert change at least until the change is clear.
/lib/inclass-exam-answer.wf (+36 -17)
184 184     return [done_form_loader $ctx $form_name]
185 185   }
186 186
187 187   set item_nr [$obj property position]
188 188
189 189   set parent_id [$obj parent_id]
190 190   #:msg "working_form_loader [$obj instance_attributes]"
191 191   set parent_obj [::xo::db::CrClass get_instance_from_db -item_id $parent_id]
192 192
193 193   #
194 194   # In case shuffling is required, fetch via the shuffled position.
195 195   #
196 196   set shuffle_id [expr {[$parent_obj property shuffle_items 0] ? [$obj creation_user] : -1}]
197 197   set position [::xowf::test_item::question_manager shuffled_index \
198 198                     -shuffle_id $shuffle_id \
199 199                     $parent_obj $item_nr]
200 200   #ns_log notice "============ working_form_loader load form on pos $position"
201 201   #
202 202   # Load the form.
203 203   #
  204   set form_obj [::xowf::test_item::question_manager nth_question_obj $parent_obj $position]
204 205
  206   if {0} {
  207     # Deactivated for now.
205 208     set form_info [::xowf::test_item::question_manager nth_question_form \
206 209                        -with_numbers \
207 210                        -with_title=false \
208 211                        -titleless_form \
209 212                        -with_minutes \
210 213                        -position $position \
211 214                        -item_nr $item_nr \
212 215                        $parent_obj]
213 216
214 217     set form_obj [::xowiki::Form new \
215 218                       -destroy_on_cleanup \
216 219                       -name en:one_question \
217 220                       -title [dict get [lindex [dict get $form_info title_infos] 0] full_title] \
218 221                       -form [list [dict get $form_info form] text/html] \
219 222                       -text {} \
220 223                       -anon_instances t \
221 224                       -form_constraints [dict get $form_info form_constraints]]
  225   }
  226
222 227   #
223 228   # Update IP address each time the form is loaded.
224 229   #
225 230   if {[$obj state] in {"initial" "working"}} {
226 231     $obj set_property ip [expr {[ns_conn isconnected] ? [ad_conn peeraddr] : "nowhere"}]
227 232   }
228 233
229 234   #
230 235   # Update the title of the page
231 236   #
  237   if {0} {
232 238     :set_title $obj -position $position -item_nr $item_nr -for_question -with_minutes -form_info $form_info
  239   } else {
  240     :set_title $obj -position $position -item_nr $item_nr -for_question -with_minutes
  241   }
233 242
234 243   #
235 244   # Disallow paste if required
236 245   #
237 246   if {![$parent_obj property allow_paste true]} {
238 247     ::xowf::test_item::question_manager disallow_paste $form_obj
239 248   }
240 249
241 250   return $form_obj
242 251 }
243 252
244 253 #
245 254 # Done form loader
246 255 #
247 256 proc done_form_loader {ctx form_name} {
248 257   set obj [$ctx object]
249 258   #
250 259   #
251 260   #
252 261   set container [$ctx wf_container]
 
267 276                    ]
268 277   }
269 278   return $result
270 279 }
271 280
272 281 #
273 282 # Set "title" with question/user/IP information.  Note that the
274 283 # "set_title" method is as well responsible for calling the rename
275 284 # function via question_manager.
276 285 #
277 286 :proc set_title {
278 287   obj
279 288   -position:integer
280 289   -item_nr:integer
281 290   {-for_question:switch false}
282 291   {-with_minutes:switch false}
283 292   {-form_info ""}
284 293 } {
285 294   set parent_obj [::xo::db::CrClass get_instance_from_db -item_id [$obj parent_id]]
286 295   if {$for_question && [$obj state] in {initial working}} {
  296     if {$form_info eq ""} {
  297     set form_info [::xowf::test_item::question_manager nth_question_form \
  298                        -with_numbers \
  299                        -with_title=false \
  300                        -with_minutes=$with_minutes \
  301                        -position $position \
  302                        -item_nr $item_nr \
  303                        $parent_obj]
  304     }
287 305     set title_info [lindex [dict get $form_info title_infos] 0]
288 306     set titleString [dict get $title_info full_title]
289 307     set title [list [string trim $titleString]]
290 308   }
291 309   lappend title \
292 310       [$parent_obj title] \
293 311       "IP: [$obj property ip]"
294 312   #ns_log notice "SETTING $obj title [join $title { · }]"
295 313   $obj title [join $title " · "]
296 314
297 315   #:msg set_title-set_parameter-MenuBar-[$obj state]
298 316   :plain_template $obj
299 317
300 318   if {[$parent_obj state] eq "published" && [$obj state] ne "done"} {
301 319     set synchronized [$parent_obj property synchronized 0]
302 320     set target_time [::xowf::test_item::question_manager exam_target_time \
303 321                          -manager $parent_obj \
304 322                          -base_time [expr { $synchronized
305 323                                             ? [$parent_obj last_modified]
306 324                                             : [$obj creation_date]}] \
 
332 350 }
333 351 #
334 352 # Form loader for summary (shows all submission data of a user)
335 353 #
336 354 # This form loader is e.g. called indirectly by www-print-answers of
337 355 # oneline-exam.wf
338 356 #
339 357 :proc summary_form {ctx form_title} {
340 358   set obj [$ctx object]
341 359   set parent_obj [::xo::db::CrClass  get_instance_from_db -item_id [$obj parent_id]]
342 360   #:msg "summary_form_loader $form_title [$obj instance_attributes]"
343 361
344 362   set shuffle_id [expr {[$parent_obj property shuffle_items 0] ? [$obj creation_user] : -1}]
345 363   set form_info [::xowf::test_item::question_manager combined_question_form \
346 364                      -with_numbers \
347 365                      -with_title \
348 366                      -with_points \
349 367                      -user_specific \
350 368                      -shuffle_id $shuffle_id \
351 369                      $parent_obj]
  370   #ns_log notice "SUMMARY FORM shuffle_id $shuffle_id $form_info"
352 371
353 372   set summary_form [dict get $form_info form]
354 373   set summary_fc [dict get $form_info disabled_form_constraints]
355 374   regsub -all {</?form[^>]*>} $summary_form {} summary_form
356 375
357 376   :set_title $obj
358 377   #ns_log notice summary_form=$summary_form
359 378   #ns_log notice fc=$summary_fc
360 379   return [::xowiki::Form new \
361 380               -destroy_on_cleanup \
362 381               -name en:summary \
363 382               -title $form_title \
364 383               -form [list <form><div>$summary_form</div></form> text/html] \
365 384               -text {} \
366 385               -anon_instances t \
367 386               -form_constraints $summary_fc]
368 387 }
369 388
370 389 :proc addSignature {obj} {
371 390   set answerAttributes [xowf::test_item::renaming_form_loader \