inspectorG4dget / AnonymousFeedback

1 stars 0 forks source link

Allow submissions of multiple feedbacks for a single section by a student #45

Closed scriptbae closed 7 years ago

scriptbae commented 7 years ago

Currently, a student may only submit feedback for a DGD section once; subsequent attempts result in an error linked to a database constraint.

Expected behaviour is to have older feedback for a DGD section by the same student to be ovewritten with new feedback.

scriptbae commented 7 years ago

After several approaches, I'm concluding that this would require a total rework of the schema for FEEDBACK as the composite key consists of every column in the table, meaning that simply converting this to an UPDATE statement is difficult.

This will be a topic of discussion at an in-person meeting Monday morning.

scriptbae commented 7 years ago

For the record, the approach tried was expanding dbhandler.submitFeedback to be:

def submitFeedback(student_number, course_code, section, fb):
    year, semester = getYearSemester()

    # extract individual feedback fields
    try:
        taID, q1, q2, q3, feedback = fb['taID'], fb['q1'], fb['q2'], fb['q3'], fb['feedback']
    except ValueError as e:
        return 'ValueError in submitFeedback'

    c = conn.cursor()

    # the feedback table has a constraint restricting duplicate entries
    try:
        c.execute('''
            INSERT INTO feedback
                (student, course, section, currYear, semester, taID, q1, q2, q3, feedback) VALUES
                (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)''' ,
            (student_number, course_code, section, year, semester, taID, q1, q2, q3, feedback))
        conn.commit()
        return 'success'
    except pg8000.ProgrammingError as e:
        conn.rollback()
        c.execute('''
            UPDATE feedback SET q1=%s, q2=%s, q3=%s, feedback=%s
                WHERE
                student=%s AND
                course=%s AND
                section=%s AND
                currYear=%s AND
                semester=%s''', (q1, q2, q3, feedback, student_number, course_code, section, year, semester))
    except Exception:
        print('fail')
        return 'fail'

An attempt at running this UPDATE query was also done via the psql command line, however this attempt hung indefinitely with no reason given.

scriptbae commented 7 years ago

After discussion with @inspectorG4dget, it's been determined that this feature will not be implemented regardless of review of the database structure down the line. The main justifications for this are that:

Further work to implement this feature will be halted unless this decision is reversed at some point in the future.