From ba163fa231473907e9fdcc696c73f175c778b41c Mon Sep 17 00:00:00 2001 From: moodler Date: Sat, 20 Mar 2004 09:39:17 +0000 Subject: [PATCH] Cleaner pages when there are no responses yet --- mod/survey/report.php | 148 +++++++++++++++++++++++------------------- 1 file changed, 80 insertions(+), 68 deletions(-) diff --git a/mod/survey/report.php b/mod/survey/report.php index b183d80e0d..fbdf83dd88 100644 --- a/mod/survey/report.php +++ b/mod/survey/report.php @@ -113,34 +113,40 @@ survey_print_graph("id=$id&group=$currentgroup&type=overall.png"); echo ""; } else { - echo "

".get_string("nobodyyet","survey")."

"; + notify(get_string("nobodyyet","survey")); } break; case "scales": print_heading($strscales); - $questions = get_records_list("survey_questions", "id", $survey->questions); - $questionorder = explode(",", $survey->questions); + if (! $results = survey_get_responses($survey->id, $currentgroup) ) { + notify(get_string("nobodyyet","survey")); - foreach ($questionorder as $key => $val) { - $question = $questions[$val]; - if ($question->type < 0) { // We have some virtual scales. Just show them. - $virtualscales = true; - break; - } - } + } else { - foreach ($questionorder as $key => $val) { - $question = $questions[$val]; - if ($question->multi) { - if ($virtualscales && $question->type > 0) { // Don't show non-virtual scales if virtual - continue; + $questions = get_records_list("survey_questions", "id", $survey->questions); + $questionorder = explode(",", $survey->questions); + + foreach ($questionorder as $key => $val) { + $question = $questions[$val]; + if ($question->type < 0) { // We have some virtual scales. Just show them. + $virtualscales = true; + break; } - echo "

multi>"; - survey_print_graph("id=$id&qid=$question->id&group=$currentgroup&type=multiquestion.png"); - echo "


"; - } + } + + foreach ($questionorder as $key => $val) { + $question = $questions[$val]; + if ($question->multi) { + if ($virtualscales && $question->type > 0) { // Don't show non-virtual scales if virtual + continue; + } + echo "

multi>"; + survey_print_graph("id=$id&qid=$question->id&group=$currentgroup&type=multiquestion.png"); + echo "


"; + } + } } break; @@ -165,63 +171,69 @@ print_heading($strallquestions); } - foreach ($questionorder as $key => $val) { - $question = $questions[$val]; - if ($question->type < 0) { // We have some virtual scales. DON'T show them. - $virtualscales = true; - break; - } - } + if (! $results = survey_get_responses($survey->id, $currentgroup) ) { + notify(get_string("nobodyyet","survey")); - foreach ($questionorder as $key => $val) { - $question = $questions[$val]; + } else { - if ($question->type < 0) { // We have some virtual scales. DON'T show them. - continue; + foreach ($questionorder as $key => $val) { + $question = $questions[$val]; + if ($question->type < 0) { // We have some virtual scales. DON'T show them. + $virtualscales = true; + break; + } } - $question->text = get_string($question->text, "survey"); - - if ($question->multi) { - echo "

$question->text:

"; - - $subquestions = get_records_list("survey_questions", "id", $question->multi); - $subquestionorder = explode(",", $question->multi); - foreach ($subquestionorder as $key => $val) { - $subquestion = $subquestions[$val]; - if ($subquestion->type > 0) { - echo "

"; - echo "id\">"; - survey_print_graph("id=$id&qid=$subquestion->id&group=$currentgroup&type=question.png"); - echo "

"; - } + + foreach ($questionorder as $key => $val) { + $question = $questions[$val]; + + if ($question->type < 0) { // We have some virtual scales. DON'T show them. + continue; } - } else if ($question->type > 0 ) { - echo "

"; - echo "id\">"; - survey_print_graph("id=$id&qid=$question->id&group=$currentgroup&type=question.png"); - echo "

"; + $question->text = get_string($question->text, "survey"); + + if ($question->multi) { + echo "

$question->text:

"; + + $subquestions = get_records_list("survey_questions", "id", $question->multi); + $subquestionorder = explode(",", $question->multi); + foreach ($subquestionorder as $key => $val) { + $subquestion = $subquestions[$val]; + if ($subquestion->type > 0) { + echo "

"; + echo "id\">"; + survey_print_graph("id=$id&qid=$subquestion->id&group=$currentgroup&type=question.png"); + echo "

"; + } + } + } else if ($question->type > 0 ) { + echo "

"; + echo "id\">"; + survey_print_graph("id=$id&qid=$question->id&group=$currentgroup&type=question.png"); + echo "

"; - } else { - $table = NULL; - $table->head = array($question->text); - $table->align = array ("left"); - - $contents = ''; - - if ($aaa = survey_get_user_answers($survey->id, $question->id, $currentgroup, "sa.time ASC")) { - foreach ($aaa as $a) { - $contents .= ""; - $contents .= ''; - $contents .= ''; - $contents .= ""; + } else { + $table = NULL; + $table->head = array($question->text); + $table->align = array ("left"); + + $contents = '
'.fullname($a).''.$a->answer1.'
'; + + if ($aaa = survey_get_user_answers($survey->id, $question->id, $currentgroup, "sa.time ASC")) { + foreach ($aaa as $a) { + $contents .= ""; + $contents .= ''; + $contents .= ''; + $contents .= ""; + } } - } - $contents .= "
'.fullname($a).''.$a->answer1.'
"; + $contents .= ""; - $table->data[] = array($contents); + $table->data[] = array($contents); - print_table($table); - print_spacer(30); + print_table($table); + print_spacer(30); + } } } -- 2.39.5