Beispiel #1
0
        /// <summary>
        /// Starts the exam for the given IdUser.
        /// </summary>
        /// <param name="idUser">The given IdUser.</param>
        /// <param name="idExam">The given IdExam.</param>
        /// <param name="ignorePrevious">Ignores previous exams and builds new ones.</param>
        /// <returns>The IdUserExam for the current IdUser/IdExam combination.</returns>
        public static int ExamStart(int idUser, int idExam, bool ignorePrevious)
        {
            int      idUserExam = Common.GetBDNum("IdUserExam", "SELECT MAX(IdUserExam) AS IdUserExam FROM UserExam WHERE IdUser = "******" AND IdExam = " + idExam);
            UserExam userExam;

            if ((idUserExam != 0) && !ignorePrevious)
            {
                userExam = new UserExam(idUserExam);
            }
            else
            {
                userExam        = new UserExam();
                userExam.IdUser = idUser;
                userExam.IdExam = idExam;
                userExam.Create();
            }
            return(userExam.IdUserExam);
        }
Beispiel #2
0
        /// <summary>
        /// Shows the exam list for the current user.
        /// </summary>
        /// <returns>An HTML with the list of available exams.</returns>
        public static string GetPendingExamsList()
        {
            int    currentId = SessionHandler.Id;
            string retval    = "";
            string className = "";
            string sql       = "";
            int    total     = 0;

            retval = "<table width='100%'>";

            //Table Header
            retval += "<tr><th>#</th><th>" + Text.Exam + "</th><th>" + Text.Status + "</th></tr>";

            //Self-Enroll exams
            sql = "SELECT IdExam FROM Exam WHERE Status = " + ExamStatus.ACTIVE + " AND SelfEnroll = 1 AND IdExam NOT IN(SELECT IdExam FROM UserExam WHERE IdUser="******")";
            string[] idExamList = Common.CSVToArray(Common.GetBDList("IdExam", sql, false));
            foreach (string idExam in idExamList)
            {
                try
                {
                    Exam exam = new Exam(Convert.ToInt32(idExam));
                    className = Common.SwitchClass(className);
                    int    examStatus     = Common.GetBDNum("Status", "SELECT Status FROM UserExam WHERE IdExam = " + idExam + " AND IdUser = "******"";
                    if (examStatus == UserExamStatus.PENDING)
                    {
                        examStatusDesc = Text.Exam_Pending;
                    }
                    else if (examStatus == UserExamStatus.INCOMPLETE)
                    {
                        examStatusDesc = Text.Exam_Incomplete;
                    }
                    else
                    {
                        examStatusDesc = Text.Exam_Complete;
                    }
                    retval += "<tr class='" + className + "' onClick='exam(" + idExam + ");'>";
                    retval += "<td width='10%' align='center'>" + (total + 1) + "</td>";
                    retval += "<td width='70%'>" + exam.ExamName + "</td>";
                    retval += "<td width='20%' align='center'>" + examStatusDesc + "</td>";
                    retval += "</tr>";
                    total++;
                }
                catch (Exception ex) { }
            }
            //Assigned Exams
            sql = "SELECT IdUserExam FROM UserExam WHERE Status = " + UserExamStatus.PENDING + " AND IdUser="******"IdUserExam", sql, false));
            foreach (string idUserExam in idUserExamList)
            {
                try
                {
                    UserExam userExam = new UserExam(Convert.ToInt32(idUserExam));
                    Exam     exam     = new Exam(userExam.IdExam);
                    className = Common.SwitchClass(className);
                    int    examStatus     = Common.GetBDNum("Status", "SELECT Status FROM UserExam WHERE IdUserExam=" + idUserExam);
                    string examStatusDesc = "";
                    if (examStatus == UserExamStatus.PENDING)
                    {
                        examStatusDesc = Text.Exam_Pending;
                    }
                    else if (examStatus == UserExamStatus.INCOMPLETE)
                    {
                        examStatusDesc = Text.Exam_Incomplete;
                    }
                    else
                    {
                        examStatusDesc = Text.Exam_Complete;
                    }
                    retval += "<tr class='" + className + "' onClick='exam(" + userExam.IdExam + ", " + userExam.IdUserExam + ");'>";
                    retval += "<td width='10%' align='center'>" + (total + 1) + "</td>";
                    retval += "<td width='70%'>" + exam.ExamName + "</td>";
                    retval += "<td width='20%' align='center'>" + examStatusDesc + "</td>";
                    retval += "</tr>";
                    total++;
                }
                catch (Exception ex) { }
            }
            if (total == 0)
            {
                retval += "<tr><td colspan='3' width='100%' class='alert'>" + Text.NoPendingExams + "</td></tr>";
            }

            retval += "</table>";
            return(retval);
        }
Beispiel #3
0
        /// <summary>
        /// Retrieves the exam list as an HTML string.
        /// </summary>
        /// <param name="modules">The current user modules.</param>
        /// <param name="currentPage">The current page used.</param>
        /// <param name="filter">An SQL filter.</param>
        /// <returns>The HTML string with the question list.</returns>
        public static string GetReportList(int currentPage, string filter)
        {
            string retval    = "";
            string className = "";
            int    total     = 0;
            string sql       = "SELECT COUNT(IdExam) AS HowMany FROM UserExam";

            sql = Common.StrAdd(sql, " WHERE ", filter);
            double recordsPerPage = Config.RecordsPerPage();
            double totalRecords   = Common.GetBDNum("HowMany", sql);
            int    totalPages     = Convert.ToInt32(Math.Ceiling(totalRecords / recordsPerPage));

            if (currentPage > totalPages)
            {
                currentPage = totalPages;
            }
            if (currentPage == 0)
            {
                currentPage = 1;
            }

            retval = "<table width='100%'>";

            //Table Header
            retval += "<tr><th>" + Text.FullName + "</th><th>" + Text.Exam + "</th><th>" + Text.DateTime + "</th><th>" + Text.Status + "</th><th>" + Text.Score + "</th></tr>";

            sql  = "SELECT IdUserExam FROM (SELECT IdUserExam, ROW_NUMBER() OVER (ORDER BY IdUserExam) AS RowNum FROM UserExam";
            sql  = Common.StrAdd(sql, " WHERE ", filter);
            sql += ") AS U WHERE U.RowNum BETWEEN ((" + currentPage + " - 1) * " + recordsPerPage + ") + 1 AND " + recordsPerPage + " * (" + currentPage + ")";
            string[] idUserExamList = Common.CSVToArray(Common.GetBDList("IdUserExam", sql, false));
            foreach (string idUserExam in idUserExamList)
            {
                try
                {
                    UserExam userExam = new UserExam(Convert.ToInt32(idUserExam));
                    User     user     = new User(userExam.IdUser);
                    Exam     exam     = new Exam(userExam.IdExam);
                    className = Common.SwitchClass(className);
                    if (userExam.Status == UserExamStatus.PENDING && Modules.Permission(SessionHandler.Modules, Modules.EVAL_SOLVE_USER))
                    {
                        retval += "<tr class='" + className + "' onClick='exam(" + idUserExam + ");'>";
                    }
                    else
                    {
                        retval += "<tr class='" + className + "' onClick='detail(" + idUserExam + ");'>";
                    }
                    retval += "<td width='30%'>" + user.FullName(true) + "</td>";
                    retval += "<td width='30%'>" + exam.ExamName + "</td>";
                    retval += "<td width='20%' align='center'>" + userExam.DateComplete + "</td>";
                    retval += "<td width='10%' align='center'>" + UserExamStatus.FriendlyText(userExam.Status) + "</td>";
                    retval += "<td width='10%' align='center'>" + String.Format("{0:0.00}", userExam.Score) + "</td>";
                    retval += "</tr>";
                    total++;
                }
                catch (Exception ex) { }
            }

            retval += "</table>";

            //footer / pagination
            retval += "<div align='center' class='pagination'>";
            retval += "<div align='left' style='width: 50%; display: inline-block;'>" + Common.StrLang(Text.ShowingXofY, total.ToString() + "," + totalRecords.ToString()) + " " + Text.Records + "</div>";
            retval += "<div align='right' style='width: 50%; display: inline-block;'>" + Common.StrLang(Text.PageXofY, currentPage.ToString() + "," + totalPages.ToString());
            retval += "&nbsp;<a href='#' class='dark' onClick='firstPage();'>&lt;&lt;</a>";
            retval += "&nbsp;<a href='#' class='dark' onClick='prevPage();'>&lt;</a>";
            retval += "&nbsp;<a href='#' class='dark' onClick='nextPage();'>&gt;</a>";
            retval += "&nbsp;<a href='#' class='dark' onClick='lastPage(" + totalPages + ");'>&gt;&gt;</a>";
            retval += "</div>";
            retval += "</div>";

            return(retval);
        }
Beispiel #4
0
 /// <summary>
 /// Retrieves the exam data from the given filters.
 /// </summary>
 /// <param name="userFilter">An SQL query.</param>
 /// <returns>A DataTable with the full Data.</returns>
 public DataTable ExportDataExam(string filter)
 {
     FullDataTable = new DataTable();
     ColumnTitles = new List<string>();
     string sql = "SELECT IdUserExam FROM UserExam";
     sql = Common.StrAdd(sql, " WHERE ", filter);
     string[] idUserExamList = Common.CSVToArray(Common.GetBDList("IdUserExam", sql, false));
     FullDataTable.Columns.Add("usr_name", typeof(string));
     ColumnTitles.Add(Text.FullName);
     FullDataTable.Columns.Add("exam_name", typeof(string));
     ColumnTitles.Add(Text.Exam);
     FullDataTable.Columns.Add("exam_date", typeof(string));
     ColumnTitles.Add(Text.DateTime);
     FullDataTable.Columns.Add("exam_status", typeof(string));
     ColumnTitles.Add(Text.Status);
     FullDataTable.Columns.Add("exam_score", typeof(double));
     ColumnTitles.Add(Text.Score);
     foreach (string idUserExam in idUserExamList)
     {
         var row = FullDataTable.NewRow();
         UserExam userExam = new UserExam(Convert.ToInt32(idUserExam));
         User user = new User(userExam.IdUser);
         Exam exam = new Exam(userExam.IdExam);
         row["usr_name"] = user.FullName(true);
         row["exam_name"] = exam.ExamName;
         row["exam_date"] = userExam.DateComplete;
         row["exam_status"] = UserExamStatus.FriendlyText(userExam.Status);
         row["exam_score"] = String.Format("{0:0.00}", userExam.Score);
         FullDataTable.Rows.Add(row);
     }
     return FullDataTable;
 }
Beispiel #5
0
        /// <summary>
        /// Retrieves the exam list as an HTML string.
        /// </summary>
        /// <param name="modules">The current user modules.</param>
        /// <param name="currentPage">The current page used.</param>
        /// <param name="filter">An SQL filter.</param>
        /// <returns>The HTML string with the question list.</returns>
        public static string GetReportList(int currentPage, string filter)
        {
            string retval = "";
            string className = "";
            int total = 0;
            string sql = "SELECT COUNT(IdExam) AS HowMany FROM UserExam";
            sql = Common.StrAdd(sql, " WHERE ", filter);
            double recordsPerPage = Config.RecordsPerPage();
            double totalRecords = Common.GetBDNum("HowMany", sql);
            int totalPages = Convert.ToInt32(Math.Ceiling(totalRecords / recordsPerPage));

            if (currentPage > totalPages)
            {
                currentPage = totalPages;
            }
            if (currentPage == 0)
            {
                currentPage = 1;
            }

            retval = "<table width='100%'>";

            //Table Header
            retval += "<tr><th>" + Text.FullName + "</th><th>" + Text.Exam + "</th><th>" + Text.DateTime + "</th><th>" + Text.Status + "</th><th>" + Text.Score + "</th></tr>";

            sql = "SELECT IdUserExam FROM (SELECT IdUserExam, ROW_NUMBER() OVER (ORDER BY IdUserExam) AS RowNum FROM UserExam";
            sql = Common.StrAdd(sql, " WHERE ", filter);
            sql += ") AS U WHERE U.RowNum BETWEEN ((" + currentPage + " - 1) * " + recordsPerPage + ") + 1 AND " + recordsPerPage + " * (" + currentPage + ")";
            string[] idUserExamList = Common.CSVToArray(Common.GetBDList("IdUserExam", sql, false));
            foreach (string idUserExam in idUserExamList)
            {
                try
                {
                    UserExam userExam = new UserExam(Convert.ToInt32(idUserExam));
                    User user = new User(userExam.IdUser);
                    Exam exam = new Exam(userExam.IdExam);
                    className = Common.SwitchClass(className);
                    if (userExam.Status == UserExamStatus.PENDING && Modules.Permission(SessionHandler.Modules, Modules.EVAL_SOLVE_USER))
                    {
                        retval += "<tr class='" + className + "' onClick='exam(" + idUserExam + ");'>";
                    }
                    else
                    {
                        retval += "<tr class='" + className + "' onClick='detail(" + idUserExam + ");'>";
                    }
                    retval += "<td width='30%'>" + user.FullName(true) + "</td>";
                    retval += "<td width='30%'>" + exam.ExamName + "</td>";
                    retval += "<td width='20%' align='center'>" + userExam.DateComplete + "</td>";
                    retval += "<td width='10%' align='center'>" + UserExamStatus.FriendlyText(userExam.Status) + "</td>";
                    retval += "<td width='10%' align='center'>" + String.Format("{0:0.00}", userExam.Score) + "</td>";
                    retval += "</tr>";
                    total++;
                }
                catch (Exception ex) { }
            }

            retval += "</table>";

            //footer / pagination
            retval += "<div align='center' class='pagination'>";
            retval += "<div align='left' style='width: 50%; display: inline-block;'>" + Common.StrLang(Text.ShowingXofY, total.ToString() + "," + totalRecords.ToString()) + " " + Text.Records + "</div>";
            retval += "<div align='right' style='width: 50%; display: inline-block;'>" + Common.StrLang(Text.PageXofY, currentPage.ToString() + "," + totalPages.ToString());
            retval += "&nbsp;<a href='#' class='dark' onClick='firstPage();'>&lt;&lt;</a>";
            retval += "&nbsp;<a href='#' class='dark' onClick='prevPage();'>&lt;</a>";
            retval += "&nbsp;<a href='#' class='dark' onClick='nextPage();'>&gt;</a>";
            retval += "&nbsp;<a href='#' class='dark' onClick='lastPage(" + totalPages + ");'>&gt;&gt;</a>";
            retval += "</div>";
            retval += "</div>";

            return retval;
        }
Beispiel #6
0
        /// <summary>
        /// Shows the exam list for the current user.
        /// </summary>
        /// <returns>An HTML with the list of available exams.</returns>
        public static string GetPendingExamsList()
        {
            int currentId = SessionHandler.Id;
            string retval = "";
            string className = "";
            string sql = "";
            int total = 0;

            retval = "<table width='100%'>";

            //Table Header
            retval += "<tr><th>#</th><th>" + Text.Exam + "</th><th>" + Text.Status + "</th></tr>";

            //Self-Enroll exams
            sql = "SELECT IdExam FROM Exam WHERE Status = " + ExamStatus.ACTIVE + " AND SelfEnroll = 1 AND IdExam NOT IN(SELECT IdExam FROM UserExam WHERE IdUser="******")";
            string[] idExamList = Common.CSVToArray(Common.GetBDList("IdExam", sql, false));
            foreach (string idExam in idExamList)
            {
                try
                {
                    Exam exam = new Exam(Convert.ToInt32(idExam));
                    className = Common.SwitchClass(className);
                    int examStatus = Common.GetBDNum("Status", "SELECT Status FROM UserExam WHERE IdExam = " + idExam + " AND IdUser = "******"";
                    if (examStatus == UserExamStatus.PENDING)
                    {
                        examStatusDesc = Text.Exam_Pending;
                    }
                    else if (examStatus == UserExamStatus.INCOMPLETE)
                    {
                        examStatusDesc = Text.Exam_Incomplete;
                    }
                    else
                    {
                        examStatusDesc = Text.Exam_Complete;
                    }
                    retval += "<tr class='" + className + "' onClick='exam(" + idExam + ");'>";
                    retval += "<td width='10%' align='center'>" + (total + 1) + "</td>";
                    retval += "<td width='70%'>" + exam.ExamName + "</td>";
                    retval += "<td width='20%' align='center'>" + examStatusDesc + "</td>";
                    retval += "</tr>";
                    total++;
                }
                catch (Exception ex) { }
            }
            //Assigned Exams
            sql = "SELECT IdUserExam FROM UserExam WHERE Status = " + UserExamStatus.PENDING + " AND IdUser="******"IdUserExam", sql, false));
            foreach (string idUserExam in idUserExamList)
            {
                try
                {
                    UserExam userExam = new UserExam(Convert.ToInt32(idUserExam));
                    Exam exam = new Exam(userExam.IdExam);
                    className = Common.SwitchClass(className);
                    int examStatus = Common.GetBDNum("Status", "SELECT Status FROM UserExam WHERE IdUserExam=" + idUserExam);
                    string examStatusDesc = "";
                    if (examStatus == UserExamStatus.PENDING)
                    {
                        examStatusDesc = Text.Exam_Pending;
                    }
                    else if (examStatus == UserExamStatus.INCOMPLETE)
                    {
                        examStatusDesc = Text.Exam_Incomplete;
                    }
                    else
                    {
                        examStatusDesc = Text.Exam_Complete;
                    }
                    retval += "<tr class='" + className + "' onClick='exam(" + userExam.IdExam + ", " + userExam.IdUserExam + ");'>";
                    retval += "<td width='10%' align='center'>" + (total + 1) + "</td>";
                    retval += "<td width='70%'>" + exam.ExamName + "</td>";
                    retval += "<td width='20%' align='center'>" + examStatusDesc + "</td>";
                    retval += "</tr>";
                    total++;
                }
                catch (Exception ex) { }
            }
            if (total == 0)
            {
                retval += "<tr><td colspan='3' width='100%' class='alert'>" + Text.NoPendingExams + "</td></tr>";
            }

            retval += "</table>";
            return retval;
        }
Beispiel #7
0
 /// <summary>
 /// Starts the exam for the given IdUser.
 /// </summary>
 /// <param name="idUser">The given IdUser.</param>
 /// <param name="idExam">The given IdExam.</param>
 /// <param name="ignorePrevious">Ignores previous exams and builds new ones.</param>
 /// <returns>The IdUserExam for the current IdUser/IdExam combination.</returns>
 public static int ExamStart(int idUser, int idExam, bool ignorePrevious)
 {
     int idUserExam = Common.GetBDNum("IdUserExam", "SELECT MAX(IdUserExam) AS IdUserExam FROM UserExam WHERE IdUser = "******" AND IdExam = " + idExam);
     UserExam userExam;
     if((idUserExam != 0) && !ignorePrevious)
     {
         userExam = new UserExam(idUserExam);
     }
     else
     {
         userExam = new UserExam();
         userExam.IdUser = idUser;
         userExam.IdExam = idExam;
         userExam.Create();
     }
     return userExam.IdUserExam;
 }