Skip to content

Commit

Permalink
see pull request notes for full changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jonters committed Aug 3, 2023
1 parent 90755a1 commit 9cb2007
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 47 deletions.
42 changes: 38 additions & 4 deletions app/src/main/java/com/innovator/solve/AnswerFormatManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ public int evaluateAnswer(Question q, int qId) {
}

public int evalMcq(Question q) {
Log.d("YAS", mcqAnswer.toString() + " " + q.getAnswer());
if (mcqAnswer.size() != q.getAnswer().split(" ").length)
return 0;
try {
if (mcqAnswer.size() != q.getAnswer().split(" ").length)
return 0;
} catch (Exception e) {
Log.d("idk", e.toString());
Log.d("idk", q.getQuestion());
}
for (String s: q.getAnswer().split(" ")) {
if (!mcqAnswer.contains((int)(s.charAt(0))-65))
return 0;
Expand All @@ -78,7 +82,37 @@ public int evalDnd(Question q) {
}

public int evalFrq(Question q) {
return 1;
if (q.getAnswer().equalsIgnoreCase(frqAnswer))
return 1;
return 0;
}

public String toString() {
if (id == 0)
return mcqToString();
if (id == 1)
return dndToString();
if (id == 2)
return frqToString();
return "NO ANSWER";
}

public String mcqToString() {
String s = "";
for (int i: mcqAnswer) {
s += "Option " + (char)(i + 65) + " ";
}
if (s.equals("")) return "NO ANSWER";
return s;
}

public String dndToString() {
return dndAnswer.toString();
}

public String frqToString() {
if (frqAnswer.equals("")) return "NO ANSWER";
return frqAnswer;
}

public Bundle bundleUp(Bundle b) {
Expand Down
75 changes: 39 additions & 36 deletions app/src/main/java/com/innovator/solve/MockTestManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class MockTestManager {
private static ArrayList<MockTest> allTests;
public static boolean loaded = false;
public static void init() {
Log.d("IDK", "smth smth");
DatabaseReference tref = FirebaseDatabase.getInstance().getReference().child("Mocks");
allTests = new ArrayList<>();
//Log.d("Database", tref.toString());
Expand Down Expand Up @@ -95,49 +96,51 @@ public void populateQuestions() {
//goes to template

tref.addListenerForSingleValueEvent(
new ValueEventListener() {
new ValueEventListener() {

@Override
public void onDataChange(DataSnapshot dataSnapshot) {
// Log.d("Output", dataSnapshot.getValue().toString());
collectTests((Map<String,Object>) dataSnapshot.getValue());
}
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
// Log.d("Output", dataSnapshot.getValue().toString());
collectTests((Map<String,Object>) dataSnapshot.getValue());
}

private void collectTests(Map<String,Object>questions) {
Log.d("Output2", questions.get("Questions").toString()); //questions.get("Questions") gets forced into an ARrayList
ArrayList<Object> list = (ArrayList<Object>) questions.get("Questions");
for (Object o:list) {
private void collectTests(Map<String,Object>questions) {
Log.d("Output2", questions.get("Questions").toString()); //questions.get("Questions") gets forced into an ARrayList
ArrayList<Object> list = (ArrayList<Object>) questions.get("Questions");
for (Object o:list) {
// Log.d("Database", o.toString());
Map<String, Object> q = (Map) o;
String answer = (String) q.get("Answer");
String type = (String) q.get("Type");
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("QuestionPicNumber"));
int exPicNum = Math.toIntExact((Long) q.get("ExMediaID"));

TreeMap<Character, String> choices = new TreeMap<>();
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));
Map<String, Object> q = (Map) o;
String answer = (String) q.get("Answer");
if (answer == null)
answer = (String) q.get("ANSWER");
String type = (String) q.get("Type");
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("QuestionPicNumber"));
int exPicNum = Math.toIntExact((Long) q.get("ExMediaID"));


TreeMap<Character, String> choices = new TreeMap<>();
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);
Question qObj = new Question(true, type, statement, choices, answer, explanation, category, picNum, exPicNum);
questionList.add(qObj);
}
populated = true;
}
populated = true;
}
@Override
public void onCancelled(DatabaseError databaseError) {
Log.d("DATABASE ERROR", databaseError.toString());
}
});
@Override
public void onCancelled(DatabaseError databaseError) {
Log.d("DATABASE ERROR", databaseError.toString());
}
});
}
public String getSubject() {
return this.subject;
Expand Down
14 changes: 7 additions & 7 deletions app/src/main/java/com/innovator/solve/Review.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ public TableLayout createTable(List<Pair<Integer, String>> list, Context context
TableRow.LayoutParams.MATCH_PARENT,
TableRow.LayoutParams.WRAP_CONTENT, 1.0f
));
Button fuckme = new Button(context);
fuckme.setText(String.valueOf(item.first));
fuckme.setTextSize(40);
fuckme.setOnClickListener(new View.OnClickListener() {
Button btn = new Button(context);
btn.setText(String.valueOf(item.first));
btn.setTextSize(40);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
System.out.println("sexy");
}
});
fuckme.setBackgroundResource(R.drawable.bordercolor);
row.addView(fuckme);
btn.setBackgroundResource(R.drawable.bordercolor);
row.addView(btn);

System.out.println(fuckme.getText());
System.out.println(btn.getText());

TextView textView2 = new TextView(context);
textView2.setText(item.second);
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/com/innovator/solve/TestActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ public void returnToHome(View view) {
finish();
}

public void showTutorial(View view) {
findViewById(R.id.tutorial_layout).setVisibility(View.VISIBLE);
getSupportFragmentManager().beginTransaction().setReorderingAllowed(true).replace(R.id.tutorial_fragment, TutorialFragment.class, null).commit();
}

public void promptHome(View view) {
findViewById(R.id.dark_screen).setVisibility(View.VISIBLE);
findViewById(R.id.leave_prompt).setVisibility(View.VISIBLE);
Expand Down
59 changes: 59 additions & 0 deletions app/src/main/java/com/innovator/solve/TutorialFragment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.innovator.solve;

import android.os.Bundle;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.Fragment;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;

public class TutorialFragment extends Fragment{
Button buttonExit;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}

@Nullable
@Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.tutorial, container, false);
}

@Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);;


buttonExit = view.findViewById(R.id.button_close);
buttonExit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
exitFragment();
}
});
}


public void exitFragment() {

getActivity().getSupportFragmentManager().beginTransaction().remove(TutorialFragment.this).commit();
}

}
32 changes: 32 additions & 0 deletions app/src/main/res/layout/layout_two.xml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,19 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />

<Button
android:id="@+id/tutorial"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="showTutorial"
android:text="help"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/viewPicButton"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="@+id/backButton"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />

</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.constraintlayout.widget.ConstraintLayout
Expand Down Expand Up @@ -415,6 +428,25 @@
</FrameLayout>
</LinearLayout>

<LinearLayout
android:id="@+id/tutorial_layout"
android:layout_width="275dp"
android:layout_height="500dp"
android:orientation="vertical"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent">

<FrameLayout
android:id="@+id/tutorial_fragment"
android:name="com.innovator.solve.TutorialFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">

</FrameLayout>
</LinearLayout>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/dark_screen"
android:layout_width="match_parent"
Expand Down
36 changes: 36 additions & 0 deletions app/src/main/res/layout/tutorial.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/blue"
xmlns:app="http://schemas.android.com/apk/res-auto">
<Button
android:id="@+id/button_close"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#003E3E3E"
android:text="x"
android:textAlignment="center"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="40sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click on the calculator button to open calculator. Click on formula sheet button to open formula sheet. Click on the forwards arrow to go to the next question, and the back arrow to go to the previous question."
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
></TextView>

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 9cb2007

Please sign in to comment.