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

Add and improve RTL support and remove hard-coded stuff #332

Open
wants to merge 4 commits into
base: MOODLE_310_STABLE
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 28 additions & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
Release Notes

_NOTE - The 3.10 releases will only work on Moodle 3.7, Moodle 3.8, Moodle 3.9, and Moodle 3.10.
_NOTE - The 3.9 releases will work on Moodle 3.7, Moodle 3.8, Moodle 3.9, and 3.10.
The 3.5 releases will work on Moodle 3.7, 3.6, 3.5, 3.4 and 3.3._

##### Version 3.10.0 (Build - 2020111100)
##### Version 3.9.1 (Build - 2020111801)
Improvements:
* Updates to deprecated unit test functions for 3.10.

(see CHANGES.TXT in release 3.9 for earlier changes.)
##### Version 3.9.0 (Build - 2020062300)
Improvements:

* [PR150](https://github.com/PoetOS/moodle-mod_questionnaire/pull/150): Added an indent to dependent questions on the question form.
* [PR250](https://github.com/PoetOS/moodle-mod_questionnaire/pull/250): Added calendar action events.
* [PR279](https://github.com/PoetOS/moodle-mod_questionnaire/pull/279): Added a progress bar.
* [PR281](https://github.com/PoetOS/moodle-mod_questionnaire/pull/281): Adding CSS classes to mobile question view.
* [GHI296](https://github.com/PoetOS/moodle-mod_questionnaire/issues/296): Replace deprecated 'download_as_dataformat' function.
* [GHI295](https://github.com/PoetOS/moodle-mod_questionnaire/issues/295): Filter title and subtitle fields for output.
* [PR284](https://github.com/PoetOS/moodle-mod_questionnaire/pull/284): Adding support for multilanguage in choice options.
* [PR285](https://github.com/PoetOS/moodle-mod_questionnaire/pull/285): Allow multilanguage options to be displayed correctly in conditions.
* [PR211](https://github.com/PoetOS/moodle-mod_questionnaire/pull/211): Improve upgrade step 2018050102.
* [PR306](https://github.com/PoetOS/moodle-mod_questionnaire/pull/306): Save page responses on next and prev buttons.

Bug fixes:

* [GHI288](https://github.com/PoetOS/moodle-mod_questionnaire/issues/288): Fixed incorrect date display problems.
* [GHI276](https://github.com/PoetOS/moodle-mod_questionnaire/issues/276): Ensure images are copied when a questionnaire is created from a copy.
* [GHI291/GHI299](https://github.com/PoetOS/moodle-mod_questionnaire/issues/291): Getting rid of unnecessary warnings.
* [GHI301/CONTRIB-8165](https://github.com/PoetOS/moodle-mod_questionnaire/issues/301): Allow zero as a valid answer in text boxes.
* [GHI300](https://github.com/PoetOS/moodle-mod_questionnaire/issues/300): Ensure that close date cannot be earlier than open date.
* [PR304](https://github.com/PoetOS/moodle-mod_questionnaire/pull/304): Restoring regression that removed incomplete responses checkbox.

(see CHANGES.TXT in release 3.8 for earlier changes.)
13 changes: 8 additions & 5 deletions classes/question/rate.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,13 @@ protected function question_survey_display($response, $descendantsdata, $blankqu
}
$nn = 100 - ($width * 2);
$colwidth = ($nn / $this->length).'%';
$textalign = 'right';
$width = $width . '%';
} else if ($nocontent) {
$width = '0%';
$colwidth = (100 / $this->length).'%';
$textalign = 'right';
} else {
$width = '59%';
$colwidth = (40 / $this->length).'%';
$textalign = 'left';
}

$choicetags->qelements['headerrow']['col1width'] = $width;
Expand Down Expand Up @@ -319,8 +316,7 @@ protected function question_survey_display($response, $descendantsdata, $blankqu
if ($this->osgood_rate_scale()) {
list($content, $contentright) = array_merge(preg_split('/[|]/', $content), array(' '));
}
$cols[] = ['colstyle' => 'text-align: '.$textalign.';',
'coltext' => format_text($content, FORMAT_HTML, ['noclean' => true]).' '];
$cols[] = ['coltext' => format_text($content, FORMAT_HTML, ['noclean' => true]).' '];

$bg = 'c0 raterow';
if (($nbchoices > 1) && !$this->no_duplicate_choices() && !$blankquestionnaire) {
Expand Down Expand Up @@ -389,6 +385,13 @@ protected function question_survey_display($response, $descendantsdata, $blankqu
if ($this->osgood_rate_scale()) {
$cols[] = ['coltext' => ' '.format_text($contentright, FORMAT_HTML, ['noclean' => true])];
}

$rtlmode = right_to_left() ? true : false;
if ($rtlmode) {
$cols = array_reverse($cols);
}

$choicetags->rtlmode = $rtlmode;
$choicetags->qelements['rows'][] = ['cols' => $cols];
}
}
Expand Down
16 changes: 9 additions & 7 deletions classes/responsetype/rank.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ private function mkresavg($sort, $stravgvalue='') {
$osgood = true;
$stravgrank = get_string('averageposition', 'questionnaire');
}
$stravg = '<div style="text-align:right">'.$stravgrank.$stravgvalue.'</div>';
$stravg = $stravgrank . $stravgvalue;

$isna = $this->question->precise == 1;
$isnahead = '';
Expand All @@ -462,13 +462,15 @@ private function mkresavg($sort, $stravgvalue='') {
$pagetags = new \stdClass();
$pagetags->averages = new \stdClass();

$headeralign = right_to_left() ? 'left' : 'right';

if ($isna) {
$header1 = new \stdClass();
$header1->text = '';
$header1->align = '';
$header1->align = $headeralign;
$header2 = new \stdClass();
$header2->text = $stravg;
$header2->align = '';
$header2->align = $headeralign;
$header3 = new \stdClass();
$header3->text = '&dArr;';
$header3->align = 'center';
Expand All @@ -480,20 +482,20 @@ private function mkresavg($sort, $stravgvalue='') {
$stravg = '<div style="text-align:center">'.$stravgrank.'</div>';
$header1 = new \stdClass();
$header1->text = '';
$header1->align = '';
$header1->align = $headeralign;
$header2 = new \stdClass();
$header2->text = $stravg;
$header2->align = '';
$header2->align = $headeralign;
$header3 = new \stdClass();
$header3->text = '';
$header3->align = 'center';
} else {
$header1 = new \stdClass();
$header1->text = '';
$header1->align = '';
$header1->align = $headeralign;
$header2 = new \stdClass();
$header2->text = $stravg;
$header2->align = '';
$header2->align = $headeralign;
$header3 = new \stdClass();
$header3->text = '&dArr;';
$header3->align = 'center';
Expand Down
3 changes: 0 additions & 3 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,6 @@ td.selected {
margin-bottom: 1em;
}

.dir-rtl .qn-container {
text-align: right;
}
.qn-info {
float: left;
width: auto;
Expand Down
11 changes: 9 additions & 2 deletions templates/question_rate.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

Example context (json):
{
"rtlmode": false,
"qelements": [
{
"twidth": "100%",
Expand Down Expand Up @@ -126,11 +127,17 @@
<tbody>
{{#qelements.headerrow}}
<tr>
<td style="width:{{col1width}}"></td>
{{#colnya}}<td title="nya"></td>{{/colnya}}
{{^rtlmode}}
<td style="width:{{col1width}}"></td>
{{#colnya}}<td title="nya"></td>{{/colnya}}
{{/rtlmode}}
{{#cols}}
<td style="width:{{colwidth}}; text-align:center;" class="smalltext">{{{coltext}}}</td>
{{/cols}}
{{#rtlmode}}
{{#colnya}}<td title="nya"></td>{{/colnya}}
<td style="width:{{col1width}}"></td>
{{/rtlmode}}
{{/qelements.headerrow}}
{{#qelements.rows}}
<tr class="raterow">
Expand Down
18 changes: 9 additions & 9 deletions templates/results_choice.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,22 @@
<table class="generaltable">
<thead>
<tr>
<th class="header c0" style="text-align:left;width:50%;" scope="col">{{#str}} response, mod_questionnaire {{/str}}</th>
<th class="header c1" style="text-align:left;width:40%;" scope="col">{{#str}} average, mod_questionnaire {{/str}}</th>
<th class="header c2 lastcol" style="text-align:right;width:10%;" scope="col">{{#str}} total, mod_questionnaire {{/str}}</th>
<th class="header c0" style="width:50%;" scope="col">{{#str}} response, mod_questionnaire {{/str}}</th>
<th class="header c1" style="width:40%;" scope="col">{{#str}} average, mod_questionnaire {{/str}}</th>
<th class="header c2 lastcol" style="width:10%;" scope="col">{{#str}} total, mod_questionnaire {{/str}}</th>
</tr>
</thead>
<tbody>
{{/responses.0}}
{{#responses}}
{{#response}}
<tr class="">
<td class="cell c0" style="text-align:left;width:50%;">{{response.text}}</td>
<td class="cell c1" style="text-align:left;width:40%;white-space:nowrap;">
<td class="cell c0" style="width:50%;">{{response.text}}</td>
<td class="cell c1" style="width:40%;white-space:nowrap">
<img style="height:9px; width:4px;" alt="{{response.alt1}}" src="{{response.image1}}" /><img style="height:9px; width:{{response.width2}}px;" alt="{{response.alt2}}" src="{{response.image2}}" /><img style="height:9px; width:4px;" alt="{{response.alt3}}" src="{{response.image3}}" />
{{{response.percent}}}
</td>
<td class="cell c2 lastcol" style="text-align:right;width:10%;">{{response.total}}</td>
<td class="cell c2 lastcol" style="width:10%;">{{response.total}}</td>
</tr>
{{/response}}
{{/responses}}
Expand All @@ -101,12 +101,12 @@
<td colspan="3"><div class="tabledivider"></div></td>
</tr>
<tr class="lastrow">
<td class="cell c0" style="text-align:left;width:50%;">{{#str}} totalresponses, mod_questionnaire{{/str}}</td>
<td class="cell c1" style="text-align:left;width:40%;white-space:nowrap;">
<td class="cell c0" style="width:50%;">{{#str}} totalresponses, mod_questionnaire{{/str}}</td>
<td class="cell c1" style="width:40%;white-space:nowrap;">
<img style="height:9px; width:4px;" alt="{{alt1}}" src="{{image1}}" /><img style="height:9px; width:{{width2}}px;" alt="{{alt2}}" src="{{image2}}" /><img style="height:9px; width:4px;" alt="{{alt3}}" src="{{image3}}" />
{{{percent}}}
</td>
<td class="cell c2 lastcol" style="text-align:right;width:10%;">{{total}}</td>
<td class="cell c2 lastcol" style="width:10%;">{{total}}</td>
</tr>
{{/total}}
{{#responses.0}}
Expand Down
12 changes: 6 additions & 6 deletions templates/results_date.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@
<table class="generaltable">
<thead>
<tr>
<th class="header c0" style="text-align:left;" scope="col">{{#str}} num, mod_questionnaire {{/str}}</th>
<th class="header c1 lastcol" style="text-align:right;" scope="col">{{#str}} response, mod_questionnaire {{/str}}</th>
<th class="header c0" scope="col">{{#str}} num, mod_questionnaire {{/str}}</th>
<th class="header c1 lastcol" scope="col">{{#str}} response, mod_questionnaire {{/str}}</th>
</tr>
</thead>
<tbody>
{{/responses.0}}
{{#responses}}
{{#response}}
<tr class="">
<td class="cell c0" style="text-align:left;">{{response.total}}</td>
<td class="cell c1 lastcol" style="text-align:right;">{{response.text}}</td>
<td class="cell c0">{{response.total}}</td>
<td class="cell c1 lastcol">{{response.text}}</td>
</tr>
{{/response}}
{{/responses}}
Expand All @@ -72,8 +72,8 @@
<td colspan="2"><div class="tabledivider"></div></td>
</tr>
<tr class="lastrow">
<td class="cell c0" style="text-align:left;">{{#str}} totalresponses, mod_questionnaire{{/str}}</td>
<td class="cell c1 lastcol" style="text-align:right;">{{total}}</td>
<td class="cell c0">{{#str}} totalresponses, mod_questionnaire{{/str}}</td>
<td class="cell c1 lastcol">{{total}}</td>
</tr>
{{/total}}
{{#responses.0}}
Expand Down
18 changes: 9 additions & 9 deletions templates/results_rate.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@
<tbody>

{{#choicelabelrow}}
<tr class="">
<tr>
{{#column1}}
<td class="cell" style="text-align:{{align}}; width:{{width}};" scope="col">{{{text}}}</td>
<td class="cell" style="width:{{width}};" scope="col">{{{text}}}</td>
{{/column1}}
{{#column2}}
<td class="cell" style="text-align:{{align}}; width:{{width}};" scope="col">
<td class="cell" style="width:{{width}};" scope="col">
<table style="width:100%" cellpadding="2" cellspacing="0" border="1">
<tbody>
<tr>
Expand All @@ -103,10 +103,10 @@
</td>
{{/column2}}
{{#column3}}
<td class="cell" style="text-align:{{align}}; width:{{width}};" scope="col">{{{text}}}</td>
<td class="cell" style="width:{{width}};" scope="col">{{{text}}}</td>
{{/column3}}
{{#column4}}
<td class="cell" style="text-align:{{align}}; width:{{width}};" scope="col">{{{text}}}</td>
<td class="cell" style="width:{{width}};" scope="col">{{{text}}}</td>
{{/column4}}
</tr>
{{/choicelabelrow}}
Expand All @@ -117,22 +117,22 @@
<td class="cell" style="text-align:{{align}}; width:{{width}};" scope="col">{{{text}}}</td>
{{/column1}}
{{#column2}}
<td class="cell" style="text-align:{{align}}; width:{{width}};" scope="col">
<td class="cell" style="width:{{width}};" scope="col">
{{#imageurl}}<img style="height:12px; width: 6px;{{#margin}} {{margin}};{{/margin}}" alt="" src="{{imageurl}}" />{{/imageurl}}
</td>
{{/column2}}
{{#column3}}
<td class="cell" style="text-align:{{align}}; width:{{width}};" scope="col">{{{text}}}</td>
<td class="cell" style="width:{{width}};" scope="col">{{{text}}}</td>
{{/column3}}
{{#column4}}
<td class="cell" style="text-align:{{align}}; width:{{width}};" scope="col">{{{text}}}</td>
<td class="cell" style="width:{{width}};" scope="col">{{{text}}}</td>
{{/column4}}
</tr>
{{/choiceaverages}}
{{#nodata.0}}
<tr class="">
{{#nodata}}
<td class="cell" style="text-align:{{align}}; width:{{width}};" scope="col">{{text}}</td>
<td class="cell" style="width:{{width}};" scope="col">{{text}}</td>
{{/nodata}}
</tr>
{{/nodata.0}}
Expand Down
12 changes: 6 additions & 6 deletions templates/results_text.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@
<table class="generaltable">
<thead>
<tr>
<th class="header c0" style="text-align:left;" scope="col">{{#str}} respondent, mod_questionnaire {{/str}}</th>
<th class="header c1 lastcol" style="text-align:right;" scope="col">{{#str}} response, mod_questionnaire {{/str}}</th>
<th class="header c0" scope="col">{{#str}} respondent, mod_questionnaire {{/str}}</th>
<th class="header c1 lastcol" scope="col">{{#str}} response, mod_questionnaire {{/str}}</th>
</tr>
</thead>
<tbody>
{{/responses.0}}
{{#responses}}
{{#response}}
<tr class="">
<td class="cell c0" style="text-align:left;">{{{response.respondent}}}</td>
<td class="cell c1 lastcol" style="text-align:right;">{{{response.text}}}</td>
<td class="cell c0">{{{response.respondent}}}</td>
<td class="cell c1 lastcol">{{{response.text}}}</td>
</tr>
{{/response}}
{{/responses}}
Expand All @@ -72,8 +72,8 @@
<td colspan="2"><div class="tabledivider"></div></td>
</tr>
<tr class="lastrow">
<td class="cell c0" style="text-align:left;">{{#str}} totalresponses, mod_questionnaire{{/str}}</td>
<td class="cell c1 lastcol" style="text-align:right;">{{total}}</td>
<td class="cell c0">{{#str}} totalresponses, mod_questionnaire{{/str}}</td>
<td class="cell c1 lastcol">{{total}}</td>
</tr>
{{/total}}
{{#responses.0}}
Expand Down
18 changes: 9 additions & 9 deletions templates/resultspdf_choice.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,22 @@
<table class="generaltable">
<thead>
<tr>
<th class="header c0" style="text-align:left;width:50%;" scope="col">{{#str}} response, mod_questionnaire {{/str}}</th>
<th class="header c1" style="text-align:left;width:40%;" scope="col">{{#str}} average, mod_questionnaire {{/str}}</th>
<th class="header c2 lastcol" style="text-align:right;width:10%;" scope="col">{{#str}} total, mod_questionnaire {{/str}}</th>
<th class="header c0" style="width:50%;" scope="col">{{#str}} response, mod_questionnaire {{/str}}</th>
<th class="header c1" style="width:40%;" scope="col">{{#str}} average, mod_questionnaire {{/str}}</th>
<th class="header c2 lastcol" style="width:10%;" scope="col">{{#str}} total, mod_questionnaire {{/str}}</th>
</tr>
</thead>
<tbody>
{{/responses.0}}
{{#responses}}
{{#response}}
<tr class=""{{^response.evencolor}} style="background-color: #E5E5E6"{{/response.evencolor}}>
<td class="cell c0" style="text-align:left;width:50%;">{{response.text}}</td>
<td class="cell c1" style="text-align:left;width:40%;white-space:nowrap;">
<td class="cell c0" style="width:50%;">{{response.text}}</td>
<td class="cell c1" style="width:40%;white-space:nowrap;">
<img style="height:9px; width:4px;" alt="{{response.alt1}}" src="{{response.image1}}" /><img style="height:9px; width:{{response.width2}}px;" alt="{{response.alt2}}" src="{{response.image2}}" /><img style="height:9px; width:4px;" alt="{{response.alt3}}" src="{{response.image3}}" />
{{{response.percent}}}
</td>
<td class="cell c2 lastcol" style="text-align:right;width:10%;">{{response.total}}</td>
<td class="cell c2 lastcol" style="width:10%;">{{response.total}}</td>
</tr>
{{/response}}
{{/responses}}
Expand All @@ -102,12 +102,12 @@
<td colspan="3"><div class="tabledivider"> </div></td>
</tr>
<tr class="lastrow"{{^total.evencolor}} style="background-color: #E5E5E6"{{/total.evencolor}}>
<td class="cell c0" style="text-align:left;width:50%;">{{#str}} totalresponses, mod_questionnaire{{/str}}</td>
<td class="cell c1" style="text-align:left;width:40%;white-space:nowrap;">
<td class="cell c0" style="width:50%;">{{#str}} totalresponses, mod_questionnaire{{/str}}</td>
<td class="cell c1" style="width:40%;white-space:nowrap;">
<img style="height:9px; width:4px;" alt="{{alt1}}" src="{{image1}}" /><img style="height:9px; width:{{width2}}px;" alt="{{alt2}}" src="{{image2}}" /><img style="height:9px; width:4px;" alt="{{alt3}}" src="{{image3}}" />
{{{percent}}}
</td>
<td class="cell c2 lastcol" style="text-align:right;width:10%;">{{total}}</td>
<td class="cell c2 lastcol" style="width:10%;">{{total}}</td>
</tr>
{{/total}}
{{#responses.0}}
Expand Down
Loading