Hi,
first of all you will need to
clone a poll web part. It uses PollView control which source code you can find in
~/CMSModules/Polls/Controls/PollView.ascx. You can copy paste it and rename for example QuizView. Then in the cloned poll web part change path to control to use your QuizView.
Now you will need to add a custom field
IsCorrectAnswerto
Polls_PollAnswer table. This can be done easily using field editor in the Site Manager - Development - System tables. The table is not visible in this location by default. To change it you need to update column
ClassShowAsSystemTable in the CMS_Class table. Look for class with name Polls - PollAnswer and change value of column ClassShowAsSystemTable to True. Now you are able to add a custo boolean field into table.
Now you can modify UI of the
CMS Desk - Tools - Polls - <edit poll> answers:
1. First of all you need to change grid definition in the file
~/CMSModules/Polls/Controls/AnswerList.xml and add a following line into xml file:
<column source="IsCorrectAnswer" caption="$IsCorrectAnswer$" wrap="false" />2. Now you can change
AnswerList file in the same location:
- in the Page_Load method add a column name:
uniGrid.Columns = "AnswerID, AnswerText, AnswerCount, AnswerEnabled, IsCorrectAnswer";3. Finally, to be able to modify value of your answer modify
AnswerEdit file:
- to Set fields section (around 202 line) add a line with SetValue:
// Set the fields
pollAnswerObj.AnswerEnabled = chkAnswerEnabled.Checked;
pollAnswerObj.AnswerText = txtAnswerText.Text.Trim();
pollAnswerObj.AnswerCount = ValidationHelper.GetInteger(this.txtVotes.Text, 0);
pollAnswerObj.SetValue("IsCorrectAnswer", chckCorrect.Checked);
- chckCorrect is an additional control inserted on markup:
<tr>
<td class="FieldLabel">
<cms:LocalizedLabel runat="server" ID="LocalizedLabel1" EnableViewState="false"
Text="CorrectAnswer" DisplayColon="true" />
</td>
<td>
<asp:CheckBox ID="chckCorrect" runat="server" Checked="true" />
</td>
</tr>
- and in Load field section add a line with ValidationHelper (around line 150):
// Load the fields
txtAnswerText.Text = pollAnswerObj.AnswerText;
chkAnswerEnabled.Checked = pollAnswerObj.AnswerEnabled;
txtVotes.Text = pollAnswerObj.AnswerCount.ToString();
chckCorrect.Checked = ValidationHelper.GetBoolean(pollAnswerObj.GetValue("IsCorrectAnswer"),false);
plcVotes.Visible = true;
The last thing is to modify your Quiz view control to check if the selected value is correct and display and provide an appropriate information to your user.
Best regards,
Ivana Tomanickova