public String createMyHit( RequesterService service, ArrayList<Object> inputs, int numberOfOutputs, int numberOfAssignments) { /* Some parameters used for initializing MTurk HIT.*/ String title = "Select best description"; String description = "Please selec the best description."; String keywords = "selection, description"; Question question = new Question(inputs, numberOfOutputs); double reward = 0.01; long assignmentDurationInSeconds = 60 * 30; // 30 minutes long autoApprovalDelayInSeconds = 60; // 1 minute long lifetimeInSeconds = 60 * 60 * 24 * 7; // 1 week HIT hit = service.createHIT( null, title, description, keywords, question.getQuestion(), reward, assignmentDurationInSeconds, autoApprovalDelayInSeconds, lifetimeInSeconds, numberOfAssignments, null, null, null); return hit.getHITId(); }
/** * A valid question has been selected, ask for an answer of the right type, and output the result. * * @param question the selected question */ private void actOnChoice(Question<?> question) { System.out.print( "Enter your answer as a/an " + question.getAnswerType().getSimpleName() + ": "); String input = ""; // Loop and read from standard input, until an answer of the right type is provided boolean done = false; while (!done) { try { input = in.readLine(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } question.setAnswer(input); // WRONG! A wrong type == null answer, try again if (question.getAnswer() == null) { System.out.print("Invalid answer you DIMWIT!, try again: "); } else { done = true; } } // All done, output the result System.out.println("\n" + question.getAnswerResponse() + "\n"); }
private void initializeQuestionTextViews(Question currentQuestion) { // mCurrentQuestion = currentQuestion; if (mReverseNumbersInQuestions) { textViewQuestion.setText( mStringParser.reverseNumbersInStringHebrew( mCurrentGame.getCurrentQuestion().getQuestion())); textViewTimesPlayedTitle.setText( mStringParser.reverseNumbersInStringHebrew( getString(R.string.textViewTimesPlayedTitleText) + mCurrentGame.getCurrentQuestion().getQuestionTimesPlayed())); } else { textViewQuestion.setText(mCurrentGame.getCurrentQuestion().getQuestion()); textViewTimesPlayedTitle.setText( getString(R.string.textViewTimesPlayedTitleText) + " " + mCurrentGame.getCurrentQuestion().getQuestionTimesPlayed()); } // setting question difficulty textViewQuestionLevel.setText(mCurrentGame.getCurrentLevelAsString()); textViewHowManyTimesQuestionsBeenAsked.setText( mCurrentGame.getHowManyTimesQuestionsBeenAsked()); // randomize answer places (indices) mCurrentQuestion.randomizeAnswerPlaces(m_Random); buttonAnswer1.setText(mCurrentQuestion.getAnswer1()); buttonAnswer2.setText(mCurrentQuestion.getAnswer2()); buttonAnswer3.setText(mCurrentQuestion.getAnswer3()); buttonAnswer4.setText(mCurrentQuestion.getAnswer4()); }
/** Creates a fragment by turning a survey question into a View. */ @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Bundle args = getArguments(); int index = (int) args.getInt("qIndex"); Question question = GlobalsApp.survey.getQuestion(index); // keep input alive even when you swipe to a faraway page if (pageView == null) { // normally inflate the view hierarchy pageView = question.getQuestionView(getActivity(), container); } else { // view is still attached to the previous view hierarchy // we need to remove it and re-attach it to the current one ViewGroup parent = (ViewGroup) pageView.getParent(); parent.removeView(pageView); } TextView promptTextView = (TextView) pageView.findViewById(R.id.prompt); promptTextView.setText(question.getPrompt()); TextView sectionTextView = (TextView) pageView.findViewById(R.id.section); sectionTextView.setVisibility(View.GONE); if (question.getSection() != null) { sectionTextView.setText(question.getSection()); sectionTextView.setVisibility(View.VISIBLE); } return pageView; }
/** 获得一批问题 */ private String getQuestionText(int number) { Question question = (Question) mQuestions.get(number); if (question != null) { return question.getText(); } return null; }
public List<Question> getQuestionsSelectedForHomework(int qIds[]) { if (getQuestions() == null) throw new IllegalStateException(); List<Question> selectedQuestions1 = new ArrayList<>(); for (Question question : getQuestions()) for (int qid : qIds) if (question.getId() == qid) selectedQuestions1.add(question); return selectedQuestions1; }
private void setQuestionView() { txtQuestion.setText(currentQ.getQuestion()); rda.setText(currentQ.getOptionA()); rdb.setText(currentQ.getOptionB()); rdc.setText(currentQ.getOptionC()); qid++; }
private String getQuestionImageUrl(int number) { Question question = (Question) mQuestions.get(number); if (question != null) { return question.getImageUrl(); } return null; }
// Method will be called when a button is clicked to answer a question. // It will grey out all the answers except the correct one, which will be in green // if the user selected the wrong answer, it will be shown in red. public void checkAnswer(View v) { buttons[0] = (Button) findViewById(R.id.button1); buttons[1] = (Button) findViewById(R.id.button2); buttons[2] = (Button) findViewById(R.id.button3); buttons[3] = (Button) findViewById(R.id.button4); Button btnChosen = (Button) findViewById(v.getId()); TextView scoreView = (TextView) findViewById(R.id.evScore); /* can change getText to getKey and set a key in the xml*/ // checks the buttons text against the Question boolean correct = currentQuestion.checkAnswer(btnChosen); if (correct) { btnChosen.setBackgroundColor(Color.GREEN); score++; scoreView.setText(Integer.toString(score)); btnChosen.setEnabled(false); } else btnChosen.setBackgroundColor(Color.RED); for (int i = 0; i < 4; i++) { if (btnChosen.equals(buttons[i])) continue; if (currentQuestion.checkAnswer(buttons[i])) buttons[i].setBackgroundColor(Color.GREEN); else buttons[i].setBackgroundColor(Color.GRAY); buttons[i].setEnabled(false); } // savedInstanceState.putInt(KEY_SCORE, score); }
public Question createQuestion(String questionText, Double valor) { if (this.typeExam == ExamType.OPEN_ANSWER) { Question q = new Question(questionText, valor); q.setExam(this); this.questions.add(q); return q; } else return null; }
/** Test of setDateCreated method, of class Question. */ @Test public void testSetDateCreated() { System.out.println("setDateCreated"); ObjectProperty<LocalDate> inDateCreated = null; Question instance = new Question(); instance.setDateCreated(inDateCreated); // TODO review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }
/** @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Question q = new Question(); TreeNode t1 = new TreeNode(2); TreeNode t2 = new TreeNode(1); t1.left = t2; int k = 1; System.out.println(q.kthSmallest(t1, k)); }
/** Test of setQuery method, of class Question. */ @Test public void testSetQuery() { System.out.println("setQuery"); String inQuery = ""; Question instance = new Question(); instance.setQuery(inQuery); // TODO review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }
/** Test of getQuery method, of class Question. */ @Test public void testGetQuery() { System.out.println("getQuery"); Question instance = new Question(); String expResult = ""; String result = instance.getQuery(); assertEquals(expResult, result); // TODO review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }
/** Test of queryProperty method, of class Question. */ @Test public void testQueryProperty() { System.out.println("queryProperty"); Question instance = new Question(); SimpleStringProperty expResult = null; SimpleStringProperty result = instance.queryProperty(); assertEquals(expResult, result); // TODO review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }
public double[] getVector(Observation data) { double[] result = new double[definitions.size()]; for (Question q : data.getQuestions()) { QuestionDef def = definitions.get(q.getId()); result[def.index] = def.getNumericValue(q.getAnswer()); } return result; }
@Test public void test_question_setText() { // GIVEN Question q = new Question(); String text = "Blabla"; // WHEN q.setText(text); // THEN assertEquals(q.getText(), text); }
@Test public void test_question_setAllowAddAnswer_false() { // GIVEN Question q = new Question(); boolean b = false; // WHEN q.setAllowAddAnswer(b); // THEN assertEquals(q.isAllowAddAnswer(), b); }
@Test public void test_question_setType() { // GIVEN Question q = new Question(); QuestionType qt = QuestionType.SIMPLE_CHOICE; // WHEN q.setType(qt); // THEN assertEquals(q.getType(), qt); }
@Test public void test_question_setAllowNoAnswer_true() { // GIVEN Question q = new Question(); boolean allow = true; // WHEN q.setAllowNoAnswer(allow); // THEN assertEquals(q.isAllowNoAnswer(), allow); }
@Test public void test_question_setPoll() { // GIVEN Question q = new Question(); Poll p = new Poll(); // WHEN q.setPoll(p); // THEN assertEquals(q.getPoll(), p); }
/** Test of getDateCreated method, of class Question. */ @Test public void testGetDateCreated() { System.out.println("getDateCreated"); Question instance = new Question(); ObjectProperty<LocalDate> expResult = null; ObjectProperty<LocalDate> result = instance.getDateCreated(); assertEquals(expResult, result); // TODO review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }
@Test public void test_question_setMedia() { // GIVEN Question q = new Question(); Media m = new Media(); // WHEN q.setMedia(m); // THEN assertEquals(q.getMedia(), m); }
@Test public void test_question_setProposedChoices() { // GIVEN Question q = new Question(); List<ProposedChoice> lprop = new ArrayList<ProposedChoice>(); // WHEN q.setProposedChoices(lprop); // THEN assertEquals(q.getProposedChoices(), lprop); }
@Test public void test_question_setId() { // GIVEN Question q = new Question(); long id = 512; // WHEN q.setId(id); // THEN assertEquals(q.getId(), id); }
@Test public void test_question_setAnswers() { // GIVEN Question q = new Question(); List<Answer> lAns = new ArrayList<Answer>(); // WHEN q.setAnswers(lAns); // THEN assertEquals(q.getAnswers(), lAns); }
@Test public void test_question_setConditions() { // GIVEN Question q = new Question(); List<QuestionCondition> lcond = new ArrayList<QuestionCondition>(); // WHEN q.setConditions(lcond); // THEN assertEquals(q.getConditions(), lcond); }
@Test public void test_question_setOrderNumber() { // GIVEN Question q = new Question(); int order = 54; // WHEN q.setOrderNumber(order); // THEN assertEquals(q.getOrderNumber(), order); }
@Before public void prepareQuestion() { question = new Question("id"); renderer = new TableQuestionRenderer(question); question.setText("Is this working?"); question.addOption("Yes", true); question.addOption("No", false); option1 = question.getOptions().get(0); option2 = question.getOptions().get(1); }
/** * This method validates the answerMaxLength field. The field must contain a number greater than * zero. * * @param question - the question to be validated * @return true if all validation has passed, false otherwise */ private boolean validateAnswerMaxLength(Question question) { if (question.getAnswerMaxLength() != null && question.getAnswerMaxLength() > 0) { return true; } else { GlobalVariables.getMessageMap() .putError( Constants.QUESTION_DOCUMENT_FIELD_ANSWER_MAX_LENGTH, KeyConstants.ERROR_QUESTION_ANSWER_MAX_LENGTH_INVALID); return false; } }