- web: change style sheet so tables are bordered only if class is "bordered"

- web: fix error if translation string missing


svn path=/trunk/boinc/; revision=16363
This commit is contained in:
David Anderson 2008-10-30 18:27:22 +00:00
parent 9b07ed4fe4
commit 685ea38041
11 changed files with 224 additions and 80 deletions

View File

@ -259,3 +259,15 @@ David Oct 24 2008
bolt.css
bolt_admin.css
bolt_sched.php
David Oct 30 2008
- added "fill in the blank" (FITB) exercise type
- added "has_answer_page()" option for exercises
html/
inc/
bolt_ex.inc
bolt.inc
user/
bolt.css
bolt_sched.php

View File

@ -8901,3 +8901,15 @@ Charlie 30 Oct 2008
clientgui/
BOINCBaseFrame.cpp, .h
BOINCGUIApp.cpp
David 30 Oct 2008
- web: change style sheet so tables are bordered only if class is "bordered"
- web: fix error if translation string missing
html/
inc/
util.inc
translation.inc
user/
language_select.php
white.css

View File

@ -21,9 +21,8 @@ function show_participant() {
<center>
<span class=section_title>Computing power</span>
<br>
<a class=heading href=chart_list.php><b>Top 100</b></a>
&middot; <a class=heading href=\"http://boinc.netsoft-online.com/e107_plugins/boinc/u_rank.php?list=tc_p1c1\"><b>Single-computer</b></a>
&middot; <a class=heading href=\"http://boinc.netsoft-online.com/e107_plugins/boinc/bu_rankselect.php\"><b>Other lists</b></a>
<a class=heading href=chart_list.php><b>Top 100 volunteers</b></a>
&middot; <a class=heading href=\"links.php#stats\"><b>Statistics</b></a>
</center>
</td></tr>
<tr><td>

View File

@ -80,10 +80,15 @@ class BoltExercise extends BoltItem {
public $callback;
// called as func($student, $score, $query_string) after scoring
public $weight;
function __construct($filename, $title, $attrs, $callback, $weight) {
public $has_answer_page;
function __construct(
$filename, $title, $attrs, $callback, $weight, $has_answer_page
) {
parent::__construct($filename, $title, $attrs);
$this->callback = $callback;
$this->weight = $weight;
$this->has_answer_page = $has_answer_page;
}
function is_exercise() {
return true;
@ -257,6 +262,10 @@ function filename($n) {
return array('filename', $n);
}
function has_answer_page($n) {
return array('has_answer_page', $n);
}
function attrs($n) {
return array('attrs', $n);
}
@ -297,6 +306,7 @@ function exercise() {
$title = "";
$attrs = null;
$weight = 1;
$has_answer_page = true;
$args = func_get_args();
$callback = null;
@ -308,6 +318,7 @@ function exercise() {
case 'attrs': $attrs = $arg[1]; break;
case 'callback': $callback = $arg[1]; break;
case 'weight': $weight = $arg[1]; break;
case 'has_answer_page': $has_answer_page = $arg[1]; break;
default: echo "Unrecognized exercise parameter: ", $arg[0], "\n"; break;
}
}
@ -318,7 +329,9 @@ function exercise() {
if (!$filename) {
error_page("Missing filename in lesson");
}
return new BoltExercise($filename, $title, $attrs, $callback, $weight);
return new BoltExercise(
$filename, $title, $attrs, $callback, $weight, $has_answer_page
);
}
function item_attrs() {

View File

@ -27,15 +27,8 @@ $bolt_ex->score = 0; // input/output: cumulative score (if mode = SCORE)
$bolt_ex->weight = 0; // input/output: cumulative weight
$bolt_ex->query_string = ""; // user's response (if SCORE or ANSWER)
class BoltWeight {
public $weight;
function __construct($weight) {
$this->weight = $weight;
}
}
function weight($w) {
return new BoltWeight($w);
return array('weight', $w);
}
function exclusive_choice() {
@ -47,14 +40,13 @@ function exclusive_choice() {
foreach ($args as $arg) {
if (is_string($arg)) {
$choices[] = $arg;
} else if (is_object($arg)) {
if (get_class($arg) == 'BoltWeight') {
$weight = $arg->weight;
} else {
"bad arg to exclusive_choice()";
} else if (is_array($arg)) {
switch ($arg[0]) {
case 'weight': $weight = $arg[1]; break;
default: echo "bad arg to exclusive_choice()";
}
} else {
"bad arg to exclusive_choice()";
echo "bad arg to exclusive_choice()";
}
}
@ -129,10 +121,10 @@ function inclusive_choice() {
if (get_class($arg) == 'BoltWeight') {
$weight = $arg->weight;
} else {
"bad arg to inclusive_choice()";
echo "bad arg to inclusive_choice()";
}
} else {
"bad arg to inclusive_choice()";
echo "bad arg to inclusive_choice()";
}
}
@ -197,8 +189,7 @@ function image_rect($img, $rect) {
switch ($bolt_ex->mode) {
case BOLT_MODE_SHOW:
echo "<form name=main action=bolt_sched.php>
<input type=image name=pic_$bolt_ex->index src=$img>
echo "<input type=image name=pic_$bolt_ex->index src=$img>
";
break;
case BOLT_MODE_SCORE:
@ -247,4 +238,110 @@ function image_rect($img, $rect) {
$bolt_ex->index++;
}
class BoltFitbField {
public $textarea, $nrows, $ncols;
function __construct($textarea, $nrows, $ncols) {
$this->textarea = $textarea;
$this->nrows = $nrows;
$this->ncols = $ncols;
}
}
function field($n) {
return new BoltFitbField(false, 1, $n);
}
function box($nr, $nc) {
return new BoltFitbField(true, $nr, $nc);
}
class BoltFitbAnswer {
public $type; // 0=constant, 1=regexp, 2=func
public $ans;
function __construct($type, $ans) {
$this->type = $type;
$this->ans = $ans;
}
}
function answer($ans) {
return new BoltFitbAnswer(0, $ans);
}
function answer_regexp($ans) {
return new BoltFitbAnswer(1, $ans);
}
function answer_func($ans) {
return new BoltFitbAnswer(2, $ans);
}
function fitb() {
global $bolt_ex;
$args = func_get_args();
$field = new BoltFitbField(false, 1, 20);
$answer = null;
foreach ($args as $arg) {
if (is_array($arg)) {
$choices[] = $arg;
} else if (is_object($arg)) {
if (get_class($arg) == 'BoltFitbField') {
$field = $arg;
} else if (get_class($arg) == 'BoltFitbAns') {
$answer = $arg;
} else {
echo "bad arg to fitb()";
}
} else {
echo "bad arg to fitb()";
}
}
switch ($bolt_ex->mode) {
case BOLT_MODE_SHOW:
if ($field->textarea) {
echo "<textarea name=q_".$bolt_ex->index." nrows=$field->nrows ncols=$field->ncols>
</textarea>
";
} else {
echo "<input name=q_".$bolt_ex->index." length=$field->ncols>";
}
break;
case BOLT_MODE_SCORE:
if (!$answer) break;
$bolt_ex->score = 0;
$key = "q_".$bolt_ex->index;
if (isset($$key)) {
$response = $$key;
} else {
$response = "";
}
switch ($answer->type) {
case 0:
if ($response == $answer->ans) {
$bolt_ex->score = 1;
}
break;
case 1:
if (ereg($answer->ans, $response)) {
$bolt_ex->score = 1;
}
break;
case 2:
$bolt_ex->score = call_user_func($answer->ans, $response);
break;
}
break;
case BOLT_MODE_ANSWER:
$key = "q_".$bolt_ex->index;
if (isset($$key)) {
$response = $$key;
} else {
$response = "";
}
break;
}
$bolt_ex->index++;
}
?>

View File

@ -156,7 +156,7 @@ function tra($text /* ...arglist... */){
// Find the string in the user's language
foreach ($languages_in_use as $language){
if ($language_lookup_array[$language][$text]){
if (isset($language_lookup_array[$language][$text])) {
$text = $language_lookup_array[$language][$text];
break;
}

View File

@ -227,12 +227,13 @@ function time_str($x) {
function pretty_time_str($x) {
return time_str($x);
}
function start_table($extra="width=\"100%\"") {
echo "<table $extra>";
echo "<table class=bordered $extra>";
}
function start_table_noborder($width="100%") {
echo "<table border=0 cellpadding=5 width=\"$width\">";
echo "<table cellpadding=5 width=\"$width\">";
}
function end_table() {
@ -565,11 +566,14 @@ function post_int($name, $optional=false) {
}
function get_str($name, $optional=false) {
$x = null;
if (isset($_GET[$name])) $x = $_GET[$name];
if (!$x && !$optional) {
if (!isset($_GET[$name])) {
if (!$optional) {
error_page("missing or bad parameter: $name");
}
$x = null;
} else {
$x = $_GET[$name];
}
return undo_magic_quotes($x);
}

View File

@ -36,15 +36,14 @@ hr {
}
table {
border: 2px solid #e8e8e8;
padding: 4px;
margin: 2px;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
}
table.noborder {
border: none;
table.bordered {
border: 2px solid #e8e8e8;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
}
th {
@ -129,7 +128,7 @@ td.friend {
tr.message { background-color: #e0e0e0; }
input, select, textarea, .button {
input[type="text"], select, textarea, .button {
border: 1px solid #d8d8d8;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;

View File

@ -150,7 +150,7 @@ function show_nav($links, $up_link, $view_id) {
<table width=60%><tr>
";
foreach ($links as $link) {
echo "<td align=center>$link</td>";
echo "<td align=center>$link</td>\n";
}
echo "</tr></table> </center>
<hr>
@ -159,7 +159,7 @@ function show_nav($links, $up_link, $view_id) {
<input type=hidden name=course_id value=$course->id>
<input type=hidden name=action value=question>
<input type=hidden name=view_id value=$view_id>
<textarea name=question cols=60>Enter question or comment here</textarea>
<textarea name=question cols=60 onfocus=\"this.value=''\">Enter question or comment here</textarea>
<br>
<input type=submit value=Submit>
</form>
@ -186,7 +186,7 @@ function show_item($iter, $view_id, $prev_view_id, $mode, $repeat=null) {
$links[] = "<a href=bolt_sched.php?$url_args&action=prev&view_id=$view_id><img src=img/prev.gif></a>";
}
$next = "<a href=bolt_sched.php?$url_args&action=next&view_id=$view_id><img src=img/next.gif></a>";
$next = "<a href=bolt_sched.php?$url_args&action=next&view_id=$view_id><img src=img/next.gif border=0></a>";
if ($item->is_exercise()) {
$bolt_ex->mode = $mode;
@ -314,6 +314,39 @@ function start_refresh() {
show_item($iter, $view_id, 0, $mode);
}
function show_next($iter, $view) {
global $refresh, $user, $course;
$iter->next();
if ($refresh) {
$iter->at();
if (!$iter->xset) {
// if we're doing a refresh and are no longer in an xset,
// we must have finished the refresh
//
show_refresh_finished();
$refresh->update('count=count+1');
break;
}
}
if ($iter->item) {
$state = $iter->encode_state();
$mode = default_mode($iter->item);
$view_id = create_view($iter, $mode, $view->id);
show_item($iter, $view_id, $view->id, $mode);
} else {
// course finished
$iter->frac_done = 1;
$fin_view_id = create_view($iter, BOLT_MODE_FINISHED, $view->id);
$e = new BoltEnrollment();
$e->user_id = $user->id;
$e->course_id = $course->id;
$e->update("last_view_id=$fin_view_id");
show_finished_page($fin_view_id, $view->id);
}
}
$user = get_logged_in_user();
BoltUser::lookup($user);
$course_id = get_int('course_id');
@ -402,35 +435,7 @@ case 'next': // "next" button in lesson or exercise answer page
$iter = new BoltIter($course_doc);
$iter->decode_state($view->state);
$iter->next();
if ($refresh) {
$iter->at();
if (!$iter->xset) {
// if we're doing a refresh and are no longer in an xset,
// we must have finished the refresh
//
show_refresh_finished();
$refresh->update('count=count+1');
break;
}
}
if ($iter->item) {
$state = $iter->encode_state();
$mode = default_mode($iter->item);
$view_id = create_view($iter, $mode, $view->id);
show_item($iter, $view_id, $view->id, $mode);
} else {
// course finished
$iter->frac_done = 1;
$fin_view_id = create_view($iter, BOLT_MODE_FINISHED, $view_id);
$e = new BoltEnrollment();
$e->user_id = $user->id;
$e->course_id = $course->id;
$e->update("last_view_id=$fin_view_id");
show_finished_page($fin_view_id, $view->id);
}
show_next($iter, $view);
break;
case 'answer': // submit answer in exercise
$view = finalize_view($view_id, BOLT_ACTION_SUBMIT);
@ -521,9 +526,13 @@ case 'answer': // submit answer in exercise
// show the answer page
if ($item->has_answer_page) {
srand($view_id);
$view_id = create_view($iter, BOLT_MODE_ANSWER, $view->id);
show_item($iter, $view_id, $view->id, BOLT_MODE_ANSWER, $repeat);
} else {
show_next($iter, $view);
}
break;
case 'answer_page':
$view = BoltView::lookup_id($view_id);

View File

@ -62,10 +62,10 @@ row2("",
"<a href=language_select.php?set_lang=auto>Use browser language setting</a>"
);
sort($languages);
for ($i=0; $i<sizeof($languages);$i++){
foreach ($languages as $language) {
row2(
"<a href=\"language_select.php?set_lang=".$languages[$i]."\">".$languages[$i]."</a>",
"<a href=\"language_select.php?set_lang=".$languages[$i]."\">".tr_specific("LANG_NAME_INTERNATIONAL", $languages[$i])." (".tr_specific("LANG_NAME_NATIVE", $languages[$i]).")</a>"
"<a href=\"language_select.php?set_lang=$language\">$language</a>",
"<a href=\"language_select.php?set_lang=$language\">".tr_specific("LANG_NAME_INTERNATIONAL", $language)." (".tr_specific("LANG_NAME_NATIVE", $language).")</a>"
);
}
end_table();

View File

@ -36,15 +36,14 @@ hr {
}
table {
border: 2px solid #e8e8e8;
padding: 4px;
margin: 2px;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
}
table.noborder {
border: none;
table.bordered {
border: 2px solid #e8e8e8;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
}
th {
@ -129,7 +128,7 @@ td.friend {
tr.message { background-color: #e0e0e0; }
input, select, textarea, .button {
input[type="text"], select, textarea, .button {
border: 1px solid #d8d8d8;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;