Skip to content
Browse files

Language changes to choice module

  • Loading branch information...
1 parent 23feeab commit c4016bc1db65f52bb3f25bb0204e3baf2f9b4a08 martin committed Aug 12, 2002
Showing with 84 additions and 71 deletions.
  1. +9 −0 lang/en/choice.php
  2. +3 −0 lang/en/moodle.php
  3. +10 −17 mod/choice/index.php
  4. +37 −2 mod/choice/lib.php
  5. +7 −7 mod/choice/mod.html
  6. +9 −15 mod/choice/report.php
  7. +1 −1 mod/choice/view.html
  8. +8 −29 mod/choice/view.php
View
9 lang/en/choice.php
@@ -5,4 +5,13 @@
$string[modulenameplural] = "Choices";
#------------------------------------------------------------
+$string[answered] = "Answered";
+$string[choice1] = "First choice";
+$string[choice2] = "Second choice";
+$string[choicename] = "Choice name";
+$string[choicetext] = "Choice text";
+$string[notanswered] = "Not answered yet";
+$string[responses] = "Responses";
+$string[savemychoice] = "Save my choice";
+$string[viewallresponses] = "View all responses";
?>
View
3 lang/en/moodle.php
@@ -18,6 +18,7 @@
$string[allparticipants] = "All participants";
$string[alphanumerical] = "Can only contain alphabetical letters or numbers";
$string[alreadyconfirmed] = "Registration has already been confirmed";
+$string[answer] = "Answer";
$string[assignteachers] = "Assign teachers";
$string[availablecourses] = "Available Courses";
$string[cancel] = "Cancel";
@@ -238,6 +239,7 @@
$string[people] = "People";
$string[personalprofile] = "Personal profile";
$string[phone] = "Phone";
+$string[question] = "Question";
$string[recentactivity] = "Recent activity";
$string[resources] = "Resources";
$string[returningtosite] = "Returning to this web site?";
@@ -280,6 +282,7 @@
$string[topicoutline] = "Topic outline";
$string[turneditingoff] = "Turn editing off";
$string[turneditingon] = "Turn editing on";
+$string[undecided] = "Undecided";
$string[unenrol] = "Unenrol";
$string[unenrolme] = "Unenrol me from \$a";
$string[unenrolsure] = "Are you sure you want to unenrol \$a from this course?";
View
27 mod/choice/index.php
@@ -1,6 +1,7 @@
<?PHP // $Id$
require("../../config.php");
+ require("lib.php");
require_variable($id); // course
@@ -16,8 +17,11 @@
$navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
}
- print_header("$course->shortname: Choices", "$course->fullname",
- "$navigation Choices", "");
+ $strchoice = get_string("modulename", "choice");
+ $strchoices = get_string("modulenameplural", "choice");
+
+ print_header("$course->shortname: $strchoices", "$course->fullname",
+ "$navigation $strchoices", "");
if (! $choices = get_all_instances_in_course("choice", $course->id, "cw.section ASC")) {
@@ -37,29 +41,19 @@
$timenow = time();
if ($course->format == "weeks") {
- $table->head = array ("Week", "Question", "Answer");
+ $table->head = array (get_string("week"), get_string("question"), get_string("answer"));
$table->align = array ("CENTER", "LEFT", "LEFT");
} else if ($course->format == "topics") {
- $table->head = array ("Topic", "Question", "Answer");
+ $table->head = array (get_string("topic"), get_string("question"), get_string("answer"));
$table->align = array ("CENTER", "LEFT", "LEFT");
} else {
- $table->head = array ("Question", "Answer");
+ $table->head = array (get_string("question"), get_string("answer"));
$table->align = array ("LEFT", "LEFT");
}
foreach ($choices as $choice) {
$answer = $answers[$choice->id];
- switch ($answer->answer) {
- case 1:
- $aa = "$choice->answer1";
- break;
- case 2:
- $aa = "$choice->answer2";
- break;
- default:
- $aa = "Undecided";
- break;
- }
+ $aa = choice_get_answer($choice, $answer->answer);
if ($course->format == "weeks" || $course->format == "topics") {
$table->data[] = array ("$choice->section",
@@ -74,7 +68,6 @@
print_table($table);
print_footer($course);
-
?>
View
39 mod/choice/lib.php
@@ -29,9 +29,9 @@ function choice_user_complete($course, $user, $mod, $choice) {
$result->info = "'$choice->answer2'";
}
$result->time = $current->timemodified;
- echo "Answered: $result->info , last updated ".userdate($result->time);
+ echo get_string("answered", "choice").": $result->info , last updated ".userdate($result->time);
} else {
- echo "Not answered yet";
+ print_string("notanswered", "choice");
}
}
@@ -83,5 +83,40 @@ function choice_delete_instance($id) {
}
+function choice_add_new_to_database($choice, $answer) {
+ global $db;
+ global $USER;
+
+ $timenow = time();
+
+ $rs = $db->Execute("INSERT INTO choice_answers (choice, user, answer, timemodified)
+ VALUES ( '$choice->id', '$USER->id', '$answer', '$timenow')");
+ return $rs;
+}
+
+function choice_update_in_database($current, $answer) {
+ global $db;
+
+ $timenow = time();
+
+ $rs = $db->Execute("UPDATE choice_answers
+ SET answer='$answer', timemodified='$timenow'
+ WHERE id = '$current->id'");
+ return $rs;
+}
+
+function choice_get_answer($choice, $code) {
+// Returns text string which is the answer that matches the code
+ switch ($code) {
+ case 1:
+ return "$choice->answer1";
+ case 2:
+ return "$choice->answer2";
+ default:
+ return get_string("undecided");
+ }
+}
+
+
?>
View
14 mod/choice/mod.html
@@ -3,39 +3,39 @@
<table cellpadding=5>
<tr valign=top>
- <td align=right><P><B>Choice Name:</B></P></TD>
+ <td align=right><P><B><? print_string("choicename","choice") ?>:</B></P></TD>
<td>
<input type="text" name="name" size=30 value="<? p($form->name) ?>">
</td>
</tr>
<tr valign=top>
- <td align=right><P><B>Choice Text:</B></P></TD>
+ <td align=right><P><B><? print_string("choicetext","choice") ?>:</B></P></TD>
<td>
<textarea name="text" rows=15 cols=30 wrap="virtual"><? p($form->text) ?></textarea>
</td>
</tr>
<tr valign=top>
- <td align=right><P><B>First choice:</B></P></TD>
+ <td align=right><P><B><? print_string("choice1","choice") ?>:</B></P></TD>
<td>
<input type="text" name="answer1" size=30 value="<?
if ($form->answer1) {
p($form->answer1);
} else {
- echo "Yes";
+ print_string("yes");
} ?>">
</td>
</tr>
<tr valign=top>
- <td align=right><P><B>Second choice:</B></P></TD>
+ <td align=right><P><B><? print_string("choice2","choice") ?>:</B></P></TD>
<td>
<input type="text" name="answer2" size=30 value="<?
if ($form->answer2) {
p($form->answer2);
} else {
- echo "No";
+ print_string("no");
} ?>">
</td>
</tr>
@@ -50,6 +50,6 @@
<input type="hidden" name=modulename value="<? p($form->modulename) ?>">
<input type="hidden" name=instance value="<? p($form->instance) ?>">
<input type="hidden" name=mode value="<? p($form->mode) ?>">
-<input type="submit" value="Save these settings">
+<input type="submit" value="<? print_string("savechanges") ?>">
</CENTER>
</FORM>
View
24 mod/choice/report.php
@@ -1,6 +1,7 @@
<?PHP // $Id$
require("../../config.php");
+ require("lib.php");
require_variable($id); // course module
@@ -22,12 +23,16 @@
error("Course module is incorrect");
}
+ $strchoice = get_string("modulename", "choice");
+ $strchoices = get_string("modulenameplural", "choice");
+ $strresponses = get_string("responses", "choice");
+
add_to_log($course->id, "choice", "report", "report.php?id=$cm->id", "$choice->id");
- print_header("$course->shortname: $choice->name: Responses", "$course->fullname",
+ print_header("$course->shortname: $choice->name: $strresponses", "$course->fullname",
"<A HREF=/course/view.php?id=$course->id>$course->shortname</A> ->
- <A HREF=index.php?id=$course->id>Choices</A> ->
- <A HREF=view.php?id=$cm->id>$choice->name</A> -> Responses", "");
+ <A HREF=index.php?id=$course->id>$strchoices</A> ->
+ <A HREF=view.php?id=$cm->id>$choice->name</A> -> $strresponses", "");
if (! $participants = get_records_sql("SELECT u.* FROM user u, user_students s, user_teachers t
@@ -71,18 +76,7 @@
echo "</P> </TD>";
echo "<TD ALIGN=CENTER BGCOLOR=\"$THEME->cellcontent\"><P>";
- switch ($answer->answer) {
- case 1:
- echo "$choice->answer1";
- break;
- case 2:
- echo "$choice->answer2";
- break;
- default:
- echo "Undecided";
- break;
-
- }
+ echo choice_get_answer($choice, $answer->answer);
echo "</P></TD></TR>";
}
echo "</TABLE>";
View
2 mod/choice/view.html
@@ -13,7 +13,7 @@
</TR></TABLE>
<P>
<INPUT type="hidden" name=id value="<?=$cm->id ?>">
-<INPUT type="submit" value="Save my choice">
+<INPUT type="submit" value="<? print_string("savemychoice","choice") ?>">
</P>
</FORM>
</CENTER>
View
37 mod/choice/view.php
@@ -1,6 +1,7 @@
<?PHP // $Id$
require("../../config.php");
+ require("lib.php");
require_variable($id); // Course Module ID
@@ -30,12 +31,12 @@
if (match_referer() && isset($HTTP_POST_VARS)) { // form submitted
$form = (object)$HTTP_POST_VARS;
if ($current) {
- if (! update_choice_in_database($current, $form->answer)) {
+ if (! choice_update_in_database($current, $form->answer)) {
error("Could not update your choice");
}
add_to_log($course->id, "choice", "update", "view.php?id=$cm->id", "$choice->id");
} else {
- if (! add_new_choice_to_database($choice, $form->answer)) {
+ if (! choice_add_new_to_database($choice, $form->answer)) {
error("Could not save your choice");
}
add_to_log($course->id, "choice", "add", "view.php?id=$cm->id", "$choice->id");
@@ -44,17 +45,20 @@
exit;
}
+ $strchoice = get_string("modulename", "choice");
+ $strchoices = get_string("modulenameplural", "choice");
+
add_to_log($course->id, "choice", "view", "view.php?id=$cm->id", "$choice->id");
if ($course->category) {
$navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
}
print_header("$course->shortname: $choice->name", "$course->fullname",
- "$navigation <A HREF=index.php?id=$course->id>Choices</A> -> $choice->name", "", "", true,
+ "$navigation <A HREF=index.php?id=$course->id>$strchoices</A> -> $choice->name", "", "", true,
update_module_icon($cm->id, $course->id));
if (isteacher($course->id)) {
- echo "<P align=right><A HREF=\"report.php?id=$cm->id\">View all responses</A></P>";
+ echo "<P align=right><A HREF=\"report.php?id=$cm->id\">".get_string("viewallresponses", "choice")."</A></P>";
}
print_simple_box( text_to_html($choice->text) , "center");
@@ -64,29 +68,4 @@
print_footer($course);
-
-// Functions /////////////////////////////////////////////////
-
-function add_new_choice_to_database($choice, $answer) {
- global $db;
- global $USER;
-
- $timenow = time();
-
- $rs = $db->Execute("INSERT INTO choice_answers (choice, user, answer, timemodified)
- VALUES ( '$choice->id', '$USER->id', '$answer', '$timenow')");
- return $rs;
-}
-
-function update_choice_in_database($current, $answer) {
- global $db;
-
- $timenow = time();
-
- $rs = $db->Execute("UPDATE choice_answers
- SET answer='$answer', timemodified='$timenow'
- WHERE id = '$current->id'");
- return $rs;
-}
-
?>

0 comments on commit c4016bc

Please sign in to comment.
Something went wrong with that request. Please try again.