Exemplo n.º 1
0
function survey_user_complete($course, $user, $mod, $survey)
{
    global $CFG;
    if (survey_already_done($survey->id, $user->id)) {
        if ($survey->template == SURVEY_CIQ) {
            // print out answers for critical incidents
            $table = NULL;
            $table->align = array("left", "left");
            $questions = get_records_list("survey_questions", "id", $survey->questions);
            $questionorder = explode(",", $survey->questions);
            foreach ($questionorder as $key => $val) {
                $question = $questions[$val];
                $questiontext = get_string($question->shorttext, "survey");
                if ($answer = survey_get_user_answer($survey->id, $question->id, $user->id)) {
                    $answertext = "{$answer->answer1}";
                } else {
                    $answertext = "No answer";
                }
                $table->data[] = array("<b>{$questiontext}</b>", $answertext);
            }
            print_table($table);
        } else {
            survey_print_graph("id={$mod->id}&amp;sid={$user->id}&amp;type=student.png");
        }
    } else {
        print_string("notdone", "survey");
    }
}
Exemplo n.º 2
0
            echo $OUTPUT->box(get_string("peoplecompleted", "survey", $numusers));
            echo '<div class="resultgraph">';
            survey_print_graph("id={$cm->id}&amp;sid={$USER->id}&amp;group={$currentgroup}&amp;type=student.png");
            echo '</div>';
        } else {
            echo $OUTPUT->box(get_string("surveycompletednograph", "survey"));
            echo $OUTPUT->box(get_string("peoplecompleted", "survey", $numusers));
        }
    } else {
        echo $OUTPUT->box(format_module_intro('survey', $survey, $cm->id), 'generalbox', 'intro');
        echo $OUTPUT->spacer(array('height' => 30, 'width' => 1), true);
        // Should be done with CSS instead.
        $questions = survey_get_questions($survey);
        foreach ($questions as $question) {
            if ($question->type == 0 or $question->type == 1) {
                if ($answer = survey_get_user_answer($survey->id, $question->id, $USER->id)) {
                    $table = new html_table();
                    $table->head = array(get_string($question->text, "survey"));
                    $table->align = array("left");
                    $table->data[] = array(s($answer->answer1));
                    // No html here, just plain text.
                    echo html_writer::table($table);
                    echo $OUTPUT->spacer(array('height' => 30, 'width' => 1), true);
                }
            }
        }
    }
    echo $OUTPUT->footer();
    exit;
}
echo "<form method=\"post\" action=\"save.php\" id=\"surveyform\">";
Exemplo n.º 3
0
/**
 * @global stdObject
 * @global object
 * @uses SURVEY_CIQ
 * @param object $course
 * @param object $user
 * @param object $mod
 * @param object $survey
 */
function survey_user_complete($course, $user, $mod, $survey) {
    global $CFG, $DB, $OUTPUT;

    if (survey_already_done($survey->id, $user->id)) {
        if ($survey->template == SURVEY_CIQ) { // print out answers for critical incidents
            $table = new html_table();
            $table->align = array("left", "left");

            $questions = $DB->get_records_list("survey_questions", "id", explode(',', $survey->questions));
            $questionorder = explode(",", $survey->questions);

            foreach ($questionorder as $key=>$val) {
                $question = $questions[$val];
                $questiontext = get_string($question->shorttext, "survey");

                if ($answer = survey_get_user_answer($survey->id, $question->id, $user->id)) {
                    $answertext = "$answer->answer1";
                } else {
                    $answertext = "No answer";
                }
                $table->data[] = array("<b>$questiontext</b>", s($answertext));
            }
            echo html_writer::table($table);

        } else {

            survey_print_graph("id=$mod->id&amp;sid=$user->id&amp;type=student.png");
        }

    } else {
        print_string("notdone", "survey");
    }
}