Skip to content

Commit

Permalink
devamı gelicek
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyasbozdemir committed Mar 16, 2024
1 parent 2d82488 commit 3b3b67f
Show file tree
Hide file tree
Showing 17 changed files with 339 additions and 54 deletions.
44 changes: 41 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,44 @@ Bu uygulama, kullanıcıların çeşitli sınav kitapçıklarından soruları ç
3. Kitapçık seçildikten sonra, kullanıcı soruları çözebilir.
4. Soruları çözdükten sonra, kullanıcı cevap anahtarlarını görüntüleyebilir.

## Veri Örneği

Örnek JSON veri:

```json
[
{
"Id": 1,
"AskText": "Android uygulama geliştirmede en yaygın kullanılan programlama dili nedir?",
"Explanation": null,
"Difficulty": "Medium",
"QuestionOptions": [
{
"Id": 1,
"Text": "Java",
"IsCorrect": true
},
{
"Id": 2,
"Text": "C#",
"IsCorrect": false
},
{
"Id": 3,
"Text": "Python",
"IsCorrect": false
},
{
"Id": 4,
"Text": "JavaScript",
"IsCorrect": false
}
]
}
]

```

## Özellikler

- Kullanıcı dostu arayüz
Expand All @@ -32,16 +70,16 @@ Bu uygulama, kullanıcıların çeşitli sınav kitapçıklarından soruları ç

## Kurulum

1. Bu depoyu klonlayın: `https://github.com/ilyasBozdemir/quiz-console-app`
1. Bu depoyu klonlayın: `git clone https://github.com/ilyasBozdemir/quiz-console-app`
2. Visual Studio'da çözümü açın: `quiz-console-app.sln`
3. Uygulamayı derleyin ve çalıştırın.

## Katkıda Bulunma

1. Bu depoyu çatallayın (fork).
2. Yeni bir dal (branch) oluşturun: `git checkout -b new-feature`
3. Değişikliklerinizi yapın ve bunları işleyin (commit): `git commit -am 'Yeni özellik ekle'`
4. Dalınızı ana depoya gönderin (push): `git push origin yeni-ozellik`
3. Değişikliklerinizi yapın ve bunları işleyin (commit): `git commit -m 'Yeni özellik ekle'`
4. Dalınızı ana depoya gönderin (push): `git push origin new-feature`
5. Bir birleştirme isteği (pull request) gönderin.

## Lisans
Expand Down
7 changes: 0 additions & 7 deletions quiz-console-app/Constants/OptionFormats.cs

This file was deleted.

9 changes: 6 additions & 3 deletions quiz-console-app/Enums/DifficultyLevel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
namespace quiz_console_app.Enums;

[Flags]
public enum DifficultyLevel
{
Easy,
Medium,
Hard
Easy = 1,
Medium = 2,
Hard = 4
}


8 changes: 0 additions & 8 deletions quiz-console-app/Enums/OptionType.cs

This file was deleted.

8 changes: 8 additions & 0 deletions quiz-console-app/Enums/QuizMode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace quiz_console_app.Enums;
[Flags]
public enum QuizMode
{
Quiz = 1,
DisplayBooklets = 2,
ExportData = 3
}
4 changes: 2 additions & 2 deletions quiz-console-app/Helpers/ConsoleColors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ public static class ConsoleColors
public static readonly ConsoleColor Title = ConsoleColor.DarkGreen;
public static readonly ConsoleColor Info = ConsoleColor.DarkBlue;
public static readonly ConsoleColor Warning = ConsoleColor.Yellow;
public static readonly ConsoleColor Debug = ConsoleColor.Magenta;
public static readonly ConsoleColor Prompt = ConsoleColor.Cyan;
public static readonly ConsoleColor Debug = ConsoleColor.Cyan;
public static readonly ConsoleColor Prompt = ConsoleColor.Magenta;
}
12 changes: 9 additions & 3 deletions quiz-console-app/Helpers/QuizDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ public static void DisplayBooklets(List<BookletViewModel> booklets)
{
foreach (var booklet in booklets)
{
Console.WriteLine();
ConsoleHelper.WriteColored("Kitapçık Id: ", ConsoleColors.Info);
ConsoleHelper.WriteColoredLine(booklet.Id, ConsoleColors.Default);

Expand Down Expand Up @@ -44,6 +43,9 @@ public static void DisplayAnswerKeys(List<AnswerKeyViewModel> answerKeys)
}

ConsoleHelper.WriteColored("Cevap Anahtarları:", ConsoleColors.Info);

int questionNumber = 1;

foreach (var answerKey in answerKeys)
{
ConsoleHelper.WriteColored("Kitapçık Id: ", ConsoleColors.Info);
Expand All @@ -52,8 +54,12 @@ public static void DisplayAnswerKeys(List<AnswerKeyViewModel> answerKeys)
ConsoleHelper.WriteColored(" Soru Id: ", ConsoleColors.Info);
ConsoleHelper.WriteColoredLine(answerKey.QuestionId, ConsoleColors.Default);

ConsoleHelper.WriteColored(" Doğru Seçenek Id: ", ConsoleColors.Info);
ConsoleHelper.WriteColoredLine(answerKey.CorrectOptionId, ConsoleColors.Default);
ConsoleHelper.WriteColored(" Doğru Seçenek : ", ConsoleColors.Info);
ConsoleHelper.WriteColored(answerKey.CorrectOptionText, ConsoleColors.Default);

ConsoleHelper.WriteColoredLine(answerKey.CorrectOptionText, ConsoleColors.Default);

questionNumber++;
}
}
}
1 change: 0 additions & 1 deletion quiz-console-app/Models/Booklet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ public class Booklet
public int Id { get; set; }
public string BookletName { get; set; }
public List<Question> Questions { get; set; }
public OptionType OptionType { get; set; }

public Booklet()
{
Expand Down
17 changes: 3 additions & 14 deletions quiz-console-app/Program.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
using quiz_console_app.Helpers;
using quiz_console_app.Models;
using quiz_console_app.Services;
using quiz_console_app.Services;

QuizService quizService = new QuizService();


List<Question> questions = new QuestionLoader().LoadQuestionsFromJson("software_questions.json"); // default path : {root-project}/bin/Debug/net8.0/software_questions.json

quizService.GenerateBooklets(questions, 1);

QuizDisplay.DisplayBooklets(quizService.Booklets);
QuizDisplay.DisplayAnswerKeys(quizService.AnswerKeys);

Console.ReadLine();
QuizModeHandlerService quizModeHandlerService = new QuizModeHandlerService();
quizModeHandlerService.ShowMainMenu();
29 changes: 29 additions & 0 deletions quiz-console-app/Screens/DisplayBookletScreen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using quiz_console_app.Helpers;
using quiz_console_app.Models;
using quiz_console_app.Services;
using quiz_console_app.ViewModels;

namespace quiz_console_app.Screens;

public class DisplayBookletScreen
{
private readonly QuizService _quizService;
private readonly QuestionLoader _questionLoader;
private readonly List<Question> _questions;
private readonly List<UserAnswerKeyViewModel> _userAnswers;
private readonly List<AnswerKeyViewModel> _answerKeys;
public DisplayBookletScreen()
{
_questionLoader = new QuestionLoader();
_questions = _questionLoader.LoadQuestionsFromJson("software_questions.json");
_quizService = new QuizService();
_quizService.GenerateBooklets(_questions, 1);
_userAnswers = new List<UserAnswerKeyViewModel>();
_answerKeys = QuizService.AnswerKeys;
}

public void Start()
{

}
}
9 changes: 9 additions & 0 deletions quiz-console-app/Screens/ExportDataScreen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace quiz_console_app.Screens;

public class ExportDataScreen
{
public void Start()
{

}
}
100 changes: 100 additions & 0 deletions quiz-console-app/Screens/QuizModeScreen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using quiz_console_app.Helpers;
using quiz_console_app.Models;
using quiz_console_app.Services;
using quiz_console_app.ViewModels;

namespace quiz_console_app.Screens;

public class QuizModeScreen
{
private readonly QuizService _quizService;
private readonly QuestionLoader _questionLoader;
private readonly List<Question> _questions;
private readonly List<UserAnswerKeyViewModel> _userAnswers;
private readonly List<AnswerKeyViewModel> _answerKeys;

public QuizModeScreen()
{
_questionLoader = new QuestionLoader();
_questions = _questionLoader.LoadQuestionsFromJson("software_questions.json");
_quizService = new QuizService();
_quizService.GenerateBooklets(_questions, 1);
_userAnswers = new List<UserAnswerKeyViewModel>();
_answerKeys = QuizService.AnswerKeys;
}

public void Start()
{
var Booklet = QuizService.Booklets.FirstOrDefault();
int questionNumber = 1;
foreach (var question in Booklet.Questions)
{
ConsoleHelper.WriteColoredLine($"{questionNumber}. Soru: ", ConsoleColors.Info);
ConsoleHelper.WriteColoredLine(question.AskText, ConsoleColors.Default);

for (int i = 0; i < question.QuestionOptions.Count; i++)
{
char optionLetter = (char)(65 + i);

ConsoleHelper.WriteColored($"{optionLetter})", ConsoleColors.Info);
ConsoleHelper.WriteColored(
$"{question.QuestionOptions[i].Text} ",
ConsoleColors.Default
);
}
Console.WriteLine();
Console.Write("Cevabınızı girin (Boş bırakmak için Enter tuşuna basın) : ");
string userAnswerFromReadLine = Console.ReadLine().ToUpper();
Console.WriteLine();
if (
userAnswerFromReadLine.Length == 1
&& userAnswerFromReadLine[0] >= (char)65
&& userAnswerFromReadLine[0] <= (char)(65 + question.QuestionOptions.Count - 1)
)
{
_userAnswers.Add(
new UserAnswerKeyViewModel
{
BookletId = Booklet.Id,
QuestionId = question.Id,
UserAnswerOption = userAnswerFromReadLine
}
);
questionNumber++;
}
else if (userAnswerFromReadLine.Length == 0) // cevap null ise
{
_userAnswers.Add(
new UserAnswerKeyViewModel
{
BookletId = Booklet.Id,
QuestionId = question.Id,
UserAnswerOption = null
}
);
questionNumber++;
}
else
{
char optionLetter = (char)64;
string optionsText = "";
for (int i = 0; i < question.QuestionOptions.Count; i++)
{
optionLetter++;
optionsText +=
(i != 0)
? (i != question.QuestionOptions.Count - 1)
? $", {optionLetter}"
: $" veya {optionLetter}"
: $"{optionLetter}";
}

string errorMessage =
$"Geçersiz cevap. Lütfen {optionsText} harflerinden birini girin. veya boş bırakmak için sadece Enter tuşuna basın.";

ConsoleHelper.WriteColoredLine(errorMessage, ConsoleColors.Error);
}
}
_quizService.EvaluateQuizResults(_userAnswers);
}
}
Loading

0 comments on commit 3b3b67f

Please sign in to comment.