Result

Here's the content of the /Data/Models/Result.cs class file:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace TestMakerFreeWebApp.Data
{
public class Result
{
#region Constructor
public Result()
{

}
#endregion

#region Properties
[Key]
[Required]
public int Id { get; set; }

[Required]
public int QuizId { get; set; }

[Required]
public string Text { get; set; }

public int? MinValue { get; set; }

public int? MaxValue { get; set; }

public string Notes { get; set; }

[DefaultValue(0)]
public int Type { get; set; }

[DefaultValue(0)]
public int Flags { get; set; }

[Required]
public DateTime CreatedDate { get; set; }

[Required]
public DateTime LastModifiedDate { get; set; }
#endregion
}
}

Here we go. The QuizId foreign key property is back as the results are bound to the quiz itself, not to questions or answers. Other than that, we can also note the MinValue and MaxValue properties; these will be the boundaries that will be used--along with the total score points earned by the user by picking the various answers--to determine the proper result(s) after the quiz is over. If multiple results are available for that given score, a random one will be picked.

Note how MinValue and MaxValue are initialized using a C# int? type, which defines a nullable int type. We did that to give the quiz author the chance to create results without boundaries so that they can act as a catch-all. For example, a result with a null MinValue will be picked for all score values up to its MaxValue; similarly, a result with a null MaxValue will be picked for all score values equal or greater than its MinValue. Needless to say, this also means that a result with both these values set to null will always be picked, unless we keep the author from doing that.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.7.102