Exemple #1
0
        private void GetFlashcardsForSet(String setName)
        {
            //WebRequest request = WebRequest.Create("https://cis-iis2.temple.edu/fall2020/CIS3342_tuh34847/webapitest/api/flashcards/getflashcardset/" + setName);
            WebRequest request = WebRequest.Create("https://localhost:44355/api/flashcards/getflashcardset/" + setName);
            WebResponse response = request.GetResponse();

            // Read the data from the Web Response, which requires working with streams.
            Stream theDataStream = response.GetResponseStream();
            StreamReader reader = new StreamReader(theDataStream);
            String data = reader.ReadToEnd();

            reader.Close();
            response.Close();

            // Deserialize a JSON string that contains an array of JSON objects into an Array of flashcardset objects.
            JavaScriptSerializer js = new JavaScriptSerializer();
            FlashcardClass[] sets = js.Deserialize<FlashcardClass[]>(data);


            foreach (FlashcardClass flashcard in sets)
            {
                FlashcardList.Add(flashcard);
            }

            flashcardImage.ImageUrl= FlashcardList[Index].FlashcardImage.ToString();
            lblQuestion.Text = FlashcardList[Index].FlashcardQuestion.ToString();
            lblAnswer.Text = FlashcardList[Index].FlashcardAnswer.ToString();
        }
Exemple #2
0
        protected void btnRemove_Click(object sender, EventArgs e)
        {
            HasHomeButtonInNavBeenClickOn = false;
            if (FlashcardList.Count == 1)
            {
                ShowFin();
            }
            else if(Index == FlashcardList.Count-1)
            {
                FlashcardList.RemoveAt(Index);
                lblQuestion.Text = FlashcardList[Index - 1].FlashcardQuestion.ToString();
                lblAnswer.Visible = false;
                lblAnswer.Text = FlashcardList[Index - 1].FlashcardAnswer.ToString();
                Index--;
            }
            else if(Index == 0)
            {
                FlashcardList.RemoveAt(Index);
                lblQuestion.Text = FlashcardList[0].FlashcardQuestion.ToString();
                lblAnswer.Visible = false;
                lblAnswer.Text = FlashcardList[0].FlashcardAnswer.ToString();
            }
            else
            {
                FlashcardList.RemoveAt(Index);
                lblQuestion.Text = FlashcardList[Index-1].FlashcardQuestion.ToString();
                lblAnswer.Visible = false;
                lblAnswer.Text = FlashcardList[Index-1].FlashcardAnswer.ToString();
                Index--;
            }

            
        }
Exemple #3
0
        private void ShowFin()
        {
            lblAnswer.Text = "Woo you're done!";
            lblAnswer.Visible = true;
            lblQuestion.Visible = false;
            btnNext.Visible = false;
            btnRemove.Visible = false;
            btnShowAnswer.Visible = false;
            FlashcardList.Clear();
            Index = -2;

        }
Exemple #4
0
        // quit studying button
        protected void btnRelax_Click(object sender, EventArgs e)
        {
            FlashcardList.Clear();
            Index = -1;
            String userType = Session["userType"].ToString();
            if(userType == "Guest")
            {
                Response.Redirect("GuestHomepage.aspx");

            }
            else if(userType == "Teacher")
            {
                Response.Redirect("TeacherHomepage.aspx");

            }
            else if(userType == "Student")
            {
                Response.Redirect("StudentHomepage.aspx");
            }
        }