2
* Copyright (C) 2009 Jordi Mas i Hernàndez <jmas@softcatala.org>
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation; either version 2 of the
7
* License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* General Public License for more details.
14
* You should have received a copy of the GNU General Public
15
* License along with this program; if not, write to the
16
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
* Boston, MA 02111-1307, USA.
22
using System.Collections.Generic;
27
using gbrainy.Core.Libraries;
29
namespace gbrainy.Core.Main.Verbal
31
public class AnalogiesMultipleOptions : Analogies
33
static protected Dictionary <int, Analogy> analogies;
34
static protected ArrayListIndicesRandom analogies_indices;
35
static protected int analogies_index = 0;
37
public AnalogiesMultipleOptions ()
39
if (analogies == null)
40
analogies = AnalogiesFactory. Get (Analogy.Type.MultipleOptions);
43
public override string Name {
44
get { return Catalog.GetString ("Multiple options");}
47
public override string Question {
49
string str = string.Empty;
54
if (current.answers == null)
55
return current.question;
57
for (int n = 0; n < current.answers.Length; n++)
59
str+= GetPossibleAnswer (n);
61
if (n +1 < current.answers.Length) {
62
// Translators: this the separator used when concatenating possible options for answering verbal analogies
63
// For example: "Possible correct answers are: a, b, c, d."
64
str += Catalog.GetString (", ");
68
// Translators: {0} is replaced by a question and {1} by the suggestions on how to answer
69
// E.g: What is the correct option? Answer A, B, C.
70
return String.Format (Catalog.GetString ("{0} Answer {1}."),
76
public override ArrayListIndicesRandom Indices {
77
get { return analogies_indices; }
78
set { analogies_indices = value; }
81
public override int CurrentIndex {
82
get { return analogies_index; }
83
set { analogies_index = value; }
86
public override Dictionary <int, Analogy> List {
87
get { return analogies; }
90
public override void Initialize ()
94
if (current == null || current.answers == null)
97
right_answer = GetPossibleAnswer (current.right);
100
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
102
double x = DrawAreaX, y = DrawAreaY + 0.1;
104
base.Draw (gr, area_width, area_height, rtl);
106
if (current == null || current.answers == null)
109
gr.SetPangoLargeFontSize ();
111
gr.ShowPangoText (Catalog.GetString ("Possible answers are:"));
113
gr.SetPangoNormalFontSize ();
117
for (int n = 0; n < current.answers.Length; n++)
120
gr.ShowPangoText (String.Format ("{0}) {1}", GetPossibleAnswer (n), current.answers[n].ToString ()));