// at the start: // protected override void Start() { base.Start(); // connect to the other instance of this class // other = (leftInstance ? right : left); // connect to the player head transform // headTransform = AirRushingAudio.singleton.transform.parent; }
// upon enablement: // private void OnEnable() { // connect the corresponding instance of this class // if (leftInstance) { left = this; } else { right = this; } }
//quiz answers submitted protected void btnsubmit_Click(object sender, EventArgs e) { SqlDataReader dReader; string email = ""; string name = ""; string selectedanswer = ""; string correctanswer = ""; int questionId = 0; int questionscount = 0; int correctcount = 0; int wrongcount = 0; int success = 0; ArrayList answersList = new ArrayList(); Page.Validate(); if (Page.IsValid) { email = txtemail.Text.Trim(); name = txtname.Text.Trim(); //check if this account has already taken the quiz. DataTable accounts = new DataTable(); SqlCommand checkentrycmd = new SqlCommand("select * from " + quizresponsestable + " where quizid=@quizid and email=@email"); checkentrycmd.Parameters.AddWithValue("quizid", quizId); checkentrycmd.Parameters.AddWithValue("email", email); db checkentry = new db(); accounts = checkentry.returnDataTable(checkentrycmd); if (accounts.Rows.Count > 0) { quizdetails.Visible = false; detailsdiv.Visible = false; questionsdiv.Visible = false; lblmessage.Visible = true; lblmessage.Text = "You have already taken this quiz!"; } else { foreach (RepeaterItem item in questionsrpt.Items) { // Checking the item is a data item if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { //get the questionid var hfId = item.FindControl("hfID") as HiddenField; questionId = Convert.ToInt32(hfId.Value); //get the submitted answer var rdbList = item.FindControl("rbloptions") as RadioButtonList; selectedanswer = rdbList.SelectedValue; //disable to prevent submitting again rdbList.Enabled = false; //get the correct answer SqlCommand getanswercmd = new SqlCommand("select optionid from " + quizquestionanswertable + " where questionid=@questionid"); getanswercmd.Parameters.AddWithValue("questionid", questionId); db getanswer = new db(); dReader = getanswer.returnDataReader(getanswercmd); if (!dReader.HasRows) { //can't find this question/answer } else { while (dReader.Read()) { correctanswer = dReader["optionid"].ToString(); } } //compare both answers if (selectedanswer == correctanswer) { correctcount++; rdbList.SelectedItem.Attributes.Add("style", "color: #006400"); } else { wrongcount++; rdbList.SelectedItem.Attributes.Add("style", "color: #ff0000"); rdbList.Items.FindByValue(correctanswer).Attributes.Add("style", "color: #006400"); } //add the submitted answer to list answersList.Add(new string[] { questionId.ToString(), selectedanswer }); } } //create entry SqlCommand insertentrycmd = new SqlCommand("insert into " + quizresponsestable + " (quizid, email, name, correctanswers, wronganswers, lastupdated) values (@quizid, @email, @name, @correctanswers, @wronganswers, @lastupdated);SELECT CAST(scope_identity() AS int)"); insertentrycmd.Parameters.AddWithValue("quizid", quizId); insertentrycmd.Parameters.AddWithValue("email", email); insertentrycmd.Parameters.AddWithValue("name", name); insertentrycmd.Parameters.AddWithValue("correctanswers", correctcount); insertentrycmd.Parameters.AddWithValue("wronganswers", wrongcount); insertentrycmd.Parameters.AddWithValue("lastupdated", updatedate); db insertentry = new db(); success = insertentry.ReturnIDonExecuteQuery(insertentrycmd); //display the result on screen if (success > 0) { foreach (string[] arr in answersList) { SqlCommand insertresponsecmd = new SqlCommand("insert into " + quizuserreponsetable + " (responseid, questionid, optionid, lastupdated) values (@responseid, @questionid, @optionid, @lastupdated)"); insertresponsecmd.Parameters.Clear(); insertresponsecmd.Parameters.AddWithValue("responseid", success); insertresponsecmd.Parameters.AddWithValue("questionid", arr[0].ToString()); insertresponsecmd.Parameters.AddWithValue("optionid", arr[1].ToString()); insertresponsecmd.Parameters.AddWithValue("lastupdated", updatedate); db insertresponses = new db(); insertresponses.ExecuteQuery(insertresponsecmd); } detailsdiv.Visible = false; questionscount = correctcount + wrongcount; lblalert.Visible = true; //get the completion description from database table SqlDataReader Treader; SqlCommand getcompletiondesc = new SqlCommand("select completiondescription from " + quizdetailstable + " where id=@quizid"); getcompletiondesc.Parameters.AddWithValue("quizid", quizId); db getdesc = new db(); Treader = getdesc.returnDataReader(getcompletiondesc); if (!Treader.HasRows) { lblalert.Text = "Thanks for taking the Quiz." + "<br />" + "You have answered <span style='color:#006400;'>" + correctcount + "</span> questions correctly out of " + questionscount + "<br />"; } else { while (Treader.Read()) { string completiondesc = Treader["completiondescription"].ToString(); lblalert.Text = completiondesc + "<br />" + "You have answered <span style='color:#006400;'>" + correctcount + "</span> questions correctly out of " + questionscount + "<br />"; } } btnsubmit.Visible = false; } else { lblalert.Visible = true; lblalert.Text = "Sorry! we could not process your request. Please try again."; } } } else { lblalert.Visible = true; lblalert.Text = "Please answer all the questions!"; } }
// methods // // method: determine the (boolean) state of this Dependency Requisite // public override bool state() { return(Treader.treading()); }
// method: determine whether the given treader is active // public static bool isActive(Treader treader) => (treader && treader.gameObject && treader.gameObject.activeSelf);
// method: toggle the direction reference transform between the corresponding hand transform and the player head transform for the given treader // public void toggleDirectionReferenceTransformForTreader_(Treader treader) => toggleDirectionReferenceTransformForTreader(treader);
// method: toggle the direction reference transform between the corresponding hand transform and the player head transform for the given treader // public static void toggleDirectionReferenceTransformForTreader(Treader treader) => treader.toggleDirectionReferenceTransform();
// method: change the direction reference transform to the player head transform for the given treader // public void changeDirectionReferenceTransformToHeadForTreader_(Treader treader) => changeDirectionReferenceTransformToHeadForTreader(treader);
// method: change the direction reference transform to the player head transform for the given treader // public static void changeDirectionReferenceTransformToHeadForTreader(Treader treader) => treader.changeDirectionReferenceTransformToHead();