Esempio n. 1
0
    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
Esempio n. 2
0
        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)


# Begin Content Reading
reader_obj.execute_content_reader(question_num,
                                    img_processor.get_page_steps(),
                                    assess_type,
                                    False,
                                    num_of_questions,
                                    subq_array,
                                    exam_number)

scripts = glob.glob("../answer_scripts/processed/"+assess_type+"/"+exam_number+".json")

# Begin Marking
for script in scripts: