diff --git a/Backend/CSAMS/APIModels/APIModel.cs b/Backend/CSAMS/APIModels/APIModel.cs index d3fac8a1bafce00bd15c1cf32614bf098a34b68c..5561d600b16f6dc34976e93dff4ccb26cdaf8228 100644 --- a/Backend/CSAMS/APIModels/APIModel.cs +++ b/Backend/CSAMS/APIModels/APIModel.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace CSAMS.APIModels +namespace CSAMS.APIModels { public interface IAPIModel { diff --git a/Backend/CSAMS/APIModels/AssignmentModel.cs b/Backend/CSAMS/APIModels/AssignmentModel.cs index 8cca78fc9eda112511b3ae6de141dd050e5380c5..b456c907f5dbc5548f144e0042e5f3b3d4fb8234 100644 --- a/Backend/CSAMS/APIModels/AssignmentModel.cs +++ b/Backend/CSAMS/APIModels/AssignmentModel.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace CSAMS.APIModels { diff --git a/Backend/CSAMS/APIModels/CommentModel.cs b/Backend/CSAMS/APIModels/CommentModel.cs index 21eb2b2073fc9019723a8f1e81ec7deba05ea2e3..366d6b94e3ea788285521c45b68ff4ce16a04253 100644 --- a/Backend/CSAMS/APIModels/CommentModel.cs +++ b/Backend/CSAMS/APIModels/CommentModel.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace CSAMS.APIModels +namespace CSAMS.APIModels { public class CommentModel : IAPIModel { diff --git a/Backend/CSAMS/APIModels/TopModels.cs b/Backend/CSAMS/APIModels/TopModels.cs index 32380de7f49511682818d43954deeeb1a2c1553a..57c830af2139ccd0298ff5ea763503fc4175d5ba 100644 --- a/Backend/CSAMS/APIModels/TopModels.cs +++ b/Backend/CSAMS/APIModels/TopModels.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace CSAMS.APIModels +namespace CSAMS.APIModels { public class TopModel : IAPIModel { @@ -11,16 +6,15 @@ namespace CSAMS.APIModels public string AssingmentName { get; set; } public int AssingmentID { get; set; } public int ReviewerID { get; set; } + public string Type { get; set; } - - public string type { get; set; } public bool AssertEqual(IAPIModel other) { var otherProject = other as TopModel; return (Grade == otherProject.Grade && AssingmentName == otherProject.AssingmentName && - type == otherProject.type && - ReviewerID==otherProject.ReviewerID&& + Type == otherProject.Type && + ReviewerID == otherProject.ReviewerID && AssingmentID == otherProject.AssingmentID); } } diff --git a/Backend/CSAMS/Controllers/AssignmentController.cs b/Backend/CSAMS/Controllers/AssignmentController.cs index d92199b1f54c87fef34a54375ed35cca067c18b3..15062f516b61aa7a742fe6a51e7db914ee7f876a 100644 --- a/Backend/CSAMS/Controllers/AssignmentController.cs +++ b/Backend/CSAMS/Controllers/AssignmentController.cs @@ -1,29 +1,32 @@ using CSAMS.APIModels; using CSAMS.Models; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace CSAMS.Controllers { + /// <summary> + /// Class for getting the Assignments + /// </summary> [Route("api/[controller]")] [ApiController] public class AssignmentController : ControllerBase { private readonly AppDbContext _context; - public AssignmentController (AppDbContext context) + public AssignmentController(AppDbContext context) { _context = context; } + /// <summary> + /// Get all Assignments + /// </summary> + /// <returns>Array of AssignmentModels</returns> public async Task<AssignmentModel[]> Get() { - Console.Write("Test"); return await _context.Assignments.Include(a => a.Course).Select(a => new AssignmentModel { ID = a.ID, Name = a.Name, Deadline = a.Deadline, ReviewDeadline = a.ReviewDeadline, Course = a.Course.CourseName }).ToArrayAsync(); } } diff --git a/Backend/CSAMS/Controllers/BasicController.cs b/Backend/CSAMS/Controllers/BasicController.cs index ef2020db13da7e8e1f935e29b86a74c14a77097b..eb05c709e5f4f9c3e82b1886ccf83313e056851b 100644 --- a/Backend/CSAMS/Controllers/BasicController.cs +++ b/Backend/CSAMS/Controllers/BasicController.cs @@ -6,6 +6,9 @@ using System.Threading.Tasks; namespace CSAMS.Controllers { + /// <summary> + /// Controller that was originally meant to be part of an example + /// </summary> [Route("api/[controller]")] [ApiController] public class BasicController : ControllerBase @@ -17,6 +20,10 @@ namespace CSAMS.Controllers _context = context; } + /// <summary> + /// Call that is used to showcase Pagination on the frontend + /// </summary> + /// <returns>Array of UserReviews with a comment</returns> [HttpGet("Comments")] public async Task<ActionResult<UserReviews[]>> GetComments() { diff --git a/Backend/CSAMS/Controllers/CommentController.cs b/Backend/CSAMS/Controllers/CommentController.cs index 278b080639723e9c817d85e4097b1a2d422eeb3f..78bfda87b05847ceaa961851ad5baaaea15fad52 100644 --- a/Backend/CSAMS/Controllers/CommentController.cs +++ b/Backend/CSAMS/Controllers/CommentController.cs @@ -1,14 +1,16 @@ using CSAMS.APIModels; -using CSAMS.Models; using CSAMS.DTOS; +using CSAMS.Models; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; -using System; using System.Linq; using System.Threading.Tasks; namespace CSAMS.Controllers { + /// <summary> + /// Class for getting filtered comments + /// </summary> [Route("api/[controller]")] [ApiController] public class CommentController : ControllerBase @@ -20,6 +22,11 @@ namespace CSAMS.Controllers _context = context; } + /// <summary> + /// Get UserReviews based on filtering by Reviewer + /// </summary> + /// <param name="filters"></param> + /// <returns>Array of filtered UserReviews</returns> [HttpPost("reviewer")] public async Task<ActionResult<CommentModel[]>> GetCommentsByReviewer(PostMessage filters) { @@ -67,7 +74,11 @@ namespace CSAMS.Controllers return returnValue.Select(m => new CommentModel { Target = m.UserTarget, Answer = m.Answer, AnswerType = m.Type, Comment = m.Comment, Reviewer = m.UserReviewer }).ToArray(); } - + /// <summary> + /// Get UserReviews based on filtering by Assignment + /// </summary> + /// <param name="filters"></param> + /// <returns>Array of filtered UserReviews</returns> [HttpPost("project")] public async Task<ActionResult<CommentModel[]>> GetCommentsByAssignment(PostMessage filters) { @@ -115,41 +126,12 @@ namespace CSAMS.Controllers return returnValue.Select(m => new CommentModel { Target = m.UserTarget, Answer = m.Answer, AnswerType = m.Type, Comment = m.Comment, Reviewer = m.UserReviewer }).ToArray(); } - [HttpGet("project/{projectID}")] - public async Task<ActionResult<CommentModel[]>> GetProjectComments(int projectID) - { - var project = await _context.Assignments.Where(A => A.ID == projectID).FirstOrDefaultAsync(); - - if (project is null) - return BadRequest($"No project with ID {projectID} exist!"); - - var reviews = await _context.UserReviews.ToArrayAsync(); - var returnValue = GetProjects(reviews, projectID); - - if (returnValue is null) - return BadRequest($"Project with ID {projectID} has no commented reviews!"); - - return returnValue; - } - - [HttpGet("reviewer/{reviewerID}")] - public async Task<ActionResult<CommentModel[]>> GetReviewerComments(int reviewerID) - { - Console.WriteLine(reviewerID); - var reviewer = await _context.Users.Where(u => u.ID == reviewerID).FirstOrDefaultAsync(); - - if (reviewer is null) - return BadRequest($"No reviewer with ID {reviewerID} exist!"); - - var reviews = await _context.UserReviews.ToArrayAsync(); - var returnValue = GetReviewers(reviews, reviewerID); - - if (returnValue is null) - return BadRequest($"Reviewer {reviewerID} has no commented reviews!"); - - return returnValue; - } - + /// <summary> + /// Filters UserReviews based on projectID + /// </summary> + /// <param name="reviews"></param> + /// <param name="projectID"></param> + /// <returns>Array of filtered UserReviews</returns> public static CommentModel[] GetProjects(UserReviews[] reviews, int projectID) { var proco = reviews.Where(r => r.AssignmentID == projectID && r.Comment != null) @@ -159,6 +141,12 @@ namespace CSAMS.Controllers return null; } + /// <summary> + /// Filters UserReviews based on reviewerID + /// </summary> + /// <param name="reviews"></param> + /// <param name="reviewerID"></param> + /// <returns>Array of filtered UserReviews</returns> public static CommentModel[] GetReviewers(UserReviews[] reviews, int reviewerID) { var model = reviews.Where(m => m.UserReviewer == reviewerID && m.Comment != null) diff --git a/Backend/CSAMS/Controllers/MinMaxControler.cs b/Backend/CSAMS/Controllers/MinMaxControler.cs index 55983c26169e2c66f58d0713d4377f125d96cdb1..2a1af79641b1525354ce274d5ae1991e8ccf7171 100644 --- a/Backend/CSAMS/Controllers/MinMaxControler.cs +++ b/Backend/CSAMS/Controllers/MinMaxControler.cs @@ -1,13 +1,15 @@ using CSAMS.Models; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +using System; using System.Linq; using System.Threading.Tasks; -using System.Collections.Generic; -using System; namespace CSAMS.Controllers { + /// <summary> + /// This class is an early class for statistics. Functions are in StatisticsController as well, but the Rest API for this is used in MinMax on the frontend + /// </summary> [Route("api/[controller]")] [ApiController] public class MinMaxController : ControllerBase diff --git a/Backend/CSAMS/Controllers/SampleController.cs b/Backend/CSAMS/Controllers/SampleController.cs index 5938dab91af1b1c0deda5aeb885a9dbf34f4cb24..270ca6ce4c9b832f1eb1dd24dec0f4975cc43597 100644 --- a/Backend/CSAMS/Controllers/SampleController.cs +++ b/Backend/CSAMS/Controllers/SampleController.cs @@ -2,13 +2,14 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using System.Threading.Tasks; -using System; -using CSAMS.DTOS; namespace CSAMS.Controllers { - + /// <summary> + /// This class was supposed to be a sample for how to get data from the database + /// It is now used to get all Users in the database + /// </summary> [Route("api/[controller]")] [ApiController] public class SampleController : ControllerBase @@ -20,37 +21,14 @@ namespace CSAMS.Controllers _context = context; } - [HttpGet("review")] - public async Task<ActionResult<Reviews[]>> GetReviews() - { - return await _context.Reviews.Include(r => r.Form).ToArrayAsync(); - } - + /// <summary> + /// Get all users + /// </summary> + /// <returns>Array of Users</returns> [HttpGet("user")] public async Task<ActionResult<Users[]>> GetUsers() { return await _context.Users.Include(u => u.UserRole).ToArrayAsync(); } - - ////////////////////////////// - - [HttpPost("post")] - public ActionResult<Users> PostUser(User newuser) - { - - - return Ok(); - } - - - [HttpPost("user")] - public ActionResult<Users> PostUserFilter(UserFilter newuser) - { - - - return Ok(); - } - - /////////////////// } } diff --git a/Backend/CSAMS/Controllers/StatisticsController.cs b/Backend/CSAMS/Controllers/StatisticsController.cs index e777227cd0df6292019a40efbb38f713686bec42..779fccdb35ad00afff9da1fb572ee4fda605a3a8 100644 --- a/Backend/CSAMS/Controllers/StatisticsController.cs +++ b/Backend/CSAMS/Controllers/StatisticsController.cs @@ -1,14 +1,17 @@ -using CSAMS.Models; -using CSAMS.DTOS; +using CSAMS.DTOS; +using CSAMS.Models; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using System.Collections.Generic; -using System; namespace CSAMS.Controllers { + /// <summary> + /// Class for getting statistics of the database + /// </summary> [Route("api/[controller]")] [ApiController] public class StatisticsController : ControllerBase @@ -20,38 +23,42 @@ namespace CSAMS.Controllers _context = context; } - + /// <summary> + /// Get Userreviews based on filter + /// </summary> + /// <param name="filter"></param> + /// <returns>Array of filtered UserReviews</returns> [HttpPost("userReviewsFiltered")] public async Task<ActionResult<UserReviews[]>> PostUserReviews(Filter filter) { UserReviews[] userReviews = await _context.UserReviews.Include(ur => ur.Assignment).Where(ur => ur.Type == "radio").Where(ur => ur.Answer != null).ToArrayAsync(); - if (filter.assignment != "") + if (filter.Assignment != "") { - userReviews = ApplyFilterAssignment(userReviews, filter.assignment); + userReviews = ApplyFilterAssignment(userReviews, filter.Assignment); } - if (filter.reviewerID != "") + if (filter.ReviewerID != "") { try { - userReviews = ApplyFilterReviewerID(userReviews, Convert.ToInt32(filter.reviewerID)); + userReviews = ApplyFilterReviewerID(userReviews, Convert.ToInt32(filter.ReviewerID)); } catch (FormatException) { - return BadRequest($"'{filter.reviewerID}' is not a valid userID!"); + return BadRequest($"'{filter.ReviewerID}' is not a valid userID!"); } } - if (filter.targetID != "") + if (filter.TargetID != "") { try { - userReviews = ApplyFilterTargetID(userReviews, Convert.ToInt32(filter.targetID)); + userReviews = ApplyFilterTargetID(userReviews, Convert.ToInt32(filter.TargetID)); } catch (FormatException) { - return BadRequest($"'{filter.targetID}' is not a valid userID!"); + return BadRequest($"'{filter.TargetID}' is not a valid userID!"); } } @@ -63,7 +70,7 @@ namespace CSAMS.Controllers return userReviews; } - public static UserReviews[] ApplyFilterAssignment(UserReviews[] userReviews, String assignmentName) + public static UserReviews[] ApplyFilterAssignment(UserReviews[] userReviews, string assignmentName) { UserReviews[] result = userReviews.Where(ur => ur.Assignment.Name == assignmentName).ToArray(); if (result.Length == 0) @@ -91,7 +98,10 @@ namespace CSAMS.Controllers return result; } - + /// <summary> + /// + /// </summary> + /// <returns>Array of UserReviews</returns> [HttpGet("userReviews")] public async Task<ActionResult<UserReviews[]>> GetUserReviews() { @@ -103,53 +113,60 @@ namespace CSAMS.Controllers return userReviews; } - + /// <summary> + /// Get statistics for all Reviews + /// </summary> + /// <returns>Array of strings</returns> [HttpGet("userReviewsStatistics")] - public async Task<ActionResult<String[]>> GetUserReviewsStatistics() + public async Task<ActionResult<string[]>> GetUserReviewsStatistics() { UserReviews[] all = await _context.UserReviews.Where(ur => ur.Type == "radio").Where(ur => ur.Answer != null).ToArrayAsync(); if (all.Length == 0) { return BadRequest($"There are no user reviews corresponding to these values!"); } - String[] array = new String[] { "Min: " + GetMin(all).Answer, "Max: "+GetMax(all).Answer,"Mean: " + GetMean(all), "Median: " + GetMedian(all), "Q1: " + GetQ1(all), "Q3: " + GetQ3(all), "Standard Deviation: " + GetStandardDeviation(all) }; + string[] array = new string[] { "Min: " + GetMin(all).Answer, "Max: " + GetMax(all).Answer, "Mean: " + GetMean(all), "Median: " + GetMedian(all), "Q1: " + GetQ1(all), "Q3: " + GetQ3(all), "Standard Deviation: " + GetStandardDeviation(all) }; return array; } - + /// <summary> + /// Get statististics for all Reviews based on filtering + /// </summary> + /// <param name="filter"></param> + /// <returns>Filtered array of strings</returns> [HttpPost("userReviewsFilteredStatistics")] - public async Task<ActionResult<String[]>> PostStatistics(Filter filter) + public async Task<ActionResult<string[]>> PostStatistics(Filter filter) { //Get all UserReviews UserReviews[] userReviews = await _context.UserReviews.Include(ur => ur.Assignment).Where(ur => ur.Type == "radio").Where(ur => ur.Answer != null).ToArrayAsync(); //Filter them - if (filter.assignment != "") + if (filter.Assignment != "") { - userReviews = ApplyFilterAssignment(userReviews, filter.assignment); + userReviews = ApplyFilterAssignment(userReviews, filter.Assignment); } - if (filter.reviewerID != "") + if (filter.ReviewerID != "") { try { - userReviews = ApplyFilterReviewerID(userReviews, Convert.ToInt32(filter.reviewerID)); + userReviews = ApplyFilterReviewerID(userReviews, Convert.ToInt32(filter.ReviewerID)); } catch (FormatException) { - return BadRequest($"'{filter.reviewerID}' is not a valid userID!"); + return BadRequest($"'{filter.ReviewerID}' is not a valid userID!"); } } - if (filter.targetID != "") + if (filter.TargetID != "") { try { - userReviews = ApplyFilterTargetID(userReviews, Convert.ToInt32(filter.targetID)); + userReviews = ApplyFilterTargetID(userReviews, Convert.ToInt32(filter.TargetID)); } catch (FormatException) { - return BadRequest($"'{filter.targetID}' is not a valid userID!"); + return BadRequest($"'{filter.TargetID}' is not a valid userID!"); } } @@ -160,10 +177,10 @@ namespace CSAMS.Controllers } //Return corresponding Statistics - String[] statistics = new String[] { }; + string[] statistics = new string[] { }; try { - statistics = new String[] { "Min: " + GetMin(userReviews).Answer, "Max: " + GetMax(userReviews).Answer, "Mean: " + GetMean(userReviews), "Median: " + GetMedian(userReviews), "Q1: " + GetQ1(userReviews), "Q3: " + GetQ3(userReviews), "Standard Deviation: " + GetStandardDeviation(userReviews) }; + statistics = new string[] { "Min: " + GetMin(userReviews).Answer, "Max: " + GetMax(userReviews).Answer, "Mean: " + GetMean(userReviews), "Median: " + GetMedian(userReviews), "Q1: " + GetQ1(userReviews), "Q3: " + GetQ3(userReviews), "Standard Deviation: " + GetStandardDeviation(userReviews) }; } catch (FormatException) { @@ -172,6 +189,11 @@ namespace CSAMS.Controllers return statistics; } + /// <summary> + /// Get Mean answer score of UserReviews + /// </summary> + /// <param name="list"></param> + /// <returns>Mean</returns> public float GetMean(UserReviews[] list) { float total = 0; @@ -181,9 +203,14 @@ namespace CSAMS.Controllers total += Convert.ToInt32(UR.Answer); n += 1; } - return total / n; + return total / n; } + /// <summary> + /// Get Median answer score of UserReviews + /// </summary> + /// <param name="list"></param> + /// <returns>Median</returns> public float GetMedian(UserReviews[] list) { List<float> values = new List<float>(); @@ -195,18 +222,28 @@ namespace CSAMS.Controllers return values.ElementAt((values.Count - 1) / 2); } + /// <summary> + /// Get Q1 answer score of UserReviews + /// </summary> + /// <param name="list"></param> + /// <returns>Q1</returns> public float GetQ1(UserReviews[] list) { List<float> values = new List<float>(); foreach (UserReviews UR in list) { - - values.Add((float)Convert.ToInt32(UR.Answer)); + + values.Add((float)Convert.ToInt32(UR.Answer)); } values.Sort(); return values.ElementAt((values.Count - 1) / 4); } + /// <summary> + /// Get Q3 answer score of UserReviews + /// </summary> + /// <param name="list"></param> + /// <returns>Q3</returns> public float GetQ3(UserReviews[] list) { List<float> values = new List<float>(); @@ -218,6 +255,11 @@ namespace CSAMS.Controllers return values.ElementAt((3 * values.Count - 1) / 4); } + /// <summary> + /// Get Standard Deviation answer score of UserReviews + /// </summary> + /// <param name="list"></param> + /// <returns>Standard Deviation</returns> public float GetStandardDeviation(UserReviews[] list) { float mean = GetMean(list); @@ -232,6 +274,11 @@ namespace CSAMS.Controllers return (float)Math.Sqrt(Convert.ToDouble(sd / n)); } + /// <summary> + /// Get Minimum answer score of UserReviews + /// </summary> + /// <param name="list"></param> + /// <returns>Minimum</returns> public UserReviews GetMin(UserReviews[] list) { UserReviews minUR = new UserReviews(); @@ -247,6 +294,11 @@ namespace CSAMS.Controllers return minUR; } + /// <summary> + /// Get Maximum answer score of UserReviews + /// </summary> + /// <param name="list"></param> + /// <returns>Maximum</returns> public UserReviews GetMax(UserReviews[] list) { UserReviews minUR = new UserReviews(); diff --git a/Backend/CSAMS/Controllers/TopController.cs b/Backend/CSAMS/Controllers/TopController.cs index 47fee43701c34f48fd7dc1d640447add071564c7..7f925c554bf2f7be8d0c59cd77efbdf4ca0a5ff1 100644 --- a/Backend/CSAMS/Controllers/TopController.cs +++ b/Backend/CSAMS/Controllers/TopController.cs @@ -60,7 +60,14 @@ namespace CSAMS.Controllers return ret; } - // [HttpGet("Top/{N}/{Type}/{IsProject}")] + /// <summary> + /// Get the Mean Average + /// </summary> + /// <param name="userReviews"></param> + /// <param name="fields"></param> + /// <param name="IsProject"></param> + /// <param name="average">Mean average of all reviews</param> + /// <returns></returns> public static TopModel TopProjects(UserReviews[] userReviews, Fields[] fields, bool IsProject, float average) { var child = userReviews @@ -83,7 +90,7 @@ namespace CSAMS.Controllers AssingmentID = ur.r.AssignmentID, AssingmentName = ur.r.Assignment.Name, ReviewerID = ur.r.UserReviewer, - type = "Top" + Type = "Top" }) .ToArray(); } @@ -96,7 +103,7 @@ namespace CSAMS.Controllers AssingmentID = ur.r.AssignmentID, AssingmentName = ur.r.Assignment.Name, ReviewerID = ur.r.UserReviewer, - type = "Top" + Type = "Top" }) .ToArray(); } @@ -114,7 +121,7 @@ namespace CSAMS.Controllers AssingmentID = grades[0].AssingmentID, AssingmentName = grades[0].AssingmentName, ReviewerID = grades[0].ReviewerID, - type = "top" + Type = "top" }; return model; diff --git a/Backend/CSAMS/DTOS/testobject.cs b/Backend/CSAMS/DTOS/testobject.cs index c049cd5932b99069408f5049bf0c4617749baebb..2747e3474dbf07f3c300cc724d4af8af634a2fa6 100644 --- a/Backend/CSAMS/DTOS/testobject.cs +++ b/Backend/CSAMS/DTOS/testobject.cs @@ -1,28 +1,11 @@ -using System.Runtime.InteropServices; -using System; namespace CSAMS.DTOS { - public class User - { - public string id { get; set; } - public string role { get; set; } - - } - - - public class UserFilter - { - public string id { get; set; } - - - } - public class Filter { - public string assignment { get; set; } - public string reviewerID { get; set; } - public string targetID { get; set; } - public string errorMsg { get; set; } + public string Assignment { get; set; } + public string ReviewerID { get; set; } + public string TargetID { get; set; } + public string ErrorMsg { get; set; } } public class PostMessage diff --git a/Backend/CSAMS/Models/AppDbContext.cs b/Backend/CSAMS/Models/AppDbContext.cs index 4b34622ca393aa884afc52c0db1de62fc5997e79..9c8deeb2d580e6a4ed03c85fe9e9286b61bf50d5 100644 --- a/Backend/CSAMS/Models/AppDbContext.cs +++ b/Backend/CSAMS/Models/AppDbContext.cs @@ -1,7 +1,5 @@ using Microsoft.EntityFrameworkCore; using System; -using System.Diagnostics; -using System.IO; namespace CSAMS.Models { @@ -27,7 +25,7 @@ namespace CSAMS.Models { var path = AppDomain.CurrentDomain.BaseDirectory; if (path.Contains("bin")) - optionsBuilder.UseSqlite($"Data Source={path.Substring(0, path.IndexOf("bin"))}Data/csams.sqlite"); + optionsBuilder.UseSqlite($"Data Source={path.Substring(0, path.IndexOf("bin"))}Data/csams.sqlite"); } } diff --git a/Backend/CSAMS/Models/Assignments.cs b/Backend/CSAMS/Models/Assignments.cs index 2d1372faac86d97d4a802c938b4353f11db2c0ee..e46d2b505130ce99210287d332fc17ba8d2e6327 100644 --- a/Backend/CSAMS/Models/Assignments.cs +++ b/Backend/CSAMS/Models/Assignments.cs @@ -1,7 +1,7 @@ -using System; +using CSAMS.APIModels; +using System; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using CSAMS.APIModels; namespace CSAMS.Models { @@ -11,12 +11,12 @@ namespace CSAMS.Models [MaxLength(11)] public int ID { get; set; } [MaxLength(64)] - [Column(TypeName ="VARCHAR")] + [Column(TypeName = "VARCHAR")] public string Name { get; set; } public string Description { get; set; } [Timestamp] public byte[] Created { get; set; } - [Column(TypeName ="datetime2")] + [Column(TypeName = "datetime2")] public DateTime PublishedDate { get; set; } [Column(TypeName = "datetime2")] public DateTime Deadline { get; set; } diff --git a/Backend/CSAMS/Models/Courses.cs b/Backend/CSAMS/Models/Courses.cs index 44f466d34e5835fdadfebb1bb617cf7c7d06fbea..4d0963a9a48eefc699f80f4c29a3a343315a0f23 100644 --- a/Backend/CSAMS/Models/Courses.cs +++ b/Backend/CSAMS/Models/Courses.cs @@ -1,6 +1,6 @@ -using System.ComponentModel.DataAnnotations; +using CSAMS.APIModels; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using CSAMS.APIModels; namespace CSAMS.Models { diff --git a/Backend/CSAMS/Models/Forms.cs b/Backend/CSAMS/Models/Forms.cs index f15fe022ed3472b3ff15d38c776eed3dd7b9bf21..aed873760514466ba2e793f5227546d25f803f78 100644 --- a/Backend/CSAMS/Models/Forms.cs +++ b/Backend/CSAMS/Models/Forms.cs @@ -1,6 +1,6 @@ -using System.ComponentModel.DataAnnotations; +using CSAMS.APIModels; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using CSAMS.APIModels; namespace CSAMS.Models { diff --git a/Backend/CSAMS/Models/Reviews.cs b/Backend/CSAMS/Models/Reviews.cs index f59a73f3cb1968e7fb52b92bd55cea310499dcd9..eb4ac41f6793ee49dd0418eded3e2d56835c91fa 100644 --- a/Backend/CSAMS/Models/Reviews.cs +++ b/Backend/CSAMS/Models/Reviews.cs @@ -1,6 +1,6 @@ -using System.ComponentModel.DataAnnotations; +using CSAMS.APIModels; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using CSAMS.APIModels; namespace CSAMS.Models { diff --git a/Backend/CSAMS/Models/Roles.cs b/Backend/CSAMS/Models/Roles.cs index 8b3b323d4717131744deee1b81d5ab9707de71d8..b27de4f3b35900da473b4bdb0edadaa9622da097 100644 --- a/Backend/CSAMS/Models/Roles.cs +++ b/Backend/CSAMS/Models/Roles.cs @@ -1,6 +1,6 @@ -using System.ComponentModel.DataAnnotations; +using CSAMS.APIModels; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using CSAMS.APIModels; namespace CSAMS.Models { diff --git a/Backend/CSAMS/Models/Submissions.cs b/Backend/CSAMS/Models/Submissions.cs index 01646094957c86a98258c88b38919831a1e710dc..0dd090401f8e2e05cdf9a9cfcfbfe6d880a67e7b 100644 --- a/Backend/CSAMS/Models/Submissions.cs +++ b/Backend/CSAMS/Models/Submissions.cs @@ -1,6 +1,6 @@ -using System.ComponentModel.DataAnnotations; +using CSAMS.APIModels; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using CSAMS.APIModels; namespace CSAMS.Models { diff --git a/Backend/CSAMS/Models/UserReviews.cs b/Backend/CSAMS/Models/UserReviews.cs index 41dee8cf4a38c094e515e0e459481a7cffebf572..22665ce411d96179b0b7b5b043544cf2f4a27686 100644 --- a/Backend/CSAMS/Models/UserReviews.cs +++ b/Backend/CSAMS/Models/UserReviews.cs @@ -1,6 +1,6 @@ -using System.ComponentModel.DataAnnotations; +using CSAMS.APIModels; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using CSAMS.APIModels; namespace CSAMS.Models { diff --git a/Backend/CSAMS/Models/Users.cs b/Backend/CSAMS/Models/Users.cs index e32a6663a9bc236632f94ad3aec599bde360c8b9..bfe3d37c71197979338a0c0049c9bec446393415 100644 --- a/Backend/CSAMS/Models/Users.cs +++ b/Backend/CSAMS/Models/Users.cs @@ -1,6 +1,6 @@ -using System.ComponentModel.DataAnnotations; +using CSAMS.APIModels; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using CSAMS.APIModels; namespace CSAMS.Models { diff --git a/Backend/Test-Framework/GlobalStatistics/CommentTests.cs b/Backend/Test-Framework/GlobalStatistics/CommentTests.cs index fb1a91de6e8dced419dc5f531fd404cce046a4b2..8d6d111053e8ade6e6dee2774838ee22b62f2870 100644 --- a/Backend/Test-Framework/GlobalStatistics/CommentTests.cs +++ b/Backend/Test-Framework/GlobalStatistics/CommentTests.cs @@ -1,7 +1,6 @@ using CSAMS.APIModels; using CSAMS.Controllers; using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; using Test_Framework.Methods; namespace Test_Framework.GlobalStatistics diff --git a/Backend/Test-Framework/GlobalStatistics/FiltersTests.cs b/Backend/Test-Framework/GlobalStatistics/FiltersTests.cs index 30f53634fe093b3af58bcbfd80f275f478908c9d..f6c3fd929a2ece57b333fe2a85a3115bb7ae407f 100644 --- a/Backend/Test-Framework/GlobalStatistics/FiltersTests.cs +++ b/Backend/Test-Framework/GlobalStatistics/FiltersTests.cs @@ -1,8 +1,8 @@ -using Test_Framework.Methods; using CSAMS.Controllers; using CSAMS.Models; using Microsoft.VisualStudio.TestTools.UnitTesting; +using Test_Framework.Methods; namespace Test_Framework.GlobalStatistics { @@ -16,7 +16,7 @@ namespace Test_Framework.GlobalStatistics new Assignments { ID = 1, Name = "assi1" }; public static readonly Assignments Assignment2 = new Assignments { ID = 2, Name = "assi2" }; - + public readonly UserReviews[] ExpectedResult1 = { new UserReviews {ID = 1, UserTarget = 1, UserReviewer = 2, Name = "assi1_review_01", Type = "radio", Answer = "2", AssignmentID = 1, Assignment = Assignment1, ReviewID = 1, Comment = "Could have been a lot better"}, @@ -131,7 +131,7 @@ namespace Test_Framework.GlobalStatistics { UserReviews[] result = StatisticsController.ApplyFilterAssignment(TestData.TestData.UserReviewTest, "assi1"); result = StatisticsController.ApplyFilterReviewerID(result, 3); - Assert.IsTrue( result is null); + Assert.IsTrue(result is null); } [TestMethod] diff --git a/Backend/Test-Framework/GlobalStatistics/TopTests.cs b/Backend/Test-Framework/GlobalStatistics/TopTests.cs index 2400ce905939bad2dfc9db4bb6ebfe47cc3fb43b..d4ffd33163f6279a768f5db0d464d55987943173 100644 --- a/Backend/Test-Framework/GlobalStatistics/TopTests.cs +++ b/Backend/Test-Framework/GlobalStatistics/TopTests.cs @@ -13,51 +13,51 @@ namespace Test_Framework.GlobalStatistics { public readonly TopModel[] ExpectedProjectResultTopOne = { - new TopModel{Grade = 4, AssingmentName = "Cloud 2021 - Assignment 2", AssingmentID = 6, ReviewerID = 33, type = "top"} + new TopModel{Grade = 4, AssingmentName = "Cloud 2021 - Assignment 2", AssingmentID = 6, ReviewerID = 33, Type = "top"} }; public readonly TopModel[] ExpectedProjectResulToptTwo = { - new TopModel{Grade = 1.21F, AssingmentName = "PROG2006 Assignment 1 tic-tac-roll", AssingmentID = 5, ReviewerID = 97,type = "top"}, - new TopModel{Grade = 2.79F, AssingmentName = "Cloud 2021 - Assignment 1", AssingmentID = 1, ReviewerID = 19, type = "top"} + new TopModel{Grade = 1.21F, AssingmentName = "PROG2006 Assignment 1 tic-tac-roll", AssingmentID = 5, ReviewerID = 97, Type = "top"}, + new TopModel{Grade = 2.79F, AssingmentName = "Cloud 2021 - Assignment 1", AssingmentID = 1, ReviewerID = 19, Type = "top"} }; public readonly TopModel[] ExpectedProjectResultBottomOne = { - new TopModel{Grade = 3.73F, AssingmentName = "Cloud 2021 - Assignment 1", AssingmentID = 1, ReviewerID = 27, type = "top"}, - new TopModel{Grade = 3, AssingmentName = "PROG2006 Assignment 1 tic-tac-roll", AssingmentID = 5, ReviewerID = 97, type = "top"} + new TopModel{Grade = 3.73F, AssingmentName = "Cloud 2021 - Assignment 1", AssingmentID = 1, ReviewerID = 27, Type = "top"}, + new TopModel{Grade = 3, AssingmentName = "PROG2006 Assignment 1 tic-tac-roll", AssingmentID = 5, ReviewerID = 97, Type = "top"} }; public readonly TopModel[] ExpectedProjectResulBottomtTwo = { - new TopModel{Grade = 3.62F, AssingmentName = "Cloud 2021 - Assignment 1", AssingmentID = 1, ReviewerID = 27, type = "top"} + new TopModel{Grade = 3.62F, AssingmentName = "Cloud 2021 - Assignment 1", AssingmentID = 1, ReviewerID = 27, Type = "top"} }; [TestMethod] public void TestProjectTopsOne() { - var TopOne = TopController.OuterTopProjects(1, "Top", true, TestData.TestData.TopTestsOne, TestData.TestData.TopTestsFields, TestData.TestData.TopTestsOne); + var TopOne = TopController.OuterTopProjects(1, "Top", true, TestData.TestData.TopTestsOne, TestData.TestData.TopTestsFields); Assert.IsTrue(EqualClassChecker.APIModelEqual(ExpectedProjectResultTopOne, TopOne)); } [TestMethod] public void TestProjectTopsTwo() { - var TopTwo = TopController.OuterTopProjects(2, "Top", false, TestData.TestData.TopTestsOne, TestData.TestData.TopTestsFields, TestData.TestData.TopTestsOne); + var TopTwo = TopController.OuterTopProjects(2, "Top", false, TestData.TestData.TopTestsOne, TestData.TestData.TopTestsFields); Assert.IsTrue(EqualClassChecker.APIModelEqual(ExpectedProjectResulToptTwo, TopTwo)); } [TestMethod] public void TestProjectBottomOne() { - var BottomOne = TopController.OuterTopProjects(2, "Bottom", true, TestData.TestData.TopTestsOne, TestData.TestData.TopTestsFields, TestData.TestData.TopTestsOne); + var BottomOne = TopController.OuterTopProjects(2, "Bottom", true, TestData.TestData.TopTestsOne, TestData.TestData.TopTestsFields); Assert.IsTrue(EqualClassChecker.APIModelEqual(ExpectedProjectResultBottomOne, BottomOne)); } [TestMethod] public void TestProjectBottomTwo() { - var BottomTwo = TopController.OuterTopProjects(1, "Bottom", false, TestData.TestData.TopTestsOne, TestData.TestData.TopTestsFields, TestData.TestData.TopTestsOne); + var BottomTwo = TopController.OuterTopProjects(1, "Bottom", false, TestData.TestData.TopTestsOne, TestData.TestData.TopTestsFields); Assert.IsTrue(EqualClassChecker.APIModelEqual(ExpectedProjectResulBottomtTwo, BottomTwo)); } } diff --git a/Backend/Test-Framework/Methods/EqualClassChecker.cs b/Backend/Test-Framework/Methods/EqualClassChecker.cs index bc03eeb7c14a37d6850db32849a3366c5c248881..af493ee2f7f2ca2addc3e22fd57218d3ecd48f0e 100644 --- a/Backend/Test-Framework/Methods/EqualClassChecker.cs +++ b/Backend/Test-Framework/Methods/EqualClassChecker.cs @@ -1,9 +1,6 @@ using CSAMS.APIModels; using CSAMS.Models; -using System; -using System.Collections.Generic; using System.Linq; -using System.Text; namespace Test_Framework.Methods { diff --git a/Backend/Test-Framework/TestData/TestData.cs b/Backend/Test-Framework/TestData/TestData.cs index 0e588be34eca92274cbacd4ec31673e045f09209..9c92e2286a66eb0c966b7af11f301cd0a8ebc809 100644 --- a/Backend/Test-Framework/TestData/TestData.cs +++ b/Backend/Test-Framework/TestData/TestData.cs @@ -1,8 +1,4 @@ using CSAMS.Models; -using System; -using System.Collections.Generic; -using System.Text; -using CSAMS.APIModels; namespace Test_Framework.TestData {