Merge branch 'master' into survey
* master: (127 commits) Prefill in the email address in the ITransact credentials form from the user's Shop address. fixed Matrix best/worst rated lists Fix bad form variable for phone number in EMS Badge address info. - Added a switch to allow the use of non-WebGUI objects with the Workflow fixing a problem with previous survey fix fixed #9671: Survey - breaks admin bar fixed a Matrix sql problem i18n the image labels and title for the asset manager, manage screen. Prevent an imported package from changing the a current asset's status from pending to anything else. Remove trailing comma in Shop/Transaction JS so IE6 works. fixed documentation fixed a bug when a matrix listing didn't have a forum attached small char encoding fix to merged upgrade fix small issue in addChild adding merge point Fix a problem with purging an EMS. Update this template so that it passes the template i18n test. Fix a broken i18n label in answer edit template for the Survey. Unify all Survey CSS into 1 file, and use it. Adding/fixing Survey i18n and Help ... Conflicts: lib/WebGUI/Asset/Wobject/Survey.pm lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm lib/WebGUI/i18n/English/Asset_Survey.pm www/extras/wobject/Survey/editsurvey/object.js
This commit is contained in:
commit
b0c5c09461
127 changed files with 5481 additions and 677 deletions
|
|
@ -1855,6 +1855,22 @@ sub update {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 validParent
|
||||
|
||||
Make sure that the current session asset is a Calendar for pasting and adding checks.
|
||||
|
||||
This is a class method.
|
||||
|
||||
=cut
|
||||
|
||||
sub validParent {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
return $session->asset->isa('WebGUI::Asset::Wobject::Calendar');
|
||||
}
|
||||
|
||||
####################################################################
|
||||
|
||||
=head2 view
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ sub definition {
|
|||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my $i18n = __PACKAGE__->i18n($session);
|
||||
my $i18n = WebGUI::International->new($session,'Asset_Photo');
|
||||
|
||||
tie my %properties, 'Tie::IxHash', (
|
||||
views => {
|
||||
|
|
@ -508,23 +508,6 @@ sub getTemplateVars {
|
|||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 i18n ( session )
|
||||
|
||||
Get the i18n object for this class. This sub must not be inherited, so always
|
||||
call it using C<__PACKAGE__>, not C<$self>.
|
||||
|
||||
=cut
|
||||
|
||||
sub i18n {
|
||||
my $self = shift;
|
||||
my $session = shift;
|
||||
# TODO: Make a migration script to move the appropriate parts from
|
||||
# Asset_Photo to Asset_GalleryFile
|
||||
return WebGUI::International->new( $session, "Asset_Photo" );
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 isFriendsOnly ( )
|
||||
|
|
@ -610,7 +593,7 @@ sub processCommentEditForm {
|
|||
my $session = $self->session;
|
||||
my $form = $self->session->form;
|
||||
my $now = WebGUI::DateTime->new( $session, time );
|
||||
my $i18n = __PACKAGE__->i18n( $session );
|
||||
my $i18n = WebGUI::International->new( $session,'Asset_Photo' );
|
||||
|
||||
# Using die here to suppress line number and file path info
|
||||
die $i18n->get("commentForm error no commentId") . "\n"
|
||||
|
|
@ -649,7 +632,7 @@ sub processCommentEditForm {
|
|||
|
||||
sub processPropertiesFromFormPost {
|
||||
my $self = shift;
|
||||
my $i18n = __PACKAGE__->i18n( $self->session );
|
||||
my $i18n = WebGUI::International->new( $self->session,'Asset_Photo' );
|
||||
my $form = $self->session->form;
|
||||
my $errors = $self->SUPER::processPropertiesFromFormPost || [];
|
||||
|
||||
|
|
@ -794,6 +777,7 @@ sub view {
|
|||
# Keywords
|
||||
my $k = WebGUI::Keyword->new( $session );
|
||||
my $keywords = $k->getKeywordsForAsset( { asArrayRef => 1, asset => $self } );
|
||||
$var->{keywords} = [ ];
|
||||
for my $keyword ( @{ $keywords } ) {
|
||||
push @{ $var->{keywords} }, {
|
||||
keyword => $keyword,
|
||||
|
|
@ -871,7 +855,7 @@ sub www_deleteComment {
|
|||
|
||||
return $session->privilege->insufficient unless $self->canEdit;
|
||||
|
||||
my $i18n = __PACKAGE__->i18n( $session );
|
||||
my $i18n = WebGUI::International->new( $session,'Asset_Photo' );
|
||||
my $commentId = $session->form->get('commentId');
|
||||
|
||||
$self->deleteComment( $commentId );
|
||||
|
|
@ -893,7 +877,7 @@ sub www_deleteConfirm {
|
|||
|
||||
return $self->session->privilege->insufficient unless $self->canEdit;
|
||||
|
||||
my $i18n = __PACKAGE__->i18n( $self->session );
|
||||
my $i18n = WebGUI::International->new( $self->session,'Asset_Photo' );
|
||||
|
||||
$self->purge;
|
||||
|
||||
|
|
@ -965,7 +949,7 @@ Save a comment being edited
|
|||
sub www_editCommentSave {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $i18n = __PACKAGE__->i18n( $session );
|
||||
my $i18n = WebGUI::International->new( $session,'Asset_Photo' );
|
||||
|
||||
# Process the form first, so we can know how to check permissions
|
||||
my $comment = eval { $self->processCommentEditForm };
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ use Image::ExifTool qw( :Public );
|
|||
use JSON qw/ to_json from_json /;
|
||||
use URI::Escape;
|
||||
use Tie::IxHash;
|
||||
use List::MoreUtils;
|
||||
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::Friends;
|
||||
|
|
@ -71,7 +70,7 @@ sub definition {
|
|||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my $i18n = __PACKAGE__->i18n($session);
|
||||
my $i18n = WebGUI::International->new($session, 'Asset_Photo');
|
||||
|
||||
tie my %properties, 'Tie::IxHash', (
|
||||
exifData => {
|
||||
|
|
@ -318,27 +317,6 @@ sub getThumbnailUrl {
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 i18n ( [ session ] )
|
||||
|
||||
Get a WebGUI::International object for this class.
|
||||
|
||||
Can be called as a class method, in which case a WebGUI::Session object
|
||||
must be passed in.
|
||||
|
||||
NOTE: This method can NOT be inherited, due to a current limitation
|
||||
in the i18n system. You must ALWAYS call this with C<__PACKAGE__>
|
||||
|
||||
=cut
|
||||
|
||||
sub i18n {
|
||||
my $self = shift;
|
||||
my $session = shift;
|
||||
|
||||
return WebGUI::International->new($session, "Asset_Photo");
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 makeResolutions ( [resolutions] )
|
||||
|
||||
Create the specified resolutions for this Photo. If resolutions is not
|
||||
|
|
@ -361,19 +339,14 @@ sub makeResolutions {
|
|||
my $storage = $self->getStorageLocation;
|
||||
$self->session->errorHandler->info(" Making resolutions for '" . $self->get("filename") . q{'});
|
||||
|
||||
my $filename = $self->get('filename');
|
||||
RESOLUTION: for my $res ( @$resolutions ) {
|
||||
for my $res ( @$resolutions ) {
|
||||
# carp if resolution is bad
|
||||
if ( $res !~ /^\d+$/ && $res !~ /^\d*x\d*/ ) {
|
||||
carp "Geometry '$res' is invalid. Skipping.";
|
||||
next RESOLUTION;
|
||||
next;
|
||||
}
|
||||
##Only resize images if the image is too big!
|
||||
my ($imageX, $imageY) = $storage->getSizeInPixels($filename);
|
||||
my @resolutions = split /x/, $res;
|
||||
next RESOLUTION if List::MoreUtils::any { $imageX < $_ && $imageY < $_ } @resolutions;
|
||||
my $newFilename = $res . ".jpg";
|
||||
$storage->copyFile( $filename, $newFilename );
|
||||
$storage->copyFile( $self->get("filename"), $newFilename );
|
||||
$storage->resize( $newFilename, $res, undef, $self->getGallery->get( 'imageDensity' ) );
|
||||
}
|
||||
}
|
||||
|
|
@ -623,7 +596,7 @@ Provides links to view the photo and add more photos.
|
|||
|
||||
sub www_showConfirmation {
|
||||
my $self = shift;
|
||||
my $i18n = __PACKAGE__->i18n( $self->session );
|
||||
my $i18n = WebGUI::International->new( $self->session, 'Asset_Photo' );
|
||||
|
||||
return $self->processStyle(
|
||||
sprintf( $i18n->get('save message'),
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ use WebGUI::HTMLForm;
|
|||
use WebGUI::Form::DynamicField;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Inbox;
|
||||
use WebGUI::Macro;
|
||||
use WebGUI::Mail::Send;
|
||||
use WebGUI::Operation;
|
||||
use WebGUI::Paginator;
|
||||
|
|
@ -548,11 +549,19 @@ sub getSynopsisAndContent {
|
|||
my $synopsis = shift;
|
||||
my $body = shift;
|
||||
unless ($synopsis) {
|
||||
$body =~ s/\n/\^\-\;/ unless ($body =~ m/\^\-\;/);
|
||||
my @content = split(/\^\-\;/,$body);
|
||||
$synopsis = WebGUI::HTML::filter($content[0],"all");
|
||||
my @content;
|
||||
if( $body =~ /\^\-\;/ ) {
|
||||
@content = split(/\^\-\;/, $body ,2);
|
||||
}
|
||||
elsif( $body =~ /<p>/ ) {
|
||||
@content = WebGUI::HTML::splitTag($body);
|
||||
}
|
||||
else {
|
||||
@content = split("\n",$body);
|
||||
}
|
||||
shift @content if $content[0] =~ /^\s*$/;
|
||||
$synopsis = WebGUI::HTML::filter($content[0],"all");
|
||||
}
|
||||
$body =~ s/\^\-\;/\n/;
|
||||
return ($synopsis,$body);
|
||||
}
|
||||
|
||||
|
|
@ -843,6 +852,7 @@ sub notifySubscribers {
|
|||
$var->{unsubscribeUrl} = $siteurl.$subscriptionAsset->getUnsubscribeUrl;
|
||||
$var->{unsubscribeLinkText} = $i18n->get("unsubscribe","Asset_Collaboration");
|
||||
my $message = $self->processTemplate($var, $cs->get("notificationTemplateId"));
|
||||
WebGUI::Macro::process($self->session, \$message);
|
||||
my $groupId = $subscriptionAsset->get('subscriptionGroupId');
|
||||
my $mail = WebGUI::Mail::Send->create($self->session, {
|
||||
from=>"<".$from.">",
|
||||
|
|
|
|||
|
|
@ -868,6 +868,22 @@ sub updateThreadRating {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 validParent
|
||||
|
||||
Make sure that the current session asset is a CS for pasting and adding checks.
|
||||
|
||||
This is a class method.
|
||||
|
||||
=cut
|
||||
|
||||
sub validParent {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
return $session->asset->isa('WebGUI::Asset::Wobject::Collaboration');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub view {
|
||||
my $self = shift;
|
||||
|
|
|
|||
|
|
@ -35,6 +35,11 @@ use WebGUI::Asset::RSSFromParent;
|
|||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
|
|
@ -58,6 +63,11 @@ sub definition {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 update
|
||||
|
||||
=cut
|
||||
|
||||
sub update {
|
||||
# Re-force isHidden to 1 on each update; these should always be hidden.
|
||||
my $self = shift;
|
||||
|
|
@ -66,6 +76,11 @@ sub update {
|
|||
}
|
||||
|
||||
#------------------------------------------------
|
||||
|
||||
=head2 _escapeXml
|
||||
|
||||
=cut
|
||||
|
||||
sub _escapeXml {
|
||||
my $text = shift;
|
||||
return $text unless (ref $text eq "");
|
||||
|
|
@ -73,6 +88,11 @@ sub _escapeXml {
|
|||
}
|
||||
|
||||
#------------------------------------------------
|
||||
|
||||
=head2 _tlsOfAsset
|
||||
|
||||
=cut
|
||||
|
||||
sub _tlsOfAsset {
|
||||
my $self = shift;
|
||||
my $asset = shift;
|
||||
|
|
@ -86,12 +106,27 @@ sub _tlsOfAsset {
|
|||
}
|
||||
|
||||
#------------------------------------------------
|
||||
|
||||
=head2 {
|
||||
|
||||
=cut
|
||||
|
||||
sub isValidRssItem { 0 }
|
||||
|
||||
#------------------------------------------------
|
||||
|
||||
=head2 displayInFolder2
|
||||
|
||||
=cut
|
||||
|
||||
sub displayInFolder2 { 0 }
|
||||
|
||||
#------------------------------------------------
|
||||
|
||||
=head2 www_view
|
||||
|
||||
=cut
|
||||
|
||||
sub www_view {
|
||||
my $self = shift;
|
||||
return '' unless $self->session->asset->getId eq $self->getId;
|
||||
|
|
|
|||
|
|
@ -804,8 +804,9 @@ sub www_getUserPrefsForm {
|
|||
}
|
||||
$f->submit({extras=>'className="nothing"'});
|
||||
$f->raw('</table>');
|
||||
my $tags = join "", values %{ $self->session->style->{_javascript} };
|
||||
my $tags = $self->session->style->generateAdditionalHeadTags();
|
||||
$output .= $tags.$f->print;
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
|
@ -855,7 +856,7 @@ sub www_saveUserPrefs {
|
|||
}
|
||||
$u->profileField($field->getId,$data{$field->getId});
|
||||
}
|
||||
return $self->www_view;
|
||||
return $self->getParent->www_view;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -463,10 +463,10 @@ sub www_addToCart {
|
|||
foreach my $field (qw(name address1 address2 address3 city state organization)) {
|
||||
$badgeInfo{$field} = $form->get($field, "text");
|
||||
}
|
||||
$badgeInfo{'phoneNumber'} = $form->get('phoneNumber', 'phone');
|
||||
$badgeInfo{'email'} = $form->get('email', 'email');
|
||||
$badgeInfo{'country'} = $form->get('country', 'country');
|
||||
$badgeInfo{'zipcode'} = $form->get('zipcode', 'zipcode');
|
||||
$badgeInfo{'phoneNumber'} = $form->get('phone', 'phone');
|
||||
$badgeInfo{'email'} = $form->get('email', 'email');
|
||||
$badgeInfo{'country'} = $form->get('country', 'country');
|
||||
$badgeInfo{'zipcode'} = $form->get('zipcode', 'zipcode');
|
||||
|
||||
|
||||
# check for required fields
|
||||
|
|
|
|||
|
|
@ -20,6 +20,11 @@ use HTML::Template::Expr;
|
|||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _rewriteVars
|
||||
|
||||
=cut
|
||||
|
||||
sub _rewriteVars { # replace dots with underscrores in keys (except in keys that aren't usable as variables (URLs etc.))
|
||||
my $vars = shift;
|
||||
my $newVars = {};
|
||||
|
|
|
|||
|
|
@ -51,18 +51,24 @@ sub addRevision {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub canAdd {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
$class->next::method($session, undef, '7');
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
return $class->next::method($session, undef, '7');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub canEdit {
|
||||
my $self = shift;
|
||||
my $form = $self->session->form;
|
||||
return (($form->process("func") eq "add" || ($form->process("assetId") eq "new" && $form->process("func") eq "editSave" && $form->process("class","className") eq "WebGUI::Asset::WikiPage")) && $self->getWiki->canEditPages) # account for new pages
|
||||
|| (!$self->isProtected && $self->getWiki->canEditPages) # account for normal editing
|
||||
|| $self->getWiki->canAdminister; # account for admins
|
||||
my $wiki = $self->getWiki;
|
||||
return undef unless defined $wiki;
|
||||
|
||||
my $form = $self->session->form;
|
||||
my $addNew = $form->process("func" ) eq "add";
|
||||
my $editSave = $form->process("assetId" ) eq "new"
|
||||
&& $form->process("func" ) eq "editSave"
|
||||
&& $form->process("class","className" ) eq "WebGUI::Asset::WikiPage";
|
||||
return $wiki->canAdminister
|
||||
|| ( $wiki->canEditPages && ( $addNew || $editSave || !$self->isProtected) );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -313,6 +319,22 @@ sub update {
|
|||
return $self->next::method($properties);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 validParent
|
||||
|
||||
Make sure that the current session asset is a WikiMaster for pasting and adding checks.
|
||||
|
||||
This is a class method.
|
||||
|
||||
=cut
|
||||
|
||||
sub validParent {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
return $session->asset->isa('WebGUI::Asset::Wobject::WikiMaster');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub view {
|
||||
my $self = shift;
|
||||
|
|
|
|||
|
|
@ -234,6 +234,23 @@ sub processPropertiesFromFormPost {
|
|||
$self->setSize($size);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub update {
|
||||
my $self = shift;
|
||||
my $previousStorageId = $self->get('storageId');
|
||||
$self->SUPER::update(@_);
|
||||
##update may have entered a new storageId. Reset the cached one just in case.
|
||||
if ($self->get("storageId") ne $previousStorageId) {
|
||||
delete $self->{_storageLocation};
|
||||
}
|
||||
$self->getStorageLocation->setPrivileges(
|
||||
$self->get("ownerUserId"),
|
||||
$self->get("groupIdView"),
|
||||
$self->get("groupIdEdit"),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
sub purge {
|
||||
|
|
@ -280,7 +297,8 @@ returns the output.
|
|||
|
||||
sub view {
|
||||
my $self = shift;
|
||||
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10 && !$self->session->form->process("overrideTemplateId") && !$self->session->form->process("pn") && !$self->session->form->process("makePrintable")) {
|
||||
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10 && !$self->session->form->process("overrideTemplateId") &&
|
||||
!$self->session->form->process($self->paginateVar) && !$self->session->form->process("makePrintable")) {
|
||||
my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get;
|
||||
return $out if $out;
|
||||
}
|
||||
|
|
@ -332,7 +350,7 @@ sub view {
|
|||
$var{"description.first.2sentences"} =~ s/^((.*?\.){2}).*/$1/s;
|
||||
$var{"description.first.sentence"} = $var{"description.first.2sentences"};
|
||||
$var{"description.first.sentence"} =~ s/^(.*?\.).*/$1/s;
|
||||
my $p = WebGUI::Paginator->new($self->session,$self->getUrl,1);
|
||||
my $p = WebGUI::Paginator->new($self->session,$self->getUrl,1,$self->paginateVar);
|
||||
if ($self->session->form->process("makePrintable") || $var{description} eq "") {
|
||||
$var{description} =~ s/\^\-\;//g;
|
||||
$p->setDataByArrayRef([$var{description}]);
|
||||
|
|
@ -343,7 +361,8 @@ sub view {
|
|||
}
|
||||
$p->appendTemplateVars(\%var);
|
||||
my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate});
|
||||
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10 && !$self->session->form->process("overrideTemplateId") && !$self->session->form->process("pn") && !$self->session->form->process("makePrintable")) {
|
||||
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10 && !$self->session->form->process("overrideTemplateId") &&
|
||||
!$self->session->form->process($self->paginateVar) && !$self->session->form->process("makePrintable")) {
|
||||
WebGUI::Cache->new($self->session,"view_".$self->getId)->set($out,$self->get("cacheTimeout"));
|
||||
}
|
||||
return $out;
|
||||
|
|
@ -351,6 +370,20 @@ sub view {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 paginateVar ( )
|
||||
|
||||
create a semi-unique variable for pagination based on the Asset Id
|
||||
|
||||
=cut
|
||||
|
||||
sub paginateVar {
|
||||
my $self = shift;
|
||||
my $id = $self->getId();
|
||||
return 'pn' . substr($id,0,2) . substr($id,-2,2) ;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_deleteFile ( )
|
||||
|
||||
Deletes and attached file.
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ use WebGUI::DateTime;
|
|||
use base 'WebGUI::Asset::Wobject';
|
||||
|
||||
use DateTime;
|
||||
use JSON qw/encode_json/;
|
||||
use JSON;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
|
|||
|
|
@ -484,7 +484,9 @@ sub deleteAttachedFiles {
|
|||
my $form = $self->_createForm($fieldConfig->{$field}, $entryData->{$field});
|
||||
if ($form->can('getStorageLocation')) {
|
||||
my $storage = $form->getStorageLocation;
|
||||
$storage->delete;
|
||||
if ($storage) {
|
||||
$storage->delete;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -364,9 +364,9 @@ sub purge {
|
|||
my $db = $self->session->db;
|
||||
|
||||
# delete registrations
|
||||
my $deleteTicket = $db->prepare("delete from EMSRegistrantTicket=?");
|
||||
my $deleteToken = $db->prepare("delete from EMSRegistrantToken=?");
|
||||
my $deleteRibbon = $db->prepare("delete from EMSRegistrantRibbon=?");
|
||||
my $deleteTicket = $db->prepare("delete from EMSRegistrantTicket where badgeId=?");
|
||||
my $deleteToken = $db->prepare("delete from EMSRegistrantToken where badgeId=?");
|
||||
my $deleteRibbon = $db->prepare("delete from EMSRegistrantRibbon where badgeId=?");
|
||||
my $sth = $db->read("select badgeId from EMSRegistrant where emsAssetId=?",[$self->getId]);
|
||||
while (my ($id) = $sth->array) {
|
||||
$deleteTicket->execute([$id]);
|
||||
|
|
|
|||
|
|
@ -235,6 +235,7 @@ sub view {
|
|||
url => $child->getUrl,
|
||||
title => $child->get("title"),
|
||||
menuTitle => $child->get("menuTitle"),
|
||||
synopsis => $child->get("synopsis") || '',
|
||||
canView => $child->canView(),
|
||||
"icon.small" => $child->getIcon(1),
|
||||
"icon.big" => $child->getIcon,
|
||||
|
|
|
|||
|
|
@ -1349,11 +1349,13 @@ sub www_search {
|
|||
|
||||
if ( $doSearch ) {
|
||||
# Keywords to search on
|
||||
my $keywords = join " ", $form->get('basicSearch'),
|
||||
$form->get('keywords'),
|
||||
$form->get('title'),
|
||||
$form->get('description')
|
||||
;
|
||||
# Do not add a space to the
|
||||
my $keywords;
|
||||
FORMVAR: foreach my $formVar (qw/ basicSearch keywords title description /) {
|
||||
my $var = $form->get($formVar);
|
||||
next FORMVAR unless $var;
|
||||
$keywords = join ' ', $keywords, $var;
|
||||
}
|
||||
|
||||
# Build a where clause from the advanced options
|
||||
# Lineage search can capture gallery
|
||||
|
|
@ -1374,6 +1376,16 @@ sub www_search {
|
|||
;
|
||||
}
|
||||
|
||||
my $dateAfter = $form->get("creationDate_after", "dateTime");
|
||||
my $dateBefore = $form->get("creationDate_before", "dateTime");
|
||||
my $creationDate = {};
|
||||
if ($dateAfter) {
|
||||
$creationDate->{start} = $dateAfter;
|
||||
}
|
||||
if ($dateBefore) {
|
||||
$creationDate->{end } = $dateBefore;
|
||||
}
|
||||
|
||||
# Classes
|
||||
my $joinClass = [
|
||||
'WebGUI::Asset::Wobject::GalleryAlbum',
|
||||
|
|
@ -1407,6 +1419,7 @@ sub www_search {
|
|||
keywords => $keywords,
|
||||
where => $where,
|
||||
joinClass => $joinClass,
|
||||
creationDate => $creationDate,
|
||||
} );
|
||||
|
||||
$var->{ keywords } = $keywords;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ sub definition {
|
|||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my $i18n = __PACKAGE__->i18n($session);
|
||||
my $i18n = WebGUI::International->new($session, 'Asset_GalleryAlbum');
|
||||
|
||||
tie my %properties, 'Tie::IxHash', (
|
||||
allowComments => {
|
||||
|
|
@ -352,27 +352,6 @@ sub DESTROY {
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 i18n ( session )
|
||||
|
||||
Get a WebGUI::International object for this class.
|
||||
|
||||
Can be called as a class method, in which case a WebGUI::Session object
|
||||
must be passed in.
|
||||
|
||||
NOTE: This method can NOT be inherited, due to a current limitation
|
||||
in the i18n system. You must ALWAYS call this with C<__PACKAGE__>
|
||||
|
||||
=cut
|
||||
|
||||
sub i18n {
|
||||
my $self = shift;
|
||||
my $session = shift;
|
||||
|
||||
return WebGUI::International->new($session, "Asset_GalleryAlbum");
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getAutoCommitWorkflowId ( )
|
||||
|
||||
Returns the workflowId of the Gallery's approval workflow.
|
||||
|
|
@ -773,6 +752,20 @@ sub sendChunkedContent {
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 update ( )
|
||||
|
||||
Override update to force isHidden=1 on all albums.
|
||||
|
||||
=cut
|
||||
|
||||
sub update {
|
||||
my $self = shift;
|
||||
my $properties = shift;
|
||||
return $self->SUPER::update({ %{ $properties }, isHidden=>1 });
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 view ( )
|
||||
|
||||
method called by the www_view method. Returns a processed template
|
||||
|
|
@ -937,7 +930,7 @@ sub www_addArchiveSave {
|
|||
|
||||
my $session = $self->session;
|
||||
my $form = $self->session->form;
|
||||
my $i18n = __PACKAGE__->i18n( $session );
|
||||
my $i18n = WebGUI::International->new( $session, 'Asset_GalleryAlbum' );
|
||||
my $properties = {
|
||||
keywords => $form->get("keywords"),
|
||||
friendsOnly => $form->get("friendsOnly"),
|
||||
|
|
@ -1093,7 +1086,7 @@ sub www_deleteConfirm {
|
|||
return $self->session->privilege->insufficient unless $self->canEdit;
|
||||
|
||||
my $gallery = $self->getParent;
|
||||
my $i18n = __PACKAGE__->i18n( $self->session );
|
||||
my $i18n = WebGUI::International->new( $self->session, 'Asset_GalleryAlbum' );
|
||||
|
||||
$self->purge;
|
||||
|
||||
|
|
@ -1119,7 +1112,7 @@ sub www_edit {
|
|||
my $session = $self->session;
|
||||
my $form = $self->session->form;
|
||||
my $var = $self->getTemplateVars;
|
||||
my $i18n = __PACKAGE__->i18n($session);
|
||||
my $i18n = WebGUI::International->new($session, 'Asset_GalleryAlbum');
|
||||
|
||||
return $session->privilege->insufficient unless $self->canEdit;
|
||||
|
||||
|
|
@ -1299,7 +1292,7 @@ Provides links to view the album.
|
|||
|
||||
sub www_showConfirmation {
|
||||
my $self = shift;
|
||||
my $i18n = __PACKAGE__->i18n( $self->session );
|
||||
my $i18n = WebGUI::International->new( $self->session, 'Asset_GalleryAlbum' );
|
||||
|
||||
my $output = '<p>' . sprintf( $i18n->get('save message'), $self->getUrl ) . '</p>'
|
||||
. '<p>' . $i18n->get('what next') . '</p>'
|
||||
|
|
|
|||
|
|
@ -550,22 +550,20 @@ sub view {
|
|||
foreach my $category (keys %{$self->getCategories}) {
|
||||
my $data;
|
||||
my $sql = "
|
||||
select
|
||||
select
|
||||
assetData.title as productName,
|
||||
assetData.url,
|
||||
listing.assetId,
|
||||
rating.meanValue,
|
||||
rating.medianValue,
|
||||
rating.countValue
|
||||
from MatrixListing as listing
|
||||
left join asset on listing.assetId = asset.assetId
|
||||
left join MatrixListing_ratingSummary as rating on rating.listingId = listing.assetId
|
||||
left join assetData on assetData.assetId = listing.assetId and listing.revisionDate =
|
||||
assetData.revisionDate
|
||||
where
|
||||
asset.parentId=?
|
||||
and asset.state='published'
|
||||
and asset.className='WebGUI::Asset::MatrixListing'
|
||||
rating.listingId,
|
||||
rating.meanValue,
|
||||
asset.parentId
|
||||
from
|
||||
MatrixListing_ratingSummary as rating
|
||||
left join asset on (rating.listingId = asset.assetId)
|
||||
left join assetData on assetData.assetId = rating.listingId
|
||||
where
|
||||
rating.category =?
|
||||
and asset.parentId=?
|
||||
and asset.state='published'
|
||||
and assetData.revisionDate=(
|
||||
select
|
||||
max(revisionDate)
|
||||
|
|
@ -575,13 +573,11 @@ assetData.revisionDate
|
|||
assetData.assetId=asset.assetId
|
||||
and (status='approved' or status='archived')
|
||||
)
|
||||
and status='approved'
|
||||
and rating.category=?
|
||||
group by
|
||||
assetData.assetId
|
||||
order by rating.meanValue ";
|
||||
|
||||
$data = $db->quickHashRef($sql." desc limit 1",[$self->getId,$category]);
|
||||
$data = $db->quickHashRef($sql." desc limit 1",[$category,$self->getId]);
|
||||
push(@{ $var->{best_rating_loop} },{
|
||||
url=>'/'.$data->{url},
|
||||
category=>$category,
|
||||
|
|
@ -590,7 +586,7 @@ assetData.revisionDate
|
|||
median=>$data->{medianValue},
|
||||
count=>$data->{countValue}
|
||||
});
|
||||
$data = $db->quickHashRef($sql." asc limit 1",[$self->getId,$category]);
|
||||
$data = $db->quickHashRef($sql." asc limit 1",[$category,$self->getId]);
|
||||
push(@{ $var->{worst_rating_loop} },{
|
||||
url=>'/'.$data->{url},
|
||||
category=>$category,
|
||||
|
|
|
|||
|
|
@ -22,6 +22,11 @@ use POSIX qw(ceil floor);
|
|||
use base 'WebGUI::Asset::Wobject';
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _addDaysForMonth
|
||||
|
||||
=cut
|
||||
|
||||
sub _addDaysForMonth {
|
||||
my $self = shift;
|
||||
my $dt = $self->session->datetime;
|
||||
|
|
@ -53,6 +58,11 @@ sub _addDaysForMonth {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _clobberImproperDependants
|
||||
|
||||
=cut
|
||||
|
||||
sub _clobberImproperDependants {
|
||||
my $self = shift;
|
||||
my $projectId = shift;
|
||||
|
|
@ -62,6 +72,11 @@ sub _clobberImproperDependants {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _doGanttTaskResourceDisplay
|
||||
|
||||
=cut
|
||||
|
||||
sub _doGanttTaskResourceDisplay {
|
||||
my $self = shift;
|
||||
my $hash = shift;
|
||||
|
|
@ -96,6 +111,11 @@ sub _doGanttTaskResourceDisplay {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _getDurationUnitHash
|
||||
|
||||
=cut
|
||||
|
||||
sub _getDurationUnitHash {
|
||||
my $self = shift;
|
||||
my ($session,$privilege,$form,$db,$dt,$i18n,$user) = $self->setSessionVars;
|
||||
|
|
@ -107,6 +127,11 @@ sub _getDurationUnitHash {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _getDurationUnitHashAbbrev
|
||||
|
||||
=cut
|
||||
|
||||
sub _getDurationUnitHashAbbrev {
|
||||
my $self = shift;
|
||||
my ($session,$privilege,$form,$db,$dt,$i18n,$user) = $self->setSessionVars;
|
||||
|
|
@ -118,6 +143,11 @@ sub _getDurationUnitHashAbbrev {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _groupSearchQuery
|
||||
|
||||
=cut
|
||||
|
||||
sub _groupSearchQuery {
|
||||
my $self = shift;
|
||||
my $exclude = shift;
|
||||
|
|
@ -136,6 +166,11 @@ SQL
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _htmlOfResourceList
|
||||
|
||||
=cut
|
||||
|
||||
sub _htmlOfResourceList {
|
||||
my $self = shift;
|
||||
my %args = %{+shift};
|
||||
|
|
@ -188,6 +223,11 @@ sub _htmlOfResourceList {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _innerHtmlOfResources
|
||||
|
||||
=cut
|
||||
|
||||
sub _innerHtmlOfResources {
|
||||
my $self = shift;
|
||||
my @resources = @_;
|
||||
|
|
@ -196,6 +236,11 @@ sub _innerHtmlOfResources {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _resourceListOfTask
|
||||
|
||||
=cut
|
||||
|
||||
sub _resourceListOfTask {
|
||||
my $self = shift;
|
||||
my $taskId = shift;
|
||||
|
|
@ -219,6 +264,11 @@ sub _resourceListOfTask {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _resourceSearchPopup
|
||||
|
||||
=cut
|
||||
|
||||
sub _resourceSearchPopup {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
|
@ -260,6 +310,11 @@ sub _resourceSearchPopup {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _userSearchQuery
|
||||
|
||||
=cut
|
||||
|
||||
sub _userSearchQuery {
|
||||
my $self = shift;
|
||||
my $exclude = shift;
|
||||
|
|
@ -280,6 +335,11 @@ SQL
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _updateDependantDates
|
||||
|
||||
=cut
|
||||
|
||||
sub _updateDependantDates {
|
||||
my $self = shift;
|
||||
my $db = $self->session->db;
|
||||
|
|
@ -335,6 +395,11 @@ sub _updateDependantDates {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _userCanManageProject
|
||||
|
||||
=cut
|
||||
|
||||
sub _userCanManageProject {
|
||||
my $self = shift;
|
||||
my $user = shift;
|
||||
|
|
@ -344,6 +409,11 @@ sub _userCanManageProject {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _userCanManageProjectList
|
||||
|
||||
=cut
|
||||
|
||||
sub _userCanManageProjectList {
|
||||
my $self = shift;
|
||||
my $user = shift;
|
||||
|
|
@ -351,6 +421,11 @@ sub _userCanManageProjectList {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _userCanObserveProject
|
||||
|
||||
=cut
|
||||
|
||||
sub _userCanObserveProject {
|
||||
my $self = shift;
|
||||
my $user = shift;
|
||||
|
|
@ -360,6 +435,11 @@ sub _userCanObserveProject {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
|
|
@ -439,6 +519,11 @@ sub definition {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
#API method called by Time Tracker to return the instance of the PM wobject which this project blongs
|
||||
|
||||
=head2 getProjectInstance
|
||||
|
||||
=cut
|
||||
|
||||
sub getProjectInstance {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
|
|
@ -454,6 +539,11 @@ sub getProjectInstance {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
#API method called by Time Tracker to return all projects in all assets for which the user passed in has tasks assigned
|
||||
|
||||
=head2 getProjectList
|
||||
|
||||
=cut
|
||||
|
||||
sub getProjectList {
|
||||
my $self = shift;
|
||||
my $db = $self->session->db;
|
||||
|
|
@ -474,6 +564,11 @@ SQL
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
#API method called by Time Tracker to return all tasks for the projectId passed in
|
||||
|
||||
=head2 getTaskList
|
||||
|
||||
=cut
|
||||
|
||||
sub getTaskList {
|
||||
my $self = shift;
|
||||
my $db = $self->session->db;
|
||||
|
|
@ -494,6 +589,11 @@ SQL
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 i18n
|
||||
|
||||
=cut
|
||||
|
||||
sub i18n {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
|
|
@ -507,6 +607,11 @@ sub i18n {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 prepareView
|
||||
|
||||
=cut
|
||||
|
||||
sub prepareView {
|
||||
my $self = shift;
|
||||
$self->SUPER::prepareView();
|
||||
|
|
@ -516,6 +621,11 @@ sub prepareView {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 processErrors
|
||||
|
||||
=cut
|
||||
|
||||
sub processErrors {
|
||||
my $self = shift;
|
||||
my $errors = "";
|
||||
|
|
@ -531,6 +641,11 @@ sub processErrors {
|
|||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 purge
|
||||
|
||||
=cut
|
||||
|
||||
sub purge {
|
||||
my $self = shift;
|
||||
#purge your wobject-specific data here. This does not include fields
|
||||
|
|
@ -539,6 +654,11 @@ sub purge {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 setSessionVars
|
||||
|
||||
=cut
|
||||
|
||||
sub setSessionVars {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
|
|
@ -556,6 +676,11 @@ sub setSessionVars {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
# API method called by Time Tracker to set percent complete field in the task and update the project cache
|
||||
|
||||
=head2 updateProjectTask
|
||||
|
||||
=cut
|
||||
|
||||
sub updateProjectTask {
|
||||
my $self = shift;
|
||||
my $db = $self->session->db;
|
||||
|
|
@ -594,6 +719,11 @@ sub updateProjectTask {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 updateProject
|
||||
|
||||
=cut
|
||||
|
||||
sub updateProject {
|
||||
my $self = shift;
|
||||
my ($session,$privilege,$form,$db,$dt,$i18n,$user) = $self->setSessionVars;
|
||||
|
|
@ -614,6 +744,11 @@ sub updateProject {
|
|||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 view
|
||||
|
||||
=cut
|
||||
|
||||
sub view {
|
||||
my $self = shift;
|
||||
my $var = $self->get;
|
||||
|
|
@ -681,6 +816,11 @@ sub view {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_deleteProject
|
||||
|
||||
=cut
|
||||
|
||||
sub www_deleteProject {
|
||||
my $self = shift;
|
||||
#Set Method Helpers
|
||||
|
|
@ -700,6 +840,11 @@ sub www_deleteProject {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_deleteTask
|
||||
|
||||
=cut
|
||||
|
||||
sub www_deleteTask {
|
||||
my $self = shift;
|
||||
#Set Method Helpers
|
||||
|
|
@ -743,6 +888,11 @@ sub www_deleteTask {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_drawGanttChart
|
||||
|
||||
=cut
|
||||
|
||||
sub www_drawGanttChart {
|
||||
my $self = shift;
|
||||
my $var = {};
|
||||
|
|
@ -988,6 +1138,11 @@ sub www_drawGanttChart {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editProject
|
||||
|
||||
=cut
|
||||
|
||||
sub www_editProject {
|
||||
my $self = shift;
|
||||
#Set Method Helpers
|
||||
|
|
@ -1101,6 +1256,11 @@ sub www_editProject {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editProjectSave
|
||||
|
||||
=cut
|
||||
|
||||
sub www_editProjectSave {
|
||||
my $self = shift;
|
||||
#Set Method Helpers
|
||||
|
|
@ -1166,6 +1326,11 @@ sub www_editProjectSave {
|
|||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editTask
|
||||
|
||||
=cut
|
||||
|
||||
sub www_editTask {
|
||||
my $self = shift;
|
||||
my $var = {};
|
||||
|
|
@ -1362,6 +1527,11 @@ sub www_editTask {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editTaskSave
|
||||
|
||||
=cut
|
||||
|
||||
sub www_editTaskSave {
|
||||
my $self = shift;
|
||||
my $var = {};
|
||||
|
|
@ -1452,6 +1622,11 @@ sub www_editTaskSave {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_groupSearchPopup
|
||||
|
||||
=cut
|
||||
|
||||
sub www_groupSearchPopup {
|
||||
my $self = shift;
|
||||
my %args = (func => 'groupSearchPopup',
|
||||
|
|
@ -1462,6 +1637,11 @@ sub www_groupSearchPopup {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_innerHtmlOfResources
|
||||
|
||||
=cut
|
||||
|
||||
sub www_innerHtmlOfResources {
|
||||
my $self = shift;
|
||||
my @resources = map {
|
||||
|
|
@ -1472,6 +1652,11 @@ sub www_innerHtmlOfResources {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_saveExistingTasks
|
||||
|
||||
=cut
|
||||
|
||||
sub www_saveExistingTasks {
|
||||
my $self = shift;
|
||||
my $var = {};
|
||||
|
|
@ -1515,6 +1700,11 @@ sub www_saveExistingTasks {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_userSearchPopup
|
||||
|
||||
=cut
|
||||
|
||||
sub www_userSearchPopup {
|
||||
my $self = shift;
|
||||
|
||||
|
|
@ -1526,6 +1716,11 @@ sub www_userSearchPopup {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_viewProject
|
||||
|
||||
=cut
|
||||
|
||||
sub www_viewProject {
|
||||
my $self = shift;
|
||||
my $var = {};
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ use Tie::IxHash;
|
|||
use JSON;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Form::File;
|
||||
use WebGUI::Utility;
|
||||
use base 'WebGUI::Asset::Wobject';
|
||||
use WebGUI::Asset::Wobject::Survey::SurveyJSON;
|
||||
use WebGUI::Asset::Wobject::Survey::ResponseJSON;
|
||||
|
|
@ -22,6 +23,17 @@ use WebGUI::Asset::Wobject::Survey::ResponseJSON;
|
|||
use Data::Dumper;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( session, [definition] )
|
||||
|
||||
Returns an array reference of definitions. Adds tableName, className, properties to array definition.
|
||||
|
||||
=head3 definition
|
||||
|
||||
An array of hashes to prepend to the list
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
|
|
@ -31,31 +43,33 @@ sub definition {
|
|||
tie %properties, 'Tie::IxHash';
|
||||
%properties = (
|
||||
templateId => {
|
||||
fieldType => "template",
|
||||
fieldType => 'template',
|
||||
defaultValue => 'PBtmpl0000000000000061',
|
||||
tab => "display",
|
||||
namespace => "Survey",
|
||||
hoverHelp => "A Survey System",
|
||||
label => "Template ID"
|
||||
tab => 'display',
|
||||
namespace => 'Survey',
|
||||
label => $i18n->get('survey template'),
|
||||
hoverHelp => $i18n->get('survey template help'),
|
||||
},
|
||||
showProgress => {
|
||||
fieldType => "yesNo",
|
||||
fieldType => 'yesNo',
|
||||
defaultValue => 0,
|
||||
tab => 'properties',
|
||||
label => "Show user their progress"
|
||||
label => $i18n->get('Show user their progress'),
|
||||
hoverHelp => $i18n->get('Show user their progress help'),
|
||||
},
|
||||
showTimeLimit => {
|
||||
fieldType => "yesNo",
|
||||
fieldType => 'yesNo',
|
||||
defaultValue => 0,
|
||||
tab => 'properties',
|
||||
label => "Show user their time remaining"
|
||||
label => $i18n->get('Show user their time remaining'),
|
||||
hoverHelp => $i18n->get('Show user their time remaining'),
|
||||
},
|
||||
timeLimit => {
|
||||
fieldType => 'integer',
|
||||
defaultValue => 0,
|
||||
tab => 'properties',
|
||||
label => $i18n->get('timelimit'),
|
||||
hoverHelp => $i18n->get('timelimit hoverHelp'),
|
||||
label => $i18n->get('timelimit')
|
||||
},
|
||||
doAfterTimeLimit => {
|
||||
fieldType => 'selectBox',
|
||||
|
|
@ -71,90 +85,92 @@ sub definition {
|
|||
groupToEditSurvey => {
|
||||
fieldType => 'group',
|
||||
defaultValue => 4,
|
||||
label => "Group to edit survey",
|
||||
label => $i18n->get('Group to edit survey'),
|
||||
hoverHelp => $i18n->get('Group to edit survey help'),
|
||||
},
|
||||
groupToTakeSurvey => {
|
||||
fieldType => 'group',
|
||||
defaultValue => 2,
|
||||
label => "Group to take survey",
|
||||
label => $i18n->get('Group to take survey'),
|
||||
hoverHelp => $i18n->get('Group to take survey help'),
|
||||
},
|
||||
groupToViewReports => {
|
||||
fieldType => 'group',
|
||||
defaultValue => 4,
|
||||
label => "Group to view reports",
|
||||
label => $i18n->get('Group to view reports'),
|
||||
hoverHelp => $i18n->get('Group to view reports help'),
|
||||
},
|
||||
exitURL => {
|
||||
fieldType => 'text',
|
||||
defaultValue => undef,
|
||||
label => "Set the URL that the survey will exit to",
|
||||
hoverHelp =>
|
||||
"When the user finishes the survey, they will be sent to this URL. Leave blank if no forwarding required.",
|
||||
label => $i18n->get('Survey Exit URL'),
|
||||
hoverHelp => $i18n->get('Survey Exit URL help'),
|
||||
},
|
||||
maxResponsesPerUser => {
|
||||
fieldType => 'integer',
|
||||
defaultValue => 1,
|
||||
label => "Max user reponses",
|
||||
label => 'Max user reponses',
|
||||
},
|
||||
overviewTemplateId => {
|
||||
tab => 'display',
|
||||
fieldType => 'template',
|
||||
defaultValue => 'PBtmpl0000000000000063',
|
||||
label => "Overview template id",
|
||||
label => 'Overview template id',
|
||||
namespace => 'Survey/Overview',
|
||||
},
|
||||
gradebookTemplateId => {
|
||||
tab => 'display',
|
||||
fieldType => 'template',
|
||||
label => "Grabebook template id",
|
||||
label => 'Grabebook template id',
|
||||
defaultValue => 'PBtmpl0000000000000062',
|
||||
namespace => 'Survey/Gradebook',
|
||||
},
|
||||
responseTemplateId => {
|
||||
tab => 'display',
|
||||
fieldType => 'template',
|
||||
label => "Response template id",
|
||||
label => 'Response template id',
|
||||
defaultValue => 'PBtmpl0000000000000064',
|
||||
namespace => 'Survey/Response',
|
||||
},
|
||||
surveyEditTemplateId => {
|
||||
tab => 'display',
|
||||
fieldType => 'template',
|
||||
label => "Survey edit template id",
|
||||
label => 'Survey edit template id',
|
||||
defaultValue => 'GRUNFctldUgop-qRLuo_DA',
|
||||
namespace => 'Survey/Edit',
|
||||
},
|
||||
surveyTakeTemplateId => {
|
||||
tab => 'display',
|
||||
fieldType => 'template',
|
||||
label => "Take survey template id",
|
||||
label => 'Take survey template id',
|
||||
defaultValue => 'd8jMMMRddSQ7twP4l1ZSIw',
|
||||
namespace => 'Survey/Take',
|
||||
},
|
||||
surveyQuestionsId => {
|
||||
tab => 'display',
|
||||
fieldType => 'template',
|
||||
label => "Questions template id",
|
||||
label => 'Questions template id',
|
||||
defaultValue => 'CxMpE_UPauZA3p8jdrOABw',
|
||||
namespace => 'Survey/Take',
|
||||
},
|
||||
sectionEditTemplateId => {
|
||||
tab => 'display',
|
||||
fieldType => 'template',
|
||||
label => "Section Edit Tempalte",
|
||||
label => 'Section Edit Tempalte',
|
||||
defaultValue => '1oBRscNIcFOI-pETrCOspA',
|
||||
namespace => 'Survey/Edit',
|
||||
},
|
||||
questionEditTemplateId => {
|
||||
tab => 'display',
|
||||
fieldType => 'template',
|
||||
label => "Question Edit Tempalte",
|
||||
label => 'Question Edit Tempalte',
|
||||
defaultValue => 'wAc4azJViVTpo-2NYOXWvg',
|
||||
namespace => 'Survey/Edit',
|
||||
},
|
||||
answerEditTemplateId => {
|
||||
tab => 'display',
|
||||
fieldType => 'template',
|
||||
label => "Answer Edit Tempalte",
|
||||
label => 'Answer Edit Tempalte',
|
||||
defaultValue => 'AjhlNO3wZvN5k4i4qioWcg',
|
||||
namespace => 'Survey/Edit',
|
||||
},
|
||||
|
|
@ -248,7 +264,6 @@ Saves the survey collateral to the DB
|
|||
|
||||
=cut
|
||||
|
||||
sub survey { return shift->{survey}; }
|
||||
|
||||
sub saveSurveyJSON {
|
||||
my $self = shift;
|
||||
|
|
@ -260,6 +275,19 @@ sub saveSurveyJSON {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 survey ( )
|
||||
|
||||
Helper to access the survey object.
|
||||
|
||||
=cut
|
||||
|
||||
sub survey { return shift->{survey}; }
|
||||
sub littleBuddy { return shift->{survey}; }
|
||||
sub allyourbases { return shift->{survey}; }
|
||||
sub helpmehelpme { return shift->{survey}; }
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editSurvey ( )
|
||||
|
||||
Loads the initial edit survey page. All other edit actions are JSON calls from this page.
|
||||
|
|
@ -279,6 +307,14 @@ sub www_editSurvey {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_submitObjectEdit ( )
|
||||
|
||||
This is called when an edit is submitted to a survey object. The POST should contain the id and updated params
|
||||
of the object, and also if the object is being deleted or copied.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_submitObjectEdit {
|
||||
my $self = shift;
|
||||
|
||||
|
|
@ -355,6 +391,15 @@ sub www_jumpTo {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 copyObject ( )
|
||||
|
||||
Takes the address of a survey object and creates a copy. The copy is placed at the end of this object's parent's list.
|
||||
|
||||
Returns the address to the new object.
|
||||
|
||||
=cut
|
||||
|
||||
sub copyObject {
|
||||
my ( $self, $address ) = @_;
|
||||
|
||||
|
|
@ -371,13 +416,28 @@ sub copyObject {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 deleteObject( $address )
|
||||
|
||||
Deletes the object matching the passed in address.
|
||||
|
||||
Returns the address to the parent object, or the very first section.
|
||||
|
||||
=head3 $address
|
||||
|
||||
An array ref. The first element of the array ref is the index of
|
||||
the section. The second element is the index of the question in
|
||||
that section. The third element is the index of the answer.
|
||||
|
||||
=cut
|
||||
|
||||
sub deleteObject {
|
||||
my ( $self, $address ) = @_;
|
||||
|
||||
$self->loadSurveyJSON();
|
||||
|
||||
my $message = $self->survey->remove($address)
|
||||
; #each object checks the ref and then either updates or passes it to the correct child. New objects will have an index of -1.
|
||||
#each object checks the ref and then either updates or passes it to the correct child. New objects will have an index of -1.
|
||||
my $message = $self->survey->remove($address);
|
||||
|
||||
$self->saveSurveyJSON();
|
||||
|
||||
|
|
@ -393,6 +453,13 @@ sub deleteObject {
|
|||
} ## end sub deleteObject
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_newObject()
|
||||
|
||||
Creates a new object from a POST param containing the new objects id concat'd on hyphens.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_newObject {
|
||||
my $self = shift;
|
||||
|
||||
|
|
@ -417,6 +484,13 @@ sub www_newObject {
|
|||
} ## end sub www_newObject
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_dragDrop
|
||||
|
||||
Takes two ids from a form POST. The "target" is the object being moved, the "before" is the object directly preceding the "target".
|
||||
|
||||
=cut
|
||||
|
||||
sub www_dragDrop {
|
||||
my $self = shift;
|
||||
|
||||
|
|
@ -483,6 +557,18 @@ sub www_dragDrop {
|
|||
} ## end sub www_dragDrop
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_loadSurvey([options])
|
||||
|
||||
For loading the survey during editing. Returns the survey meta list and the html data for editing a particular survey object.
|
||||
|
||||
=head3 options
|
||||
|
||||
Can either be a hashref containing the address to be edited. And/or a the specific variables to be edited.
|
||||
If undef, the address is pulled form the form POST.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_loadSurvey {
|
||||
my ( $self, $options ) = @_;
|
||||
my $editflag = 1;
|
||||
|
|
@ -503,7 +589,6 @@ sub www_loadSurvey {
|
|||
$address = [0];
|
||||
}
|
||||
}
|
||||
my $message = defined $options->{message} ? $options->{message} : '';
|
||||
my $var
|
||||
= defined $options->{var}
|
||||
? $options->{var}
|
||||
|
|
@ -605,6 +690,12 @@ sub prepareView {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 purge
|
||||
|
||||
Completely remove from WebGUI.
|
||||
|
||||
=cut
|
||||
|
||||
sub purge {
|
||||
my $self = shift;
|
||||
$self->session->db->write( "delete from Survey_response where assetId = ?", [ $self->getId() ] );
|
||||
|
|
@ -628,7 +719,6 @@ sub purgeCache {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
sub purgeRevision {
|
||||
my $self = shift;
|
||||
return $self->SUPER::purgeRevision;
|
||||
|
|
@ -644,9 +734,30 @@ returns the output.
|
|||
=cut
|
||||
|
||||
sub view {
|
||||
my $self = shift;
|
||||
my $var = $self->getMenuVars;
|
||||
|
||||
my ( $code, $overTakeLimit ) = $self->getResponseInfoForView();
|
||||
$var->{'lastResponseCompleted'} = $code;
|
||||
$var->{'lastResponseTimedOut'} = $code > 1 ? 1 : 0;
|
||||
$var->{'maxResponsesSubmitted'} = $overTakeLimit;
|
||||
my $out = $self->processTemplate( $var, undef, $self->{_viewTemplate} );
|
||||
|
||||
return $out;
|
||||
} ## end sub view
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getMenuVars ( )
|
||||
|
||||
Returns the top menu template variables as a hashref.
|
||||
|
||||
=cut
|
||||
|
||||
sub getMenuVars {
|
||||
my $self = shift;
|
||||
my %var;
|
||||
|
||||
|
||||
$var{'edit_survey_url'} = $self->getUrl('func=editSurvey');
|
||||
$var{'take_survey_url'} = $self->getUrl('func=takeSurvey');
|
||||
$var{'view_simple_results_url'} = $self->getUrl('func=exportSimpleResults');
|
||||
|
|
@ -656,15 +767,9 @@ sub view {
|
|||
$var{'user_canTakeSurvey'} = $self->session->user->isInGroup( $self->get("groupToTakeSurvey") );
|
||||
$var{'user_canViewReports'} = $self->session->user->isInGroup( $self->get("groupToViewReports") );
|
||||
$var{'user_canEditSurvey'} = $self->session->user->isInGroup( $self->get("groupToEditSurvey") );
|
||||
$var{'user_canEditSurvey'} = $self->session->user->isInGroup( $self->get("groupToEditSurvey") );
|
||||
my ( $code, $overTakeLimit ) = $self->getResponseInfoForView();
|
||||
$var{'lastResponseCompleted'} = $code;
|
||||
$var{'lastResponseTimedOut'} = $code > 1 ? 1 : 0;
|
||||
$var{'maxResponsesSubmitted'} = $overTakeLimit;
|
||||
my $out = $self->processTemplate( \%var, undef, $self->{_viewTemplate} );
|
||||
|
||||
return $out;
|
||||
} ## end sub view
|
||||
return \%var;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -747,6 +852,12 @@ sub www_view {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_takeSurvey
|
||||
|
||||
Returns the template needed to take the survey. This template dynamically loads the survey via async requests.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_takeSurvey {
|
||||
my $self = shift;
|
||||
my %var;
|
||||
|
|
@ -763,11 +874,37 @@ sub www_takeSurvey {
|
|||
}
|
||||
};
|
||||
|
||||
$self->session->style->setScript($self->session->url->extras('yui/build/utilities/utilities.js'), {type =>
|
||||
'text/javascript'});
|
||||
$self->session->style->setScript($self->session->url->extras('yui/build/container/container-min.js'), {type =>
|
||||
'text/javascript'});
|
||||
$self->session->style->setScript($self->session->url->extras('yui/build/menu/menu-min.js'), {type =>
|
||||
'text/javascript'});
|
||||
$self->session->style->setScript($self->session->url->extras('yui/build/button/button-min.js'), {type =>
|
||||
'text/javascript'});
|
||||
$self->session->style->setScript($self->session->url->extras('yui/build/calendar/calendar-min.js'), {type =>
|
||||
'text/javascript'});
|
||||
$self->session->style->setScript($self->session->url->extras('yui/build/json/json-min.js'), {type =>
|
||||
'text/javascript'});
|
||||
$self->session->style->setScript($self->session->url->extras('yui/build/logger/logger-min.js'), {type =>
|
||||
'text/javascript'});
|
||||
$self->session->style->setScript($self->session->url->extras('yui/build/resize/resize-min.js'), {type =>
|
||||
'text/javascript'});
|
||||
$self->session->style->setScript($self->session->url->extras('yui/build/slider/slider-min.js'), {type =>
|
||||
'text/javascript'});
|
||||
|
||||
my $out = $self->processTemplate( \%var, $self->get("surveyTakeTemplateId") );
|
||||
return $self->session->style->process( $out, $self->get("styleTemplateId") );
|
||||
} ## end sub www_takeSurvey
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_deleteResponses
|
||||
|
||||
Deletes all the responses from the survey.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_deleteResponses {
|
||||
my $self = shift;
|
||||
|
||||
|
|
@ -779,8 +916,14 @@ sub www_deleteResponses {
|
|||
return;
|
||||
}
|
||||
|
||||
#handles questions that were submitted
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_submitQuestions
|
||||
|
||||
Handles questions submitted by the survey taker, adding them to their response.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_submitQuestions {
|
||||
my $self = shift;
|
||||
|
||||
|
|
@ -845,8 +988,14 @@ sub www_submitQuestions {
|
|||
return $self->www_loadQuestions($responseId);
|
||||
} ## end sub www_submitQuestions
|
||||
|
||||
#finds the questions to display next and builds the data structre to hold them
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_loadQuestions
|
||||
|
||||
Determines which questions to display to the survey taker next, loads and returns them.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_loadQuestions {
|
||||
my $self = shift;
|
||||
my $wasRestarted = shift;
|
||||
|
|
@ -941,12 +1090,21 @@ sub surveyEnd {
|
|||
}
|
||||
}
|
||||
}
|
||||
# $self->session->http->setRedirect($url);
|
||||
return to_json( { "type", "forward", "url", $url } );
|
||||
$url = $self->session->url->gateway($url);
|
||||
#$self->session->http->setRedirect($url);
|
||||
#$self->session->http->setMimeType('application/json');
|
||||
my $json = to_json( { "type", "forward", "url", $url } );
|
||||
return $json;
|
||||
} ## end sub surveyEnd
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
#sends the processed template and questions structure to the client
|
||||
|
||||
=head2 prepareShowSurveyTemplate
|
||||
|
||||
Sends the processed template and questions structure to the client
|
||||
|
||||
=cut
|
||||
|
||||
sub prepareShowSurveyTemplate {
|
||||
my ( $self, $section, $questions ) = @_;
|
||||
my %multipleChoice = (
|
||||
|
|
@ -1011,6 +1169,16 @@ sub prepareShowSurveyTemplate {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 loadBothJSON($rId)
|
||||
|
||||
Loads both the Survey and the appropriate response objects from JSON.
|
||||
|
||||
=head3 $rId
|
||||
|
||||
The reponse id to load.
|
||||
|
||||
=cut
|
||||
|
||||
sub loadBothJSON {
|
||||
my $self = shift;
|
||||
my $rId = shift;
|
||||
|
|
@ -1025,6 +1193,21 @@ sub loadBothJSON {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 loadResponseJSON([$jsonHash],[$rId])
|
||||
|
||||
Loads the response object from JSON.
|
||||
|
||||
=head3 $jsonHash
|
||||
|
||||
Optional, but if the hash has been pulled from the DB before, there is no need to pull it again.
|
||||
|
||||
=head3 $rId
|
||||
|
||||
Optional, but if not passed in, it is grabbed.
|
||||
|
||||
=cut
|
||||
|
||||
sub loadResponseJSON {
|
||||
my $self = shift;
|
||||
my $jsonHash = shift;
|
||||
|
|
@ -1043,16 +1226,31 @@ sub loadResponseJSON {
|
|||
} ## end sub loadResponseJSON
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head3 saveResponseJSON
|
||||
|
||||
Turns the response object into JSON and saves it to the DB.
|
||||
|
||||
=cut
|
||||
|
||||
sub saveResponseJSON {
|
||||
my $self = shift;
|
||||
|
||||
my $data = $self->response->freeze();
|
||||
|
||||
$self->session->db->write( "update Survey_response set responseJSON = ? where Survey_responseId = ?",
|
||||
|
||||
[ $data, $self->{responseId} ] );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 response
|
||||
|
||||
Helper to easily grab the response object and prevent typos.
|
||||
|
||||
=cut
|
||||
|
||||
sub response {
|
||||
my $self = shift;
|
||||
return $self->{response};
|
||||
|
|
@ -1060,6 +1258,13 @@ sub response {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getResponseId
|
||||
|
||||
Determines the response id of the current user. If there is not a response for the user, a new one is created.
|
||||
If the user is anonymous, the IP is used. Or an email'd or linked code can be used.
|
||||
|
||||
=cut
|
||||
|
||||
sub getResponseId {
|
||||
my $self = shift;
|
||||
return $self->{responseId} if ( defined $self->{responseId} );
|
||||
|
|
@ -1148,6 +1353,12 @@ sub getResponseId {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 canTakeSurvey
|
||||
|
||||
Determines if the current user has permissions to take the survey.
|
||||
|
||||
=cut
|
||||
|
||||
sub canTakeSurvey {
|
||||
my $self = shift;
|
||||
|
||||
|
|
@ -1187,24 +1398,144 @@ sub canTakeSurvey {
|
|||
} ## end sub canTakeSurvey
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_viewGradeBook (){
|
||||
|
||||
Returns the Grade Book screen.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_viewGradeBook {
|
||||
my $self = shift;
|
||||
my $self = shift;
|
||||
my $db = $self->session->db;
|
||||
|
||||
return $self->session->privilege->insufficient()
|
||||
unless ( $self->session->user->isInGroup( $self->get("groupToViewReports") ) );
|
||||
|
||||
my $var = $self->getMenuVars;
|
||||
|
||||
$self->loadTempReportTable();
|
||||
|
||||
my $paginator = WebGUI::Paginator->new($self->session,$self->getUrl('func=viewGradebook'));
|
||||
$paginator->setDataByQuery("select userId,username,ipAddress,Survey_responseId,startDate,endDate
|
||||
from Survey_response
|
||||
where assetId=".$db->quote($self->getId)." order by username,ipAddress,startDate");
|
||||
my $users = $paginator->getPageData;
|
||||
|
||||
$self->loadSurveyJSON();
|
||||
$var->{question_count} = $self->survey->questionCount;
|
||||
|
||||
my @responseloop;
|
||||
foreach my $user (@$users) {
|
||||
my ($correctCount) = $db->quickArray("select count(*) from Survey_tempReport
|
||||
where Survey_responseId=? and isCorrect=1",[$user->{Survey_responseId}]);
|
||||
push(@responseloop, {
|
||||
# response_url is left out because it looks like Survey doesn't have a viewIndividualSurvey feature
|
||||
# yet.
|
||||
#'response_url'=>$self->getUrl('func=viewIndividualSurvey;responseId='.$user->{Survey_responseId}),
|
||||
'response_user_name'=>($user->{userId} eq '1') ? $user->{ipAddress} : $user->{username},
|
||||
'response_count_correct' => $correctCount,
|
||||
'response_percent' => round(($correctCount/$var->{question_count})*100)
|
||||
});
|
||||
}
|
||||
$var->{response_loop} = \@responseloop;
|
||||
$paginator->appendTemplateVars($var);
|
||||
|
||||
my $out = $self->processTemplate( $var, $self->get("gradebookTemplateId") );
|
||||
return $self->session->style->process( $out, $self->get("styleTemplateId") );
|
||||
|
||||
} ## end sub www_viewGradeBook
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_viewStatisticalOverview (){
|
||||
|
||||
Returns the Statistical Overview screen.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_viewStatisticalOverview {
|
||||
my $self = shift;
|
||||
my $db = $self->session->db;
|
||||
|
||||
return $self->session->privilege->insufficient()
|
||||
unless ( $self->session->user->isInGroup( $self->get("groupToViewReports") ) );
|
||||
|
||||
$self->loadTempReportTable();
|
||||
$self->loadSurveyJSON();
|
||||
my $survey = $self->survey;
|
||||
my $var = $self->getMenuVars;
|
||||
|
||||
my $paginator = WebGUI::Paginator->new($self->session,$self->getUrl('func=viewStatisticalOverview'));
|
||||
my @questionloop;
|
||||
for ( my $sectionIndex = 0; $sectionIndex <= $#{ $survey->sections() }; $sectionIndex++ ) {
|
||||
for ( my $questionIndex = 0; $questionIndex <= $#{ $survey->questions([$sectionIndex]) }; $questionIndex++ ) {
|
||||
my $question = $survey->question( [ $sectionIndex, $questionIndex ] );
|
||||
my $questionType = $question->{questionType};
|
||||
my (@answerloop, $totalResponses);;
|
||||
|
||||
my @peoples
|
||||
= $self->session->db->quickArray( "SELECT UNIQUE(Survey_responseId) from Survey_tempReport where assetId = ?",
|
||||
[ $self->getId() ] );
|
||||
for my $people (@peoples) {
|
||||
|
||||
#my $
|
||||
if ($questionType eq "Multiple Choice"){
|
||||
$totalResponses = $db->quickScalar("select count(*) from Survey_tempReport
|
||||
where sectionNumber=? and questionNumber=?",[$sectionIndex,$questionIndex]);
|
||||
|
||||
for ( my $answerIndex = 0; $answerIndex <= $#{ $survey->answers([$sectionIndex,$questionIndex]) }; $answerIndex++ ) {
|
||||
my $numResponses = $db->quickScalar("select count(*) from Survey_tempReport
|
||||
where sectionNumber=? and questionNumber=? and answerNumber=?",
|
||||
[$sectionIndex,$questionIndex,$answerIndex]);
|
||||
my $responsePercent;
|
||||
if ($totalResponses) {
|
||||
$responsePercent = round(($numResponses/$totalResponses)*100);
|
||||
} else {
|
||||
$responsePercent = 0;
|
||||
}
|
||||
my @commentloop;
|
||||
my $comments = $db->read("select answerComment from Survey_tempReport
|
||||
where sectionNumber=? and questionNumber=? and answerNumber=?",
|
||||
[$sectionIndex,$questionIndex,$answerIndex]);
|
||||
while (my ($comment) = $comments->array) {
|
||||
push(@commentloop,{
|
||||
'answer_comment'=>$comment
|
||||
});
|
||||
}
|
||||
push(@answerloop,{
|
||||
'answer_isCorrect'=>$survey->answer( [ $sectionIndex, $questionIndex, $answerIndex ] )->{isCorrect},
|
||||
'answer' => $survey->answer( [ $sectionIndex, $questionIndex, $answerIndex ] )->{text},
|
||||
'answer_response_count' =>$numResponses,
|
||||
'answer_response_percent' =>$responsePercent,
|
||||
'comment_loop'=>\@commentloop
|
||||
});
|
||||
}
|
||||
}
|
||||
else{
|
||||
my $responses = $db->read("select value,answerComment from Survey_tempReport
|
||||
where sectionNumber=? and questionNumber=?",
|
||||
[$sectionIndex,$questionIndex]);
|
||||
while (my $response = $responses->hashRef) {
|
||||
push(@answerloop,{
|
||||
'answer_value' =>$response->{value},
|
||||
'answer_comment' =>$response->{answerComment}
|
||||
});
|
||||
}
|
||||
}
|
||||
push(@questionloop,{
|
||||
'question' => $question->{text},
|
||||
'question_id' => $sectionIndex.'_'.$questionIndex,
|
||||
'question_isMultipleChoice' => ($questionType eq "Multiple Choice"),
|
||||
'question_response_total' => $totalResponses,
|
||||
'answer_loop' => \@answerloop,
|
||||
'questionallowComment' => $question->{allowComment}
|
||||
});
|
||||
} ## end for ( my $questionIndex = 0; $questionIndex <= ...
|
||||
}
|
||||
$paginator->setDataByArrayRef(\@questionloop);
|
||||
@questionloop = @{$paginator->getPageData};
|
||||
|
||||
} ## end sub www_viewGradeBook
|
||||
$var->{question_loop} = \@questionloop;
|
||||
$paginator->appendTemplateVars($var);
|
||||
|
||||
my $out = $self->processTemplate( $var, $self->get("overviewTemplateId") );
|
||||
return $self->session->style->process( $out, $self->get("styleTemplateId") );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_exportSimpleResults {
|
||||
|
|
@ -1224,6 +1555,48 @@ sub www_exportSimpleResults {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_exportTransposedResults (){
|
||||
|
||||
Returns transposed results as a tabbed file.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_exportTransposedResults {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient()
|
||||
unless ( $self->session->user->isInGroup( $self->get("groupToViewReports") ) );
|
||||
|
||||
$self->loadTempReportTable();
|
||||
|
||||
my $filename = $self->session->url->escape( $self->get("title") . "_transposedResults.tab" );
|
||||
my $content
|
||||
= $self->session->db->quickTab(
|
||||
"select r.userId, r.username, r.ipAddress, r.startDate, r.endDate, r.isComplete, t.*
|
||||
from Survey_tempReport t
|
||||
left join Survey_response r using(Survey_responseId)
|
||||
where t.assetId=?
|
||||
order by r.userId, r.Survey_responseId, t.order",
|
||||
[ $self->getId() ] );
|
||||
return $self->export( $filename, $content );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 export($filename,$content)
|
||||
|
||||
Exports the data in $content to $filename, then forwards the user to $filename.
|
||||
|
||||
=head3 $filename
|
||||
|
||||
The name of the file you want exported.
|
||||
|
||||
=head3 $content
|
||||
|
||||
The data you want exported (CSV, tab, whatever).
|
||||
|
||||
=cut
|
||||
|
||||
sub export {
|
||||
my $self = shift;
|
||||
my $filename = shift;
|
||||
|
|
@ -1246,6 +1619,16 @@ sub export {
|
|||
return undef;
|
||||
} ## end sub export
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 loadTempReportTable
|
||||
|
||||
Loads the responses from the survey into the Survey_tempReport table, so that other or custom reports can be ran against this data.
|
||||
|
||||
=cut
|
||||
|
||||
sub loadTempReportTable {
|
||||
my $self = shift;
|
||||
|
||||
|
|
|
|||
|
|
@ -1086,6 +1086,12 @@ sub aIndexes {
|
|||
|
||||
=head2 returnResponsesForReporting
|
||||
|
||||
Used to extract JSON responses for use in reporting results.
|
||||
|
||||
Returns an array ref containing the current responses to the survey. The array ref contains a list of hashes with the section, question,
|
||||
sectionName, questionName, questionComment, and an answer array ref. The answer array ref contains a list of hashes, with isCorrect (1 true, 0 false),
|
||||
recorded value, and the id of the answer.
|
||||
|
||||
=cut
|
||||
|
||||
# TODO: This sub should make use of recordedResponses
|
||||
|
|
|
|||
|
|
@ -1253,6 +1253,25 @@ sub question {
|
|||
return $self->sections->[ $address->[0] ]->{questions}->[ $address->[1] ];
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 questionCount (){
|
||||
|
||||
Return the total number of questions in this survey.
|
||||
|
||||
=cut
|
||||
|
||||
sub questionCount {
|
||||
my $self = shift;
|
||||
my $count;
|
||||
for ( my $s = 0; $s <= $#{ $self->sections() }; $s++ ) {
|
||||
$count = $count + scalar @{$self->questions( [$s] )};
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 answers ($address)
|
||||
|
||||
Return a reference to all answers from a particular question.
|
||||
|
|
|
|||
|
|
@ -146,14 +146,17 @@ sub generateFeed {
|
|||
$value = $cache->setByHTTP($url, $self->get("cacheTimeout"));
|
||||
$newlyCached = 1;
|
||||
}
|
||||
utf8::downgrade($value);
|
||||
# if the content can be downgraded, it is either valid latin1 or didn't have
|
||||
# an HTTP Content-Encoding header. In the second case, XML::FeedPP will take
|
||||
# care of any encoding specified in the XML prolog
|
||||
utf8::downgrade($value, 1);
|
||||
eval {
|
||||
my $singleFeed = XML::FeedPP->new($value, utf8_flag => 1);
|
||||
$feed->merge($singleFeed);
|
||||
};
|
||||
if (my $e = WebGUI::Error->caught()) {
|
||||
$log->error("Syndicated Content asset (".$self->getId.") has a bad feed URL (".$url."). Failed with ".$e->message);
|
||||
}
|
||||
if ($@) {
|
||||
$log->error("Syndicated Content asset (".$self->getId.") has a bad feed URL (".$url."). Failed with ".$@);
|
||||
}
|
||||
}
|
||||
|
||||
# build a new feed that matches the term the user is interested in
|
||||
|
|
@ -196,9 +199,9 @@ sub getTemplateVariables {
|
|||
my @items = $feed->get_item;
|
||||
my %var;
|
||||
$var{channel_title} = WebGUI::HTML::filter($feed->title, 'javascript');
|
||||
$var{channel_description} = WebGUI::HTML::filter($feed->description, 'javascript');
|
||||
$var{channel_date} = WebGUI::HTML::filter($feed->get_pubDate_epoch, 'javascript');
|
||||
$var{channel_copyright} = WebGUI::HTML::filter($feed->copyright, 'javascript');
|
||||
$var{channel_description} = WebGUI::HTML::filter(scalar($feed->description), 'javascript');
|
||||
$var{channel_date} = WebGUI::HTML::filter(scalar($feed->get_pubDate_epoch), 'javascript');
|
||||
$var{channel_copyright} = WebGUI::HTML::filter(scalar($feed->copyright), 'javascript');
|
||||
$var{channel_link} = WebGUI::HTML::filter($feed->link, 'javascript');
|
||||
my @image = $feed->image;
|
||||
$var{channel_image_url} = WebGUI::HTML::filter($image[0], 'javascript');
|
||||
|
|
@ -215,7 +218,7 @@ sub getTemplateVariables {
|
|||
$item{author} = WebGUI::HTML::filter($object->author, 'javascript');
|
||||
$item{guid} = WebGUI::HTML::filter($object->guid, 'javascript');
|
||||
$item{link} = WebGUI::HTML::filter($object->link, 'javascript');
|
||||
$item{description} = WebGUI::HTML::filter($object->description, 'javascript');
|
||||
$item{description} = WebGUI::HTML::filter(scalar($object->description), 'javascript');
|
||||
$item{descriptionFirst100words} = $item{description};
|
||||
$item{descriptionFirst100words} =~ s/(((\S+)\s+){100}).*/$1/s;
|
||||
$item{descriptionFirst75words} = $item{descriptionFirst100words};
|
||||
|
|
|
|||
|
|
@ -22,6 +22,11 @@ use base 'WebGUI::Asset::Wobject';
|
|||
use WebGUI::Asset::Wobject::ProjectManager;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
|
|
@ -82,6 +87,11 @@ sub definition {
|
|||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 prepareView
|
||||
|
||||
=cut
|
||||
|
||||
sub prepareView {
|
||||
my $self = shift;
|
||||
$self->SUPER::prepareView();
|
||||
|
|
@ -96,6 +106,11 @@ sub prepareView {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 processErrors
|
||||
|
||||
=cut
|
||||
|
||||
sub processErrors {
|
||||
my $self = shift;
|
||||
my $errors = "";
|
||||
|
|
@ -111,6 +126,11 @@ sub processErrors {
|
|||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 purge
|
||||
|
||||
=cut
|
||||
|
||||
sub purge {
|
||||
my $self = shift;
|
||||
#purge your wobject-specific data here. This does not include fields
|
||||
|
|
@ -119,6 +139,11 @@ sub purge {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDaysInWeek
|
||||
|
||||
=cut
|
||||
|
||||
sub getDaysInWeek {
|
||||
my $self = shift;
|
||||
my $week = $_[0];
|
||||
|
|
@ -142,6 +167,11 @@ sub getDaysInWeek {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getSessionVars
|
||||
|
||||
=cut
|
||||
|
||||
sub getSessionVars {
|
||||
my $self = shift;
|
||||
my @vars = @_;
|
||||
|
|
@ -159,6 +189,11 @@ sub getSessionVars {
|
|||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 view
|
||||
|
||||
=cut
|
||||
|
||||
sub view {
|
||||
my $self = shift;
|
||||
my $var = $self->get;
|
||||
|
|
@ -197,6 +232,11 @@ sub view {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editTimeEntrySave
|
||||
|
||||
=cut
|
||||
|
||||
sub www_editTimeEntrySave {
|
||||
my $self = shift;
|
||||
my ($session,$privilege,$form,$db,$user,$eh,$dt) = $self->getSessionVars("privilege","form","db","user","errorHandler","datetime");
|
||||
|
|
@ -271,6 +311,11 @@ sub www_editTimeEntrySave {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_deleteProject
|
||||
|
||||
=cut
|
||||
|
||||
sub www_deleteProject {
|
||||
my $self = shift;
|
||||
my ($session,$privilege,$form,$db,$user,$eh,$config) = $self->getSessionVars("privilege","form","db","user","errorHandler","config");
|
||||
|
|
@ -293,6 +338,11 @@ sub www_deleteProject {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editProject
|
||||
|
||||
=cut
|
||||
|
||||
sub www_editProject {
|
||||
my $self = shift;
|
||||
my ($session,$privilege,$form,$db,$user,$eh,$config) = $self->getSessionVars("privilege","form","db","user","errorHandler","config");
|
||||
|
|
@ -393,6 +443,11 @@ sub www_editProject {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editProjectSave
|
||||
|
||||
=cut
|
||||
|
||||
sub www_editProjectSave {
|
||||
my $self = shift;
|
||||
my ($session,$privilege,$form,$db,$dt,$user,$eh) = $self->getSessionVars("privilege","form","db","datetime","user","errorHandler");
|
||||
|
|
@ -453,6 +508,11 @@ sub www_editProjectSave {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_manageProjects
|
||||
|
||||
=cut
|
||||
|
||||
sub www_manageProjects {
|
||||
my $self = shift;
|
||||
my ($session,$privilege,$form,$db,$dt,$user,$eh,$config) = $self->getSessionVars("privilege","form","db","datetime","user","errorHandler","config");
|
||||
|
|
@ -574,6 +634,11 @@ sub www_manageProjects {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_buildTimeTable
|
||||
|
||||
=cut
|
||||
|
||||
sub www_buildTimeTable {
|
||||
my $self = shift;
|
||||
my $viewVar = $_[0];
|
||||
|
|
@ -738,6 +803,11 @@ sub www_buildTimeTable {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _buildRow
|
||||
|
||||
=cut
|
||||
|
||||
sub _buildRow {
|
||||
my $self = shift;
|
||||
my ($session,$dt,$eh,$form,$db,$user) = $self->getSessionVars("datetime","errorHandler","form","db","user");
|
||||
|
|
@ -762,20 +832,41 @@ sub _buildRow {
|
|||
-name=>"taskEntryId_$rowCount",
|
||||
-value=>$entryId
|
||||
});
|
||||
|
||||
#Entry Date
|
||||
|
||||
##Handle cases when a user has been removed from a project. The projectList
|
||||
##and taskList hash refs that have been passed in will not contain entries for
|
||||
##their old project info
|
||||
|
||||
#Entry Task
|
||||
tie my %taskHash, "Tie::IxHash";
|
||||
if ($projectId) {
|
||||
if (! exists $projectList->{$projectId}) {
|
||||
my $projectName = $db->quickScalar('select projectName from TT_projectList where projectId=?',[$projectId]);
|
||||
$projectList->{$projectId} = $projectName;
|
||||
}
|
||||
if (! exists $taskList->{$projectId}) {
|
||||
%taskHash = $db->buildHash("select taskId, taskName from TT_projectTasks where projectId=?",[$projectId]);
|
||||
}
|
||||
else {
|
||||
%taskHash = %{$taskList->{$projectId}};
|
||||
}
|
||||
#$eh->warn($projectId);
|
||||
}
|
||||
my $chooseLabel = $i18n->get("Choose One");
|
||||
%taskHash = (""=>$chooseLabel,%taskHash);
|
||||
|
||||
#Entry Date
|
||||
$var->{'entry.hours'} = $entry->{hours};
|
||||
if($reportComplete) {
|
||||
$var->{'form.date'} = $entry->{taskDate};
|
||||
$var->{'form.project'} = $projectList->{$projectId};
|
||||
|
||||
my $taskHash = $taskList->{$projectId};
|
||||
$var->{'form.task'} = $taskHash->{$entry->{taskId}};
|
||||
$var->{'form.task'} = $taskHash{$entry->{taskId}};
|
||||
$var->{'form.hours'} = $var->{'entry.hours'};
|
||||
$var->{'form.comments'} = $entry->{comments};
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
tie my %days, "Tie::IxHash";
|
||||
%days = (""=>$chooseLabel, %{$daysInWeek});
|
||||
$var->{'form.date'} = WebGUI::Form::selectBox($session,{
|
||||
|
|
@ -793,15 +884,7 @@ sub _buildRow {
|
|||
-value=>$projectId,
|
||||
-extras=>qq|onchange="changeOptions(this,document.getElementById('$taskId'));" class="pt-select"|
|
||||
});
|
||||
|
||||
#Entry Task
|
||||
tie my %taskHash, "Tie::IxHash";
|
||||
%taskHash = (""=>$chooseLabel,%taskHash);
|
||||
if($projectId) {
|
||||
#$eh->warn($projectId);
|
||||
%taskHash = %{$taskList->{$projectId}};
|
||||
}
|
||||
|
||||
|
||||
$var->{'form.task'} = WebGUI::Form::selectBox($session,{
|
||||
-name=>$taskName,
|
||||
-options=>\%taskHash,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue