Moodle

Can we avoid inline CSS in mod/quiz/edit.php

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 2.0
  • Fix Version/s: 2.0
  • Component/s: Quiz
  • Labels:
    None
  • Affected Branches:
    MOODLE_20_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE

Description

Instead, can we just add, or not add, a class name to some div using PHP, and put the CSS in the theme. I am looking at lines 716 onwards.

Activity

Hide
Olli Savolainen added a comment - - edited

I did this already, but I hesitate to commit it, since it seems it will be smarter to keep the inline CSS.

The classes I created are non-semantic like bankvisible and quizwhenbankcollapsed - they do not add any semantics since they are bound to the very behaviour of the css properties, so they will just be badly named - keeping the semantics in the HTML and the style in the CSS is the idea of classes, after all. We won't reach there here, just as we do not with the special javascript class added to body (though that one may have technical reasoning).

It does not seem to make any sense to theme that specific CSS, it will just add another reference, making the code harder to read. Where is the benefit?

Show
Olli Savolainen added a comment - - edited I did this already, but I hesitate to commit it, since it seems it will be smarter to keep the inline CSS. The classes I created are non-semantic like bankvisible and quizwhenbankcollapsed - they do not add any semantics since they are bound to the very behaviour of the css properties, so they will just be badly named - keeping the semantics in the HTML and the style in the CSS is the idea of classes, after all. We won't reach there here, just as we do not with the special javascript class added to body (though that one may have technical reasoning). It does not seem to make any sense to theme that specific CSS, it will just add another reference, making the code harder to read. Where is the benefit?
Hide
Tim Hunt added a comment -

To me, the CSS class names seem more semantic than the inline CSS. Wy would it matter? Ah, here is an example. Suppose someone making a theme wanted to do something fancy, for example put rounded corners on the question bank. They would need to know the state of the question bank, because they might need to apply different style rules to the bit that stays visible in the two states.

Show
Tim Hunt added a comment - To me, the CSS class names seem more semantic than the inline CSS. Wy would it matter? Ah, here is an example. Suppose someone making a theme wanted to do something fancy, for example put rounded corners on the question bank. They would need to know the state of the question bank, because they might need to apply different style rules to the bit that stays visible in the two states.
Hide
Tim Hunt added a comment -

Actually, you already have <div class="questionbankwindow sideblock"> which is fairly semantic. Can't you just either add 'collapsed' as a third class name or not, so you either have

<div class="questionbankwindow sideblock">

or

<div class="questionbankwindow sideblock collapsed">

Show
Tim Hunt added a comment - Actually, you already have <div class="questionbankwindow sideblock"> which is fairly semantic. Can't you just either add 'collapsed' as a third class name or not, so you either have <div class="questionbankwindow sideblock"> or <div class="questionbankwindow sideblock collapsed">
Hide
Olli Savolainen added a comment -

Done.

Show
Olli Savolainen added a comment - Done.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: