Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spellings Puzzle: There was an issue with scorecard and restarting spellings puzzle. #5

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void onClick(View v) {
@Override
public void onClick(View v) {

if (iQuestionIndex < mCardList.size()) {
if (iQuestionIndex < mCardList.size()-1) {
isFlipped = false;
iQuestionIndex++;
questionView.setVisibility(View.VISIBLE);
Expand All @@ -115,6 +115,7 @@ public void onClick(View v) {
populateQuestion(iQuestionIndex);

} else {
finish();
/*Intent myIntent = new Intent(FlashActivity.this,
ScoreActivity.class);
startActivity(myIntent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public void onClick(View arg0) {
reInitialize();
Intent myIntent = new Intent(arg0.getContext(),
ScoreActivity.class);
myIntent.putExtra("Activity",0);// 0: Quiz Template and 1: Spellings Template
startActivity(myIntent);
finish();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,45 +37,76 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE

import com.actionbarsherlock.app.SherlockActivity;
import com.buildmlearnstore.model.QuizModel;
import com.buildmlearnstore.model.SpellingsModel;

public class ScoreActivity extends SherlockActivity {
private QuizModel mQuizModel;
private SpellingsModel mSpellingsModel;
private TextView mTv_correct, mTv_wrong, mTv_unanswered;

private int activity=0;// 0: Quiz Template and 1: Spellings Template
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.score_view);
mQuizModel = QuizModel.getInstance();
Intent intent=getIntent();
activity=intent.getIntExtra("Activity",0);
System.out.println("#"+activity+"#");
if(activity==1)
mSpellingsModel=SpellingsModel.getInstance();
else
mQuizModel = QuizModel.getInstance();

mTv_correct = (TextView) findViewById(R.id.tv_correct);
mTv_wrong = (TextView) findViewById(R.id.tv_wrong);
mTv_unanswered = (TextView) findViewById(R.id.tv_unanswered);
mTv_correct.setText("Total Correct: " + mQuizModel.getTotalCorrect());
mTv_wrong.setText("Total Wrong: " + mQuizModel.getTotalWrong());
int unanswered = mQuizModel.getQueAnsList().size()
- mQuizModel.getTotalCorrect() - mQuizModel.getTotalWrong();
mTv_unanswered.setText("Unanswered: " + unanswered);

if(activity==1)
{
mTv_correct.setText("Total Correct: " + mSpellingsModel.getTotalCorrect());
mTv_wrong.setText("Total Wrong: " + mSpellingsModel.getTotalWrong());
int unanswered = mSpellingsModel.getSpellingsList().size()
- mSpellingsModel.getTotalCorrect() - mSpellingsModel.getTotalWrong();
mTv_unanswered.setText("Unanswered: " + unanswered);
}
else
{
mTv_correct.setText("Total Correct: " + mQuizModel.getTotalCorrect());
mTv_wrong.setText("Total Wrong: " + mQuizModel.getTotalWrong());
int unanswered = mQuizModel.getQueAnsList().size()
- mQuizModel.getTotalCorrect() - mQuizModel.getTotalWrong();
mTv_unanswered.setText("Unanswered: " + unanswered);
}
Button startAgainButton = (Button) findViewById(R.id.start_again_button);
startAgainButton.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
Intent myIntent = new Intent(arg0.getContext(),
QuestionActivity.class);
if(activity==1)
{
Intent myIntent = new Intent(arg0.getContext(),
SpellingActivity.class);
startActivityForResult(myIntent, 0);
mSpellingsModel.clearInstance();
finish();
}
else
{
Intent myIntent = new Intent(arg0.getContext(),
QuestionActivity.class);
startActivityForResult(myIntent, 0);
mQuizModel.clearInstance();
finish();
}
}
});

Button quitButton = (Button) findViewById(R.id.quit_button);
quitButton.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
// android.os.Process.killProcess(android.os.Process.myPid());
mSpellingsModel.clearInstance();
mQuizModel.clearInstance();
finish();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class SpellingActivity extends SherlockActivity implements
TextToSpeech.OnInitListener {
private TextToSpeech textToSpeech;
private ArrayList<WordModel> mWordList;
private int count;
private int count=0;
private AlertDialog mAlert;
private TextView mTv_WordNumber;
private Button mBtn_Spell, mBtn_Skip;
Expand Down Expand Up @@ -101,6 +101,7 @@ public void click(View view) {
mBtn_Spell.setTextColor(Color.WHITE);
} else {
Intent resultIntent = new Intent(this, ScoreActivity.class);
resultIntent.putExtra("Activity",1);// 0: Quiz Template and 1: Spellings Template
startActivity(resultIntent);
finish();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ public class QuizModel {


public static QuizModel mQuizModel;

public static void clearInstance()
{
if(mQuizModel!=null) {
mQuizModel.totalCorrect = 0;
mQuizModel.totalWrong = 0;
}
}
public static QuizModel getInstance()
{
if(mQuizModel==null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ public class SpellingsModel {


public static SpellingsModel mSpellingsModel;

public static void clearInstance()
{
mSpellingsModel.totalCorrect=0;
mSpellingsModel.totalWrong=0;
mSpellingsModel.activeCount=0;
}
public static SpellingsModel getInstance()
{
if(mSpellingsModel==null)
Expand Down