science-ation/testapi.php

132 lines
3.7 KiB
PHP
Raw Normal View History

<?
include "common.inc.php";
?>
<html>
<head>
<script type="text/javascript" src="js/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$.get('api/role/list', {}, function(results){
var list, disabled;
var selector = [];
selector[0] = $('<select name="role_id"></select>');
selector[1] = $('<select name="role_id"></select>');
eval('list = ' + results);
for(n in list['roles']){
disabled = '';
if(list['roles'][n].registration == 'not available'){
disabled = ' disabled ';
}
selector[0].append($('<option ' + disabled + ' value="' + list['roles'][n].id + '">' + list['roles'][n].name + '</option>'));
selector[1].append($('<option ' + disabled + ' value="' + list['roles'][n].id + '">' + list['roles'][n].name + '</option>'));
}
$('#rolediv_1').prepend(selector[0]);
$('#rolediv_2').prepend(selector[1]);
});
});
</script>
</head>
<body>
<h1>General Commands</h1>
Login
<form method="post" action="api/auth/login">
<input type="text" name="username">
<input type="password" name="password">
<input type="submit" value="Login">
</form>
Logout
<form method="post" action="api/auth/logout">
<input type="submit" value="Logout">
</form>
<a href="api/conferences">Conference List</a><br />
Switch Conference
<form method="post" action="api/conferences/switch">
<input type="text" size=2 name="conferences_id">
<input type="submit" value="Switch Conference">
</form>
<script type="text/javascript">
function dateListForConference() {
var o=document.getElementById('conferences_id');
window.location.href='api/dates/'+o.value;
return false;
}
</script>
<a href="api/dates">Dates List (current conference)</a><br />
<form method="post" onsubmit="return dateListForConference()">
Date List
<input type="text" size=2 id="conferences_id" name="conferences_id">
<input type="submit" value="Conference Date List">
</form>
<h1>Teacher Specific Commands</h1>
<a href="api/scienceolympics/teams/list">Science Olympic Teams List</a><br />
<form method="post" action="api/scienceolympics/teams/add">
<input type="text" name="teamname">
<input type="submit" value="Add Team">
</form>
<form method="post" action="api/scienceolympics/teams/delete">
<input type="text" size=2 name="id">
<input type="submit" value="Delete Team">
</form>
<form method="post" action="api/scienceolympics/teams/edit">
<input type="text" size=2 name="id">
<input type="text" name="teamname">
<input type="submit" value="Edit Team">
</form>
<h1>Event Schedule</h1>
<a href="api/schedule/list">Schedule Listing</a><br/>
<a href="api/locations/list">Location Listing</a><br/>
Register a team for a scheduled event<br/>
<form method="post" action="api/schedule/register">
Team Id: <input type="text" name="team_id"></input>,
Schedule ID: <input type="text" name="schedule_id"></input>
<input type="submit" value="Register"></input>
</form>
Un-Register a team for a scheduled event<br/>
<form method="post" action="api/schedule/unregister">
Team Id: <input type="text" name="team_id"></input>,
Schedule ID: <input type="text" name="schedule_id"></input>
<input type="submit" value="Unregister"></input>
</form>
<h1>Roles</h1>
<a href="api/role/list">Get a list of roles for this conference</a><br/>
Add a role to this account
<form method="post" action="api/role/add">
<div id="rolediv_1">
Password: <input name="password" type="password"></input>
<input type="submit" value="Add Role"></input>
</div>
</form>
Remove a role from this account
<form method="post" action="api/role/remove">
<div id="rolediv_2">
<input type="submit" value="Remove Role"></input>
</div>
</form>
<h1>Session Variables</h1>
<?
echo json_encode($_SESSION);
?>
</body>
</html>