Run SQL to add new question type to database:
insert into QuestionType values(NEWID(),'ESSAY','Essay')
Add the view in /Views/StudentExam/TakeExam.cshtml
@if (Model.QuestionType == "ESSAY"){
<!--Add the rich text editor code here-->
}
Explore rich text editor options:
Add a “mark essay” section in /Views/Result/StudentQuestionAnswer
@if (item.QuestionType == "ESSAY"){
<form asp-action="MarkEssay" asp-controller="Result">
<div class="color-primarycolor">@Resource.StudentAnswer</div>
<div><textarea class="form-control" rows="3" readonly>@item.AnswerText</textarea></div>
<label for="[email protected]">Marks Obtained:</label>
<input type="number" name="Marks" placeholder="Enter the marks" class="form-control" required />
<!--Add other hidden inputs for the id fields too, like:-->
<input type="text" name="StudentId" value="@item.StudentId" class="form-control" hidden />
<input type="text" name="QuestionId" value="@item.QuestionId" class="form-control" hidden />
<input type="text" name="StudentId" value="@item.StudentId" class="form-control" hidden />
<input type="text" name="AnswerId" value="@item.AnswerId" class="form-control" hidden />
<button type="submit" class="btn btn-primary">Submit Marks</button>
</form>
}
Add code in Result controller to save the mark
[HttpPost]
public IActionResult MarkEssay(int Marks, Guid? StudentId, Guid? QuestionId, Guid? AnswerId, Guid? ExamId)
{
//Add code to save the marks
TempData["NotifySuccess"] = "Marks submitted successfully.";
//result/studentquestionanswer?eId=5b6c52c0-5697-4166-b504-6ddcda14b6aa&sId=877b218c-3bb5-4295-9198-e73636ef778e&num=1
return RedirectToAction("studentquestionanswer", "Result",new{eid=ExamId,sid=StudentId});