It seems that due to your experience of failing, your motivation has gone down. Label your emotions when you sit to study. What do you feel? What are the various emotions involved? Is it anger, guilt etc?
Secondly assess how committed you are towards achieving your goal and evaluate your strengths and weaknesses that play a vital role in your achievement of your ultimate goal. Change your strategy of studying. Break down your ultimate goal into short term goals. Your short term daily goals should be realistic and moderately difficult (between too easy and too difficult) . Once you start finishing these goals your motivation will increase. Try to engage in mock competition with friends studying for the same course. It will help you give a feedback about how much effort is needed and if any change of strategy is required. Set up a schedule for your day, eat healthy, get enough sleep and exercise.