From e866381c4aed7ca0df099f1bb7334a4ceb68cbed Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 31 Jul 2008 18:28:49 +0000 Subject: [PATCH] - Bossa stuff svn path=/trunk/boinc/; revision=15726 --- doc/boinc_news.php | 5 +- html/inc/bossa.inc | 9 ++ html/inc/bossa_example4.inc | 172 ++++++++++++++++++++++++++ html/ops/bossa_admin.php | 3 +- html/ops/bossa_example4_make_jobs.php | 52 ++++++++ html/ops/bossa_example_make_jobs.php | 2 +- html/user/bossa_apps.php | 4 +- html/user/bossa_example4.php | 53 ++++++++ 8 files changed, 294 insertions(+), 6 deletions(-) create mode 100644 html/inc/bossa_example4.inc create mode 100644 html/ops/bossa_example4_make_jobs.php create mode 100644 html/user/bossa_example4.php diff --git a/doc/boinc_news.php b/doc/boinc_news.php index 66e3966937..af93b7529b 100644 --- a/doc/boinc_news.php +++ b/doc/boinc_news.php @@ -2,9 +2,8 @@ $project_news = array( array("July 30, 2008", - "BOINC 6.2.14 has been released to the public for all platforms. - Please visit the - download page to upgrade now." + "BOINC 6.2.14 is now the recommended version for all platforms. + Upgrade now." ), array("July 29, 2008", "The Quake Catcher Network diff --git a/html/inc/bossa.inc b/html/inc/bossa.inc index eece3ae1f6..f5e861311a 100644 --- a/html/inc/bossa.inc +++ b/html/inc/bossa.inc @@ -34,4 +34,13 @@ function bossa_app_lookup($name) { return $app->id; } +function bossa_lookup_job($instid, &$job, &$inst, &$user) { + $inst = BossaJobInst::lookup_id($instid); + if (!$inst) return false; + $job = BossaJob::lookup_id($inst->job_id); + $user = BoincUser::lookup_id($inst->user_id); + BossaUser::lookup($user); + return true; +} + ?> diff --git a/html/inc/bossa_example4.inc b/html/inc/bossa_example4.inc new file mode 100644 index 0000000000..24b2c9f612 --- /dev/null +++ b/html/inc/bossa_example4.inc @@ -0,0 +1,172 @@ +get_opaque_data(); + $features = $output->features; + $input = $job->get_opaque_data(); + $path = $input->path; + + show_style(); + echo " + +
+
+ + id\"> + + "; + $size = 100; + $size2 = 50; + $i = 0; + foreach ($features as $f) { + $cx = $f->x - $size2; + $cy = $f->y - $size2; + echo " + + "; + $c = $f->comment?"($f->comment)":""; + echo " + + + + + $f->type $c + + + + "; + echo " + id&action=delete&index=$i> + + "; + $i++; + } + echo " +
+ "; + control_bar($features, $inst); + echo " +
+ "; +} + +function job_issued($job, $inst, $user) { + $job->set_priority(0); +} + +function job_finished($job, $inst) { +} + +function job_timed_out($job, $inst, $user) { + $job->set_priority(1); +} + +function job_summary($job) { + $info = $job->get_opaque_data(); + return "path>View image"; +} + +function instance_summary($opaque_data) { + $features = $opaque_data->features; + $x = ""; + foreach ($features as $f) { + $c = $f->comment?"($f->comment)":""; + $x .= "$f->type $c
"; + } + return $x; +} + +function show_user_summary($user) { +} + +function show_style() { + echo " + + "; +} + +function select_type() { + echo " + + "; +} + +function control_bar($features, $inst) { + if (count($features)) { + $str1 = "any more"; + $str2 = "another"; + } else { + $str1 = "any"; + $str2 = "a"; + } + echo " +
+ id\"> + If you see $str2 feature: + "; + select_type(); + echo " + + + and click on its center. +
+ If you don't see $str1 features, click + id>DONE +
+ "; +} + +?> diff --git a/html/ops/bossa_admin.php b/html/ops/bossa_admin.php index 10e0882a53..3e09585517 100644 --- a/html/ops/bossa_admin.php +++ b/html/ops/bossa_admin.php @@ -132,7 +132,7 @@ function job_show_instances($job) { $d "; - echo instance_summary($inst->get_info()); + echo instance_summary($inst->get_opaque_data()); echo " @@ -280,6 +280,7 @@ case 'add_app': $time_estimate = get_str('time_estimate'); $time_limit = get_str('time_limit'); $calibration_frac = get_str('calibration_frac' , true); + if (!$calibration_frac) $calibration_frac = 0; $now = time(); $app_id = BossaApp::insert("(create_time, name, short_name, description, bolt_course_id, time_estimate, time_limit, calibration_frac) values ($now, '$name', '$short_name', '$description', $courseid, $time_estimate, $time_limit, $calibration_frac)"); if ($courseid) { diff --git a/html/ops/bossa_example4_make_jobs.php b/html/ops/bossa_example4_make_jobs.php new file mode 100644 index 0000000000..0b29d4ebd6 --- /dev/null +++ b/html/ops/bossa_example4_make_jobs.php @@ -0,0 +1,52 @@ +path = $path; + + if (!bossa_job_create($appid, $batchid, $info, false)) { + exit("bossa_create_job() failed\n"); + } + echo "created job for $path\n"; +} + +function make_jobs($dir, $appid) { + $batchid = bossa_batch_create($appid, date(DATE_RFC822), false); + if (!$batchid) { + exit("bossa_create_batch() failed\n"); + } + + $d = opendir("../user/$dir"); + while ($file = readdir($d)) { + if (!strstr($file, ".png") && !strstr($file, ".jpg")) continue; + make_job("$dir/$file", $batchid, $appid); + } + closedir($d); +} + +function usage() { + exit("Usage: bossa_example4_make_jobs.php --dir d\n"); +} + +for ($i=1; $i<$argc; $i++) { + if ($argv[$i] == '--dir') $dir = $argv[++$i]; + else usage(); +} + +if (!$dir) usage(); + +if (!is_dir("../user/$dir")) { + exit("../user/$dir is not a directory\n"); +} + +$appid = bossa_app_lookup("bossa_example4"); +if (!$appid) exit("No application 'bossa_example4'\n"); + +make_jobs($dir, $appid); diff --git a/html/ops/bossa_example_make_jobs.php b/html/ops/bossa_example_make_jobs.php index 1a45aa3ee2..ebc159d4e4 100644 --- a/html/ops/bossa_example_make_jobs.php +++ b/html/ops/bossa_example_make_jobs.php @@ -41,7 +41,7 @@ function make_jobs($dir, $appid, $calibration) { } function usage() { - exit("Usage: bossa_example_make_jobs --app_name x --dir d [--calibration]]\n"); + exit("Usage: php bossa_example_make_jobs.php --app_name x --dir d [--calibration]]\n"); } $calibration = false; diff --git a/html/user/bossa_apps.php b/html/user/bossa_apps.php index 3c58f7a649..5b1535c3c0 100644 --- a/html/user/bossa_apps.php +++ b/html/user/bossa_apps.php @@ -25,7 +25,9 @@ function show_app($app) { } else { $x = "id>Get job"; } - row2("$app->name
$app->description
", $x); + $est = number_format($app->time_estimate/60., 2); + $limit = number_format($app->time_limit/60., 2); + row2("$app->name
$app->description
Time: $est min. average, $limit min limit
", $x); } function show_apps() { diff --git a/html/user/bossa_example4.php b/html/user/bossa_example4.php new file mode 100644 index 0000000000..1e4b00073e --- /dev/null +++ b/html/user/bossa_example4.php @@ -0,0 +1,53 @@ +x = get_int('pic_x'); + $f->y = get_int('pic_y'); + $f->type = get_str('type'); + $c = get_str('comment', true); + if (strstr($c, "(optional)")) $c = ""; + $f->comment = $c; + $output = $inst->get_opaque_data(); + $output->features[] = $f; + $inst->set_opaque_data($output); + header("location: bossa_example4.php?bji=$inst->id"); +} + +function handle_delete($job, $inst, $index) { + $output = $inst->get_opaque_data(); + $features = $output->features; + array_splice($features, $index, 1); + $output->features = $features; + $inst->set_opaque_data($output); + header("location: bossa_example4.php?bji=$inst->id"); +} + +$bji = get_int("bji"); +if (!bossa_lookup_job($bji, $job, $inst, $u)) { + error_page("No such instance"); +} +$user = get_logged_in_user(); +if ($u->id != $user->id) { + error_page("Not your job"); +} + +$action = get_str("action", true); +switch ($action) { +case "add": + handle_add($job, $inst); + break; +case "delete": + $index = get_int("index"); + handle_delete($job, $inst, $index); + break; +default: + job_show($job, $inst, $user); + break; +} + +?>