/**
  * Il metodo in questione, ogni qualvolta richiamato, permette all'utente
  * di andare indietro per sfogliare le domande già visualizzate in precedenza
  **/
 private void btnIndietro_Clicked(object sender, EventArgs e)
 {
     if (btnAvanti.IsVisible == false)
     {
         btnAvanti.IsVisible = true;
     }
     if (indiceBack > 0)
     {
         recordCampiDomandaRisposte = strutturaAppoggio[indiceBack - 1];
         visualizzaRispostaEsatta(recordCampiDomandaRisposte);
         indiceBack--;
         if (indiceBack == 0)
         {
             btnIndietro.IsVisible = false;
         }
         numeroAttualeDomanda  = numeroAttualeDomanda - 1;
         ContatoreDomande.Text = "Domanda " + numeroAttualeDomanda.ToString() + " di " + numeroTotaleDelSetDiDomande.ToString();
     }
     else
     {
         btnIndietro.IsVisible = false;
         numeroAttualeDomanda  = numeroAttualeDomanda - 1;
         ContatoreDomande.Text = "Domanda " + numeroAttualeDomanda.ToString() + " di " + numeroTotaleDelSetDiDomande.ToString();
     }
 }
Ejemplo n.º 2
0
 public void DomandaSuccessiva(bool flag)
 {
     if (struttura.Count > 0)
     {
         recordCampiDomandaRisposte = null;
         index = rnd.Next(struttura.Count);
         recordCampiDomandaRisposte = struttura[index];
         lblDomanda.Text            = recordCampiDomandaRisposte.Domanda;
         Griglia(recordCampiDomandaRisposte);
         strutturaAppoggio.Add(recordCampiDomandaRisposte);
         indiceStrutturaAppoggio++;
         struttura.RemoveAt(index);
         numeroAttualeDomanda++;
         ContatoreDomande.Text = "Domanda " + numeroAttualeDomanda.ToString() + " di " + numeroTotaleDelSetDiDomande.ToString();
         if (recordCampiDomandaRisposte.urlVideo != null && flag != false)
         {
             btnVideo.IsVisible = true;
         }
         else
         {
             btnVideo.IsVisible = false;
         }
     }
     else
     {
         DisplayAlert("Complimenti!", "La sessione di simulazione è terminata.", "Esci");
         //var page = Navigation.NavigationStack.ElementAtOrDefault(Navigation.NavigationStack.Count - 1);
         bool flagPunteggio = false;
         Navigation.PushAsync(new RisultatoSimulazione(contEsatteTot, contSbagliateTot, lblTempo.Text, lstdatirisultati, flagPunteggio, contNonRisposteTot));
         //Navigation.RemovePage(page);
     }
     btnAvanti.IsVisible = false;
 }
        /**
         * Il metodo domanda successiva, ogni qualvolta richiamato,
         * permette di visualizzare a video una domanda, presa in maniera casuale,
         * dal server.
         **/
        public void DomandaSuccessiva()
        {
            if (indiceStrutturaAppoggio == 0)
            {
                btnIndietro.IsVisible = false;
                btnAvanti.IsVisible   = true;
            }
            else
            {
                btnIndietro.IsVisible = true;
            }

            if (struttura.Count > 0)
            {
                indiceAccessoStruttura     = rnd.Next(struttura.Count);
                recordCampiDomandaRisposte = struttura[indiceAccessoStruttura];
                visualizzaRispostaEsatta(recordCampiDomandaRisposte);
                strutturaAppoggio.Add(recordCampiDomandaRisposte);
                indiceBack = indiceStrutturaAppoggio;
                indiceStrutturaAppoggio++;
                struttura.RemoveAt(indiceAccessoStruttura);
                numeroAttualeDomanda++;
                ContatoreDomande.Text = "Domanda " + numeroAttualeDomanda.ToString() + " di " + numeroTotaleDelSetDiDomande.ToString();
            }
            else
            {
                DisplayAlert("Complimenti!", "La sessione è terminata.", "Esci");
                Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 1]);
            }
        }
        public async void DomandaSuccessiva(bool flag)
        {
            if (struttura.Count > 0)
            {
                recordCampiDomandaRisposte = null;
                recordCampiDomandaRisposte = struttura[0];
                await CaricamentoImmagine(recordCampiDomandaRisposte.tipo, Costanti.urlBase, recordCampiDomandaRisposte.link);

                lblDomanda.Text = recordCampiDomandaRisposte.Domanda;
                Griglia(recordCampiDomandaRisposte);
                numeroAttualeDomanda++;
                indiceAppoggio++;
                if (recordCampiDomandaRisposte.urlVideo != null && flag != false)
                {
                    btnVideo.IsVisible = true;
                }
                else
                {
                    btnVideo.IsVisible = false;
                }

                if (numeroAttualeDomanda <= numeroTotaleDelSetDiDomande)
                {
                    ContatoreDomande.Text  = "Domanda " + numeroAttualeDomanda.ToString() + " di " + numeroTotaleDelSetDiDomande.ToString();
                    saltaDomanda.IsEnabled = true;
                    saltaDomanda.IsVisible = true;
                }
                else
                {
                    ContatoreDomande.Text = "Domanda " + numeroTotaleDelSetDiDomande.ToString() + " di " + numeroTotaleDelSetDiDomande.ToString();
                }
                if (indiceAppoggio > numeroTotaleDelSetDiDomande)
                {
                    consegnaSimulazione.IsVisible = true;
                    consegnaSimulazione.IsEnabled = true;
                }
            }
            else
            {
                StopTempoTrascorsoGlobale();
                fermaAvviaTempoGlobale        = false;
                GrigliaDomande.IsEnabled      = false;
                consegnaSimulazione.IsEnabled = false;
                consegnaSimulazione.IsVisible = false;
                saltaDomanda.IsEnabled        = false;
                saltaDomanda.IsVisible        = false;
                await DisplayAlert("Complimenti!", "La sessione di esercitazione è terminata.", "Guarda il risultato!");
                await attesaInvioDatiStatistiche();
            }
        }
        /**
         * Il metoto in questione visualizzerà a video, colorando di colore verde,
         * la risposta esatta
         **/
        private async void visualizzaRispostaEsatta(Domande prova)
        {
            lblDomanda.Text = prova.Domanda;
            await CaricamentoImmagine(prova.tipo, Costanti.urlBase, prova.link);

            btn.IsEnabled       = true;
            btn.BackgroundColor = Color.FromHex("#0069c0");

            for (int i = 0; i <= Costanti.alfabeto.Length; i++)
            {
                if (Costanti.alfabeto[i].ToString() == prova.Risposta)
                {
                    btn.IsVisible       = true;
                    btn.Text            = prova.Quesiti[i];
                    btn.BackgroundColor = Color.Green;
                    break;
                }
            }
        }
        public void Griglia(Domande recordCampiDomandaRisposte)
        {
            GrigliaDomande.Children.Clear();
            GrigliaDomande.RowDefinitions    = new RowDefinitionCollection();
            GrigliaDomande.ColumnDefinitions = new ColumnDefinitionCollection();
            var listaBottoni = new List <Button>();
            var listaLabel   = new List <Label>();
            var lista        = new List <string>();

            GrigliaDomande.ColumnDefinitions.Add(new ColumnDefinition
            {
                Width = new GridLength(0.2, GridUnitType.Star)
            });

            GrigliaDomande.ColumnDefinitions.Add(new ColumnDefinition
            {
                Width = new GridLength(0.8, GridUnitType.Star)
            });

            int i = 0;

            foreach (var el in recordCampiDomandaRisposte.Quesiti)
            {
                lista.Add(el);

                GrigliaDomande.RowDefinitions.Add(new RowDefinition
                {
                    Height = new GridLength(1, GridUnitType.Auto)
                });
                var btn = Addbutton(Costanti.alfabeto[i].ToString());

                var lbl = AddLabel();

                listaBottoni.Add(btn);
                listaLabel.Add(lbl);

                listaLabel[i].Text = lista[i];
                GrigliaDomande.Children.Add(listaBottoni[i], 0, i);
                GrigliaDomande.Children.Add(listaLabel[i], 1, i);
                i++;
            }
        }
 /**
  * Il metodo in questione, ogni qualvolta richiamato, permette ogni volta che sarà
  * cliccato il button avanti di sfogliare le domande successive
  **/
 private void btnAvanti_Clicked(object sender, EventArgs e)
 {
     indiceBack++;
     indiceNext = indiceStrutturaAppoggio - indiceBack;
     if (indiceNext >= 1)
     {
         recordCampiDomandaRisposte = strutturaAppoggio[indiceBack];
         visualizzaRispostaEsatta(recordCampiDomandaRisposte);
         numeroAttualeDomanda++;
         ContatoreDomande.Text = "Domanda " + numeroAttualeDomanda.ToString() + " di " + numeroTotaleDelSetDiDomande.ToString();
     }
     else if (indiceNext < 1)
     {
         btn.IsEnabled       = false;
         btn.BackgroundColor = Color.FromHex("#0069c0");
         DomandaSuccessiva();
     }
     if (btnIndietro.IsVisible == false)
     {
         btnIndietro.IsVisible = true;
     }
 }