Skip to content

Commit

Permalink
Removed Remark while displaying Marks
Browse files Browse the repository at this point in the history
  • Loading branch information
therealsujitk committed Jan 12, 2021
1 parent 031ac27 commit 0210c31
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected void onCreate(Bundle savedInstanceState) {
public void run() {
SQLiteDatabase myDatabase = context.openOrCreateDatabase("vtop", Context.MODE_PRIVATE, null);

myDatabase.execSQL("CREATE TABLE IF NOT EXISTS marks (id INT(3) PRIMARY KEY, course VARCHAR, type VARCHAR, title VARCHAR, score VARCHAR, status VARCHAR, weightage VARCHAR, average VARCHAR, posted VARCHAR, remark VARCHAR)");
myDatabase.execSQL("CREATE TABLE IF NOT EXISTS marks (id INT(3) PRIMARY KEY, course VARCHAR, type VARCHAR, title VARCHAR, score VARCHAR, status VARCHAR, weightage VARCHAR, average VARCHAR, posted VARCHAR)");
Cursor c = myDatabase.rawQuery("SELECT DISTINCT title FROM marks", null);

int titleIndex = c.getColumnIndex("title");
Expand Down Expand Up @@ -141,10 +141,9 @@ public void run() {
int statusIndex = s.getColumnIndex("status");
int weightageIndex = s.getColumnIndex("weightage");
int averageIndex = s.getColumnIndex("average");
int remarkIndex = s.getColumnIndex("remark");

int[] indexes = {typeIndex, scoreIndex, weightageIndex, averageIndex, statusIndex, remarkIndex};
String[] titles = {getString(R.string.type), getString(R.string.score), getString(R.string.weightage), getString(R.string.average), getString(R.string.status), getString(R.string.remark)};
int[] indexes = {typeIndex, scoreIndex, weightageIndex, averageIndex, statusIndex};
String[] titles = {getString(R.string.type), getString(R.string.score), getString(R.string.weightage), getString(R.string.average), getString(R.string.status)};

s.moveToFirst();

Expand Down Expand Up @@ -184,7 +183,7 @@ public void run() {

block.addView(course); //Adding the course to block

for (int k = 0; k < 6; ++k) {
for (int k = 0; k < 5; ++k) {
String valueString = s.getString(indexes[k]);
if (!valueString.equals("")) {
/*
Expand Down
23 changes: 5 additions & 18 deletions app/src/main/java/tk/therealsuji/vtopchennai/VTOP.java
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,7 @@ public void downloadMarks() {
" var rows = doc.getElementById('fixedTableContainer').getElementsByTagName('tr');" +
" var heads = rows[0].getElementsByTagName('td');" +
" var columns = heads.length;" +
" var courseIndex, typeIndex, titleIndex, maxIndex, percentIndex, statusIndex, scoredIndex, weightageIndex, averageIndex, postedIndex, remarkIndex;" +
" var courseIndex, typeIndex, titleIndex, maxIndex, percentIndex, statusIndex, scoredIndex, weightageIndex, averageIndex, postedIndex;" +
" var course = '', type = '', flag = 0, k = 0;" +
" for (var i = 0; i < columns; ++i) {" +
" var heading = heads[i].innerText.toLowerCase();" +
Expand All @@ -1380,41 +1380,30 @@ public void downloadMarks() {
" var heading = heads[j].innerText.toLowerCase();" +
" if (heading.includes('title')) {" +
" titleIndex = j;" +
" ++flag;" +
" }" +
" if (heading.includes('max')) {" +
" maxIndex = j;" +
" ++flag;" +
" }" +
" if (heading.includes('%')) {" +
" percentIndex = j;" +
" ++flag;" +
" }" +
" if (heading.includes('status')) {" +
" statusIndex = j;" +
" ++flag;" +
" }" +
" if (heading.includes('scored')) {" +
" scoredIndex = j;" +
" ++flag;" +
" }" +
" if (heading.includes('weightage') && heading.includes('mark')) {" +
" weightageIndex = j;" +
" ++flag;" +
" }" +
" if (heading.includes('average')) {" +
" averageIndex = j;" +
" ++flag;" +
" }" +
" if (heading.includes('posted')) {" +
" postedIndex = j;" +
" ++flag;" +
" }" +
" if (heading.includes('remark')) {" +
" remarkIndex = j;" +
" ++flag;" +
" }" +
" }" +
" ++flag;" +
" }" +
" for (var j = 0; j < records; ++j) {" +
" var values = rows[++i].getElementsByTagName('td');" +
Expand All @@ -1427,7 +1416,6 @@ public void downloadMarks() {
" temp['weightage'] = values[weightageIndex].innerText.trim();" +
" temp['average'] = values[averageIndex].innerText.trim();" +
" temp['posted'] = values[postedIndex].innerText.trim();" +
" temp['remark'] = values[remarkIndex].innerText.trim();" +
" temp['course'] = course;" +
" temp['type'] = type;" +
" obj[k++] = temp;" +
Expand All @@ -1453,7 +1441,7 @@ public void onReceiveValue(final String obj) {
public void run() {
try {
myDatabase.execSQL("DROP TABLE IF EXISTS marks");
myDatabase.execSQL("CREATE TABLE IF NOT EXISTS marks (id INTEGER PRIMARY KEY, course VARCHAR, type VARCHAR, title VARCHAR, score VARCHAR, status VARCHAR, weightage VARCHAR, average VARCHAR, posted VARCHAR, remark VARCHAR)");
myDatabase.execSQL("CREATE TABLE IF NOT EXISTS marks (id INTEGER PRIMARY KEY, course VARCHAR, type VARCHAR, title VARCHAR, score VARCHAR, status VARCHAR, weightage VARCHAR, average VARCHAR, posted VARCHAR)");

((Activity) context).runOnUiThread(new Runnable() {
@Override
Expand All @@ -1475,7 +1463,7 @@ public void run() {
JSONObject myObj = new JSONObject(obj);

myDatabase.execSQL("DROP TABLE IF EXISTS marks");
myDatabase.execSQL("CREATE TABLE IF NOT EXISTS marks (id INTEGER PRIMARY KEY, course VARCHAR, type VARCHAR, title VARCHAR, score VARCHAR, status VARCHAR, weightage VARCHAR, average VARCHAR, posted VARCHAR, remark VARCHAR)");
myDatabase.execSQL("CREATE TABLE IF NOT EXISTS marks (id INTEGER PRIMARY KEY, course VARCHAR, type VARCHAR, title VARCHAR, score VARCHAR, status VARCHAR, weightage VARCHAR, average VARCHAR, posted VARCHAR)");

for (int i = 0; i < myObj.length(); ++i) {
JSONObject tempObj = new JSONObject(myObj.getString(Integer.toString(i)));
Expand All @@ -1487,9 +1475,8 @@ public void run() {
String weightage = tempObj.getString("weightage") + " / " + tempObj.getString("percent");
String average = tempObj.getString("average");
String posted = tempObj.getString("posted");
String remark = tempObj.getString("remark");

myDatabase.execSQL("INSERT INTO marks (course, type, title, score, status, weightage, average, posted, remark) VALUES('" + course + "', '" + type + "', '" + title + "', '" + score + "', '" + status + "', '" + weightage + "', '" + average + "', '" + posted + "', '" + remark + "')");
myDatabase.execSQL("INSERT INTO marks (course, type, title, score, status, weightage, average, posted) VALUES('" + course + "', '" + type + "', '" + title + "', '" + score + "', '" + status + "', '" + weightage + "', '" + average + "', '" + posted + "')");
}

((Activity) context).runOnUiThread(new Runnable() {
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@
<string name="weightage">Weightage Score</string>
<string name="status">Status</string>
<string name="average">Class Average</string>
<string name="remark">Remark</string>


<string name="proctor">Proctor</string>
Expand Down

0 comments on commit 0210c31

Please sign in to comment.