Ok, in our last blog entry we implemented a retrieval method for a join table which would combine the vocabulary with a scheduled review date. In this post, we are going to first test and make sure a row outside of the start and end quiz range, because it falls within the review date.
It's defaulting to level four for now, but it's making the default to be the full range of the data available. Since I'm going to have to re-install the database a few times, I need to fix this. I need to fix it anyway, so let's get it out of the way. I think if it's not found, i.e. the shared memory, it puts the end number to the number available for the database. We want to change that to 5.
O.k. That worked. Now, let's create a record on the schedule table. It has to be level 4, and the same Id as an existing row. And, it can't be in the range currently in effect.
From the previous blog: http://gettingintomobile.blogspot.com/
insert into word_review_schedule (_id, rating, last_review_date,next_review_date) values (100,"no_rating", "2001-01-01", "2011-07-15")
Ok, it's showing up on this query:
select * from v_words_schedule_join
It's the money shot - o-kane.
So, now - before I test it - I need to change the logic to allow a value outside the level number to be included:
Here it is now:
for (Question question : rows) {
cntr++;
if ((cntr >= startNum) && (cntr <= endNum)) {
// question.number is like an id
quizSequence.add(new Integer(question.number));
}
if (cntr > endNum) {
break; // no need to go further
}
}
We have to know first what the null date comes back as. Let's pretend it's null for now. And display it.
for (Question question : rows) {
cntr++;
Log.d(TAG, "question.nextReviewDate: " + question.nextReviewDate;
if (null == question.nextReviewDate) {
if ((cntr >= startNum) && (cntr <= endNum)) {
// question.number is like an id
quizSequence.add(new Integer(question.number));
}
}
else {
// it automatically adds the row if it's not null
quizSequence.add(new Integer(question.number));
}
}
It didn't come up. Let look at the log.
Ok - a lot of the dates were null - but was the right one null? It seemed like it returned a lot of records. That makes sense, because there's just one record set up. I need to dump the whole question.
Ok, it seems like money isn't showing up on the list. Why?
Ok, it's the wrong level. Change to 5.
Hmmm...it didn't show up. Not only that, my debug statements for adding the questions didn't show the data being added statements - yet they showed up on the quiz. Hmm.
Ok, when I run the select on RazorSQL, the 100 record is showing up.
select * from v_words_schedule_join
where level = 5 and (next_review_date is null or next_review_date < "2011-01-01")
Wait - did I replace the database? Rats. I let myself get distracted by two loud guys. Next time, I turn up the volume on my earphones.
I'll add a row for level 4:
insert into word_review_schedule (_id, rating, last_review_date,next_review_date) values (599,"no_rating", "2001-01-01", "2011-07-15")
Ok, I added "to export", _id 599.
Ok - a dump showed it came up as null. Really?
select * from v_words_schedule_join
where level = 4 and (next_review_date is null or next_review_date < "2011-01-01")
Ok - my problem all along was just not setting level. It's a good test, but I have to more careful when setting up data manually. As a developer, you can really save a lot of time if you *take your time*.
Ok, another problem - it's not saving the data on an update. Do I have to do a commit, or something?
insert into word_review_schedule (_id, rating, last_review_date,next_review_date) values (1098, "no_rating", "2001-01-01", "2011-07-18")
ok, now:
select * from v_words_schedule_join where next_review_date > 1
select * from all_words where _id = 1098
Ok - sweet. It's showing the added data. This was difficult because of the pickiness of the data. But - at least it's done. Where close. Next up is inserting the row.
No comments:
Post a Comment