Exemplo n.º 1
0
        public string getTest(string category, string mode, string difficulty, string showUnapproved)
        {
            DAL.DAL dal = new DAL.DAL("Data Source=localhost;Initial Catalog=dbExaminator;Integrated Security=True");

            dal.AddParam("@CatName", category);
            dal.AddParam("@Difficulty", difficulty);
            if (mode == "exam" || showUnapproved == "no")
            {
                dal.AddParam("@ApprovedOnly", "yes");
            }
            else
            {
                dal.AddParam("@ApprovedOnly", "no");
            }
            DataSet ds = new DataSet();

            ds = dal.ExecuteProcedure("spGetQuiz");

            DataTable dt = ds.Tables[0];

            JavaScriptSerializer serializer          = new JavaScriptSerializer();
            List <Dictionary <string, object> > rows = new List <Dictionary <string, object> >();
            Dictionary <string, object>         row;

            foreach (DataRow dr in dt.Rows)
            {
                row = new Dictionary <string, object>();
                foreach (DataColumn col in dt.Columns)
                {
                    row.Add(col.ColumnName, dr[col]);
                }
                rows.Add(row);
            }
            return(serializer.Serialize(rows));
        }
Exemplo n.º 2
0
        public void updateTimes(int questionID, int newTime)
        {
            DAL.DAL dal = new DAL.DAL("Data Source=localhost;Initial Catalog=dbExaminator;Integrated Security=True");
            dal.AddParam("@QuestionID", questionID);
            dal.AddParam("@QuestionNewTime", newTime);
            DataSet ds = new DataSet();

            ds = dal.ExecuteProcedure("spUpdateDefaultTimes");
        }
Exemplo n.º 3
0
        /// <summary>
        /// This method is called by the DefaultMaster page, when a user attempts to log in.
        /// It passes the username and password through the 'spVerifyUsers' procedure of the database.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pw"></param>
        /// <returns>The level of the user, which is -1 if the username or password do not match and a 2 if
        /// the user is an administrator, or a 1 if the user information is valid but does not have level clearance.</returns>
        public int VerifyUser(string name, string pw)
        {
            DAL.DAL dal = new DAL.DAL("Data Source = localhost; Initial Catalog = dbExaminator; Integrated Security = True");
            DataSet ds  = new DataSet();

            dal.AddParam("@UserName", name);
            dal.AddParam("@UserPass", pw);
            ds = dal.ExecuteProcedure("spVerifyUsers");
            return(Convert.ToInt16(ds.Tables[0].Rows[0]["UserLvl"]));
        }
Exemplo n.º 4
0
        /// <summary>
        /// This method is called by the DefaultMaster page when a new user registers their account.
        /// It passes the username, password and email through the 'spAddUsers' procedure of the database.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pw"></param>
        /// <param name="email"></param>
        /// <returns>If returns a value of 'UserID Exists' of 'User Email Exists' if the username or
        /// email address already exist in the database, otherwise it returns the userid.</returns>
        public string addNewUser(string name, string pw, string email)
        {
            DAL.DAL dal = new DAL.DAL("Data Source = localhost; Initial Catalog = dbExaminator; Integrated Security = True");
            DataSet ds  = new DataSet();

            dal.AddParam("@UserName", name);
            dal.AddParam("@UserPass", pw);
            dal.AddParam("@UserEmail", email);
            ds = dal.ExecuteProcedure("spAddUsers");
            return(ds.Tables[0].Rows[0][0].ToString());
        }
Exemplo n.º 5
0
        public void recordScores(string user, string category, int score, int totalTime, bool scoreBit)
        {
            DAL.DAL dal = new DAL.DAL("Data Source=localhost;Initial Catalog=dbExaminator;Integrated Security=True");
            dal.AddParam("@UserName", user);
            dal.AddParam("@CatName", category);
            dal.AddParam("@Score", score);
            dal.AddParam("@TotalTime", totalTime);
            dal.AddParam("@ScoreBit", scoreBit);
            DataSet ds = new DataSet();

            ds = dal.ExecuteProcedure("spWriteScores");
        }
Exemplo n.º 6
0
 /// <summary>
 /// This method receives the information necessary to update the explanation table using the procedure
 /// 'spUpdateExplanations' in the database and then executes the same.
 /// </summary>
 /// <param name="questionID"></param>
 /// <param name="explnText"></param>
 protected void UpdateExplanation(int questionID, string explnText)
 {
     try
     {
         DAL.DAL dal = new DAL.DAL("Data Source = localhost; Initial Catalog = dbExaminator; Integrated Security = True");
         DataSet ds  = new DataSet();
         dal.AddParam("@ExplanationQuestionID", questionID);
         dal.AddParam("@ExplanationText", explnText);
         dal.ExecuteProcedure("spUpdateExplanations");
     }
     catch
     {
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// This method receives the information necessary to update the category table using the procedure
 /// 'spUpdateCat' in the database and then executes the same.
 /// </summary>
 /// <param name="categoryID"></param>
 /// <param name="catName"></param>
 /// <param name="catDesc"></param>
 protected void UpdateCategory(int categoryID, string catName, string catDesc)
 {
     try
     {
         DAL.DAL dal = new DAL.DAL("Data Source = localhost; Initial Catalog = dbExaminator; Integrated Security = True");
         dal.AddParam("@CatID", categoryID);
         dal.AddParam("@CatName", catName);
         dal.AddParam("@CatDesc", catDesc);
         dal.ExecuteProcedure("spUpdateCat");
     }
     catch
     {
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// This method receives the information necessary to update the question table using the procedure
 /// 'spUpdateQuestions' in the database and then executes the same.
 /// </summary>
 /// <param name="categoryID"></param>
 /// <param name="questionID"></param>
 /// <param name="questionApproval"></param>
 /// <param name="questionActive"></param>
 /// <param name="questionText"></param>
 protected void UpdateQuestion(int categoryID, int questionID, bool questionApproval, bool questionActive, string questionText)
 {
     try
     {
         DAL.DAL dal = new DAL.DAL("Data Source = localhost; Initial Catalog = dbExaminator; Integrated Security = True");
         dal.AddParam("@QuestionID", questionID);
         dal.AddParam("@QuestionCatID", categoryID);
         dal.AddParam("@QuestionText", questionText);
         dal.AddParam("@QuestionApprovalBit", questionApproval);
         dal.AddParam("@QuestionBit", questionActive);
         dal.ExecuteProcedure("spUpdateQuestions");
     }
     catch
     {
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// This method is called by the DefaultMaster page when a user logs in. It passes the username
        /// through the 'spGetPreferences' procedure of the database to retrieve the settings of that user
        /// that determine whether they wish their scores to be displayed on the public scoreboard or not
        /// as well as whether they want to see unapproved questions or not.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pw"></param>
        /// <param name="access"></param>
        /// <returns>The variable 'currentUser' of type User is populated with all the information
        /// retrieved and returned.</returns>
        public User GetPreferences(string name, string pw, bool access)
        {
            DAL.DAL dal = new DAL.DAL("Data Source = localhost; Initial Catalog = dbExaminator; Integrated Security = True");
            DataSet ds  = new DataSet();

            dal.AddParam("@UserName", name);
            ds = dal.ExecuteProcedure("spGetPreferences");
            bool   showLeader; bool showUnapproved;
            string email = ds.Tables[0].Rows[0]["UserEmail"].ToString();

            if ((ds.Tables[0].Rows[0]["PrefShowInLeader"] != null) && !DBNull.Value.Equals(ds.Tables[0].Rows[0]["PrefShowInLeader"]))
            {
                showLeader = Convert.ToBoolean(ds.Tables[0].Rows[0]["PrefShowInLeader"]);
            }
            else
            {
                showLeader = false;
            }
            if ((ds.Tables[0].Rows[0]["PrefShowUnapproved"] != null) && !DBNull.Value.Equals(ds.Tables[0].Rows[0]["PrefShowUnapproved"]))
            {
                showUnapproved = Convert.ToBoolean(ds.Tables[0].Rows[0]["PrefShowUnapproved"]);
            }
            else
            {
                showUnapproved = false;
            }

            User currentUser = new User(name, pw, access, email, showLeader, showUnapproved);

            return(currentUser);
        }
Exemplo n.º 10
0
        /// <summary>
        /// This method is called by the DefaultMaster page when a user changes their preferences.
        /// It passes the user email, password and preferences along with username, depending on whether
        /// there is any change to the username or not through the 'spUpdatePreferences' procedure in the database.
        /// </summary>
        /// <param name="currentUser"></param>
        /// <param name="same"></param>
        /// <returns>Returns a message if the username was different from the initial username, but already exists
        /// in the database, or a 'good to go' message if the preferences were inserted correctly.</returns>
        public string SetPreferences(User currentUser, bool same)
        {
            DAL.DAL dal = new DAL.DAL("Data Source = localhost; Initial Catalog = dbExaminator; Integrated Security = True");
            DataSet ds  = new DataSet();

            dal.AddParam("@UserEmail", currentUser.UserEmail);

            if (!same)
            {
                dal.AddParam("@UserName", currentUser.UserName);
            }

            dal.AddParam("@UserPass", currentUser.UserPW);
            dal.AddParam("@PrefShowInLeader", currentUser.PrefLeader);
            dal.AddParam("@PrefShowUnapproved", currentUser.PrefUnapproved);
            ds = dal.ExecuteProcedure("spUpdatePreferences");
            return(ds.Tables[0].Rows[0][0].ToString());
        }
Exemplo n.º 11
0
        /// <summary>
        /// This method is called on by the UploadQuestion page in order to insert an explanation along
        /// with the associated question id number.
        /// </summary>
        /// <param name="questionID"></param>
        /// <param name="explanationText"></param>
        /// <returns>Returns an 'OK' or the error message depending on whether the explanation
        /// was inserted correctly or not.</returns>
        public string insertExplanation(int questionID, string explanationText)
        {
            try
            {
                DAL.DAL dal = new DAL.DAL("Data Source=localhost;Initial Catalog=dbExaminator;Integrated Security=True");

                dal.AddParam("@ExplanationQuestionID", questionID);
                dal.AddParam("@ExplanationText", explanationText);

                DataSet ds = new DataSet();
                ds = dal.ExecuteProcedure("spUploadExplanations");
                return("OK");
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// This method is called on by the UploadQuestion page in order to insert a category and description.
        /// </summary>
        /// <param name="catName"></param>
        /// <param name="catDesc"></param>
        /// <returns>Returns the category ID number or -1 if the category cannot be inserted</returns>
        public int insertCategory(string catName, string catDesc)
        {
            try
            {
                DAL.DAL dal = new DAL.DAL("Data Source=localhost;Initial Catalog=dbExaminator;Integrated Security=True");

                dal.AddParam("@CatName", catName);
                dal.AddParam("@CatDesc", catDesc);

                DataSet ds = new DataSet();
                ds = dal.ExecuteProcedure("spUploadCat");

                return(Convert.ToInt32(ds.Tables[0].Rows[0][0]));
            }
            catch
            {
                return(-1);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// This method is called on by the UploadQuestion page in order to insert a question id and text along with the
        /// username of the user that uploaded the question.
        /// </summary>
        /// <param name="catID"></param>
        /// <param name="user"></param>
        /// <param name="questionText"></param>
        /// <returns>Returns the question ID number or a -1 if the question cannot be inserted</returns>
        public int insertQuestion(int catID, string user, string questionText)
        {
            try
            {
                DAL.DAL dal = new DAL.DAL("Data Source=localhost;Initial Catalog=dbExaminator;Integrated Security=True");

                dal.AddParam("@QuestionCatID", catID);
                dal.AddParam("@QuestionUploader", user);
                dal.AddParam("@QuestionText", questionText);

                DataSet ds = new DataSet();
                ds = dal.ExecuteProcedure("spUploadQuestions");

                return(Convert.ToInt32(ds.Tables[0].Rows[0][0]));
            }
            catch
            {
                return(-1);
            }
        }
Exemplo n.º 14
0
        public string forgotPassword(string emailAddress, string newPassword)
        {
            string result;

            DAL.DAL dal = new DAL.DAL("Data Source = localhost; Initial Catalog=dbExaminator; Integrated Security = True");
            DataSet ds  = new DataSet();

            dal.AddParam("@UserEmail", emailAddress);
            dal.AddParam("@UserPass", newPassword);
            ds = dal.ExecuteProcedure("spForgotPW");
            if (ds.Tables[0].Rows[0]["Message"].ToString() == "Invalid Email")
            {
                return("Your email was not found in the database. Sorry!");
            }
            else
            {
                string message = "Your password has been reset to: " + newPassword + ". Please remember to change and record your password.";
                string subject = "Password reset";
                result = sendEmail(emailAddress, message, subject);
                return(result);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// The username of the user currently logged in is sent to the 'spGetScoresByID' procedure of the
        /// database to generate the personalized scoreboard.
        ///
        /// A label notifying the user that unless their settings allow, they will not be able to see their
        /// personal scores on the public leaderboard is displayed if that is the case.
        /// </summary>
        protected void populatePersonal()
        {
            DAL.DAL dal         = new DAL.DAL("Data Source = localhost; Initial Catalog = dbExaminator; Integrated Security = True");
            DataSet ds          = new DataSet();
            User    currentUser = (User)Session["User"];

            dal.AddParam("@UserName", currentUser.UserName);
            ds = dal.ExecuteProcedure("spGetScoresByID");
            gvPersonal.DataSource = ds;
            gvPersonal.DataBind();
            if (!currentUser.PrefLeader)
            {
                lblDisplay.Visible = true;
            }
        }
Exemplo n.º 16
0
 /// <summary>
 /// The database procedure 'GetAll' is invoked to populate the gridview with all questions in a specified
 /// category.
 /// </summary>
 /// <param name="catName"></param>
 protected void PopulateGridview(string catName)
 {
     try
     {
         DAL.DAL dal = new DAL.DAL("Data Source = localhost; Initial Catalog = dbExaminator; Integrated Security = True");
         DataSet ds  = new DataSet();
         dal.AddParam("@CatName", catName);
         ds = dal.ExecuteProcedure("spGetAll");
         gvEditor.DataSource = ds;
         gvEditor.DataBind();
     }
     catch
     {
     }
 }
Exemplo n.º 17
0
 /// <summary>
 /// This method receives the information necessary to update the answer table using the procedure
 /// 'spUpdateAnswers' in the database and then executes the same.
 /// </summary>
 /// </summary>
 /// <param name="questionID"></param>
 /// <param name="answerCorrect"></param>
 /// <param name="answer1"></param>
 /// <param name="answer2"></param>
 /// <param name="answer3"></param>
 /// <param name="answer4"></param>
 /// <param name="answer5"></param>
 protected void UpdateAnswer(int questionID, string answerCorrect, string answer1, string answer2, string answer3, string answer4, string answer5)
 {
     try
     {
         DAL.DAL dal = new DAL.DAL("Data Source = localhost; Initial Catalog = dbExaminator; Integrated Security = True");
         DataSet ds  = new DataSet();
         dal.AddParam("@AnswerQuestionID", questionID);
         dal.AddParam("@AnswerCorrect", answerCorrect);
         dal.AddParam("@Answer1", answer1);
         dal.AddParam("@Answer2", answer2);
         dal.AddParam("@Answer3", answer3);
         dal.AddParam("@Answer4", answer4);
         dal.AddParam("@Answer5", answer5);
         dal.ExecuteProcedure("spUpdateAnswers");
     }
     catch
     {
     }
 }
Exemplo n.º 18
0
        /// <summary>
        /// This method is called on by the UploadQuestion page in order to insert a set of answers along
        /// with the associated question id number.
        /// </summary>
        /// <param name="questionID"></param>
        /// <param name="answerCorrect"></param>
        /// <param name="answer1"></param>
        /// <param name="answer2"></param>
        /// <param name="answer3"></param>
        /// <param name="answer4"></param>
        /// <param name="answer5"></param>
        /// <returns>Returns an 'OK' or the error message depending on whether the answer was inserted correctly or not.</returns>
        public string insertAnswer(int questionID, string answerCorrect, string answer1, string answer2, string answer3, string answer4, string answer5)
        {
            try
            {
                DAL.DAL dal = new DAL.DAL("Data Source=localhost;Initial Catalog=dbExaminator;Integrated Security=True");

                dal.AddParam("@AnswerQuestionID", questionID);
                dal.AddParam("@AnswerCorrect", answerCorrect);
                dal.AddParam("@Answer1", answer1);
                dal.AddParam("@Answer2", answer2);
                dal.AddParam("@Answer3", answer3);
                dal.AddParam("@Answer4", answer4);
                dal.AddParam("@Answer5", answer5);

                DataSet ds = new DataSet();
                ds = dal.ExecuteProcedure("spUploadAnswers");
                return("OK");
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
Exemplo n.º 19
0
 /// <summary>
 /// This method receives the information necessary to update the answer table using the procedure
 /// 'spUpdateAnswers' in the database and then executes the same.
 /// </summary>
 /// </summary>
 /// <param name="questionID"></param>
 /// <param name="answerCorrect"></param>
 /// <param name="answer1"></param>
 /// <param name="answer2"></param>
 /// <param name="answer3"></param>
 /// <param name="answer4"></param>
 /// <param name="answer5"></param>
 protected void UpdateAnswer(int questionID, string answerCorrect, string answer1, string answer2, string answer3, string answer4, string answer5)
 {
     try
     {
         DAL.DAL dal = new DAL.DAL("Data Source = localhost; Initial Catalog = dbExaminator; Integrated Security = True");
         DataSet ds = new DataSet();
         dal.AddParam("@AnswerQuestionID", questionID);
         dal.AddParam("@AnswerCorrect", answerCorrect);
         dal.AddParam("@Answer1", answer1);
         dal.AddParam("@Answer2", answer2);
         dal.AddParam("@Answer3", answer3);
         dal.AddParam("@Answer4", answer4);
         dal.AddParam("@Answer5", answer5);
         dal.ExecuteProcedure("spUpdateAnswers");
     }
     catch
     {
     }
 }
Exemplo n.º 20
0
        /// <summary>
        /// This method is called by the DefaultMaster page when a user changes their preferences.
        /// It passes the user email, password and preferences along with username, depending on whether
        /// there is any change to the username or not through the 'spUpdatePreferences' procedure in the database.
        /// </summary>
        /// <param name="currentUser"></param>
        /// <param name="same"></param>
        /// <returns>Returns a message if the username was different from the initial username, but already exists
        /// in the database, or a 'good to go' message if the preferences were inserted correctly.</returns>
        public string SetPreferences(User currentUser, bool same)
        {
            DAL.DAL dal = new DAL.DAL("Data Source = localhost; Initial Catalog = dbExaminator; Integrated Security = True");
            DataSet ds = new DataSet();
            dal.AddParam("@UserEmail", currentUser.UserEmail);

            if (!same)
            {
                dal.AddParam("@UserName", currentUser.UserName);
            }

            dal.AddParam("@UserPass", currentUser.UserPW);
            dal.AddParam("@PrefShowInLeader", currentUser.PrefLeader);
            dal.AddParam("@PrefShowUnapproved", currentUser.PrefUnapproved);
            ds = dal.ExecuteProcedure("spUpdatePreferences");
            return ds.Tables[0].Rows[0][0].ToString();
        }
Exemplo n.º 21
0
 /// <summary>
 /// This method is called by the DefaultMaster page, when a user attempts to log in.
 /// It passes the username and password through the 'spVerifyUsers' procedure of the database.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="pw"></param>
 /// <returns>The level of the user, which is -1 if the username or password do not match and a 2 if 
 /// the user is an administrator, or a 1 if the user information is valid but does not have level clearance.</returns>
 public int VerifyUser(string name, string pw)
 {
     DAL.DAL dal = new DAL.DAL("Data Source = localhost; Initial Catalog = dbExaminator; Integrated Security = True");
     DataSet ds = new DataSet();
     dal.AddParam("@UserName", name);
     dal.AddParam("@UserPass", pw);
     ds = dal.ExecuteProcedure("spVerifyUsers");
     return Convert.ToInt16(ds.Tables[0].Rows[0]["UserLvl"]);
 }
Exemplo n.º 22
0
 /// <summary>
 /// This method is called by the DefaultMaster page when a new user registers their account.
 /// It passes the username, password and email through the 'spAddUsers' procedure of the database.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="pw"></param>
 /// <param name="email"></param>
 /// <returns>If returns a value of 'UserID Exists' of 'User Email Exists' if the username or
 /// email address already exist in the database, otherwise it returns the userid.</returns>
 public string addNewUser(string name, string pw, string email)
 {
     DAL.DAL dal = new DAL.DAL("Data Source = localhost; Initial Catalog = dbExaminator; Integrated Security = True");
     DataSet ds = new DataSet();
     dal.AddParam("@UserName", name);
     dal.AddParam("@UserPass", pw);
     dal.AddParam("@UserEmail", email);
     ds = dal.ExecuteProcedure("spAddUsers");
     return ds.Tables[0].Rows[0][0].ToString();
 }
Exemplo n.º 23
0
 /// <summary>
 /// This method receives the information necessary to update the question table using the procedure
 /// 'spUpdateQuestions' in the database and then executes the same.
 /// </summary>
 /// <param name="categoryID"></param>
 /// <param name="questionID"></param>
 /// <param name="questionApproval"></param>
 /// <param name="questionActive"></param>
 /// <param name="questionText"></param>
 protected void UpdateQuestion(int categoryID, int questionID, bool questionApproval, bool questionActive, string questionText)
 {
     try
     {
         DAL.DAL dal = new DAL.DAL("Data Source = localhost; Initial Catalog = dbExaminator; Integrated Security = True");
         dal.AddParam("@QuestionID", questionID);
         dal.AddParam("@QuestionCatID", categoryID);
         dal.AddParam("@QuestionText", questionText);
         dal.AddParam("@QuestionApprovalBit", questionApproval);
         dal.AddParam("@QuestionBit", questionActive);
         dal.ExecuteProcedure("spUpdateQuestions");
     }
     catch
     {
     }
 }
Exemplo n.º 24
0
 /// <summary>
 /// This method receives the information necessary to update the explanation table using the procedure
 /// 'spUpdateExplanations' in the database and then executes the same.
 /// </summary>
 /// <param name="questionID"></param>
 /// <param name="explnText"></param>
 protected void UpdateExplanation(int questionID, string explnText)
 {
     try
     {
         DAL.DAL dal = new DAL.DAL("Data Source = localhost; Initial Catalog = dbExaminator; Integrated Security = True");
         DataSet ds = new DataSet();
         dal.AddParam("@ExplanationQuestionID", questionID);
         dal.AddParam("@ExplanationText", explnText);
         dal.ExecuteProcedure("spUpdateExplanations");
     }
     catch
     {
     }
 }
Exemplo n.º 25
0
        /// <summary>
        /// This method is called by the DefaultMaster page when a user logs in. It passes the username
        /// through the 'spGetPreferences' procedure of the database to retrieve the settings of that user
        /// that determine whether they wish their scores to be displayed on the public scoreboard or not
        /// as well as whether they want to see unapproved questions or not.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pw"></param>
        /// <param name="access"></param>
        /// <returns>The variable 'currentUser' of type User is populated with all the information
        /// retrieved and returned.</returns>
        public User GetPreferences(string name, string pw, bool access)
        {
            DAL.DAL dal = new DAL.DAL("Data Source = localhost; Initial Catalog = dbExaminator; Integrated Security = True");
            DataSet ds = new DataSet();
            dal.AddParam("@UserName", name);
            ds = dal.ExecuteProcedure("spGetPreferences");
            bool showLeader; bool showUnapproved;
            string email = ds.Tables[0].Rows[0]["UserEmail"].ToString();

            if ((ds.Tables[0].Rows[0]["PrefShowInLeader"] != null) && !DBNull.Value.Equals(ds.Tables[0].Rows[0]["PrefShowInLeader"]))
            {
                showLeader = Convert.ToBoolean(ds.Tables[0].Rows[0]["PrefShowInLeader"]);
            }
            else
            {
                showLeader = false;
            }
            if ((ds.Tables[0].Rows[0]["PrefShowUnapproved"] != null) && !DBNull.Value.Equals(ds.Tables[0].Rows[0]["PrefShowUnapproved"]))
            {
                showUnapproved = Convert.ToBoolean(ds.Tables[0].Rows[0]["PrefShowUnapproved"]);
            }
            else
            {
               showUnapproved = false;
            }

            User currentUser = new User(name, pw, access, email, showLeader, showUnapproved);
            return currentUser;
        }
Exemplo n.º 26
0
        /// <summary>
        /// This method is called on by the UploadQuestion page in order to insert a question id and text along with the
        /// username of the user that uploaded the question.
        /// </summary>
        /// <param name="catID"></param>
        /// <param name="user"></param>
        /// <param name="questionText"></param>
        /// <returns>Returns the question ID number or a -1 if the question cannot be inserted</returns>
        public int insertQuestion(int catID, string user, string questionText)
        {
            try
            {
                DAL.DAL dal = new DAL.DAL("Data Source=localhost;Initial Catalog=dbExaminator;Integrated Security=True");

                dal.AddParam("@QuestionCatID", catID);
                dal.AddParam("@QuestionUploader", user);
                dal.AddParam("@QuestionText", questionText);

                DataSet ds = new DataSet();
                ds = dal.ExecuteProcedure("spUploadQuestions");

                return Convert.ToInt32(ds.Tables[0].Rows[0][0]);
            }
            catch
            {
                return -1;
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// This method is called on by the UploadQuestion page in order to insert an explanation along
        /// with the associated question id number.
        /// </summary>
        /// <param name="questionID"></param>
        /// <param name="explanationText"></param>
        /// <returns>Returns an 'OK' or the error message depending on whether the explanation
        /// was inserted correctly or not.</returns>
        public string insertExplanation(int questionID, string explanationText)
        {
            try
            {
                DAL.DAL dal = new DAL.DAL("Data Source=localhost;Initial Catalog=dbExaminator;Integrated Security=True");

                dal.AddParam("@ExplanationQuestionID", questionID);
                dal.AddParam("@ExplanationText", explanationText);

                DataSet ds = new DataSet();
                ds = dal.ExecuteProcedure("spUploadExplanations");
                return "OK";
            }
            catch (Exception e)
            {
                return e.ToString();
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// This method is called on by the UploadQuestion page in order to insert a set of answers along
        /// with the associated question id number.
        /// </summary>
        /// <param name="questionID"></param>
        /// <param name="answerCorrect"></param>
        /// <param name="answer1"></param>
        /// <param name="answer2"></param>
        /// <param name="answer3"></param>
        /// <param name="answer4"></param>
        /// <param name="answer5"></param>
        /// <returns>Returns an 'OK' or the error message depending on whether the answer was inserted correctly or not.</returns>
        public string insertAnswer(int questionID, string answerCorrect, string answer1, string answer2, string answer3, string answer4, string answer5)
        {
            try
            {
                DAL.DAL dal = new DAL.DAL("Data Source=localhost;Initial Catalog=dbExaminator;Integrated Security=True");

                dal.AddParam("@AnswerQuestionID", questionID);
                dal.AddParam("@AnswerCorrect", answerCorrect);
                dal.AddParam("@Answer1", answer1);
                dal.AddParam("@Answer2", answer2);
                dal.AddParam("@Answer3", answer3);
                dal.AddParam("@Answer4", answer4);
                dal.AddParam("@Answer5", answer5);

                DataSet ds = new DataSet();
                ds = dal.ExecuteProcedure("spUploadAnswers");
                return "OK";
            }
            catch (Exception e)
            {
                return e.ToString();
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// This method is called on by the UploadQuestion page in order to insert a category and description.
        /// </summary>
        /// <param name="catName"></param>
        /// <param name="catDesc"></param>
        /// <returns>Returns the category ID number or -1 if the category cannot be inserted</returns>
        public int insertCategory(string catName, string catDesc)
        {
            try
            {
                DAL.DAL dal = new DAL.DAL("Data Source=localhost;Initial Catalog=dbExaminator;Integrated Security=True");

                dal.AddParam("@CatName", catName);
                dal.AddParam("@CatDesc", catDesc);

                DataSet ds = new DataSet();
                ds = dal.ExecuteProcedure("spUploadCat");

                return Convert.ToInt32(ds.Tables[0].Rows[0][0]);
            }
            catch
            {
                return -1;
            }
        }
Exemplo n.º 30
0
 /// <summary>
 /// This method receives the information necessary to update the category table using the procedure
 /// 'spUpdateCat' in the database and then executes the same.
 /// </summary>
 /// <param name="categoryID"></param>
 /// <param name="catName"></param>
 /// <param name="catDesc"></param>
 protected void UpdateCategory(int categoryID, string catName, string catDesc)
 {
     try
     {
         DAL.DAL dal = new DAL.DAL("Data Source = localhost; Initial Catalog = dbExaminator; Integrated Security = True");
         dal.AddParam("@CatID", categoryID);
         dal.AddParam("@CatName", catName);
         dal.AddParam("@CatDesc", catDesc);
         dal.ExecuteProcedure("spUpdateCat");
     }
     catch
     {
     }
 }