You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.2 KiB
72 lines
2.2 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Model
|
|
{
|
|
public class Question
|
|
{
|
|
/// <summary>
|
|
/// represent a mathematical question
|
|
/// attributes :
|
|
/// id : identifier of the question in the database
|
|
/// content : the content of the question
|
|
/// difficulty : difficulty (between 1 and 3 included) of the question
|
|
/// nbFails : number of time that people fail on this question
|
|
/// idChapter : identifier of the chapter of the question
|
|
/// idAnswerGood : identifier of the right answer to this question
|
|
/// </summary>
|
|
private int id;
|
|
private string? content;
|
|
private int difficulty;
|
|
private int nbFalls;
|
|
private int idChapter;
|
|
private int idAnswerGood;
|
|
|
|
public int? Id
|
|
{
|
|
get => id == -1 ? null : id;
|
|
private set { id = value == null || value < -1 ? -1 : value.Value; }
|
|
}
|
|
public string Content
|
|
{
|
|
get => content == null ? "" : content;
|
|
set { content = value == "" ? null : value;}
|
|
}
|
|
public int Difficulty
|
|
{
|
|
get => difficulty;
|
|
set { difficulty = value < 0 ? 0 : value; }
|
|
}
|
|
public int NbFalls
|
|
{
|
|
get => nbFalls;
|
|
set { nbFalls = value < 0 ? 0 : value; }
|
|
}
|
|
public int? IdChapter
|
|
{
|
|
get => idChapter == -1 ? null : idChapter;
|
|
private set { idChapter = value == null || value < -1 ? -1 : value.Value; }
|
|
}
|
|
public int? IdAnswerGood
|
|
{
|
|
get => idAnswerGood == -1 ? null : idAnswerGood;
|
|
set { idAnswerGood = value == null || value < -1 ? -1 : value.Value; }
|
|
}
|
|
|
|
public Question(string content, int idChapter = -1, int id = -1, int idAnswerGood = -1)
|
|
{
|
|
Id = id;
|
|
Content = content;
|
|
Difficulty = 1;
|
|
NbFalls = 0;
|
|
IdChapter = idChapter;
|
|
IdAnswerGood = idAnswerGood;
|
|
}
|
|
}
|
|
}
|