Example #1
0
 list($firstname, $lastname, $email) = mysql_fetch_row($result);
 $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 {
Example #2
0
		<?php 
        //not done with assessment.
        $page_formAction = "drillassess.php?cid={$cid}&daid={$daid}";
        if ($showans) {
            echo "<form id=\"qform\" method=\"post\" enctype=\"multipart/form-data\" action=\"{$page_formAction}\"\">\n";
            echo "<p>Displaying last question with solution <input type=submit name=\"next\" value=\"New Question\"/></p>\n";
            echo "</form>\n";
            displayq(0, $curitemid, $seed, 2, true, 0);
        } else {
            if ($sa == 3) {
                $doshowans = 1;
            } else {
                $doshowans = 0;
            }
            echo "<form id=\"qform\" method=\"post\" enctype=\"multipart/form-data\" action=\"{$page_formAction}&score=true\" onsubmit=\"doonsubmit()\">\n";
            displayq(0, $curitemid, $seed, $doshowans, true, 0);
            if ($sa == 3) {
                echo "<input type=submit name=\"next\" value=\"Next Question\">\n";
            } else {
                echo "<input type=submit name=\"check\" value=\"Check Answer\">\n";
            }
            echo "</form>\n";
        }
    }
}
echo '</div>';
require "../footer.php";
function countcorrect($sca)
{
    $corr = 0;
    foreach ($sca as $sc) {
Example #3
0
 } else {
     $GLOBALS['questionscoreref'] = array("scorebox{$i}", $pts[$questions[$i]]);
 }
 if (isset($rawscores[$i])) {
     //$colors = scorestocolors($rawscores[$i],$pts[$questions[$i]],$answeights[$questions[$i]],false);
     if (strpos($rawscores[$i], '~') !== false) {
         $colors = explode('~', $rawscores[$i]);
     } else {
         $colors = array($rawscores[$i]);
     }
 } else {
     $colors = array();
 }
 $capturechoices = true;
 $choicesdata = array();
 $qtypes = displayq($i, $qsetid, $seeds[$i], $showa, false, $attempts[$i], false, false, false, $colors);
 echo '</div>';
 if ($scores[$i] == -1) {
     $scores[$i] = "N/A";
 } else {
     $total += getpts($scores[$i]);
 }
 echo "<div class=review>Question " . ($i + 1) . ": ";
 if ($withdrawn[$questions[$i]] == 1) {
     echo "<span class=\"red\">Question Withdrawn</span> ";
 }
 list($pt, $parts) = printscore($scores[$i]);
 if ($canedit && $parts == '') {
     echo "<input type=text size=4 id=\"scorebox{$i}\" name=\"{$i}\" value=\"{$pt}\">";
     if ($rubric[$questions[$i]] != 0) {
         echo printrubriclink($rubric[$questions[$i]], $pts[$questions[$i]], "scorebox{$i}", "feedback", $i + 1);
Example #4
0
<?php

require "../validate.php";
$id = intval($_GET['id']);
$sig = $_GET['sig'];
$t = intval($_GET['t']);
$sessiondata['coursetheme'] = $coursetheme;
$flexwidth = true;
require "header.php";
echo '<p><b style="font-size:110%">' . _('Written Example') . '</b> ' . _('of a similar problem') . '</p>';
if ($sig != md5($id . $sessiondata['secsalt'])) {
    echo "invalid signature - not authorized to view the solution for this problem";
}
require "displayq2.php";
$txt = displayq(0, $id, 0, false, false, 0, 2 + $t);
echo filter($txt);
require "../footer.php";
Example #5
0
        ?>
&offset=<?php 
        echo $offset;
        ?>
&lib=<?php 
        echo $lib;
        ?>
" onsubmit="doonsubmit()">
		<input type=hidden name=seed value="<?php 
        echo $seed;
        ?>
">
		
<?php 
        unset($lastanswers);
        displayq(0, $qsetid, $seed, true, true, 0);
        ?>
		<input type=submit value="Submit">
	</form>
<?php 
        if ($source == 0) {
            echo "\t<p><a href=\"reviewlibrary.php?cid={$cid}&offset={$offset}&lib={$lib}&source=1\">View/Modify Question Code</a></p>\n";
        } else {
            ?>
	<p>
		<a href="reviewlibrary.php?cid=<?php 
            echo $cid;
            ?>
&offset=<?php 
            echo $offset;
            ?>
Example #6
0
require "./assessment/header.php";
if ($page_scoreMsg != '' && !isset($_GET['noscores'])) {
    echo '<div class="review">' . _('Score on last question:') . $page_scoreMsg;
    echo '</div>';
}
if ($showans) {
    echo "<form id=\"qform\" method=\"post\" enctype=\"multipart/form-data\" action=\"{$page_formAction}\" onsubmit=\"doonsubmit()\">\n";
    echo "<p>" . _('Displaying last question with solution') . " <input type=submit name=\"next\" value=\"" . _('New Question') . "\"/></p>\n";
    displayq(0, $qsetid, $seed, 2, true, 0);
    echo "</form>\n";
} else {
    $doshowans = 0;
    echo "<form id=\"qform\" method=\"post\" enctype=\"multipart/form-data\" action=\"{$page_formAction}\" onsubmit=\"doonsubmit()\">\n";
    echo "<input type=\"hidden\" name=\"seed\" value=\"{$seed}\" />";
    $lastanswers = array();
    displayq(0, $qsetid, $seed, $doshowans, true, 0);
    echo "<input type=submit name=\"check\" value=\"" . _('Check Answer') . "\">\n";
    echo "</form>\n";
}
require "./footer.php";
function getansweights($code, $seed)
{
    $foundweights = false;
    if (($p = strpos($code, 'answeights')) !== false || strpos($code, 'anstypes') === false) {
        $p = strpos($code, "\n", $p);
        $weights = sandboxgetweights($code, $seed);
        if (is_array($weights)) {
            return $weights;
        }
    }
    if (!$foundweights) {
Example #7
0
function basicshowq($qn, $seqinactive = false, $colors = array())
{
    global $showansduring, $questions, $testsettings, $qi, $seeds, $showhints, $attempts, $regenonreattempt, $showansafterlast, $showeachscore, $noraw, $rawscores;
    $qshowansduring = $showansduring && $qi[$questions[$qn]]['showans'] == '0';
    $qshowansafterlast = $showansafterlast && $qi[$questions[$qn]]['showans'] == '0' || $qi[$questions[$qn]]['showans'] == 'F' || $qi[$questions[$qn]]['showans'] == 'J';
    if (canimprove($qn)) {
        if ($qshowansduring && $attempts[$qn] >= $testsettings['showans']) {
            $showa = true;
        } else {
            $showa = false;
        }
    } else {
        $showa = ($qshowansduring || $qshowansafterlast) && $showeachscore;
    }
    $regen = ($regenonreattempt && $qi[$questions[$qn]]['regen'] == 0 || $qi[$questions[$qn]]['regen'] == 1) && amreattempting($qn);
    $thisshowhints = $qi[$questions[$qn]]['showhints'] == 2 || $qi[$questions[$qn]]['showhints'] == 0 && $showhints;
    if (!$noraw && $showeachscore) {
        //&& $GLOBALS['questionmanualgrade'] != true) {
        //$colors = scorestocolors($rawscores[$qn], '', $qi[$questions[$qn]]['answeights'], $noraw);
        if (strpos($rawscores[$qn], '~') !== false) {
            $colors = explode('~', $rawscores[$qn]);
        } else {
            $colors = array($rawscores[$qn]);
        }
    }
    if (!$seqinactive) {
        displayq($qn, $qi[$questions[$qn]]['questionsetid'], $seeds[$qn], $showa, $thisshowhints, $attempts[$qn], false, $regen, $seqinactive, $colors);
    } else {
        displayq($qn, $qi[$questions[$qn]]['questionsetid'], $seeds[$qn], $showa, false, $attempts[$qn], false, $regen, $seqinactive, $colors);
    }
}
Example #8
0
function showscores($questions, $attempts, $testsettings)
{
    global $isdiag, $allowregen, $isreview, $noindivscores, $scores, $bestscores, $qi, $superdone, $timelimitkickout, $reviewatend;
    $total = 0;
    $lastattempttotal = 0;
    for ($i = 0; $i < count($bestscores); $i++) {
        if (getpts($bestscores[$i]) > 0) {
            $total += getpts($bestscores[$i]);
        }
        if (getpts($scores[$i]) > 0) {
            $lastattempttotal += getpts($scores[$i]);
        }
    }
    $totpossible = totalpointspossible($qi);
    $average = round(100 * (double) $total / (double) $totpossible, 1);
    $doendredirect = false;
    $outmsg = '';
    if ($testsettings['endmsg'] != '') {
        $endmsg = unserialize($testsettings['endmsg']);
        $redirecturl = '';
        if (isset($endmsg['msgs'])) {
            foreach ($endmsg['msgs'] as $sc => $msg) {
                //array must be reverse sorted
                if ($endmsg['type'] == 0 && $total >= $sc || $endmsg['type'] == 1 && $average >= $sc) {
                    $outmsg = $msg;
                    break;
                }
            }
            if ($outmsg == '') {
                $outmsg = $endmsg['def'];
            }
            if (!isset($endmsg['commonmsg'])) {
                $endmsg['commonmsg'] = '';
            }
            if (strpos($outmsg, 'redirectto:') !== false) {
                $redirecturl = trim(substr($outmsg, 11));
                echo "<input type=\"button\" value=\"", _('Continue'), "\" onclick=\"window.location.href='{$redirecturl}'\"/>";
                return false;
            }
        }
    }
    if ($isdiag) {
        global $userid;
        $query = "SELECT * from imas_users WHERE id='{$userid}'";
        $result = mysql_query($query) or die("Query failed : " . mysql_error());
        $userinfo = mysql_fetch_array($result, MYSQL_ASSOC);
        echo "<h3>{$userinfo['LastName']}, {$userinfo['FirstName']}: ";
        echo substr($userinfo['SID'], 0, strpos($userinfo['SID'], '~'));
        echo "</h3>\n";
    }
    echo "<h3>", _('Scores:'), "</h3>\n";
    if (!$noindivscores && !$reviewatend) {
        echo "<table class=scores>";
        for ($i = 0; $i < count($scores); $i++) {
            echo "<tr><td>";
            if ($bestscores[$i] == -1) {
                $bestscores[$i] = 0;
            }
            if ($scores[$i] == -1) {
                $scores[$i] = 0;
                echo _('Question') . ' ' . ($i + 1) . ': </td><td>';
                echo _('Last attempt: ');
                echo _('Not answered');
                echo "</td>";
                echo "<td>  ", _('Score in Gradebook: ');
                echo printscore($bestscores[$i], $i);
                echo "</td>";
                echo "</tr>\n";
            } else {
                echo _('Question') . ' ' . ($i + 1) . ': </td><td>';
                echo _('Last attempt: ');
                echo printscore($scores[$i], $i);
                echo "</td>";
                echo "<td>  ", _('Score in Gradebook: ');
                echo printscore($bestscores[$i], $i);
                echo "</td>";
                echo "</tr>\n";
            }
        }
        echo "</table>";
    }
    global $testid;
    recordtestdata();
    if ($testsettings['testtype'] != "NoScores") {
        echo "<p>", sprintf(_('Total Points on Last Attempts:  %d out of %d possible'), $lastattempttotal, $totpossible), "</p>\n";
        //if ($total<$testsettings['minscore']) {
        if ($testsettings['minscore'] < 10000 && $total < $testsettings['minscore'] || $testsettings['minscore'] > 10000 && $total < ($testsettings['minscore'] - 10000) / 100 * $totpossible) {
            echo "<p><b>", sprintf(_('Total Points Earned:  %d out of %d possible: '), $total, $totpossible);
        } else {
            echo "<p><b>", sprintf(_('Total Points in Gradebook: %d out of %d possible: '), $total, $totpossible);
        }
        echo "{$average} % </b></p>\n";
        if ($outmsg != '') {
            echo "<p style=\"color:red;font-weight: bold;\">{$outmsg}</p>";
            if ($endmsg['commonmsg'] != '' && $endmsg['commonmsg'] != '<p></p>') {
                echo $endmsg['commonmsg'];
            }
        }
        //if ($total<$testsettings['minscore']) {
        if ($testsettings['minscore'] < 10000 && $total < $testsettings['minscore'] || $testsettings['minscore'] > 10000 && $total < ($testsettings['minscore'] - 10000) / 100 * $totpossible) {
            if ($testsettings['minscore'] < 10000) {
                $reqscore = $testsettings['minscore'];
            } else {
                $reqscore = $testsettings['minscore'] - 10000 . '%';
            }
            echo "<p><span style=\"color:red;\"><b>", sprintf(_('A score of %s is required to receive credit for this assessment'), $reqscore), "<br/>", _('Grade in Gradebook: No Credit (NC)'), "</span></p> ";
        }
    } else {
        echo "<p><b>", _('Your scores have been recorded for this assessment.'), "</b></p>";
    }
    //if timelimit is exceeded
    $now = time();
    if (!$timelimitkickout && $testsettings['timelimit'] > 0 && $now - $GLOBALS['starttime'] > $testsettings['timelimit']) {
        $over = $now - $GLOBALS['starttime'] - $testsettings['timelimit'];
        echo "<p>", _('Time limit exceeded by'), " ";
        if ($over > 60) {
            $overmin = floor($over / 60);
            echo "{$overmin} ", _('minutes'), ", ";
            $over = $over - $overmin * 60;
        }
        echo "{$over} ", _('seconds'), ".<br/>\n";
        echo _('Grade is subject to acceptance by the instructor'), "</p>\n";
    }
    if (!$superdone) {
        // $total < $totpossible &&
        if ($noindivscores) {
            echo "<p>", _('<a href="showtest.php?reattempt=all">Reattempt assessment</a> on questions allowed (note: where reattempts are allowed, all scores, correct and incorrect, will be cleared)'), "</p>";
        } else {
            if (canimproveany()) {
                echo "<p>", _('<a href="showtest.php?reattempt=canimprove">Reattempt assessment</a> on questions that can be improved where allowed'), "</p>";
            }
            if (hasreattemptsany()) {
                echo "<p>", _('<a href="showtest.php?reattempt=all">Reattempt assessment</a> on all questions where allowed'), "</p>";
            }
        }
        if ($allowregen) {
            echo "<p>", _('<a href="showtest.php?regenall=missed">Try similar problems</a> for all questions with less than perfect scores where allowed.'), "</p>";
            echo "<p>", _('<a href="showtest.php?regenall=all">Try similar problems</a> for all questions where allowed.'), "</p>";
        }
    }
    if ($testsettings['testtype'] != "NoScores") {
        $hascatset = false;
        foreach ($qi as $qii) {
            if ($qii['category'] != '0') {
                $hascatset = true;
                break;
            }
        }
        if ($hascatset) {
            include "../assessment/catscores.php";
            catscores($questions, $bestscores, $testsettings['defpoints'], $testsettings['defoutcome'], $testsettings['courseid']);
        }
    }
    if ($reviewatend) {
        global $testtype, $scores, $saenddate, $isteacher, $istutor, $seeds, $attempts, $rawscores, $noraw;
        $showa = false;
        for ($i = 0; $i < count($questions); $i++) {
            echo '<div>';
            if (!$noraw) {
                if (strpos($rawscores[$i], '~') !== false) {
                    $col = explode('~', $rawscores[$i]);
                } else {
                    $col = array($rawscores[$i]);
                }
            } else {
                $col = scorestocolors($noraw ? $scores[$i] : $rawscores[$i], $qi[$questions[$i]]['points'], $qi[$questions[$i]]['answeights'], $noraw);
            }
            displayq($i, $qi[$questions[$i]]['questionsetid'], $seeds[$i], $showa, false, $attempts[$i], false, false, false, $col);
            echo "<div class=review>", _('Question') . " " . ($i + 1) . ". ", _('Last Attempt:');
            echo printscore($scores[$i], $i);
            echo '<br/>', _('Score in Gradebook: ');
            echo printscore($bestscores[$i], $i);
            echo '</div>';
        }
    }
    return true;
}
Example #9
0
            $rawscores = array();
        } else {
            $seed = rand(1, 9999);
        }
        $doshowans = 0;
        echo "<form id=\"qform\" method=\"post\" enctype=\"multipart/form-data\" action=\"{$page_formAction}\" onsubmit=\"doonsubmit()\">\n";
        echo "<input type=\"hidden\" name=\"seed\" value=\"{$seed}\" />";
        if (isset($_GET['auth'])) {
            echo '<input type="hidden" name="auth" value="' . $_GET['auth'] . '"/>';
        }
        if (isset($_GET['showhints']) && $_GET['showhints'] == 0) {
            $showhints = false;
        } else {
            $showhints = true;
        }
        displayq(0, $qsetid, $seed, $doshowans, $showhints, 0);
        if ($jssubmit) {
            echo '<input type="submit" id="submitbutton" style="display:none;"/>';
            echo '<script type="text/javascript">
		$(function() {
			$(window).on("message", function(e) {
				var data = e.originalEvent.data;
				if (data=="submit") {
					$("#submitbutton").click();
				}});
		});
		</script>';
        } else {
            echo "<input type=submit name=\"check\" value=\"" . _('Submit') . "\">\n";
        }
        echo "</form>\n";
Example #10
0
                                $laarr[$k] = $tmp[0];
                            }
                        }
                        echo str_replace(array('&', '%nbsp;'), array('; ', '&nbsp;'), strip_tags($laarr[$k]));
                    }
                    $cnt++;
                }
            }
            echo '. ';
        }
        if ($timesontask[$i] != '') {
            echo 'Average time per submission: ';
            $timesarr = explode('~', $timesontask[$i]);
            $avgtime = array_sum($timesarr) / count($timesarr);
            if ($avgtime < 60) {
                echo round($avgtime, 1) . ' seconds ';
            } else {
                echo round($avgtime / 60, 1) . ' minutes ';
            }
            echo '<br/>';
        }
        echo '</div>';
    } else {
        displayq($i, $qsetid, $seeds[$i], $showa, $testsettings['showhints'] == 1, $attempts[$i]);
    }
    echo "<hr />";
    echo '</div>';
}
if ($endtext != '') {
    echo '<div class="intro">' . $endtext . '</div>';
}
Example #11
0
     		}
     		*/
     $answeights = getansweights($loc, $qcontrol);
     for ($i = 0; $i < count($answeights) - 1; $i++) {
         $answeights[$i] = round($answeights[$i] * $points, 2);
     }
     //adjust for rounding
     $diff = $points - array_sum($answeights);
     $answeights[count($answeights) - 1] += $diff;
 }
 if ($qtype == 'multipart') {
     $GLOBALS['questionscoreref'] = array("ud-{$line['id']}-{$loc}", $answeights);
 } else {
     $GLOBALS['questionscoreref'] = array("ud-{$line['id']}-{$loc}", $points);
 }
 $qtypes = displayq($cnt, $qsetid, $seeds[$loc], true, false, $attempts[$loc]);
 echo '</div>';
 echo "<div class=review>";
 echo '<span class="person">' . $line['LastName'] . ', ' . $line['FirstName'] . ': </span>';
 if (!$groupdup) {
     echo '<span class="group" style="display:none">' . $groupnames[$line['agroupid']] . ': </span>';
 }
 if ($isgroup) {
 }
 list($pt, $parts) = printscore($scores[$loc]);
 if ($parts == '') {
     if ($pt == -1) {
         $pt = 'N/A';
     }
     echo "<input type=text size=4 id=\"ud-{$line['id']}-{$loc}\" name=\"ud-{$line['id']}-{$loc}\" value=\"{$pt}\">";
     if ($rubric != 0) {
Example #12
0
     if (strpos($rawscores, '~') !== false) {
         $colors = explode('~', $rawscores);
     } else {
         $colors = array($rawscores);
         //scorestocolors($rawscores,1,0,false);
     }
 } else {
     $colors = array();
 }
 displayq(0, $_GET['qsetid'], $seed, true, true, $attempt, false, false, false, $colors);
 echo "<input type=submit value=\"Submit\"><input type=submit name=\"regen\" value=\"Submit and Regen\">\n";
 echo "<input type=button value=\"White Background\" onClick=\"whiteout()\"/>";
 echo "<input type=button value=\"Show HTML\" onClick=\"document.getElementById('qhtml').style.display='';\"/>";
 echo "</form>\n";
 echo '<code id="qhtml" style="display:none">';
 $message = displayq(0, $_GET['qsetid'], $seed, false, false, 0, true);
 $message = printfilter(forcefiltergraph($message));
 $message = preg_replace('/(`[^`]*`)/', "<span class=\"AM\">\$1</span>", $message);
 $message = str_replacE('`', '\\`', $message);
 echo htmlentities($message);
 echo '</code>';
 if (isset($CFG['GEN']['sendquestionproblemsthroughcourse'])) {
     echo "<p>Question id: {$_GET['qsetid']}.  <a href=\"{$imasroot}/msgs/msglist.php?add=new&cid={$CFG['GEN']['sendquestionproblemsthroughcourse']}&to={$line['ownerid']}&title=Problem%20with%20question%20id%20{$_GET['qsetid']}\" target=\"_blank\">Message owner</a> to report problems</p>";
 } else {
     echo "<p>Question id: {$_GET['qsetid']}.  <a href=\"mailto:{$line['email']}?subject=Problem%20with%20question%20id%20{$_GET['qsetid']}\">E-mail owner</a> to report problems</p>";
 }
 echo "<p>Description: {$line['description']}</p><p>Author: {$line['author']}</p>";
 echo "<p>Last Modified: {$lastmod}</p>";
 if ($line['deleted'] == 1) {
     echo '<p style="color:red;">This question has been marked for deletion.  This might indicate there is an error in the question. ';
     echo 'It is recommended you discontinue use of this question when possible</p>';
Example #13
0
        $itemarr[] = $itel;
        $itemnum[$itel] = $k + 1;
    }
}
echo '<p style="color:#f00;">Warning: Results are not accurate or meaningful for randomized questions</p>';
require "../assessment/displayq2.php";
$questions = array_keys($qdata);
foreach ($itemarr as $k => $q) {
    echo '<div style="border:1px solid #000;padding:10px;margin-bottom:10px;clear:left;">';
    echo '<p><span style="float:right">(Question ID ' . $qsids[$q] . ')</span><b>' . $qsdata[$qsids[$q]][2] . '</b></p>';
    echo '<br class="clear"/>';
    echo '<div style="float:left;width:35%;">';
    showresults($q, $qsdata[$qsids[$q]][0]);
    echo '</div>';
    echo '<div style="float:left;width:60%;margin-left:10px;">';
    displayq($k, $qsids[$q], 0, 0, 0, 0);
    echo '</div>';
    echo '<br class="clear"/>';
    echo '</div>';
}
require "../footer.php";
function showresults($q, $qtype)
{
    global $qdata, $qsids, $qsdata;
    eval(interpret('control', $qtype, $qsdata[$qsids[$q]][1]));
    if ($qtype == 'choices' || $qtype == 'multans' || $qtype == 'multipart') {
        if (isset($choices) && !isset($questions)) {
            $questions =& $choices;
        }
        if ($qtype == 'multipart') {
            if (!is_array($anstypes)) {