示例#1
0
function printq($qn, $qsetid, $seed, $pts)
{
    global $isfinal, $imasroot;
    srand($seed);
    $query = "SELECT qtype,control,qcontrol,qtext,answer,hasimg FROM imas_questionset WHERE id='{$qsetid}'";
    $result = mysql_query($query) or die("Query failed : " . mysql_error());
    $qdata = mysql_fetch_array($result, MYSQL_ASSOC);
    if ($qdata['hasimg'] > 0) {
        $query = "SELECT var,filename,alttext FROM imas_qimages WHERE qsetid='{$qsetid}'";
        $result = mysql_query($query) or die("Query failed : " . mysql_error());
        while ($row = mysql_fetch_row($result)) {
            ${$row[0]} = "<img src=\"{$imasroot}/assessment/qimages/{$row[1]}\" alt=\"{$row[2]}\" />";
        }
    }
    eval(interpret('control', $qdata['qtype'], $qdata['control']));
    eval(interpret('qcontrol', $qdata['qtype'], $qdata['qcontrol']));
    $toevalqtxt = interpret('qtext', $qdata['qtype'], $qdata['qtext']);
    $toevalqtxt = str_replace('\\', '\\\\', $toevalqtxt);
    $toevalqtxt = str_replace(array('\\\\n', '\\\\"', '\\\\$', '\\\\{'), array('\\n', '\\"', '\\$', '\\{'), $toevalqtxt);
    srand($seed + 1);
    eval(interpret('answer', $qdata['qtype'], $qdata['answer']));
    srand($seed + 2);
    $la = '';
    if (isset($choices) && !isset($questions)) {
        $questions =& $choices;
    }
    if (isset($variable) && !isset($variables)) {
        $variables =& $variable;
    }
    if ($displayformat == "select") {
        unset($displayformat);
    }
    //pack options
    if (isset($ansprompt)) {
        $options['ansprompt'] = $ansprompt;
    }
    if (isset($displayformat)) {
        $options['displayformat'] = $displayformat;
    }
    if (isset($answerformat)) {
        $options['answerformat'] = $answerformat;
    }
    if (isset($questions)) {
        $options['questions'] = $questions;
    }
    if (isset($answers)) {
        $options['answers'] = $answers;
    }
    if (isset($answer)) {
        $options['answer'] = $answer;
    }
    if (isset($questiontitle)) {
        $options['questiontitle'] = $questiontitle;
    }
    if (isset($answertitle)) {
        $options['answertitle'] = $answertitle;
    }
    if (isset($answersize)) {
        $options['answersize'] = $answersize;
    }
    if (isset($variables)) {
        $options['variables'] = $variables;
    }
    if (isset($domain)) {
        $options['domain'] = $domain;
    }
    if (isset($answerboxsize)) {
        $options['answerboxsize'] = $answerboxsize;
    }
    if (isset($hidepreview)) {
        $options['hidepreview'] = $hidepreview;
    }
    if (isset($matchlist)) {
        $options['matchlist'] = $matchlist;
    }
    if (isset($noshuffle)) {
        $options['noshuffle'] = $noshuffle;
    }
    if (isset($reqdecimals)) {
        $options['reqdecimals'] = $reqdecimals;
    }
    if (isset($grid)) {
        $options['grid'] = $grid;
    }
    if (isset($background)) {
        $options['background'] = $background;
    }
    if ($qdata['qtype'] == "multipart") {
        if (!is_array($anstypes)) {
            $anstypes = explode(",", $anstypes);
        }
        $laparts = explode("&", $la);
        foreach ($anstypes as $kidx => $anstype) {
            list($answerbox[$kidx], $tips[$kidx], $shans[$kidx]) = makeanswerbox($anstype, $kidx, $laparts[$kidx], $options, $qn + 1);
        }
    } else {
        list($answerbox, $tips[0], $shans[0]) = makeanswerbox($qdata['qtype'], $qn, $la, $options, 0);
    }
    echo "<div class=q>";
    if ($isfinal) {
        echo "<div class=\"trq{$qn}\">\n";
    } else {
        echo "<div class=m id=\"trq{$qn}\">\n";
    }
    echo "<div class=qnum>" . ($qn + 1) . ") ";
    if (isset($_POST['points'])) {
        echo '<br/>' . $pts . 'pts';
    }
    echo "</div>\n";
    //end qnum div
    echo "<div class=floatl><div>\n";
    //echo $toevalqtext;
    eval("\$evaledqtext = \"{$toevalqtxt}\";");
    echo printfilter(filter($evaledqtext));
    echo "</div>\n";
    //end question div
    if (strpos($toevalqtxt, '$answerbox') === false) {
        if (is_array($answerbox)) {
            foreach ($answerbox as $iidx => $abox) {
                echo printfilter(filter("<div>{$abox}</div>\n"));
                echo "<div class=spacer>&nbsp;</div>\n";
            }
        } else {
            //one question only
            echo printfilter(filter("<div>{$answerbox}</div>\n"));
        }
    }
    echo "</div>\n";
    //end floatl div
    echo "</div>";
    //end m div
    if (!$isfinal) {
        echo "<div class=cbutn>\n";
        echo "<p><input type=button value=\"+1\" onclick=\"incspace({$qn},1)\"><input type=button value=\"+.5\" onclick=\"incspace({$qn},.5)\"><input type=button value=\"+.25\" onclick=\"incspace({$qn},.25)\"><input type=button value=\"+.1\" onclick=\"incspace({$qn},.1)\"><br/>";
        echo "<input type=button value=\"-1\" onclick=\"incspace({$qn},-1)\"><input type=button value=\"-.5\" onclick=\"incspace({$qn},-.5)\"><input type=button value=\"-.25\" onclick=\"incspace({$qn},-.25)\"><input type=button value=\"-.1\" onclick=\"incspace({$qn},-.1)\"></p>";
        echo "</div>\n";
        //end cbutn div
    }
    echo "&nbsp;";
    echo "</div>\n";
    //end q div
    if (!isset($showanswer)) {
        return $shans;
    } else {
        return $showanswer;
    }
}
示例#2
0
 $useeditor = "message";
 require "../header.php";
 if ($_GET['sendtype'] == 'msg') {
     echo '<h2>New Message</h2>';
     $to = "{$lastname}, {$firstname}";
 } else {
     if ($_GET['sendtype'] == 'email') {
         echo '<h2>New Email</h2>';
         $to = "{$lastname}, {$firstname} ({$email})";
     }
 }
 if (isset($_GET['quoteq'])) {
     require "../assessment/displayq2.php";
     $parts = explode('-', $_GET['quoteq']);
     $message = displayq($parts[0], $parts[1], $parts[2], false, false, 0, true);
     $message = printfilter(forcefiltergraph($message));
     $message = preg_replace('/(`[^`]*`)/', "<span class=\"AM\">\$1</span>", $message);
     $message = '<p> </p><br/><hr/>' . $message;
     $courseid = $cid;
     if (isset($parts[3])) {
         //sending to instructor
         $query = "SELECT name FROM imas_assessments WHERE id='" . intval($parts[3]) . "'";
         $result = mysql_query($query) or die("Query failed : {$query} " . mysql_error());
         $title = 'Question about #' . ($parts[0] + 1) . ' in ' . str_replace('"', '&quot;', mysql_result($result, 0, 0));
         if ($_GET['to'] == 'instr') {
             unset($_GET['to']);
             $msgset = 1;
             //force instructor only list
         }
     } else {
         $title = '';
示例#3
0
function printq($qn, $qsetid, $seed, $pts, $showpts)
{
    global $isfinal, $imasroot, $urlmode;
    $isbareprint = true;
    srand($seed);
    $query = "SELECT qtype,control,qcontrol,qtext,answer,hasimg FROM imas_questionset WHERE id='{$qsetid}'";
    $result = mysql_query($query) or die("Query failed : {$query} " . mysql_error());
    $qdata = mysql_fetch_array($result, MYSQL_ASSOC);
    if ($qdata['hasimg'] > 0) {
        $query = "SELECT var,filename,alttext FROM imas_qimages WHERE qsetid='{$qsetid}'";
        $result = mysql_query($query) or die("Query failed : {$query}" . mysql_error());
        while ($row = mysql_fetch_row($result)) {
            if (isset($GLOBALS['CFG']['GEN']['AWSforcoursefiles']) && $GLOBALS['CFG']['GEN']['AWSforcoursefiles'] == true) {
                ${$row[0]} = "<img src=\"{$urlmode}s3.amazonaws.com/{$GLOBALS['AWSbucket']}/qimages/{$row[1]}\" alt=\"" . htmlentities($row[2], ENT_QUOTES) . "\" />";
            } else {
                ${$row[0]} = "<img src=\"{$imasroot}/assessment/qimages/{$row[1]}\" alt=\"" . htmlentities($row[2], ENT_QUOTES) . "\" />";
            }
        }
    }
    eval(interpret('control', $qdata['qtype'], $qdata['control']));
    eval(interpret('qcontrol', $qdata['qtype'], $qdata['qcontrol']));
    $toevalqtxt = interpret('qtext', $qdata['qtype'], $qdata['qtext']);
    $toevalqtxt = str_replace('\\', '\\\\', $toevalqtxt);
    $toevalqtxt = str_replace(array('\\\\n', '\\\\"', '\\\\$', '\\\\{'), array('\\n', '\\"', '\\$', '\\{'), $toevalqtxt);
    srand($seed + 1);
    eval(interpret('answer', $qdata['qtype'], $qdata['answer']));
    srand($seed + 2);
    $la = '';
    if (isset($choices) && !isset($questions)) {
        $questions =& $choices;
    }
    if (isset($variable) && !isset($variables)) {
        $variables =& $variable;
    }
    if ($displayformat == "select") {
        unset($displayformat);
    }
    //pack options
    if (isset($ansprompt)) {
        $options['ansprompt'] = $ansprompt;
    }
    if (isset($displayformat)) {
        $options['displayformat'] = $displayformat;
    }
    if (isset($answerformat)) {
        $options['answerformat'] = $answerformat;
    }
    if (isset($questions)) {
        $options['questions'] = $questions;
    }
    if (isset($answers)) {
        $options['answers'] = $answers;
    }
    if (isset($answer)) {
        $options['answer'] = $answer;
    }
    if (isset($questiontitle)) {
        $options['questiontitle'] = $questiontitle;
    }
    if (isset($answertitle)) {
        $options['answertitle'] = $answertitle;
    }
    if (isset($answersize)) {
        $options['answersize'] = $answersize;
    }
    if (isset($variables)) {
        $options['variables'] = $variables;
    }
    if (isset($domain)) {
        $options['domain'] = $domain;
    }
    if (isset($answerboxsize)) {
        $options['answerboxsize'] = $answerboxsize;
    }
    if (isset($hidepreview)) {
        $options['hidepreview'] = $hidepreview;
    }
    if (isset($matchlist)) {
        $options['matchlist'] = $matchlist;
    }
    if (isset($noshuffle)) {
        $options['noshuffle'] = $noshuffle;
    }
    if (isset($reqdecimals)) {
        $options['reqdecimals'] = $reqdecimals;
    }
    if (isset($grid)) {
        $options['grid'] = $grid;
    }
    if (isset($background)) {
        $options['background'] = $background;
    }
    if ($qdata['qtype'] == "multipart") {
        if (!is_array($anstypes)) {
            $anstypes = explode(",", $anstypes);
        }
        $laparts = explode("&", $la);
        foreach ($anstypes as $kidx => $anstype) {
            list($answerbox[$kidx], $tips[$kidx], $shans[$kidx]) = makeanswerbox($anstype, $kidx, $laparts[$kidx], $options, $qn + 1);
        }
    } else {
        list($answerbox, $tips[0], $shans[0]) = makeanswerbox($qdata['qtype'], $qn, $la, $options, 0);
    }
    echo "<div class=q>";
    if ($isfinal) {
        echo "<div class=\"trq{$qn}\">\n";
    } else {
        echo "<div class=m id=\"trq{$qn}\">\n";
    }
    if ($showpts) {
        echo $qn + 1 . '. (' . $pts . ' pts) ';
    }
    echo "<div>\n";
    //echo $toevalqtext;
    eval("\$evaledqtext = \"{$toevalqtxt}\";");
    echo printfilter(filter($evaledqtext));
    echo "</div>\n";
    //end question div
    if (strpos($toevalqtxt, '$answerbox') === false) {
        if (is_array($answerbox)) {
            foreach ($answerbox as $iidx => $abox) {
                echo printfilter(filter("<div>{$abox}</div>\n"));
                echo "<div class=spacer>&nbsp;</div>\n";
            }
        } else {
            //one question only
            echo printfilter(filter("<div>{$answerbox}</div>\n"));
        }
    }
    echo "</div>";
    //end m div
    echo "&nbsp;";
    echo "</div>\n";
    //end q div
    if (!isset($showanswer)) {
        return $shans;
    } else {
        return $showanswer;
    }
}