Example #1
0
File: steps.php Project: bvds/andes
 if (strcasecmp($theProblem[$clientID], "kt1apart") == 0 || strcasecmp($theProblem[$clientID], "kt1asolved") == 0) {
     continue;
 }
 // If load has failed don't attempt any solution steps.
 if (array_key_exists($clientID, $loadFailed) && $loadFailed[$clientID] && in_array($method, $methods) && strcmp($method, "close-problem") != 0) {
     continue;
 }
 // Remove Done button from some problems, ignore
 // associated button events.
 // problems commit 6376f20fd808, Nov 19 2011
 if (strcmp($method, "solution-step") == 0 && doneButtonProblem($theProblem[$clientID]) && isset($a->params) && isset($a->params->id) && strpos($a->params->id, "doneButton") !== false) {
     continue;
 }
 // Send query to help server.
 $queryStart = microtime(true);
 $newResponse = $server->message($action, $thisClientID);
 $dt = microtime(true) - $queryStart;
 $serverTime += $dt;
 // See if this is the last turn in a session
 // Or if the server has closed the session and
 // the problem has not already been closed.
 // Then close the session.
 if (($lastID[$clientID] == $ttID || strpos($response, "Your session is no longer active.") !== false) && !(array_key_exists($clientID, $lastTime) && $lastTime[$clientID] == -2)) {
     // Close the session "by hand" and record
     $closeID = $a->id + 1;
     $closeAction = "{\"id\":{$closeID},\"method\":\"close-problem\",\"params\":{},\"jsonrpc\":\"2.0\"}";
     $closeResponse = $server->message($closeAction, $thisClientID);
     $closeTime = $sessionStartTime[$clientID];
     $closeSession[$clientID] = "<td>{$closeTime}</td>" . $sessionLink1 . "&amp;cid=" . $clientID . $sessionLink2 . "<td>{$closeResponse}</td>";
 }
 // Determine if problem load failed, set variable
Example #2
0
         continue;
     }
 }
 $a = $json->decode($action);
 // Drop turns without method.
 if (!isset($a->method)) {
     continue;
 }
 $method = $a->method;
 // If load has failed don't attempt any solution steps.
 if ($loadFailed && in_array($method, $methods) && strcmp($method, "close-problem") != 0) {
     continue;
 }
 // Send query to help server.
 $queryStart = microtime(true);
 $newResponse = $server->message($action, $sessionIdBase . $sessionId);
 $dt = microtime(true) - $queryStart;
 $serverTime += $dt;
 // Determine if problem load failed, set variable
 if (strcmp($method, "open-problem") == 0 && preg_match('/PROBLEM-LOAD-FAILED/', $newResponse) != 0) {
     $loadFailed = true;
 }
 // Problem might be closed later by server.
 // No attempt here to remove "out of focus" since we
 // don't have that working yet.
 if (isset($a->params->time) && strcmp($method, "close-problem") != 0) {
     $ttime = $a->params->time;
 }
 if (isset($methodTime[$method])) {
     $methodTime[$method] += $dt;
 } else {