Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
jonters committed Aug 3, 2023
1 parent 6841e3d commit 90755a1
Show file tree
Hide file tree
Showing 17 changed files with 550 additions and 163 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:theme="@style/AppTheme">
<activity android:name="com.innovator.solve.ProgressBarActivity">
<intent-filter>
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/com/innovator/solve/CongratsPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ public void returnToHome(View v){
startActivity(new Intent(this, MainMenuController.class));
}
public void goToReviewPage(View v){
startActivity(new Intent(this, PastProblemsTwo.class));
Intent i = new Intent(this, PastProblemsTwo.class);
i.putExtra("ANSWERS", getIntent().getExtras().getString("ANSWERS"));
i.putExtra("TestID", getIntent().getExtras().getString("TestID"));
startActivity(i);
}

}
34 changes: 31 additions & 3 deletions app/src/main/java/com/innovator/solve/DailyChallenge.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
package com.innovator.solve;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.collection.CircularArray;

import com.bumptech.glide.Glide;
import com.google.api.Distribution;
import com.innovator.solve.R;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
Expand All @@ -29,6 +37,7 @@

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
Expand Down Expand Up @@ -58,6 +67,8 @@ public class DailyChallenge extends AppCompatActivity{

private String currentDate;



@Override
protected void onCreate(Bundle savedInstance){
super.onCreate(savedInstance);
Expand All @@ -71,8 +82,10 @@ protected void onCreate(Bundle savedInstance){
currentDate=formatter.format(date).substring(0,10).replace('/','-');

selectCategory();

}


public void selectCategory(){
SharedPreferences pastCategories=getSharedPreferences("PastCategories", Context.MODE_PRIVATE);
SharedPreferences.Editor editPastQuestions=pastCategories.edit();
Expand Down Expand Up @@ -153,6 +166,9 @@ public void loadChallenge(){

currentQuestionData=DailyChallengeManager.getCurrentQuestionData();

popup = findViewById(R.id.popup);
popup.setVisibility(View.GONE);

questionDisplay.setText("Question: "+(String)currentQuestionData.get("question"));
choiceA.setText("A. "+currentQuestionData.get("optA"));
choiceB.setText("B. "+currentQuestionData.get("optB"));
Expand Down Expand Up @@ -250,9 +266,7 @@ public void clickedD(View view){
}

private void verifyAnswer(String choice){
TextView explanationText = findViewById(R.id.explanation);

explanationText.setText("Explanation: "+currentQuestionData.get("explanation"));
popup();
}

private boolean retrieveDataPoints(Map<String, Object> databaseStorage){
Expand Down Expand Up @@ -305,4 +319,18 @@ public void onComplete(@NonNull Task<Uri> task) {
});
}

private LinearLayout popup;

private void popup() {
popup.setVisibility(View.VISIBLE);
TextView txt = (TextView) findViewById(R.id.textView2);
txt.setText("Explanation: "+currentQuestionData.get("explanation"));
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
popup.setVisibility(View.GONE);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void returnToHome(View view){
}

public void dailyChallenge(View view){
startActivity(new Intent(this, Review.class));
startActivity(new Intent(this, DailyChallenge.class));
}

@Override
Expand Down
15 changes: 8 additions & 7 deletions app/src/main/java/com/innovator/solve/MockTestManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,20 @@ private void collectTests(Map<String,Object>questions) {
String category = (String) q.get("Category");
String statement = (String) q.get("Question");
String explanation = (String) q.get("Explanation");
int picNum = Math.toIntExact((Long) q.get("MediaID"));
int picNum = Math.toIntExact((Long) q.get("QuestionPicNumber"));
int exPicNum = Math.toIntExact((Long) q.get("ExMediaID"));



TreeMap<Character, String> choices = new TreeMap<>();
Map choiceMap = (Map) q.get("Choices");
for (Object key: (choiceMap).keySet()) {
Character k = ((String) key).charAt(0);
choices.put(k, (String) choiceMap.get(key));
if (type.charAt(0) != 'S') {
Map choiceMap = (Map) q.get("Choices");
for (Object key: (choiceMap).keySet()) {
Character k = ((String) key).charAt(0);
choices.put(k, (String) choiceMap.get(key));
}
}



Question qObj = new Question(true, type, statement, choices, answer, explanation, category, picNum, exPicNum);
questionList.add(qObj);
}
Expand Down
52 changes: 14 additions & 38 deletions app/src/main/java/com/innovator/solve/MultipleAnswerFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,16 @@ public void onClick(View v) {
}
});
buttonD = (FButton) view.findViewById(R.id.buttonD);
buttonD.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
buttonD(true);
}
});
if (numChoices > 3) {
buttonD.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
buttonD(true);
}
});
}
else
view.findViewById(R.id.buttonD).setVisibility(View.GONE);
buttonE = (FButton) view.findViewById(R.id.buttonE);
if (numChoices > 4) {
view.findViewById(R.id.buttonE).setVisibility(View.VISIBLE);
Expand Down Expand Up @@ -246,34 +250,6 @@ public void displayQuestion() {
buttonB.setText(currentQuestion.getOptB());
buttonC.setText(currentQuestion.getOptC());
buttonD.setText(currentQuestion.getOptD());
Log.d("YAS2", ""+currentQuestion.getPicNumber());
if (currentQuestion.getPicNumber() > -1) {
loadQuestionPic(currentQuestion.getPicNumber());
}
}

private void loadQuestionPic(int questionPicID){
Log.d("YAS", ""+questionPicID);
if(questionPicID < 0)return;
StorageReference qImageRef = FirebaseStorage.getInstance().getReference() //but what if it doesn't exist?
.child(TopicManager.getPicRootFolderName())
.child("Question_Pics")
.child(TopicManager.getPicNamePrefix()+"_q_"+questionPicID+".PNG");

qImageRef.getDownloadUrl().addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
if(task.isSuccessful())
{
Glide.with(getActivity())
.load(task.getResult())
.into(questionPic);
}
else {

}
}
});
}

public void setAnswer(int i) {
Expand Down Expand Up @@ -309,15 +285,15 @@ public void updateButtons(boolean notOnCreate) {
updateChoices();
buttonA.setButtonColor(ContextCompat.getColor(getActivity().getApplicationContext(), (buttonClicked[0] == 1)?R.color.blue:R.color.white));
buttonB.setButtonColor(ContextCompat.getColor(getActivity().getApplicationContext(), (buttonClicked[1] == 1)?R.color.blue:R.color.white));
buttonC.setButtonColor(ContextCompat.getColor(getActivity().getApplicationContext(), (buttonClicked[2] == 1)?R.color.blue:R.color.white));
buttonD.setButtonColor(ContextCompat.getColor(getActivity().getApplicationContext(), (buttonClicked[3] == 1)?R.color.blue:R.color.white));
if (numChoices > 2) buttonC.setButtonColor(ContextCompat.getColor(getActivity().getApplicationContext(), (buttonClicked[2] == 1)?R.color.blue:R.color.white));
if (numChoices > 3) buttonD.setButtonColor(ContextCompat.getColor(getActivity().getApplicationContext(), (buttonClicked[3] == 1)?R.color.blue:R.color.white));
if (numChoices > 4) buttonE.setButtonColor(ContextCompat.getColor(getActivity().getApplicationContext(), (buttonClicked[4] == 1)?R.color.blue:R.color.white));
if (numChoices > 5) buttonF.setButtonColor(ContextCompat.getColor(getActivity().getApplicationContext(), (buttonClicked[5] == 1)?R.color.blue:R.color.white));
if (numChoices > 6) buttonG.setButtonColor(ContextCompat.getColor(getActivity().getApplicationContext(), (buttonClicked[6] == 1)?R.color.blue:R.color.white));
buttonA.setTextColor(ContextCompat.getColor(getActivity().getApplicationContext(), (buttonClicked[0] == 1)?R.color.white:R.color.grey));
buttonB.setTextColor(ContextCompat.getColor(getActivity().getApplicationContext(), (buttonClicked[1] == 1)?R.color.white:R.color.grey));
buttonC.setTextColor(ContextCompat.getColor(getActivity().getApplicationContext(), (buttonClicked[2] == 1)?R.color.white:R.color.grey));
buttonD.setTextColor(ContextCompat.getColor(getActivity().getApplicationContext(), (buttonClicked[3] == 1)?R.color.white:R.color.grey));
if (numChoices > 2) buttonC.setTextColor(ContextCompat.getColor(getActivity().getApplicationContext(), (buttonClicked[2] == 1)?R.color.white:R.color.grey));
if (numChoices > 3) buttonD.setTextColor(ContextCompat.getColor(getActivity().getApplicationContext(), (buttonClicked[3] == 1)?R.color.white:R.color.grey));
if (numChoices > 4) buttonE.setTextColor(ContextCompat.getColor(getActivity().getApplicationContext(), (buttonClicked[4] == 1)?R.color.white:R.color.grey));
if (numChoices > 5) buttonF.setTextColor(ContextCompat.getColor(getActivity().getApplicationContext(), (buttonClicked[5] == 1)?R.color.white:R.color.grey));
if (numChoices > 6) buttonG.setTextColor(ContextCompat.getColor(getActivity().getApplicationContext(), (buttonClicked[6] == 1)?R.color.white:R.color.grey));
Expand Down
29 changes: 21 additions & 8 deletions app/src/main/java/com/innovator/solve/PastProblems.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ protected void onCreate(Bundle savedInstanceState){
pastProblemsLayout = (LinearLayout)findViewById(R.id.past_problems_linear_layout);

populateLayout();

}

private LinearLayout popup;

private void getPastProblems(){
String currentUserID=InnovatorApplication.getUser().getId();

questionLocation.collection("User_"+currentUserID).get().addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
@Override
public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
Expand All @@ -72,6 +76,8 @@ public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
@Override
public void onClick(View view) {
setContentView(R.layout.single_past_problem);
popup = findViewById(R.id.popup);
popup.setVisibility(View.GONE);

long questionPicNumber=-1;
if(questionData.get("picNumber")!=null){
Expand All @@ -90,13 +96,11 @@ public void onClick(View view) {
Button choiceD=findViewById(R.id.pastAnswerD);

TextView questionText=findViewById(R.id.questionDisplay);
TextView explanationText=findViewById(R.id.explanation);

Map<String, Button> references = new HashMap<String, Button>(){{
put("Option A", choiceA);
put("Option B", choiceB);
put("Option C", choiceC);
put("Option D", choiceD);
put("Option A", choiceA);
put("Option B", choiceB);
put("Option C", choiceC);
put("Option D", choiceD);
}};

choiceA.setText(questionData.get("optA").toString());
Expand All @@ -105,8 +109,17 @@ public void onClick(View view) {
choiceD.setText(questionData.get("optD").toString());

questionText.setText("Question: "+questionData.get("question").toString());
explanationText.setText("Explanation: "+questionData.get("explanation").toString());

popup.setVisibility(View.VISIBLE);
TextView txt = (TextView) findViewById(R.id.textView2);
txt.setText("Explanation: "+questionData.get("explanation").toString());
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
popup.setVisibility(View.GONE);
}
});
references.get("Option "+correctAnswer).setBackgroundColor(Color.GREEN);
references.get("Option "+correctAnswer).setTextColor(Color.WHITE);

Expand Down Expand Up @@ -183,5 +196,5 @@ public void returnToHome(View v){
public void retryCurrentQuestion(View view){
startActivity(new Intent(this, RetryProblem.class));
}

}
26 changes: 18 additions & 8 deletions app/src/main/java/com/innovator/solve/PastProblemsTwo.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,41 @@
package com.innovator.solve;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;

import java.util.ArrayList;
import java.util.Arrays;

public class PastProblemsTwo extends AppCompatActivity {

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.review_page);

ReviewPage information = new ReviewPage();
String testID = getIntent().getExtras().getString("TestID");
ArrayList<String> answers = new ArrayList<>(Arrays.asList(getIntent().getExtras().getString("ANSWERS").split("\n")));
Log.d("YAS", testID);
MockTestManager.MockTest m = MockTestManager.getTestByID(testID);
ArrayList<Question> qs = m.questionList;
ReviewPage information = new ReviewPage(qs, answers);

TextView Question = findViewById(R.id.Question);
TextView Answer = findViewById(R.id.Answer);
TextView YourAnswer = findViewById(R.id.your_answer);
TextView Answer = findViewById(R.id.answer);
Button button = findViewById(R.id.Next);
Button back = findViewById(R.id.back);

information.updateButtons(button, back);
information.question(Question);
information.yourAnswer(YourAnswer);
information.answer(Answer);
information.Click(button, Question, Answer);
information.back(back, Question, Answer);
information.Click(button, back, Question, YourAnswer, Answer);
information.back(button, back, Question, YourAnswer, Answer);
}
public void goBack(View v){
startActivity(new Intent(this, CongratsPage.class));
public void goBack(View v) {
finish();
}
}
17 changes: 16 additions & 1 deletion app/src/main/java/com/innovator/solve/RetryProblem.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

Expand Down Expand Up @@ -35,6 +36,8 @@ public class RetryProblem extends AppCompatActivity {

public Map<String, Button> buttonDict;

private LinearLayout popup;

private boolean answerSelected;

protected void onCreate(Bundle savedInstance){
Expand Down Expand Up @@ -64,6 +67,9 @@ protected void onCreate(Bundle savedInstance){
}

public void initiateValues(){
popup = findViewById(R.id.popup);
popup.setVisibility(View.GONE);

questionText.setText("Question: "+retryQuestion.getQuestion());
choiceA.setText(retryQuestion.getOptA());
choiceB.setText(retryQuestion.getOptB());
Expand All @@ -74,7 +80,16 @@ public void initiateValues(){
}

private void verifyAnswer(String choice){
explanationText.setText("Explanation: "+retryQuestion.getExplanation());
popup.setVisibility(View.VISIBLE);
TextView txt = (TextView) findViewById(R.id.textView2);
txt.setText("Explanation: "+retryQuestion.getExplanation());
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
popup.setVisibility(View.GONE);
}
});

buttonDict.get(choice).setBackgroundColor(Color.RED);
buttonDict.get(choice).setTextColor(Color.WHITE);
Expand Down
Loading

0 comments on commit 90755a1

Please sign in to comment.