Skip to content

Course: Let teachers choose where the introduction sits on the course home - refs #2256 - #9481

Open
ybtbeez wants to merge 1 commit into
chamilo:masterfrom
ybtbeez:fix/issue-2256-introduction-position
Open

ybtbeez wants to merge 1 commit into
chamilo:masterfrom
ybtbeez:fix/issue-2256-introduction-position

Conversation

@ybtbeez

@ybtbeez ybtbeez commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #2256

What

Teachers can choose where the course introduction sits on the course homepage: above, below, left or right of the tools. The default is above, so existing courses keep the current layout.

The position is stored as the per-course setting introduction_position (category course_homepage) in c_course_setting. No schema migration is needed; missing rows are treated as above. New courses get the default row when they are created.

Course homepage

  • CourseHome.vue applies the setting with layout classes.
  • In the teacher's view, a small Introduction position picker on the introduction block writes the setting immediately. Learners only see the result.
  • Left and right apply only at desktop widths (1024px and up). On smaller screens they stack the introduction above the tools.
  • Sequence column rule: when the course sequence column is shown on the right, a saved position of right is displayed as above, so the two columns do not overlap. The stored setting is left unchanged, so the introduction moves to the right if the sequence column is hidden later. Left can appear beside the tools with the sequence column still on the far right.

Course settings

  • A Course homepage section exposes the same setting as radio options, including a short note about the mobile and sequence-column behaviour.

Endpoint: POST /api/course-settings/introduction-position?cid=&sid=

  • Body: { "position": "above"|"below"|"left"|"right" }
  • Allowed for platform admins and teachers of that course (CourseVoter EDIT). Other users, including students and teachers of a different course, get 403. Invalid values get 400.
  • CSRF protection is the existing listener (unsafe methods, no csrf: false).

Tests

  • PHPUnit: tests/CoreBundle/Api/CourseIntroductionPositionApiTest.php — teacher can save, student is refused, invalid values are rejected, a teacher of another course is refused. All 4 tests passed against the chamilo_test_test database.
  • JS: tests/javascript/introductionPosition.test.cjs — layout resolution, including the mobile stack and the sequence-column fallback. 6 tests passed (node --test).
  • ESLint and Prettier on the changed Vue/JS files: clean.
  • ECS on the changed src/ and tests/ PHP files: clean.
  • PHPStan on the new controller and test: clean. Pre-existing PHPStan findings in CourseSettingsManager.php and CourseHelper.php are unrelated to this change. Psalm was not run (it cannot run on this box).

Security review

  • Access control: the new POST is authenticated and allows only admins and teachers of the requested course. Values are limited to the four allowed positions.
  • CSRF: POST only; the existing origin-based listener covers cookie sessions. The operation does not disable CSRF.
  • XSS / injection: the setting is an allowlisted token used as a CSS class name, never as HTML. The introduction's existing v-html rendering is unchanged.
  • DoS / path traversal / XXE: not applicable; the payload is a single short allowlisted string.

Release note

Teachers can now place the course introduction above, below, to the left or to the right of the tools, from the course homepage or from Course settings. Existing courses stay unchanged (above the tools). On small screens, left and right stack above the tools. If the course sequence column is also shown, a right-hand introduction is displayed above the tools so the two columns do not overlap.

… home - refs chamilo#2256

Add a per-course introduction_position setting (above, below, left, right;
default above) and apply it on the course homepage. Teachers can change it
from a picker on the introduction block or from the course settings page.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Home page in a course : position of the introduction of the course

1 participant