xowf::test_item::Answer_manager method answers_panel (public)
<instance of xowf::test_item::Answer_manager> 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 (optional, defaults to
"false"
)- when specified, provide live updates of the numbers via AJAX calls
- -heading (optional, defaults to
"#xowf.submitted_answers#"
)- -submission_msg (optional, defaults to
"#xowf.participants_answered_question#"
)- -manager_obj (optional, object)
- -target_state (optional)
- -wf (optional, object)
- -current_question (optional)
- -extra_text (optional)
- optional extra text for the panel, has to be provided with valid HTML markup.
- Testcases:
- No testcase defined.
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 $answerStatusXQL Not present: Generic, PostgreSQL, Oracle