$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";
?>
$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";
$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?";
$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?";
<?PHP // $Id$
require("../../config.php");
+ require("lib.php");
require_variable($id); // course
$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")) {
$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",
print_table($table);
print_footer($course);
-
?>
$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");
}
}
}
+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");
+ }
+}
+
+
?>
<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>
<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>
<?PHP // $Id$
require("../../config.php");
+ require("lib.php");
require_variable($id); // course module
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
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>";
</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>
<?PHP // $Id$
require("../../config.php");
+ require("lib.php");
require_variable($id); // Course Module ID
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");
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");
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;
-}
-
?>