private void UpdateScore() { strSQL = "select b.APTestID,SectionID,Answers from AP_SavedSection a join AP_SavedTest b on a.APTestID = b.APTestID and PortfolioID=" + PortInfo["PortfolioID"].ToString() + " and SchoolID = " + PortInfo["SchoolID"].ToString() + " and IsActiveStatus = 1 order by a.SectionID"; DataTable dtAnswers = CCLib.Common.DataAccess.GetDataTable(strSQL); if (dtAnswers.Rows.Count > 0) { for (int i = 0; i < dtAnswers.Rows.Count; i++) { strAnswers[i] = dtAnswers.Rows[i]["Answers"].ToString(); } scoTest = new CareerCruisingWeb.CCLib.AbilityProfiler.Score(); scoTest.ScoreTest(strAnswers); strSQL = ""; for (int j = 0; j < 6; j++) { strSQL += "update AP_SavedSection set CorrectAnswers = " + scoTest.CorrectAnswers[j].ToString() + ", ConvertedScore = " + scoTest.ScaledScores[scoTest.SubTestMatchingAbilityNameIndex[j]].ToString() + ", Percentile = " + scoTest.PercentileScores[j].ToString() + " where APTestID=" + dtAnswers.Rows[0]["APTestID"].ToString() + " and SectionID = " + Convert.ToString(j + 1) + "; "; } CCLib.Common.DataAccess.ExecuteNonQuery(strSQL); } }
protected void WizardSection_ConfirmButtonClick(object sender, EventArgs e) { DataTable dtTest = new DataTable(); if (WizardSection.ActiveStep == this.WizardStep3) { strSQL = "select b.APTestID,b.Sectionid from AP_SavedTest a "; strSQL += " join AP_SavedSection b on a.APTestID = b.APTestID "; strSQL += " and PortfolioID = " + strPID + " and SchoolID = " + SchoolID + " and IsActiveStatus = 1 "; dtTest = CCLib.Common.DataAccess.GetDataTable(strSQL); DataRow[] drs = dtTest.Select("SectionID=4"); if (dtTest.Rows.Count == 0) { strSQL = "insert into AP_SavedTest(PortfolioID,SchoolID,GradeNumber) values(" + strPID + "," + SchoolID + "," + dtStudent.Rows[0]["GradeNumber"].ToString() + ")"; int intAPTestID = CCLib.Common.DataAccess.ExecuteDbWithIntResult(strSQL + "; select @@identity;"); strTestID = intAPTestID.ToString(); } else strTestID = dtTest.Rows[0]["APTestID"].ToString(); if (drs.Length == 0) { try { strSQL = "insert into AP_SavedSection(SectionID,APTestID,APRegID,StartTime,EndTime,Answers) values(4," + strTestID + ",0,'" + lblDate3.Text + " 12:00:00 PM','" + DateTime.Now + "','" + ViewState["Result"].ToString() + "')"; CCLib.Common.DataAccess.ExecuteNonQuery(strSQL); } catch (System.Data.SqlClient.SqlException ex)//avoid duplicate records { if (ex.Message.IndexOf("Violation of UNIQUE KEY constraint 'un_section'. ") < 0) throw; } if (dtTest.Rows.Count == 5) { strSQL = "select SectionID,Answers from AP_SavedSection where APTestID=" + strTestID + " order by SectionID"; dtAnswers = CCLib.Common.DataAccess.GetDataTable(strSQL); if (dtAnswers.Rows.Count > 0) { for (int i = 0; i < dtAnswers.Rows.Count; i++) { strAnswers[i] = dtAnswers.Rows[i]["Answers"].ToString(); } scoTest = new CareerCruisingWeb.CCLib.AbilityProfiler.Score(); scoTest.ScoreTest(strAnswers); strSQL = ""; for (int j = 0; j < 6; j++) { strSQL += "update AP_SavedSection set CorrectAnswers = " + scoTest.CorrectAnswers[j].ToString() + ", ConvertedScore = " + scoTest.ScaledScores[scoTest.SubTestMatchingAbilityNameIndex[j]].ToString() + ", Percentile = " + scoTest.PercentileScores[j].ToString() + " where APTestID=" + strTestID + " and SectionID = " + Convert.ToString(j + 1) + "; "; } CCLib.Common.DataAccess.ExecuteNonQuery(strSQL); } DataRow drwPCSCriteria = CareerCruisingWeb.CCLib.PCS.SDPCS.GetPCSCriteria(dtStudent.Rows[0]["GradeNumber"].ToString()); DataRow drwPCSStatus = CareerCruisingWeb.CCLib.PCS.SDPCS.GetPCSStatus(strPID, drwPCSCriteria); CCLib.PCS.SDPCS.UpdatePCSStatusFromSection("AbilityProfiler", strPID, drwPCSCriteria, drwPCSStatus); } strURL = "APSpecialResult.aspx?PP=1&PID=" + strPID; Response.Write("<script language='javascript'>alert('Your changes have been saved.');location.href='" + strURL + "';</script>"); } else Response.Write("<script language='javascript'>alert('There is already an instance of the Ability Profiler associated with your account.');</script>"); } }
protected void getCareerPercentile() { string[] strAnswers = new string[6]; string strSQL = "select b.APTestID,SectionID,Answers,Percentile from AP_SavedSection a join AP_SavedTest b on a.APTestID = b.APTestID and PortfolioID=" + LoginInfo["PID"].ToString() + " and IsActiveStatus = 1 order by a.SectionID"; DataTable dtAnswers = CCLib.Common.DataAccess.GetDataTable(strSQL); if (dtAnswers.Rows.Count >= 6 ) { scoTest = new CareerCruisingWeb.CCLib.AbilityProfiler.Score(); scoTest.IdentifyOccupations(); dtCareer = scoTest.Occupations; DataRow[] dr = dtCareer.Select("OccNumber=" + strOccNumber); if (dr.Length > 0) { dblAR = Convert.ToDouble(dr[0]["ARPercentile"].ToString()); dblCM = Convert.ToDouble(dr[0]["CMPPercentile"].ToString()); dblVA = Convert.ToDouble(dr[0]["Vpercentile"].ToString()); dblSA = Convert.ToDouble(dr[0]["Spercentile"].ToString()); dblCP = Convert.ToDouble(dr[0]["Qpercentile"].ToString()); dblFP = Convert.ToDouble(dr[0]["Ppercentile"].ToString()); blHasAP = true; } //get AP Result Graph dblStuAR = Convert.ToDouble(dtAnswers.Rows[0]["Percentile"].ToString()); dblStuCM = Convert.ToDouble(dtAnswers.Rows[3]["Percentile"].ToString()); dblStuVA = Convert.ToDouble(dtAnswers.Rows[1]["Percentile"].ToString()); dblStuSA = Convert.ToDouble(dtAnswers.Rows[2]["Percentile"].ToString()); dblStuCP = Convert.ToDouble(dtAnswers.Rows[4]["Percentile"].ToString()); dblStuFP = Convert.ToDouble(dtAnswers.Rows[5]["Percentile"].ToString()); //get Difference strLevelAR = getDifference(dblStuAR, dblAR); strLevelCM = getDifference(dblStuCM, dblCM); strLevelVA = getDifference(dblStuVA, dblVA); strLevelSA = getDifference(dblStuSA, dblSA); strLevelCP = getDifference(dblStuCP, dblCP); strLevelFP = getDifference(dblStuFP, dblFP); } }
protected void Page_Load(object sender, EventArgs e) { LoginID = Request.QueryString["LoginID"]; PID = Request.QueryString["PID"]; LoginInfo = CCLib.Login.GetLoginInfo(LoginID); Redirect(); PageTitle = "Ability Profiler"; Section = "mm"; CSS = "global_css"; HeadTag = "<style type='TEXT/CSS'><!--.btnDescription { font: 11px Verdana, Arial, Helvetica, sans-serif; margin: 0px 15px}--></style>"; BodyTag = " alink='#990000' style='background-image:url(/media/shared/bg_else.gif); background-repeat:no-repeat; background-color:#FFFFFF;' leftmargin=0 link='#003366' text='#000000' topmargin=0 vlink='#003366' marginwidth='0' marginheight='0'"; LeftBar = "<table border='0' cellpadding='0' cellspacing='0' style='width:100%;'><tr style='background-color:#336699; vertical-align:top;'><td style='background-image:url(/media/mm/i_top_bar_bg.gif);'><img src='/media/mm/i_c_mm_icon.gif' alt=''><img src='/media/mm/h_c_mm.gif' alt='" + TextCode(273) + "'>"; HasTopCenterButtons = false; CheckPortSession(); ClientScript.RegisterClientScriptBlock(Page.GetType(),"Reconnect", CCLib.Login.AddKeepAlive()); strSection = (CCLib.Common.Strings.GetQueryString("SID") == "") ? "0" : CCLib.Common.Strings.GetSecureQueryString("SID"); strTestID = (CCLib.Common.Strings.GetQueryString("TID") == "") ? "0" : CCLib.Common.Strings.GetSecureQueryString("TID"); strRegID = (CCLib.Common.Strings.GetQueryString("RID") == "") ? "0" : CCLib.Common.Strings.GetSecureQueryString("RID"); if (Page.IsPostBack) { strResult = CCLib.Common.Strings.GetFormString("hidResult"); strUrl = CCLib.Common.Strings.GetFormString("hidUrl"); // Save answers to DB if (ViewState["CompletedSection"].ToString() == "0") { strSQL = "select count(APTestID) from AP_SavedTest where PortfolioID=" + PortInfo["PortfolioID"].ToString() + " and SchoolID=" + PortInfo["SchoolID"].ToString() + " and IsActiveStatus = 1"; intActiveTest = Convert.ToInt16(CCLib.Common.DataAccess.GetValue(strSQL)); if (intActiveTest == 0) { strSQL = "insert into AP_SavedTest(PortfolioID,SchoolID,GradeNumber) values(" + PortInfo["PortfolioID"].ToString() + "," + PortInfo["SchoolID"].ToString() + "," + PortInfo["GradeNumber"].ToString() + ")"; intAPTestID = CCLib.Common.DataAccess.ExecuteDbWithIntResult(strSQL + "; select @@identity;"); strTestID = intAPTestID.ToString(); } else strUrl = "Error"; } if (strTestID != "0") { try { strSQL = "insert into AP_SavedSection(SectionID,APTestID,APRegID,StartTime,EndTime,Answers) values(" + strSection + "," + strTestID + "," + strRegID + ",'" + Session["StartTime"].ToString() + "','" + DateTime.Now + "','" + strResult + "')"; CCLib.Common.DataAccess.ExecuteNonQuery(strSQL); } catch (System.Data.SqlClient.SqlException ex)//avoid duplicate records { if (ex.Message.IndexOf("Violation of UNIQUE KEY constraint 'un_section'. ") < 0) throw; } if (ViewState["CompletedSection"].ToString() == "5") { strSQL = "select SectionID,Answers from AP_SavedSection where APTestID=" + strTestID + " order by SectionID"; dtAnswers = CCLib.Common.DataAccess.GetDataTable(strSQL); if (dtAnswers.Rows.Count > 0) { for (int i = 0; i < dtAnswers.Rows.Count; i++) { strAnswers[i] = dtAnswers.Rows[i]["Answers"].ToString(); } scoTest = new CareerCruisingWeb.CCLib.AbilityProfiler.Score(); scoTest.ScoreTest(strAnswers); strSQL = ""; for (int j = 0; j < 6; j++) { strSQL += "update AP_SavedSection set CorrectAnswers = " + scoTest.CorrectAnswers[j].ToString() + ", ConvertedScore = " + scoTest.ScaledScores[scoTest.SubTestMatchingAbilityNameIndex[j]].ToString() + ", Percentile = " + scoTest.PercentileScores[j].ToString() + " where APTestID=" + strTestID + " and SectionID = " + Convert.ToString(j + 1) + "; "; } CCLib.Common.DataAccess.ExecuteNonQuery(strSQL); } strAllDone = "1"; UpdatePCSStatusFromSection("AbilityProfiler"); } } if (strUrl == "Next") Response.Redirect("AP_Test.aspx?LoginID=" + LoginID + "&SID=" + Server.UrlEncode(CCLib.Common.Strings.SetSecureQueryString("SID", ViewState["Section"].ToString())) + "&TID=" + Server.UrlEncode(CCLib.Common.Strings.SetSecureQueryString("TID", strTestID)) + "&RID=" + Server.UrlEncode(CCLib.Common.Strings.SetSecureQueryString("RID", strRegID))); if (strUrl == "Done") Response.Redirect("/Individual/AP_Portfolio1.aspx?LoginID=" + LoginID); if (strUrl == "Result") Response.Redirect("/MatchMaker/AP_Pro/AP_Results.aspx?LoginID=" + LoginID + "&tid=" + strTestID); if (strUrl == "Timeout") Response.Redirect("AP_Timeout.aspx?LoginID=" + LoginID + "&SID=" + Server.UrlEncode(CCLib.Common.Strings.SetSecureQueryString("SID", ViewState["Section"].ToString())) + "&TID=" + Server.UrlEncode(CCLib.Common.Strings.SetSecureQueryString("TID", strTestID)) + "&RID=" + Server.UrlEncode(CCLib.Common.Strings.SetSecureQueryString("RID", strRegID)) + "&Result=" + strAllDone); if (strUrl == "Error") Response.Write("<script language='javascript'>alert('There is already an instance of the Ability Profiler associated with your account.');location.href='/Individual/AP_Portfolio1.aspx?LoginID=" + LoginID + "';</script>"); } else { Session["StartTime"] = DateTime.Now; // Get completed sections strSQL = "select SavedSectionID,SectionID,a.APTestID from AP_SavedTest a "; strSQL += " join AP_SavedSection b on a.APTestID = b.APTestID "; strSQL += " and PortfolioID = " + PortInfo["PortfolioID"].ToString(); strSQL += " and SchoolID = " + PortInfo["SchoolID"].ToString() + " and IsActiveStatus = 1 "; strSQL += " order by SectionID "; dtCompletedSection = CCLib.Common.DataAccess.GetDataTable(strSQL); ViewState["CompletedSection"] = dtCompletedSection.Rows.Count; intNextPart = Convert.ToInt16(strSection) + 1; strSQL = "SELECT SectionID, SectionName_EN, SectionNameCapital_EN, SectionDescription_EN, ExampleDescription_EN, PracticeDescription_EN, Timer, "; strSQL += " NumberOfSlotsInOnePage, NumberOfQuestionInSlot, LayoutType,TotalQuestions FROM AP_Section"; dtbSection = CCLib.Cache.GetCachedDataTable("AP_Section" + CCLib.Common.Strings.SuffixCode(), strSQL); drsSection = dtbSection.Select("SectionID=" + strSection); if (drsSection.Length > 0) { strTimer = drsSection[0]["Timer"].ToString(); intNumberOfSlotsInOnePage = Convert.ToInt32(drsSection[0]["NumberOfSlotsInOnePage"]); intNumberOfQuestionInSlot = Convert.ToInt32(drsSection[0]["NumberOfQuestionInSlot"]); strLayoutType = drsSection[0]["LayoutType"].ToString(); } if (Convert.ToInt16(strSection) <= dtCompletedSection.Rows.Count) { for (int x = 0; x < dtCompletedSection.Rows.Count; x++) { if (Convert.ToInt16(dtCompletedSection.Rows[x]["SectionID"]) - intNextPart == 0) intNextPart = Convert.ToInt16(dtCompletedSection.Rows[x]["SectionID"]) + 1; } } ViewState["Section"] = intNextPart; if (intNextPart <= 6) { drsNextSection = dtbSection.Select("SectionID=" + intNextPart.ToString()); if (drsNextSection.Length > 0) strNextSectionTimer = drsNextSection[0]["Timer"].ToString(); } strSQL = "select SectionID,QuestionID,QuestionOrder,QuestionDescription" + CCLib.Common.Strings.SuffixCode() + ",QuestionImagePath from AP_Question"; dtbQuestion = CCLib.Cache.GetCachedDataTable("AP_Question" + CCLib.Common.Strings.SuffixCode(), strSQL); drsQuestion = dtbQuestion.Select("SectionID=" + strSection); strSQL = "select OptionID,QuestionID,OptionOrder,OptionDescription" + CCLib.Common.Strings.SuffixCode() + ",OptionImagePath,OptionValue from AP_QuestionOptions"; dtbQuestionOptions = CCLib.Cache.GetCachedDataTable("AP_QuestionOptions" + CCLib.Common.Strings.SuffixCode(), strSQL); for (int x = 0; x < drsQuestion.Length; x++) { Page.ClientScript.RegisterArrayDeclaration("arrQues", String.Concat("\"", drsQuestion[x]["QuestionID"].ToString(), "\"")); } strInnerHTML = @" "; intTTL = (int)Math.Ceiling((double)drsQuestion.Length / (double)(intNumberOfSlotsInOnePage * intNumberOfQuestionInSlot)); for (int i = 0; i < intTTL; i++) { strInnerHTML += @"<div id='div" + i + "' style='display:none; position:absolute; margin-left: 24px; padding: 30px;'>"; if (strLayoutType == "3") { strInnerHTML += @" <div class='timeRemaining timeRemainingWide'><input type='text' style='border:none 0; width:20px; height:16px;' class='timeRemaining timeRemainingWide' id='txtTimer" + i + "' value=" + strTimer + @" /> Minutes Remaining</div> <table class='apTable apTableWide'> <tr class='headerTitle headerTitleWide'>"; } else { strInnerHTML += @" <div class='timeRemaining'><input type='text' style='border:none 0; width:20px; height:16px;' class='timeRemaining' id='txtTimer" + i + "' value=" + strTimer + @" /> Minutes Remaining</div> <table class='apTable'> <tr class='headerTitle'>"; } strInnerHTML += @" <td class='firstChild'> </td> <td id='tdTimer" + i + "' colspan='3'>" + drsSection[0]["SectionNameCapital_EN"].ToString() + @"</td> </tr> <tr class='headerInstructions'> <td class='firstChild' rowspan='4'> </td> <td colspan='3'>" + drsSection[0]["SectionDescription_EN"].ToString() + @"</td> </tr> <tr> <td colspan='3'>"; intQuestionID = Convert.ToInt32(drsQuestion[i * intNumberOfSlotsInOnePage * intNumberOfQuestionInSlot]["QuestionID"]); strInnerHTML += LoadQuestionTemplate(intQuestionID, i); strInnerHTML += @" </td> </tr> <tr class='footer'> "; int intPrev = i - 1; int intNext = i + 1; if (i > 0) strInnerHTML += "<td class='firstChild'><a href=\"javascript:SwitchDIV('div" + i.ToString() + "', 'div" + intPrev.ToString() + "');\">Back</a></td>"; else strInnerHTML += "<td class='firstChild' style='background-image:none;'><span style='visibility:hidden;'>Back</span></td>"; strInnerHTML += @" <td class='secondChild'> <div class='pageOf'>Page " + intNext.ToString() + @" of " + intTTL + @"</div> <div><div id='progressbar' class='progressbar'><img src='/media/student_parent/shared/i_status_bar_progress.gif' width='" + Convert.ToInt16((Convert.ToDouble(intNext) / Convert.ToDouble(intTTL)) * 161).ToString() + @"' style='height:6px;' /></div></div> </td> <td class='lastChild'>"; if (i == intTTL - 1) strInnerHTML += "<a href=\"javascript:SwitchDIV('div" + i.ToString() + "','divSummary');\">Next</a>"; else { switch (strLayoutType) { case "1": strInnerHTML += "<a href=\"javascript:SwitchDIV('div" + i.ToString() + "', 'div" + intNext.ToString() + "');\">Next</a>"; break; case "2": strInnerHTML += "<a href=\"javascript:SwitchDIVNext('div" + i.ToString() + "', 'div" + intNext.ToString() + "');\">Next</a>"; break; case "3": strInnerHTML += "<a href=\"javascript:SwitchDIVNext('div" + i.ToString() + "', 'div" + intNext.ToString() + "');\">Next</a>"; break; case "4": strInnerHTML += "<a href=\"javascript:SwitchDIV('div" + i.ToString() + "', 'div" + intNext.ToString() + "');\">Next</a>"; break; default: break; } } strInnerHTML += @" </td> </tr> </table> </div> "; } strInnerHTML += LoadSummaryTemplate(dtCompletedSection.Rows.Count); tdQues.InnerHtml = strInnerHTML + "</div>"; } }
private void UpdateScore(JobList jl) { DataTable dtCareer; double dblAR, dblCM, dblVA, dblSA, dblCP, dblFP, dblStuAR, dblStuCM, dblStuVA, dblStuSA, dblStuCP, dblStuFP; scoTest = new CareerCruisingWeb.CCLib.AbilityProfiler.Score(); string strSQL = "select b.APTestID,SectionID,Answers,Percentile from AP_SavedSection a join AP_SavedTest b on a.APTestID = b.APTestID and PortfolioID=" + LoginInfo["PID"].ToString() + " and IsActiveStatus = 1 order by a.SectionID"; DataTable dtAnswers = CCLib.Common.DataAccess.GetDataTable(strSQL); if (dtAnswers.Rows.Count >= 6) { if (dtAnswers.Rows[0]["Percentile"].ToString() == "") { for (int i = 0; i < dtAnswers.Rows.Count; i++) { strAnswers[i] = dtAnswers.Rows[i]["Answers"].ToString(); } scoTest.ScoreTest(strAnswers); dtCareer = scoTest.Occupations; strSQL = ""; for (int j = 0; j < 6; j++) { strSQL += "update AP_SavedSection set CorrectAnswers = " + scoTest.CorrectAnswers[j].ToString() + ", ConvertedScore = " + scoTest.ScaledScores[scoTest.SubTestMatchingAbilityNameIndex[j]].ToString() + ", Percentile = " + scoTest.PercentileScores[j].ToString() + " where APTestID=" + dtAnswers.Rows[0]["APTestID"].ToString() + " and SectionID = " + Convert.ToString(j + 1) + "; "; } CCLib.Common.DataAccess.ExecuteNonQuery(strSQL); strSQL = "select b.APTestID,SectionID,Answers,Percentile from AP_SavedSection a join AP_SavedTest b on a.APTestID = b.APTestID and PortfolioID=" + LoginInfo["PID"].ToString() + " and IsActiveStatus = 1 order by a.SectionID"; dtAnswers = CCLib.Common.DataAccess.GetDataTable(strSQL); } else { scoTest.IdentifyOccupations(); dtCareer = scoTest.Occupations; } foreach (JobItem ji in jl) { DataRow[] dr = dtCareer.Select("OccNumber=" + ji.JobRef.ToString()); if (dr.Length > 0) { dblAR = Convert.ToDouble(dr[0]["ARPercentile"].ToString()); dblCM = Convert.ToDouble(dr[0]["CMPPercentile"].ToString()); dblVA = Convert.ToDouble(dr[0]["Vpercentile"].ToString()); dblSA = Convert.ToDouble(dr[0]["Spercentile"].ToString()); dblCP = Convert.ToDouble(dr[0]["Qpercentile"].ToString()); dblFP = Convert.ToDouble(dr[0]["Ppercentile"].ToString()); dblStuAR = Convert.ToDouble(dtAnswers.Rows[0]["Percentile"].ToString()); dblStuCM = Convert.ToDouble(dtAnswers.Rows[3]["Percentile"].ToString()); dblStuVA = Convert.ToDouble(dtAnswers.Rows[1]["Percentile"].ToString()); dblStuSA = Convert.ToDouble(dtAnswers.Rows[2]["Percentile"].ToString()); dblStuCP = Convert.ToDouble(dtAnswers.Rows[4]["Percentile"].ToString()); dblStuFP = Convert.ToDouble(dtAnswers.Rows[5]["Percentile"].ToString()); //get Difference int intAPMatch = 0; int intAPNotMatch = 0; if (getDifference(dblStuAR, dblAR) == 1) intAPMatch++; else intAPNotMatch++; if (getDifference(dblStuCM, dblCM) == 1) intAPMatch++; else intAPNotMatch++; if (getDifference(dblStuVA, dblVA) == 1) intAPMatch++; else intAPNotMatch++; if (getDifference(dblStuSA, dblSA) == 1) intAPMatch++; else intAPNotMatch++; if (getDifference(dblStuCP, dblCP) == 1) intAPMatch++; else intAPNotMatch++; if (getDifference(dblStuFP, dblFP) == 1) intAPMatch++; else intAPNotMatch++; ji.APMatchCat = intAPMatch.ToString(); ji.APNotMatchCat = intAPNotMatch.ToString(); } else { ji.APMatchCat = "N/A"; ji.APNotMatchCat = "N/A"; } } SaveAPResults(jl); } }