$sessdata = mysql_fetch_array($result, MYSQL_ASSOC); $curitem = $sessdata['curitem']; $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']}'";
function scorequestion($qn, $rectime = true) { global $questions, $scores, $seeds, $testsettings, $qi, $attempts, $lastanswers, $isreview, $bestquestions, $bestseeds, $bestscores, $bestattempts, $bestlastanswers, $reattempting, $rawscores, $bestrawscores, $firstrawscores; global $regenonreattempt, $sessiondata; //list($qsetid,$cat) = getqsetid($questions[$qn]); $lastrawscore = $rawscores[$qn]; list($unitrawscore, $rawscores[$qn]) = scoreq($qn, $qi[$questions[$qn]]['questionsetid'], $seeds[$qn], $_POST["qn{$qn}"], $attempts[$qn], $qi[$questions[$qn]]['points']); $afterpenalty = calcpointsafterpenalty($unitrawscore, $qi[$questions[$qn]], $testsettings, $attempts[$qn]); $rawscore = calcpointsafterpenalty($unitrawscore, $qi[$questions[$qn]], $testsettings, 0); //possible $noscores = $testsettings['testtype'] == "NoScores"; //work in progress //need to rework canimprove if (!$regenonreattempt && $attempts[$qn] > 0 && strpos($afterpenalty, '~') !== false && !$noscores) { $appts = explode('~', $afterpenalty); $prepts = explode('~', $rawscore); $curs = explode('~', $scores[$qn]); if (count($appts) != count($curs)) { //number of parts has changed - ignore previous work $scores[$qn] = $afterpenalty; } else { for ($k = 0; $k < count($curs); $k++) { if ($appts[$k] > $curs[$k]) { //part after penalty better than orig, replace $curs[$k] = $appts[$k]; } if ($prepts[$k] < $curs[$k]) { //changed correct to incorrect, take away pts $curs[$k] = $appts[$k]; } } $scores[$qn] = implode('~', $curs); } } else { $scores[$qn] = $afterpenalty; } if (!$isreview && $attempts[$qn] == 0 && strpos($lastanswers[$qn], '##') === false && !$sessiondata['isteacher']) { $firstrawscores[$qn] = $rawscores[$qn]; if ($rectime) { global $timesontask; $time = explode('~', $timesontask[$qn]); $time = $time[0]; } else { $time = 0; //for all at once display, where time is not useful info } $query = "INSERT INTO imas_firstscores (courseid,qsetid,score,scoredet,timespent) VALUES "; $query .= "('" . addslashes($testsettings['courseid']) . "','" . $qi[$questions[$qn]]['questionsetid'] . "','" . round(100 * getpts($unitrawscore)) . "','" . $rawscores[$qn] . "','{$time}')"; mysql_query($query) or die("Query failed : " . mysql_error()); } //$scores[$qn] = $afterpenalty; $attempts[$qn]++; $loc = array_search($qn, $reattempting); if ($loc !== false) { array_splice($reattempting, $loc, 1); } if ((getpts($scores[$qn]) >= getpts($bestscores[$qn]) || $noscores && ($lastrawscore != $rawscores[$qn] || $rawscore == 0)) && !$isreview) { $bestseeds[$qn] = $seeds[$qn]; $bestscores[$qn] = $scores[$qn]; $bestrawscores[$qn] = $rawscores[$qn]; $bestattempts[$qn] = $attempts[$qn]; deletefilesifnotused($bestlastanswers[$qn], $lastanswers[$qn]); $bestlastanswers[$qn] = $lastanswers[$qn]; $bestquestions[$qn] = $questions[$qn]; } return $rawscore; }
if (empty($_GET['id'])) { echo 'Need to supply an id'; exit; } $qsetid = $_GET['id']; $sessiondata['coursetheme'] = $coursetheme; $page_formAction = "embedq.php?id={$qsetid}"; if (isset($_GET['noscores'])) { $page_formAction .= '&noscores=true'; } if (isset($_GET['noregen'])) { $page_formAction .= '&noregen=true'; } $showans = false; if (isset($_POST['seed'])) { list($score, $rawscores) = scoreq(0, $qsetid, $_POST['seed'], $_POST['qn0']); if (strpos($score, '~') === false) { $after = round($score, 1); 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);
$formn = $_GET['formn']; $loc = $_GET['loc']; if (isset($_GET['checked']) || isset($_GET['usecheck'])) { $chk = "&checked=0"; } else { $chk = ''; } if ($onlychk == 1) { $page_onlyChkMsg = "var prevnext = window.opener.getnextprev('{$formn}','{$_GET['loc']}',true);"; } else { $page_onlyChkMsg = "var prevnext = window.opener.getnextprev('{$formn}','{$_GET['loc']}');"; } } $lastanswers = array(''); if (isset($_POST['seed'])) { list($score, $rawscores) = scoreq(0, $_GET['qsetid'], $_POST['seed'], $_POST['qn0'], $attempt - 1); $scores[0] = $score; $lastanswers[0] = stripslashes($lastanswers[0]); $page_scoreMsg = "<p>Score on last answer: {$score}/1</p>\n"; } else { $page_scoreMsg = ""; $scores = array(-1); $_SESSION['choicemap'] = array(); } $page_formAction = "testquestion.php?cid={$_GET['cid']}&qsetid={$_GET['qsetid']}"; if (isset($_POST['usecheck'])) { $page_formAction .= "&checked=" . $_GET['usecheck']; } else { if (isset($_GET['checked'])) { $page_formAction .= "&checked=" . $_GET['checked']; }