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

 <instance of xowf::test_item::Answer_manager[i]> answers_panel \
    [ -polling ] [ -heading heading ] \
    [ -submission_msg submission_msg ] [ -manager_obj manager_obj ] \
    [ -target_state target_state ] [ -wf wf ] \
    [ -current_question current_question ] [ -extra_text extra_text ]

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

Produce HTML code for an answers panel, containing the number of participants of an e-assessment and the number of participants, who have already answered.

Switches:
-polling
(defaults to "false") (optional)
when specified, provide live updates of the numbers via AJAX calls
-heading
(defaults to "#xowf.submitted_answers#") (optional)
-submission_msg
(defaults to "#xowf.participants_answered_question#") (optional)
-manager_obj
(optional)
-target_state
(optional)
-wf
(optional)
-current_question
(optional)
-extra_text
(optional)
optional extra text for the panel, has to be provided with valid HTML markup.

Partial Call Graph (max 5 caller/called nodes):
%3 test_create_test_items create_test_items (test xowf) xowf::test_item::Answer_manager instproc answers_panel xowf::test_item::Answer_manager instproc answers_panel test_create_test_items->xowf::test_item::Answer_manager instproc answers_panel template::add_body_script template::add_body_script (public) xowf::test_item::Answer_manager instproc answers_panel->template::add_body_script xowiki::bootstrap::card xowiki::bootstrap::card (public) xowf::test_item::Answer_manager instproc answers_panel->xowiki::bootstrap::card

Testcases:
create_test_items
Source code:
set answers [:get_answer_attributes $wf]
set nrParticipants [llength $answers]
if {$current_question ne ""} {
  set answered [:FL answers_for_form  [$current_question name]  $answers]
} else {
  set answered [:get_answer_attributes -state $target_state $wf]
}
set nrAnswered [llength $answered]

set answerStatus [::xowiki::bootstrap::card  -title $heading  -body [subst {<p><span id='answer-status'>$nrAnswered/$nrParticipants</span>
                        $submission_msg<p>$extra_text}]]

if {$polling} {
  #
  # Auto refresh of number of participants and submissions when
  # polling is on.
  #
  set url [$manager_obj pretty_link -query m=poll]
  template::add_body_script -script [subst -nocommands {
    (function poll() {
      setTimeout(function() {
        var xhttp = new XMLHttpRequest();
        xhttp.open("GET", '$url', true);
        xhttp.onreadystatechange = function() {
          if (this.readyState == 4 && this.status == 200) {
            var data = xhttp.responseText;
            var el = document.querySelector('#answer-status');
            el.innerHTML = data;
            poll();
            //activate links if a users started the exam
            var answers = data.split('/');
            if (answers.length == 2 && answers[1] > 0) {
              var disabledLinkItems = document.querySelectorAll(".list-group-item.link-disabled");
              disabledLinkItems.forEach(function(linkItem) {
                linkItem.classList.remove("link-disabled");
              });
            }
          }
        };
        xhttp.send();
      }, 1000);
    })();
  }]
}

return $answerStatus
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: