Learning the material well and getting good grades are not necessarily correlated. If an assignment has grading rubrics, satisfy them literally and you'll get a good grade. As for really learning the material, it's often challenging to do within the timeline allowed for a course, especially with other courses competing for your attention. Just try to do well and get through the semester/quarter, then afterward when you have more free time, pick the subjects that speak to you and go through the material again, this time with the objective of internalizing the knowledge. Feel free to supplement your school material with material from other sources. Remember that what you're learning in school will only scratch the surface of CS; the real learning, if you choose to pursue it, will happen afterward.
Best of luck!