[LON-CAPA-cvs] cvs: doc /loncapafiles loncapafiles.lpml loncom/html/adm/help/tex Authoring_Multilingual_Problems.tex

bisitz bisitz at source.lon-capa.org
Wed Apr 23 13:27:04 EDT 2014


bisitz		Wed Apr 23 17:27:04 2014 EDT

  Added files:                 
    /loncom/html/adm/help/tex	Authoring_Multilingual_Problems.tex 

  Modified files:              
    /doc/loncapafiles	loncapafiles.lpml 
  Log:
  New help file about how to write multilingual problems, e.g. explains the translated tag and the languages function.
  (Interface inclusion, i.e. help link, will follow later)
  
  
  
Index: doc/loncapafiles/loncapafiles.lpml
diff -u doc/loncapafiles/loncapafiles.lpml:1.888 doc/loncapafiles/loncapafiles.lpml:1.889
--- doc/loncapafiles/loncapafiles.lpml:1.888	Tue Apr 22 17:10:52 2014
+++ doc/loncapafiles/loncapafiles.lpml	Wed Apr 23 17:27:04 2014
@@ -2,7 +2,7 @@
  "http://lpml.sourceforge.net/DTD/lpml.dtd">
 <!-- loncapafiles.lpml -->
 
-<!-- $Id: loncapafiles.lpml,v 1.888 2014/04/22 17:10:52 bisitz Exp $ -->
+<!-- $Id: loncapafiles.lpml,v 1.889 2014/04/23 17:27:04 bisitz Exp $ -->
 
 <!--
 
@@ -3222,6 +3222,7 @@
 Authoring_Intro.tex;
 Authoring_Library_Scripts.tex;
 Authoring_Math_Editor.tex;
+Authoring_Multilingual_Problems.tex;
 Authoring_NumericalResponse.tex;
 Authoring_OptionResponse.tex;
 Authoring_Output_Tags.tex;

Index: loncom/html/adm/help/tex/Authoring_Multilingual_Problems.tex
+++ loncom/html/adm/help/tex/Authoring_Multilingual_Problems.tex
\label{Authoring_Multilingual}
\textbf{How to write problems in different languages?}

LON-CAPA offers the optional possibility to create multilingual problems.
You can use different languages for the task text and also for the options and
all other texts shown to the student. LON-CAPA automatically finds the best
fitting language for the texts to show to your students.


\textbf{Problem Template}

A good point to start is to select the template \textbf{Option Response -
Matching (multilingual)} when creating a new problem. You can see there how
to show texts and options in an optionresponse problem
\ref{Authoring_OptionResponse} in different languages. More details how to
write such problems as follows.


\textbf{Different languages in a text block}

Text to show to students is surrounded by <startouttext /> and <endouttext>.
If you use only one language, just type your text within these tags:

\begin{verbatim}
<startouttext />
English question
<endouttext />
\end{verbatim}

If you want to offer your text with more than one language, use the
\textbf{<translated>} tag within the <startouttext> / <endouttext> tag. Type
your text for each language in a \textbf{<lang>} tag. Specify the language code
in the attribute ``which'', e.g. ``en'' for English or ``de'' for German.
When the problem is presented to your students, LON-CAPA will automatically
choose the best language fitting to the user's environment taking care of
personal preferences. Details see below.

Don't forget to always have a \textbf{default language} present. If the default
was missing and LON-CAPA didn't find any fitting language, no text at all would
be shown to the student. It is recommended to use English as default or -
depending on the field of application - the language which fits best in the
context where the problem will be likely used.

Example (three different languages and default):
\begin{verbatim}
<startouttext />
   <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>
<endouttext />
\end{verbatim}

Add a <lang> tag and the corresponding text for each additional language. Watch
out to extend all <translated> tags within this problem in this way to have a
consistent language for all texts in the problem.


\textbf{Interface language vs. problem language}

LON-CAPA supports various languages for the web interface, e.g. for menu items
and help files. These languages are not necessarily dependent on the languages
offered within problems. I.e. it is possible to have the web interface shown
in Chinese and a problem is shown in Turkish. However, the user's language
preference is considered when the interface is rendered and also when the best
fitting language for texts in a problem is chosen. Details see below.


\textbf{Language Codes}

Some language codes which can be used in the <lang> tag within the <translated>
tag:
\begin{itemize}
\item ar - Arabic
\item de - German
\item en - English
\item es - Spanish
\item fa - Persian
\item fr - French
\item he - Hebrew
\item ja - Japanese
\item pt - Portuguese
\item ru - Russian
\item tr - Turkish
\item zh - Chinese (Simplified)
\end{itemize}

These languages are currently also available as interface language, see
Language \ref{Prefs_Language} in the User Preferences section.
You can use other languages in your problems.


\textbf{Different languages in options, variables, etc.}

If you use a script block to create dynamic content and it contains text, the
\textbf{\&languages()} function is used to offer these texts in different
languages. This function can be called in different ways, see Script Functions
\ref{Problem_LON-CAPA_Functions}.
One way is to provide the language codes for the languages you like to support
in an anonymous array to the function and get back the best fitting language of
those. Use the returned language code to decide which text in which language
should be used. 

Example:
\begin{verbatim}
<script type="loncapa/perl">
&bestlanguage = &languages(['en','de','fr']);
if ($bestlanguage eq 'de') {
   $optiontext = 'rot';
} elsif ($bestlanguage eq 'fr') {
   $optiontext = 'rouge';
} else { # 'en' and default
   $optiontext = 'red';
}
</script>
\end{verbatim}


\textbf{Consistent language with <translated> and \&languages()}

If you use both, <translated> and \&languages(), in your problem, always make
sure to keep the languages synchronized. Use exactly the same language codes
for the \&languages() call like those used in the <lang> tags within
<translated>.

\textbf{Testing multilingual problems}

You can temporarily change the language for a problem in the \emph{Problem
Testing} screen. Use the ``Language'' dropdown list to choose the language
to be used for testing and click \fbox{Change View}.

Note: Your own personal settings apply, including your browser settings (see
below).


\textbf{Language hierarchy model in LON-CAPA}

LON-CAPA uses the best fitting language by considering the following settings
(if available), in the order as follows:
\begin{enumerate}
\item Overall default: English
\item Server setting (see Domain Configuration \ref{Domain_Configuration_LangTZAuth})
\item User's language preference(s) in the web browser (client side)
\item User preference: Language \ref{Prefs_Language}
\item Course setting (see Course Configuration \ref{Course_Prefs_Language})
\item Individual problem content (e.g. hard coded language)
\end{enumerate}

Example 1:

The server is set to French, the user's preference in LON-CAPA is set to
prefer Spanish, the problem is programmed to offer Portuguese ans Spanish,
and the problem default language is German.
LON-CAPA shows this problem in Spanish to the student.

Example 2:

The server is set to French, the user's preference in LON-CAPA is set to
prefer Spanish, the problem is programmed to offer Turkish and Portuguese,
and the problem default language is German.
LON-CAPA shows this problem in French to the student.

Example 3:

The user's preference in LON-CAPA is set to prefer Spanish, the problem
is programmed to offer French and Portuguese, and the problem default language
is German.
LON-CAPA shows this problem in German to the student.


\textbf{Legacy code with <languageblock>}

Some old problems might contain the \textbf{<languageblock>} tag. This tag is
deprecated and it is discouraged to use it. The functionality is different to
<translated>. It does not fully support the practical needs for offering
multilingual problems. If you adapt such a problem for your own purposes, it
is recommended to replace <languageblock> by <translated> as described above.





More information about the LON-CAPA-cvs mailing list