| 1 |
figdor32 |
2 |
using System; |
| 2 |
|
|
using System.Collections.Generic; |
| 3 |
|
|
using System.Linq; |
| 4 |
|
|
using System.Text; |
| 5 |
|
|
using System.Threading.Tasks; |
| 6 |
|
|
|
| 7 |
|
|
namespace TELTest.Gamemodes { |
| 8 |
|
|
public class Pisania : QuizGamemode { |
| 9 |
|
|
public Pisania() { |
| 10 |
|
|
} |
| 11 |
|
|
public Pisania(QuizContainer container, BaseQuizContext context) : base(container, context) { |
| 12 |
|
|
} |
| 13 |
|
|
|
| 14 |
|
|
public override String Name => "Pisania"; |
| 15 |
|
|
|
| 16 |
|
|
public override String SystemName => "Pisania"; |
| 17 |
|
|
|
| 18 |
|
|
public override String Description => "Tryb pisania wymaga od cieie napisania pelnej odpowiedzi zamiast litery."; |
| 19 |
|
|
public override QuizGamemode CreateInstance(QuizContainer quiz, BaseQuizContext context) => new Pisania(quiz, context); |
| 20 |
|
|
public override async Task Begin() { |
| 21 |
|
|
int score = 0; |
| 22 |
|
|
await WriteLine("Tytul quizu: " + Quiz.Title); |
| 23 |
|
|
await WriteLine("Autor quizu: " + Quiz.Author); |
| 24 |
|
|
await Write("Rozpocznij... "); |
| 25 |
|
|
await ReadKey(); |
| 26 |
|
|
await Flush(); |
| 27 |
|
|
for (int i = 0; i < Quiz.Questions.Length; i++) { |
| 28 |
|
|
await Clear(); |
| 29 |
|
|
await WriteLine((i + 1) + ". " + Quiz.Questions[i].Content); |
| 30 |
|
|
|
| 31 |
|
|
await Write("Twoja odpowiedz: "); |
| 32 |
|
|
string ans = await ReadLine(); |
| 33 |
|
|
await Flush(); |
| 34 |
|
|
await WriteLine(); |
| 35 |
|
|
ans = ans.Trim().ToUpper(); |
| 36 |
|
|
bool wasCorrect = false; |
| 37 |
|
|
List<string> correct = new List<string>(); |
| 38 |
|
|
for (int j = 0; j < Quiz.Questions[i].Answers.Length; j++) { |
| 39 |
|
|
var item = Quiz.Questions[i].Answers[j]; |
| 40 |
|
|
if (item.Correct) correct.Add(item.Content); |
| 41 |
|
|
if (item.Content.Trim().ToUpper() == ans && item.Correct) { wasCorrect = true; break; } |
| 42 |
|
|
} |
| 43 |
|
|
if (!wasCorrect && correct.Count == 0 && string.IsNullOrWhiteSpace(ans)) { |
| 44 |
|
|
wasCorrect = true; |
| 45 |
|
|
} |
| 46 |
|
|
if (wasCorrect) { |
| 47 |
|
|
if (correct.Count == 0) |
| 48 |
|
|
await WriteLine("Dobrze! Nie bylo poprawnej odpowiedzi."); |
| 49 |
|
|
else |
| 50 |
|
|
await WriteLine("Dobrze! Zdobywasz punkt."); |
| 51 |
|
|
score++; |
| 52 |
|
|
} else { |
| 53 |
|
|
if (correct.Count == 1) { |
| 54 |
|
|
await WriteLine("Zle! Poprawna odpowiedz to: {0}", correct[0]); |
| 55 |
|
|
} else if (correct.Count == 0) { |
| 56 |
|
|
await WriteLine("Zle! Nie ma poprawnej odpowiedzi."); |
| 57 |
|
|
} else { |
| 58 |
|
|
await WriteLine("Zle! Poprawne odpowiedzi to:\r\n - {0}", string.Join("\r\n - ", correct)); |
| 59 |
|
|
} |
| 60 |
|
|
} |
| 61 |
|
|
await Write("\r\n\r\n"); |
| 62 |
|
|
await Pause(); |
| 63 |
|
|
} |
| 64 |
|
|
await WriteLine("Twoj wynik: {0}", score, Quiz.Questions.Length); |
| 65 |
|
|
await Pause(); |
| 66 |
|
|
|
| 67 |
|
|
await DoScoreSubmission(score); |
| 68 |
|
|
} |
| 69 |
|
|
|
| 70 |
|
|
} |
| 71 |
|
|
} |