xowf::test_item::Answer_manager method time_window_setup (public)

 <instance of xowf::test_item::Answer_manager[i]> time_window_setup \
    -time_window time_window  parentObj

Defined in packages/xowf/tcl/test-item-procs.tcl

Check the provided time_window values, adjust it if necessary, and make sure, according atjobs are provided. This method was made public, since there configuration window update in inclass-exam.wf requires this for the update via update_attribute_from_slot. Probably, we should move the core of this function to this file, and make it protected again.

Switches:
-time_window
(required)
Parameters:
parentObj

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.
Source code:
set dtstart [dict get $time_window time_window.dtstart]
set dtend [dict get $time_window time_window.dtend]

if {$dtstart ne ""} {
  set total_minutes [question_manager total_minutes_for_exam -manager $parentObj]
  ns_log notice "#### create_workflows: atjobs for time_window <$time_window> total-mins $total_minutes"
  set start_clock [clock scan $dtstart -format %Y-%m-%dT%H:%M]

  if {$dtend eq ""} {
    #
    # No end given. Set it to start + exam time + 5 minutes.
    # The value of "total_minutes" might contain fractions of a
    # minute, so make sure that the end_clock is an integer as
    # needed by "clock format",
    set end_clock [expr {int($start_clock + ($total_minutes + 5) * 60)}]
    set new_dtend [clock format $end_clock -format %H:%M]
    ns_log notice "#### no dtend given. set it from $dtend to $new_dtend"

  } else {
    set end_date    [clock format $start_clock -format %Y-%m-%d]T$dtend
    set end_clock   [clock scan $end_date      -format %Y-%m-%dT%H:%M]
    if {($end_clock - $start_clock) < ($total_minutes * 60)} {
      #
      # The specified end time is too early. Set it to start +
      # exam time + 5 minutes.
      #
      set end_clock [expr {int($start_clock + ($total_minutes + 5)*60)}]
      set new_dtend [clock format $end_clock -format %H:%M]
      ns_log notice "#### dtend is too early. Move it from $dtend to $new_dtend"

    } else {
      set new_dtend $dtend
    }
  }

  if {$new_dtend ne $dtend} {
    ns_log notice "#### create_workflows: must change dtend from <$dtend> to <$new_dtend>"
    set ia [$parentObj instance_attributes]
    dict set time_window time_window.dtend $new_dtend
    dict set ia time_window $time_window
    #ns_log notice "SAVE updated ia <${:instance_attributes}>"
    $parentObj update_attribute_from_slot [$parentObj find_slot instance_attributes] $ia
  }

  #
  # Delete previously scheduled atjobs
  #
  :delete_scheduled_atjobs $parentObj

  #
  # Schedule new atjobs
  #
  $parentObj schedule_action  -time [clock format $start_clock -format "%Y-%m-%d %H:%M:%S"]  -action publish
  $parentObj schedule_action  -time [clock format $end_clock -format "%Y-%m-%d %H:%M:%S"]  -action unpublish
}
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: