diff --git a/lang/en/choice.php b/lang/en/choice.php index cf6cc88b78a..8d1b0398205 100644 --- a/lang/en/choice.php +++ b/lang/en/choice.php @@ -6,8 +6,7 @@ $string[modulenameplural] = "Choices"; #------------------------------------------------------------ $string[answered] = "Answered"; -$string[choice1] = "First choice"; -$string[choice2] = "Second choice"; +$string[choice] = "Choice \$a"; $string[choicename] = "Choice name"; $string[choicetext] = "Choice text"; $string[notanswered] = "Not answered yet"; diff --git a/mod/choice/lib.php b/mod/choice/lib.php index cad24204fc5..be0179b9384 100644 --- a/mod/choice/lib.php +++ b/mod/choice/lib.php @@ -1,18 +1,11 @@ id' AND user='$user->id'")) { - if ($current->answer == "1") { - $result->info = "'$choice->answer1'"; - } else if ($current->answer == "2") { - $result->info = "'$choice->answer2'"; - } + $result->info = "'".choice_get_answer($choice, $current->answer)."'"; $result->time = $current->timemodified; return $result; } @@ -23,11 +16,7 @@ function choice_user_outline($course, $user, $mod, $choice) { function choice_user_complete($course, $user, $mod, $choice) { if ($current = get_record_sql("SELECT * FROM choice_answers WHERE choice='$choice->id' AND user='$user->id'")) { - if ($current->answer == "1") { - $result->info = "'$choice->answer1'"; - } else if ($current->answer == "2") { - $result->info = "'$choice->answer2'"; - } + $result->info = "'".choice_get_answer($choice, $current->answer)."'"; $result->time = $current->timemodified; echo get_string("answered", "choice").": $result->info , last updated ".userdate($result->time); } else { @@ -90,11 +79,35 @@ function choice_get_answer($choice, $code) { return "$choice->answer1"; case 2: return "$choice->answer2"; + case 3: + return "$choice->answer3"; + case 4: + return "$choice->answer4"; + case 5: + return "$choice->answer5"; + case 6: + return "$choice->answer6"; default: return get_string("notanswered", "choice"); } } +function choice_get_choice($choiceid) { +// Gets a full choice record + + if ($choice = get_record("choice", "id", $choiceid)) { + $choice->answer[1] = $choice->answer1; + $choice->answer[2] = $choice->answer2; + $choice->answer[3] = $choice->answer3; + $choice->answer[4] = $choice->answer4; + $choice->answer[5] = $choice->answer5; + $choice->answer[6] = $choice->answer6; + return $choice; + } else { + return false; + } +} + ?> diff --git a/mod/choice/mod.html b/mod/choice/mod.html index 3898b500ea8..9405973a3e2 100644 --- a/mod/choice/mod.html +++ b/mod/choice/mod.html @@ -13,30 +13,52 @@
print_string("choicetext","choice") ?>:
print_string("choice1","choice") ?>:
print_string("choice","choice","1") ?>:
print_string("choice2","choice") ?>:
print_string("choice","choice","2") ?>:
print_string("choice","choice","3") ?>:
print_string("choice","choice","4") ?>:
print_string("choice","choice","5") ?>:
print_string("choice","choice","6") ?>: