using System;
namespace TMSDAL.DTO.AssessmentQuestion
{
///
/// DTO for MASSESSMENTQUESTION table.
/// Simple mode — questions attached directly to an assessment definition.
/// Detail of MSESSIONASSESSMENT.
///
/// QUESTIONTYPE:
/// 0 = MCQ — single correct option from multiple choices
/// 1 = TrueFalse — binary true/false answer
/// 2 = ShortAnswer — free-text response
/// 3 = MultiSelect — one or more correct options
/// 4 = Matching — match pairs (left → right)
/// 5 = Ordering — arrange items in correct sequence
///
/// OPTIONSJSON — nullable; stores MCQ/MultiSelect/Matching/Ordering options as JSON
/// EXPLANATION — nullable; shown after attempt if ShowAnswersOnComplete = 1
///
/// No standard audit fields (CREATEDBYID / CREATEDON etc.) on this table.
///
public class AssessmentQuestionDTO
{
#region Private Members
// ── Primary Key ───────────────────────────────────────────────────────
private int assessmentquestionid;
// ── Parent FK ─────────────────────────────────────────────────────────
private int assessmentid;
// ── Sequence ──────────────────────────────────────────────────────────
private short slno; // DEFAULT 1
// ── Business Columns ──────────────────────────────────────────────────
private string questiontext; // NVARCHAR(MAX) NOT NULL
private byte questiontype; // 0-5 NOT NULL DEFAULT 0
private string? optionsjson; // NVARCHAR(MAX) NULL — JSON array of options
private string correctanswer; // NVARCHAR(MAX) NOT NULL
private short marks; // SMALLINT NOT NULL DEFAULT 1
private string? explanation; // NVARCHAR(MAX) NULL
private byte requiresmanualevaluation; // 0 No, 1 Yes NOT NULL DEFAULT 0
// ── Read-only Joined Fields (GET only — not saved) ────────────────────
private string? assessmenttitle; // From MSESSIONASSESSMENT
#endregion
#region Public Members
// ── Primary Key ───────────────────────────────────────────────────────
/// PK — ASSESSMENTQUESTIONID
public int AssessmentQuestionId
{
get { return assessmentquestionid; }
set { assessmentquestionid = value; }
}
// ── Parent FK ─────────────────────────────────────────────────────────
/// FK → MSESSIONASSESSMENT.ASSESSMENTID (NOT NULL)
public int AssessmentId
{
get { return assessmentid; }
set { assessmentid = value; }
}
// ── Sequence ──────────────────────────────────────────────────────────
///
/// Question display order within the assessment (NOT NULL, DEFAULT 1)
/// SMALLINT → short (range: -32,768 to 32,767)
///
public short SlNo
{
get { return slno; }
set { slno = value; }
}
// ── Business Columns ──────────────────────────────────────────────────
///
/// Full question text (NOT NULL, NVARCHAR MAX)
/// Supports rich text / HTML for formatted questions.
///
public string QuestionText
{
get { return questiontext; }
set { questiontext = value; }
}
///
/// Question type (NOT NULL, DEFAULT 0)
/// 0 = MCQ — single correct option
/// 1 = TrueFalse — binary answer
/// 2 = ShortAnswer — free-text
/// 3 = MultiSelect — one or more correct options
/// 4 = Matching — match left → right pairs
/// 5 = Ordering — arrange in correct sequence
/// CHECK: IN (0,1,2,3,4,5)
/// TINYINT → byte
///
public byte QuestionType
{
get { return questiontype; }
set { questiontype = value; }
}
///
/// Options stored as JSON (NULLABLE, NVARCHAR MAX)
/// Used by: MCQ, MultiSelect, Matching, Ordering
/// Null for: TrueFalse, ShortAnswer
///
/// MCQ / MultiSelect example:
/// [{"id":1,"text":"Option A"},{"id":2,"text":"Option B"}]
///
/// Matching example:
/// [{"left":"Term A","right":"Definition A"},{"left":"Term B","right":"Definition B"}]
///
/// Ordering example:
/// [{"id":1,"text":"Step 1"},{"id":2,"text":"Step 2"}]
///
public string? OptionsJson
{
get { return optionsjson; }
set { optionsjson = value; }
}
///
/// Correct answer (NOT NULL, NVARCHAR MAX)
/// Stored as a string regardless of question type:
///
/// MCQ → option id as string e.g. "2"
/// TrueFalse → "true" or "false"
/// ShortAnswer → expected answer text e.g. "photosynthesis"
/// MultiSelect → comma-separated option ids e.g. "1,3"
/// Matching → JSON pairs e.g. [{"left":1,"right":2}]
/// Ordering → JSON ordered id array e.g. "[3,1,2,4]"
///
public string CorrectAnswer
{
get { return correctanswer; }
set { correctanswer = value; }
}
///
/// Marks awarded for a correct answer (NOT NULL, DEFAULT 1)
/// SMALLINT → short
///
public short Marks
{
get { return marks; }
set { marks = value; }
}
///
/// Explanation shown after attempt (NULLABLE, NVARCHAR MAX)
/// Displayed only when MSESSIONASSESSMENT.SHOWANSWERSONCOMPLETE = 1
///
public string? Explanation
{
get { return explanation; }
set { explanation = value; }
}
///
/// 0 = No (default auto-eval by exact-match against CorrectAnswer), 1 = Yes — always
/// route this question's response through IAssessmentAnswerEvaluationService (human
/// grader today, pluggable AI evaluator later) regardless of whether CorrectAnswer is set.
///
public byte RequiresManualEvaluation
{
get { return requiresmanualevaluation; }
set { requiresmanualevaluation = value; }
}
// ── Read-only Joined Fields (GET only — never included in INSERT/UPDATE) ─
/// From MSESSIONASSESSMENT.ASSESSMENTTITLE (GET only)
public string? AssessmentTitle
{
get { return assessmenttitle; }
set { assessmenttitle = value; }
}
#endregion
}
}