File:  [LON-CAPA] / loncom / homework / templates / SelectFromOptions-multilingual.problem
Revision 1.1: download - view: text, annotated - select for diffs
Thu Dec 5 18:04:46 2013 UTC (10 years, 11 months ago) by bisitz
Branches: MAIN
CVS tags: version_2_12_X, version_2_11_X, version_2_11_5_msu, version_2_11_5, version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4, version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3, version_2_11_2_uiuc, version_2_11_2_msu, version_2_11_2_educog, version_2_11_2, version_2_11_1, version_2_11_0_RC3, version_2_11_0, HEAD
New problem template:
Multilingual problem using optionsresponse
Makes use of language function and translated tag

<problem>

<script type="loncapa/perl">
$bestlanguage = &languages(['en','de','fr']);
if ($bestlanguage eq 'de') {
    %colors = (green => 'Grün', red => 'Rot', blue => 'Blau');
} elsif ($bestlanguage eq 'fr') {
    %colors = (green => 'Vert', red => 'Rouge', blue => 'Bleu');
} else { # 'en' and default
    %colors = (green => 'Green', red => 'Red', blue => 'Blue');
}
</script>

<startouttext />
<p>
    <translated>
        <lang which="en">
            English Question
        </lang>
        <lang which="de">
            Deutscher Aufgabentext
        </lang>
        <lang which="fr">
            Texte de la question en français
        </lang>
        <lang which="default">
            English Question
        </lang>
    </translated>
</p>
<endouttext />

<optionresponse max="10" randomize="yes" TeXlayout="horizontal">
    <foilgroup options="('$colors{red}','$colors{green}','$colors{blue}')">
        <foil location="random" value="$colors{green}" name="Foil1">
            <startouttext />
                <translated>
                    <lang which="en">
                        Foil One, currently set to "Green"
                    </lang>
                    <lang which="de">
                        Auswahlmöglichkeit 1, derzeit gesetzt auf "Grün"
                    </lang>
                    <lang which="fr">
                        Alternative n°1, valeur de courant: "Vert"
                    </lang>
                    <lang which="default">
                        This is foil One. It is currently set to "Green".
                    </lang>
                </translated>
            <endouttext />
        </foil>
        <foil location="random" value="$colors{red}" name="Foil2">
            <startouttext />
                <translated>
                    <lang which="en">
                        Foil Two, currently set to "Red"
                    </lang>
                    <lang which="de">
                        Auswahlmöglichkeit 2, derzeit gesetzt auf "Rot"
                    </lang>
                    <lang which="fr">
                        Alternative n°2, valeur de courant: "Rouge"
                    </lang>
                    <lang which="default">
                        Foil Two, currently set to "Red"
                    </lang>
                </translated>
            <endouttext />
        </foil>
        <foil location="random" value="$colors{blue}" name="Foil3">
            <startouttext />
                <translated>
                    <lang which="en">
                        Foil Three, currently set to "Blue"
                    </lang>
                    <lang which="de">
                        Auswahlmöglichkeit 3, derzeit gesetzt auf "Blau"
                    </lang>
                    <lang which="fr">
                        Alternative n°3, valeur de courant: "Bleu"
                    </lang>
                    <lang which="default">
                        Foil Three, currently set to "Blue"
                    </lang>
                </translated>
            <endouttext />
        </foil>
        <foil location="random" value="$colors{red}" name="Foil4">
            <startouttext />
                <translated>
                    <lang which="en">
                        Foil Four, currently set to "Red"
                    </lang>
                    <lang which="de">
                        Auswahlmöglichkeit 4, derzeit gesetzt auf "Rot"
                    </lang>
                    <lang which="fr">
                        Alternative n°4, valeur de courant: "Rouge"
                    </lang>
                    <lang which="default">
                        Foil Four, currently set to "Red"
                    </lang>
                </translated>
            <endouttext />
        </foil>
    </foilgroup>
    <hintgroup showoncorrect="no">
        <startouttext /><endouttext />
    </hintgroup>
</optionresponse>

</problem>


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>