Skip to content

Error for template preview on question creation #68

@Kemmotar83

Description

@Kemmotar83

Hi,

we experienced the following problem.

When a teacher tries to create a new Shortmath question, a permission error occurs. You can see it in the screenshot below (in a popup window).
image

In the question creation page, the page loads the Default template and correctly tries to preview it through a web service call to external function qtype_shortmath_get_template, which calls the get_template function inside the editor_template.
Inside this function template_require_capability_on is called, where the viewall capability is checked (template_has_capability_on) but, since Default template is assigned to system context and course teachers has no system capabilities, obviously a permission error occurs.

A workaround is to assign viewall capability to the Authenticated user role, since it is not assigned by default.
Maybe for "preview only" purpose users should not need any capability, which should be requested only inside template editor.

Steps to reproduce the behavior (after plugin installation):

  1. Create a "test user"
  2. Create a "test course"
  3. Enrol the "test user" in the "test course" with role "editing teacher"
  4. Log in as "test user"
  5. Go to "test course"
  6. Go to Question bank
  7. Create a new Shortmath question
  8. See the error as described before

Thanks,
Giorgio

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions