private function getExperiment($username, $exp_name, $cat_name) { $weblab_data = $this->getWeblabData(); $weblab = new WebLabDeusto($weblab_data[0]); $sess_id = $weblab->login($weblab_data[1], $weblab_data[2]); $consumer_data = array("user_agent" => $_SERVER['HTTP_USER_AGENT'], "from_ip" => $_SERVER['REMOTE_ADDR'], "external_user" => $username); $reservation_status = $weblab->reserve($sess_id, $exp_name, $cat_name, "{}", $consumer_data); $reservation_status = $weblab->get_reservation_status($reservation_status->reservation_id); $client_url = $weblab->create_client($reservation_status); return $client_url; }
// all requests. If the login cookie expires while another request // is in process, this request fails // $weblab = new WebLabDeusto("http://localhost/weblab/", WebLabHttpRequestGateway::$CURL); // additional optional argument: cookiefile // Using CURL with different cookie file // $weblab = new WebLabDeusto("http://localhost/weblab/", WebLabHttpRequestGateway::$CURL, "cookiefile"); echo "Using http gateway: " . $weblab->getGatewayName() . "<br/>\n"; $sess_id = $weblab->login("any", "password"); ////////////////////////////////////////////// // // Ask for the available experiments (with session_id) // (see "ExperimentPermission") // $experiments = $weblab->list_experiments($sess_id); foreach ($experiments as $experiment) { echo "I have permission " . $experiment->name . " of category " . $experiment->category . " during " . $experiment->assigned_time . " seconds <br/>\n"; } //////////////////////////////////////// // // Create reservation (still with session_id) // $exp_name = "ud-dummy"; $cat_name = "Dummy experiments"; $consumer_data = array("external_user" => "moodle_student1"); $reservation_status = $weblab->reserve($sess_id, $exp_name, $cat_name, "{}", $consumer_data); var_dump($reservation_status); // Optional: check the reservation (now with reservation_id) $reservation_status = $weblab->get_reservation_status($reservation_status->reservation_id); var_dump($reservation_status); $client_url = $weblab->create_client($reservation_status); echo "URL: " . $client_url . "\n"; echo "<br/><br/><a href=\"" . $client_url . "\">open</a>";