Assuming that what's inside the comma pairs is parenthetical, then it's grammatical status is debatable, but its conventional use is wrong because of the punctuation.
When analyzing a sentence, do so by removing the parenthetical information. In the specific example here, the following is the result:
You should do your home work, and if you have more extra time, you should also prepare for exams.
Or:
You should do your home work you should also prepare for exams.
Except that most people would object to that, saying that either you need to add some kind of a conjunction (in this case, the conjunction was inside the parentheses and so isn't a consideration of the surrounding text), or it should be punctuated in some way.
In short, possibilities include the following:
You should do your home work and you should also prepare for exams.
You should do your home work; you should also prepare for exams.
You should do your home work. You should also prepare for exams.
There isn't necessarily anything ungrammatical about the version of the sentence without the additional punctuation (assuming it's thought that punctuation doesn't strictly impact grammar), but it's certainly strange and would cause people to want to tweak it so it makes more sense.
So, in theory, the sentence could be analyzed as fine in both instances of the punctuation. But it's likely that, because of this issue, at least some people would object to having the conjunction inside the comma pair. In short, if using the example in the question, the short answer to the question would be something like, "Yes, using a forced interpretation, but it would be unusual."
In fact, the examples of (d1) and (d2) apply more appropriately to the first version of the sentence than to the second.
With the second version (assuming conventional punctuation), the if you have more extra time text is part of the parenthetical text and doesn't belong with a second independent clause.