Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Learning mode - Change all question styles for quiz page #7124

Merged
Merged
Show file tree
Hide file tree
Changes from 83 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
faecfc4
Update question block to newer api version
Imran92 Aug 18, 2023
a96cca4
Update quiz block to api version 2
Imran92 Aug 18, 2023
06406f3
Fix missing question block attributes with useBlockProps hook
Imran92 Aug 18, 2023
6f97ec1
Use blockprops quiz block as well
Imran92 Aug 18, 2023
723b0e0
Add block class to make theme styles load in frontend
Imran92 Aug 18, 2023
335a159
Add block class to make question styles load in frontend non LM
Imran92 Aug 18, 2023
684932c
Merge branch 'add/footer-style-update-lm-quiz' into add/change-all-qu…
Aug 21, 2023
042e21f
Wrap the question header area
Imran92 Aug 21, 2023
c244253
Remove default numbering of question list
Imran92 Aug 21, 2023
c29694b
Fix question header area styles
Imran92 Aug 21, 2023
5c722a2
Update radio button styles
Imran92 Aug 21, 2023
ec8d0e4
Move radio style to learning mode specific file
Imran92 Aug 22, 2023
37e3dcf
Update question answer block to v 2
Imran92 Aug 22, 2023
e8c967a
Use block prop wrapper to use v2 features
Imran92 Aug 22, 2023
9c10b1b
Update question description block to v2
Imran92 Aug 22, 2023
d9465cd
Use block props to enable v2 features
Imran92 Aug 22, 2023
d4c0a94
Add block class in frontend to enable styling to desc block
Imran92 Aug 22, 2023
be3b0dc
Remove extra padding from left of questions
Imran92 Aug 22, 2023
78a5c17
Fix margin after question description
Imran92 Aug 22, 2023
4a36b3f
Add wrapper around question answer
Imran92 Aug 22, 2023
c45d043
Remove unnecessary margin from mcq answers
Imran92 Aug 23, 2023
3da9b43
Margin bottom only for single line input answers
Imran92 Aug 23, 2023
99ab9d0
Border fix for single and multi line input placeholders in editor
Imran92 Aug 23, 2023
edc31c2
Remove label and add placeholder in single line answers
Imran92 Aug 23, 2023
b186db7
Fix background and text color in tinymce editor
Imran92 Aug 23, 2023
91a48b4
Make content style script conditional
Imran92 Aug 23, 2023
c65abc3
Make tinymce editor inside background transparent
Imran92 Aug 23, 2023
47a847c
Update file selector button style
Imran92 Aug 23, 2023
5a1a646
Add course theme specific file upload button styles
Imran92 Aug 23, 2023
4e94cc6
Remove italic style from max upload text
Imran92 Aug 23, 2023
ce9eea0
Add style for non course theme h2 and font sizes
Imran92 Aug 23, 2023
3062c49
Update checkbox styles
Imran92 Aug 23, 2023
6fa90cc
Specify quiz style more
Imran92 Aug 23, 2023
51ad838
Fix font size of max upload size file text
Imran92 Aug 23, 2023
a9055a6
Make styles apply to submitted quiz as well
Imran92 Aug 23, 2023
b811e36
Fix questions not aligning with title
Imran92 Aug 24, 2023
27e47e2
Fix grade not aligning with question bottom
Imran92 Aug 24, 2023
06d1237
Remove mcq options font size
Imran92 Aug 24, 2023
e9d3665
Remove font family from core css
Imran92 Aug 24, 2023
1de09fb
Remove letter spacing from file upload button text
Imran92 Aug 24, 2023
e5af76a
Remove file upload button padding to theme
Imran92 Aug 24, 2023
4d0340e
Move file upload padding to theme
Imran92 Aug 24, 2023
8148e23
Fix file upload button color and padding for non compat themes
Imran92 Aug 24, 2023
1c776df
Fix checkbox and radio background border color
Imran92 Aug 24, 2023
77f88f5
Load global preset variables inside tinymce body
Imran92 Aug 24, 2023
7e9065a
Remove extra spaces
Imran92 Aug 24, 2023
359976d
Add placeholder inside tinymce editor
Imran92 Aug 24, 2023
e403b6e
Fix spacings of tinymce script
Imran92 Aug 24, 2023
5c100e9
Remove label from multi line placeholder answer
Imran92 Aug 24, 2023
5ed9389
Move styles to common areas for editor and frontend
Imran92 Aug 24, 2023
89f6f65
Remove editor specific stylings
Imran92 Aug 24, 2023
6baff96
Remove question header styles to general file
Imran92 Aug 24, 2023
341e1f6
Add quiz class in frontend
Imran92 Aug 24, 2023
f7a9370
Change header class name
Imran92 Aug 24, 2023
1a65439
Change file upload editor text
Imran92 Aug 24, 2023
356cc38
Add grade class to apply the same styles as frontend
Imran92 Aug 24, 2023
71e747c
Fix styles for non course themes
Imran92 Aug 24, 2023
1414422
Fix lint issue
Imran92 Aug 24, 2023
c5e6996
Merge branch 'add/footer-style-update-lm-quiz' into add/change-all-qu…
Imran92 Aug 25, 2023
2beae2a
Remove placeholder text before submit
Imran92 Aug 25, 2023
3910183
Merge branch 'add/footer-style-update-lm-quiz' into add/change-all-qu…
Imran92 Aug 28, 2023
804ff9e
Simplify quiz selectors
donnapep Aug 29, 2023
bcfe828
Use class selector instead of file input selector for all quiz
Imran92 Aug 30, 2023
640e1a9
make file upload text have same font family and size as max limit
Imran92 Aug 30, 2023
37a619b
Add custom class for file input question answer
Imran92 Aug 30, 2023
d982af6
Use class selector instead of input for compat themes
Imran92 Aug 30, 2023
3a36e00
Use separate css file for tinymce stylings
Imran92 Aug 30, 2023
ab73741
Separate tinymce script and load it inside tinymce
Imran92 Aug 30, 2023
075ad5f
Tweak placeholder text for multiline question
donnapep Aug 30, 2023
c23e6c7
target class instead of input type selector
Imran92 Aug 30, 2023
46eac93
update missing radio selector
Imran92 Aug 30, 2023
98e91aa
Fix failing js test because of useBlockProps
Imran92 Aug 31, 2023
87d5543
Fix linting issue
Imran92 Aug 31, 2023
02bc872
Fix linting issues
Imran92 Aug 31, 2023
5fdbb2a
Fix phpcs
Imran92 Aug 31, 2023
798f6c7
Fix phpcs issue
Imran92 Aug 31, 2023
426cf49
Style file upload component
donnapep Sep 1, 2023
a21a8cc
File upload component style tweaks for Course theme
donnapep Sep 1, 2023
29a4b2e
Make file upload component functional
donnapep Sep 1, 2023
f9e9b57
Use translated version of esc_html
donnapep Sep 1, 2023
e70bce0
Fix border color used in some questions
donnapep Sep 1, 2023
74e9d0f
Fix it for real this time
donnapep Sep 1, 2023
ddab598
Load file upload JS for file upload question type regardless of LM en…
donnapep Sep 1, 2023
77a43eb
Fix phpcs issue for space
Imran92 Sep 4, 2023
efd1efe
Merge branch 'add/footer-style-update-lm-quiz' into add/change-all-qu…
Imran92 Sep 6, 2023
ff027ee
Add changelog
Imran92 Sep 6, 2023
081049e
Merge remote-tracking branch 'origin/add/change-all-question-styles' …
Sep 6, 2023
ebe93cd
Merge branch 'feature/frontend-improvements' into add/change-all-ques…
Imran92 Sep 7, 2023
3ae7404
Add stubs to fix psalm
Imran92 Sep 7, 2023
53183f0
Merge branch 'add/change-all-question-styles' of https://github.com/A…
Imran92 Sep 7, 2023
0c0e534
Change esc_attr to intval for int value
Imran92 Sep 7, 2023
3d59272
Change esc_attr to intval
Imran92 Sep 7, 2023
91bb7fe
Fix param type
Imran92 Sep 7, 2023
dd37651
Change input type to accept null as well
Imran92 Sep 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions assets/blocks/quiz/answer-blocks/file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { __ } from '@wordpress/i18n';
*/
const FileUploadAnswer = () => {
return (
<div className="sensei-lms-question-block__answer sensei-lms-question-block__answer--file-upload">
<div className="sensei-lms-question-block__file-input-placeholder">
{ __( 'Browse…', 'sensei-lms' ) }
<div className="wp-block-button is-style-outline sensei-lms-question-block__answer sensei-lms-question-block__answer--file-upload">
<div className="wp-block-button__link wp-element-button">
{ __( 'Choose File', 'sensei-lms' ) }
</div>
</div>
);
Expand Down
8 changes: 0 additions & 8 deletions assets/blocks/quiz/answer-blocks/multi-line.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';

/**
* Question block multi-line answer component.
*/
const MultiLineAnswer = () => {
return (
<div className="sensei-lms-question-block__answer sensei-lms-question-block__answer--multi-line">
<small className="sensei-lms-question-block__input-label">
{ __( 'Answer:', 'sensei-lms' ) }
</small>
<div className="sensei-lms-question-block__text-input-placeholder multi-line" />
</div>
);
Expand Down
1 change: 1 addition & 0 deletions assets/blocks/quiz/question-answers-block/block.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "sensei-lms/question-answers",
"apiVersion": 2,
"title": "Answers",
"description": "Question Answers.",
"parent": [ "sensei-lms/quiz-question" ],
Expand Down
13 changes: 7 additions & 6 deletions assets/blocks/quiz/question-answers-block/question-answers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@
*/
import { useContext } from '@wordpress/element';

/**
* External dependencies
*/
import classnames from 'classnames';

/**
* Internal dependencies
*/
import { AnswerFeedbackToggle } from '../answer-feedback-block/answer-feedback-toggle';
import { QuestionContext } from '../question-block/question-context';
import { useBlockProps } from '@wordpress/block-editor';

/**
* Question Description control.
Expand All @@ -26,8 +22,13 @@
hasSelected,
canHaveFeedback,
} = useContext( QuestionContext );

const blockProps = useBlockProps( {

Check warning on line 26 in assets/blocks/quiz/question-answers-block/question-answers.js

View check run for this annotation

Codecov / codecov/patch

assets/blocks/quiz/question-answers-block/question-answers.js#L26

Added line #L26 was not covered by tests
className: 'sensei-lms-question-answers-block',
} );

return (
<div className={ classnames( 'sensei-lms-question-answers-block' ) }>
<div { ...blockProps }>
{ AnswerBlock?.edit && (
<>
<AnswerBlock.edit
Expand Down
1 change: 1 addition & 0 deletions assets/blocks/quiz/question-block/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "sensei-lms/quiz-question",
"title": "Question",
"apiVersion": 2,
"description": "The building block of all quizzes.",
"parent": [
"sensei-lms/quiz"
Expand Down
32 changes: 7 additions & 25 deletions assets/blocks/quiz/question-block/question-block.editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ $block: '.sensei-lms-question-block';
.sensei-lms-question-block {

.editor-styles-wrapper .wp-block &__title, .editor-styles-wrapper .wp-block &__index {
font-size: 24px;
margin-top: 0;
margin-bottom: 0;
line-height: 1.25;
}

.editor-styles-wrapper .wp-block &__title {
Expand All @@ -22,11 +20,6 @@ $block: '.sensei-lms-question-block';
}

&__index {
position: absolute;
right: 100%;
text-align: right;
top: 0;
font-weight: bold;
white-space: nowrap;

#{$block}.is-draft & {
Expand All @@ -39,11 +32,7 @@ $block: '.sensei-lms-question-block';
}

&__grade {
position: absolute;
right: 0;
top: 0;
line-height: 32px;
font-size: 14px;
line-height: 100%;
}

&__type-selector {
Expand Down Expand Up @@ -74,26 +63,21 @@ $block: '.sensei-lms-question-block';
}
}

&__text-input-placeholder, &__file-input-placeholder {
border: 2px solid currentColor;
&__text-input-placeholder {
border: 1px solid currentColor;
border-radius: 2px;
padding: 5px;
min-height: 52px;
display: flex;

&.multi-line {
min-height: 200px;
}
}

&__file-input-placeholder {
text-transform: uppercase;
display: inline-flex;
padding: 5px 15px;
align-items: center;
justify-content: center;
font-size: 16px;
user-select: none;
&__text-input-placeholder:not(.multi-line) {
border-top: 0;
border-left: 0;
border-right: 0;
}

&__input-label {
Expand All @@ -116,7 +100,6 @@ $block: '.sensei-lms-question-block';
}

&__toggle {

&__wrapper {
flex-basis: 65px;
margin-left: 12px;
Expand Down Expand Up @@ -157,7 +140,6 @@ $block: '.sensei-lms-question-block';
}

.editor-styles-wrapper & li {
min-height: 45px;
display: flex;
align-items: baseline;
}
Expand Down
70 changes: 39 additions & 31 deletions assets/blocks/quiz/question-block/question-edit.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/**
* External dependencies
*/
import classnames from 'classnames';

/**
* WordPress dependencies
*/
import { BlockControls, InnerBlocks } from '@wordpress/block-editor';
import {
BlockControls,
InnerBlocks,
useBlockProps,
} from '@wordpress/block-editor';
import { select, useDispatch } from '@wordpress/data';
import { useCallback, useMemo, useState } from '@wordpress/element';
import { compose } from '@wordpress/compose';
Expand Down Expand Up @@ -43,6 +42,11 @@
import { QuestionTypeToolbar } from './question-type-toolbar';
import SingleQuestion from './single-question';

/**
* External dependencies
*/
import classNames from 'classnames';

let questionOptions = Object.entries( types ).map(
( [ value, settings ] ) => ( {
...settings,
Expand Down Expand Up @@ -125,7 +129,7 @@
props.meta.showValidationErrors && props.meta.validationErrors?.length;

const questionGrade = (
<div className="sensei-lms-question-block__grade">
<div className="sensei-lms-question-block__grade grade">

Check warning on line 132 in assets/blocks/quiz/question-block/question-edit.js

View check run for this annotation

Codecov / codecov/patch

assets/blocks/quiz/question-block/question-edit.js#L132

Added line #L132 was not covered by tests
{ formatGradeLabel( options.grade ) }
</div>
);
Expand Down Expand Up @@ -170,6 +174,14 @@
[ canHaveFeedback ]
);

const blockProps = useBlockProps( {

Check warning on line 177 in assets/blocks/quiz/question-block/question-edit.js

View check run for this annotation

Codecov / codecov/patch

assets/blocks/quiz/question-block/question-edit.js#L177

Added line #L177 was not covered by tests
className: classNames( 'sensei-lms-question-block', {
'is-draft': ! title,
'is-invalid': isInvalid,
'show-answer-feedback': showAnswerFeedback,
} ),
} );

if ( ! editable ) {
return (
<QuestionView
Expand All @@ -180,30 +192,26 @@
}

return (
<div
className={ classnames( 'sensei-lms-question-block', {
'is-draft': ! title,
'is-invalid': isInvalid,
'show-answer-feedback': showAnswerFeedback,
} ) }
>
{ questionIndex }
{ isSingle && <SingleQuestion { ...props } /> }
<h2 className="sensei-lms-question-block__title">
<SingleLineInput
placeholder={ __( 'Question Title', 'sensei-lms' ) }
value={ title }
onChange={ ( nextValue ) =>
setAttributes( { title: nextValue } )
}
onEnter={ selectDescription }
onRemove={ () => removeBlock( clientId ) }
/>
</h2>
{ AnswerBlock.subtitle && (
<AnswerBlock.subtitle isQuestionSelected={ hasSelected } />
) }
{ showContent && questionGrade }
<div { ...blockProps }>
<div className="sensei-lms-question-block__header">
{ questionIndex }
{ isSingle && <SingleQuestion { ...props } /> }
<h2 className="sensei-lms-question-block__title">
<SingleLineInput
placeholder={ __( 'Question Title', 'sensei-lms' ) }
value={ title }
onChange={ ( nextValue ) =>
setAttributes( { title: nextValue } )

Check warning on line 204 in assets/blocks/quiz/question-block/question-edit.js

View check run for this annotation

Codecov / codecov/patch

assets/blocks/quiz/question-block/question-edit.js#L204

Added line #L204 was not covered by tests
}
onEnter={ selectDescription }
onRemove={ () => removeBlock( clientId ) }

Check warning on line 207 in assets/blocks/quiz/question-block/question-edit.js

View check run for this annotation

Codecov / codecov/patch

assets/blocks/quiz/question-block/question-edit.js#L207

Added line #L207 was not covered by tests
/>
</h2>
{ AnswerBlock.subtitle && (
<AnswerBlock.subtitle isQuestionSelected={ hasSelected } />
) }
{ showContent && questionGrade }
</div>
{ hasSelected && shared && <SharedQuestionNotice /> }
{ showContent && (
<QuestionContext.Provider value={ questionContext }>
Expand Down
105 changes: 105 additions & 0 deletions assets/blocks/quiz/question-block/question.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,114 @@
@import '../answer-blocks/option-toggle';
@import '~@wordpress/base-styles/breakpoints';

/**
* Sensei question and question block styles shared between frontend and editor.
*/

$question-input-border-color: var(--wp--preset--color--foreground, #155E65 );

.wp-block-sensei-lms-question-description {
margin-bottom: 20px;

*:last-child {
margin-bottom: 0;
}
}

.wp-block-sensei-lms-quiz {
.wp-block-sensei-lms-quiz-question {
margin-top: clamp(3.75rem, 2.596rem + 3.846vw, 5rem);
}

.sensei-lms-question-block__title {
flex-grow: 1;
line-height: 1;

textarea {
display: block;
padding: 0;
margin: 0;
}
}

.sensei-lms-question-block__header {
margin-bottom: clamp(1.25rem, 0.096rem + 3.846vw, 2.5rem);
padding: 0;
display: flex;
align-items: baseline;
justify-content: space-between;
line-height: 1;

.sensei-lms-question-block__title {
textarea {
font-size: inherit;
}
}

.question-title {
margin: 0;
padding: 0;
}

.grade {
line-height: 1;
}
}
}

.wp-block-sensei-lms-question-answers {
color: inherit;

li:not(:last-child) {
margin-bottom: 1.25rem;
}

.wp-editor-wrap {
& * {
background: transparent;
}
}

input {
color: inherit;
}

input[type="text"]:not(.components-form-token-field__input) {
border: 0px;
border-bottom: 1px solid $question-input-border-color;
background-color: transparent;
font-family: inherit;
font-size: inherit;
padding: 0;
&:focus-visible {
outline: none;
}
}

input[type="text"]:not(.gapfill-answer-gap) {
width: 100%;
@media (min-width: $break-small) {
width: 490px;
}
}

.wp-editor-container {
border: 1px solid $question-input-border-color;
}

.sensei-lms-question-block__file-upload {
display: inline-block;
}

.sensei-lms-question-block__file-input {
display: none;
}

.max_upload_size {
margin-top: 20px;
}
}

.sensei-lms-question__answer-feedback {
--color: #DCDCDE;
$horizontal-padding: 24px;
Expand Down
1 change: 1 addition & 0 deletions assets/blocks/quiz/question-description-block/block.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "sensei-lms/question-description",
"apiVersion": 2,
"title": "Description",
"description": "Question Description.",
"parent": [ "sensei-lms/quiz-question" ],
Expand Down
Loading
Loading