Page History: Jetfire Code: QnA
Compare Page Revisions
Page Revision: 2009/07/28 21:58
Jetfire Code: QnA Class
The Jetfire Code Class for QnA (Questions and Answers) is shown below in the box. This simple class is inherited by Quizes and Surveys that are designed using
Form Maker.
// Q n A W O R K F L O W
//===================================================================================
// QnA.txt
//===================================================================================
// Copyright (C) 2008 TrackerRealm Corporation
// This file is part of Jetfire. http://Jetfire.ca
//
// Jetfire is open software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, version 3 of the License.
//
// Jetfire is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with Jetfire.
// If not, see http://www.gnu.org/licenses.
// REMOVAL OF THIS NOTICE IS VIOLATION OF THE COPYRIGHT.
//===================================================================================
namespace JetfireBase
{
// This workflow provides a Base Class for associating Questions and Answers.
public workflow QnA
{
// Need to add default Constructor.
private QnA()
{
this.Subject = "What is your name?";
this.inputType = QnAInput.Text;
this.Answers.Add("Bob");
}
// Define a question where the user enters one or more yes/no, decimal, integer, selection or text answers
// Selection is a list from which the user may select an answer
public QnA(string question, int numberOfAnswers, QnAInput inputType)
{
string s = "";
this.Subject = question;
this.inputType = inputType;
if (inputType == QnAInput.YesNo)
{ // Pre-populate the list for the display
this.Answers.Add(false);
return;
}
if (inputType == QnAInput.Decimal)
{ // Pre-populate the list for the display
this.Answers.Add(0);
return;
}
if (inputType == QnAInput.Integer)
{ // Pre-populate the list for the display
this.Answers.Add(0);
return;
}
if (inputType == QnAInput.Number)
{ // Pre-populate the list for the display
this.Answers.Add(0);
return;
}
if (inputType == QnAInput.Text)
{ // Pre-populate the list for the display
this.Answers.Add(s);
return;
}
if (inputType == QnAInput.Text_Long)
{ // Pre-populate the list for the display
this.Answers.Add(s);
return;
}
if (inputType == QnAInput.DateTime)
{ // Pre-populate the list for the display
this.Answers.Add(DateTime.Today);
return;
}
if (inputType == QnAInput.Date)
{ // Pre-populate the list for the display
this.Answers.Add(Date.Today);
return;
}
if (inputType == QnAInput.Duration)
{ // Pre-populate the list for the display
this.Answers.Add(TimeSpan.Zero);
return;
}
if (inputType == QnAInput.Selection)
{ // Pre-populate the list for the display
for (int i=0; i