Backing out Survey for now
This commit is contained in:
parent
4c546d312f
commit
151e705286
25 changed files with 2519 additions and 3365 deletions
|
|
@ -8,8 +8,6 @@
|
|||
- The Syndicated Content asset was rewritten, and now uses 35% less memory
|
||||
and is 400% faster.
|
||||
- fixed #9025: Testing function of UsersOnline macro fails.
|
||||
- Brand new Survey system. Make sure to export your old results as they will
|
||||
not be imported, only the surveys themselves.
|
||||
- fixed #9028: Thingy fails when setting values containing single quotes
|
||||
- fixed #9047: Unable to reorder DataForm tabs
|
||||
- added: Delete columns from DataTable
|
||||
|
|
|
|||
|
|
@ -19,10 +19,6 @@ save you many hours of grief.
|
|||
|
||||
* You must upgrade to 7.6.2 before you can upgrade to 7.6.3.
|
||||
|
||||
* The Survey system has been completely updated. Please make sure you
|
||||
create full backups of your survey results and export them as needed.
|
||||
Results will not be imported into the new Survey system. Your old surveys
|
||||
will be imported into the new survey system.
|
||||
|
||||
7.6.1
|
||||
--------------------------------------------------------------------
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -33,7 +33,6 @@ createLastUpdatedField($session);
|
|||
createFieldShowOnline($session);
|
||||
upgradeSyndicatedContentTemplates($session);
|
||||
removeCaseInsensitiveConfig($session);
|
||||
migrateSurvey($session);
|
||||
|
||||
finish($session); # this line required
|
||||
|
||||
|
|
@ -48,193 +47,6 @@ sub removeCaseInsensitiveConfig {
|
|||
print " Done.\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# This method migrates the the old survey system and existing surveys to the new survey system
|
||||
#
|
||||
#
|
||||
sub migrateSurvey{
|
||||
my $session = shift;
|
||||
print "Migrating surveys to new survey system..." unless $quiet;
|
||||
|
||||
_moveOldSurveyTables($session);
|
||||
_addSurveyTables($session);
|
||||
|
||||
print "\n";
|
||||
|
||||
my $surveys = $session->db->buildArrayRefOfHashRefs(
|
||||
"SELECT * FROM Survey_old s
|
||||
where s.revisionDate = (select max(s1.revisionDate) from Survey_old s1 where s1.assetId = s.assetId)"
|
||||
);
|
||||
|
||||
for my $survey(@$surveys){
|
||||
|
||||
#move over survey
|
||||
$session->db->write("insert into Survey
|
||||
values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
||||
[
|
||||
$$survey{groupToTakeSurvey},$$survey{groupToViewReports},'PBtmpl0000000000000064','PBtmpl0000000000000063',$$survey{maxResponsesPerUser},
|
||||
$$survey{gradebookTemplateId},$$survey{assetId},'PBtmpl0000000000000061',$$survey{revisionDate},'GRUNFctldUgop-qRLuo_DA','AjhlNO3wZvN5k4i4qioWcg',
|
||||
'wAc4azJViVTpo-2NYOXWvg', '1oBRscNIcFOI-pETrCOspA','d8jMMMRddSQ7twP4l1ZSIw','CxMpE_UPauZA3p8jdrOABw','','{}'
|
||||
]
|
||||
);
|
||||
|
||||
my $sjson = WebGUI::Asset::Wobject::Survey::SurveyJSON->new();
|
||||
|
||||
#move over sections
|
||||
my $sql = "select * from Survey_section_old where Survey_id = '$$survey{Survey_id}' order by sequenceNumber";
|
||||
my $sections = $session->db->buildArrayRefOfHashRefs($sql);
|
||||
my $sId = 0;
|
||||
my %sMap;
|
||||
for my $section(@$sections){
|
||||
my $random = $$section{questionOrder} eq 'random' ? 1 : 0;
|
||||
$sMap{$$section{Survey_sectionId}} = $sId;
|
||||
$sjson->update([$sId++],
|
||||
{
|
||||
'text','','title',$$section{sectionName},'variable',$$section{Survey_sectionId},
|
||||
'questionsPerPage',$$survey{questionsPerPage},'randomizeQuestions',$random
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#move over questions
|
||||
#my %qMap = ('radioList','Multiple Choice','text','Text','HTMLArea','Text','textArea','Text');
|
||||
$sql = "select * from Survey_question_old where Survey_id = '$$survey{Survey_id}' order by sequenceNumber";
|
||||
my $questions = $session->db->buildArrayRefOfHashRefs($sql);
|
||||
my $qId = 0;
|
||||
my %qMap;
|
||||
my %qS;
|
||||
for my $question(@$questions){
|
||||
$qMap{$$question{Survey_questionId}} = $qId;
|
||||
$qS{$$question{Survey_questionId}} = $$question{Survey_sectionId};
|
||||
$sjson->update([$sMap{$$question{Survey_sectionId}},$qId++],
|
||||
{
|
||||
'text',$$question{question},'variable',$$question{Survey_questionId},'allowComment',$$question{allowComment},
|
||||
'randomizeAnswers',$$question{randomizeAnswers},'questionType',$qMap{$$question{answerField}}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
#move over answers
|
||||
$sql = "select * from Survey_answer_old where Survey_id = '$$survey{Survey_id}' order by sequenceNumber";
|
||||
my $answers = $session->db->buildArrayRefOfHashRefs($sql);
|
||||
my $aId = 0;
|
||||
my %aMap;
|
||||
for my $answer(@$answers){
|
||||
$aMap{$$survey{Survey_answerId}} = $aId;
|
||||
$sjson->update([$sMap{$qS{$$answer{Survey_questionId}}},$qMap{$$answer{Survey_questionId}},$aId++],
|
||||
{
|
||||
'text',$$answer{answer},'goto',$$answer{Survey_questionId},'recordedAnswer',$$answer{answer},
|
||||
'isCorrect',$$answer{isCorrect},'NEED TO MAP QUESTION TYPES'
|
||||
}
|
||||
);
|
||||
}
|
||||
my $date = $session->db->quickScalar('select max(revisionDate) from Survey where assetId = ?',[$$survey{assetId}]);
|
||||
$session->db->write('update Survey set surveyJSON = ? where assetId = ? and revisionDate = ?',[$sjson->freeze,$$survey{assetId},$date]);
|
||||
|
||||
|
||||
my $rjson = WebGUI::Asset::Wobject::Survey::ResponseJSON->new(undef,undef,$sjson);
|
||||
$rjson->createSurveyOrder();
|
||||
#move over responses
|
||||
$sql = "select * from Survey_response_old where Survey_id = '$$survey{Survey_id}'";
|
||||
my $responses = $session->db->buildArrayRefOfHashRefs($sql);
|
||||
for my $response(@$responses){
|
||||
$session->db->write('insert into Survey_response values(?,?,?,?,?,?,?,?,?,?)',
|
||||
[
|
||||
$$survey{assetId},$$response{Survey_responseId},$$response{userId},$$response{userName},$$response{ipAddress},$$response{startDate},$$response{endDate},
|
||||
$$response{isComplete},undef,'{}'
|
||||
]
|
||||
);
|
||||
#$sql = "select * from Survey_questionResponse_old where Survey_responseId = '$$response{Survey_responseId}'";
|
||||
#my $qresponses = $session->db->buildArrayRefOfHashRefs($sql);
|
||||
#for my $qresponse(@$qresponses){
|
||||
#}
|
||||
}
|
||||
}
|
||||
|
||||
print "Finished\n" unless $quiet;
|
||||
}
|
||||
|
||||
|
||||
sub _moveOldSurveyTables{
|
||||
my $session = shift;
|
||||
eval{
|
||||
$session->db->write("alter table Survey rename to Survey_old");
|
||||
$session->db->write("alter table Survey_answer rename to Survey_answer_old");
|
||||
$session->db->write("alter table Survey_question rename to Survey_question_old");
|
||||
$session->db->write("alter table Survey_section rename to Survey_section_old");
|
||||
$session->db->write("alter table Survey_response rename to Survey_response_old");
|
||||
$session->db->write("alter table Survey_questionResponse rename to Survey_questionResponse_old");
|
||||
};
|
||||
}
|
||||
|
||||
sub _addSurveyTables{
|
||||
my $session = shift;
|
||||
$session->db->write("DROP TABLE IF EXISTS `Survey`");
|
||||
$session->db->write("
|
||||
CREATE TABLE `Survey` (
|
||||
`groupToTakeSurvey` char(22) character set utf8 collate utf8_bin NOT NULL default '2',
|
||||
`groupToViewReports` char(22) character set utf8 collate utf8_bin NOT NULL default '3',
|
||||
`responseTemplateId` char(22) character set utf8 collate utf8_bin NOT NULL,
|
||||
`overviewTemplateId` char(22) character set utf8 collate utf8_bin NOT NULL,
|
||||
`maxResponsesPerUser` int(11) NOT NULL default '1',
|
||||
`gradebookTemplateId` char(22) character set utf8 collate utf8_bin NOT NULL,
|
||||
`assetId` char(22) character set utf8 collate utf8_bin NOT NULL,
|
||||
`templateId` char(22) character set utf8 collate utf8_bin NOT NULL,
|
||||
`revisionDate` bigint(20) NOT NULL default '0',
|
||||
`surveyEditTemplateId` char(22) default NULL,
|
||||
`answerEditTemplateId` char(22) default NULL,
|
||||
`questionEditTemplateId` char(22) default NULL,
|
||||
`sectionEditTemplateId` char(22) default NULL,
|
||||
`surveyTakeTemplateId` char(22) default NULL,
|
||||
`surveyQuestionsId` char(22) default NULL,
|
||||
`exitURL` varchar(512) default NULL,
|
||||
`surveyJSON` longblob,
|
||||
PRIMARY KEY (`assetId`,`revisionDate`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
");
|
||||
$session->db->write("DROP TABLE IF EXISTS `Survey_response`");
|
||||
$session->db->write("
|
||||
CREATE TABLE `Survey_response` (
|
||||
`assetId` char(22) character set utf8 collate utf8_bin NOT NULL,
|
||||
`Survey_responseId` char(22) character set utf8 collate utf8_bin NOT NULL,
|
||||
`userId` char(22) default NULL,
|
||||
`username` char(255) default NULL,
|
||||
`ipAddress` char(15) default NULL,
|
||||
`startDate` bigint(20) NOT NULL default '0',
|
||||
`endDate` bigint(20) NOT NULL default '0',
|
||||
`isComplete` int(11) NOT NULL default '0',
|
||||
`anonId` varchar(255) default NULL,
|
||||
`responseJSON` longblob,
|
||||
PRIMARY KEY (`Survey_responseId`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
");
|
||||
$session->db->write("DROP TABLE IF EXISTS `Survey_tempReport`");
|
||||
$session->db->write("
|
||||
CREATE TABLE `Survey_tempReport` (
|
||||
`assetId` char(22) NOT NULL,
|
||||
`Survey_responseId` char(22) NOT NULL,
|
||||
`order` smallint(5) unsigned NOT NULL,
|
||||
`sectionNumber` smallint(5) unsigned NOT NULL,
|
||||
`sectionName` varchar(512) default NULL,
|
||||
`questionNumber` smallint(5) unsigned NOT NULL,
|
||||
`questionName` varchar(512) default NULL,
|
||||
`questionComment` mediumtext,
|
||||
`answerNumber` smallint(5) unsigned default NULL,
|
||||
`answerValue` mediumtext,
|
||||
`answerComment` mediumtext,
|
||||
`entryDate` bigint(20) unsigned NOT NULL COMMENT 'UTC Unix Time',
|
||||
`isCorrect` tinyint(3) unsigned default NULL,
|
||||
`value` int(11) default NULL,
|
||||
`fileStoreageId` char(22) default NULL COMMENT 'Not implemented yet',
|
||||
PRIMARY KEY (`assetId`,`Survey_responseId`,`order`),
|
||||
KEY `assetId` (`assetId`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub createLastUpdatedField {
|
||||
my $session = shift;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,338 +0,0 @@
|
|||
package WebGUI::Asset::Wobject::Survey::ResponseJSON;
|
||||
|
||||
use strict;
|
||||
use JSON;
|
||||
use Data::Dumper;
|
||||
|
||||
sub new{
|
||||
my $class = shift;
|
||||
my $json = shift;
|
||||
my $log = shift;
|
||||
my $survey = shift;
|
||||
my $self = {};
|
||||
$self->{survey} = $survey;
|
||||
$self->{log} = $log;
|
||||
my $temp = decode_json($json) if defined $json;
|
||||
$self->{surveyOrder} = defined $temp->{surveyOrder} ? $temp->{surveyOrder} : [];#an array of question addresses, with the third member being an array of answers
|
||||
$self->{responses} = defined $temp->{responses} ? $temp->{responses} : {};
|
||||
$self->{lastResponse} = defined $temp->{lastResponse} ? $temp->{lastResponse} : -1;
|
||||
bless($self,$class);
|
||||
return $self;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 createSurveyOrder ( SurveyJSON, [address,address] )
|
||||
|
||||
This creates the order for the survey which will change after every fork.
|
||||
The survey order is to precreate random questions and answers, which also leaves a record or what the user was presented with.
|
||||
Forks are passed in to show where to branch the new order.
|
||||
|
||||
=cut
|
||||
|
||||
sub createSurveyOrder{
|
||||
my $self = shift;
|
||||
my $order;
|
||||
my $qstarting = 0;
|
||||
$self->log('wtf am I faling for');
|
||||
for(my $s = 0; $s <= $#{$self->survey->sections()}; $s++){
|
||||
#create question order for section
|
||||
my @qorder;
|
||||
if($self->survey->section([$s])->{randomizeQuestions}){
|
||||
@qorder = shuffle(($qstarting .. $#{$self->survey->questions([$s])}));
|
||||
}else{
|
||||
@qorder = (($qstarting .. $#{$self->survey->questions([$s])}));
|
||||
}
|
||||
|
||||
#if this is an empty section, make sure it is still on the list to be seen
|
||||
if(@qorder == 0){
|
||||
push(@$order,[$s]);
|
||||
}
|
||||
$qstarting = 0;
|
||||
#create answer order for question
|
||||
for (@qorder){
|
||||
my @aorder;
|
||||
if($self->survey->question([$s,$_])->{randomizeAnswers}){
|
||||
@aorder = shuffle(($qstarting .. $#{$self->survey->question([$s,$_])->{answers}}));
|
||||
}else{
|
||||
@aorder = (($qstarting .. $#{$self->survey->question([$s,$_])->{answers}}));
|
||||
}
|
||||
push(@$order,[$s,$_,\@aorder]);
|
||||
}
|
||||
}
|
||||
$self->{surveyOrder} = $order;
|
||||
}
|
||||
sub shuffle {
|
||||
my @a = splice @_;
|
||||
for my $i (0 .. $#a) {
|
||||
my $j = int rand @a;
|
||||
@a[$i, $j] = @a[$j, $i];
|
||||
}
|
||||
return @a;
|
||||
}
|
||||
|
||||
sub freeze{
|
||||
my $self = shift;
|
||||
my %temp = %{$self};
|
||||
delete $temp{log};
|
||||
delete $temp{survey};
|
||||
return encode_json(\%temp);
|
||||
}
|
||||
|
||||
#the index of the last surveyOrder entry shown
|
||||
sub lastResponse{
|
||||
my $self = shift;
|
||||
my $res = shift;
|
||||
if(defined $res){
|
||||
$self->{lastResponse} = $res;
|
||||
}else{
|
||||
return $self->{lastResponse};
|
||||
}
|
||||
}
|
||||
#array of addresses in which the survey should be presented
|
||||
sub surveyOrder{
|
||||
my $self = shift;
|
||||
return $self->{surveyOrder};
|
||||
}
|
||||
|
||||
|
||||
sub nextSectionId{
|
||||
my $self = shift;
|
||||
return $self->surveyOrder->[$self->lastResponse + 1]->[0];
|
||||
}
|
||||
|
||||
|
||||
sub nextSection{
|
||||
my $self = shift;
|
||||
return $self->survey->section([$self->surveyOrder->[$self->lastResponse + 1]->[0]]);
|
||||
}
|
||||
sub currentSection{
|
||||
my $self = shift;
|
||||
return $self->survey->section([$self->surveyOrder->[$self->lastResponse]->[0]]);
|
||||
}
|
||||
|
||||
sub recordResponses{
|
||||
my $self = shift;
|
||||
my $responses = shift;
|
||||
my $session = shift;
|
||||
|
||||
my %mcTypes = ('Agree/Disagree',1,'Certainty',1,'Concern',1,'Confidence',1,'Education',1,'Effectiveness',1,'Gender',1,'Ideology',1,'Importance',1,
|
||||
'Likelihood',1,'Party',1,'Multiple Choice',1,'Oppose/Support',1,'Race',1,'Risk',1,'Satisfaction',1,'Scale',1,'Security',1,
|
||||
'Threat',1,'True/False',1,'Yes/No',1);
|
||||
my %sliderTypes = ('Dual Slider - Range',1,'Multi Slider - Allocate',1,'Slider',1);
|
||||
my %textTypes = ('Currency','Email',1,'Phone Number',1,'Text',1,'Text Date',1);
|
||||
my %fileTypes = ('File Upload',1);
|
||||
my %dateTypes = ('Date','Date Range',1);
|
||||
my %hiddenTypes = ('Hidden',1);
|
||||
#These were just submitted from the user, so we need to see what and how they were (un)answered.
|
||||
my $questions = $self->nextQuestions();
|
||||
my $qAnswered = 1;
|
||||
my $terminal = 0;
|
||||
my $terminalUrl;
|
||||
my $goto;
|
||||
#my $section = $self->survey->section([$questions->[0]->{sid}]);
|
||||
my $section = $self->currentSection();
|
||||
if($section->{terminal}){
|
||||
$terminal = 1;
|
||||
$terminalUrl = $section->{terminalUrl};
|
||||
}
|
||||
|
||||
#There were no questions in the section just displayed, so increment the lastResponse by one
|
||||
if(ref $questions ne 'ARRAY'){
|
||||
$self->lastResponse($self->lastResponse + 1);
|
||||
#$self->log("Incrementing last response by one");
|
||||
return [$terminal,$terminalUrl];
|
||||
}
|
||||
#$self->log("There are questions to be submitted in this section");
|
||||
|
||||
for my $question(@$questions){
|
||||
my $aAnswered = 0;
|
||||
if($question->{terminal}){
|
||||
$terminal = 1;
|
||||
$terminalUrl = $question->{terminalUrl};
|
||||
}
|
||||
$self->responses->{$question->{id}}->{comment} = $responses->{$question->{id}."comment"};
|
||||
for my $answer(@{$question->{answers}}){
|
||||
|
||||
if(defined($responses->{$answer->{id}}) and $responses->{$answer->{id}} =~ /\S/){
|
||||
|
||||
$aAnswered = 1;
|
||||
if($mcTypes{$question->{questionType}}){
|
||||
$self->responses->{$answer->{id}}->{value} = $answer->{recordedAnswer};
|
||||
#$self->log("Recorded Answer ".$answer->{recordedAnswer});
|
||||
}
|
||||
else{
|
||||
#$self->log("Returned Answer ".$responses->{$answer->{id}});
|
||||
$self->responses->{$answer->{id}}->{value} = $responses->{$answer->{id}};
|
||||
}
|
||||
$self->responses->{$answer->{id}}->{'time'} = time();
|
||||
$self->responses->{$answer->{id}}->{comment} = $responses->{$answer->{id}."comment"};
|
||||
|
||||
if($answer->{terminal}){
|
||||
$terminal = 1;
|
||||
$terminalUrl = $answer->{terminalUrl};
|
||||
}
|
||||
elsif($answer->{goto} =~ /\w/){
|
||||
$goto = $answer->{goto};
|
||||
}
|
||||
}
|
||||
}
|
||||
$qAnswered = 0 if(!$aAnswered and $question->{required});
|
||||
}
|
||||
|
||||
#if all responses completed, move the lastResponse index to the last question shown
|
||||
if($qAnswered){
|
||||
$self->lastResponse($self->lastResponse + @$questions);
|
||||
$self->goto($goto) if(defined $goto);
|
||||
}else{
|
||||
$terminal = 0;
|
||||
}
|
||||
return [$terminal,$terminalUrl];
|
||||
}
|
||||
sub goto{
|
||||
my $self = shift;
|
||||
my $goto = shift;
|
||||
#$self->log("In goto for '$goto'");
|
||||
for(my $i = 0; $i <= $#{$self->surveyOrder()}; $i++){
|
||||
my $section = $self->survey->section($self->surveyOrder()->[$i]);
|
||||
my $question = $self->survey->question($self->surveyOrder()->[$i]);
|
||||
if(ref $section eq 'HASH' and $section->{variable} eq $goto){
|
||||
#$self->log("setting lastResponse to section ".($i-1));
|
||||
$self->lastResponse($i - 1);
|
||||
last;
|
||||
}
|
||||
if(ref $question eq 'HASH' and $question->{variable} eq $goto){
|
||||
#$self->log("setting lastResponse to question ".($i-1));
|
||||
$self->lastResponse($i - 1);
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
sub getPreviousAnswer{
|
||||
my $self = shift;
|
||||
my $questionParam = shift;
|
||||
for my $q (@{$self->surveyOrder}){
|
||||
my $question = $self->survey->question([$$q[0],$$q[1]]);
|
||||
if($question->{variable} eq $questionParam){
|
||||
for (0 .. @{$self->survey->answers([$$q[0],$$q[1]])}){
|
||||
if(exists $self->responses->{$$q[0]."-".$$q[1]."-".$_}){
|
||||
return $self->responses->{$$q[0]."-".$$q[1]."-".$_}->{value};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub nextQuestions{
|
||||
my $self = shift;
|
||||
#$self->log("In nextQuestions");
|
||||
|
||||
if($self->lastResponse >= $#{$self->surveyOrder}){
|
||||
return [];
|
||||
}
|
||||
|
||||
my $nextSectionId = $self->nextSectionId;
|
||||
|
||||
#$self->log("next sectionid is $nextSectionId");
|
||||
|
||||
my $qPerPage = $self->survey->section([$self->nextSectionId])->{questionsPerPage};
|
||||
|
||||
|
||||
#load Previous answer text
|
||||
my $section = $self->nextSection();
|
||||
#$self->log("Section text is ".$section->{text});
|
||||
$section->{'text'} =~ s/\[\[([^\%]*?)\]\]/$self->getPreviousAnswer($1)/eg;
|
||||
|
||||
#$self->log("qperpage $qPerPage");
|
||||
|
||||
my $questions;
|
||||
for(my $i = 1; $i <= $qPerPage; $i++){
|
||||
my $qAddy = $self->surveyOrder->[$self->lastResponse + $i];
|
||||
#$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)
|
||||
|
||||
if($$qAddy[0] != $nextSectionId){
|
||||
#$self->log("Next question section did not match current section");
|
||||
last;
|
||||
}
|
||||
#$self->log("wtf");
|
||||
my %question = %{$self->survey->question([$$qAddy[0],$$qAddy[1]])};
|
||||
$question{'text'} =~ s/\[\[([^\%]*?)\]\]/$self->getPreviousAnswer($1)/eg;
|
||||
delete $question{answers};
|
||||
$question{id} = "$$qAddy[0]-$$qAddy[1]";
|
||||
$question{sid} = "$$qAddy[0]";
|
||||
for (@{$$qAddy[2]}){
|
||||
my $ans = $self->survey->answer([$$qAddy[0],$$qAddy[1],$_]);
|
||||
$ans->{'text'} =~ s/\[\[([^\%]*?)\]\]/$self->getPreviousAnswer($1)/eg;
|
||||
$ans->{id} = "$$qAddy[0]-$$qAddy[1]-$_";
|
||||
push(@{$question{answers}},$ans);
|
||||
}
|
||||
push(@$questions,\%question);
|
||||
}
|
||||
#$self->log("Next Questions returning with ");
|
||||
return $questions
|
||||
}
|
||||
|
||||
sub surveyEnd{
|
||||
my $self = shift;
|
||||
#$self->log("LR is ".$self->lastResponse." and order is ".$#{$self->surveyOrder});
|
||||
#$self->log("ENDING THE SURVEY\n\n\n") if($self->lastResponse > $#{$self->surveyOrder});
|
||||
return 1 if($self->lastResponse >= $#{$self->surveyOrder});
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub returnResponseForReporting{
|
||||
my $self = shift;
|
||||
my @responses = ();
|
||||
for my $entry(@{$self->surveyOrder}){
|
||||
if(@$entry == 1){
|
||||
next;
|
||||
}
|
||||
my @answers;
|
||||
for (@{$$entry[2]}){
|
||||
if(defined $self->responses->{"$$entry[0]-$$entry[1]-$_"}){
|
||||
$self->responses->{"$$entry[0]-$$entry[1]-$_"}->{id} = $_;
|
||||
if($self->survey->answer([$$entry[0],$$entry[1],$_])->{isCorrect}){
|
||||
my $value;
|
||||
if($self->survey->answer([$$entry[0],$$entry[1],$_])->{value} =~ /\w/){
|
||||
$value = $self->survey->answer([$$entry[0],$$entry[1],$_])->{value};
|
||||
}else{
|
||||
$value = $self->survey->question([$$entry[0],$$entry[1]])->{value};
|
||||
}
|
||||
$self->responses->{"$$entry[0]-$$entry[1]-$_"}->{value} = $value;
|
||||
$self->responses->{"$$entry[0]-$$entry[1]-$_"}->{isCorrect} = 1;
|
||||
}else{
|
||||
$self->responses->{"$$entry[0]-$$entry[1]-$_"}->{isCorrect} = 0;
|
||||
}
|
||||
push(@answers,($self->responses->{"$$entry[0]-$$entry[1]-$_"}));
|
||||
}
|
||||
}
|
||||
push(@responses,({'section',$$entry[0],'question',$$entry[1],
|
||||
'sectionName',$self->survey->section([$$entry[0]])->{variable},
|
||||
'questionName',$self->survey->question([$$entry[0],$$entry[1]])->{variable},
|
||||
'questionComment',$self->responses->{"$$entry[0]-$$entry[1]"}->{comment},
|
||||
'answers',\@answers}));
|
||||
}
|
||||
#$self->log(Dumper @responses);
|
||||
return \@responses;
|
||||
}
|
||||
|
||||
#the actual responses to the survey. A response is for a question and is accessed by the exact same address as a survey member.
|
||||
#Questions only contain the comment and an array of answer Responses.
|
||||
#Answers only contain, entered text, entered verbatim, their index in the Survey Question Answer array, and the assetId to the uploaded file.
|
||||
sub responses{
|
||||
my $self = shift;
|
||||
return $self->{responses};
|
||||
}
|
||||
|
||||
sub survey{
|
||||
my $self = shift;
|
||||
return $self->{survey};
|
||||
}
|
||||
sub log{
|
||||
my ($self,$message) = @_;
|
||||
if(defined $self->{log}){
|
||||
$self->{log}->error($message);
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
|
@ -1,446 +0,0 @@
|
|||
package WebGUI::Asset::Wobject::Survey::SurveyJSON;
|
||||
|
||||
use strict;
|
||||
use JSON;
|
||||
use Data::Dumper;
|
||||
|
||||
sub new{
|
||||
my $class = shift;
|
||||
my $json = shift;
|
||||
my $log = shift;
|
||||
my $self = {};
|
||||
$self->{log} = $log;
|
||||
my $temp = decode_json($json) if defined $json;
|
||||
$self->{sections} = defined $temp->{sections} ? $temp->{sections} : [];
|
||||
$self->{survey} = defined $temp->{survey} ? $temp->{survey} : {};
|
||||
bless($self,$class);
|
||||
if(@{$self->sections} == 0){
|
||||
$self->newObject([]);
|
||||
}
|
||||
return $self;
|
||||
}
|
||||
sub freeze{
|
||||
my $self = shift;
|
||||
my %temp;
|
||||
$temp{sections} = $self->{sections};
|
||||
$temp{survey} = $self->{survey};
|
||||
return encode_json(\%temp);
|
||||
}
|
||||
sub newObject{
|
||||
my $self = shift;
|
||||
my $address = shift;
|
||||
if(@$address == 0){
|
||||
push(@{$self->sections}, $self->newSection());
|
||||
return [$#{$self->sections}];
|
||||
}elsif(@$address == 1){
|
||||
push( @{$self->questions($address)}, $self->newQuestion($address));
|
||||
$$address[1] = $#{$self->questions($address)};
|
||||
return $address;
|
||||
}elsif(@$address == 2){
|
||||
push(@{$self->answers($address)}, $self->newAnswer($address));
|
||||
$$address[2] = $#{$self->answers($address)};
|
||||
return $address;
|
||||
}
|
||||
}
|
||||
|
||||
#address is the array of objects currently selected in the edit screen
|
||||
#data is the array of hash items for displaying
|
||||
sub getDragDropList{
|
||||
my $self = shift;
|
||||
my $address = shift;
|
||||
my @data;
|
||||
#$self->log("dd'ing sections".$#{$self->sections});
|
||||
eval{
|
||||
for(my $i = 0; $i <= $#{$self->sections}; $i++){
|
||||
push(@data,{text=>$self->section([$i])->{title}, type=>'section'});
|
||||
if($address->[0] == $i){
|
||||
|
||||
for(my $x = 0; $x <= $#{$self->questions($address)}; $x++){
|
||||
##$self->log("dd'ing questions".$#{$self->questions});
|
||||
push(@data,{text=>$self->question([$i,$x])->{text}, type=>'question'});
|
||||
if($address->[1] == $x){
|
||||
for(my $y = 0; $y <= $#{$self->answers($address)}; $y++){
|
||||
##$self->log("dd'ing answers".$#{$self->answers});
|
||||
push(@data,{text=>$self->answer([$i,$x,$y])->{text}, type=>'answer'});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
#$self->log($@);
|
||||
##$self->log('finished dding');
|
||||
return \@data;
|
||||
}
|
||||
|
||||
sub getObject{
|
||||
my ($self,$address) = @_;
|
||||
if(@$address == 1){
|
||||
return $self->{sections}->[$address->[0]];
|
||||
}elsif(@$address == 2){
|
||||
return $self->{sections}->[$address->[0]]->{questions}->[$address->[1]];
|
||||
}else{
|
||||
return $self->{sections}->[$address->[0]]->{questions}->[$address->[1]]->{answers}->[$address->[2]];
|
||||
}
|
||||
}
|
||||
|
||||
sub getEditVars{
|
||||
my ($self,$address) = @_;
|
||||
|
||||
if(@$address == 1){
|
||||
return $self->getSectionEditVars($address);
|
||||
}elsif(@$address == 2){
|
||||
return $self->getQuestionEditVars($address);
|
||||
}elsif(@$address == 3){
|
||||
return $self->getAnswerEditVars($address);
|
||||
}
|
||||
}
|
||||
sub getSectionEditVars{
|
||||
my $self = shift;
|
||||
my $address = shift;
|
||||
my $object = $self->section($address);
|
||||
my %var = %{$object};
|
||||
$var{id} = $address->[0];
|
||||
$var{displayed_id} = $address->[0]+1;
|
||||
delete $var{questions};
|
||||
delete $var{questionsPerPage};
|
||||
for(1 .. 20){
|
||||
# if($_ == $self->section($address)->{questionsPerPage}){
|
||||
if($_ == $object->{questionsPerPage}){
|
||||
push(@{$var{questionsPerPage}},{'index',$_,'selected',1});
|
||||
}else{
|
||||
push(@{$var{questionsPerPage}},{'index',$_,'selected',0});
|
||||
}
|
||||
}
|
||||
return \%var;
|
||||
}
|
||||
sub getQuestionEditVars{
|
||||
my $self = shift;
|
||||
my $address = shift;
|
||||
my $object = $self->question($address);
|
||||
my %var = %{$object};
|
||||
$var{id} = $address->[0]."-".$address->[1];
|
||||
$var{displayed_id} = $address->[1]+1;
|
||||
delete $var{answers};
|
||||
delete $var{questionType};
|
||||
my @types = ('Agree/Disagree','Certainty','Concern','Confidence','Currency','Date','Date Range','Dual Slider - Range','Education','Effectiveness',
|
||||
'Email','File Upload','Gender','Hidden','Ideology','Importance','Likelihood','Multi Slider - Allocate','Multiple Choice','Oppose/Support',
|
||||
'Party','Phone Number','Race','Risk','Satisfaction','Scale','Security','Slider','Text','Text Date','Threat','True/False','Yes/No');
|
||||
for(@types){
|
||||
if($_ eq $object->{questionType}){
|
||||
push(@{$var{questionType}},{'text',$_,'selected',1});
|
||||
}else{
|
||||
push(@{$var{questionType}},{'text',$_,'selected',0});
|
||||
}
|
||||
}
|
||||
return \%var;
|
||||
}
|
||||
sub getAnswerEditVars{
|
||||
my $self = shift;
|
||||
my $address = shift;
|
||||
my $object = $self->answer($address);
|
||||
my %var = %{$object};
|
||||
$var{id} = $address->[0]."-".$address->[1]."-".$address->[2];
|
||||
$var{displayed_id} = $address->[2]+1;
|
||||
return \%var;
|
||||
}
|
||||
|
||||
sub update{
|
||||
my ($self,$address,$ref) = @_;
|
||||
my $object;
|
||||
my $newQuestion = 0;
|
||||
if(@$address == 1){
|
||||
#$self->log("A section");
|
||||
$object = $self->section($address);
|
||||
if(! defined $object){
|
||||
$object = $self->newSection();
|
||||
push(@{$self->sections},$object);
|
||||
}
|
||||
}elsif(@$address == 2){
|
||||
#$self->log("A question");
|
||||
$object = $self->question($address);
|
||||
if(! defined $object){
|
||||
my $newQuestion = 1;
|
||||
$object = $self->newQuestion();
|
||||
push(@{$self->questions($address)},$object);
|
||||
}
|
||||
}elsif(@$address == 3){
|
||||
#$self->log("A answer");
|
||||
$object = $self->answer($address);
|
||||
if(! defined $object){
|
||||
$object = $self->newAnswer();
|
||||
push(@{$self->answers($address)},$object);
|
||||
}
|
||||
}
|
||||
if(@$address == 2 and ! $newQuestion){
|
||||
if($ref->{questionType} ne $self->question($address)->{questionType}){
|
||||
$self->updateQuestionAnswers($address,$ref->{questionType});
|
||||
}
|
||||
}
|
||||
for my $key(keys %$object){
|
||||
#$self->log("$key $$object{$key}");
|
||||
$object->{$key} = $ref->{$key} if(defined $$ref{$key});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#determine what to add and add it.
|
||||
# ref should contain all the information for the new
|
||||
sub insertObject{
|
||||
my ($self,$object,$address) = @_;
|
||||
#$self->log("Inserting ".join(',',@$address));
|
||||
if(@$address == 1){
|
||||
splice(@{$self->sections($address)},$$address[0] + 1, 0, $object);
|
||||
}elsif(@$address == 2){
|
||||
splice(@{$self->questions($address)},$$address[1] + 1, 0, $object);
|
||||
}elsif(@$address == 3){
|
||||
splice(@{$self->answers($address)},$$address[2] + 1, 0, $object);
|
||||
}
|
||||
#$self->log("Finished inserting ");
|
||||
|
||||
}
|
||||
|
||||
sub copy{
|
||||
my ($self,$address) = @_;
|
||||
if(@$address == 1){
|
||||
my %newSection = %{$self->section($address)};
|
||||
push(@{$self->sections}, \%newSection);
|
||||
return [$#{$self->sections}];
|
||||
#$self->log("copying here $$address[0] :".$#{$self->sections});
|
||||
}elsif(@$address == 2){
|
||||
#$self->log("copying question $$address[0] $$address[1]");
|
||||
my %newQuestion = %{$self->question($address)};
|
||||
push( @{$self->questions($address)}, \%newQuestion);
|
||||
$$address[1] = $#{$self->questions($address)};
|
||||
#$self->log("to $$address[0] $$address[1]");
|
||||
return $address;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub remove{
|
||||
my ($self,$address,$movingOverride) = @_;
|
||||
if(@$address == 1){
|
||||
#$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
|
||||
#$self->log("removing here $$address[0] :".$#{$self->sections});
|
||||
}elsif(@$address == 2){
|
||||
#$self->log("removing here $$address[0] $$address[1]");
|
||||
splice(@{$self->questions($address)},$$address[1],1);
|
||||
}elsif(@$address == 3){
|
||||
#$self->log("removing here $$address[0] $$address[1] $$address[2]");
|
||||
splice(@{$self->answers($address)},$$address[2],1);
|
||||
}
|
||||
}
|
||||
|
||||
sub newSection{
|
||||
my %members = (
|
||||
'text', '',
|
||||
'title', 'NEW SECTION',
|
||||
'variable', '',
|
||||
'questionsPerPage', 5,
|
||||
'questionsOnSectionPage', 1,
|
||||
'randomizeQuestions', 0,
|
||||
'everyPageTitle', 1,
|
||||
'everyPageText', 1,
|
||||
'terminal', 0,
|
||||
'terminalUrl', '',
|
||||
'goto', '',
|
||||
'timeLimit', 0,
|
||||
'type','section'
|
||||
);
|
||||
$members{questions} = [];
|
||||
return \%members;
|
||||
}
|
||||
sub newQuestion{
|
||||
my %members = (
|
||||
'text', '',
|
||||
'variable','',
|
||||
'allowComment',0,
|
||||
'commentCols',10,
|
||||
'commentRows',5,
|
||||
'randomizeAnswers',0,
|
||||
'questionType','Multiple Choice',
|
||||
'randomWords','',
|
||||
'verticalDisplay',0,
|
||||
'required',0,
|
||||
'maxAnswers',1,
|
||||
'value',1,
|
||||
'textInButton',0,
|
||||
# 'terminal',0,
|
||||
# 'terminalUrl','',
|
||||
'type','question'
|
||||
);
|
||||
$members{answers} = [];
|
||||
return \%members;
|
||||
}
|
||||
sub newAnswer{
|
||||
my %members = (
|
||||
'text', '',
|
||||
'verbatim',0,
|
||||
'textCols',10,
|
||||
'textRows',5,
|
||||
'goto','',
|
||||
'recordedAnswer','',
|
||||
'isCorrect',1,
|
||||
'min',1,
|
||||
'max',10,
|
||||
'step',1,
|
||||
'value',1,
|
||||
'terminal',0,
|
||||
'terminalUrl','',
|
||||
'type','answer'
|
||||
);
|
||||
return \%members;
|
||||
}
|
||||
|
||||
sub updateQuestionAnswers{
|
||||
my $self = shift;
|
||||
my $address = shift;
|
||||
my $type = shift;
|
||||
|
||||
#$self->log("In updateQuestion");
|
||||
|
||||
my @addy = @{$address};
|
||||
my $question = $self->question($address);
|
||||
$question->{answers} = [];
|
||||
|
||||
if($type eq 'Date Range' or $type eq 'Multi Slider - Allocate' or $type eq 'Dual Slider - Range'){
|
||||
push(@{$question->{answers}},$self->newAnswer());
|
||||
push(@{$question->{answers}},$self->newAnswer());
|
||||
}elsif($type eq 'Currency'){
|
||||
push(@{$question->{answers}},$self->newAnswer());
|
||||
$addy[2] = 0;
|
||||
$self->update(\@addy,{'text','Currency Amount'});
|
||||
}elsif($type eq 'Text Date'){
|
||||
push(@{$question->{answers}},$self->newAnswer());
|
||||
$addy[2] = 0;
|
||||
$self->update(\@addy,{'text','Date:'});
|
||||
}elsif($type eq 'Phone Number'){
|
||||
push(@{$question->{answers}},$self->newAnswer());
|
||||
$addy[2] = 0;
|
||||
$self->update(\@addy,{'text','Phone Number:'});
|
||||
}elsif($type eq 'Email'){
|
||||
push(@{$question->{answers}},$self->newAnswer());
|
||||
$addy[2] = 0;
|
||||
$self->update(\@addy,{'text','Email:'});
|
||||
}elsif($type eq 'Education'){
|
||||
my @ans = ('Elementary or some high school','High school/GED','Some college/vocational school','College graduate',
|
||||
'Some graduate work','Master\'s degree','Doctorate (of any type)','Other degree (verbatim)');
|
||||
$self->addAnswersToQuestion(\@addy,\@ans,{7,1});
|
||||
}elsif($type eq 'Party'){
|
||||
my @ans = ('Democratic party','Republican party (or GOP)','Independant party','Other party (verbatim)');
|
||||
$self->addAnswersToQuestion(\@addy,\@ans,{3,1});
|
||||
}elsif($type eq 'Race'){
|
||||
my @ans = ('American Indian','Asian','Black','Hispanic','White non-Hispanic','Something else (verbatim)');
|
||||
$self->addAnswersToQuestion(\@addy,\@ans,{5,1});
|
||||
}elsif($type eq 'Ideology'){
|
||||
my @ans = ('Strongly liberal','Liberal','Somewhat liberal','Middle of the road','Slightly conservative','Conservative','Strongly conservative');
|
||||
$self->addAnswersToQuestion(\@addy,\@ans,{});
|
||||
}elsif($type eq 'Security'){
|
||||
my @ans = ('Not at all secure','','','','','','','','','','Extremely secure');
|
||||
$self->addAnswersToQuestion(\@addy,\@ans,{});
|
||||
}elsif($type eq 'Threat'){
|
||||
my @ans = ('No threat','','','','','','','','','','Extreme threat');
|
||||
$self->addAnswersToQuestion(\@addy,\@ans,{});
|
||||
}elsif($type eq 'Risk'){
|
||||
my @ans = ('No risk','','','','','','','','','','Extreme risk');
|
||||
$self->addAnswersToQuestion(\@addy,\@ans,{});
|
||||
}elsif($type eq 'Concern'){
|
||||
my @ans = ('Not at all concerned','','','','','','','','','','Extremely concerned');
|
||||
$self->addAnswersToQuestion(\@addy,\@ans,{});
|
||||
}elsif($type eq 'Effectiveness'){
|
||||
my @ans = ('Not at all effective','','','','','','','','','','Extremely effective');
|
||||
$self->addAnswersToQuestion(\@addy,\@ans,{});
|
||||
}elsif($type eq 'Confidence'){
|
||||
my @ans = ('Not at all confident','','','','','','','','','','Extremely confident');
|
||||
$self->addAnswersToQuestion(\@addy,\@ans,{});
|
||||
}elsif($type eq 'Satisfaction'){
|
||||
my @ans = ('Not at all satisfied','','','','','','','','','','Extremely satisfied');
|
||||
$self->addAnswersToQuestion(\@addy,\@ans,{});
|
||||
}elsif($type eq 'Certainty'){
|
||||
my @ans = ('Not at all certain','','','','','','','','','','Extremely certain');
|
||||
$self->addAnswersToQuestion(\@addy,\@ans,{});
|
||||
}elsif($type eq 'Likelihood'){
|
||||
my @ans = ('Not at all likely','','','','','','','','','','Extremely likely');
|
||||
$self->addAnswersToQuestion(\@addy,\@ans,{});
|
||||
}elsif($type eq 'Importance'){
|
||||
my @ans = ('Not at all important','','','','','','','','','','Extremely important');
|
||||
$self->addAnswersToQuestion(\@addy,\@ans,{});
|
||||
}elsif($type eq 'Oppose/Support'){
|
||||
my @ans = ('Strongly oppose','','','','','','Strongly Support');
|
||||
$self->addAnswersToQuestion(\@addy,\@ans,{});
|
||||
}elsif($type eq 'Agree/Disagree'){
|
||||
my @ans = ('Strongly disagree','','','','','','Strongly agree');
|
||||
$self->addAnswersToQuestion(\@addy,\@ans,{});
|
||||
}elsif($type eq 'True/False'){
|
||||
my @ans = ('True','False');
|
||||
$self->addAnswersToQuestion(\@addy,\@ans,{});
|
||||
}elsif($type eq 'Yes/No'){
|
||||
my @ans = ('Yes','No');
|
||||
$self->addAnswersToQuestion(\@addy,\@ans,{});
|
||||
}elsif($type eq 'Gender'){
|
||||
my @ans = ('Male','Female');
|
||||
$self->addAnswersToQuestion(\@addy,\@ans,{});
|
||||
}else{
|
||||
push(@{$question->{answers}},$self->newAnswer());
|
||||
}
|
||||
}
|
||||
sub addAnswersToQuestion{
|
||||
my $self = shift;
|
||||
my $addy = shift;
|
||||
my $ans = shift;
|
||||
my $verbs = shift;
|
||||
#$self->log(Dumper $verbs);
|
||||
for(0 .. $#$ans){
|
||||
push(@{$self->question($addy)->{answers}},$self->newAnswer());
|
||||
$$addy[2] = $_;
|
||||
#$self->log("$_:".defined $$verbs{$_}." ".$$verbs{$_});
|
||||
if(defined $$verbs{$_} and $_ == $$verbs{$_}){
|
||||
$self->update($addy,{'text',$$ans[$_],'recordedAnswer',$_+1,'verbatim',1});
|
||||
}else{
|
||||
$self->update($addy,{'text',$$ans[$_],'recordedAnswer',$_+1});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#------------------------------
|
||||
#accessors and helpers
|
||||
#------------------------------
|
||||
sub sections{
|
||||
my $self = shift;
|
||||
return $self->{sections};
|
||||
}
|
||||
sub section{
|
||||
my $self = shift;
|
||||
my $address = shift;
|
||||
return $self->{sections}->[$$address[0]];
|
||||
}
|
||||
sub questions{
|
||||
my $self = shift;
|
||||
my $address = shift;
|
||||
return $self->{sections}->[$$address[0]]->{questions};
|
||||
}
|
||||
sub question{
|
||||
my $self = shift;
|
||||
my $address = shift;
|
||||
return $self->{sections}->[$$address[0]]->{questions}->[$$address[1]];
|
||||
}
|
||||
sub answers{
|
||||
my $self = shift;
|
||||
my $address = shift;
|
||||
return $self->{sections}->[$$address[0]]->{questions}->[$$address[1]]->{answers};
|
||||
}
|
||||
sub answer{
|
||||
my $self = shift;
|
||||
my $address = shift;
|
||||
return $self->{sections}->[$$address[0]]->{questions}->[$$address[1]]->{answers}->[$$address[2]];
|
||||
}
|
||||
sub log{
|
||||
my ($self,$message) = @_;
|
||||
if(defined $self->{log}){
|
||||
$self->{log}->error($message);
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
|
@ -78,7 +78,7 @@ sub execute {
|
|||
my $archiveDate = $epoch - $cs->get("archiveAfter");
|
||||
my $sql = "select asset.assetId, assetData.revisionDate from Post left join asset on asset.assetId=Post.assetId
|
||||
left join assetData on Post.assetId=assetData.assetId and Post.revisionDate=assetData.revisionDate
|
||||
where Post.revisionDate > ? and assetData.status='archived' and asset.state='published'
|
||||
where Post.revisionDate<? and assetData.status='approved' and asset.state='published'
|
||||
and Post.threadId=Post.assetId and asset.lineage like ?";
|
||||
my $b = $self->session->db->read($sql,[$archiveDate, $cs->get("lineage").'%']);
|
||||
while (my ($id, $version) = $b->array) {
|
||||
|
|
@ -87,7 +87,7 @@ sub execute {
|
|||
foreach my $post (@{$thread->getPosts}) {
|
||||
$archiveIt = 0 if (defined $post && $post->get("revisionDate") > $archiveDate);
|
||||
}
|
||||
$thread->unarchive if ($archiveIt);
|
||||
$thread->archive if ($archiveIt);
|
||||
}
|
||||
$b->finish;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,453 +0,0 @@
|
|||
if (typeof Survey == "undefined") {
|
||||
var Survey = {};
|
||||
}
|
||||
|
||||
Survey.Form = new function() {
|
||||
|
||||
var multipleChoice = {'Multiple Choice':1,'Gender':1,'Yes/No':1,'True/False':1,'Ideology':1, 'Race':1,'Party':1,'Education':1
|
||||
,'Scale':1,'Agree/Disagree':1,'Oppose/Support':1,'Importance':1,
|
||||
'Likelihood':1,'Certainty':1,'Satisfaction':1,'Confidence':1,'Effectiveness':1,'Concern':1,'Risk':1,'Threat':1,'Security':1};
|
||||
var text = {'Text':1, 'Email':1, 'Phone Number':1, 'Text Date':1, 'Currency':1};
|
||||
var slider = {'Slider':1, 'Dual Slider - Range':1, 'Multi Slider - Allocate':1};
|
||||
var dateType = {'Date':1,'Date Range':1};
|
||||
var fileUpload = {'File Upload':1};
|
||||
var hidden = {'Hidden':1};
|
||||
|
||||
var hasFile;
|
||||
var verb = 0;
|
||||
var lastSection = 'first';
|
||||
|
||||
var toValidate;
|
||||
|
||||
var sliderWidth = 500;
|
||||
|
||||
var sliders;
|
||||
|
||||
// this.submittimer;
|
||||
|
||||
|
||||
this.displayQuestions = function(params){
|
||||
toValidate = new Array();//clear array
|
||||
var qs = params.questions;
|
||||
var s = params.section;
|
||||
sliders = new Array();
|
||||
|
||||
//What to show and where
|
||||
document.getElementById('survey').innerHTML = params.html;
|
||||
//var te = document.createElement('span');
|
||||
//te.innerHTML = "<input type=button id=testB name='Reload Page' value='Reload Page'>";
|
||||
//document.getElementById('survey').appendChild(te);
|
||||
//YAHOO.util.Event.addListener("testB", "click", function(){Survey.Comm.callServer('','loadQuestions');});
|
||||
|
||||
if(qs[0] != undefined){
|
||||
if(lastSection != s.id|| s.everyPageTitle > 0){
|
||||
document.getElementById('headertitle').style.display='block';
|
||||
}
|
||||
if(lastSection != s.id|| s.everyPageText > 0){
|
||||
document.getElementById('headertext').style.display = 'block';
|
||||
}
|
||||
|
||||
if(lastSection != s.id && s.questionsOnSectionPage != '1'){
|
||||
var span = document.createElement("div");
|
||||
span.innerHTML = "<input type=button id='showQuestionsButton' value='Continue'>";
|
||||
span.style.display = 'block';
|
||||
|
||||
document.getElementById('header').appendChild(span);
|
||||
YAHOO.util.Event.addListener("showQuestionsButton", "click",
|
||||
function(){
|
||||
document.getElementById('showQuestionsButton').style.display = 'none';
|
||||
if(s.everyPageTitle == 0){
|
||||
document.getElementById('headertitle').style.display = 'none';
|
||||
}
|
||||
if(s.everyPageText == 0){
|
||||
document.getElementById('headertext').style.display = 'none';
|
||||
}
|
||||
document.getElementById('questions').style.display='inline';
|
||||
Survey.Form.addWidgets(qs);
|
||||
});
|
||||
}else{
|
||||
document.getElementById('questions').style.display='inline';
|
||||
Survey.Form.addWidgets(qs);
|
||||
}
|
||||
lastSection = s.id;
|
||||
}else{
|
||||
document.getElementById('headertitle').style.display='block';
|
||||
document.getElementById('headertext').style.display = 'block';
|
||||
document.getElementById('questions').style.display='inline';
|
||||
Survey.Form.addWidgets(qs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//Display questions
|
||||
this.addWidgets = function(qs){
|
||||
hasFile = false;
|
||||
for(var i = 0; i < qs.length; i++){
|
||||
var q = qs[i];
|
||||
var verts = '';
|
||||
var verte = '';
|
||||
for(var x in q.answers){
|
||||
for(var y in q.answers[x]){
|
||||
if(q.answers[x][y] == undefined){q.answers[x][y] = '';}
|
||||
}
|
||||
}
|
||||
|
||||
//Check if this question should be validated
|
||||
if(q.required == 1){
|
||||
toValidate[q.id] = new Array();
|
||||
toValidate[q.id]['type'] = q.questionType;
|
||||
toValidate[q.id]['answers'] = new Array();
|
||||
}
|
||||
|
||||
|
||||
if(multipleChoice[q.questionType]){
|
||||
var butts = new Array();
|
||||
verb = 0;
|
||||
for(var x = 0; x < q.answers.length; x++){
|
||||
var a = q.answers[x];
|
||||
if(toValidate[q.id]){
|
||||
toValidate[q.id]['answers'][a.id] = 1;
|
||||
}
|
||||
var b = document.getElementById(a.id+'button');
|
||||
/*
|
||||
b = new YAHOO.widget.Button({ type: "checkbox", label: a.answerText, id: a.id+'button', name: a.id+'button',
|
||||
value: a.id,
|
||||
container: a.id+"container", checked: false });
|
||||
*/
|
||||
// b.on("click", this.buttonChanged,[b,a.id,q.maxAnswers,butts,qs.length,a.id]);
|
||||
// YAHOO.util.Event.addListener(a.id+'button', "click", this.buttonChanged,[b,a.id,q.maxAnswers,butts,qs.length,a.id]);
|
||||
if(a.verbatim == 1){
|
||||
verb = 1;
|
||||
}
|
||||
YAHOO.util.Event.addListener(a.id+'button', "click", this.buttonChanged,[b,a.id,q.maxAnswers,butts,qs.length,a.id]);
|
||||
b.hid = a.id;
|
||||
butts.push(b);
|
||||
}
|
||||
}
|
||||
else if(dateType[q.questionType]){
|
||||
for(var x = 0; x < q.answers.length; x++){
|
||||
var a = q.answers[x];
|
||||
if(toValidate[q.id]){
|
||||
toValidate[q.id]['answers'][a.id] = 1;
|
||||
}
|
||||
var calid = a.id+'container';
|
||||
var c = new YAHOO.widget.Calendar(calid,{title:'Choose a date:', close:true});
|
||||
c.selectEvent.subscribe(this.selectCalendar,[c,a.id],true);
|
||||
c.render();
|
||||
c.hide();
|
||||
var b = new YAHOO.widget.Button({ label:"Select Date", id:"pushbutton"+a.id, container:a.id+'button' });
|
||||
b.on("click", this.showCalendar,[c]);
|
||||
}
|
||||
}
|
||||
else if(slider[q.questionType]){
|
||||
//First run through and put up the span placeholders and find the max value for an answer, to know how big the allocation points will be.
|
||||
var max = 0;
|
||||
if(q.questionType == 'Dual Slider - Range'){
|
||||
new this.dualSliders(q);
|
||||
}else{
|
||||
for(var s in q.answers){
|
||||
var a = q.answers[s];
|
||||
YAHOO.util.Event.addListener(a.id, "blur", this.sliderTextSet);
|
||||
if(a.max - a.min > max){max = a.max - a.min;}
|
||||
}
|
||||
}
|
||||
if(q.questionType == 'Multi Slider - Allocate'){
|
||||
//sliderManagers[sliderManagers.length] = new this.sliderManager(q,max);
|
||||
for(var x = 0; x < q.answers.length; x++){
|
||||
var a = q.answers[x];
|
||||
if(toValidate[q.id]){
|
||||
toValidate[q.id]['total'] = a.max;
|
||||
toValidate[q.id]['answers'][a.id] = 1;
|
||||
}
|
||||
}
|
||||
new this.sliderManager(q,max);
|
||||
}
|
||||
else if(q.questionType == 'Slider'){
|
||||
new this.sliders(q);
|
||||
}
|
||||
}
|
||||
|
||||
else if(fileUpload[q.questionType]){
|
||||
hasFile = true;
|
||||
}
|
||||
|
||||
else if(text[q.questionType]){
|
||||
var a = q.answers[x];
|
||||
if(toValidate[q.id]){
|
||||
toValidate[q.id]['answers'][a.id] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
YAHOO.util.Event.addListener("submitbutton", "click", this.formsubmit);
|
||||
}
|
||||
|
||||
|
||||
this.formsubmit = function(event){
|
||||
var submit = 1;//boolean for if all was good or not
|
||||
for(var i in toValidate){
|
||||
var answered = 0;
|
||||
if(toValidate[i]['type'] == 'Multi Slider - Allocate'){
|
||||
var total = 0;
|
||||
for(var z in toValidate[i]['answers']){
|
||||
total += Math.round(document.getElementById(z).value);
|
||||
}
|
||||
if(total == toValidate[i]['total']){answered = 1;}
|
||||
else{
|
||||
var amountLeft = toValidate[i]['total']-total;
|
||||
alert("Please allocate the remaining "+amountLeft+ ".");
|
||||
}
|
||||
}else{
|
||||
for(var z in toValidate[i]['answers']){
|
||||
var v = document.getElementById(z).value;
|
||||
if(v != '' && v != undefined){
|
||||
answered = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(answered == 0){
|
||||
submit = 0;
|
||||
document.getElementById(i+'required').innerHTML = "<font color=red>*</font>";
|
||||
}else{
|
||||
document.getElementById(i+'required').innerHTML = "";
|
||||
}
|
||||
}
|
||||
if(submit == 1){
|
||||
YAHOO.log("Submitting");
|
||||
Survey.Comm.callServer('','submitQuestions','surveyForm',hasFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
this.dualSliders = function(q){
|
||||
var total = sliderWidth;
|
||||
// var sliders = new Array();
|
||||
var a1 = q.answers[0];
|
||||
var a2 = q.answers[1];
|
||||
var scale = sliderWidth/a1.max;
|
||||
|
||||
var id = q.id;
|
||||
var a1id = a1.id;
|
||||
var a2id = a2.id;
|
||||
|
||||
var a1h = document.getElementById(a1id);
|
||||
var a2h = document.getElementById(a2id);
|
||||
var a1s = document.getElementById(a1id+'show');
|
||||
var a2s = document.getElementById(a2id+'show');
|
||||
var s = YAHOO.widget.Slider.getHorizDualSlider(id+'slider-bg',
|
||||
a1id+"slider-min-thumb", a2id+"slider-max-thumb",
|
||||
sliderWidth, 1*scale, [1,sliderWidth]);
|
||||
sliders[id] = s;
|
||||
//YAHOO.log(1);
|
||||
|
||||
s.minRange = 4;
|
||||
var updateUI = function () {
|
||||
var min = Math.round(s.minVal/scale),
|
||||
max = Math.round(s.maxVal/scale);
|
||||
a1h.value = min;
|
||||
a1s.innerHTML = min;
|
||||
a2h.value = max;
|
||||
a2s.innerHTML = max;
|
||||
};
|
||||
|
||||
// Subscribe to the dual thumb slider's change and ready events to
|
||||
// report the state.
|
||||
// s.subscribe('ready', updateUI);
|
||||
//s.subscribe('change', updateUI);
|
||||
s.subscribe('slideEnd', updateUI);
|
||||
}
|
||||
this.sliders = function(q){
|
||||
var total = sliderWidth;
|
||||
for(var i in q.answers){
|
||||
var a = q.answers[i];
|
||||
var step = Math.round(q.answers[i].step);
|
||||
var min = Math.round(parseFloat(q.answers[i].min));
|
||||
var distance = Math.round(parseFloat(q.answers[i].max) + (-1 * min));
|
||||
var scale = Math.round(sliderWidth/distance);
|
||||
var lang = YAHOO.lang;
|
||||
var id = a.id;
|
||||
var s = YAHOO.widget.Slider.getHorizSlider(id+'slider-bg', id+'slider-thumb',
|
||||
0, sliderWidth, (scale*step));
|
||||
s.scale = scale;
|
||||
sliders[q.Survey_questionid] = new Array();
|
||||
sliders[q.Survey_questionid][id] = s;
|
||||
s.input = a.id;
|
||||
s.scale = scale;
|
||||
document.getElementById(id).value = a.min;
|
||||
var check = function() {
|
||||
var t = document.getElementById(this.input);
|
||||
t.value = this.getRealValue();
|
||||
};
|
||||
s.getRealValue = function() {
|
||||
return Math.round(parseFloat(( (this.getValue() / total) * distance) + min ));
|
||||
}
|
||||
s.subscribe("slideEnd", check);
|
||||
}
|
||||
}
|
||||
//an object which creates sliders for allocation type questions and then manages their events and keeps them from overallocating
|
||||
this.sliderManager = function(q,t){
|
||||
var total = sliderWidth;
|
||||
var step = Math.round(parseFloat(q.answers[0].step));
|
||||
var min = Math.round(parseFloat(q.answers[0].min));
|
||||
var distance = Math.round(parseFloat(q.answers[0].max) + (-1 * min));
|
||||
var scale = Math.round(sliderWidth/distance);
|
||||
for(var i in q.answers){
|
||||
var a = q.answers[i];
|
||||
var Event = YAHOO.util.Event;
|
||||
var lang = YAHOO.lang;
|
||||
var id = a.id+'slider-bg';
|
||||
var s = YAHOO.widget.Slider.getHorizSlider(id, a.id+'slider-thumb',
|
||||
0, sliderWidth, scale*step);
|
||||
s.animate = false;
|
||||
if(sliders[q.id] == undefined){
|
||||
sliders[q.id] = new Array();
|
||||
}
|
||||
sliders[q.id][a.id] = s;
|
||||
s.input = a.id;
|
||||
s.lastValue = 0;
|
||||
var check = function() {
|
||||
var t = 0;
|
||||
for(var x in sliders[q.id]){
|
||||
t+= sliders[q.id][x].getValue();
|
||||
}
|
||||
if(t > total){
|
||||
t -= this.getValue();
|
||||
t = Math.round(t);
|
||||
this.setValue(total-t);// + (scale*step));
|
||||
document.getElementById(this.input).value = Math.round(parseFloat(( ((total-t) / total) * distance) + min ));
|
||||
}else{
|
||||
this.lastValue = this.getValue();
|
||||
document.getElementById(this.input).value = this.getRealValue();
|
||||
}
|
||||
};
|
||||
s.subscribe("change", check);
|
||||
s.subscribe("slideEnd", check);
|
||||
var manualEntry = function(e){
|
||||
// set the value when the 'return' key is detected
|
||||
if (Event.getCharCode(e) === 13 || e.type == 'blur') {
|
||||
var v = parseFloat(this.value, 10);
|
||||
v = (lang.isNumber(v)) ? v : 0;
|
||||
// v *= scale;
|
||||
v = ( ( (v-min) / distance))*total;
|
||||
// convert the real value into a pixel offset
|
||||
for(var sl in sliders[q.id]){
|
||||
if(sliders[q.id][sl].input == this.id){
|
||||
sliders[q.id][sl].setValue(Math.round(v));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Event.on(document.getElementById(s.input), "blur", manualEntry);
|
||||
Event.on(document.getElementById(s.input), "keypress", manualEntry);
|
||||
|
||||
s.getRealValue = function() {
|
||||
return Math.round(parseFloat(( (this.getValue() / total) * distance) + min ));
|
||||
}
|
||||
document.getElementById(s.input).value = s.getRealValue();
|
||||
}
|
||||
}
|
||||
|
||||
this.selectCalendar = function(event,args,obj){
|
||||
var id = obj[1];
|
||||
var selected = args[0];
|
||||
var date = selected[0];
|
||||
var year = date[0], month = date[1], day = date[2];
|
||||
var input = document.getElementById(id);
|
||||
input.value = month + "/" + day + "/" + year;
|
||||
obj[0].hide();
|
||||
}
|
||||
|
||||
|
||||
this.showCalendar = function(event,objs){
|
||||
objs[0].show();
|
||||
}
|
||||
|
||||
this.sliderTextSet = function(event,objs){
|
||||
this.value = this.value * 1;
|
||||
if(this.value == 'NaN'){this.value = 0;}
|
||||
sliders[this.id].setValue(Math.round(this.value * sliders[this.id].scale));
|
||||
}
|
||||
|
||||
this.buttonChanged = function(event,objs){
|
||||
var b = objs[0];
|
||||
var qid = objs[1];
|
||||
var maxA = objs[2];
|
||||
var butts = objs[3];
|
||||
var qsize = objs[4];
|
||||
var aid = objs[5];
|
||||
max = parseFloat(max);
|
||||
// clearTimeout(Survey.Form.submittimer);
|
||||
if(maxA == 1){
|
||||
if(b.className == 'mcbutton-selected'){
|
||||
document.getElementById(b.hid).value = 0;
|
||||
b.className='mcbutton';
|
||||
}else{
|
||||
document.getElementById(b.hid).value = 1;
|
||||
b.className='mcbutton-selected';
|
||||
}
|
||||
for(var i in butts){
|
||||
if(butts[i] != b){
|
||||
butts[i].className='mcbutton';
|
||||
document.getElementById(butts[i].hid).value = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(b.className == 'mcbutton'){
|
||||
var bscount = 0;//button selected count
|
||||
for(var i in butts){
|
||||
if(butts[i].className == 'mcbutton-selected'){bscount++;}
|
||||
}
|
||||
var max = maxA - bscount;//= parseFloat(document.getElementById(qid+'max').innerHTML);
|
||||
if(max == 0){
|
||||
b.className='mcbutton';
|
||||
//warn that options used up
|
||||
}
|
||||
else{
|
||||
b.className='mcbutton-selected';
|
||||
//document.getElementById(qid+'max').innerHTML = parseFloat(max-1);
|
||||
document.getElementById(b.hid).value = 1;
|
||||
}
|
||||
}else{
|
||||
b.className='mcbutton';
|
||||
var bscount = 0;//button selected count
|
||||
for(var i in butts){
|
||||
if(butts[i].className == 'mcbutton-selected'){bscount++;}
|
||||
}
|
||||
var max = maxA - bscount;//= parseFloat(document.getElementById(qid+'max').innerHTML);
|
||||
// document.getElementById(qid+'max').innerHTML = parseFloat(max+1);
|
||||
document.getElementById(b.hid).value = '';
|
||||
}
|
||||
/*
|
||||
if(qsize == 1 && b.className == 'mcbutton-selected'){
|
||||
if(! document.getElementById(aid+'verbatim')){
|
||||
Survey.Form.submittimer=setTimeout("Survey.Form.formsubmit()",500);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}();
|
||||
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
//
|
||||
// Initialize survey
|
||||
//
|
||||
//----------------------------------------------------------------
|
||||
Survey.OnLoad = new function() {
|
||||
var e = YAHOO.util.Event;
|
||||
this.init = function() {
|
||||
e.onDOMReady(this.initHandler);
|
||||
}
|
||||
this.initHandler = function(){
|
||||
Survey.Comm.setUrl('/'+document.getElementById('assetPath').value);
|
||||
Survey.Comm.callServer('','loadQuestions');
|
||||
}
|
||||
}();
|
||||
|
||||
Survey.OnLoad.init();
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
if (typeof Survey == "undefined") {
|
||||
var Survey = {};
|
||||
}
|
||||
|
||||
Survey.Comm= new function(){
|
||||
|
||||
|
||||
this.url = '';
|
||||
this.setUrl = function(u){this.url = u;}
|
||||
var callMade = 0;
|
||||
var request = function(sUrl,callback,postData,form, hasFile){
|
||||
if(form != undefined){
|
||||
if(hasFile){
|
||||
YAHOO.util.Connect.setForm(form,true);
|
||||
//YAHOO.log('set file was true');
|
||||
}else{
|
||||
//YAHOO.log('set file was false');
|
||||
YAHOO.util.Connect.setForm(form);
|
||||
}
|
||||
//YAHOO.log('setForm was true');
|
||||
}
|
||||
if(callMade == 1){
|
||||
alert("Waiting on previous request");
|
||||
}else{
|
||||
callMade = 1;
|
||||
YAHOO.log(sUrl);
|
||||
YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.callback = {
|
||||
upload:function(o){
|
||||
callMade = 0;
|
||||
Survey.Comm.callServer('','loadQuestions');
|
||||
},
|
||||
success:function(o){
|
||||
window.scrollTo(0,0);
|
||||
callMade = 0;
|
||||
var response = '';
|
||||
response = YAHOO.lang.JSON.parse(o.responseText);
|
||||
if(response.type == 'displayquestions'){
|
||||
Survey.Form.displayQuestions(response);
|
||||
}else if(response.type == 'forward'){
|
||||
//YAHOO.log("going to "+response.url);
|
||||
location.href=response.url;
|
||||
}else{
|
||||
alert("bad response");
|
||||
}
|
||||
},
|
||||
failure: function(o){
|
||||
callMade = 0;
|
||||
if(o.status == -1){
|
||||
alert("Last request timed out, please try again");
|
||||
}else{
|
||||
alert("Last request failed "+o.statusText);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
this.callServer = function(data,functionName,form,hasFile){
|
||||
var postData;
|
||||
if(form == undefined){
|
||||
postData = "data="+YAHOO.lang.JSON.stringify(data,data);
|
||||
//YAHOO.log(postData);
|
||||
}
|
||||
var sUrl = this.url + "?func="+functionName;
|
||||
request(sUrl,this.callback,postData,form,hasFile);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}();
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 433 B |
|
|
@ -1,125 +0,0 @@
|
|||
if (typeof Survey == "undefined") {
|
||||
var Survey = {};
|
||||
}
|
||||
var Dom = YAHOO.util.Dom;
|
||||
var Event = YAHOO.util.Event;
|
||||
var DDM = YAHOO.util.DragDropMgr;
|
||||
|
||||
Survey.DDList = function(id, sGroup, config) {
|
||||
|
||||
Survey.DDList.superclass.constructor.call(this, id, sGroup, config);
|
||||
|
||||
this.logger = this.logger || YAHOO;
|
||||
var el = this.getDragEl();
|
||||
Dom.setStyle(el, "opacity", 0.67); // The proxy is slightly transparent
|
||||
|
||||
this.goingUp = false;
|
||||
this.lastY = 0;
|
||||
};
|
||||
|
||||
YAHOO.extend(Survey.DDList, YAHOO.util.DDProxy, {
|
||||
|
||||
startDrag: function(x, y) {
|
||||
this.logger.log(this.id + " startDrag");
|
||||
|
||||
// make the proxy look like the source element
|
||||
var dragEl = this.getDragEl();
|
||||
var clickEl = this.getEl();
|
||||
Dom.setStyle(clickEl, "visibility", "hidden");
|
||||
|
||||
dragEl.innerHTML = clickEl.innerHTML;
|
||||
|
||||
Dom.setStyle(dragEl, "color", Dom.getStyle(clickEl, "color"));
|
||||
Dom.setStyle(dragEl, "backgroundColor", Dom.getStyle(clickEl, "backgroundColor"));
|
||||
Dom.setStyle(dragEl, "border", "2px solid gray");
|
||||
},
|
||||
|
||||
endDrag: function(e) {
|
||||
|
||||
var srcEl = this.getEl();
|
||||
var proxy = this.getDragEl();
|
||||
|
||||
// Show the proxy element and animate it to the src element's location
|
||||
Dom.setStyle(proxy, "visibility", "");
|
||||
var a = new YAHOO.util.Motion(
|
||||
proxy, {
|
||||
points: {
|
||||
to: Dom.getXY(srcEl)
|
||||
}
|
||||
},
|
||||
0.2,
|
||||
YAHOO.util.Easing.easeOut
|
||||
)
|
||||
var proxyid = proxy.id;
|
||||
var thisid = this.id;
|
||||
|
||||
// Hide the proxy and show the source element when finished with the animation
|
||||
a.onComplete.subscribe(function() {
|
||||
Dom.setStyle(proxyid, "visibility", "hidden");
|
||||
Dom.setStyle(thisid, "visibility", "");
|
||||
});
|
||||
a.animate();
|
||||
},
|
||||
|
||||
onDragDrop: function(e, id) {
|
||||
|
||||
// If there is one drop interaction, the li was dropped either on the list,
|
||||
// or it was dropped on the current location of the source element.
|
||||
if (DDM.interactionInfo.drop.length === 1) {
|
||||
|
||||
// The position of the cursor at the time of the drop (YAHOO.util.Point)
|
||||
var pt = DDM.interactionInfo.point;
|
||||
|
||||
// The region occupied by the source element at the time of the drop
|
||||
var region = DDM.interactionInfo.sourceRegion;
|
||||
|
||||
// Check to see if we are over the source element's location. We will
|
||||
// append to the bottom of the list once we are sure it was a drop in
|
||||
// the negative space (the area of the list without any list items)
|
||||
if (!region.intersect(pt)) {
|
||||
var destEl = Dom.get(id);
|
||||
var destDD = DDM.getDDById(id);
|
||||
destEl.appendChild(this.getEl());
|
||||
destDD.isEmpty = false;
|
||||
DDM.refreshCache();
|
||||
}
|
||||
|
||||
}
|
||||
Survey.Data.dragDrop(this.getEl());
|
||||
},
|
||||
|
||||
onDrag: function(e) {
|
||||
|
||||
// Keep track of the direction of the drag for use during onDragOver
|
||||
var y = Event.getPageY(e);
|
||||
|
||||
if (y < this.lastY) {
|
||||
this.goingUp = true;
|
||||
} else if (y > this.lastY) {
|
||||
this.goingUp = false;
|
||||
}
|
||||
|
||||
this.lastY = y;
|
||||
},
|
||||
|
||||
onDragOver: function(e, id) {
|
||||
|
||||
var srcEl = this.getEl();
|
||||
var destEl = Dom.get(id);
|
||||
|
||||
// We are only concerned with list items, we ignore the dragover
|
||||
// notifications for the list.
|
||||
if (destEl.nodeName.toLowerCase() == "li") {
|
||||
var orig_p = srcEl.parentNode;
|
||||
var p = destEl.parentNode;
|
||||
|
||||
if (this.goingUp) {
|
||||
p.insertBefore(srcEl, destEl); // insert above
|
||||
} else {
|
||||
p.insertBefore(srcEl, destEl.nextSibling); // insert below
|
||||
}
|
||||
|
||||
DDM.refreshCache();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -1,123 +0,0 @@
|
|||
if (typeof Survey == "undefined") {
|
||||
var Survey = {};
|
||||
}
|
||||
|
||||
Survey.Data = new function(){
|
||||
var lastDataSet = {};
|
||||
var focus;
|
||||
|
||||
|
||||
this.dragDrop = function(did){
|
||||
var type;
|
||||
YAHOO.log('In drag drop');
|
||||
if(did.className.match("section")){type = 'section';}
|
||||
else if(did.className.match("question")){type = 'question';}
|
||||
else{ type = 'answer';}
|
||||
|
||||
var first = {id:did.id,type:type};
|
||||
var before = document.getElementById(did.id).previousSibling;
|
||||
|
||||
while(1){
|
||||
if( before == undefined || (before.id != undefined && before.id != '') ){
|
||||
break;
|
||||
}
|
||||
var before = before.previousSibling;
|
||||
}
|
||||
|
||||
var data = {id:'',type:''};
|
||||
|
||||
if(before != undefined && before.id != undefined && before.id != ''){
|
||||
if(before.className.match("section")){type = 'section';}
|
||||
else if(before.className.match("question")){type = 'question';}
|
||||
else{ type = 'answer';}
|
||||
data = {id:before.id,type:type};
|
||||
}
|
||||
YAHOO.log(first.id+' '+data.id);
|
||||
Survey.Comm.dragDrop(first,data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.clicked = function(){
|
||||
Survey.Comm.loadSurvey(this.id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.loadData = function(d){
|
||||
focus = d.address;//What is the current highlighted item.
|
||||
document.getElementById('sections').innerHTML=d.ddhtml;
|
||||
|
||||
//add event handlers for if a tag is clicked
|
||||
for(var x in d.ids){
|
||||
YAHOO.log('adding handler for '+ d.ids[x]);
|
||||
YAHOO.util.Event.addListener(d.ids[x], "click", this.clicked);
|
||||
new Survey.DDList(d.ids[x],"sections");
|
||||
}
|
||||
|
||||
//add the add object buttons
|
||||
// if(d.buttons['section']){
|
||||
document.getElementById('addSection').innerHTML = '';
|
||||
document.getElementById('addQuestion').innerHTML = '';
|
||||
document.getElementById('addAnswer').innerHTML = '';
|
||||
var button = new YAHOO.widget.Button({ label:"Add Section", id:"addsection", container:"addSection" });
|
||||
button.on("click", this.addSection);
|
||||
// }
|
||||
// if(d.buttons['question']){
|
||||
var button = new YAHOO.widget.Button({ label:"Add Question", id:"addquestion", container:"addQuestion" });
|
||||
button.on("click", this.addQuestion,d.buttons['question']);
|
||||
// }
|
||||
if(d.buttons['answer']){
|
||||
var button = new YAHOO.widget.Button({ label:"Add Answer", id:"addanswer", container:"addAnswer" });
|
||||
button.on("click", this.addAnswer,d.buttons['answer']);
|
||||
}
|
||||
|
||||
this.loadObjectEdit(d.edithtml,d.type);
|
||||
lastDataSet = d;
|
||||
}
|
||||
|
||||
this.addSection = function(){
|
||||
Survey.Comm.newSection();
|
||||
}
|
||||
|
||||
|
||||
this.addQuestion = function(e,id){
|
||||
Survey.Comm.newQuestion(id);
|
||||
}
|
||||
|
||||
this.addAnswer = function(e,id){
|
||||
Survey.Comm.newAnswer(id);
|
||||
}
|
||||
|
||||
this.loadObjectEdit = function(edit,type){
|
||||
if(edit){
|
||||
Survey.ObjectTemplate.loadObject(edit,type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.loadLast = function(){
|
||||
this.loadData(lastDataSet);
|
||||
}
|
||||
}();
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
//
|
||||
// Initialize survey
|
||||
//
|
||||
//----------------------------------------------------------------
|
||||
Survey.OnLoad = function() {
|
||||
var e = YAHOO.util.Event;
|
||||
return {
|
||||
init: function() {
|
||||
e.onDOMReady(this.initHandler);
|
||||
},
|
||||
initHandler: function(){
|
||||
new YAHOO.util.DDTarget("sections","sections");
|
||||
Survey.Comm.loadSurvey();
|
||||
},
|
||||
}
|
||||
}();
|
||||
|
||||
Survey.OnLoad.init();
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
if (typeof Survey == "undefined") {
|
||||
var Survey = {};
|
||||
}
|
||||
|
||||
Survey.AnswerTemplate = new function(){
|
||||
this.params;
|
||||
this.loadAnswer = function(params){
|
||||
for(var p in params){
|
||||
if(params[p] == undefined){params[p] = '';}
|
||||
}
|
||||
|
||||
var html = "\
|
||||
<div id='answer'>\
|
||||
<div class='hd'>Please enter answer information</div>\
|
||||
<div class='bd'>\
|
||||
\
|
||||
<form name='form' method='POST' action='?func=submitAnswerEdit'>\
|
||||
\
|
||||
<p>Answer Number: "+params.sequenceNumber + "\
|
||||
\
|
||||
<input type='hidden' name='Survey_sectionId' value='"+params.Survey_sectionId+"'>\
|
||||
<input type='hidden' name='Survey_questionId' value='"+params.Survey_questionId+"'>\
|
||||
<input type='hidden' name='Survey_answerId' value='"+params.Survey_answerId+"'>";
|
||||
html = html + "<p>Answer Text:\n<textarea name='answerText'>"+params.answerText+"</textArea>\n";
|
||||
html = html + "<p>Recorded Answer\n<textarea name='recordedAnswer'>"+params.recordedAnswer+"</textArea>\n";
|
||||
html = html + "<p>Jump to:<input type=text value='"+params.gotoQuestion+"' name=gotoQuestion size=4>";
|
||||
html = html + "<span id='textParams'><p>Text Answer Cols:<input type=text size=2 value='"+params.textCols+"' name=textCols> Rows: \
|
||||
<input type=text size=2 value='"+params.textRows+"' name=textRows> </p></span>";
|
||||
html = html + "<p>Is this the correct answer:\n" +
|
||||
this.makeRadio('isCorrect',[{text:'Yes',value:1},{text:'No',value:0}],params.isCorrect);
|
||||
html = html + "<p>Min:<input type=text value='"+params.min+"' name=min size=2>";
|
||||
html = html + "<p>Max:<input type=text value='"+params.max+"' name=max size=2>";
|
||||
html = html + "<p>Step:<input type=text value='"+params.step+"' name=step size=2>";
|
||||
html = html + "<p>Verbatim:\n" +
|
||||
this.makeRadio('verbatim',[{text:'Yes',value:1},{text:'No',value:0}],params.verbatim);
|
||||
document.getElementById('edit').innerHTML = html;
|
||||
|
||||
var butts = [{ text:"Submit", handler:function(){this.submit();}, isDefault:true },{ text:"Cancel", handler:function(){this.cancel();}} ];
|
||||
if(params.Survey_answerId != ''){
|
||||
butts[2] = { text:"Delete", handler:function(){Survey.Comm.deleteAnswer(Survey.AnswerTemplate.params.Survey_answerId);}};
|
||||
}
|
||||
|
||||
var form = new YAHOO.widget.Dialog("answer",
|
||||
{ width : "500px",
|
||||
fixedcenter : true,
|
||||
visible : false,
|
||||
constraintoviewport : true,
|
||||
buttons : butts
|
||||
});
|
||||
|
||||
form.callback = Survey.Comm.callback;
|
||||
form.render();
|
||||
form.show();
|
||||
this.params = params;
|
||||
};
|
||||
|
||||
this.makeRadio = function(name,values,checked){
|
||||
var html = '';
|
||||
for(var i in values){
|
||||
if(checked == values[i]['value']){
|
||||
html = html+ "<input type='radio' name='" + name + "' value='" + values[i]['value'] + "' checked>" + values[i]['text'];
|
||||
}else{
|
||||
html = html+ "<input type='radio' name='" + name + "' value='" + values[i]['value'] + "' >" + values[i]['text'];
|
||||
}
|
||||
}
|
||||
html = html + "\n";
|
||||
return html;
|
||||
}
|
||||
}();
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
if (typeof Survey == "undefined") {
|
||||
var Survey = {};
|
||||
}
|
||||
|
||||
Survey.Comm = new function(){
|
||||
var callMade = 0;
|
||||
|
||||
var request = function(sUrl,callback,postData){
|
||||
if(callMade == 1){
|
||||
alert("Waiting on previous request");
|
||||
}else{
|
||||
callMade = 1;
|
||||
YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);
|
||||
}
|
||||
}
|
||||
this.callback = {
|
||||
success:function(o){
|
||||
callMade = 0;
|
||||
Survey.Data.loadData(YAHOO.lang.JSON.parse(o.responseText));
|
||||
},
|
||||
failure: function(o){
|
||||
callMade = 0;
|
||||
alert("Last request failed");
|
||||
Survey.Data.loadLast();
|
||||
},
|
||||
timeout: 5000
|
||||
};
|
||||
this.loadSurvey = function(p){
|
||||
var postData = "data="+p;
|
||||
var sUrl = "?func=loadSurvey";
|
||||
request(sUrl,this.callback,postData);
|
||||
}
|
||||
this.dragDrop = function(target,before){
|
||||
var p = {};
|
||||
p['target'] = target;
|
||||
p['before'] = before;
|
||||
var postData = "data="+YAHOO.lang.JSON.stringify(p);
|
||||
var sUrl = "?func=dragDrop";
|
||||
request(sUrl,this.callback,postData);
|
||||
}
|
||||
this.submitEdit = function(p){
|
||||
var postData = "data="+YAHOO.lang.JSON.stringify(p);
|
||||
var sUrl = "?func=submitEdit";
|
||||
request(sUrl,this.callback,postData);
|
||||
}
|
||||
this.newSection = function(){
|
||||
var sUrl = "?func=newObject";
|
||||
request(sUrl,this.callback);
|
||||
}
|
||||
this.newQuestion = function(id){
|
||||
var postData = "data="+id;
|
||||
var sUrl = "?func=newObject";
|
||||
request(sUrl,this.callback,postData);
|
||||
}
|
||||
this.newAnswer = function(id){
|
||||
var postData = "data="+id;
|
||||
var sUrl = "?func=newObject";
|
||||
request(sUrl,this.callback,postData);
|
||||
}
|
||||
this.deleteAnswer = function(id){
|
||||
var postData = "data="+id;
|
||||
var sUrl = "?func=deleteAnswer";
|
||||
request(sUrl,this.callback,postData);
|
||||
}
|
||||
this.deleteQuestion = function(id){
|
||||
var postData = "data="+id;
|
||||
var sUrl = "?func=deleteQuestion";
|
||||
request(sUrl,this.callback,postData);
|
||||
}
|
||||
this.deleteSection = function(id){
|
||||
var postData = "data="+id;
|
||||
var sUrl = "?func=deleteSection";
|
||||
request(sUrl,this.callback,postData);
|
||||
}
|
||||
}();
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
if (typeof Survey == "undefined") {
|
||||
var Survey = {};
|
||||
}
|
||||
|
||||
Survey.ObjectTemplate = new function(){
|
||||
|
||||
this.loadObject = function(html,type){
|
||||
|
||||
document.getElementById('edit').innerHTML = html;
|
||||
|
||||
var butts = [
|
||||
{ text:"Submit", handler:function(){this.submit();}, isDefault:true },
|
||||
{ text:"Copy", handler:function(){document.getElementById('copy').value = 1; this.submit();}},
|
||||
{ text:"Cancel", handler:function(){this.cancel();}},
|
||||
{ text:"Delete", handler:function(){document.getElementById('delete').value = 1; this.submit();}}
|
||||
];
|
||||
|
||||
var form = new YAHOO.widget.Dialog(type,
|
||||
{
|
||||
width : "500px",
|
||||
fixedcenter : true,
|
||||
visible : false,
|
||||
constraintoviewport : true,
|
||||
buttons : butts
|
||||
} );
|
||||
|
||||
form.callback = Survey.Comm.callback;
|
||||
form.render();
|
||||
form.show();
|
||||
}
|
||||
}();
|
||||
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
<div id='question'>
|
||||
<div class='hd'>Please enter question information</div>
|
||||
<div class='bd'>
|
||||
<form name='form' method='POST' action='?func=submitObjectEdit'>
|
||||
<p>Question Number: <tmpl_var displayed_id>
|
||||
<input type='hidden' name='id' value='<tmpl_var id>'>
|
||||
<p>Question Text:\n";
|
||||
<textarea name='questionText'><tmpl_var text></textArea>\n";
|
||||
<p>Question variable name:<input maxlength=35 size=10 type=text value='<tmpl_var variable>' name=variable size=2></p>";
|
||||
<p>Randomize answers:";
|
||||
<input type='radio' name='randomizeAnswers' value=1 <tmpl_if randomizeAnswers>checked</tmpl_if>>Yes
|
||||
<input type='radio' name='randomizeAnswers' value=0 <tmpl_unless randomizeAnswers>checked</tmpl_unless>>No
|
||||
<p>Question type:
|
||||
<select name='questionType'>
|
||||
<tmpl_loop questionType>
|
||||
<option value='<tmpl_var text>' <tmpl_if selected>selected</tmpl_if>><tmpl_var text></option>
|
||||
</tmpl_loop>
|
||||
</select>
|
||||
<p>Randomized words:
|
||||
<textarea name=randomizWords><tmpl_var randomWords></textArea>
|
||||
<p>Vertical display:
|
||||
<input type='radio' name='verticalDisplay' value=1 <tmpl_if verticalDisplay>checked</tmpl_if>>Yes
|
||||
<input type='radio' name='verticalDisplay' value=0 <tmpl_unless verticalDisplay>checked</tmpl_unless>>No
|
||||
|
||||
<p>Show text in button:
|
||||
<input type='radio' name='textInButton' value=1 <tmpl_if textInButton>checked</tmpl_if>>Yes
|
||||
<input type='radio' name='textInButton' value=0 <tmpl_unless textInButton>checked</tmpl_unless>>No
|
||||
|
||||
<p>Allow comment:
|
||||
<input type='radio' name='allowComment' value=1 <tmpl_if allowComment>checked</tmpl_if>>Yes
|
||||
<input type='radio' name='allowComment' value=0 <tmpl_unless allowComment>checked</tmpl_unlexx>>No
|
||||
<span id='commentParams'><p> Cols:<input type=text size=2 value='<tmpl_var commentCols>' name=commentCols> Rows:
|
||||
<input type=text size=2 value='<tmpl_var commentRows>' name=commentRows> </p></span>
|
||||
<p>Maximum number of answers:<input type=text value='<tmpl_var maxAnswers>' name=maxAnswers size=2>
|
||||
<p>Required:
|
||||
<input type='radio' name='required' value=1 <tmpl_if required>checked</tmpl_if>>Yes
|
||||
<input type='radio' name='required' value=0 <tmpl_unless required>checked</tmpl_unless>>No
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
if (typeof Survey == "undefined") {
|
||||
var Survey = {};
|
||||
}
|
||||
|
||||
Survey.QuestionTemplate = new function(){
|
||||
|
||||
this.loadQuestion = function(params){
|
||||
|
||||
for(var p in params){
|
||||
if(params[p] == undefined){params[p] = '';}
|
||||
}
|
||||
|
||||
var html = "\
|
||||
<div id='question'>\
|
||||
<div class='hd'>Please enter question information</div>\
|
||||
<div class='bd'>\
|
||||
\
|
||||
<form name='form' method='POST' action='?func=submitQuestionEdit'>\
|
||||
<p>Question Number: "+params.sequenceNumber + "\
|
||||
\
|
||||
<input type='hidden' name='Survey_sectionId' value='"+params.Survey_sectionId+"'>\
|
||||
<input type='hidden' name='Survey_questionId' value='"+params.Survey_questionId+"'>\
|
||||
<p>Question Text:\n";
|
||||
if(params.questionText == ''){
|
||||
html = html + "<textarea name='questionText'>Enter Text Here</textArea>\n";
|
||||
}
|
||||
else{
|
||||
html = html + "<textarea name='questionText'>"+params.questionText+"</textArea>\n";
|
||||
}
|
||||
html = html + "<p>Question variable name:<input maxlength=35 size=10 type=text value='"+ params.questionVariable +"' name=questionVariable size=2></p>";
|
||||
html = html + "<p>Randomize answers:";
|
||||
|
||||
html = html+ this.makeRadio('randomizeAnswers',[{text:'Yes',value:1},{text:'No',value:0}],params.randomizeAnswers);
|
||||
html = html + "<p>Question type:";
|
||||
var questions = ['Agree/Disagree','Certainty','Concern','Confidence','Currency','Date','Date Range','Dual Slider - Range','Education','Effectiveness',
|
||||
'Email','File Upload','Gender','Hidden','Ideology','Importance','Likelihood','Multi Slider - Allocate','Multiple Choice','Oppose/Support',
|
||||
'Party','Phone Number','Race','Risk','Satisfaction','Scale','Security','Slider','Text','Text Date','Threat','True/False','Yes/No'];
|
||||
// var questions = ['Multiple Choice','Gender','Yes/No','True/False','Agree/Disagree','Oppose/Support','Importance','Likelihood','Certainty','Satisfaction',
|
||||
// 'Confidence','Effectiveness','Concern','Risk','Threat','Security','Ideology','Race','Party','Education',
|
||||
// 'Text', 'Email', 'Phone Number', 'Text Date', 'Currency',
|
||||
// 'Slider','Dual Slider - Range','Multi Slider - Allocate', 'Date','Date Range', 'File Upload','Hidden'];
|
||||
|
||||
html = html + this.makeMenu('questionType',questions,questions,params.questionType);
|
||||
|
||||
html = html + "\
|
||||
<p>Randomized words:\
|
||||
<textarea name=randomizedWords>"+params.randomizedWords+"</textArea>\
|
||||
<p>Vertical display:";
|
||||
|
||||
html = html+ this.makeRadio('verticalDisplay',[{text:'Yes',value:1},{text:'No',value:0}],params.verticalDisplay);
|
||||
html = html + "<p>Show text in button:";
|
||||
html = html + this.makeRadio('textInButton',[{text:'Yes',value:1},{text:'No',value:0}],params.textInButton);
|
||||
html = html + "<p>Allow comment:";
|
||||
html = html + this.makeRadio('allowComment',[{text:'Yes',value:1},{text:'No',value:0}],params.allowComment);
|
||||
html = html + "<span id='commentParams'><p> Cols:<input type=text size=2 value='"+params.commentCols+"' name=commentCols> Rows: \
|
||||
<input type=text size=2 value='"+params.commentRows+"' name=commentRows> </p></span>";
|
||||
html = html + "<p>Maximum number of answers:<input type=text value='"+params.maxAnswers+"' name=maxAnswers size=2>";
|
||||
html = html + "<p>Required:";
|
||||
html = html+ this.makeRadio('required',[{text:'Yes',value:1},{text:'No',value:0}],params.required);
|
||||
html = html + "\
|
||||
</form>\
|
||||
</div>\
|
||||
</div>\
|
||||
";
|
||||
|
||||
document.getElementById('edit').innerHTML = html;
|
||||
|
||||
|
||||
var butts = [ { text:"Submit", handler:function(){this.submit();}, isDefault:true }, { text:"Cancel", handler:function(){this.cancel();}} ];
|
||||
if(params.Survey_questionId != ''){
|
||||
butts[2] = {text:"Delete", handler:function(){Survey.Comm.deleteQuestion(params.Survey_questionId);}};
|
||||
}
|
||||
|
||||
var form = new YAHOO.widget.Dialog("question",
|
||||
{ width : "500px",
|
||||
fixedcenter : true,
|
||||
visible : false,
|
||||
constraintoviewport : true,
|
||||
buttons : butts
|
||||
} );
|
||||
|
||||
form.callback = Survey.Comm.callback;
|
||||
form.render();
|
||||
form.show();
|
||||
|
||||
}
|
||||
this.makeMenu = function(name,values,text,selected){
|
||||
var html = "<select name='"+name+"'>\n";
|
||||
for(var i in values){
|
||||
if(values[i] == selected){
|
||||
html = html + "<option value='"+values[i]+"' selected>"+text[i]+"</option>\n";
|
||||
}else{
|
||||
html = html + "<option value='"+values[i]+"' >"+text[i]+"</option>\n";
|
||||
}
|
||||
}
|
||||
html = html + "</select>\n";
|
||||
return html;
|
||||
}
|
||||
this.makeRadio = function(name,values,checked){
|
||||
var html = '';
|
||||
for(var i in values){
|
||||
if(checked == values[i]['value']){
|
||||
html = html+ "<input type='radio' id='"+name+"' name='" + name + "' value='" + values[i]['value'] + "' checked>" + values[i]['text'];
|
||||
}else{
|
||||
html = html+ "<input type='radio' id='"+name+"' name='" + name + "' value='" + values[i]['value'] + "' >" + values[i]['text'];
|
||||
}
|
||||
}
|
||||
html = html + "\n";
|
||||
return html;
|
||||
}
|
||||
|
||||
}();
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
if (typeof Survey == "undefined") {
|
||||
var Survey = {};
|
||||
}
|
||||
|
||||
Survey.SectionTemplate = new function(){
|
||||
|
||||
this.loadSection = function(html){
|
||||
|
||||
document.getElementById('edit').innerHTML = html;
|
||||
|
||||
var butts = [ { text:"Submit", handler:function(){this.submit();}, isDefault:true }, { text:"Cancel", handler:function(){this.cancel();}},
|
||||
{text:"Delete", handler:function(){document.getElementById('delete').setValue(1); this.submit();}}
|
||||
];
|
||||
|
||||
var form = new YAHOO.widget.Dialog("section",
|
||||
{ width : "500px",
|
||||
fixedcenter : true,
|
||||
visible : false,
|
||||
constraintoviewport : true,
|
||||
buttons : butts
|
||||
} );
|
||||
|
||||
form.callback = Survey.Comm.callback;
|
||||
form.render();
|
||||
form.show();
|
||||
}
|
||||
}();
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 132 B |
|
|
@ -1,85 +0,0 @@
|
|||
body {
|
||||
margin: 0;
|
||||
background-repeat: repeat-y;
|
||||
background-position: 0px 0px;
|
||||
}
|
||||
.header {
|
||||
width: 80%;
|
||||
height: 20px;
|
||||
margin-left: 80px;
|
||||
}
|
||||
#survey {
|
||||
margin-left: 80px;
|
||||
width: 85%;
|
||||
}
|
||||
|
||||
div.dateanswer {
|
||||
min-height: 250px;
|
||||
}
|
||||
div.slider-bg {
|
||||
position: relative;
|
||||
background:url(/extras/wobject/Survey/bg-fader-500.gif) 5px 0 no-repeat;
|
||||
height:68px;
|
||||
width:529px;
|
||||
}
|
||||
div.slider-thumb {
|
||||
cursor:default;
|
||||
position: absolute;
|
||||
top: 30px;
|
||||
left: 4px;
|
||||
}
|
||||
div.slider-min-thumb {
|
||||
cursor:default;
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
}
|
||||
div.slider-max-thumb {
|
||||
cursor:default;
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
}
|
||||
#headertitle {
|
||||
display: none;
|
||||
}
|
||||
#headertext {
|
||||
display: none;
|
||||
}
|
||||
#questions {
|
||||
display: none;
|
||||
}
|
||||
input.mcbutton{
|
||||
font-size: 10px;
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
background-color: #CCCCCC;
|
||||
background-repeat: repeat-x;
|
||||
text-align: center;
|
||||
display: block;
|
||||
margin: 0.5em;
|
||||
padding: .8em;
|
||||
width: 60px;
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
color: #000000;
|
||||
background-image: url(/extras/wobject/Survey/gradient-glossy.png);
|
||||
}
|
||||
input.mcbutton:hover{
|
||||
background-color: #B6D2F1;
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size: 10px;
|
||||
color: #000000;
|
||||
}
|
||||
input.mcbutton-selected{
|
||||
background-color: #172D9D;
|
||||
background-repeat: repeat-x;
|
||||
color: #FFFFFF;
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size: 10px;
|
||||
margin: 0.5em;
|
||||
padding: .8em;
|
||||
width: 60px;
|
||||
text-align: center;
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
background-image: url(/extras/wobject/Survey/gradient-glossy.png);
|
||||
background-position: 0px 0px;
|
||||
}
|
||||
|
|
@ -1,132 +0,0 @@
|
|||
|
||||
div.testarea {
|
||||
width: 200px;
|
||||
height: 100px;
|
||||
z-index: 999;
|
||||
border: 1px solid gray;
|
||||
background: #f7f7f7;
|
||||
position: absolute;
|
||||
top: 5%;
|
||||
left:5%;
|
||||
}
|
||||
|
||||
div.trashcan {
|
||||
border: 1px solid gray;
|
||||
width: 175px;
|
||||
height: 50px;
|
||||
}
|
||||
div.workarea {
|
||||
padding:10px;
|
||||
padding-top:40px;
|
||||
float:left
|
||||
}
|
||||
|
||||
div.editarea {
|
||||
margin-top:40px;
|
||||
padding:10px;
|
||||
float:left;
|
||||
border: 1px solid gray;
|
||||
}
|
||||
|
||||
div.editquestion {
|
||||
padding:10px;
|
||||
float:left;
|
||||
}
|
||||
div.editanswer {
|
||||
padding:10px;
|
||||
float:left;
|
||||
}
|
||||
|
||||
#submitbutton { padding:20px; }
|
||||
|
||||
div.entry {
|
||||
padding-bottom:10px;
|
||||
padding-left:10px;
|
||||
}
|
||||
|
||||
ul.draglist {
|
||||
position: relative;
|
||||
width: 340px;
|
||||
background: #f7f7f7;
|
||||
border: 1px solid gray;
|
||||
list-style: none;
|
||||
margin:0;
|
||||
padding:0;
|
||||
padding-bottom:20px;
|
||||
}
|
||||
|
||||
ul.draglist li {
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
ul.questionList {
|
||||
position: relative;
|
||||
background: #f7f7f7;
|
||||
border: 1px solid gray;
|
||||
list-style: none;
|
||||
margin:0;
|
||||
padding:0;
|
||||
min-height: 40px
|
||||
}
|
||||
|
||||
li.section {
|
||||
background-color: #CCCCFF;
|
||||
border:1px solid #7EA6B2;
|
||||
cursor: move;
|
||||
min-height: 10px;
|
||||
}
|
||||
|
||||
li.ssection {
|
||||
background-color: #E76300;
|
||||
border:1px solid #7EA6B2;
|
||||
cursor: move;
|
||||
min-height: 10px;
|
||||
}
|
||||
|
||||
li.squestion {
|
||||
background-color: #CC6600;
|
||||
border:1px solid #7EA6B2;
|
||||
cursor: move;
|
||||
padding-left:15px;
|
||||
width: 80%;
|
||||
min-height: 10px;
|
||||
}
|
||||
li.newQuestion {
|
||||
# background-color: #D1E6EC;
|
||||
# border:1px solid #7EA6B2;
|
||||
# cursor: move;
|
||||
padding-left:25px;
|
||||
}
|
||||
|
||||
li.question {
|
||||
background-color: #D1E6EC;
|
||||
border:1px solid #7EA6B2;
|
||||
cursor: move;
|
||||
padding-left:15px;
|
||||
width:80%;
|
||||
min-height: 10px;
|
||||
}
|
||||
|
||||
li.answer {
|
||||
background-color: #D1E6EC;
|
||||
border:1px solid #7EA6B2;
|
||||
cursor: move;
|
||||
padding-left:50px;
|
||||
width:60%;
|
||||
min-height: 10px;
|
||||
}
|
||||
li.sanswer {
|
||||
background-color: #CC6600;
|
||||
border:1px solid #7EA6B2;
|
||||
cursor: move;
|
||||
padding-left:50px;
|
||||
width:60%;
|
||||
min-height: 10px;
|
||||
}
|
||||
li.newAnswer {
|
||||
# background-color: #D1E6EC;
|
||||
# border:1px solid #7EA6B2;
|
||||
padding-left:50px;
|
||||
# cursor: move;
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 612 B |
Loading…
Add table
Add a link
Reference in a new issue