Skip to content

Commit cc73ce0

Browse files
committed
on the first start challenges are imported automatically if there are no challenges in the database
1 parent b6bd856 commit cc73ce0

File tree

2 files changed

+263
-1
lines changed

2 files changed

+263
-1
lines changed

app/src/main/java/de/fhdw/ergoholics/brainphaser/activities/main/ProxyActivity.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,23 @@
44
import android.net.Uri;
55
import android.os.Bundle;
66

7+
import java.io.InputStream;
8+
79
import javax.inject.Inject;
810

911
import de.fhdw.ergoholics.brainphaser.BrainPhaserApplication;
1012
import de.fhdw.ergoholics.brainphaser.BrainPhaserComponent;
1113
import de.fhdw.ergoholics.brainphaser.R;
1214
import de.fhdw.ergoholics.brainphaser.activities.BrainPhaserActivity;
1315
import de.fhdw.ergoholics.brainphaser.activities.createuser.CreateUserActivity;
16+
import de.fhdw.ergoholics.brainphaser.database.ChallengeDataSource;
1417
import de.fhdw.ergoholics.brainphaser.logic.UserManager;
18+
import de.fhdw.ergoholics.brainphaser.logic.fileimport.FileImport;
19+
import de.fhdw.ergoholics.brainphaser.logic.fileimport.exceptions.ElementAmountException;
20+
import de.fhdw.ergoholics.brainphaser.logic.fileimport.exceptions.FileFormatException;
21+
import de.fhdw.ergoholics.brainphaser.logic.fileimport.exceptions.InvalidAttributeException;
22+
import de.fhdw.ergoholics.brainphaser.logic.fileimport.exceptions.UnexpectedElementException;
23+
import de.fhdw.ergoholics.brainphaser.model.Challenge;
1524

1625
/**
1726
* Created by funkv on 29.02.2016.
@@ -20,7 +29,10 @@
2029
* user and redirects to the main activity.
2130
*/
2231
public class ProxyActivity extends BrainPhaserActivity {
23-
@Inject UserManager mUserManager;
32+
@Inject
33+
UserManager mUserManager;
34+
@Inject
35+
ChallengeDataSource mChallengeDataSource;
2436

2537
/**
2638
* This method injects the activity to the given BrainPhaserComponent
@@ -51,6 +63,17 @@ public void onCreate(Bundle savedInstanceState) {
5163
startActivity(intent);
5264
finish();
5365
} else {
66+
// Import challenges if the database does not include any
67+
if (mChallengeDataSource.getAll().size() == 0) {
68+
InputStream is = getResources().openRawResource(R.raw.challenges);
69+
try {
70+
FileImport.importBPC(is, application);
71+
} catch (Exception e) {
72+
throw new RuntimeException("An unexpected error has occured when trying to add " +
73+
"example challenges!");
74+
}
75+
}
76+
5477
startActivity(new Intent(Intent.ACTION_INSERT, Uri.EMPTY, getApplicationContext(), CreateUserActivity.class));
5578
finish();
5679
}

app/src/main/res/raw/challenges.bpc

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<categories>
3+
<category description="Schulwissen zu Elektrotechnik" image="@drawable/physik_elektrizitaet" title="Physik">
4+
<challenge question="Mit welchem Symbol wird der elektrische Widerstand angegeben?"
5+
type="1">
6+
<answer correct="true" text="R" />
7+
<answer correct="false" text="I" />
8+
<answer correct="false" text="U" />
9+
<answer correct="false" text="A" />
10+
</challenge>
11+
<challenge question="Wie lautet das Ohmsche Gesetz?" type="1">
12+
<answer correct="true" text="R = U / I" />
13+
<answer correct="true" text="U = R * I" />
14+
<answer correct="true" text="I = U / R" />
15+
<answer correct="false" text="R = U * I" />
16+
</challenge>
17+
<challenge question="In welcher Richtung fließt der elektische Strom aus technischer und aus physikalischer Sicht?" type="3">
18+
<answer correct="true" text="Die technische Stromrichtung: Von Plus nach Minus" />
19+
<answer correct="true" text="Die physikalische Stromrichtung: Von Minus nach Plus." />
20+
</challenge>
21+
<challenge question="Was ist die physische Einheit für elektrische Stromstärke?" type="1">
22+
<answer correct="false" text="Volt V" />
23+
<answer correct="true" text="Ampere A" />
24+
<answer correct="false" text="Watt W" />
25+
<answer correct="false" text="Ohm Ω" />
26+
</challenge>
27+
<challenge question="Wie groß ist der elektrische Gesamtwiderstand bei einer Reihenschaltung, in der ein Widerstand von 10 Ω, 20 Ω und 30 Ω verbaut sind?"
28+
type="2">
29+
<answer correct="true" text="60 Ω" />
30+
<answer correct="true" text="60Ω" />
31+
<answer correct="true" text="60" />
32+
<answer correct="true" text="60 Ohm" />
33+
<answer correct="true" text="60 ohm" />
34+
</challenge>
35+
<challenge question="Was gibt die physische Einheit Watt W an?" type="1">
36+
<answer correct="false" text="Elektrische Spannung" />
37+
<answer correct="true" text="Elektische Wirkleistung" />
38+
<answer correct="false" text="Elektrischer Widerstand" />
39+
<answer correct="false" text="Elektrische Stärke" />
40+
</challenge>
41+
<challenge question="In welcher Einheit wird die Spannung angegeben?" type="1">
42+
<answer correct="true" text="Volt V" />
43+
<answer correct="false" text="Ampere A" />
44+
<answer correct="false" text="Watt W" />
45+
<answer correct="false" text="Ohm Ω" />
46+
</challenge>
47+
<challenge question="In einem Stromkreis ist ein Widerstand von 10 Ohm verbaut und es fließen 5 Ampere elektrische Stromstärke hindurch. Wie groß ist die Spannung in diesem Stromkreis?"
48+
type="2">
49+
<answer correct="true" text="50 V" />
50+
<answer correct="true" text="50" />
51+
<answer correct="true" text="50V" />
52+
<answer correct="true" text="50 v" />
53+
<answer correct="true" text="50v" />
54+
</challenge>
55+
</category>
56+
57+
58+
<category description="Business Englisch speziell zum Thema International Trade" image="@drawable/international_trade" title="Trade">
59+
<challenge question="A maximum quantity of goods of a specific kind that can be imported into a country is a?"
60+
type="1">
61+
<answer correct="false" text="trade barrier" />
62+
<answer correct="true" text="quota" />
63+
<answer correct="false" text="comparative advantage" />
64+
<answer correct="false" text="absolute advantage" />
65+
</challenge>
66+
<challenge question="A name or a symbol showing that a product is made by a particular producer and which cannot be legally used by anyone else is a?"
67+
type="3">
68+
<answer correct="true" text="trademark" />
69+
</challenge>
70+
<challenge question="What is a surplus?" type="1">
71+
<answer correct="true" text="A negative balance of trade or payments." />
72+
<answer
73+
correct="false"
74+
text="The difference between what a country receives and pays for its exports and imports of goods." />
75+
<answer correct="true" text="A positive balance of trade or payments" />
76+
<answer
77+
correct="false"
78+
text="The difference between a country’s total earnings and its total expenditure on imports." />
79+
</challenge>
80+
<challenge question="Which term describes the selling of goods abroad at a price that is lower than production cost?" type="2">
81+
<answer correct="true" text="dumping" />
82+
<answer correct="true" text="Dumping" />
83+
</challenge>
84+
<challenge question="What is a generic product?" type="3">
85+
<answer correct="true"
86+
text="A cheaper copy of a product that is not marked with the producer’s name." />
87+
</challenge>
88+
<challenge question="Which term describes the restriction of imports by means of trade barriers (such as tariffs and quotas)?"
89+
type="2">
90+
<answer correct="true" text="Protectionism" />
91+
<answer correct="true" text="protectionism" />
92+
</challenge>
93+
<challenge question="What is the difference between a country’s total earnings and its total expenditure on imports called?"
94+
type="1">
95+
<answer correct="false" text="balance of trade" />
96+
<answer correct="false" text="surplus" />
97+
<answer correct="true" text="balance of payments" />
98+
<answer correct="false" text="autarky" />
99+
</challenge>
100+
<challenge question="A strategic industry is one that …?" type="1">
101+
<answer correct="true" text="is particularly important to a country’s economy." />
102+
<answer correct="false" text="produces goods at a lower cost than any other country." />
103+
<answer correct="false"
104+
text="produces particular goods more efficiently than any other country." />
105+
<answer correct="false"
106+
text="has government policies or regulations that restrict international trade." />
107+
</challenge>
108+
</category>
109+
110+
111+
<category description="Grundlagen zu IT-Netzwerken" image="@drawable/computer" title="Netzwerke">
112+
<challenge question="Was bedeutet TCP" type="3">
113+
<answer correct="true" text="Transmission Control Protocol" />
114+
</challenge>
115+
<challenge question="Was sind die grundlegenden Eigenschaften des Internet Protokolls?" type="1">
116+
<answer correct="true" text="Unzuverlässig" />
117+
<answer correct="false" text="Zuverlässig" />
118+
<answer correct="true" text="Verbindungslos" />
119+
<answer correct="true" text="Paketorientiert" />
120+
</challenge>
121+
<challenge question="Für welche Dienste ist SMB ein Kommunikationsprotokoll?" type="3">
122+
<answer correct="true" text="SBM ist ein Kommunikationsprotokoll für Datei-, Druck- und andere Serverdienste im Netzwerk" />
123+
</challenge>
124+
<challenge question="Was bedeutet VNC?" type="2">
125+
<answer correct="true" text="Virtual Network Computing" />
126+
<answer correct="true" text="virtual network computing" />
127+
</challenge>
128+
<challenge question="Wozu dient das Address Resolution Protocol?" type="3">
129+
<answer correct="true" text="Es wandelt MAC-Adressen in die zugehörigen IP-Adressen um" />
130+
</challenge>
131+
<challenge question="Welche Protokolle arbeiten nach dem OSI-Schichten Modell auf dem Application Layer?" type="1">
132+
<answer correct="true" text="HTTP" />
133+
<answer correct="false" text="IP" />
134+
<answer correct="true" text="FTP" />
135+
<answer correct="true" text="SMB" />
136+
</challenge>
137+
<challenge question="Wofür steht die Abkürzung DHCP?" type="2">
138+
<answer correct="true" text="Dynamic Host Configuration Protocol" />
139+
<answer correct="true" text="dynamic host configuration protocol" />
140+
</challenge>
141+
<challenge question="Was sind Komponenten eines HTTP Requests?" type="1">
142+
<answer correct="true" text="HTTP Methode" />
143+
<answer correct="false" text="MIME-Type" />
144+
<answer correct="true" text="URL" />
145+
<answer correct="false" text="Status-code" />
146+
</challenge>
147+
</category>
148+
149+
150+
<category description="Vokabular zu Business Englisch" image="@drawable/englisch" title="Englisch">
151+
<challenge question="Was bedeutet Vertrieb auf Englisch?" type="2">
152+
<answer correct="true" text="Sales" />
153+
<answer correct="true" text="sales" />
154+
</challenge>
155+
<challenge question="Was bedeutet Zahlungsunfähigkeit auf Englisch?" type="3">
156+
<answer correct="true" text="failure to pay" />
157+
</challenge>
158+
<challenge question="What does liability mean in German?" type="1">
159+
<answer correct="false" text="Liberalität" />
160+
<answer correct="true" text="Haftung" />
161+
<answer correct="false" text="Ausschluss" />
162+
<answer correct="false" text="Lizenz" />
163+
</challenge>
164+
<challenge question="What does pundit mean in German?" type="3">
165+
<answer correct="true" text="Experte, Insider" />
166+
</challenge>
167+
<challenge question="Was bedeutet Unterdrückung im Sinne von Volksunterdrückung?" type="2">
168+
<answer correct="true" text="repression" />
169+
</challenge>
170+
<challenge question="Which parts constitute the triple bottom line?" type="1">
171+
<answer correct="true" text="financial" />
172+
<answer correct="false" text="social" />
173+
<answer correct="true" text="private" />
174+
<answer correct="true" text="environmental" />
175+
</challenge>
176+
<challenge question="Was bedeutet Konkurrenz auf Englisch?" type="2">
177+
<answer correct="true" text="competitor" />
178+
<answer correct="true" text="opponent" />
179+
<answer correct="true" text="revil" />
180+
</challenge>
181+
<challenge question="To concide has the same meaning as?" type="1">
182+
<answer correct="false" text="to consult" />
183+
<answer correct="false" text="to negotiate" />
184+
<answer correct="true" text="to admit" />
185+
<answer correct="false" text="to access" />
186+
</challenge>
187+
</category>
188+
189+
190+
<category description="Grundwissen zum Thema Europäische Union." image="@drawable/european_commission" title="EU">
191+
<challenge question="In welchem Jahr wurde Kroatien ein Mitglied der EU?" type="2">
192+
<answer correct="true" text="2013" />
193+
</challenge>
194+
<challenge question="Was besagt das Schengen Abkommen?" type="1">
195+
<answer correct="true"
196+
text="Keine Polizei Kontrollen an den Grenzen zwischen EU Ländern" />
197+
<answer correct="true" text="Verstärkte Kontrollen an EU Grenzen zu nicht EU-Ländern" />
198+
<answer correct="true" text="Freier Import und Export zwischen EU Staaten" />
199+
<answer correct="false" text="Überall die gleiche Geldwährung" />
200+
</challenge>
201+
<challenge question="Unter welcher Bezeichnung haben sich im Jahr 1952 Deutschland, die Benelux Staaten, Frankreich und Italien zusammengeschlossen?"
202+
type="3">
203+
<answer correct="true" text="Die europäische Kohle und Stahl Gemeinschaft" />
204+
<answer correct="true" text="Montanunion" />
205+
<answer correct="true" text="EGKS" />
206+
</challenge>
207+
<challenge question="Welcher EU-Kreis wird nicht gewählt?" type="1">
208+
<answer correct="false" text="EU-Parlament" />
209+
<answer correct="true" text="EU-Kommission" />
210+
<answer correct="false" text="EU-Rat" />
211+
<answer correct="false" text="EU-Präsident" />
212+
</challenge>
213+
<challenge question="Was ist keine Rolle der europäischen Kommission?" type="1">
214+
<answer correct="false" text="Legislative" />
215+
<answer correct="false" text="Executive" />
216+
<answer correct="true" text="Aufstellen des EU-Budgets" />
217+
<answer correct="false" text="Repräsentation der EU auf der internationalen Ebene" />
218+
</challenge>
219+
<challenge question="Nach wie vielen Jahren wird das europäische Parlament gewählt?" type="2">
220+
<answer correct="true" text="5" />
221+
<answer correct="true" text="5 Jahre" />
222+
<answer correct="true" text="nach 5 Jahren" />
223+
<answer correct="true" text="5 jahre" />
224+
<answer correct="true" text="nach 5 jahren" />
225+
<answer correct="true" text="fünf Jahren" />
226+
<answer correct="true" text="Fünf Jahren" />
227+
</challenge>
228+
<challenge question="Wer ist Präsident des EU-Parlaments?" type="1">
229+
<answer correct="false" text="Angela Merkel" />
230+
<answer correct="false" text="Jean-Claude Juncker" />
231+
<answer correct="false" text="Donald Trump" />
232+
<answer correct="true" text="Martin Schulz" />
233+
</challenge>
234+
<challenge question="Aus wie vielen Mitgliedsländern besteht das europäische Parlament?"
235+
type="2">
236+
<answer correct="true" text="28" />
237+
</challenge>
238+
</category>
239+
</categories>

0 commit comments

Comments
 (0)