Android Open Source - dv-quiz Quiz






From Project

Back to project page dv-quiz.

License

The source code is released under:

Apache License

If you think the Android project dv-quiz listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.dvorakdev.dvquiz.model;
//from  www  . j  av  a  2 s.  co  m
import java.util.Collections;
import java.util.List;

import com.activeandroid.Model;
import com.activeandroid.annotation.Column;
import com.activeandroid.annotation.Column.ForeignKeyAction;
import com.activeandroid.query.Select;

public class Quiz extends Model {
  
  @Override
  public String toString()
  {
    return this.getName();
  }
  
  public Boolean isNew()
  {
    return this.getId() == null;
  }
  
  private List<Question> questions;
  private List<Question> shuffledQuestions;
  
  @Column(name = "Category", onDelete = ForeignKeyAction.CASCADE)
  private Category category;

  @Column(name = "Name")
  private String name;
  
  public Category getCategory() {
    return category;
  }

  public void setCategory(Category category) {
    this.category = category;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

    public List<Question> getQuestions()
    {
      if (this.questions == null)
      {
        this.questions = this.getMany(Question.class, "Quiz");
      }
      
        return this.questions;
    }

    public List<Question> getShuffledQuestions()
    {
      if (this.shuffledQuestions == null)
      {
        this.shuffledQuestions = this.getQuestions();
        
        Collections.shuffle(this.shuffledQuestions);
      }
      
        return this.shuffledQuestions;
    }
  
  public static Quiz oneByName(String aQuizName)
  {
    return new Select().from(Quiz.class).where("Name = ?", aQuizName).executeSingle();
  }
    
    public static List<Quiz> all()
    {
      return Model.all(Quiz.class);
    }
    
    public static void truncate()
    {
      Model.delete(Quiz.class);
    }

}




Java Source Code List

com.dvorakdev.dvquiz.AboutActivity.java
com.dvorakdev.dvquiz.CategoryFormActivity.java
com.dvorakdev.dvquiz.MainActivity.java
com.dvorakdev.dvquiz.QuizActivity.java
com.dvorakdev.dvquiz.QuizFormActivity.java
com.dvorakdev.dvquiz.QuizResultActivity.java
com.dvorakdev.dvquiz.context.dvQuizContext.java
com.dvorakdev.dvquiz.model.Answer.java
com.dvorakdev.dvquiz.model.Category.java
com.dvorakdev.dvquiz.model.Question.java
com.dvorakdev.dvquiz.model.Quiz.java
com.dvorakdev.dvquiz.reference.dvQuizReference.java
com.dvorakdev.lib.dvExpandableListAdapter.java
com.dvorakdev.lib.dvFileDialog.java
com.dvorakdev.lib.dvObjectRadioButton.java
com.dvorakdev.lib.dvUtils.java