]> git.mjollnir.org Git - moodle.git/commitdiff
Language changes to choice module
authormartin <martin>
Mon, 12 Aug 2002 08:28:04 +0000 (08:28 +0000)
committermartin <martin>
Mon, 12 Aug 2002 08:28:04 +0000 (08:28 +0000)
lang/en/choice.php
lang/en/moodle.php
mod/choice/index.php
mod/choice/lib.php
mod/choice/mod.html
mod/choice/report.php
mod/choice/view.html
mod/choice/view.php

index 2df820cab2ec0c0118ad1f853d0bd45e7d40eb2a..80fbadea17f8d2385948e507de6295b7fd0a54e9 100644 (file)
@@ -5,4 +5,13 @@ $string[modulename] = "Choice";
 $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";
 ?>
index 9929c43ef82a87b95ee95526007bca80971b0146..c7572b63e5ed0209f80e0fb087d9d3203f0045c1 100644 (file)
@@ -18,6 +18,7 @@ $string[allowguests] = "This course allows guest users to enter";
 $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[passwordsenttext] = "
 $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[topic] = "Topic";
 $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?";
index 9d4f8598dff4f5c3c309d8e76d9ceaa52532e6b8..d7c8038fecf5407f2e980162c0986967b51eddf5 100644 (file)
@@ -1,6 +1,7 @@
 <?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",
@@ -74,7 +68,6 @@
     print_table($table);
 
     print_footer($course);
-
  
 ?>
 
index 25c97ad5fd70e6a643b9df9fa49813475614c99b..25b2083c504353c9041bbf0ea7517d00c0da08d8 100644 (file)
@@ -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");
+    }
+}
+
+
 ?>
 
index 1f471660c23cd42386585bfc54d0eba0a3080d97..3898b500ea86fc761d61dd37281374602a8539ab 100644 (file)
@@ -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>
index 7fb30f218a8844074852226631723acdb6d02bc5..42ff7710d8ce8796ad40c6d94750a522b2cb6cf9 100644 (file)
@@ -1,6 +1,7 @@
 <?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>";
index 286232c422fc3231d916e7e95b55d47f9a7d5979..f43a9afdf16fa914cf45bde601e0f61edcaf8162 100644 (file)
@@ -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>
index 5800e95ab72eb8df10efd281921247b2ee3aa413..3161db6d22362775ff0087eb90ad0f60ec1a8086 100644 (file)
@@ -1,6 +1,7 @@
 <?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;
-}
-
 ?>