Esempio n. 1
0
        private void ShowReport()
        {
            //2. Add criteria to the report viewer
            Hashtable parameters = this.rvReport.Parameters;

            string[] selectUnits;
            selectUnits = trvUnitPath.GetSelectedValues();
            //Double check
            BusinessServices.Unit objUnit = new  BusinessServices.Unit();
            selectUnits = objUnit.ReturnAdministrableUnitsByUserID(UserContext.UserID, UserContext.UserData.OrgID, selectUnits);
            string strParentUnits = String.Join(",", selectUnits);

            parameters["unitIDs"]           = strParentUnits;
            parameters["organisationID"]    = UserContext.UserData.OrgID;
            parameters["adminUserID"]       = UserContext.UserID;
            parameters["langCode"]          = Request.Cookies["currentCulture"].Value;
            parameters["langInterfaceName"] = "Report.CPDReport";
            parameters["profileid"]         = this.cboProfile.SelectedValue == ""?"-1":this.cboProfile.SelectedValue;
            parameters["profileperiodid"]   = this.cboPeriod.SelectedValue == ""?"-1":this.cboPeriod.SelectedValue;
            parameters["UserFirstName"]     = this.txtFirstName.Text;
            parameters["UserLastName"]      = this.txtLastName.Text;
            parameters["userName"]          = this.txtUserName.Text;
            parameters["shortfallusers"]    = this.chbShortFallUsers.Checked?1:0;
            // report title for the CPD Report
            int intOrganisationID = UserContext.UserData.OrgID;

            BusinessServices.Profile objProfile = new BusinessServices.Profile();
            parameters["rptReportTitle"] = objProfile.getCPDReportTitle(intOrganisationID);
        }
Esempio n. 2
0
        private void ApplyProfilePoints(int ProfileID)
        {
            BusinessServices.Profile objProfile = new BusinessServices.Profile();
            bool ApplyToQuiz   = objProfile.QuizRequiredForPoints(ProfileID);
            bool ApplyToLesson = objProfile.LessonRequiredForPoints(ProfileID);

            int ModuleID = Int32.Parse(Request.QueryString["ModuleID"].ToString());
            int UserID   = Int32.Parse(Request.QueryString["UserID"].ToString());

            // If both Quiz and Lesson need to be completed to gain points
            if (ApplyToQuiz && ApplyToLesson)
            {
                //Check if quiz has been completed
                //if it has and if lesson completed then apply points to user
                if ((objProfile.CheckQuizComplete(UserID, ProfileID, ModuleID)) && (objProfile.CheckLessonComplete(UserID, ProfileID, ModuleID)))
                {
                    if (!(objProfile.CheckLessonPointsAlreadyGivenForPeriod(ProfileID, UserID, ModuleID, 2)) || !(objProfile.CheckQuizPointsAlreadyGivenForPeriod(ProfileID, UserID, ModuleID, 2)))
                    {
                        objProfile.ApplyCPDPoints(ProfileID, UserID, ModuleID, 2);
                    }
                }
            }
            else                   // then either quiz only or lesson only
            {
                if (ApplyToLesson) // lesson only
                {
                    // if lesson completed then apply points to user
                    if (!(objProfile.CheckLessonPointsAlreadyGivenForPeriod(ProfileID, UserID, ModuleID, 0)))
                    {
                        objProfile.ApplyCPDPoints(ProfileID, UserID, ModuleID, 0);
                    }
                }
                // not worried about quiz in this scenario as have just completed lesson
            }
        }
Esempio n. 3
0
        private void ApplyProfilePoints(int ProfileID, int QuizStatus, int ModuleID, int UserID)
        {
            BusinessServices.Profile objProfile = new BusinessServices.Profile();
            bool ApplyToQuiz   = objProfile.QuizRequiredForPoints(ProfileID);
            bool ApplyToLesson = objProfile.LessonRequiredForPoints(ProfileID);

            // If both Quiz and Lesson need to be completed to gain points
            if (ApplyToQuiz && ApplyToLesson)
            {
                //Check if Lesson has been completed
                if ((objProfile.CheckQuizComplete(UserID, ProfileID, ModuleID)) && (objProfile.CheckLessonComplete(UserID, ProfileID, ModuleID)))
                {
                    if (!(objProfile.CheckLessonPointsAlreadyGivenForPeriod(ProfileID, UserID, ModuleID, 2)) || !(objProfile.CheckQuizPointsAlreadyGivenForPeriod(ProfileID, UserID, ModuleID, 2)))
                    {
                        objProfile.ApplyCPDPoints(ProfileID, UserID, ModuleID, 2);
                    }
                }
            }
            else                 // then either quiz only or lesson only
            {
                if (ApplyToQuiz) // quiz only
                {
                    // if quiz passed then apply points to user
//					if(QuizStatus == 2)
//					{
                    if (!(objProfile.CheckQuizPointsAlreadyGivenForPeriod(ProfileID, UserID, ModuleID, 1)))
                    {
                        objProfile.ApplyCPDPoints(ProfileID, UserID, ModuleID, 1);
                    }
//					}
                }
                // not worried about lesson in this scenario as have just completed quiz
            }
        }
Esempio n. 4
0
        private void dgrCPD_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView drv       = (DataRowView)e.Item.DataItem;
                int         profileID = (int)drv["ProfileID"];

                BusinessServices.Profile objProfile = new BusinessServices.Profile();
                DataTable dtProfile = objProfile.GetProfile(profileID, -1, UserContext.UserData.OrgID);

                if (dtProfile.Rows.Count > 0)
                {
                    if (Gprofileid != profileID)
                    {
                        Gprofileid       = profileID;
                        Gprofilerowcount = 0;
                    }
                    else
                    {
                        Gprofilerowcount++;
                    }
                    if (!dtProfile.Rows[Gprofilerowcount]["DateStart"].Equals(System.DBNull.Value))
                    {
                        DateTime dtStart = (DateTime)dtProfile.Rows[Gprofilerowcount]["DateStart"];
                        if (dtStart < DateTime.Now)                         //Current Period
                        {
                            Label lblCurrentDate = (Label)e.Item.FindControl("lblCurrentDate");
                            lblCurrentDate.Text =
                                string.Format("{0:dd/MM/yyyy}", (DateTime)dtProfile.Rows[Gprofilerowcount]["DateStart"])
                                + " - " +
                                string.Format("{0:dd/MM/yyyy}", (DateTime)dtProfile.Rows[Gprofilerowcount]["DateEnd"]);

                            Label lblFutureDate = (Label)e.Item.FindControl("lblFutureDate");
                            if (!dtProfile.Rows[Gprofilerowcount]["FutureDateStart"].Equals(System.DBNull.Value))
                            {
                                lblFutureDate.Text =
                                    string.Format("{0:dd/MM/yyyy}", (DateTime)dtProfile.Rows[Gprofilerowcount]["FutureDateStart"])
                                    + " - " +
                                    string.Format("{0:dd/MM/yyyy}", (DateTime)dtProfile.Rows[Gprofilerowcount]["FutureDateEnd"]);
                            }
                        }
                        else                         //Future Period
                        {
                            Label lblFutureDate = (Label)e.Item.FindControl("lblFutureDate");
                            lblFutureDate.Text =
                                string.Format("{0:dd/MM/yyyy}", (DateTime)dtProfile.Rows[Gprofilerowcount]["DateStart"])
                                + " - " +
                                string.Format("{0:dd/MM/yyyy}", (DateTime)dtProfile.Rows[Gprofilerowcount]["DateEnd"]);
                        }
                    }
                }
            }
        }
Esempio n. 5
0
//		private void SaveCPD(string ProfileNameValue, int OrganisationID)
//		{
//			// Save the CPD Profile
//			BusinessServices.Profile objProfile = new BusinessServices.Profile();
//			objProfile.AddProfile(ProfileNameValue, OrganisationID);
//		}

        private bool PolicyNameExists(string ProfileNameValue, int OrganisationID)
        {
            bool NameExists = false;

            BusinessServices.Profile objProfile = new BusinessServices.Profile();
            DataTable dtCheckPolicyName         = objProfile.CheckProfileName(ProfileNameValue, OrganisationID);

            if (dtCheckPolicyName.Rows.Count > 0)
            {
                NameExists = true;
            }
            return(NameExists);
        }
Esempio n. 6
0
        /// <summary>
        /// Lesson End event
        /// </summary>
        /// <remarks>
        /// A user can exit a lesson at any point by clicking on the Exit button.  Alternatively, when they reach the end of a lesson they will be presented with a screen indicating they have completed the lesson for the current module and provide a link to exit the lesson.  Any of these 2 actions will trigger the Lesson_OnExit event.
        /// The event will call the Toolbook.EndLessonSession method by passing the following parameters:
        ///		.Bookmark: The bookmark is the current page ID.
        ///					If they selected the Exit button on any page other than the last page the book mark parameter will be sent.
        ///					If the user selects to exit on the last page by pressing the exit button in the toolbar a bookmark parameter should not be sent to the SALT LMS as part of the event.
        ///		.Duration: The system needs to keep track of the duration of a lesson. The duration, in seconds as an integer needs to be supplied as part of the EndLessonSession method of objToolBook.
        /// </remarks>
        private void Lesson_End()
        {
            if (!PageContext.Current.IsPreviewMode)
            {
                try
                {
                    string bookmark;
                    if (!PageContext.Current.IsLastPage)
                    {
                        bookmark = PageContext.Current.PageID;
                    }
                    else
                    {
                        bookmark = null;
                    }

                    TimeSpan objTimeSpan = DateTime.Now.Subtract(PageContext.Current.StartTime);

                    BusinessServices.Toolbook objToolbook = new BusinessServices.Toolbook();
                    objToolbook.EndLessonSession(PageContext.Current.SessionID, objTimeSpan.Seconds, bookmark);

                    //obtain profileIDs for all profiles that have access to module and apply points
                    BusinessServices.Profile objProfile = new BusinessServices.Profile();
                    int       ModuleID     = Int32.Parse(Request.QueryString["ModuleID"].ToString());
                    int       UserID       = Int32.Parse(Request.QueryString["UserID"].ToString());
                    int       intCourseID  = Int32.Parse(Request.QueryString["CourseID"].ToString());
                    int       intProfileID = Int32.Parse(Request.QueryString["ProfileID"].ToString());
                    DataTable dtProfiles   = objProfile.ProfilesWithModuleAccess(UserID, ModuleID);
                    foreach (DataRow dr in dtProfiles.Rows)
                    {
                        int ProfileID = int.Parse(dr["ProfileID"].ToString());
                        ApplyProfilePoints(ProfileID);
                    }
                    Response.Redirect("/MyTraining.aspx");
                }
                catch (Exception ex)
                {
                    if (ex.Message.ToLower().StartsWith("violation of primary key"))
                    {
                        Response.Write(ResourceManager.GetString("QuizLesson_Error"));
                        Response.End();
                    }
                    else
                    {
                        throw ex;
                    }
                }
            }
        }
Esempio n. 7
0
		private void LoadProfile()
		{
			LoadUnitTree();
			int intOrganisationID = UserContext.UserData.OrgID; // organisation ID
			BusinessServices.Profile objProfile = new BusinessServices.Profile(); //Profile Object
			DataTable dtbProfile = objProfile.GetProfilesForCurrentOrg(intOrganisationID); // List of profiles accesable to the organisation
			if (dtbProfile.Rows.Count==0)
			{
				this.plhSearchCriteria.Visible=false;
				this.lblError.Text=ResourceManager.GetString("lblError.NoProfile");//"No profiles exist within this organisation.";
				this.lblError.CssClass = "FeedbackMessage";
				this.lblError.Visible=true;
				return;
			}
			cboProfile.DataSource = dtbProfile;
			cboProfile.DataValueField = "ProfileID";
			cboProfile.DataTextField = "ProfileName";
			cboProfile.DataBind();			
		}
Esempio n. 8
0
        private void LoadPeriod()
        {
            string strProfileid = cboProfile.SelectedValue.ToString();
            int    intProfileID;

            if (strProfileid == "")          // not blank selection
            {
                cboPeriod.Items.Clear();
            }
            else
            {
                intProfileID = Int32.Parse(strProfileid);
                BusinessServices.Profile objProfile = new BusinessServices.Profile();                //Profile Object
                DataTable dtbPeriod = objProfile.GetPeriodsForProfile(intProfileID);                 // List of periods for the selected profile
                cboPeriod.DataSource     = dtbPeriod;
                cboPeriod.DataValueField = "ProfilePeriodID";
                cboPeriod.DataTextField  = "PeriodName";
                cboPeriod.DataBind();
            }
        }
        }         // SaveData

        #endregion

        private void UpdateProfilePoints()
        {
            // Initialise parameters to be passed
            string ProfilePointsType;

            ProfilePointsType = "M";
            double Points = 0.0;
            int    Active = 1;

            BusinessServices.Organisation objOrganisation = new BusinessServices.Organisation();
            DataTable dtCourses = objOrganisation.GetCourseAccessList(UserContext.UserData.OrgID);

            foreach (DataRow drCourse in dtCourses.Rows)
            {
                int intCourseID = int.Parse(drCourse["CourseID"].ToString());
                BusinessServices.Module objModule = new BusinessServices.Module();
                DataTable dtModules = objModule.GetModuleListByCourse(intCourseID, UserContext.UserData.OrgID);
                foreach (DataRow drModule in dtModules.Rows)
                {
                    int intModuleID = int.Parse(drModule["ModuleID"].ToString());
                    BusinessServices.Profile objProfile = new BusinessServices.Profile();
                    DataTable dtProfiles = objProfile.GetProfilesForCurrentOrg(UserContext.UserData.OrgID);
                    foreach (DataRow drProfile in dtProfiles.Rows)
                    {
                        int intProfileID       = int.Parse(drProfile["ProfileID"].ToString());
                        int intProfilePeriodID = objProfile.GetProfilePeriodID(intProfileID);

                        // Check if record already exists in tblProfilePoints - if not then add record
                        if (!objProfile.CheckProfilePointsExist(intProfilePeriodID, intModuleID) && intProfilePeriodID != -1)
                        {
                            objProfile.AddProfilePoints(ProfilePointsType, intModuleID, intProfilePeriodID, Points, Active, UserContext.UserData.OrgID);
                        }
                    }
                }
            }
        }
Esempio n. 10
0
        public string writeDMEs(int StudentID, int ModuleID, string strSessID1, DataSet xmlDS, string sessiondata, int ProfileId)
        {
            try
            {
                Boolean isLesson     = false;
                Boolean completed    = false;
                int     score        = 0;
                int     interactions = 0;
                string  strResult    = "";
                int     currentpage  = 0;
                int     Totalpage    = 0;

                Hashtable ht = new Hashtable();

                foreach (DataRow r in xmlDS.Tables["dme"].Rows)
                {
                    // get the salt variables here...
                    if (r["name"].ToString().ToLower().Contains("salt.variables.var"))
                    {
                        ht.Add(r["name"].ToString().ToLower(), r["value"].ToString());
                    }


                    if (r["name"].ToString().ToLower().Equals("salt.lessonorquiz"))
                    {
                        try
                        {
                            isLesson = (r["value"].ToString().ToLower() == "lesson");
                        }
                        catch
                        {
                            isLesson = true;
                        }
                    }

                    if (r["name"].ToString().Equals("cmi.core.lesson_status"))
                    {
                        if (r["value"].ToString().Equals("completed") || r["value"].ToString().Equals("passed"))
                        {
                            completed = true;
                            if (completed)
                            {
                                //break;
                            }
                        }
                    }

                    ////if (r["name"].ToString().Equals("cmi.core.lesson_status"))
                    ////{
                    ////    completed = r["value"].ToString().Equals("passed");
                    ////    if (completed)
                    ////    {
                    ////        //break;
                    ////    }
                    ////}Adaptive
                    //if (r["name"].ToString().Equals("salt.variables.VarPageInChapter"))
                    //{
                    //    currentpage = int.Parse(r["value"].ToString());

                    //}
                    //if (r["name"].ToString().Equals("cmi.suspend_data"))
                    //{
                    //    string phrase = r["value"].ToString();
                    //    string[] strTallyVisited = phrase.Split(';');
                    //    currentpage = Convert.ToInt32(strTallyVisited[0].Split('=')[1].ToString().Trim());


                    //}
                    //if (r["name"].ToString().Equals("salt.variables.VarPagesInChapter"))
                    //{
                    //    Totalpage = int.Parse(r["value"].ToString());
                    //    //if (Totalpage - 1 == currentpage && Totalpage != 0)
                    //    //{
                    //    //    completed = true;
                    //    //    if (completed)
                    //    //    {
                    //    //        //break;
                    //    //    }
                    //    //}
                    //}
                    //if (r["name"].ToString().Equals("salt.variables.VarRunningPageCount"))
                    //{
                    //    string phrase = r["value"].ToString();
                    //    string[] strTallyVisited = phrase.Split(' ');
                    //    currentpage = Convert.ToInt32(strTallyVisited[1].ToString().Trim());
                    //    Totalpage = Convert.ToInt32(strTallyVisited[3].ToString().Trim());
                    //    if (Totalpage - 1 == currentpage && Totalpage != 0)
                    //    {
                    //        completed = true;
                    //        if (completed)
                    //        {
                    //            //break;
                    //        }
                    //    }
                    //}

                    //if (Totalpage != 0 || currentpage != 0)
                    //{

                    //    if (Totalpage == currentpage)
                    //    {
                    //        completed = true;
                    //        if (completed)
                    //        {
                    //            //break;
                    //        }
                    //    }
                    //}


                    if (r["name"].ToString().Equals("cmi.core.score.raw"))
                    {
                        try
                        {
                            score = int.Parse(r["value"].ToString());
                        }
                        catch
                        {
                            score = 0;
                        }
                    }

                    if (r["name"].ToString().Equals("cmi.core.lesson_score"))
                    {
                        try
                        {
                            score = int.Parse(r["value"].ToString());
                        }
                        catch
                        {
                            score = 0;
                        }
                    }


                    if (r["name"].ToString().Equals("cmi.interactions._count"))
                    {
                        try
                        {
                            interactions = int.Parse(r["value"].ToString());
                            r["value"]   = "0";
                        }
                        catch
                        {
                            // do nothing
                        }
                    }

                    if (r["value"].ToString() != "")
                    {
                        strResult = WriteDMEvalue(StudentID, ModuleID, r["name"].ToString(), r["value"].ToString());
                    }
                }

                if (!isLesson) // train tblQuizQuestion and tblQuizAnswer
                {
                    int      intAskedQuestion     = 1;
                    int      intWeighting         = 1;
                    String   strLatency           = "";
                    String   strTime              = "";
                    String   strText              = "";
                    String   strType              = "";
                    String   strID                = "";
                    Boolean  isCorrect            = false;
                    String   strCorrectResponse   = "";
                    String   strStudentResponse   = "";
                    int      intNextAskedQuestion = 0;
                    String[] strPosAskedQuestion;

                    BusinessServices.Toolbook objToolbook = new Toolbook();
                    DataTable endQuizInfo = objToolbook.BeforeQuizEnd2(StudentID, ModuleID, 46664, score);

                    DataRow tmpRow    = endQuizInfo.Rows[0];
                    String  SessionID = tmpRow["SessionID"].ToString();


                    foreach (DataRow r in xmlDS.Tables["dme"].Rows)
                    {
                        if (r["name"].ToString().Length > 16)
                        {
                            if (r["name"].ToString().Substring(0, 16).Equals("cmi.interactions"))
                            {
                                strPosAskedQuestion = r["name"].ToString().Split('.');
                                try
                                {
                                    intNextAskedQuestion = int.Parse(strPosAskedQuestion[2]);
                                }
                                catch
                                {
                                }
                                if (intNextAskedQuestion != intAskedQuestion && strText != "")
                                {
                                    saveQuestion(StudentID, intAskedQuestion, intWeighting, strLatency, strTime, strText, strID, isCorrect, strCorrectResponse, strStudentResponse, strType, ModuleID, SessionID);

                                    intAskedQuestion   = intNextAskedQuestion;
                                    intWeighting       = 1;
                                    strLatency         = "";
                                    strTime            = "";
                                    strText            = "";
                                    strID              = "";
                                    isCorrect          = false;
                                    strCorrectResponse = "";
                                    strStudentResponse = "";
                                    strType            = "";
                                }
                                try
                                {
                                    if (strPosAskedQuestion[3].Equals("id"))
                                    {
                                        try { strID = r["value"].ToString(); }
                                        catch { }
                                    }
                                    ;
                                    if (strPosAskedQuestion[3].Equals("latency"))
                                    {
                                        strLatency = r["value"].ToString();
                                    }
                                    if (strPosAskedQuestion[3].Equals("question"))
                                    {
                                        strText = r["value"].ToString().Replace("\\r", "");
                                        foreach (DictionaryEntry entry in ht)
                                        {
                                            if (entry.Value.ToString().Equals(strText))
                                            {
                                                String[] arr = entry.Key.ToString().Split('_');
                                                strStudentResponse = ht["salt.variables.varquestion_" + arr[1]].ToString();
                                                strCorrectResponse = ht["salt.variables.varvarcorrectanswertext_" + arr[1]].ToString();
                                                break;
                                            }
                                        }
                                    }

                                    if (strPosAskedQuestion[3].Equals("result"))
                                    {
                                        try { isCorrect = r["value"].ToString().ToLower().Equals("correct"); }
                                        catch { }
                                    }
                                    ;
                                    if (strPosAskedQuestion[3].Equals("time"))
                                    {
                                        strTime = r["value"].ToString();
                                    }
                                    if (strPosAskedQuestion[3].Equals("type"))
                                    {
                                        strType = r["value"].ToString();
                                    }
                                    if (strPosAskedQuestion[3].Equals("weighting"))
                                    {
                                        try { intWeighting = int.Parse(r["value"].ToString()); }
                                        catch { }
                                    }
                                    ;
                                }
                                catch { };
                            }
                        }
                    }
                    if (!intAskedQuestion.Equals(1))
                    {
                        saveQuestion(StudentID, intAskedQuestion, intWeighting, strLatency, strTime, strText, strID, isCorrect, strCorrectResponse, strStudentResponse, strType, ModuleID, SessionID);
                        intAskedQuestion = 1;
                    }



                    if (!isLesson && interactions > 0)
                    {
                        int      intUserID;
                        int      intQuizID;
                        int      intPassMark;
                        int      intUnitID;
                        int      intModuleID;
                        int      intQuizFrequency;
                        int      intOldCourseStatus;
                        int      intNewCourseStatus;
                        int      intNewQuizStatus;
                        int      intCourseID;
                        DateTime dtmQuizCompletionDate;
                        intUserID = Int32.Parse(tmpRow["UserID"].ToString());
                        try
                        {
                            intQuizID = Int32.Parse(tmpRow["QuizID"].ToString());
                        }
                        catch { intQuizID = 0; }
                        intPassMark      = Int32.Parse(tmpRow["PassMark"].ToString());
                        intUnitID        = Int32.Parse(tmpRow["UnitID"].ToString());
                        intModuleID      = Int32.Parse(tmpRow["ModuleID"].ToString());
                        intQuizFrequency = tmpRow["QuizFrequency"] == null?Int32.Parse(tmpRow["QuizFrequency"].ToString()) : 0;

                        intOldCourseStatus    = Int32.Parse(tmpRow["OldCourseStatus"].ToString());
                        intNewCourseStatus    = Int32.Parse(tmpRow["NewCourseStatus"].ToString());
                        intNewQuizStatus      = Int32.Parse(tmpRow["NewQuizStatus"].ToString());
                        intCourseID           = Int32.Parse(tmpRow["CourseID"].ToString());
                        dtmQuizCompletionDate = (tmpRow["QuizCompletionDate"] == System.DBNull.Value ? DateTime.Parse("1/1/1900") : (DateTime)tmpRow["QuizCompletionDate"]);

                        endQuizInfo = objToolbook.EndQuizSession_UpdateTables(SessionID, 46664, score, intUserID, intQuizID, intPassMark, intUnitID, ModuleID, intCourseID, intOldCourseStatus, intNewQuizStatus, intNewCourseStatus, intQuizFrequency, dtmQuizCompletionDate);

                        // read cert flag
                        tmpRow = endQuizInfo.Rows[0];
                        Boolean blnSendCert = (bool)tmpRow["sendcert"];

                        if (blnSendCert)
                        {
                            DefaultQuiz dq = new DefaultQuiz();
                            dq.certemail(intUserID, intCourseID, 0);
                        }
                    }

                    //code for adaptive
                    else
                    {
                        if (endQuizInfo.Rows[0]["toolbooklocation"].ToString().Trim().Contains("launchpage.html"))
                        {
                            if (!isLesson && sessiondata == SessionID && score == 100)
                            {
                                int      intUserIDAdapt;
                                int      intQuizIDAdapt;
                                int      intPassMarkAdapt;
                                int      intUnitIDAdapt;
                                int      intModuleIDAdapt;
                                int      intQuizFrequencyAdapt;
                                int      intOldCourseStatusAdapt;
                                int      intNewCourseStatusAdapt;
                                int      intNewQuizStatusAdapt;
                                int      intCourseIDAdapt;
                                DateTime dtmQuizCompletionDateAdapt;
                                intUserIDAdapt = Int32.Parse(tmpRow["UserID"].ToString());
                                try
                                {
                                    intQuizIDAdapt = Int32.Parse(tmpRow["QuizID"].ToString());
                                }
                                catch { intQuizIDAdapt = 0; }


                                intPassMarkAdapt           = Int32.Parse(tmpRow["PassMark"].ToString());
                                intUnitIDAdapt             = Int32.Parse(tmpRow["UnitID"].ToString());
                                intModuleIDAdapt           = Int32.Parse(tmpRow["ModuleID"].ToString());
                                intQuizFrequencyAdapt      = tmpRow["adaptivequizfreq"] == null ? 0 : Int32.Parse(tmpRow["adaptivequizfreq"].ToString());
                                intOldCourseStatusAdapt    = Int32.Parse(tmpRow["OldCourseStatus"].ToString());
                                intNewCourseStatusAdapt    = Int32.Parse(tmpRow["NewCourseStatus"].ToString());
                                intNewQuizStatusAdapt      = Int32.Parse(tmpRow["NewQuizStatus"].ToString());
                                intCourseIDAdapt           = Int32.Parse(tmpRow["CourseID"].ToString());
                                dtmQuizCompletionDateAdapt = (tmpRow["QuizCompletionDate"] == System.DBNull.Value ? DateTime.Parse("1/1/1900") : (DateTime)tmpRow["QuizCompletionDate"]);
                                if (score == 100)
                                {
                                    endQuizInfo = objToolbook.EndQuizSession_UpdateTables(SessionID, 46664, score, intUserIDAdapt, intQuizIDAdapt, intPassMarkAdapt, intUnitIDAdapt, ModuleID, intCourseIDAdapt, intOldCourseStatusAdapt, intNewQuizStatusAdapt, intNewCourseStatusAdapt, intQuizFrequencyAdapt, dtmQuizCompletionDateAdapt);


                                    if (ProfileId > -1)
                                    {
                                        BusinessServices.Profile objProfile = new BusinessServices.Profile();
                                        bool ApplyToQuiz = objProfile.QuizRequiredForPoints(ProfileId);
                                        if (ApplyToQuiz) // quiz only
                                        {
                                            if (!(objProfile.CheckQuizPointsAlreadyGivenForPeriod(ProfileId, intUserIDAdapt, ModuleID, 1)))
                                            {
                                                objProfile.ApplyCPDPoints(ProfileId, intUserIDAdapt, ModuleID, 1);
                                            }
                                        }
                                    }
                                }
                                // read cert flag
                                tmpRow = endQuizInfo.Rows[0];
                                Boolean blnSendCert = (bool)tmpRow["sendcert"];

                                if (blnSendCert)
                                {
                                    DefaultQuiz dq = new DefaultQuiz();
                                    dq.certemail(intUserIDAdapt, intCourseIDAdapt, 0);
                                }
                            }
                            else if (!isLesson && sessiondata == SessionID && (score > 0 && score < 100))
                            {
                                int      intUserIDAdapt;
                                int      intQuizIDAdapt;
                                int      intPassMarkAdapt;
                                int      intUnitIDAdapt;
                                int      intModuleIDAdapt;
                                int      intQuizFrequencyAdapt;
                                int      intOldCourseStatusAdapt;
                                int      intNewCourseStatusAdapt;
                                int      intNewQuizStatusAdapt;
                                int      intCourseIDAdapt;
                                DateTime dtmQuizCompletionDateAdapt;
                                intUserIDAdapt = Int32.Parse(tmpRow["UserID"].ToString());
                                try
                                {
                                    intQuizIDAdapt = Int32.Parse(tmpRow["QuizID"].ToString());
                                }
                                catch { intQuizIDAdapt = 0; }


                                intPassMarkAdapt           = Int32.Parse(tmpRow["PassMark"].ToString());
                                intUnitIDAdapt             = Int32.Parse(tmpRow["UnitID"].ToString());
                                intModuleIDAdapt           = Int32.Parse(tmpRow["ModuleID"].ToString());
                                intQuizFrequencyAdapt      = tmpRow["adaptivequizfreq"] == null ? 0 : Int32.Parse(tmpRow["adaptivequizfreq"].ToString());
                                intOldCourseStatusAdapt    = Int32.Parse(tmpRow["OldCourseStatus"].ToString());
                                intNewCourseStatusAdapt    = Int32.Parse(tmpRow["NewCourseStatus"].ToString());
                                intNewQuizStatusAdapt      = Int32.Parse(tmpRow["NewQuizStatus"].ToString());
                                intCourseIDAdapt           = Int32.Parse(tmpRow["CourseID"].ToString());
                                dtmQuizCompletionDateAdapt = (tmpRow["QuizCompletionDate"] == System.DBNull.Value ? DateTime.Parse("1/1/1900") : (DateTime)tmpRow["QuizCompletionDate"]);
                                if (score == 100)
                                {
                                    endQuizInfo = objToolbook.EndQuizSession_UpdateTables(SessionID, 46664, score, intUserIDAdapt, intQuizIDAdapt, intPassMarkAdapt, intUnitIDAdapt, ModuleID, intCourseIDAdapt, intOldCourseStatusAdapt, intNewQuizStatusAdapt, intNewCourseStatusAdapt, intQuizFrequencyAdapt, dtmQuizCompletionDateAdapt);


                                    if (ProfileId > -1)
                                    {
                                        BusinessServices.Profile objProfile = new BusinessServices.Profile();
                                        bool ApplyToQuiz = objProfile.QuizRequiredForPoints(ProfileId);
                                        if (ApplyToQuiz) // quiz only
                                        {
                                            if (!(objProfile.CheckQuizPointsAlreadyGivenForPeriod(ProfileId, intUserIDAdapt, ModuleID, 1)))
                                            {
                                                objProfile.ApplyCPDPoints(ProfileId, intUserIDAdapt, ModuleID, 1);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    //end code

                    delDME(StudentID, ModuleID);
                }

                if (completed && isLesson)
                {
                    delDME(StudentID, ModuleID);
                    Module.InsertLessonStatus(StudentID, ModuleID, LessonStatus.Completed);
                }

                return("");
            }
            catch (Exception exc)
            {
                // do some thign here
                Debug.WriteLine(exc.StackTrace);
                return("");
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Quiz End event
        /// </summary>
        /// <remarks>
        /// This event fires when a student clicks the “Submit answers” button on the last page. The event will
        ///		.Score: Calculate the score (Question number with correct answer/Total question number * 100)
        ///		.Duration: Calculate the duration of the testing.
        ///		.QuizQuestionAudit: Record quiz question audit.
        ///		.QuizAnswerAudit: Record quiz answer audit
        /// </remarks>
        public void Quiz_End()
        {
            //certemail(956, 42, 0);
            if (!PageContext.Current.IsPreviewMode)
            {
                try
                {
                    BusinessServices.Toolbook objToolbook = new BusinessServices.Toolbook();
                    NameValueCollection       nvcAnswers  = CurrentQuizContext.Answers;
                    DataTable endQuizInfo;
                    int       intUserID;
                    int       intQuizID;
                    int       intPassMark;
                    int       intUnitID;
                    int       intModuleID;
                    int       intQuizFrequency;
                    int       intOldCourseStatus;
                    int       intNewCourseStatus;
                    int       intNewQuizStatus;
                    int       intCourseID;
                    DateTime  dtmQuizCompletionDate;

                    foreach (string strKey in nvcAnswers.AllKeys)
                    {
                        objToolbook.CreateQuizQuestionAudit(PageContext.Current.SessionID, strKey);
                        objToolbook.CreateQuizAnswerAudit(PageContext.Current.SessionID, strKey, Convert.ToInt32(nvcAnswers[strKey]));
                    }

                    int      intScore    = objToolbook.GetQuizScore(PageContext.Current.SessionID);
                    TimeSpan objTimeSpan = DateTime.Now.Subtract(PageContext.Current.StartTime);

                    //objToolbook.EndQuizSession(PageContext.Current.SessionID,objTimeSpan.Seconds,intScore);

                    endQuizInfo = objToolbook.BeforeQuizEnd(PageContext.Current.SessionID, objTimeSpan.Seconds, intScore);

                    DataRow tmpRow = endQuizInfo.Rows[0];
                    intUserID        = Int32.Parse(tmpRow["UserID"].ToString());
                    intQuizID        = Int32.Parse(tmpRow["QuizID"].ToString());
                    intPassMark      = Int32.Parse(tmpRow["PassMark"].ToString());
                    intUnitID        = Int32.Parse(tmpRow["UnitID"].ToString());
                    intModuleID      = Int32.Parse(tmpRow["ModuleID"].ToString());
                    intQuizFrequency = tmpRow["QuizFrequency"] == null?Int32.Parse(tmpRow["QuizFrequency"].ToString()) : 0;

                    intOldCourseStatus = Int32.Parse(tmpRow["OldCourseStatus"].ToString());
                    intNewCourseStatus = Int32.Parse(tmpRow["NewCourseStatus"].ToString());
                    intNewQuizStatus   = Int32.Parse(tmpRow["NewQuizStatus"].ToString());
                    intCourseID        = Int32.Parse(tmpRow["CourseID"].ToString());
                    int intProfileID = Int32.Parse(Request.QueryString["ProfileID"].ToString());
                    dtmQuizCompletionDate = (tmpRow["QuizCompletionDate"] == System.DBNull.Value ? DateTime.Parse("1/1/1900"): (DateTime)tmpRow["QuizCompletionDate"]);

                    endQuizInfo = objToolbook.EndQuizSession_UpdateTables(PageContext.Current.SessionID, objTimeSpan.Seconds, intScore, intUserID, intQuizID, intPassMark, intUnitID, intModuleID, intCourseID, intOldCourseStatus, intNewQuizStatus, intNewCourseStatus, intQuizFrequency, dtmQuizCompletionDate);
                    tmpRow      = endQuizInfo.Rows[0];
                    Boolean blnSendCert = (bool)tmpRow["sendcert"];
                    if (blnSendCert)
                    {
                        certemail(intUserID, intCourseID, intProfileID);
                    }


                    //obtain profileIDs for all profiles that have access to module and apply points
                    BusinessServices.Profile objProfile = new BusinessServices.Profile();
                    DataTable dtProfiles = objProfile.ProfilesWithModuleAccess(intUserID, intModuleID);
                    foreach (DataRow dr in dtProfiles.Rows)
                    {
                        int ProfileID = int.Parse(dr["ProfileID"].ToString());
                        ApplyProfilePoints(ProfileID, intNewQuizStatus, intModuleID, intUserID);
                    }
                    Session["CourseID"]           = intCourseID.ToString();
                    Session["CourseID_ProfileID"] = "CourseID=" + intCourseID.ToString() + "&ProfileID=" + intProfileID.ToString();
                }
                catch (Exception ex)
                {
                    if (ex.Message.ToLower().StartsWith("violation of primary key"))
                    {
                        Response.Write(ResourceManager.GetString("QuizLesson_Error"));
                        Response.End();
                    }
                    else
                    {
                        //throw ex;
                        ErrorHandler.ErrorLog el = new ErrorHandler.ErrorLog(ex);
                    }
                }

                Response.Redirect("/Reporting/QuizResult.aspx?QuizSessionID=" + PageContext.Current.SessionID);
            }
        }
Esempio n. 12
0
		private void ShowDataPage(int currentPageIndex)
		{
			try
			{
				BusinessServices.Profile objProfile = new BusinessServices.Profile();
				int intProfileID = Int32.Parse(cboProfile.SelectedValue.ToString());

				string[] selectUnits;
				selectUnits = trvUnitPath.GetSelectedValues();
				//Double check
				BusinessServices.Unit objUnit = new  BusinessServices.Unit();
				selectUnits = objUnit.ReturnAdministrableUnitsByUserID( UserContext.UserID, UserContext.UserData.OrgID, selectUnits);
				string  strParentUnits  = String.Join(",",selectUnits);

				//1. Get data
				DataView  dvwPagination = objProfile.GetCPDEmailData(intProfileID, strParentUnits);
				
				if ( dvwPagination.Table.Rows.Count==0)
				{
					this.lblError.Text += "<BR>" + ResourceManager.GetString("lblError.NoDataFound");
					this.lblError.CssClass = "FeedbackMessage";
					this.plhSearchCriteria.Visible=false;
					this.plhReportResults.Visible=false;
					this.lblError.Visible=true;
				}
				else
				{
					//1.5 record the user ids to send the emails to
					// Only Populate it the first time
					if (ViewState["UserIDsHaveBeenPopulated"]==null)
					{
						foreach (DataRow drwUser in dvwPagination.Table.Rows)
						{
							this.txtUserIDs.Text += drwUser.ItemArray[1].ToString() + ",";
						}
						// remove trailing comma
						if (this.txtUserIDs.Text.Length > 0)
						{
							this.txtUserIDs.Text = this.txtUserIDs.Text.Substring(0,this.txtUserIDs.Text.Length-1);
						}
						ViewState["UserIDsHaveBeenPopulated"]="Yes";
					}

					//2. Sort Data
					string	strOrderByField, strOrderByDirection;
					strOrderByField =(string)ViewState["OrderByField"];
					strOrderByDirection =(string)ViewState["OrderByDirection"];

					dvwPagination.Sort = strOrderByField + " " + strOrderByDirection;

					//3. Set pagination panel
					int intPageSize;
					intPageSize = ApplicationSettings.PageSize ;
					this.SetPaginationPanel(intPageSize, dvwPagination.Count,ref currentPageIndex);

					//4. Bind Data
					grdPagination.DataSource = dvwPagination;
					grdPagination.PageSize = intPageSize;
					grdPagination.CurrentPageIndex = currentPageIndex;
					grdPagination.DataBind();
				} 
			}
			catch(BusinessServiceException ex)
			{
				this.tblPagination.Visible=false;
				this.lblMessage.Text = ex.Message;
				this.lblMessage.CssClass = "WarningMessage";
			}
		}