예제 #1
0
        private void SubmitExam()
        {
            StoreScore storeStore = new StoreScore();

            storeStore.UserId          = SessionUtil.User.Id;
            storeStore.ExamId          = exam.Id;
            this.pnlExamResult.Visible = true;
            List <int> results = null;

            try
            {
                results = examClient.SaveStudentTotalScore(storeStore);
            }
            catch (FaultException <DBException> faultDbException)
            {
                ShowAlertWindow(faultDbException.Message);
                HideQuestionRelativeControls();
            }
            catch (CommunicationException communicationException)
            {
                ShowAlertWindow(Constants.CannotConnServer);
                HideQuestionRelativeControls();
            }
            catch (TimeoutException timeoutException)
            {
                ShowAlertWindow(Constants.NetworkTimeout);
                HideQuestionRelativeControls();
            }

            this.lblExamResultScore.Text           = results[0].ToString();
            this.lblExamResultCorrectQuantity.Text = results[1].ToString();
            this.studentScore    = results[0];
            this.correctQuantity = results[1];
        }
예제 #2
0
파일: ExamDal.cs 프로젝트: kevinwen24/oes
        public void SaveStudentTotalScore(StoreScore storeScore)
        {
            SqlConnection connection = DBUtil.GetSqlConnection();

            try
            {
                connection.Open();
                SqlCommand command = new SqlCommand(Constants.ProcSaveStudentScore, connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add(new SqlParameter(Constants.SqlParameterUserId, storeScore.UserId));
                command.Parameters.Add(new SqlParameter(Constants.SqlParameterExamId, storeScore.ExamId));
                command.Parameters.Add(new SqlParameter(Constants.SqlParameterScore, storeScore.Score));
                command.Parameters.Add(new SqlParameter(Constants.SqlParameterOperation, storeScore.Operation));
                command.ExecuteNonQuery();
            }
            finally
            {
                DBUtil.ColseSqlConnection(connection);
            }
        }
예제 #3
0
    void saveHighScores()
    {
        StoreScore.loadScores();
        //Add Score
        StoreScore.scoreClass.highScores.Add(PlayerManager.playerScore);
        StoreScore.scoreClass.highScores.Sort();
        StoreScore.scoreClass.highScores.Reverse();
        StoreScore.scoreClass.highScores.RemoveAt(StoreScore.scoreClass.highScores.Count - 1);

        //Add name
        int scoreIndex;

        if (StoreScore.scoreClass.highScores.Contains(PlayerManager.playerScore))
        {
            scoreIndex = StoreScore.scoreClass.highScores.IndexOf(PlayerManager.playerScore);
            StoreScore.scoreClass.playerNames.Insert(scoreIndex, StartMenu.playerName);
            StoreScore.scoreClass.playerNames.RemoveAt(StoreScore.scoreClass.playerNames.Count - 1);
        }

        StoreScore.saveScores();
    }
예제 #4
0
        public List <int> SaveStudentTotalScore(StoreScore storeScore)
        {
            try
            {
                List <int> results          = new List <int>();
                Exam       exam             = examDal.GetExamByExamId(storeScore.ExamId);
                List <int> isCorrectAnswers = examDal.SelectStudentAnswerScore(storeScore.UserId, storeScore.ExamId);

                int correctNum = 0;
                for (int i = 0; i < isCorrectAnswers.Count; i++)
                {
                    if (isCorrectAnswers[i] == 1)
                    {
                        correctNum++;
                    }
                }

                storeScore.Score = correctNum * exam.SingleScore;

                if (storeScore.Score >= exam.PassScore)
                {
                    storeScore.Operation = "Pass";
                }

                else if (storeScore.Score < exam.PassScore)
                {
                    storeScore.Operation = "No pass";
                }
                examDal.SaveStudentTotalScore(storeScore);
                results.Add(storeScore.Score);
                results.Add(correctNum);
                return(results);
            }
            catch (SqlException sqlException)
            {
                log.Error(sqlException.StackTrace);
                throw new FaultException <DBException>(new DBException(), Constants.ServerError);
            }
        }
예제 #5
0
 // Start is called before the first frame update
 void Start()
 {
     StoreScore.loadScores();
 }