rw-moore / SciLO

GNU General Public License v3.0
0 stars 0 forks source link

Fix Sage Script #12

Closed haotianzhu closed 5 years ago

haotianzhu commented 5 years ago

Any sage script has 2 parameters: attempt and answers and they should be JSON format. But we should not send whole attempt JSON objects to those script

https://github.com/Mallorne/SciLO/blob/69cd3375bbff0fca84a2d9abdca056218e1c50ba/polls/script/mathexpress.py#L7

=>

    def run(self, student_answer, answers):
        '''
        student_answer: {} which is ResponseAttempt json
        answers: [{}] which is list of Answer json
        '''
        matched_answer = []
        ignore_case = self.__args__.get('ignore_case', False)
        student_answer_value = student_answer

        for answer in answers:
            if ignore_case:
                if answer['content'].lower() == student_answer_value.lower():
                    matched_answer.append(answer)
                    break
            else:
                if answer['content'] == student_answer_value:
                    matched_answer.append(answer)
                    break
        return matched_answer