Ejemplo n.º 1
0
void MainWindow::readResults(QString input)
{
    QTextStream in(&input); QString buffer; QuestionItem * item; double maxscore = 0.0;
    do {
        if (in.readLine() != "[Q_NAME]") { return; }
        buffer = in.readLine(); item = NULL;
        for (int i = 0; i < LQListWidget->count(); ++i) {
            if (current_test_questions.value(LQListWidget->item(i))->name() == buffer) {
                item = current_test_questions.value(LQListWidget->item(i)); break;
            }
        }
        if (item == NULL) { in.readLine(); in.readLine(); continue; }
        if (in.readLine() != "[Q_C_ANS]") { return; }
        if (current_db_multiple_ans_support) {
            item->setCorrectAnswers((Question::Answer)in.readLine().toInt());
        } else {
            item->setCorrectAnswers(Question::convertOldAnsNumber(in.readLine().toInt()));
        }
        current_test_score += item->score();
        maxscore += item->maximumScore();
        if (current_db_itdb1_4_support) {
            if (in.readLine() != "[Q_EXPL]") { return; }
            item->setExplanation(in.readLine());
        }
    } while (!in.atEnd());
    scoreLabel->setText(tr("%1 out of %2 (%3)").arg(current_test_score).arg(maxscore).arg(current_test_passmark.check(current_test_questions.values()) ? tr("PASSED") : tr("FAILED")));
    loadResults(resultsTableWidget);
}
Ejemplo n.º 2
0
int main(int argc, char ** argv){
     loadData(data,true);
     loadTestData();
     loadUserItemData(users, items, data);
     for(int i = 0; i < data.size(); ++i) nu[data[i].user]++;
#define K 7
     vector< vector< map<int,float> > > tests(K);
     vector< float > weight(K);
     int k = 0;
     loadResults("../ret2/results-knni-iuf.txt.0", tests[k]); weight[k] = 1; ++k;
     loadResults("../ret2/results-knnu-iif.txt.0", tests[k]); weight[k] = 1; ++k;
     loadResults("../ret2/results-knnui.txt.0", tests[k]); weight[k] = 1; ++k;
     loadResults("../ret2/results-language.txt.0", tests[k]); weight[k] = 0.4; ++k;
     loadResults("../ret2/results-repos.txt.0", tests[k]); weight[k] = 0.4; ++k;
     loadResults("../ret2/results-reponame.txt.0", tests[k]); weight[k] = 0.2; ++k;
     loadResults("../ret2/results-pop-nic.txt.0", tests[k]); weight[k] = 0.01; ++k;
     srand(time(0));
     int j = 0;
     for(int step = 0; step < 20; ++step){
          int i = j % K;
          ++j;
          float w0 = weight[i];
          int r0 = bag(tests, weight);
          weight[i] *= (1 + 0.5 * (rand01() - 0.5));
          int r1 = bag(tests, weight);
          if(r1 <= r0)
               weight[i] = w0;
          cout << step << "\t" << r0 << "\t" << r1 << endl;
     }

     for(int i = 0; i < weight.size(); ++i) cout << i << "\t" << weight[i] << endl;
     return 0;
}
Ejemplo n.º 3
0
MainWgt::MainWgt(QWidget *parent) :
  QWidget(parent),
  ui(new Ui::MainWgt)
{
  ui->setupUi(this);

  resultsList = ui->lwResults;

  pMenu = ui->pageMenu;
  pGame = ui->pageGame;
  pResults = ui->pageResults;

  stacked = new SlidingStackedWidget(this);
  stacked->setSpeed(500);
  stacked->addWidget(pMenu);
  stacked->addWidget(pGame);
  stacked->addWidget(pResults);
  stacked->slideInIdx(stacked->indexOf(pMenu));
  layout()->addWidget(stacked);
  ui->stackedWidget->hide();
  ui->stackedWidget->deleteLater();

  scene = new QGraphicsScene();
  ui->gw->setScene(scene);

  ui->gw->setRenderHint(QPainter::Antialiasing);
  ui->gw->setBackgroundBrush(QPixmap(":/img/block_wall.png"));
  ui->gw->setCacheMode(QGraphicsView::CacheBackground);
  ui->gw->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);

  placeSemkoTimer = new QTimer();
  connect(placeSemkoTimer,SIGNAL(timeout ()), this, SLOT(placeSemko()));

  loadResults();

  musicOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
  musicOutput->setVolume(0.5);
  notifyOutput = new Phonon::AudioOutput(Phonon::NotificationCategory, this);
  notifyOutput->setVolume(0.7);

  moMainTheme = new Phonon::MediaObject(this);
  connect(moMainTheme,SIGNAL(finished()),moMainTheme,SLOT(play()));
  moMainTheme->setCurrentSource(Phonon::MediaSource(QApplication::applicationDirPath() + "/sounds/mainTheme.mp3"));
  Phonon::createPath(moMainTheme, musicOutput);

  moGameOver  = new Phonon::MediaObject(this);
  moGameOver->setCurrentSource(Phonon::MediaSource(QApplication::applicationDirPath() + "/sounds/gameOver.mp3"));
  Phonon::createPath(moGameOver, notifyOutput);
}
Ejemplo n.º 4
0
void MainWindow::finish()
{
    switch (QMessageBox::information(this, tr("Finish the exam"), tr("Are you sure you want to finish? Once you click Finish there is no going back."), tr("&Finish"), tr("&Cancel"), 0, 1)) {
         case 0: // Finish
              break;
         case 1: // Cancel
              return; break;
    }
    mainStackedWidget->setCurrentIndex(3);
    if (current_test_results_sent) { return; }
    current_test_results_sent = true;
    current_test_time_finished = QDateTime::currentDateTime().toString("yyyy.MM.dd-hh:mm");
    sendResults();
    if (rbtnFromFile->isChecked()) { loadResults(resultsTableWidget); }
}
Ejemplo n.º 5
0
void MainWindow::updateTime()
{
    if (current_test_time_remaining > 1) {
        timer.start(60000);
        current_test_time_remaining--;
        remainingTimeLcdNumber->display(current_test_time_remaining);
        remainingTimeProgressBar->setValue(current_test_time_remaining);
    } else {
        if (mainStackedWidget->currentIndex() != 2) { return; }
        if (current_test_results_sent) { return; }
        current_test_results_sent = true;
        current_test_time_finished = QDateTime::currentDateTime().toString("yyyy.MM.dd-hh:mm");
        mainStackedWidget->setCurrentIndex(3); sendResults();
        if (rbtnFromFile->isChecked()) { loadResults(resultsTableWidget); }
        QMessageBox::information(this, tr("Exam finished"), tr("You have run out of time. Your answers are being sent."));
    }
}
Ejemplo n.º 6
0
int main()
{
	addLog("===========================================================");
	addLog("NWChecker started");
	string curdir=getCurrentDir();
	loadResults();
	if (parseConfig())
		return 1;
	checkAll();
	SetCurrentDirectory(curdir.c_str());
	generateHTML();
	saveResults();
	if(silentMode) {
		int i;
		cin>>i;
	}
	return 0;
}
Ejemplo n.º 7
0
	void callEpilogue(Thread* t)
	{
		if(t->hooks & CrocThreadHook_Ret)
			callHook(t, CrocThreadHook_Ret);

		// Get results before popARTo takes them away
		auto destSlot = t->currentAR->returnSlot;
		auto expectedResults = t->currentAR->expectedResults;
		auto results = loadResults(t);

		// Pop the act record (which also closes upvals and removes EH frames)
		popARTo(t, t->arIndex - 1);

		// Copy and adjust results
		bool isMultRet = expectedResults == -1;
		auto actualResults = results.length;

		if(isMultRet)
			expectedResults = actualResults;

		auto stk = t->stack;
		auto slotAfterRets = destSlot + expectedResults;

		if(cast(uword)expectedResults <= actualResults)
			stk.slicea(destSlot, slotAfterRets, results.slice(0, expectedResults));
		else
		{
			stk.slicea(destSlot, destSlot + actualResults, results);
			stk.slice(destSlot + actualResults, slotAfterRets).fill(Value::nullValue);
		}

		t->numYields = actualResults;

		// Set stack index appropriately; last case happens in native -> native calls
		if(t->arIndex == 0 || isMultRet || t->currentAR->savedTop < slotAfterRets)
			t->stackIndex = slotAfterRets;
		else
			t->stackIndex = t->currentAR->savedTop;

		assert(t->stackIndex > 0);
	}