From: martin Date: Mon, 12 Aug 2002 08:28:04 +0000 (+0000) Subject: Language changes to choice module X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c4016bc1db65f52bb3f25bb0204e3baf2f9b4a08;p=moodle.git Language changes to choice module --- diff --git a/lang/en/choice.php b/lang/en/choice.php index 2df820cab2..80fbadea17 100644 --- a/lang/en/choice.php +++ b/lang/en/choice.php @@ -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"; ?> diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 9929c43ef8..c7572b63e5 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -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?"; diff --git a/mod/choice/index.php b/mod/choice/index.php index 9d4f8598df..d7c8038fec 100644 --- a/mod/choice/index.php +++ b/mod/choice/index.php @@ -1,6 +1,7 @@ id\">$course->shortname ->"; } - 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); - ?> diff --git a/mod/choice/lib.php b/mod/choice/lib.php index 25c97ad5fd..25b2083c50 100644 --- a/mod/choice/lib.php +++ b/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"); + } +} + + ?> diff --git a/mod/choice/mod.html b/mod/choice/mod.html index 1f471660c2..3898b500ea 100644 --- a/mod/choice/mod.html +++ b/mod/choice/mod.html @@ -3,39 +3,39 @@ - + - + - + - + @@ -50,6 +50,6 @@ - +"> diff --git a/mod/choice/report.php b/mod/choice/report.php index 7fb30f218a..42ff7710d8 100644 --- a/mod/choice/report.php +++ b/mod/choice/report.php @@ -1,6 +1,7 @@ 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", "id>$course->shortname -> - id>Choices -> - id>$choice->name -> Responses", ""); + id>$strchoices -> + id>$choice->name -> $strresponses", ""); if (! $participants = get_records_sql("SELECT u.* FROM user u, user_students s, user_teachers t @@ -71,18 +76,7 @@ echo "

"; echo ""; } echo "

Choice Name:

:

Choice Text:

:

First choice:

:

">

Second choice:

:

">
cellcontent\">

"; - 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 "

"; diff --git a/mod/choice/view.html b/mod/choice/view.html index 286232c422..f43a9afdf1 100644 --- a/mod/choice/view.html +++ b/mod/choice/view.html @@ -13,7 +13,7 @@

- +">

diff --git a/mod/choice/view.php b/mod/choice/view.php index 5800e95ab7..3161db6d22 100644 --- a/mod/choice/view.php +++ b/mod/choice/view.php @@ -1,6 +1,7 @@ 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 = "id\">$course->shortname ->"; } print_header("$course->shortname: $choice->name", "$course->fullname", - "$navigation id>Choices -> $choice->name", "", "", true, + "$navigation id>$strchoices -> $choice->name", "", "", true, update_module_icon($cm->id, $course->id)); if (isteacher($course->id)) { - echo "

id\">View all responses

"; + echo "

id\">".get_string("viewallresponses", "choice")."

"; } 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; -} - ?>