Replaced custom loading of data and then question object creation using internal question_bank functionality with question_bank::load_question. Removed the call $quizobj->load_questions as it is redundant.