public string insertNewSelfTestRecord(string userId, string selfTestId, string answer) { UserResultInSelfTestTableAdapter stResultAdapter = new UserResultInSelfTestTableAdapter(); int success = stResultAdapter.InsertNewAnswerToSelfTest(Convert.ToInt32(userId), Convert.ToInt32(selfTestId), answer); if (success == 1) { return "Success"; } return "Failed to insert a new self test record."; }
public string markASelfTestRecord(string userId, string score, string selfTestId) { UserResultInSelfTestTableAdapter resultAdapter = new UserResultInSelfTestTableAdapter(); int success = resultAdapter.UpdateScore(Convert.ToInt32(score), Convert.ToInt32(userId), Convert.ToInt32(selfTestId)); if (success == 1) { return "Success"; } return "Failed to mark the student with ID:" + userId + " in question " + selfTestId; }
public List<SelfTestResult> getUserSelfTestResult(string userId) { UserResultInSelfTestTableAdapter userSTAdapter = new UserResultInSelfTestTableAdapter(); List<SelfTestResult> list = new List<SelfTestResult>(); int uId = Convert.ToInt32(userId); UserDataTableAdapter adapter = new UserDataTableAdapter(); foreach (var row in userSTAdapter.GetSelfTestResultByUserId(uId)) { SelfTestResult str = new SelfTestResult(); str.questionId = row.SelfTestId; str.userId = row.UserId; str.username = adapter.GetUserDataById(str.userId)[0].Username; try { str.score = row.Score; } catch (StrongTypingException e) { str.score = -1; } try { str.answer = row.Answer; } catch (StrongTypingException e) { str.answer = null; } list.Add(str); } return list; }