function getansweights($qi, $code) { global $seeds, $questions; if (preg_match('/scoremethod\\s*=\\s*"(singlescore|acct|allornothing)"/', $code)) { return array(1); } $i = array_search($qi, $questions); return sandboxgetweights($code, $seeds[$i]); }
function getansweights($code, $seed) { $foundweights = false; $weights = sandboxgetweights($code, $seed); if (is_array($weights)) { return $weights; } else { return array(1); } }
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) { preg_match('/anstypes\\s*=(.*)/', $code, $match); $n = substr_count($match[1], ',') + 1; if ($n > 1) { $weights = array_fill(0, $n - 1, round(1 / $n, 3)); $weights[] = 1 - array_sum($weights); return $weights; } else { return array(1); } } }