bool Question::operator < (const Question & that) const { if(this->getQuestion() != that.getQuestion()) { return this->getQuestion() < that.getQuestion(); } return this->getAnswer() < that.getAnswer(); }
bool Import::datamatrixToQuestions(){ bool success = false; cout << "START READING DATA TO QUESTION OBJECTS" << endl; // fills CSV Data from vector < vector <...> > datamatrix to questiondata objects. int m = dataMatrix[0].size(); // check dimensions of datamatix if(m!=questionTypes.size()){ cout << "ERROR: number of survey questions != number of questiontypes" << endl; QMessageBox msgBox; msgBox.setText("FEHLER: Der ausgewählte Ausstellungstyp passt nicht zur .CSV Datei."); msgBox.setInformativeText("Bitte richtigen Ausstellungstyp wählen."); msgBox.setDefaultButton(QMessageBox::Ok); int ret = msgBox.exec(); success = false; return success; } int id=0; for(int i=0; i<m;++i){ if(questionTypes[i].toInt()!=0){ Question *tempQuestion = new Question; tempQuestion->setQuestiontype(questionTypes[i].toInt()); tempQuestion->setQuestion(QString::fromStdString(dataMatrix[0][i])); tempQuestion->setSubquestion(QString::fromStdString(dataMatrix[1][i])); if(tempQuestion->getQuestionType()!=6) tempQuestion->setDataFromStdStringMatrix(dataMatrix,i); else tempQuestion->setTextAnswersFromStdStringMatrix(dataMatrix,i); if(tempQuestion->getQuestion()!="") ++id; tempQuestion->write_ID(id); // a question and its subquestions share the same id questions.push_back(*tempQuestion); delete tempQuestion; } } success=true; return success; }
void MainWindow::changeQuestion(Question question) { ui->question->setText(question.getQuestion()); currentQuestion = question; ui->answer->setText(""); ui->right->setHidden(true); ui->wrong->setHidden(true); ui->showAnswer->setHidden(false); }
void OpenQuestionSet::openNewQuestion() { Question q = allQuestionSet->getNewQuestioin(); if (q.getQuestion().empty()) { sizeOfOpenQuestion--; } else { openQuestion.push_back(q); } }
/** *This function builds a packet that presents a question according to the protocol. *Input: Index of question. *Output: Question packet as the protocol. **/ string Game::buildQuestionPacket(int questionNo) { Question * q = _questions[questionNo]; int len, i; string packet, str; string * answers = q->getAnswers(); packet = to_string(SEND_QUESTION); str = q->getQuestion(); len = str.size(); packet += Helper::getPaddedNumber(len, 3) + str; for (i = 0; i < 4; i++) { str = answers[i]; len = str.size(); packet += Helper::getPaddedNumber(len, 3) + str; } return packet; }
bool Question::operator == (const Question & that) const { return this->getQuestion() == that.getQuestion() && this->getAnswer() == that.getAnswer(); }