def prepare_memo(self, memo_path, tot_num_questions, sub_questions_arr, memo_id): memo_src = db_controller.get_memo_path(memo_id) subq_array = db_controller.get_subquestions_count(memo_id) reader_obj = ContentReader(23) img_processor = ImageProcessor(tot_num_questions, subq_array) house_keeper.create_dirs(tot_num_questions, sub_questions_arr) file_path = db_controller.get_memo_path(memo_id) memo_script_id = file_path[file_path.rfind("/") + 1:file_path.find(".")] if (memo_path.lower().endswith('.zip')): try: questions = img_processor.unzip_files(memo_path) ext = "zip" except Error as e: e.print_error() sys.exit(0) elif (memo_path.lower().endswith('.pdf')): try: memo_scripts_path = "../../../../marker/memo/" + db_controller.get_assesment_type( memo_id) questions = img_processor.convert_pdf2img( memo_path, memo_scripts_path) ext = "pdf" except Error as e: e.print_error() sys.exit(0) for index in range(0, tot_num_questions): file_name = questions[index] img_processor.read_img(file_name) img_processor.execute_slicer(index + 1, reader_obj) question_num = 1 reader_obj.execute_content_reader( question_num, img_processor.get_page_steps(), str(db_controller.get_assesment_type(memo_id)), True, tot_num_questions, sub_questions_arr, memo_script_id) house_keeper.delete_dirs(tot_num_questions) return
# Initialize variables answer_scripts_file = "../answer_scripts/unprocessed/"+str(file_path) answer_scripts_path = "../answer_scripts/unprocessed/"+db_controller.get_assesment_type(q_memo_id); num_questions = 0 question_num = 1 ext = "" exam_number = file_path[file_path.rfind("/")+1:file_path.find(".")] reader_obj = ContentReader(23) img_processor = ImageProcessor(num_of_questions, subq_array) if(file_path.lower().endswith('.zip')): questions = img_processor.unzip_files(answer_scripts_file) ext = "zip" elif(file_path.lower().endswith('.pdf')): try: questions = img_processor.convert_pdf2img(answer_scripts_file, answer_scripts_path) ext = "pdf" except Error as e: e.print_error() house_keeper.delete_dirs(num_of_questions) sys.exit(0) obt_mark = None result_status = None ink_color = None # Begin Image Processing for index in range(0, len(questions)): file_name = questions[index] img_processor.read_img(file_name) img_processor.execute_slicer(index + 1, reader_obj)