Test abusing references in getObject.
More insertObject testing. More POD.
This commit is contained in:
parent
fe33c87f13
commit
020c882fb6
2 changed files with 231 additions and 5 deletions
|
|
@ -163,6 +163,41 @@ sub getDragDropList {
|
|||
return \@data;
|
||||
} ## end sub getDragDropList
|
||||
|
||||
=head2 getObject ( $address )
|
||||
|
||||
Retrieve objects from the sections data structure by address.
|
||||
|
||||
=head3 $address
|
||||
|
||||
An array ref. The number of elements array set what is fetched.
|
||||
|
||||
=over 4
|
||||
|
||||
=item empty
|
||||
|
||||
If the array ref is empty, nothing is done.
|
||||
|
||||
=item 1 element
|
||||
|
||||
If there's just 1 element, returns the section with that index.
|
||||
|
||||
=item 2 elements
|
||||
|
||||
If there are 2 elements, then the first element is an index into
|
||||
section array, and the second element is an index into the questions
|
||||
in that section. Returns that question.
|
||||
|
||||
=back
|
||||
|
||||
=item 3 elements
|
||||
|
||||
Three elements are enough to reference an answer, inside of a particular
|
||||
question in a section. Returns that answer.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub getObject {
|
||||
my ( $self, $address ) = @_;
|
||||
if ( @$address == 1 ) {
|
||||
|
|
@ -255,6 +290,52 @@ sub getAnswerEditVars {
|
|||
return \%var;
|
||||
}
|
||||
|
||||
=head2 update ( $address, $object )
|
||||
|
||||
Update new "objects" into the current data structure, or add new ones. It does not
|
||||
return anything significant.
|
||||
|
||||
=head3 $address
|
||||
|
||||
An array ref. The number of elements array set what is updated.
|
||||
|
||||
=over 4
|
||||
|
||||
=item empty
|
||||
|
||||
If the array ref is empty, nothing is done.
|
||||
|
||||
=item 1 element
|
||||
|
||||
If there's just 1 element, then that element is used as an index into
|
||||
the array of sections, and information from $object is used to replace
|
||||
the properties of that section. If the select section does not exist, such
|
||||
as by using an out of bounds array index, then a new section is appended
|
||||
to the list of sections.
|
||||
|
||||
=item 2 elements
|
||||
|
||||
If there are 2 elements, then the first element is an index into
|
||||
section array, and the second element is an index into the questions
|
||||
in that section.
|
||||
|
||||
=back
|
||||
|
||||
=item 3 elements
|
||||
|
||||
Three elements are enough to reference an answer, inside of a particular
|
||||
question in a section. $object is spliced in right after that answer.
|
||||
|
||||
=head3 $object
|
||||
|
||||
A perl data structure. Note, that it is not checked for homegeneity,
|
||||
so it is possible to add a "question" object into the list of section
|
||||
objects.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub update {
|
||||
my ( $self, $address, $ref ) = @_;
|
||||
my $object;
|
||||
|
|
@ -415,6 +496,12 @@ sub remove {
|
|||
}
|
||||
}
|
||||
|
||||
=head2 newSection
|
||||
|
||||
Returns a reference to a new, empty section.
|
||||
|
||||
=cut
|
||||
|
||||
sub newSection {
|
||||
my %members = (
|
||||
'text', '',
|
||||
|
|
@ -430,6 +517,12 @@ sub newSection {
|
|||
return \%members;
|
||||
}
|
||||
|
||||
=head2 newQuestion
|
||||
|
||||
Returns a reference to a new, empty question.
|
||||
|
||||
=cut
|
||||
|
||||
sub newQuestion {
|
||||
my %members = (
|
||||
'text', '',
|
||||
|
|
@ -454,6 +547,12 @@ sub newQuestion {
|
|||
return \%members;
|
||||
} ## end sub newQuestion
|
||||
|
||||
=head2 newAnswer
|
||||
|
||||
Returns a reference to a new, empty answer.
|
||||
|
||||
=cut
|
||||
|
||||
sub newAnswer {
|
||||
my %members = (
|
||||
'text', '', 'verbatim', 0, 'textCols', 10, 'textRows', 5, 'goto', '', 'recordedAnswer', '', 'isCorrect', 1,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue