| Quizzer documentation | Contained in the Quizzer distribution. |
Quizzer::Element::Container - Container input element
This is a Container input element. A Container is an element that can hold other elements that are displayed when it is.
This function sets/gets a Container's question property, as usual. It also handles creating and setting up all the Elements inside the container.
Containers are visible if any of the items contained in them are visible. Or are they? This is still being decided -- TODO.
When a container is displayed, it displays all elements inside it.
Joey Hess <joey@kitenet.net>
| Quizzer documentation | Contained in the Quizzer distribution. |
#!/usr/bin/perl -w
package Quizzer::Element::Container; use Quizzer::Element; use Quizzer::ConfigDb; use strict; use UNIVERSAL qw(isa); use vars qw(@ISA); @ISA=qw(Quizzer::Element); my $VERSION='0.01';
sub question { my $this=shift; if (@_) { # This shouldn't happen.. if (! $this->frontend) { die "Container element question medthod called before frontend was set."; } $this->{'question'}=shift; # Create Elements for each Question inside the container # Question. However, do _not_ create Elements if they are # inside a nested Container. The nested Container takes # care of those on its own. my @contained=(); my @subcontainers=(); foreach my $question (Quizzer::ConfigDb::gettree($this->{'question'})) { my $ok=1; foreach (@subcontainers) { $ok='' if Quizzer::ConfigDb::isunder($_, $question); } next unless $ok; my $element=$this->frontend->makeelement($question); if (isa($element, "Quizzer::Element::Container")) { push @subcontainers, $element; } push @contained, $element; } $this->{'contained'}=\@contained; } return $this->{'question'}; }
#sub visible { # my $this=shift; # # # TODO: test it. # # # Call parent class to deal with everything else. # return $this->SUPER::visible; #}
sub show { my $this=shift; my @contained=@{$this->contained}; foreach my $elt (@contained) { $elt->show; } }
1