March 6, 2022

Set Default Show Answer of Common Problem to Never on Open edX

Activities, Android Developer, Ansible, Apache2, Atlassian, Ayo Belajar Linux, Bestpath Network, BLC Telkom Klaten, BSD, Caddy Server, Case Study, Cisco, Cisco Indonesia, Cloud Computing, Cockpit, Custom Weapons, Docker, E-Learning, Engenius, Error, FreeBSD, FreeBSD Indonesia, Komunitas Pengguna Linux Indonesia, KPLI Bulukumba, KPLI Klaten, Lets Encrypt, Linux, MacOS, Microsoft Azure, Microsoft SQL Server, MikroTik, MikroTik Indonesia, MySQL, Nginx, Open edX, OpenSID, Others, PHP, phpMyAdmin, PostgreSQL, Proxmox, Python, Redash, Sendy, SSH, Stories, Subnetting, TP-Link, Ubiquiti, Unix, Virtualization, Windows, X-Mosque, Faizar Septiawan, Icar, siBunglonGanteng, Orang Ganteng, siBunglonLabs, Programmer, SysAdmin, Site Reliability Engineer, Developer, Palugada, Makassar, Ganteng, Gila, Cyclist, Panglima, Setan, Panglima Setan, sibunglon, Ganteng

By default, option show answer of Blank Common Problem component (including multiple choice components, checkboxes, etc.) was set to finished. But this configuration can be override, for example want to set it never as default. Follow the steps below:

  1. Go to Open edX server console.

  2. Open and edit file /edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/modulestore/inheritance.py.

  3. Find the following codes snippet:

    ...
        showanswer = String(
            display_name=_("Show Answer"),
            help=_(
                # Translators: DO NOT translate the words in quotes here, they are
                # specific words for the acceptable values.
                'Specify when the Show Answer button appears for each problem. '
                'Valid values are "always", "answered", "attempted", "closed", '
                '"finished", "past_due", "correct_or_past_due", and "never".'
            ),
            scope=Scope.settings,
            default="finished",
        )
    ...
    
  4. Then update the code, change part default="finished" from finished to never. See the following codes snippet:

    ...
        showanswer = String(
            display_name=_("Show Answer"),
            help=_(
                # Translators: DO NOT translate the words in quotes here, they are
                # specific words for the acceptable values.
                'Specify when the Show Answer button appears for each problem. '
                'Valid values are "always", "answered", "attempted", "closed", '
                '"finished", "past_due", "correct_or_past_due", and "never".'
            ),
            scope=Scope.settings,
            default="never",
        )
    ...
    
  5. Open and edit file /edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/capa_base.py.

  6. Find the following codes snippet:

    ...
        showanswer = String(
            display_name=_("Show Answer"),
            help=_("Defines when to show the answer to the problem. "
                   "A default value can be set in Advanced Settings."),
            scope=Scope.settings,
            default=SHOWANSWER.FINISHED,
            values=[
                {"display_name": _("Always"), "value": SHOWANSWER.ALWAYS},
                {"display_name": _("Answered"), "value": SHOWANSWER.ANSWERED},
                {"display_name": _("Attempted"), "value": SHOWANSWER.ATTEMPTED},
                {"display_name": _("Closed"), "value": SHOWANSWER.CLOSED},
                {"display_name": _("Finished"), "value": SHOWANSWER.FINISHED},
                {"display_name": _("Correct or Past Due"), "value": SHOWANSWER.CORRECT_OR_PAST_DUE},
                {"display_name": _("Past Due"), "value": SHOWANSWER.PAST_DUE},
                {"display_name": _("Never"), "value": SHOWANSWER.NEVER},
                {"display_name": _("After Some Number of Attempts"), "value": SHOWANSWER.AFTER_SOME_NUMBER_OF_ATTEMPTS},
            ]
        )
    ...
    
  7. Then update the code, change part default=SHOWANSWER.FINISHED from SHOWANSWER.FINISHED to SHOWANSWER.NEVER. See the following codes snippet:

    ...
        showanswer = String(
            display_name=_("Show Answer"),
            help=_("Defines when to show the answer to the problem. "
                   "A default value can be set in Advanced Settings."),
            scope=Scope.settings,
            default=SHOWANSWER.NEVER,
            values=[
                {"display_name": _("Always"), "value": SHOWANSWER.ALWAYS},
                {"display_name": _("Answered"), "value": SHOWANSWER.ANSWERED},
                {"display_name": _("Attempted"), "value": SHOWANSWER.ATTEMPTED},
                {"display_name": _("Closed"), "value": SHOWANSWER.CLOSED},
                {"display_name": _("Finished"), "value": SHOWANSWER.FINISHED},
                {"display_name": _("Correct or Past Due"), "value": SHOWANSWER.CORRECT_OR_PAST_DUE},
                {"display_name": _("Past Due"), "value": SHOWANSWER.PAST_DUE},
                {"display_name": _("Never"), "value": SHOWANSWER.NEVER},
                {"display_name": _("After Some Number of Attempts"), "value": SHOWANSWER.AFTER_SOME_NUMBER_OF_ATTEMPTS},
            ]
        )
    ...
    
  8. Restart LMS and CMS services.