示例#1
0
/**
 * @global object
 * @global int
 * @param object $question
 */
function survey_print_single($question) {
    global $DB, $qnum, $OUTPUT;

    $rowclass = survey_question_rowclass(0);

    $qnum++;

    echo "<br />\n";
    echo "<table width=\"90%\" cellpadding=\"4\" cellspacing=\"0\">\n";
    echo "<tr class=\"$rowclass\">";
    echo "<th scope=\"row\" class=\"optioncell\"><label for=\"q$question->id\"><b class=\"qnumtopcell\">$qnum</b> &nbsp; ";
    echo "<span class=\"questioncell\">$question->text</span></label></th>\n";
    echo "<td class=\"questioncell smalltext\">\n";


    if ($question->type == 0) {           // Plain text field
        echo "<textarea rows=\"3\" cols=\"30\" name=\"q$question->id\" id=\"q$question->id\">$question->options</textarea>";

    } else if ($question->type > 0) {     // Choose one of a number
        $strchoose = get_string("choose");
        echo "<select name=\"q$question->id\" id=\"q$question->id\">";
        echo "<option value=\"0\" selected=\"selected\">$strchoose...</option>";
        $options = explode( ",", $question->options);
        foreach ($options as $key => $val) {
            $key++;
            echo "<option value=\"$key\">$val</option>";
        }
        echo "</select>";

    } else if ($question->type < 0) {     // Choose several of a number
        $options = explode( ",", $question->options);
        echo $OUTPUT->notification("This question type not supported yet");
    }

    echo "</td></tr></table>";

}
示例#2
0
function survey_print_single($question)
{
    global $db, $qnum;
    $rowclass = survey_question_rowclass(0);
    $qnum++;
    echo "<br />\n";
    echo "<table width=\"90%\" cellpadding=\"4\" cellspacing=\"0\">\n";
    echo "<tr class=\"{$rowclass}\">";
    echo "<td valign=\"top\"><b>{$qnum}</b></td>";
    echo "<td class=\"questioncell\">{$question->text}</td>\n";
    echo "<td class=\"questioncell\"><span class='smalltext'>\n";
    if ($question->type == 0) {
        // Plain text field
        echo "<textarea rows=\"3\" cols=\"30\" name=\"q{$question->id}\">{$question->options}</textarea>";
    } else {
        if ($question->type > 0) {
            // Choose one of a number
            $strchoose = get_string("choose");
            echo "<select name=\"q{$question->id}\">";
            echo "<option value=\"0\" selected=\"selected\">{$strchoose}...</option>";
            $options = explode(",", $question->options);
            foreach ($options as $key => $val) {
                $key++;
                echo "<option value=\"{$key}\">{$val}</option>";
            }
            echo "</select>";
        } else {
            if ($question->type < 0) {
                // Choose several of a number
                $options = explode(",", $question->options);
                notify("This question type not supported yet");
            }
        }
    }
    echo "</span></td></tr></table>";
}