Created
September 10, 2013 16:13
-
-
Save Kodiologist/6511753 to your computer and use it in GitHub Desktop.
An unfinished program that would have uploaded TurningPoint quiz scores to Blackboard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use feature 'say'; | |
use warnings; | |
use strict; | |
use Archive::Zip; | |
use XML::Simple 'XMLin'; | |
use List::MoreUtils 'all', 'true', 'firstidx'; | |
# ----------------------------------------------------- | |
# * Create a table of points scored in any new sessions | |
# ----------------------------------------------------- | |
my $input_path = '/tmp/New Session 7-30-2013 8-01 PM.tpzx'; | |
my $session = XMLin( | |
do | |
{my $zip = Archive::Zip->new; | |
$zip->read($input_path); | |
scalar $zip->contents('TTSession.xml')}, | |
GroupTags => | |
{participants => 'participant', | |
questions => 'multichoice', | |
answers => 'answer', | |
responses => 'response'}); | |
# use YAML::XS; print Dump $session; | |
$session->{properties}{datecreated} =~ m!(\d+)/(\d+)/(\d+)! or die; | |
my $date = "$3-$1-$2"; | |
my @clicker_ids = map {$_->{assigneddevice}} | |
@{$session->{participantlist}{participants}}; | |
my @quiz_qs; | |
foreach (@{$session->{questionlist}{questions}}) | |
{$_->{anonymous} and $_->{anonymous} eq 'True' | |
# A poll question. Ignore it. | |
and next; | |
my @vt = map {$_->{valuetype}} @{$_->{answers}}; | |
# We rely on certain assumptions about the value types in order to | |
# score quiz questions. Test them. | |
(true {$_ eq '-1'} @vt) == $#vt and (true {$_ eq '1'} @vt) == 1 | |
or die 'Weird valuetypes: ', join ', ', @vt; | |
push @quiz_qs, | |
{correct => (firstidx {$_ eq '1'} @vt), | |
responses => $_->{responses}};} | |
my $maximum_score = @quiz_qs; | |
my %points = map {$_ => 0} @clicker_ids; | |
foreach (@quiz_qs) | |
{my $correct = $_->{correct} + 1; | |
# Indices in responsestring are 1-based. | |
foreach (@{$_->{responses}}) | |
{$_->{responsestring} eq $correct | |
and ++$points{$_->{deviceid}}}} | |
say "$date,$maximum_score"; | |
say "$_,$points{$_}" | |
foreach sort keys %points; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment