Merge pull request #12612 from pedrobmarin/f-r-ppp

feat(recording): process published polls
This commit is contained in:
Pedro Beschorner Marin 2021-06-19 11:36:34 -03:00 committed by GitHub
commit b4cf043962
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,7 +27,7 @@ require 'trollop'
require 'yaml'
require 'builder'
require 'fastimage' # require fastimage to get the image size of the slides (gem install fastimage)
require 'json'
# This script lives in scripts/archive/steps while properties.yaml lives in scripts/
bbb_props = BigBlueButton.read_props
@ -1115,6 +1115,93 @@ def processDeskshareEvents(events)
end
end
def getPollQuestion(event)
question = ""
if not event.at_xpath("question").nil?
question = event.at_xpath("question").text
end
question
end
def getPollAnswers(event)
answers = []
if not event.at_xpath("answers").nil?
answers = JSON.load(event.at_xpath("answers").content)
end
answers
end
def getPollRespondents(event)
respondents = 0
if not event.at_xpath("numRespondents").nil?
respondents = event.at_xpath("numRespondents").text.to_i
end
respondents
end
def getPollResponders(event)
responders = 0
if not event.at_xpath("numResponders").nil?
responders = event.at_xpath("numResponders").text.to_i
end
responders
end
def getPollId(event)
id = ""
if not event.at_xpath("pollId").nil?
id = event.at_xpath("pollId").text
end
id
end
def getPollType(events, published_poll_event)
published_poll_id = getPollId(published_poll_event)
type = ""
events.xpath("//event[@eventname='PollStartedRecordEvent']").each do |event|
poll_id = getPollId(event)
if poll_id.eql?(published_poll_id)
type = event.at_xpath("type").text
break
end
end
type
end
def processPollEvents(events, package_dir)
BigBlueButton.logger.info("Processing poll events")
published_polls = []
$rec_events.each do |re|
events.xpath("//event[@eventname='PollPublishedRecordEvent']").each do |event|
if (event[:timestamp].to_i >= re[:start_timestamp] and event[:timestamp].to_i <= re[:stop_timestamp])
published_polls << {
:timestamp => (translateTimestamp(event[:timestamp]) / 1000).to_i,
:type => getPollType(events, event),
:question => getPollQuestion(event),
:answers => getPollAnswers(event),
:respondents => getPollRespondents(event),
:responders => getPollResponders(event)
}
end
end
end
if not published_polls.empty?
File.open("#{package_dir}/polls.json", "w") do |f|
f.puts(published_polls.to_json)
end
end
end
$shapes_svg_filename = 'shapes.svg'
$panzooms_xml_filename = 'panzooms.xml'
$cursor_xml_filename = 'cursor.xml'
@ -1312,6 +1399,8 @@ begin
processDeskshareEvents(@doc)
processPollEvents(@doc, package_dir)
# Write slides.xml to file
File.open("#{package_dir}/slides_new.xml", 'w') { |f| f.puts $slides_doc.to_xml }