Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace QCM
- {
- public partial class QCM : Form
- {
- int[] indexquestion = new int[10]; //J'utilise un tableau pour retrouver l'index des differentes questions qui seront passées.
- int position = 0; //J'utilise la position pour retrouver la bonne position d'index si dessus.
- Points points = new Points(); //Je crée une instance de la classe points.
- bool testFini=false;
- public QCM()
- {
- InitializeComponent();
- }
- private void QcmText() //Affichage de la question et des réponses.
- {
- LBL_question.Text = Global.ListeQuestion()[indexquestion[position]].Questions;
- RADIO_rep1.Text = Global.ListeQuestion()[indexquestion[position]].Rep1;
- RADIO_rep2.Text = Global.ListeQuestion()[indexquestion[position]].Rep2;
- RADIO_rep3.Text = Global.ListeQuestion()[indexquestion[position]].Rep3;
- RADIO_rep4.Text = Global.ListeQuestion()[indexquestion[position]].Rep4;
- RADIO_rep1.Checked = false;
- RADIO_rep2.Checked = false;
- RADIO_rep3.Checked = false;
- RADIO_rep4.Checked = false;
- }
- private void QCM_Load(object sender, EventArgs e)//On remplis le tableau d'index à l'ouverture du formulaire et l'ont affiche la première question ainsi que les premières questions.
- { //Le "Lotto" se fait ici pour remplir le tableau.
- this.Text = "[" + (position + 1) + "/10] - " + Global.etudiantEnCour.Nom + " " + Global.etudiantEnCour.Prenom;
- Random rnd1 = new Random();
- indexquestion[0] = rnd1.Next(0, 14);
- for (int i = 1; i < 10; i++)
- {
- indexquestion[i] = rnd1.Next(0, 14);
- for (int j = i - 1; j >= 0; j--)
- {
- if (indexquestion[i] == indexquestion[j])
- {
- i--;
- break;
- }
- }
- }
- QcmText();
- }
- private void BUT_OK_Click(object sender, EventArgs e) //Ajout des points via la fonctions addpoints si l'élève as bien répondu.
- {
- if (Global.ListeQuestion()[indexquestion[position]].BonneRep == 1 & RADIO_rep1.Checked == true)
- {
- points.addpoint();
- }
- else if (Global.ListeQuestion()[indexquestion[position]].BonneRep == 2 & RADIO_rep2.Checked == true)
- {
- points.addpoint();
- }
- else if (Global.ListeQuestion()[indexquestion[position]].BonneRep == 3 & RADIO_rep3.Checked == true)
- {
- points.addpoint();
- }
- else if (Global.ListeQuestion()[indexquestion[position]].BonneRep == 4 & RADIO_rep4.Checked == true)
- {
- points.addpoint();
- }
- if (position == 9) //si l'étudiant arrive à la dernière question
- {
- if (points.Pointstest == 0) { points.Appreciation = "Nul"; }
- else if (points.Pointstest >= 1 & points.Pointstest <= 4) { points.Appreciation = "Insuffisant"; }
- else if (points.Pointstest == 5) { points.Appreciation = "Suffisant"; }
- else if (points.Pointstest >= 6 & points.Pointstest <= 7) { points.Appreciation = "Bien"; }
- else if (points.Pointstest == 8 & points.Pointstest == 9) { points.Appreciation = "Très bien"; }
- else if (points.Pointstest == 10) { points.Appreciation = "Excellent"; }
- MessageBox.Show("Test terminé par " + Global.etudiantEnCour.Nom + " " + Global.etudiantEnCour.Prenom + "." + Environment.NewLine + Environment.NewLine + "Il as eu un résultât de " + points.Pointstest + "/10 ce qui est " + points.Appreciation + ".");
- testFini = true;
- Application.Exit();
- }
- else //Temps que l'élève n'est pas à la dernière question
- {
- position++;
- this.Text = "[" + (position + 1) + "/10] - " + Global.etudiantEnCour.Nom + " " + Global.etudiantEnCour.Prenom;
- QcmText();
- }
- }
- private void QCM_FormClosing(object sender, FormClosingEventArgs e) //Si l'élève tente de fermer l'application avant d'avoir finis son test
- {
- if (testFini == false)
- {
- DialogResult dialogResult = MessageBox.Show("Voulez vous vraiment abandonner se test", " Abandonner", MessageBoxButtons.YesNo);
- if (dialogResult == DialogResult.Yes)
- {
- if (points.Pointstest == 0) { points.Appreciation = "Nul"; }
- else if (points.Pointstest >= 1 & points.Pointstest <= 4) { points.Appreciation = "Insuffisant"; }
- else if (points.Pointstest == 5) { points.Appreciation = "Suffisant"; }
- else if (points.Pointstest >= 6 & points.Pointstest <= 7) { points.Appreciation = "Bien"; }
- else if (points.Pointstest == 8 & points.Pointstest == 9) { points.Appreciation = "Très bien"; }
- else if (points.Pointstest == 10) { points.Appreciation = "Excellent"; }
- MessageBox.Show("Test abandonné par " + Global.etudiantEnCour.Nom + " " + Global.etudiantEnCour.Prenom + "." + Environment.NewLine + Environment.NewLine + "Il as eu un résultât de " + points.Pointstest + "/10 ce qui est " + points.Appreciation + ".");
- }
- else if (dialogResult == DialogResult.No)
- {
- e.Cancel = true;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement