Summaries added to the survey
This commit is contained in:
parent
e918f3ff7b
commit
a6a70a46e0
7 changed files with 81 additions and 16 deletions
|
|
@ -1,7 +1,7 @@
|
|||
7.7.3
|
||||
- fixed #10094: double explanation in thread help
|
||||
- rfe #9612: Carousel Wobject (was Widget Wobject) (SDH Consulting Group)
|
||||
|
||||
- Survey summaries now added. In the Survey edit, select quiz mode, and a summary will be shown to the user at the end of the survey.
|
||||
7.7.2
|
||||
- fixed #10056: YUI javascripts included while adminOff (BNC)
|
||||
- fixed a bug that required you to hit "update cart" before the checkout
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -112,6 +112,14 @@ sub definition {
|
|||
label => $i18n->get('Max user responses'),
|
||||
hoverHelp => $i18n->get('Max user responses help'),
|
||||
},
|
||||
surveySummaryTemplateId => {
|
||||
tab => 'display',
|
||||
fieldType => 'template',
|
||||
label => $i18n->get('Survey Summary Template'),
|
||||
hoverHelp => $i18n->get('Survey Summary Template help'),
|
||||
defaultValue => '7F-BuEHi7t9bPi008H8xZQ',
|
||||
namespace => 'Survey/Summary',
|
||||
},
|
||||
surveyTakeTemplateId => {
|
||||
tab => 'display',
|
||||
fieldType => 'template',
|
||||
|
|
@ -1144,6 +1152,14 @@ sub www_submitQuestions {
|
|||
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getSummary{
|
||||
my $self = shift;
|
||||
my $summary = $self->responseJSON->showSummary();
|
||||
my $out = $self->processTemplate( $summary, $self->get('surveySummaryTemplateId') );
|
||||
return $out;
|
||||
# return $self->session->style->process( $out, $self->get('styleTemplateId') );
|
||||
}
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_loadQuestions
|
||||
|
|
@ -1155,7 +1171,7 @@ Determines which questions to display to the survey taker next, loads and return
|
|||
sub www_loadQuestions {
|
||||
my $self = shift;
|
||||
my $wasRestarted = shift;
|
||||
|
||||
|
||||
if ( !$self->canTakeSurvey() ) {
|
||||
$self->session->log->debug('canTakeSurvey false, surveyEnd');
|
||||
return $self->surveyEnd();
|
||||
|
|
@ -1175,9 +1191,8 @@ sub www_loadQuestions {
|
|||
$self->session->log->debug('Response surveyEnd, so calling surveyEnd');
|
||||
if ( $self->get('quizModeSummary') ) {
|
||||
if(! $self->session->form->param('shownsummary')){
|
||||
my $summary = $self->responseJSON->showSummary();
|
||||
my $out = $self->processTemplate( $summary, $self->get('surveyQuestionsId') );
|
||||
# return $out;
|
||||
my $json = to_json( { type => 'summary', summary => $self->getSummary() });
|
||||
return $json;
|
||||
}
|
||||
}
|
||||
return $self->surveyEnd();
|
||||
|
|
@ -1261,7 +1276,7 @@ sub surveyEnd {
|
|||
}
|
||||
}
|
||||
}
|
||||
$url = $self->session->url->gateway($url);
|
||||
$url = $self->session->url->gateway($url) if($url !~ /^http:/i);
|
||||
#$self->session->http->setRedirect($url);
|
||||
#$self->session->http->setMimeType('application/json');
|
||||
my $json = to_json( { type => 'forward', url => $url } );
|
||||
|
|
|
|||
|
|
@ -1117,10 +1117,18 @@ sub showSummary{
|
|||
my ($sectionIndex, $questionIndex, $answerIndex) = (-1, -1, -1);
|
||||
my ($currentSection,$currentQuestion) = (-1, -1);
|
||||
|
||||
($summaries->{totalCorrect},$summaries->{totalIncorrect}) = (0,0);
|
||||
|
||||
for my $response (@$responses){
|
||||
if(! $all and ! $goodSection{$response->{address}->[0]}){next;}
|
||||
|
||||
if($response->{isCorrect}){
|
||||
$summaries->{totalCorrect}++;
|
||||
}else{
|
||||
$summaries->{totalIncorrect}++;
|
||||
}
|
||||
$summaries->{totalAnswers}++;
|
||||
if($currentSection != $response->{address}->[0]){
|
||||
$summaries->{totalSections}++;
|
||||
$sectionIndex++;
|
||||
$questionIndex = -1;
|
||||
$answerIndex = -1;
|
||||
|
|
@ -1129,6 +1137,7 @@ sub showSummary{
|
|||
_loadSectionIntoSummary(\%{$summaries->{sections}->[$sectionIndex]},$response);
|
||||
}
|
||||
if($currentQuestion != $response->{address}->[1]){
|
||||
$summaries->{totalQuestions}++;
|
||||
$questionIndex++;
|
||||
$answerIndex = -1;
|
||||
$currentQuestion = $response->{address}->[1];
|
||||
|
|
@ -1145,10 +1154,13 @@ sub _loadAnswerIntoSummary{
|
|||
my $node = shift;
|
||||
my $response = shift;
|
||||
my $types = shift;
|
||||
|
||||
$node->{id} = $response->{address}->[2] + 1;
|
||||
if($response->{isCorrect}){
|
||||
$node->{iscorrect} = 1;
|
||||
$node->{score} = $response->{value};
|
||||
}else{
|
||||
$node->{iscorrect} = 0;
|
||||
$node->{score} = 0;
|
||||
}
|
||||
$node->{text} = $response->{answerText};
|
||||
|
|
@ -1163,21 +1175,21 @@ sub _loadAnswerIntoSummary{
|
|||
sub _loadQuestionIntoSummary{
|
||||
my $node = shift;
|
||||
my $response = shift;
|
||||
$node->{id} = $response->{address}->[1];
|
||||
$node->{id} = $response->{address}->[1] + 1;
|
||||
$node->{text} = $response->{questionText};
|
||||
}
|
||||
sub _loadSectionIntoSummary{
|
||||
my $node = shift;
|
||||
my $response = shift;
|
||||
$node->{id} = $response->{address}->[0];
|
||||
$node->{id} = $response->{address}->[0] + 1;
|
||||
$node->{inCorrect} = 0 if(!defined $node->{section}->{inCorrect});
|
||||
$node->{score} = 0 if(!defined $node->{section}->{score});
|
||||
$node->{correct} = 0 if(!defined $node->{section}->{correct});
|
||||
if($response->{isCorrect}){
|
||||
$node->{score} = 0 if(!defined $node->{section}->{score});
|
||||
$node->{correct} = 0 if(!defined $node->{section}->{correct});
|
||||
$node->{score} += $response->{value};
|
||||
$node->{correct}++;
|
||||
}else{
|
||||
$node->{incorrect} = 0 if(!defined $node->{section}->{incorrect});
|
||||
$node->{incorrect}++;
|
||||
$node->{inCorrect}++;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -475,6 +475,14 @@ Survey's edit screen|,
|
|||
context => q|The message shown to the user taking the survey when the survey is restarted after reaching
|
||||
the time limit for completing the survey. This message is in the 'take survey' template.|,
|
||||
},
|
||||
'Quiz mode summaries' => {
|
||||
message => q|Show quiz mode summaries?|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
'Quiz mode summaries help' => {
|
||||
message => q|When set, summaries are shown to users giving their quiz results?|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
'Show user their progress' => {
|
||||
message => q|Show user their progress?|,
|
||||
lastUpdated => 0,
|
||||
|
|
@ -608,6 +616,18 @@ the time limit for completing the survey. This message is in the 'take survey' t
|
|||
message => q|The template for displaying the screen for editing the survey.|,
|
||||
lastUpdated => 0
|
||||
},
|
||||
|
||||
'Survey Summary Template' => {
|
||||
message => q|Survey Summary Template|,
|
||||
context => q|The template for displaying the summary page to users.|,
|
||||
lastUpdated => 0
|
||||
},
|
||||
|
||||
'Survey Summary Template help' => {
|
||||
message => q|This is the template shown to users in quiz mode to summarize their results.|,
|
||||
context => q|The template for displaying the summary page to users.|,
|
||||
lastUpdated => 0
|
||||
},
|
||||
|
||||
'Take Survey Template' => {
|
||||
message => q|Take Survey Template|,
|
||||
|
|
|
|||
|
|
@ -327,6 +327,11 @@ if (typeof Survey === "undefined") {
|
|||
|
||||
// Public API
|
||||
Survey.Form = {
|
||||
showSummary: function(html){
|
||||
var html = html;
|
||||
document.getElementById('survey').innerHTML = html;
|
||||
YAHOO.util.Event.addListener("submitbutton", "click", function(){ Survey.Comm.submitSummary(); });
|
||||
},
|
||||
displayQuestions: function(params){
|
||||
toValidate = [];
|
||||
var qs = params.questions;
|
||||
|
|
|
|||
|
|
@ -44,14 +44,23 @@ if (typeof Survey === "undefined") {
|
|||
if (response.type === 'displayquestions') {
|
||||
Survey.Form.displayQuestions(response);
|
||||
}
|
||||
else
|
||||
else{
|
||||
if (response.type === 'forward') {
|
||||
//YAHOO.log("going to "+response.url);
|
||||
location.href = response.url;
|
||||
var url;
|
||||
if(response.url.match(/http/)){
|
||||
url = response.url;
|
||||
}else{
|
||||
url = location.protocol+"//"+location.host+"/"+response.url;
|
||||
}
|
||||
window.location = url;
|
||||
}
|
||||
else if(response.type === 'summary'){
|
||||
Survey.Form.showSummary(response.summary);
|
||||
}
|
||||
else {
|
||||
alert("bad response");
|
||||
}
|
||||
}
|
||||
},
|
||||
failure: function(o){
|
||||
callMade = 0;
|
||||
|
|
@ -63,6 +72,10 @@ if (typeof Survey === "undefined") {
|
|||
}
|
||||
}
|
||||
},
|
||||
submitSummary: function(data,functionName){
|
||||
var sUrl = "?func=loadQuestions&shownSummary=1";
|
||||
request(sUrl, this.callback, null, null, null);
|
||||
},
|
||||
callServer: function(data, functionName, form, hasFile){
|
||||
var postData;
|
||||
if (!form) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue