Go back to Richel Bilderbeek's homepage.

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

 

 

 

 

 

(C++) TestExercise

 

TestExercise is a tool to test the Exercise class.

 

 

 

 

 

Downloads

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./ToolTestExercise/ToolTestExerciseDesktop.pro

 

include(../../DesktopApplication.pri)
include(../../Libraries/BigInteger.pri)
include(../../Libraries/Boost.pri)
include(../../Libraries/GeneralConsole.pri)
include(../../Libraries/GeneralDesktop.pri)


include(../../Classes/CppCanvas/CppCanvas.pri)
include(../../Classes/CppContainer/CppContainer.pri)
include(../../Classes/CppExercise/CppExercise.pri)
include(../../Classes/CppImageCanvas/CppImageCanvas.pri)
include(../../Classes/CppMultipleChoiceQuestion/CppMultipleChoiceQuestion.pri)
include(../../Classes/CppMultipleChoiceQuestionDialog/CppMultipleChoiceQuestionDialog.pri)
include(../../Classes/CppOpenQuestion/CppOpenQuestion.pri)
include(../../Classes/CppOpenQuestionDialog/CppOpenQuestionDialog.pri)
include(../../Classes/CppQuestion/CppQuestion.pri)
include(../../Classes/CppQtQuestionDialog/CppQtQuestionDialog.pri)
include(../../Classes/CppTribool/CppTribool.pri)

include(ToolTestExerciseDesktop.pri)

SOURCES += qtmain.cpp

 

 

 

 

 

Qt project file: ./ToolTestExercise/ToolTestExerciseWebsite.pro

 

include(../../WebApplication.pri)
include(../../Libraries/BigInteger.pri)
include(../../Libraries/BoostAll.pri)
include(../../Libraries/Wt.pri)

include(../../Libraries/GeneralConsole.pri)
include(../../Libraries/GeneralWeb.pri)


include(../../Classes/CppCanvas/CppCanvas.pri)
include(../../Classes/CppExercise/CppExercise.pri)
include(../../Classes/CppImageCanvas/CppImageCanvas.pri)
include(../../Classes/CppMultipleChoiceQuestion/CppMultipleChoiceQuestion.pri)
include(../../Classes/CppMultipleChoiceQuestionDialog/CppMultipleChoiceQuestionDialog.pri)
include(../../Classes/CppOpenQuestion/CppOpenQuestion.pri)
include(../../Classes/CppOpenQuestionDialog/CppOpenQuestionDialog.pri)
include(../../Classes/CppQuestion/CppQuestion.pri)
include(../../Classes/CppQtQuestionDialog/CppQtQuestionDialog.pri)
include(../../Classes/CppWtExercise/CppWtExercise.pri)
include(../../Classes/CppWtMultipleChoiceQuestionDialog/CppWtMultipleChoiceQuestionDialog.pri)
include(../../Classes/CppWtOpenQuestionDialog/CppWtOpenQuestionDialog.pri)
include(../../Classes/CppWtQuestionDialog/CppWtQuestionDialog.pri)

include(ToolTestExerciseWebsite.pri)

SOURCES += wtmain.cpp

 

 

 

 

 

./ToolTestExercise/ToolTestExerciseConsole.pri

 

INCLUDEPATH += \
    ../../Tools/ToolTestExercise

SOURCES += \
    ../../Tools/ToolTestExercise/testexercisemenudialog.cpp

HEADERS += \
    ../../Tools/ToolTestExercise/testexercisemenudialog.h

OTHER_FILES += \
    ../../Tools/ToolTestExercise/Licence.txt

RESOURCES += \
    ../../Tools/ToolTestExercise/ToolTestExercise.qrc

 

 

 

 

 

./ToolTestExercise/ToolTestExerciseDesktop.pri

 

include(../../Tools/ToolTestExercise/ToolTestExerciseConsole.pri)

 

 

 

 

 

./ToolTestExercise/ToolTestExerciseWebsite.pri

 

include(../../Tools/ToolTestExercise/ToolTestExerciseConsole.pri)

SOURCES += \
    ../../Tools/ToolTestExercise/wttestexercisemaindialog.cpp \
    ../../Tools/ToolTestExercise/wttestexercisemenudialog.cpp

HEADERS  += \
    ../../Tools/ToolTestExercise/wttestexercisemaindialog.h \
    ../../Tools/ToolTestExercise/wttestexercisemenudialog.h

 

 

 

 

 

./ToolTestExercise/qtmain.cpp

 

//---------------------------------------------------------------------------
/*
TestExercise, tool to test the Exercise class
Copyright (C) 2011-2014 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/ToolTestExercise.htm
//---------------------------------------------------------------------------
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include <QApplication>
#include "qttestexercisemenudialog.h"
#pragma GCC diagnostic pop

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  ribi::QtTestExerciseMenuDialog w;
  w.show();
  return a.exec();
}

 

 

 

 

 

./ToolTestExercise/testexercisemenudialog.h

 

//---------------------------------------------------------------------------
/*
TestExercise, tool to test the Exercise class
Copyright (C) 2011-2015 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/ToolTestExercise.htm
//---------------------------------------------------------------------------
#ifndef TESTEXERCISEMENUDIALOG_H
#define TESTEXERCISEMENUDIALOG_H

#include "menudialog.h"


namespace ribi {

///The logic behind the menu dialog
struct TestExerciseMenuDialog final : public MenuDialog
{
  About GetAbout() const noexcept override;
  Help GetHelp() const noexcept override;
  boost::shared_ptr<const Program> GetProgram() const noexcept override;
  std::string GetVersion() const noexcept override;
  std::vector<std::string> GetVersionHistory() const noexcept override;

  private:
  int ExecuteSpecific(const std::vector<std::string>& argv) noexcept override;

  #ifndef NDEBUG
  static void Test() noexcept;
  #endif
};

} //~namespace ribi

#endif // TESTEXERCISEMENUDIALOG_H

 

 

 

 

 

./ToolTestExercise/testexercisemenudialog.cpp

 

//---------------------------------------------------------------------------
/*
TestExercise, tool to test the Exercise class
Copyright (C) 2011-2015 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/ToolTestExercise.htm
//---------------------------------------------------------------------------
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include "testexercisemenudialog.h"

#include <cassert>
#include <iostream>

#include "exercise.h"
#include "multiplechoicequestion.h"
#include "multiplechoicequestiondialog.h"
#include "openquestion.h"
#include "openquestiondialog.h"
#include "testtimer.h"
#include "question.h"
#include "questiondialog.h"
#include "richelbilderbeekprogram.h"
#include "trace.h"
#pragma GCC diagnostic pop

int ribi::TestExerciseMenuDialog::ExecuteSpecific(const std::vector<std::string>& argv) noexcept
{
  #ifndef NDEBUG
  Test();
  #endif
  const int argc = static_cast<int>(argv.size());
  if (argc == 1)
  {
    std::cout << GetHelp() << '\n';
    return 1;
  }
  assert(!"TODO");
  return 1;
}

ribi::About ribi::TestExerciseMenuDialog::GetAbout() const noexcept
{
  About a(
    "Richel Bilderbeek",
    "TestExercise",
    "tool to test the Exercise class",
    "the 2nd of October 2011",
    "2011-2015",
    "http://www.richelbilderbeek.nl/ToolTestExercise.htm",
    GetVersion(),
    GetVersionHistory());
  a.AddLibrary("Exercise version: " + Exercise::GetVersion());
  a.AddLibrary("MultipleChoiceQuestion version: " + MultipleChoiceQuestion::GetVersion());
  a.AddLibrary("MultipleChoiceQuestionDialog version: " + MultipleChoiceQuestionDialog::GetVersion());
  a.AddLibrary("OpenQuestion version: " + OpenQuestion::GetVersion());
  a.AddLibrary("OpenQuestionDialog version: " + OpenQuestionDialog::GetVersion());
  a.AddLibrary("Question version: " + Question::GetVersion());
  a.AddLibrary("QuestionDialog version: " + QuestionDialog::GetVersion());
  a.AddLibrary("Trace version: " + Trace::GetVersion());
  return a;
}

ribi::Help ribi::TestExerciseMenuDialog::GetHelp() const noexcept
{
  return Help(
    this->GetAbout().GetFileTitle(),
    this->GetAbout().GetFileDescription(),
    {

    },
    {

    }
  );
}

boost::shared_ptr<const ribi::Program> ribi::TestExerciseMenuDialog::GetProgram() const noexcept
{
  const boost::shared_ptr<const Program> p {
    new ProgramTestExercise
  };
  assert(p);
  return p;
}
std::string ribi::TestExerciseMenuDialog::GetVersion() const noexcept
{
  return "1.1";
}

std::vector<std::string> ribi::TestExerciseMenuDialog::GetVersionHistory() const noexcept
{
  return {
    "2011-09-26: Version 1.0: initial version",
    "2013-11-05: version 1.1: conformized for ProjectRichelBilderbeekConsole"
  };
}

#ifndef NDEBUG
void ribi::TestExerciseMenuDialog::Test() noexcept
{
  {
    static bool is_tested{false};
    if (is_tested) return;
    is_tested = true;
  }
  const TestTimer test_timer(__func__,__FILE__,1.0);
}
#endif

 

 

 

 

 

./ToolTestExercise/wtmain.cpp

 

//---------------------------------------------------------------------------
/*
TestExercise, tool to test the Exercise class
Copyright (C) 2011-2014 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/ToolTestExercise.htm
//---------------------------------------------------------------------------
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include <Wt/WApplication>
#include <Wt/WEnvironment>

#include "trace.h"
#include "wtautoconfig.h"
#include "wttestexercisemenudialog.h"
#pragma GCC diagnostic pop

struct WtApplication : public Wt::WApplication
{
  WtApplication(const Wt::WEnvironment& env)
    : Wt::WApplication(env)
  {
    this->setTitle("TestExercise");
    this->useStyleSheet("wt.css");
    root()->addWidget(new ribi::WtTestExerciseMenuDialog);
  }
};

Wt::WApplication *createApplication(
  const Wt::WEnvironment& env)
{
  return new WtApplication(env);
}

int main(int argc, char **argv)
{
  { START_TRACE(); }
  ribi::WtAutoConfig a(argc,argv,createApplication);
  ribi::WtAutoConfig::SaveDefaultStylesheet();
  return a.Run();
}

 

 

 

 

 

./ToolTestExercise/wttestexercisemaindialog.h

 

//---------------------------------------------------------------------------
/*
TestExercise, tool to test the Exercise class
Copyright (C) 2011-2015 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/ToolTestExercise.htm
//---------------------------------------------------------------------------
#ifndef WTTESTEXERCISEMAINDIALOG_H
#define WTTESTEXERCISEMAINDIALOG_H

#include <vector>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include <boost/shared_ptr.hpp>

#include <Wt/WContainerWidget>
#pragma GCC diagnostic pop

namespace ribi {

struct WtExercise;

struct WtTestExerciseMainDialog : public Wt::WContainerWidget
{
  WtTestExerciseMainDialog();

  private:
  struct Ui
  {
    Ui();
    Wt::WTextArea * const m_area_input;
    Wt::WPushButton * const m_button_submit;
    Wt::WLineEdit * const m_edit_wait_correct;
    Wt::WLineEdit * const m_edit_wait_incorrect;
    Wt::WLabel * const m_label_status;
    WtExercise * const m_exercise_dialog;
  } ui;

  void OnSubmit();
};

} //~namespace ribi

#endif // WTTESTEXERCISEMAINDIALOG_H

 

 

 

 

 

./ToolTestExercise/wttestexercisemaindialog.cpp

 

//---------------------------------------------------------------------------
/*
TestExercise, tool to test the Exercise class
Copyright (C) 2011-2015 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/ToolTestExercise.htm
//---------------------------------------------------------------------------
#include <cstdio>
#include <fstream>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include <boost/lexical_cast.hpp>
#include <boost/numeric/conversion/cast.hpp>

#include <Wt/WBreak>
#include <Wt/WLabel>
#include <Wt/WLineEdit>
#include <Wt/WPushButton>
#include <Wt/WTextArea>

#include "exercise.h"
#include "multiplechoicequestion.h"
#include "multiplechoicequestiondialog.h"
#include "openquestion.h"
#include "openquestiondialog.h"
#include "questiondialog.h"
//#include "trace.h"
#include "wtaboutdialog.h"
#include "wtmultiplechoicequestiondialog.h"
#include "wtopenquestiondialog.h"
#include "wtexercise.h"
#include "wttestexercisemaindialog.h"
#pragma GCC diagnostic pop

ribi::WtTestExerciseMainDialog::Ui::Ui()
  : m_area_input(new Wt::WTextArea),
    m_button_submit(new Wt::WPushButton),
    m_edit_wait_correct(new Wt::WLineEdit),
    m_edit_wait_incorrect(new Wt::WLineEdit),
    m_label_status(new Wt::WLabel),
    m_exercise_dialog(new WtExercise)
{

}

ribi::WtTestExerciseMainDialog::WtTestExerciseMainDialog()
  : ui{}
{
  this->addWidget(new Wt::WLabel("Waiting time correct (msecs)"));
  this->addWidget(ui.m_edit_wait_correct);
  this->addWidget(new Wt::WBreak);
  this->addWidget(new Wt::WLabel("Waiting time incorrect (msecs)"));
  this->addWidget(ui.m_edit_wait_incorrect);
  this->addWidget(new Wt::WBreak);
  this->addWidget(new Wt::WBreak);
  this->addWidget(ui.m_area_input);
  this->addWidget(new Wt::WBreak);
  this->addWidget(ui.m_button_submit);
  this->addWidget(new Wt::WBreak);
  this->addWidget(ui.m_exercise_dialog);

  ui.m_button_submit->setText("Submit");
  ui.m_button_submit->clicked().connect(this,&ribi::WtTestExerciseMainDialog::OnSubmit);

  ui.m_edit_wait_correct->setText("1000");
  ui.m_edit_wait_incorrect->setText("5000");
  ui.m_exercise_dialog->setMinimumSize(600,400);
  ui.m_area_input->setMinimumSize(800,100);
  ui.m_area_input->setText(
    "-,1+1=?,2/two/Two\n"
    "-,1+1=?,2,1,3,4\n"
    "ToolTestExerciseQuestion.png,The solution of this equation is:,2/two/Two\n"
    "ToolTestExerciseQuestion.png,The solution of this equation is:,2,1,3,4");
}

void ribi::WtTestExerciseMainDialog::OnSubmit()
{
  //Test input
  {
    const std::string s = ui.m_edit_wait_correct->text().toUTF8();
    try
    {
      const int i = boost::lexical_cast<int>(s);
      if (i < 0)
      {
        ui.m_button_submit->setText("Waiting time correct must be a positive integer");
        return;
      }
    }
    catch (boost::bad_lexical_cast&)
    {
      ui.m_button_submit->setText("Waiting time correct must be an integer");
      return;
    }
  }
  {
    const std::string s = ui.m_edit_wait_incorrect->text().toUTF8();
    try
    {
      const int i = boost::lexical_cast<int>(s);
      if (i < 0)
      {
        ui.m_button_submit->setText("Waiting time incorrect must be a positive integer");
        return;
      }
    }
    catch (boost::bad_lexical_cast&)
    {
      ui.m_button_submit->setText("Waiting time incorrect must be an integer");
      return;
    }
  }
  ui.m_button_submit->setText("Submit");


  //Process valid input
  const std::string filename = "tmp.txt";
  //Save text to file
  {
    std::ofstream f(filename.c_str());
    assert(ui.m_area_input);
    f << ui.m_area_input->text().toUTF8();
  }
  //Read the WtExercise from file
  assert(ui.m_exercise_dialog);
  ui.m_exercise_dialog->SetQuestions(filename.c_str());
  ui.m_exercise_dialog->SetWaitingTimeCorrect(
    boost::lexical_cast<int>(ui.m_edit_wait_correct->text().toUTF8()));
  ui.m_exercise_dialog->SetWaitingTimeIncorrect(
    boost::lexical_cast<int>(ui.m_edit_wait_incorrect->text().toUTF8()));
  //Remove the file
  std::remove(filename.c_str());
  //Display info about the WtExercise
  {
    const std::string s
      = std::string("Loaded ")
      + boost::lexical_cast<std::string>(ui.m_exercise_dialog->GetExercise()->GetNumberOfQuestions())
      + std::string(" questions");
    ui.m_label_status->setText(s.c_str());
  }
}

 

 

 

 

 

./ToolTestExercise/wttestexercisemenudialog.h

 

//---------------------------------------------------------------------------
/*
TestExercise, tool to test the Exercise class
Copyright (C) 2011-2015 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/ToolTestExercise.htm
//---------------------------------------------------------------------------
#ifndef WTTESTEXERCISEMENUDIALOG_H
#define WTTESTEXERCISEMENUDIALOG_H


#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include <boost/scoped_ptr.hpp>

#include <Wt/WContainerWidget>
#pragma GCC diagnostic pop

namespace ribi {

struct TestExerciseMenuDialog;

struct WtTestExerciseMenuDialog : public Wt::WContainerWidget
{
  WtTestExerciseMenuDialog();
  private:
  Wt::WWidget * CreateNewAboutDialog() const;
  Wt::WWidget * CreateNewMainDialog() const;
  Wt::WWidget * CreateNewWelcomeDialog() const;

  boost::scoped_ptr<TestExerciseMenuDialog> m_dialog;
};

} //~namespace ribi

#endif // WTTESTEXERCISEMENUDIALOG_H

 

 

 

 

 

./ToolTestExercise/wttestexercisemenudialog.cpp

 

//---------------------------------------------------------------------------
/*
TestExercise, tool to test the Exercise class
Copyright (C) 2011-2015 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/ToolTestExercise.htm
//---------------------------------------------------------------------------
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include <cassert>

#include <Wt/WBreak>
#include <Wt/WContainerWidget>
#include <Wt/WGroupBox>
#include <Wt/WImage>
#include <Wt/WLabel>
#include <Wt/WStackedWidget>
#include <Wt/WMenu>
#include <Wt/WMenuItem>

#include "fileio.h"
#include "testexercisemenudialog.h"
#include "wtaboutdialog.h"
#include "wtautoconfig.h"
#include "wtexercise.h"
#include "wttestexercisemaindialog.h"
#include "wttestexercisemenudialog.h"
#include "wtmultiplechoicequestiondialog.h"
#include "wtopenquestiondialog.h"
#include "wtquestiondialog.h"

#include <QFile>
#pragma GCC diagnostic pop


ribi::WtTestExerciseMenuDialog::WtTestExerciseMenuDialog()
  : m_dialog(new TestExerciseMenuDialog)
{
{
    std::vector<std::string> image_names;
    image_names.push_back("ToolTestExerciseWelcome.png");
    image_names.push_back("ToolTestExerciseQuestion.png");
    image_names.push_back("ToolTestExerciseQuestionmark.png");

    for(const auto filename:image_names)
    {

      if (!fileio::FileIo().IsRegularFile(filename))
      {
        QFile f( (std::string(":/images/") + filename).c_str() );
        f.copy(filename.c_str());
      }
      if (!fileio::FileIo().IsRegularFile(filename))
      {
        std::cerr << "File not found: " << filename << '\n';
      }
      assert(fileio::FileIo().IsRegularFile(filename.c_str()));
    }
  }
  this->setContentAlignment(Wt::AlignCenter);
  {
    Wt::WLabel * const title = new Wt::WLabel("TestExercise");
    title->setStyleClass("title");
    this->addWidget(title);
  }
  //Menu
  {
    Wt::WStackedWidget * const contents = new Wt::WStackedWidget;
    Wt::WMenu * const menu = new Wt::WMenu(contents,Wt::Horizontal);
    menu->setStyleClass("menu");
    {
      Wt::WMenuItem * const item = new Wt::WMenuItem(
        "Welcome",
        CreateNewWelcomeDialog());
      menu->addItem(item);
    }
    {
      Wt::WMenuItem * const item = new Wt::WMenuItem(
        "Start",
        CreateNewMainDialog());
      menu->addItem(item);
    }
    {
      Wt::WMenuItem * const item = new Wt::WMenuItem(
        "About",
        CreateNewAboutDialog());
      menu->addItem(item);
    }
    //Display menu on top
    this->addWidget(menu);
    this->addWidget(new Wt::WBreak);
    //Display contents below menu
    this->addWidget(contents);
  }
}

Wt::WWidget * ribi::WtTestExerciseMenuDialog::CreateNewAboutDialog() const
{
  About a = m_dialog->GetAbout();
  a.AddLibrary("WtAutoConfig version: " + WtAutoConfig::GetVersion());
  a.AddLibrary("WtExercise version: " + WtExercise::GetVersion());
  a.AddLibrary("WtMultipleChoiceQuestionDialog version: " + WtMultipleChoiceQuestionDialog::GetVersion());
  a.AddLibrary("WtOpenQuestionDialog version: " + WtOpenQuestionDialog::GetVersion());
  a.AddLibrary("WtQuestionDialog version: " + WtQuestionDialog::GetVersion());
  WtAboutDialog * const d = new WtAboutDialog(a,false);
  assert(d);
  return d;
}

Wt::WWidget * ribi::WtTestExerciseMenuDialog::CreateNewMainDialog() const
{
  WtTestExerciseMainDialog * const d = new WtTestExerciseMainDialog;
  assert(d);
  return d;
}

Wt::WWidget * ribi::WtTestExerciseMenuDialog::CreateNewWelcomeDialog() const
{
  Wt::WContainerWidget * dialog = new Wt::WContainerWidget;
  dialog->setContentAlignment(Wt::AlignCenter);
  dialog->addWidget(new Wt::WBreak);
  new Wt::WLabel("Welcome to TestExercise",dialog);
  new Wt::WBreak(dialog);
  new Wt::WBreak(dialog);
  new Wt::WLabel("TestExercise tests the Exercise classes",dialog);
  new Wt::WBreak(dialog);
  new Wt::WBreak(dialog);
   Wt::WGroupBox * const box = new Wt::WGroupBox("Explanation",dialog);
  box->addWidget(new Wt::WImage("ToolTestExerciseWelcome.png"));
  return dialog;
}

 

 

 

 

 

./ToolTestExercise/zip.sh

 

#!/bin/sh
#zip packs all the files to port into a single .zip file,
#minicking the same folder structure
#Folder structure
# *
#   * Classes
#     * CppAbout
#     * CppExercise
#     * CppMultipleChoiceQuestion
#     * CppMultipleChoiceQuestionDialog
#     * CppOpenQuestion
#     * CppOpenQuestionDialog
#     * CppQuestion
#     * CppQuestionDialog
#     * CppTrace
#     * CppWtAboutDialog
#     * CppWtAutoConfig
#     * CppWtExercise
#     * CppWtMultipleChoiceQuestionDialog
#     * CppWtOpenQuestionDialog
#     * CppWtQuestionDialog
#   * Tools
#    * ToolTestExercise

FOLDERNAME=ToolTestExercise
FILENAME=$FOLDERNAME"Source_1_0"
ZIP_FILENAME=$FILENAME".zip"
HTM_FILENAME=$FILENAME".htm"

#echo "Converting DIA to PNG"
#dia --filter=png ToolTestExerciseArchitecture.dia

echo "Removing previous user's information"
rm *.user

echo "Mimicking file structure"
mkdir temp_zip
mkdir temp_zip/Classes
mkdir temp_zip/Classes/CppAbout
mkdir temp_zip/Classes/CppExercise
mkdir temp_zip/Classes/CppMultipleChoiceQuestion
mkdir temp_zip/Classes/CppMultipleChoiceQuestionDialog
mkdir temp_zip/Classes/CppOpenQuestion
mkdir temp_zip/Classes/CppOpenQuestionDialog
mkdir temp_zip/Classes/CppQuestion
mkdir temp_zip/Classes/CppQuestionDialog
mkdir temp_zip/Classes/CppTrace
mkdir temp_zip/Classes/CppWtAboutDialog
mkdir temp_zip/Classes/CppWtAutoConfig
mkdir temp_zip/Classes/CppWtExercise
mkdir temp_zip/Classes/CppWtMultipleChoiceQuestionDialog
mkdir temp_zip/Classes/CppWtOpenQuestionDialog
mkdir temp_zip/Classes/CppWtQuestionDialog
mkdir temp_zip/Tools
mkdir temp_zip/Tools/ToolTestExercise

echo "Copying files"
cp ../../Classes/CppAbout/*.* temp_zip/Classes/CppAbout
cp ../../Classes/CppExercise/*.* temp_zip/Classes/CppExercise
cp ../../Classes/CppMultipleChoiceQuestion/*.* temp_zip/Classes/CppMultipleChoiceQuestion
cp ../../Classes/CppMultipleChoiceQuestionDialog/*.* temp_zip/Classes/CppMultipleChoiceQuestionDialog
cp ../../Classes/CppOpenQuestion/*.* temp_zip/Classes/CppOpenQuestion
cp ../../Classes/CppOpenQuestionDialog/*.* temp_zip/Classes/CppOpenQuestionDialog
cp ../../Classes/CppQuestion/*.* temp_zip/Classes/CppQuestion
cp ../../Classes/CppQuestionDialog/*.* temp_zip/Classes/CppQuestionDialog
cp ../../Classes/CppTrace/*.* temp_zip/Classes/CppTrace
cp ../../Classes/CppWtAboutDialog/*.* temp_zip/Classes/CppWtAboutDialog
cp ../../Classes/CppWtAutoConfig/*.* temp_zip/Classes/CppWtAutoConfig
cp ../../Classes/CppWtExercise/*.* temp_zip/Classes/CppWtExercise
cp ../../Classes/CppWtMultipleChoiceQuestionDialog/*.* temp_zip/Classes/CppWtMultipleChoiceQuestionDialog
cp ../../Classes/CppWtOpenQuestionDialog/*.* temp_zip/Classes/CppWtOpenQuestionDialog
cp ../../Classes/CppWtQuestionDialog/*.* temp_zip/Classes/CppWtQuestionDialog
cp ../../Tools/ToolTestExercise/*.* temp_zip/Tools/ToolTestExercise

#echo "Compressing files"
cd temp_zip
zip -r $FILENAME Classes
#zip -r $FILENAME Libraries
#zip -r $FILENAME Projects
zip -r $FILENAME Tools
cd ..
cp "temp_zip/"$ZIP_FILENAME $ZIP_FILENAME

echo "Cleaning up"

#Classes
rm temp_zip/Classes/CppAbout/*.*
rm temp_zip/Classes/CppExercise/*.*
rm temp_zip/Classes/CppMultipleChoiceQuestion/*.*
rm temp_zip/Classes/CppMultipleChoiceQuestionDialog/*.*
rm temp_zip/Classes/CppOpenQuestion/*.*
rm temp_zip/Classes/CppOpenQuestionDialog/*.*
rm temp_zip/Classes/CppQuestion/*.*
rm temp_zip/Classes/CppQuestionDialog/*.*
rm temp_zip/Classes/CppTrace/*.*
rm temp_zip/Classes/CppWtAboutDialog/*.*
rm temp_zip/Classes/CppWtAutoConfig/*.*
rm temp_zip/Classes/CppWtExercise/*.*
rm temp_zip/Classes/CppWtMultipleChoiceQuestionDialog/*.*
rm temp_zip/Classes/CppWtOpenQuestionDialog/*.*
rm temp_zip/Classes/CppWtQuestionDialog/*.*

rmdir temp_zip/Classes/CppAbout
rmdir temp_zip/Classes/CppExercise
rmdir temp_zip/Classes/CppMultipleChoiceQuestion
rmdir temp_zip/Classes/CppMultipleChoiceQuestionDialog
rmdir temp_zip/Classes/CppOpenQuestion
rmdir temp_zip/Classes/CppOpenQuestionDialog
rmdir temp_zip/Classes/CppQuestion
rmdir temp_zip/Classes/CppQuestionDialog
rmdir temp_zip/Classes/CppTrace
rmdir temp_zip/Classes/CppWtAboutDialog
rmdir temp_zip/Classes/CppWtAutoConfig
rmdir temp_zip/Classes/CppWtExercise
rmdir temp_zip/Classes/CppWtMultipleChoiceQuestionDialog
rmdir temp_zip/Classes/CppWtOpenQuestionDialog
rmdir temp_zip/Classes/CppWtQuestionDialog
rmdir temp_zip/Classes

#Tools
rm temp_zip/Tools/ToolTestExercise/*.*
rmdir temp_zip/Tools/ToolTestExercise
rmdir temp_zip/Tools
rm temp_zip/*.*
rmdir temp_zip
echo "Done"

../ToolCodeToHtmlConsole-build-desktop/codetohtml --source "../"$FOLDERNAME
cp $FOLDERNAME".htm" $HTM_FILENAME
rm $FOLDERNAME".htm"

 

 

 

 

 

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