Update to v2.x. That is the first thing. There is no point in hanging on to v1.9.x any longer, support for it is declining and runs out at the end of the year I think - and then that long only due to the generosity of a Moodle Partner. What is worse, the skills base around the older Moodle releases is being lost in the shuffle to v2.x.
The v1.9.x documentation is still available, so may still be useful.
1. Dowload and install a v2.x to your local machine.
2. Download your users as a csv file with their enrollments.
3. Reset all your courses and then back them up without student data.
4. Restore the courses to the local machine and when ready, restore your users with their course enrollments. Check carefully, there is sufficient documentation on how to do this, you might want to do a few students first to make sure that it all works, then the rest of them.
Test thoroughly, make sure all processes and restorations work as they should.
Once done, back everything up and restore to your production site. Check that everything is working there and it should be OK. Yu may also want to look at this discussion as well...
Having said all this, to get you out of immediate drama, you might want to try to find the common elements causing this problem and run the replace.php. Put in the wrong html line, then enter the correct one. The trouble is you may have to do it on all the courses, the replacement string may reflect only one value at a time. This should chang all the matching values throughout the whole Moodle. Otherwise, you may have to do it all manually.