Skip to content

Conversation

@irtazaakram
Copy link
Member

Pending Work:

@irtazaakram irtazaakram moved this to 🏗 In progress in Aximprovements Team Dec 23, 2025
@irtazaakram irtazaakram added the create-sandbox open-craft-grove should create a sandbox environment from this PR label Jan 5, 2026
@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@irtazaakram irtazaakram force-pushed the deprecate-FEATURES_WITH_GRADING_METHOD_IN_PROBLEMS branch from f32df84 to 0d92c08 Compare January 5, 2026 14:12
@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@irtazaakram irtazaakram marked this pull request as ready for review January 28, 2026 08:24
the student answers. The student answers will always remain the same over time.
"""
oldcmap = correct_map if self.is_grading_method_enabled else self.correct_map
oldcmap = correct_map if correct_map is not None else self.correct_map
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a logic change from what was there previously. I would have expected this line to be updated to just be, oldcmap = correct_map, why still have this conditional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had to fall back to self.correct_map because correct_map can be None on the first grading pass, and hint logic assumes oldcmap is always a valid/non-null CorrectMap.

    def get_hints(self, student_answers, new_cmap, old_cmap):  # pylint: disable=too-many-locals
        """
        Generate adaptive hints for this problem based on student answers, the old CorrectMap,
        and the new CorrectMap produced by get_score.
    
        Does not return anything.
    
        Modifies new_cmap, by adding hints to answer_id entries as appropriate.
        """
    
        hintfn = None
        hint_function_provided = False
        hintgroup = self.xml.find("hintgroup")
        if hintgroup is not None:
            hintfn = hintgroup.get("hintfn")
            if hintfn is not None:
                hint_function_provided = True
    
        if hint_function_provided:
            # if a hint function has been supplied, it will take precedence
            # Hint is determined by a function defined in the <script> context; evaluate
            # that function to obtain list of hint, hintmode for each answer_id.
    
            # The function should take arguments (answer_ids, student_answers, new_cmap, old_cmap)
            # and it should modify new_cmap as appropriate.
    
            # We may extend this in the future to add another argument which provides a
            # callback procedure to a social hint generation system.
    
            global CORRECTMAP_PY  # pylint: disable=global-statement
            if CORRECTMAP_PY is None:
                # We need the CorrectMap code for hint functions. No, this is not great.
                CORRECTMAP_PY = inspect.getsource(correctmap)
    
            code = (
                CORRECTMAP_PY
                + "\n"
                + self.context["script_code"]
                + "\n"
                + textwrap.dedent(
                    """
                    new_cmap = CorrectMap()
                    new_cmap.set_dict(new_cmap_dict)
                    old_cmap = CorrectMap()
                    old_cmap.set_dict(old_cmap_dict)
                    {hintfn}(answer_ids, student_answers, new_cmap, old_cmap)
                    new_cmap_dict.update(new_cmap.get_dict())
                    old_cmap_dict.update(old_cmap.get_dict())
                    """
                ).format(hintfn=hintfn)
            )
            globals_dict = {
                "answer_ids": self.answer_ids,
                "student_answers": student_answers,
                "new_cmap_dict": new_cmap.get_dict(),
>               "old_cmap_dict": old_cmap.get_dict(),
            }
E           AttributeError: 'NoneType' object has no attribute 'get_dict'

xmodule/capa/responsetypes.py:475: AttributeError

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

create-sandbox open-craft-grove should create a sandbox environment from this PR

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

4 participants