/* * Copyright (c) 2013 Allogy Interactive. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.allogy.app.media; import java.util.ArrayList; import android.net.Uri; public class Question { /** Constants which defines the presence of a type of quiz question */ public static final int TYPE_MULTIPLE_CHOICE = 0x1; public static final int TYPE_SHORT_ANSWER = 0x1<<1; public static final int TYPE_VIDEO = 0x1<<2; /** The id parsed from the xml - Unique id representing the question, generated by * the backend */ private String id; /** The uri which represents the media content, Currently not used */ private Uri mediaUri; /** Question type representing the type of answers the question can have. This is * Constructed by OR ing the constants defined above */ private int questionType; /** The question text */ private String questionText; /** For multiple choice questions, this holds the different choices */ private ArrayList<String> possibleAnswers; private ArrayList<String> answerIds; /** For the questions which has multiple choices, this holds the selected answer */ private int selectedAnswer; /** For short answer questions, this holds the short answer entered by the student, * Max 140 characters */ private String shortAnswer; public Question () { questionText = ""; possibleAnswers = new ArrayList<String>(); answerIds = new ArrayList<String>(); selectedAnswer = -1; } public void setId(String question_id){ id = question_id; } public String getId(){ return id; } public void addAnswerId(String answerId) { answerIds.add(answerId); } public String getAnswerId(int i ){ return answerIds.get(i); } public void setMediaUri (String s) { mediaUri = Uri.parse(s); } public Uri getMediaUri () { return mediaUri; } public void setType (int s) { questionType = s; } public int getType() { return questionType; } public void setText (String s) { questionText = s; } public String getQuestionText () { return questionText; } public int length() { return possibleAnswers.size(); } public void addAnswer (String s) { possibleAnswers.add(s); } public String getAnswerText(int i) { return possibleAnswers.get(i); } public int getNumAnswers() { return possibleAnswers.size(); } public void setSelected(int i) { selectedAnswer = i; } public int getSelected() { return selectedAnswer; } public boolean hasMediaContent() { return false; } public void setShortAnswer(String shortAnswer) { this.shortAnswer = shortAnswer; } public String getShortAnswer() { return shortAnswer; } }