Skip to content
Snippets Groups Projects
Commit 816c6e20 authored by Jonas Eilertsen Hægdahl's avatar Jonas Eilertsen Hægdahl
Browse files

Format and comment code

parent 253a73ad
No related branches found
No related tags found
No related merge requests found
Showing
with 176 additions and 177 deletions
using System; namespace CSAMS.APIModels
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace CSAMS.APIModels
{ {
public interface IAPIModel public interface IAPIModel
{ {
......
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace CSAMS.APIModels namespace CSAMS.APIModels
{ {
......
using System; namespace CSAMS.APIModels
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace CSAMS.APIModels
{ {
public class CommentModel : IAPIModel public class CommentModel : IAPIModel
{ {
......
using System; namespace CSAMS.APIModels
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace CSAMS.APIModels
{ {
public class TopModel : IAPIModel public class TopModel : IAPIModel
{ {
...@@ -11,15 +6,14 @@ namespace CSAMS.APIModels ...@@ -11,15 +6,14 @@ namespace CSAMS.APIModels
public string AssingmentName { get; set; } public string AssingmentName { get; set; }
public int AssingmentID { get; set; } public int AssingmentID { get; set; }
public int ReviewerID { get; set; } public int ReviewerID { get; set; }
public string Type { get; set; }
public string type { get; set; }
public bool AssertEqual(IAPIModel other) public bool AssertEqual(IAPIModel other)
{ {
var otherProject = other as TopModel; var otherProject = other as TopModel;
return (Grade == otherProject.Grade && return (Grade == otherProject.Grade &&
AssingmentName == otherProject.AssingmentName && AssingmentName == otherProject.AssingmentName &&
type == otherProject.type && Type == otherProject.Type &&
ReviewerID == otherProject.ReviewerID && ReviewerID == otherProject.ReviewerID &&
AssingmentID == otherProject.AssingmentID); AssingmentID == otherProject.AssingmentID);
} }
......
using CSAMS.APIModels; using CSAMS.APIModels;
using CSAMS.Models; using CSAMS.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace CSAMS.Controllers namespace CSAMS.Controllers
{ {
/// <summary>
/// Class for getting the Assignments
/// </summary>
[Route("api/[controller]")] [Route("api/[controller]")]
[ApiController] [ApiController]
public class AssignmentController : ControllerBase public class AssignmentController : ControllerBase
...@@ -21,9 +21,12 @@ namespace CSAMS.Controllers ...@@ -21,9 +21,12 @@ namespace CSAMS.Controllers
_context = context; _context = context;
} }
/// <summary>
/// Get all Assignments
/// </summary>
/// <returns>Array of AssignmentModels</returns>
public async Task<AssignmentModel[]> Get() 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(); 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();
} }
} }
......
...@@ -6,6 +6,9 @@ using System.Threading.Tasks; ...@@ -6,6 +6,9 @@ using System.Threading.Tasks;
namespace CSAMS.Controllers namespace CSAMS.Controllers
{ {
/// <summary>
/// Controller that was originally meant to be part of an example
/// </summary>
[Route("api/[controller]")] [Route("api/[controller]")]
[ApiController] [ApiController]
public class BasicController : ControllerBase public class BasicController : ControllerBase
...@@ -17,6 +20,10 @@ namespace CSAMS.Controllers ...@@ -17,6 +20,10 @@ namespace CSAMS.Controllers
_context = context; _context = context;
} }
/// <summary>
/// Call that is used to showcase Pagination on the frontend
/// </summary>
/// <returns>Array of UserReviews with a comment</returns>
[HttpGet("Comments")] [HttpGet("Comments")]
public async Task<ActionResult<UserReviews[]>> GetComments() public async Task<ActionResult<UserReviews[]>> GetComments()
{ {
......
using CSAMS.APIModels; using CSAMS.APIModels;
using CSAMS.Models;
using CSAMS.DTOS; using CSAMS.DTOS;
using CSAMS.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace CSAMS.Controllers namespace CSAMS.Controllers
{ {
/// <summary>
/// Class for getting filtered comments
/// </summary>
[Route("api/[controller]")] [Route("api/[controller]")]
[ApiController] [ApiController]
public class CommentController : ControllerBase public class CommentController : ControllerBase
...@@ -20,6 +22,11 @@ namespace CSAMS.Controllers ...@@ -20,6 +22,11 @@ namespace CSAMS.Controllers
_context = context; _context = context;
} }
/// <summary>
/// Get UserReviews based on filtering by Reviewer
/// </summary>
/// <param name="filters"></param>
/// <returns>Array of filtered UserReviews</returns>
[HttpPost("reviewer")] [HttpPost("reviewer")]
public async Task<ActionResult<CommentModel[]>> GetCommentsByReviewer(PostMessage filters) public async Task<ActionResult<CommentModel[]>> GetCommentsByReviewer(PostMessage filters)
{ {
...@@ -67,7 +74,11 @@ namespace CSAMS.Controllers ...@@ -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(); 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")] [HttpPost("project")]
public async Task<ActionResult<CommentModel[]>> GetCommentsByAssignment(PostMessage filters) public async Task<ActionResult<CommentModel[]>> GetCommentsByAssignment(PostMessage filters)
{ {
...@@ -115,41 +126,12 @@ namespace CSAMS.Controllers ...@@ -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(); 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}")] /// <summary>
public async Task<ActionResult<CommentModel[]>> GetProjectComments(int projectID) /// Filters UserReviews based on projectID
{ /// </summary>
var project = await _context.Assignments.Where(A => A.ID == projectID).FirstOrDefaultAsync(); /// <param name="reviews"></param>
/// <param name="projectID"></param>
if (project is null) /// <returns>Array of filtered UserReviews</returns>
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;
}
public static CommentModel[] GetProjects(UserReviews[] reviews, int projectID) public static CommentModel[] GetProjects(UserReviews[] reviews, int projectID)
{ {
var proco = reviews.Where(r => r.AssignmentID == projectID && r.Comment != null) var proco = reviews.Where(r => r.AssignmentID == projectID && r.Comment != null)
...@@ -159,6 +141,12 @@ namespace CSAMS.Controllers ...@@ -159,6 +141,12 @@ namespace CSAMS.Controllers
return null; 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) public static CommentModel[] GetReviewers(UserReviews[] reviews, int reviewerID)
{ {
var model = reviews.Where(m => m.UserReviewer == reviewerID && m.Comment != null) var model = reviews.Where(m => m.UserReviewer == reviewerID && m.Comment != null)
......
using CSAMS.Models; using CSAMS.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Collections.Generic;
using System;
namespace CSAMS.Controllers 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]")] [Route("api/[controller]")]
[ApiController] [ApiController]
public class MinMaxController : ControllerBase public class MinMaxController : ControllerBase
......
...@@ -2,13 +2,14 @@ ...@@ -2,13 +2,14 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System.Threading.Tasks; using System.Threading.Tasks;
using System;
using CSAMS.DTOS;
namespace CSAMS.Controllers 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]")] [Route("api/[controller]")]
[ApiController] [ApiController]
public class SampleController : ControllerBase public class SampleController : ControllerBase
...@@ -20,37 +21,14 @@ namespace CSAMS.Controllers ...@@ -20,37 +21,14 @@ namespace CSAMS.Controllers
_context = context; _context = context;
} }
[HttpGet("review")] /// <summary>
public async Task<ActionResult<Reviews[]>> GetReviews() /// Get all users
{ /// </summary>
return await _context.Reviews.Include(r => r.Form).ToArrayAsync(); /// <returns>Array of Users</returns>
}
[HttpGet("user")] [HttpGet("user")]
public async Task<ActionResult<Users[]>> GetUsers() public async Task<ActionResult<Users[]>> GetUsers()
{ {
return await _context.Users.Include(u => u.UserRole).ToArrayAsync(); 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();
}
///////////////////
} }
} }
using CSAMS.Models; using CSAMS.DTOS;
using CSAMS.DTOS; using CSAMS.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Collections.Generic;
using System;
namespace CSAMS.Controllers namespace CSAMS.Controllers
{ {
/// <summary>
/// Class for getting statistics of the database
/// </summary>
[Route("api/[controller]")] [Route("api/[controller]")]
[ApiController] [ApiController]
public class StatisticsController : ControllerBase public class StatisticsController : ControllerBase
...@@ -20,38 +23,42 @@ namespace CSAMS.Controllers ...@@ -20,38 +23,42 @@ namespace CSAMS.Controllers
_context = context; _context = context;
} }
/// <summary>
/// Get Userreviews based on filter
/// </summary>
/// <param name="filter"></param>
/// <returns>Array of filtered UserReviews</returns>
[HttpPost("userReviewsFiltered")] [HttpPost("userReviewsFiltered")]
public async Task<ActionResult<UserReviews[]>> PostUserReviews(Filter filter) 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(); 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 try
{ {
userReviews = ApplyFilterReviewerID(userReviews, Convert.ToInt32(filter.reviewerID)); userReviews = ApplyFilterReviewerID(userReviews, Convert.ToInt32(filter.ReviewerID));
} }
catch (FormatException) 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 try
{ {
userReviews = ApplyFilterTargetID(userReviews, Convert.ToInt32(filter.targetID)); userReviews = ApplyFilterTargetID(userReviews, Convert.ToInt32(filter.TargetID));
} }
catch (FormatException) 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 ...@@ -63,7 +70,7 @@ namespace CSAMS.Controllers
return userReviews; 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(); UserReviews[] result = userReviews.Where(ur => ur.Assignment.Name == assignmentName).ToArray();
if (result.Length == 0) if (result.Length == 0)
...@@ -91,7 +98,10 @@ namespace CSAMS.Controllers ...@@ -91,7 +98,10 @@ namespace CSAMS.Controllers
return result; return result;
} }
/// <summary>
///
/// </summary>
/// <returns>Array of UserReviews</returns>
[HttpGet("userReviews")] [HttpGet("userReviews")]
public async Task<ActionResult<UserReviews[]>> GetUserReviews() public async Task<ActionResult<UserReviews[]>> GetUserReviews()
{ {
...@@ -103,53 +113,60 @@ namespace CSAMS.Controllers ...@@ -103,53 +113,60 @@ namespace CSAMS.Controllers
return userReviews; return userReviews;
} }
/// <summary>
/// Get statistics for all Reviews
/// </summary>
/// <returns>Array of strings</returns>
[HttpGet("userReviewsStatistics")] [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(); UserReviews[] all = await _context.UserReviews.Where(ur => ur.Type == "radio").Where(ur => ur.Answer != null).ToArrayAsync();
if (all.Length == 0) if (all.Length == 0)
{ {
return BadRequest($"There are no user reviews corresponding to these values!"); 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; return array;
} }
/// <summary>
/// Get statististics for all Reviews based on filtering
/// </summary>
/// <param name="filter"></param>
/// <returns>Filtered array of strings</returns>
[HttpPost("userReviewsFilteredStatistics")] [HttpPost("userReviewsFilteredStatistics")]
public async Task<ActionResult<String[]>> PostStatistics(Filter filter) public async Task<ActionResult<string[]>> PostStatistics(Filter filter)
{ {
//Get all UserReviews //Get all UserReviews
UserReviews[] userReviews = await _context.UserReviews.Include(ur => ur.Assignment).Where(ur => ur.Type == "radio").Where(ur => ur.Answer != null).ToArrayAsync(); UserReviews[] userReviews = await _context.UserReviews.Include(ur => ur.Assignment).Where(ur => ur.Type == "radio").Where(ur => ur.Answer != null).ToArrayAsync();
//Filter them //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 try
{ {
userReviews = ApplyFilterReviewerID(userReviews, Convert.ToInt32(filter.reviewerID)); userReviews = ApplyFilterReviewerID(userReviews, Convert.ToInt32(filter.ReviewerID));
} }
catch (FormatException) 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 try
{ {
userReviews = ApplyFilterTargetID(userReviews, Convert.ToInt32(filter.targetID)); userReviews = ApplyFilterTargetID(userReviews, Convert.ToInt32(filter.TargetID));
} }
catch (FormatException) 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 ...@@ -160,10 +177,10 @@ namespace CSAMS.Controllers
} }
//Return corresponding Statistics //Return corresponding Statistics
String[] statistics = new String[] { }; string[] statistics = new string[] { };
try 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) catch (FormatException)
{ {
...@@ -172,6 +189,11 @@ namespace CSAMS.Controllers ...@@ -172,6 +189,11 @@ namespace CSAMS.Controllers
return statistics; return statistics;
} }
/// <summary>
/// Get Mean answer score of UserReviews
/// </summary>
/// <param name="list"></param>
/// <returns>Mean</returns>
public float GetMean(UserReviews[] list) public float GetMean(UserReviews[] list)
{ {
float total = 0; float total = 0;
...@@ -184,6 +206,11 @@ namespace CSAMS.Controllers ...@@ -184,6 +206,11 @@ namespace CSAMS.Controllers
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) public float GetMedian(UserReviews[] list)
{ {
List<float> values = new List<float>(); List<float> values = new List<float>();
...@@ -195,6 +222,11 @@ namespace CSAMS.Controllers ...@@ -195,6 +222,11 @@ namespace CSAMS.Controllers
return values.ElementAt((values.Count - 1) / 2); 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) public float GetQ1(UserReviews[] list)
{ {
List<float> values = new List<float>(); List<float> values = new List<float>();
...@@ -207,6 +239,11 @@ namespace CSAMS.Controllers ...@@ -207,6 +239,11 @@ namespace CSAMS.Controllers
return values.ElementAt((values.Count - 1) / 4); 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) public float GetQ3(UserReviews[] list)
{ {
List<float> values = new List<float>(); List<float> values = new List<float>();
...@@ -218,6 +255,11 @@ namespace CSAMS.Controllers ...@@ -218,6 +255,11 @@ namespace CSAMS.Controllers
return values.ElementAt((3 * values.Count - 1) / 4); 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) public float GetStandardDeviation(UserReviews[] list)
{ {
float mean = GetMean(list); float mean = GetMean(list);
...@@ -232,6 +274,11 @@ namespace CSAMS.Controllers ...@@ -232,6 +274,11 @@ namespace CSAMS.Controllers
return (float)Math.Sqrt(Convert.ToDouble(sd / n)); 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) public UserReviews GetMin(UserReviews[] list)
{ {
UserReviews minUR = new UserReviews(); UserReviews minUR = new UserReviews();
...@@ -247,6 +294,11 @@ namespace CSAMS.Controllers ...@@ -247,6 +294,11 @@ namespace CSAMS.Controllers
return minUR; return minUR;
} }
/// <summary>
/// Get Maximum answer score of UserReviews
/// </summary>
/// <param name="list"></param>
/// <returns>Maximum</returns>
public UserReviews GetMax(UserReviews[] list) public UserReviews GetMax(UserReviews[] list)
{ {
UserReviews minUR = new UserReviews(); UserReviews minUR = new UserReviews();
......
...@@ -60,7 +60,14 @@ namespace CSAMS.Controllers ...@@ -60,7 +60,14 @@ namespace CSAMS.Controllers
return ret; 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) public static TopModel TopProjects(UserReviews[] userReviews, Fields[] fields, bool IsProject, float average)
{ {
var child = userReviews var child = userReviews
...@@ -83,7 +90,7 @@ namespace CSAMS.Controllers ...@@ -83,7 +90,7 @@ namespace CSAMS.Controllers
AssingmentID = ur.r.AssignmentID, AssingmentID = ur.r.AssignmentID,
AssingmentName = ur.r.Assignment.Name, AssingmentName = ur.r.Assignment.Name,
ReviewerID = ur.r.UserReviewer, ReviewerID = ur.r.UserReviewer,
type = "Top" Type = "Top"
}) })
.ToArray(); .ToArray();
} }
...@@ -96,7 +103,7 @@ namespace CSAMS.Controllers ...@@ -96,7 +103,7 @@ namespace CSAMS.Controllers
AssingmentID = ur.r.AssignmentID, AssingmentID = ur.r.AssignmentID,
AssingmentName = ur.r.Assignment.Name, AssingmentName = ur.r.Assignment.Name,
ReviewerID = ur.r.UserReviewer, ReviewerID = ur.r.UserReviewer,
type = "Top" Type = "Top"
}) })
.ToArray(); .ToArray();
} }
...@@ -114,7 +121,7 @@ namespace CSAMS.Controllers ...@@ -114,7 +121,7 @@ namespace CSAMS.Controllers
AssingmentID = grades[0].AssingmentID, AssingmentID = grades[0].AssingmentID,
AssingmentName = grades[0].AssingmentName, AssingmentName = grades[0].AssingmentName,
ReviewerID = grades[0].ReviewerID, ReviewerID = grades[0].ReviewerID,
type = "top" Type = "top"
}; };
return model; return model;
......
using System.Runtime.InteropServices;
using System;
namespace CSAMS.DTOS 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 class Filter
{ {
public string assignment { get; set; } public string Assignment { get; set; }
public string reviewerID { get; set; } public string ReviewerID { get; set; }
public string targetID { get; set; } public string TargetID { get; set; }
public string errorMsg { get; set; } public string ErrorMsg { get; set; }
} }
public class PostMessage public class PostMessage
......
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System; using System;
using System.Diagnostics;
using System.IO;
namespace CSAMS.Models namespace CSAMS.Models
{ {
......
using System; using CSAMS.APIModels;
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using CSAMS.APIModels;
namespace CSAMS.Models namespace CSAMS.Models
{ {
......
using System.ComponentModel.DataAnnotations; using CSAMS.APIModels;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using CSAMS.APIModels;
namespace CSAMS.Models namespace CSAMS.Models
{ {
......
using System.ComponentModel.DataAnnotations; using CSAMS.APIModels;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using CSAMS.APIModels;
namespace CSAMS.Models namespace CSAMS.Models
{ {
......
using System.ComponentModel.DataAnnotations; using CSAMS.APIModels;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using CSAMS.APIModels;
namespace CSAMS.Models namespace CSAMS.Models
{ {
......
using System.ComponentModel.DataAnnotations; using CSAMS.APIModels;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using CSAMS.APIModels;
namespace CSAMS.Models namespace CSAMS.Models
{ {
......
using System.ComponentModel.DataAnnotations; using CSAMS.APIModels;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using CSAMS.APIModels;
namespace CSAMS.Models namespace CSAMS.Models
{ {
......
using System.ComponentModel.DataAnnotations; using CSAMS.APIModels;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using CSAMS.APIModels;
namespace CSAMS.Models namespace CSAMS.Models
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment