prepping for merge

This commit is contained in:
Kaleb Murphy 2008-11-06 19:44:28 +00:00
parent a907495f0b
commit 76b1f55225
2 changed files with 39 additions and 39 deletions

View file

@ -140,10 +140,10 @@ sub recordResponses{
#There were no questions in the section just displayed, so increment the lastResponse by one #There were no questions in the section just displayed, so increment the lastResponse by one
if(ref $questions ne 'ARRAY'){ if(ref $questions ne 'ARRAY'){
$self->lastResponse($self->lastResponse + 1); $self->lastResponse($self->lastResponse + 1);
$self->log("Incrementing last response by one"); #$self->log("Incrementing last response by one");
return [$terminal,$terminalUrl]; return [$terminal,$terminalUrl];
} }
$self->log("There are questions to be submitted in this section"); #$self->log("There are questions to be submitted in this section");
for my $question(@$questions){ for my $question(@$questions){
my $aAnswered = 0; my $aAnswered = 0;
@ -159,10 +159,10 @@ $self->log("There are questions to be submitted in this section");
$aAnswered = 1; $aAnswered = 1;
if($mcTypes{$question->{questionType}}){ if($mcTypes{$question->{questionType}}){
$self->responses->{$answer->{id}}->{value} = $answer->{recordedAnswer}; $self->responses->{$answer->{id}}->{value} = $answer->{recordedAnswer};
$self->log("Recorded Answer ".$answer->{recordedAnswer}); #$self->log("Recorded Answer ".$answer->{recordedAnswer});
} }
else{ else{
$self->log("Returned Answer ".$responses->{$answer->{id}}); #$self->log("Returned Answer ".$responses->{$answer->{id}});
$self->responses->{$answer->{id}}->{value} = $responses->{$answer->{id}}; $self->responses->{$answer->{id}}->{value} = $responses->{$answer->{id}};
} }
$self->responses->{$answer->{id}}->{'time'} = time(); $self->responses->{$answer->{id}}->{'time'} = time();
@ -192,17 +192,17 @@ $self->log("Returned Answer ".$responses->{$answer->{id}});
sub goto{ sub goto{
my $self = shift; my $self = shift;
my $goto = shift; my $goto = shift;
$self->log("In goto for '$goto'"); #$self->log("In goto for '$goto'");
for(my $i = 0; $i <= $#{$self->surveyOrder()}; $i++){ for(my $i = 0; $i <= $#{$self->surveyOrder()}; $i++){
my $section = $self->survey->section($self->surveyOrder()->[$i]); my $section = $self->survey->section($self->surveyOrder()->[$i]);
my $question = $self->survey->question($self->surveyOrder()->[$i]); my $question = $self->survey->question($self->surveyOrder()->[$i]);
if(ref $section eq 'HASH' and $section->{variable} eq $goto){ if(ref $section eq 'HASH' and $section->{variable} eq $goto){
$self->log("setting lastResponse to section ".($i-1)); #$self->log("setting lastResponse to section ".($i-1));
$self->lastResponse($i - 1); $self->lastResponse($i - 1);
last; last;
} }
if(ref $question eq 'HASH' and $question->{variable} eq $goto){ if(ref $question eq 'HASH' and $question->{variable} eq $goto){
$self->log("setting lastResponse to question ".($i-1)); #$self->log("setting lastResponse to question ".($i-1));
$self->lastResponse($i - 1); $self->lastResponse($i - 1);
last; last;
} }
@ -225,7 +225,7 @@ sub getPreviousAnswer{
sub nextQuestions{ sub nextQuestions{
my $self = shift; my $self = shift;
$self->log("In nextQuestions"); #$self->log("In nextQuestions");
if($self->lastResponse >= $#{$self->surveyOrder}){ if($self->lastResponse >= $#{$self->surveyOrder}){
return []; return [];
@ -233,29 +233,29 @@ $self->log("In nextQuestions");
my $nextSectionId = $self->nextSectionId; my $nextSectionId = $self->nextSectionId;
$self->log("next sectionid is $nextSectionId"); #$self->log("next sectionid is $nextSectionId");
my $qPerPage = $self->survey->section([$self->nextSectionId])->{questionsPerPage}; my $qPerPage = $self->survey->section([$self->nextSectionId])->{questionsPerPage};
#load Previous answer text #load Previous answer text
my $section = $self->nextSection(); my $section = $self->nextSection();
$self->log("Section text is ".$section->{text}); #$self->log("Section text is ".$section->{text});
$section->{'text'} =~ s/\[\[([^\%]*?)\]\]/$self->getPreviousAnswer($1)/eg; $section->{'text'} =~ s/\[\[([^\%]*?)\]\]/$self->getPreviousAnswer($1)/eg;
$self->log("qperpage $qPerPage"); #$self->log("qperpage $qPerPage");
my $questions; my $questions;
for(my $i = 1; $i <= $qPerPage; $i++){ for(my $i = 1; $i <= $qPerPage; $i++){
my $qAddy = $self->surveyOrder->[$self->lastResponse + $i]; my $qAddy = $self->surveyOrder->[$self->lastResponse + $i];
$self->log("qAddy was $$qAddy[0]-$$qAddy[1]"); #$self->log("qAddy was $$qAddy[0]-$$qAddy[1]");
next if(! exists $$qAddy[1]);#skip this if it doesn't have a question (for sections with no questions) next if(! exists $$qAddy[1]);#skip this if it doesn't have a question (for sections with no questions)
if($$qAddy[0] != $nextSectionId){ if($$qAddy[0] != $nextSectionId){
$self->log("Next question section did not match current section"); #$self->log("Next question section did not match current section");
last; last;
} }
$self->log("wtf"); #$self->log("wtf");
my %question = %{$self->survey->question([$$qAddy[0],$$qAddy[1]])}; my %question = %{$self->survey->question([$$qAddy[0],$$qAddy[1]])};
$question{'text'} =~ s/\[\[([^\%]*?)\]\]/$self->getPreviousAnswer($1)/eg; $question{'text'} =~ s/\[\[([^\%]*?)\]\]/$self->getPreviousAnswer($1)/eg;
delete $question{answers}; delete $question{answers};
@ -269,14 +269,14 @@ $self->log("wtf");
} }
push(@$questions,\%question); push(@$questions,\%question);
} }
$self->log("Next Questions returning with "); #$self->log("Next Questions returning with ");
return $questions return $questions
} }
sub surveyEnd{ sub surveyEnd{
my $self = shift; my $self = shift;
$self->log("LR is ".$self->lastResponse." and order is ".$#{$self->surveyOrder}); #$self->log("LR is ".$self->lastResponse." and order is ".$#{$self->surveyOrder});
$self->log("ENDING THE SURVEY\n\n\n") if($self->lastResponse > $#{$self->surveyOrder}); #$self->log("ENDING THE SURVEY\n\n\n") if($self->lastResponse > $#{$self->surveyOrder});
return 1 if($self->lastResponse >= $#{$self->surveyOrder}); return 1 if($self->lastResponse >= $#{$self->surveyOrder});
return 0; return 0;
} }
@ -313,7 +313,7 @@ sub returnResponseForReporting{
'questionComment',$self->responses->{"$$entry[0]-$$entry[1]"}->{comment}, 'questionComment',$self->responses->{"$$entry[0]-$$entry[1]"}->{comment},
'answers',\@answers})); 'answers',\@answers}));
} }
$self->log(Dumper @responses); #$self->log(Dumper @responses);
return \@responses; return \@responses;
} }

View file

@ -49,18 +49,18 @@ sub getDragDropList{
my $self = shift; my $self = shift;
my $address = shift; my $address = shift;
my @data; my @data;
$self->log("dd'ing sections".$#{$self->sections}); #$self->log("dd'ing sections".$#{$self->sections});
eval{ eval{
for(my $i = 0; $i <= $#{$self->sections}; $i++){ for(my $i = 0; $i <= $#{$self->sections}; $i++){
push(@data,{text=>$self->section([$i])->{title}, type=>'section'}); push(@data,{text=>$self->section([$i])->{title}, type=>'section'});
if($address->[0] == $i){ if($address->[0] == $i){
for(my $x = 0; $x <= $#{$self->questions($address)}; $x++){ for(my $x = 0; $x <= $#{$self->questions($address)}; $x++){
#$self->log("dd'ing questions".$#{$self->questions}); ##$self->log("dd'ing questions".$#{$self->questions});
push(@data,{text=>$self->question([$i,$x])->{text}, type=>'question'}); push(@data,{text=>$self->question([$i,$x])->{text}, type=>'question'});
if($address->[1] == $x){ if($address->[1] == $x){
for(my $y = 0; $y <= $#{$self->answers($address)}; $y++){ for(my $y = 0; $y <= $#{$self->answers($address)}; $y++){
#$self->log("dd'ing answers".$#{$self->answers}); ##$self->log("dd'ing answers".$#{$self->answers});
push(@data,{text=>$self->answer([$i,$x,$y])->{text}, type=>'answer'}); push(@data,{text=>$self->answer([$i,$x,$y])->{text}, type=>'answer'});
} }
} }
@ -68,8 +68,8 @@ eval{
} }
} }
}; };
$self->log($@); #$self->log($@);
#$self->log('finished dding'); ##$self->log('finished dding');
return \@data; return \@data;
} }
@ -150,14 +150,14 @@ sub update{
my $object; my $object;
my $newQuestion = 0; my $newQuestion = 0;
if(@$address == 1){ if(@$address == 1){
$self->log("A section"); #$self->log("A section");
$object = $self->section($address); $object = $self->section($address);
if(! defined $object){ if(! defined $object){
$object = $self->newSection(); $object = $self->newSection();
push(@{$self->sections},$object); push(@{$self->sections},$object);
} }
}elsif(@$address == 2){ }elsif(@$address == 2){
$self->log("A question"); #$self->log("A question");
$object = $self->question($address); $object = $self->question($address);
if(! defined $object){ if(! defined $object){
my $newQuestion = 1; my $newQuestion = 1;
@ -165,7 +165,7 @@ $self->log("A question");
push(@{$self->questions($address)},$object); push(@{$self->questions($address)},$object);
} }
}elsif(@$address == 3){ }elsif(@$address == 3){
$self->log("A answer"); #$self->log("A answer");
$object = $self->answer($address); $object = $self->answer($address);
if(! defined $object){ if(! defined $object){
$object = $self->newAnswer(); $object = $self->newAnswer();
@ -178,7 +178,7 @@ $self->log("A answer");
} }
} }
for my $key(keys %$object){ for my $key(keys %$object){
$self->log("$key $$object{$key}"); #$self->log("$key $$object{$key}");
$object->{$key} = $ref->{$key} if(defined $$ref{$key}); $object->{$key} = $ref->{$key} if(defined $$ref{$key});
} }
} }
@ -188,7 +188,7 @@ $self->log("$key $$object{$key}");
# ref should contain all the information for the new # ref should contain all the information for the new
sub insertObject{ sub insertObject{
my ($self,$object,$address) = @_; my ($self,$object,$address) = @_;
$self->log("Inserting ".join(',',@$address)); #$self->log("Inserting ".join(',',@$address));
if(@$address == 1){ if(@$address == 1){
splice(@{$self->sections($address)},$$address[0] + 1, 0, $object); splice(@{$self->sections($address)},$$address[0] + 1, 0, $object);
}elsif(@$address == 2){ }elsif(@$address == 2){
@ -196,7 +196,7 @@ $self->log("Inserting ".join(',',@$address));
}elsif(@$address == 3){ }elsif(@$address == 3){
splice(@{$self->answers($address)},$$address[2] + 1, 0, $object); splice(@{$self->answers($address)},$$address[2] + 1, 0, $object);
} }
$self->log("Finished inserting "); #$self->log("Finished inserting ");
} }
@ -206,13 +206,13 @@ sub copy{
my %newSection = %{$self->section($address)}; my %newSection = %{$self->section($address)};
push(@{$self->sections}, \%newSection); push(@{$self->sections}, \%newSection);
return [$#{$self->sections}]; return [$#{$self->sections}];
$self->log("copying here $$address[0] :".$#{$self->sections}); #$self->log("copying here $$address[0] :".$#{$self->sections});
}elsif(@$address == 2){ }elsif(@$address == 2){
$self->log("copying question $$address[0] $$address[1]"); #$self->log("copying question $$address[0] $$address[1]");
my %newQuestion = %{$self->question($address)}; my %newQuestion = %{$self->question($address)};
push( @{$self->questions($address)}, \%newQuestion); push( @{$self->questions($address)}, \%newQuestion);
$$address[1] = $#{$self->questions($address)}; $$address[1] = $#{$self->questions($address)};
$self->log("to $$address[0] $$address[1]"); #$self->log("to $$address[0] $$address[1]");
return $address; return $address;
} }
} }
@ -221,14 +221,14 @@ $self->log("to $$address[0] $$address[1]");
sub remove{ sub remove{
my ($self,$address,$movingOverride) = @_; my ($self,$address,$movingOverride) = @_;
if(@$address == 1){ if(@$address == 1){
$self->log("removing here $$address[0] :".$#{$self->sections}) if($$address[0] != 0 or defined $movingOverride);; #$self->log("removing here $$address[0] :".$#{$self->sections}) if($$address[0] != 0 or defined $movingOverride);;
splice(@{$self->{sections}},$$address[0],1) if($$address[0] != 0 or defined $movingOverride);#can't delete the first section splice(@{$self->{sections}},$$address[0],1) if($$address[0] != 0 or defined $movingOverride);#can't delete the first section
$self->log("removing here $$address[0] :".$#{$self->sections}); #$self->log("removing here $$address[0] :".$#{$self->sections});
}elsif(@$address == 2){ }elsif(@$address == 2){
$self->log("removing here $$address[0] $$address[1]"); #$self->log("removing here $$address[0] $$address[1]");
splice(@{$self->questions($address)},$$address[1],1); splice(@{$self->questions($address)},$$address[1],1);
}elsif(@$address == 3){ }elsif(@$address == 3){
$self->log("removing here $$address[0] $$address[1] $$address[2]"); #$self->log("removing here $$address[0] $$address[1] $$address[2]");
splice(@{$self->answers($address)},$$address[2],1); splice(@{$self->answers($address)},$$address[2],1);
} }
} }
@ -299,7 +299,7 @@ sub updateQuestionAnswers{
my $address = shift; my $address = shift;
my $type = shift; my $type = shift;
$self->log("In updateQuestion"); #$self->log("In updateQuestion");
my @addy = @{$address}; my @addy = @{$address};
my $question = $self->question($address); my $question = $self->question($address);
@ -391,11 +391,11 @@ sub addAnswersToQuestion{
my $addy = shift; my $addy = shift;
my $ans = shift; my $ans = shift;
my $verbs = shift; my $verbs = shift;
$self->log(Dumper $verbs); #$self->log(Dumper $verbs);
for(0 .. $#$ans){ for(0 .. $#$ans){
push(@{$self->question($addy)->{answers}},$self->newAnswer()); push(@{$self->question($addy)->{answers}},$self->newAnswer());
$$addy[2] = $_; $$addy[2] = $_;
$self->log("$_:".defined $$verbs{$_}." ".$$verbs{$_}); #$self->log("$_:".defined $$verbs{$_}." ".$$verbs{$_});
if(defined $$verbs{$_} and $_ == $$verbs{$_}){ if(defined $$verbs{$_} and $_ == $$verbs{$_}){
$self->update($addy,{'text',$$ans[$_],'recordedAnswer',$_+1,'verbatim',1}); $self->update($addy,{'text',$$ans[$_],'recordedAnswer',$_+1,'verbatim',1});
}else{ }else{