diff --git a/docs/upgrades/packages-7.6.10/root_import_survey_default_overview_report.wgpkg b/docs/upgrades/packages-7.6.10/root_import_survey_default_overview_report.wgpkg new file mode 100644 index 000000000..1c5377380 Binary files /dev/null and b/docs/upgrades/packages-7.6.10/root_import_survey_default_overview_report.wgpkg differ diff --git a/lib/WebGUI/Asset/Wobject/Survey.pm b/lib/WebGUI/Asset/Wobject/Survey.pm index e8332d517..14cb446d5 100644 --- a/lib/WebGUI/Asset/Wobject/Survey.pm +++ b/lib/WebGUI/Asset/Wobject/Survey.pm @@ -1332,6 +1332,97 @@ sub www_viewGradeBook { } ## 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);; + + 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}; + + $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 { my $self = shift; diff --git a/lib/WebGUI/Help/Asset_Survey.pm b/lib/WebGUI/Help/Asset_Survey.pm index ce97f5a02..a4ce42518 100644 --- a/lib/WebGUI/Help/Asset_Survey.pm +++ b/lib/WebGUI/Help/Asset_Survey.pm @@ -71,27 +71,19 @@ our $HELP = { }, 'survey template common vars' => { - title => '90', + title => 'survey template common vars title', body => '', fields => [], variables => [ - { 'name' => 'user.canViewReports' }, - { 'name' => 'delete.all.responses.url' }, - { 'name' => 'delete.all.responses.label' }, - { 'name' => 'export.answers.url' }, - { 'name' => 'export.answers.label' }, - { 'name' => 'export.questions.url' }, - { 'name' => 'export.questions.label' }, - { 'name' => 'export.responses.url' }, - { 'name' => 'export.responses.label' }, - { 'name' => 'export.composite.url' }, - { 'name' => 'export.composite.label' }, - { 'name' => 'report.gradebook.url' }, - { 'name' => 'report.gradebook.label' }, - { 'name' => 'report.overview.url' }, - { 'name' => 'report.overview.label' }, - { 'name' => 'survey.url' }, - { 'name' => 'survey.label' } + { 'name' => 'user_canViewReports' }, + { 'name' => 'delete_all_responses.url' }, + { 'name' => 'export_answers_url' }, + { 'name' => 'export_questions_url' }, + { 'name' => 'export_responses_url' }, + { 'name' => 'export_composite_url' }, + { 'name' => 'report_gradebook_url' }, + { 'name' => 'report_overview_url' }, + { 'name' => 'survey_url' }, ], related => [ { tag => 'survey template', @@ -101,7 +93,7 @@ our $HELP = { }, 'gradebook report template' => { - title => '1087', + title => 'gradebook report template title', body => '', fields => [], isa => [ @@ -116,17 +108,13 @@ our $HELP = { }, ], variables => [ - { 'name' => 'title' }, - { 'name' => 'question.count' }, - { 'name' => 'response.user.label' }, - { 'name' => 'response.count.label' }, - { 'name' => 'response.percent.label' }, + { 'name' => 'question_count' }, { 'name' => 'response_loop', 'variables' => [ - { 'name' => 'response.url' }, - { 'name' => 'response.user.name' }, - { 'name' => 'response.count.correct' }, - { 'name' => 'response.percent' } + { 'name' => 'response_url' }, + { 'name' => 'response_user_name' }, + { 'name' => 'response_count_correct' }, + { 'name' => 'response_percent' } ] } ], @@ -185,7 +173,7 @@ our $HELP = { }, 'statistical overview report template' => { - title => '1091', + title => 'statistical overview template title', body => '', fields => [], isa => [ @@ -200,31 +188,23 @@ our $HELP = { }, ], variables => [ - { 'name' => 'title', }, - { 'name' => 'answer.label', - 'description' => 'report answer.label' - }, - { 'name' => 'response.count.label', - 'description' => 'report response.count.label' - }, - { 'name' => 'response.percent.label', }, - { 'name' => 'show.responses.label' }, - { 'name' => 'show.comments.label' }, { 'name' => 'question_loop', 'variables' => [ { 'name' => 'question', }, - { 'name' => 'question.id', }, - { 'name' => 'question.isRadioList', }, - { 'name' => 'question.response.total' }, - { 'name' => 'question.allowComment', }, + { 'name' => 'question_id', }, + { 'name' => 'question_isMultipleChoice', }, + { 'name' => 'question_response_total' }, + { 'name' => 'question_allowComment', }, { 'name' => 'answer_loop', 'variables' => [ - { 'name' => 'answer.isCorrect' }, + { 'name' => 'answer_isCorrect' }, { 'name' => 'answer' }, - { 'name' => 'answer.response.count' }, - { 'name' => 'answer.response.percent' }, + { 'name' => 'answer_response_count' }, + { 'name' => 'answer_response_percent' }, + { 'name' => 'answer_comment' }, + { 'name' => 'answer_value' }, { 'name' => 'comment_loop', - 'variables' => [ { 'name' => 'answer.comment' } ] + 'variables' => [ { 'name' => 'answer_comment' } ] } ] } @@ -246,7 +226,6 @@ our $HELP = { fields => [], variables => [ { 'name' => 'templateId' }, - { 'name' => 'Survey_id' }, { 'name' => 'questionOrder' }, { 'name' => 'groupToTakeSurvey' }, { 'name' => 'groupToViewReports' }, diff --git a/lib/WebGUI/i18n/English/Asset_Survey.pm b/lib/WebGUI/i18n/English/Asset_Survey.pm index b81362d36..1d4373634 100644 --- a/lib/WebGUI/i18n/English/Asset_Survey.pm +++ b/lib/WebGUI/i18n/English/Asset_Survey.pm @@ -515,6 +515,168 @@ our $I18N = { lastUpdated => 0 }, + 'answer label' => { + message => q|Answer|, + context => q|Label for the Answer column on the statistical overview screen.|, + lastUpdated => 0 + }, + + 'response count label' => { + message => q|Responses|, + context => q|Label for the Response Count column on the statistical overview screen.|, + lastUpdated => 0 + }, + + 'response percent label' => { + message => q|Percentage|, + context => q|Label for the Response Percent column on the statistical overview screen.|, + lastUpdated => 0 + }, + + 'show comments label' => { + message => q|View Comments|, + context => q|Label for the Show Comments link on the statistical overview screen.|, + lastUpdated => 0 + }, + + 'show responses label' => { + message => q|View Responses|, + context => q|Label for the View Responses link on the statistical overview screen.|, + lastUpdated => 0 + }, + + 'statistical overview template title' => { + message => q|Survey Statistical Overview Report Template|, + context => q|The title of a template Help page.|, + lastUpdated => 1149654954, + }, + + 'question_loop' => { + message => q|A loop containing questions.|, + context => q|Description of a template loop for a template Help page.|, + lastUpdated => 1149654954, + }, + + 'question' => { + message => q|The text of this question.|, + context => q|Description of a template variable for a template Help page.|, + lastUpdated => 0, + }, + + 'question_id' => { + message => q|The id of this question|, + context => q|Description of a template variable for a template Help page.|, + lastUpdated => 0, + }, + + 'question_allowComment' => { + message => q|A boolean indicating whether comments about this question are allowed.|, + context => q|Description of a template variable for a template Help page.|, + lastUpdated => 0, + }, + + 'question_response_total' => { + message => q|The total number of responses for this answer.|, + context => q|Description of a template variable for a template Help page.|, + lastUpdated => 1149654954, + }, + + 'question_isMultipleChoice' => { + message => q|A boolean indicating whether this is a multiple choice question.|, + context => q|Description of a template variable for a template Help page.|, + lastUpdated => 1149654954, + }, + + 'answer_loop' => { + message => q|A loop containing the answers and responses for this question.|, + context => q|Description of a template loop for a template Help page.|, + lastUpdated => 1149654954, + }, + + 'answer_isCorrect' => { + message => q|A boolean indicating whether this answer is marked correct. Only available for multiple choice questions.|, + context => q|Description of a template variable for a template Help page.|, + lastUpdated => 1149654954, + }, + + 'answer' => { + message => q|The answer itself.|, + context => q|Description of a template variable for a template Help page. Only available for multiple choice questions.|, + lastUpdated => 1149654954, + }, + + 'answer_value' => { + message => q|The value of this answer. Not available for multiple choice questions.|, + context => q|Description of a template variable for a template Help page.|, + lastUpdated => 0, + }, + + 'answer_response_count' => { + message => q|The total number of responses given for this answer. Only available for multiple choice questions.|, + context => q|Description of a template variable for a template Help page.|, + lastUpdated => 1149654954, + }, + + 'answer_response_percent' => { + message => q|The percent of responses to this question that went to this answer. Only available for multiple choice questions.|, + context => q|Description of a template variable for a template Help page.|, + lastUpdated => 1149654954, + }, + + 'comment_loop' => { + message => q|A loop that contains all of the comments for this answer. Only available for multiple choice questions.|, + context => q|Description of a template loop for a template Help page.|, + lastUpdated => 1149654954, + }, + + 'answer_comment' => { + message => q|A comment. This tmpl_var is available in the comment_loop for multiple choice questions and +directly inside the answer_loop for other types of questions.|, + context => q|Description of a template variable for a template Help page.|, + lastUpdated => 0, + }, + + 'gradebook report template title' => { + message => q|Survey Gradebook Report Template|, + context => q|The title of a template Help page.|, + lastUpdated => 0, + }, + + 'question_count' => { + message => q|The number of questions in the survey.|, + context => q|Description of a template variable for a template Help page.|, + lastUpdated => 1149654771, + }, + + 'response_loop' => { + message => q|A loop containing a list of responses.|, + context => q|Description of a template loop for a template Help page.|, + lastUpdated => 1149654771, + }, + + 'response_user_name' => { + message => q|The username of the user that gave this response.|, + context => q|Description of a template variable for a template Help page.|, + lastUpdated => 1149654771, + }, + + 'response_count_correct' => { + message => q|The total number of questions that this user got correct.|, + context => q|Description of a template variable for a template Help page.|, + lastUpdated => 1149654771, + }, + + 'response_percent' => { + message => q|The percentage of correct questions.|, + context => q|Description of a template variable for a template Help page.|, + lastUpdated => 1149654771, + }, + + 'survey template common vars title' => { + message => q|Survey Template Common Vars|, + context => q|The title of a template Help page.|, + lastUpdated => 1078223067 + }, }; 1;