Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) MultipleChoiceQuestionDialog

 

MultipleChoiceQuestionDialog is a dialog for MultipleChoiceQuestion.

 

 

 

 

 

multiplechoicequestiondialog.h

 

//---------------------------------------------------------------------------
/*
MultipleChoiceQuestionDialog, dialog for MultipleChoiceQuestion
Copyright (C) 2011 Richel Bilderbeek

This program is free 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, either version 3 of the License, or
(at your option) any later version.

This program 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 this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/CppMultipleChoiceQuestionDialog.htm
//---------------------------------------------------------------------------
#ifndef MULTIPLECHOICEQUESTIONDIALOG_H
#define MULTIPLECHOICEQUESTIONDIALOG_H
//---------------------------------------------------------------------------
#include <boost/shared_ptr.hpp>
//---------------------------------------------------------------------------
#include "questiondialog.h"
//---------------------------------------------------------------------------
struct MultipleChoiceQuestion;
//---------------------------------------------------------------------------
struct MultipleChoiceQuestionDialog : public QuestionDialog
{
  MultipleChoiceQuestionDialog(
    const boost::shared_ptr<MultipleChoiceQuestion>& question
    = CreateDefaultQuestion());

  MultipleChoiceQuestionDialog(const std::string& question);

  ///Obtain the version
  static const std::string GetVersion();

  ///Obtain the version history
  static const std::vector<std::string> GetVersionHistory();

  private:
  ///Create a default Question
  //static MultipleChoiceQuestion * CreateDefaultQuestion();
  static boost::shared_ptr<MultipleChoiceQuestion> CreateDefaultQuestion();
};
//---------------------------------------------------------------------------
#endif // MULTIPLECHOICEQUESTIONDIALOG_H

 

 

 

 

 

multiplechoicequestiondialog.cpp

 

//---------------------------------------------------------------------------
/*
MultipleChoiceQuestionDialog, dialog for MultipleChoiceQuestion
Copyright (C) 2011 Richel Bilderbeek

This program is free 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, either version 3 of the License, or
(at your option) any later version.

This program 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 this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/CppMultipleChoiceQuestionDialog.htm
//---------------------------------------------------------------------------
#include <cassert>
//---------------------------------------------------------------------------
#include "multiplechoicequestiondialog.h"
#include "multiplechoicequestion.h"
#include "question.h"
//---------------------------------------------------------------------------
MultipleChoiceQuestionDialog::MultipleChoiceQuestionDialog(
  const boost::shared_ptr<MultipleChoiceQuestion>& question)
  //const MultipleChoiceQuestion * const question)
  : QuestionDialog(question)
{
  assert(CanSubmit());
  assert(!HasSubmitted());
  assert(GetQuestion());
}
//---------------------------------------------------------------------------
MultipleChoiceQuestionDialog::MultipleChoiceQuestionDialog(const std::string& question)
  : QuestionDialog(
    boost::shared_ptr<MultipleChoiceQuestion>(new
      MultipleChoiceQuestion(question)))
{
  assert(CanSubmit());
  assert(!HasSubmitted());
  assert(GetQuestion());
}
//---------------------------------------------------------------------------
///Create a default Question
/*
MultipleChoiceQuestion * MultipleChoiceQuestionDialog::CreateDefaultQuestion()
{
  return new MultipleChoiceQuestion(
      "*",
      "1+2=",
      "3",
      {"1","2","4","5"} );
}
*/
//---------------------------------------------------------------------------
///Create a default Question
boost::shared_ptr<MultipleChoiceQuestion> MultipleChoiceQuestionDialog::CreateDefaultQuestion()
{
  return boost::shared_ptr<MultipleChoiceQuestion>(
    new MultipleChoiceQuestion(
      "*",
      "1+2=",
      "3",
      {"1","2","4","5"}
    )
  );
}
//---------------------------------------------------------------------------
const std::string MultipleChoiceQuestionDialog::GetVersion()
{
  return "1.0";
}
//---------------------------------------------------------------------------
const std::vector<std::string> MultipleChoiceQuestionDialog::GetVersionHistory()
{
  std::vector<std::string> v;
  v.push_back("2011-06-29: version 1.0: initial version");
  return v;
}
//---------------------------------------------------------------------------

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml