public IActionResult UpdatePlacementTest(int id, [FromBody] PlacementTest placementTest) { try { _testService.Update(id, placementTest); return(Ok()); } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } }
public frmPlacementTest(Student drillStudent, int numQuestions) { InitializeComponent(); Student = drillStudent; Placement = new PlacementTest(drillStudent); Placement.DrillQuestionCount = numQuestions; // generate first Question object. Placement.GetNextQuestion(); txtQuestion.Text = Placement.Question.NewQuestion; txtAnswer.Select(); }
public static bool AddCompletedPlacement(PlacementTest placement, Student student) { DateTime currentDateTime = new DateTime(); currentDateTime = DateTime.UtcNow; SqlConnection connection = MathWizzDB.GetConnection(); String selectStatement = "INSERT INTO ActivityHistory (StudentId, DateTime, TotalQuestions, CorrectAnswers, SkillLevel, ActivityType)" + "VALUES (@StudentId, @DateTime, @TotalQuestions, @CorrectAnswers, @SkillLevel, @ActivityType)"; SqlCommand command = new SqlCommand(selectStatement, connection); command.Parameters.AddWithValue("@StudentId", (student.UserId)); command.Parameters.AddWithValue("@DateTime", currentDateTime); command.Parameters.AddWithValue("@TotalQuestions", placement.NumberOfQuestions); command.Parameters.AddWithValue("@CorrectAnswers", placement.NumberOfCorrectAnswers); command.Parameters.AddWithValue("@SkillLevel", student.studentLevel); command.Parameters.AddWithValue("@ActivityType", "Placement"); try { connection.Open(); int rowsAffected = command.ExecuteNonQuery(); if (rowsAffected > 0) { return(true); } else { return(false); } } catch (SqlException ex) { throw ex; } finally { connection.Close(); } }