May I know, how can I randomize data gathered and randomize selected using SQL I will integrate this to c# winform
For example
main content-----content1-----content2-----content3-----content4
To
main content-----content1-----content4-----content2-----content3
Like a multiple choice question, randomize the question and its choices. Thanks in advance.
edit:
this is my class.
public class qbank
{
string question, c1, c2, c3, c4, ans;
public string Ans
{
get { return ans; }
set { ans = value; }
}
public string C1
{
get { return c1; }
set { c1 = value; }
}
public string C2
{
get { return c2; }
set { c2 = value; }
}
public string C3
{
get { return c3; }
set { c3 = value; }
}
public string C4
{
get { return c4; }
set { c4 = value; }
}
public string Question
{
get { return question; }
set { question = value; }
}
this is my winform
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace frmMain
{
public partial class frmPIPETest : Form
{
string connString = @"Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=C:\Users\rehpe\Documents\Visual Studio 2015\Projects\panibago\questionbank.accdb;
Persist Security Info=False";
string query = "";
OleDbConnection conn = null;
public frmPIPETest()
{
InitializeComponent();
}
private void frmPIPETest_FormClosing(object sender, FormClosingEventArgs e)
{
System.Media.SystemSounds.Beep.Play();
DialogResult dialog = MessageBox.Show("Do you really want to exit?",
"Exit Program",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2);
if (dialog == DialogResult.Yes)
{
Application.ExitThread();
}
else
{
e.Cancel = true;
}
}
private void btnBack_Click(object sender, EventArgs e)
{
System.Media.SystemSounds.Beep.Play();
DialogResult dialog = MessageBox.Show("Go back to topic selection?",
"Return",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2);
if (dialog == DialogResult.Yes)
{
frmPIPE frm = new frmPIPE();
frm.Show();
Hide();
}
}
int i = 0;
private void timer1_Tick(object sender, EventArgs e)
{
i++;
lblTimer.Text = i.ToString() + "s";
}
public qbank()
{
IEnumerable<qbank> content = new List<qbank>
var random = new Random();
var result = content
.Select(c =>
{
var strings = new[]
{
c.C1,
c.C2,
c.C3,
c.C4,
}.OrderBy(x => random.Next())
.ToArray();
return new qbank
{
Question = c.Question,
C1 = strings[0],
C2 = strings[1],
C3 = strings[2],
C4 = strings[3],
};
})
.OrderBy(x => random.Next());
}
}
}
Im attaching pictures since there are errors to where I created my list.