Пример #1
0
    $curitemid = $itemids[$curitem];
    $seed = $sessdata['seed'];
    if ($sessdata['curscores'] == '') {
        $curscores = array();
    } else {
        $curscores = explode(',', $sessdata['curscores']);
    }
    $starttime = $sessdata['starttime'];
    $scorerec = unserialize($sessdata['scorerec']);
}
//score a submitted question
$showans = false;
if (isset($_GET['score'])) {
    list($score, $rawscores) = scoreq(0, $curitemid, $seed, $_POST['qn0']);
    $lastanswers[0] = stripslashes($lastanswers[0]);
    $page_scoreMsg = printscore($score, $curitemid, $seed);
    if (getpts($score) < 0.99 && $sa == 0) {
        $showans = true;
    } else {
        if (getpts($score) < 0.99 && $sa == 4) {
            unset($lastanswers);
        } else {
            unset($lastanswers);
            $seed = rand(1, 9999);
        }
    }
    $curscores[] = getpts($score);
    $scorelist = implode(',', $curscores);
    $query = "UPDATE imas_drillassess_sessions SET curscores='{$scorelist}',seed='{$seed}' WHERE id='{$sessdata['id']}'";
    mysql_query($query) or die("Query failed : " . mysql_error());
    if ($mode == 'cntdown') {
Пример #2
0
     $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);
     }
 } else {
     echo $pt;
 }
 if ($parts != '') {
     if ($canedit) {
         echo " (parts: ";
         $prts = explode(', ', $parts);
         for ($j = 0; $j < count($prts); $j++) {
             echo "<input type=text size=2 id=\"scorebox{$i}-{$j}\" name=\"{$i}-{$j}\" value=\"{$prts[$j]}\">";
             if ($rubric[$questions[$i]] != 0) {
Пример #3
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;
}
Пример #4
0
        if ($after < 0) {
            $after = 0;
        }
    } else {
        $fparts = explode('~', $score);
        $after = array();
        foreach ($fparts as $k => $fpart) {
            $after[$k] = round($fpart, 2);
            if ($after[$k] < 0) {
                $after[$k] = 0;
            }
        }
        $after = implode('~', $after);
    }
    $lastanswers[0] = stripslashes($lastanswers[0]);
    $page_scoreMsg = printscore($after, $qsetid, $_POST['seed']);
    $pts = getpts($after);
    $page_scoreMsg .= '<script type="text/javascript">
	function inIframe() {
	 try {
        	return window.self !== window.top;
         } catch (e) {
        	return true;
         }
	}
	if (inIframe()) {
		window.parent.postMessage(' . $pts . ',"*");
	}
	</script>';
    if (isset($_GET['noregen'])) {
        $seed = $_POST['seed'];
Пример #5
0
 $showa = $isteacher;
 if (isset($intropieces[$i + 1])) {
     echo '<div class="intro">' . $intropieces[$i + 1] . '</div>';
 }
 echo '<div class="nobreak">';
 if (isset($_GET['descr'])) {
     $query = "SELECT description FROM imas_questionset WHERE id='{$qsetid}'";
     $result = mysql_query($query) or die("Query failed : {$query}: " . mysql_error());
     echo '<div>ID:' . $qsetid . ', ' . mysql_result($result, 0, 0) . '</div>';
 } else {
     //list($points,$qattempts) = getpointspossible($questions[$i],$testsettings['defpoints'],$testsettings['defattempts']);
     $points = $qi[$questions[$i]]['points'];
     $qattempts = $qi[$questions[$i]]['attempts'];
     if ($scoredview) {
         echo "<div>#" . ($i + 1) . " ";
         echo printscore($scores[$i], $i);
         echo "</div>";
     } else {
         echo "<div>#" . ($i + 1) . " Points possible: {$points}.  Total attempts: {$qattempts}</div>";
     }
 }
 if ($scoredview) {
     //$col = scorestocolors($scores[$i], $qi[$questions[$i]]['points'], $qi[$questions[$i]]['answeights']);
     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 {