$grpasidexists = true; } else { //use asid from first student assessment $grpasidexists = false; $query = "SELECT id,{$fieldstocopy} "; $query .= "FROM imas_assessment_sessions WHERE userid IN ({$stulist}) AND assessmentid='{$aid[0]}'"; $result = mysql_query($query) or die("Query failed : {$query}:" . mysql_error()); if (mysql_num_rows($result) > 0) { $row = mysql_fetch_row($result); $srcasid = array_shift($row); $rowgrptest = addslashes_deep($row); $rowgrptest[1] = $grpid; //use new groupid while ($row = mysql_fetch_row($result)) { //delete files from everyone else's attempts deleteasidfilesfromstring2($row[7] . $row[13], 'id', $row[0], $row[1]); } } } if ($rowgrptest != '') { //if an assessment session already exists $fieldstocopyarr = explode(',', $fieldstocopy); $insrow = "'" . implode("','", $rowgrptest) . "'"; if ($grpasidexists == false) { //asid coming from added group member. Also copy to any existing group members $stustoadd = array_merge($stustoadd, $existinggrpmembers); } foreach ($stustoadd as $stuid) { $query = "SELECT id,agroupid FROM imas_assessment_sessions WHERE userid='{$stuid}' AND assessmentid={$aid[0]}"; $result = mysql_query($query) or die("Query failed : {$query}:" . mysql_error()); if (mysql_num_rows($result) > 0) {
$scores = explode(',', $sp[0]); $rawscores = explode(',', $sp[1]); $sp = explode(';', $line['bestscores']); $bestscores = explode(',', $sp[0]); $bestrawscores = explode(',', $sp[1]); $firstrawscores = explode(',', $sp[2]); $noraw = false; } $attempts = explode(",", $line['attempts']); $lastanswers = explode("~", $line['lastanswers']); $reattempting = explode(',', $line['reattempting']); $bestattempts = explode(",", $line['bestattempts']); $bestlastanswers = explode("~", $line['bestlastanswers']); $clearid = $_GET['clearq']; if ($clearid !== '' && is_numeric($clearid) && isset($scores[$clearid])) { deleteasidfilesfromstring2($lastanswers[$clearid] . $bestlastanswers[$clearid], $qp[0], $qp[1], $qp[2]); $scores[$clearid] = -1; $attempts[$clearid] = 0; $lastanswers[$clearid] = ''; $bestscores[$clearid] = -1; $bestattempts[$clearid] = 0; $bestlastanswers[$clearid] = ''; if (!$noraw) { $rawscores[$clearid] = -1; $bestrawscores[$clearid] = -1; $firstscores[$clearid] = -1; } $loc = array_search($clearid, $reattempting); if ($loc !== false) { array_splice($reattempting, $loc, 1); }
function deletefilesifnotused($delfrom, $ifnothere) { global $testsettings, $sessiondata, $testid, $isreview; $outstr = ''; preg_match_all('/@FILE:(.+?)@/', $delfrom, $matches); foreach ($matches[0] as $match) { if (strpos($ifnothere, $match) === false) { $outstr .= $match; } } require_once "../includes/filehandler.php"; if ($testsettings['isgroup'] > 0 && $sessiondata['groupid'] > 0 && !$isreview) { deleteasidfilesfromstring2($outstr, 'agroupid', $sessiondata['groupid'], $testsettings['id']); } else { deleteasidfilesfromstring2($outstr, 'id', $testid, $testsettings['id']); } //deleteasidfilesfromstring($outstr); }