0
Reply

Assigning score to quiz

JOHN JOHNNNY

JOHN JOHNNNY

Oct 28 2014 4:34 AM
636
Good day
The code below shows quiz app with questions, answers and submit button to move to the next question when option is chosen and clicked
XAML:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<StackPanel>
<TextBlock x:Name="question" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" TextWrapping="Wrap"/>
<RadioButton x:Name="opt1" GroupName="g1"></RadioButton>
<RadioButton x:Name="opt2" GroupName="g1"></RadioButton>
<RadioButton x:Name="opt3" GroupName="g1"></RadioButton>
<RadioButton x:Name="opt4" GroupName="g1"></RadioButton>
<Button Content="Submit" HorizontalAlignment="Left" Height="79" Margin="52,0,0,0" Width="198" Click="Button_Click"/>
</StackPanel>
</Grid> CS:
int currentNum = 0;
string[] questions = new string[] { "What is 9 cubed?", "What is 6+3?", "What type of animal is tuna sandwiches made from?", "What is 18 backwards?" };
string[] options = new string[] { "9", "81", "729", "2", "4", "2", "9", "1", "zebra", "aardvark", "fish", "gnu", "31", "81", "91", "88" };
string[] Answers = new string[] { "81", "9", "fish", "81 ", };
public MainPage()
{
InitializeComponent();
generateBinding
(currentNum);
}
public void generateBinding(int currentNum)
{
question
.Text = questions[currentNum];
opt1
.Content = answers[currentNum * 4];
opt2
.Content = answers[currentNum * 4 + 1];
opt3
.Content = answers[currentNum * 4 + 2];
opt4
.Content = answers[currentNum * 4 + 3];
}
private void Button_Click(object sender, RoutedEventArgs e)
{ currentNum++;
generateBinding
(currentNum);
} Here are my questions
-How will i make the submit button to show the number of wrong answer, correct answer and score in a message box
on clicking on submit button after attempting the last question
-I will also like to add a timer/stop watch in order to add duration to the quiz
Regards and reply soon