Refactored Survey ExpressionEngine tag() util into tag() setter and tagged() accessor.
Updated i18n to reflect the fact that min/max/step are used for all numeric types, not just slider. Also updated textCols/Rows i18n.
This commit is contained in:
parent
494efe1cf1
commit
f3ed30d939
6 changed files with 98 additions and 65 deletions
|
|
@ -171,50 +171,67 @@ sub answeredX {
|
|||
|
||||
=head2 tag ($name, [$value])
|
||||
|
||||
Mutator utility sub that gives expressions access to tag response values (and optionally set them).
|
||||
Utility sub that allows expressions to tag data
|
||||
|
||||
=head3 $name
|
||||
|
||||
Name of tag whose value is returned.
|
||||
Name of tag to set
|
||||
|
||||
=head3 $value (optional)
|
||||
|
||||
If provided, the tag is set to this value.
|
||||
Value of tag to set. Defaults to 1 (boolean true flag).
|
||||
|
||||
=cut
|
||||
|
||||
sub tag {
|
||||
my ($name, $value) = @_;
|
||||
if (defined $value) {
|
||||
$session->log->debug("Setting tag [$name] to [$value]");
|
||||
$tags->{$name} = $value;
|
||||
} else {
|
||||
$value = $tags->{$name};
|
||||
$session->log->debug("tag($name) resolves to [$value]");
|
||||
}
|
||||
return $value;
|
||||
$value = 1 if !defined $value;
|
||||
$session->log->debug("Setting tag [$name] to [$value]");
|
||||
$tags->{$name} = $value;
|
||||
}
|
||||
|
||||
=head2 tagX
|
||||
=head2 tagged ($name)
|
||||
|
||||
Same as L<tag>, except that first argument is an asset spec (assetId or url), which must resolve
|
||||
to a valid survey instance. The sub is applied to the most recent completed response for the user
|
||||
on the survey instance given by asset_spec.
|
||||
Utility sub that gives expressions access to tagged data
|
||||
|
||||
Note that it doesn't really make sense to try to set a tag on an external asset, so this sub
|
||||
is only an accessor.
|
||||
=head3 $name
|
||||
|
||||
Name of tag whose value is returned.
|
||||
|
||||
=cut
|
||||
|
||||
sub tagX {
|
||||
sub tagged {
|
||||
my ($name) = @_;
|
||||
if (@_ == 2) {
|
||||
my $args = join ',', @_;
|
||||
$session->log->warn("Two arguments passed to tagged($args). Did you mean tag($args)?");
|
||||
}
|
||||
my $value = $tags->{$name};
|
||||
$session->log->debug("tagged($name) resolves to [$value]");
|
||||
return $value;
|
||||
}
|
||||
|
||||
=head2 taggedX
|
||||
|
||||
Same as L<tagged>, except that first argument is an asset spec (assetId or url), which must resolve
|
||||
to a valid survey instance. The sub is applied to the most recent completed response for the user
|
||||
on the survey instance given by asset_spec.
|
||||
|
||||
=cut
|
||||
|
||||
sub taggedX {
|
||||
my ( $asset_spec, $name ) = @_;
|
||||
|
||||
if (@_ == 3) {
|
||||
my $args = join ',', @_;
|
||||
$session->log->warn("Three arguments passed to taggedX($args). Did you mean tag($args)?");
|
||||
}
|
||||
# See if $otherInstances already contains the external survey
|
||||
if (my $other_instance = $otherInstances->{$asset_spec}) {
|
||||
my $tags = $other_instance->{tags};
|
||||
|
||||
my $value = $tags->{$name};
|
||||
$session->log->debug("tagX($asset_spec, $name) returns [$value]");
|
||||
$session->log->debug("taggedX($asset_spec, $name) returns [$value]");
|
||||
return $value;
|
||||
} else {
|
||||
# Throw an exception, triggering run() to resolve the external reference and re-run
|
||||
|
|
@ -362,7 +379,8 @@ sub run {
|
|||
$compartment->share('&answered');
|
||||
$compartment->share('&answeredX');
|
||||
$compartment->share('&tag');
|
||||
$compartment->share('&tagX');
|
||||
$compartment->share('&tagged');
|
||||
$compartment->share('&taggedX');
|
||||
$compartment->share('&jump');
|
||||
$compartment->share('&avg');
|
||||
|
||||
|
|
|
|||
|
|
@ -281,23 +281,23 @@ our $I18N = {
|
|||
lastUpdated => 1224686319
|
||||
},
|
||||
'cols description' => {
|
||||
message => q|The number of columns used for the comment TextArea input field.|,
|
||||
message => q|The number of columns used for the input field (for TextArea question types).|,
|
||||
context => q|Description of the 'cols' field, used as hoverhelp in the edit question dialog.|,
|
||||
lastUpdated => 0
|
||||
lastUpdated => 1241588599
|
||||
},
|
||||
'comment rows' => {
|
||||
message => q|Comment Rows:|,
|
||||
lastUpdated => 1224686319
|
||||
},
|
||||
'rows description' => {
|
||||
message => q|The number of rows shown for the comment TextArea input field.|,
|
||||
message => q|The number of rows used for the input field (for TextArea question types).|,
|
||||
context => q|Description of the 'rows' field, used as hoverhelp in the edit question dialog.|,
|
||||
lastUpdated => 0
|
||||
lastUpdated => 1241588599
|
||||
},
|
||||
'maximum number of answers' => {
|
||||
message => q|Maximum number of answers:|,
|
||||
lastUpdated => 1224686319
|
||||
},
|
||||
'maximum number of answers' => {
|
||||
message => q|Maximum number of answers:|,
|
||||
lastUpdated => 1224686319
|
||||
},
|
||||
'maximum number of answers description' => {
|
||||
message => q|Enter the maximum number of answers.|,
|
||||
context => q|Description of the 'maximum number of answers' field, used as hoverhelp in the edit question dialog.|,
|
||||
|
|
@ -393,41 +393,41 @@ our $I18N = {
|
|||
lastUpdated => 1224686319
|
||||
},
|
||||
'min label' => {
|
||||
message => q|Slider Min|,
|
||||
lastUpdated => 1224686319
|
||||
message => q|Min|,
|
||||
lastUpdated => 1241588065
|
||||
},
|
||||
'min description' => {
|
||||
message => q|The minimum value of this answer for slider type questions.|,
|
||||
context => q|Description of the 'min' field, used as hoverhelp in the edit answer dialog.|,
|
||||
lastUpdated => 0
|
||||
},
|
||||
'min description' => {
|
||||
message => q|The minimum numeric value allowed for this answer (for numeric question types such as Number and Slider). Keep this field empty if you do not want to enforce a minimum value. |,
|
||||
context => q|Description of the 'min' field, used as hoverhelp in the edit answer dialog.|,
|
||||
lastUpdated => 1241588065
|
||||
},
|
||||
'max label' => {
|
||||
message => q|Slider Max|,
|
||||
lastUpdated => 1224686319
|
||||
message => q|Max|,
|
||||
lastUpdated => 1241588065
|
||||
},
|
||||
'max description' => {
|
||||
message => q|The maximum value of this answer for slider type questions.|,
|
||||
context => q|Description of the 'max' field, used as hoverhelp in the edit answer dialog.|,
|
||||
lastUpdated => 0
|
||||
},
|
||||
'max description' => {
|
||||
message => q|The maximum numeric value allowed for this answer (for Number and Slider type questions). Keep this field empty if you do not want to enforce a maximum value. |,
|
||||
context => q|Description of the 'max' field, used as hoverhelp in the edit answer dialog.|,
|
||||
lastUpdated => 1241588065
|
||||
},
|
||||
'step label' => {
|
||||
message => q|Slider Step|,
|
||||
lastUpdated => 1224686319
|
||||
message => q|Step|,
|
||||
lastUpdated => 1241588065
|
||||
},
|
||||
'step description' => {
|
||||
message => q|The step value of this answer for slider type questions.|,
|
||||
context => q|Description of the 'step' field, used as hoverhelp in the edit answer dialog.|,
|
||||
lastUpdated => 0
|
||||
},
|
||||
'step description' => {
|
||||
message => q|The step value, that is, the numeric interval to allow between values (for Number and Slider type questions). Keep this field empty if you do not want to enforce a step value. |,
|
||||
context => q|Description of the 'step' field, used as hoverhelp in the edit answer dialog.|,
|
||||
lastUpdated => 0
|
||||
},
|
||||
'verbatim label' => {
|
||||
message => q|Verbatim|,
|
||||
lastUpdated => 1224686319
|
||||
},
|
||||
'verbatim description' => {
|
||||
message => q|Set to yes to add an extra text input to the answer, where the user can enter a single line of text. Typically used to permit a free-text 'other' response.|,
|
||||
context => q|Description of the 'verbatim' field, used as hoverhelp in the edit answer dialog.|,
|
||||
lastUpdated => 0
|
||||
},
|
||||
'verbatim description' => {
|
||||
message => q|Set to yes to add an extra text input to the answer, where the user can enter a single line of text. Typically used to permit a free-text 'other' response.|,
|
||||
context => q|Description of the 'verbatim' field, used as hoverhelp in the edit answer dialog.|,
|
||||
lastUpdated => 0
|
||||
},
|
||||
'answer score' => {
|
||||
message => q|Answer score:|,
|
||||
lastUpdated => 1239251986
|
||||
|
|
@ -1358,13 +1358,23 @@ section/answer.|,
|
|||
'textCols' => {
|
||||
message => q|The number of columns for TextArea questions.|,
|
||||
context => q|Description of a template variable for a template Help page.|,
|
||||
lastUpdated => 0,
|
||||
lastUpdated => 1241588599,
|
||||
},
|
||||
|
||||
'textCols label' => {
|
||||
message => q|TextArea Columns|,
|
||||
lastUpdated => 1241588599
|
||||
},
|
||||
|
||||
'textRows' => {
|
||||
message => q|The number of rows for TextArea questions.|,
|
||||
context => q|Description of a template variable for a template Help page.|,
|
||||
lastUpdated => 0,
|
||||
lastUpdated => 1241588599,
|
||||
},
|
||||
|
||||
'textRows label' => {
|
||||
message => q|TextArea Rows|,
|
||||
lastUpdated => 1241588599
|
||||
},
|
||||
|
||||
'answers' => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue