-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa5659c
commit 4f9131a
Showing
16 changed files
with
430 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace quiz_console_app.Helpers; | ||
|
||
public static class OptionHelper | ||
{ | ||
public static char ToOptionLetter(int optionId) | ||
{ | ||
if (optionId < 0 || optionId > 25) | ||
throw new ArgumentException("Option ID must be between 0 and 25"); | ||
|
||
return ((char)(65 + optionId)); | ||
} | ||
|
||
public static int FromOptionLetter(char optionLetter) | ||
{ | ||
if (!char.IsLetter(optionLetter)) | ||
throw new ArgumentException("Input must be a letter."); | ||
|
||
return char.ToUpper(optionLetter) - 65; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using quiz_console_app.ViewModels; | ||
|
||
namespace quiz_console_app.Models; | ||
|
||
public class AnswerKeyCollection | ||
{ | ||
private Dictionary<int, List<AnswerKeyViewModel>> _answerKeysByBookletId; | ||
|
||
public AnswerKeyCollection() | ||
{ | ||
_answerKeysByBookletId = new Dictionary<int, List<AnswerKeyViewModel>>(); | ||
} | ||
|
||
public void AddAnswerKey(int bookletId, List<AnswerKeyViewModel> answerKeys) | ||
{ | ||
_answerKeysByBookletId.Add(bookletId, answerKeys); | ||
} | ||
|
||
public List<AnswerKeyViewModel> GetAnswerKeys(int bookletId) | ||
{ | ||
if (_answerKeysByBookletId.ContainsKey(bookletId)) | ||
{ | ||
return _answerKeysByBookletId[bookletId]; | ||
} | ||
else | ||
{ | ||
return new List<AnswerKeyViewModel>(); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,24 @@ | ||
namespace quiz_console_app.Models; | ||
|
||
|
||
// ScoringRules buna göre net hesaplaması yapılcaktır. | ||
public class QuizResultSummary | ||
{ | ||
public int CorrectCount { get; set; } = 0; | ||
public int IncorrectCount { get; set; } = 0; | ||
public int BlankCount { get; set; } = 0; | ||
public int NetCount => CorrectCount - (IncorrectCount + BlankCount); | ||
public double SuccessPercentage => CalculateSuccessPercentage(); | ||
public double NetCount => CalculateNetCount(); | ||
public int TotalQuestions { get; set; } = 0; | ||
|
||
public int QuestionCurrentNumber { get; set; } = 1; | ||
|
||
public QuizResultSummary(int totalQuestions) | ||
public ScoringRules ScoringRules { get; set; } | ||
public QuizResultSummary(int totalQuestions, ScoringRules scoringRules) | ||
{ | ||
this.TotalQuestions = totalQuestions; | ||
TotalQuestions = totalQuestions; | ||
this.ScoringRules = scoringRules; | ||
} | ||
|
||
private double CalculateSuccessPercentage() | ||
private double CalculateNetCount() | ||
{ | ||
int totalQuestions = CorrectCount + IncorrectCount + BlankCount; | ||
if (totalQuestions == 0) | ||
{ | ||
return 0.0; | ||
} | ||
|
||
return (double)CorrectCount / totalQuestions * 100; | ||
return (ScoringRules.PenaltyForIncorrectAnswer) | ||
? CorrectCount - ScoringRules.IncorrectAnswerScore * IncorrectCount | ||
: CorrectCount; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using quiz_console_app.ViewModels; | ||
|
||
namespace quiz_console_app.Models; | ||
|
||
public class UserAnswerKeyCollection | ||
{ | ||
private Dictionary<Guid, List<UserAnswerKeyViewModel>> _userAnswerKeysByUserId; | ||
|
||
public UserAnswerKeyCollection() | ||
{ | ||
_userAnswerKeysByUserId = new Dictionary<Guid, List<UserAnswerKeyViewModel>>(); | ||
} | ||
|
||
public void AddUserAnswerKey(Guid userId, List<UserAnswerKeyViewModel> userAnswerKeys) | ||
{ | ||
_userAnswerKeysByUserId.Add(userId, userAnswerKeys); | ||
} | ||
|
||
public List<UserAnswerKeyViewModel> GetUserAnswerKeys(Guid userId) | ||
{ | ||
if (_userAnswerKeysByUserId.ContainsKey(userId)) | ||
{ | ||
return _userAnswerKeysByUserId[userId]; | ||
} | ||
else | ||
{ | ||
return new List<UserAnswerKeyViewModel>(); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using quiz_console_app.Services; | ||
using quiz_console_app.Helpers; | ||
using quiz_console_app.Services; | ||
|
||
QuizModeHandlerService quizModeHandlerService = new QuizModeHandlerService(); | ||
quizModeHandlerService.ShowMainMenu(); | ||
quizModeHandlerService.ShowMainMenu(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.