Others have done a great job answering your question. Yes, it will affect your GPA, but since you are in middle school, it won't be on your college applications, so it is not that terrible. However, if you are applying to a private high school, it can be an issue.
Just work really hard on your remaining tests and final exam. In my personal experience, teachers will be impressed with your improvement and may even ignore your midterm score if you do well enough on the final exam.