Skip to content

Commit

Permalink
MDL-47980 gradebook: add labels and legends missing from single view
Browse files Browse the repository at this point in the history
  • Loading branch information
Jetha Chan committed Nov 6, 2014
1 parent dc3fab7 commit dd01789
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 10 deletions.
17 changes: 15 additions & 2 deletions grade/report/singleview/classes/local/screen/screen.php
Expand Up @@ -157,12 +157,25 @@ public function fetch_grade_or_default($item, $userid) {
public function make_toggle($key) {
$attrs = array('href' => '#');

// Do proper lang strings for title attributes exist for the given key?
$strmanager = \get_string_manager();
$titleall = get_string('all');
$titlenone = get_string('none');
if ($strmanager->string_exists(strtolower($key) . 'all', 'gradereport_singleview')) {
$titleall = get_string(strtolower($key) . 'all', 'gradereport_singleview');
}
if ($strmanager->string_exists(strtolower($key) . 'none', 'gradereport_singleview')) {
$titlenone = get_string(strtolower($key) . 'none', 'gradereport_singleview');
}

$all = html_writer::tag('a', get_string('all'), $attrs + array(
'class' => 'include all ' . $key
'class' => 'include all ' . $key,
'title' => $titleall
));

$none = html_writer::tag('a', get_string('none'), $attrs + array(
'class' => 'include none ' . $key
'class' => 'include none ' . $key,
'title' => $titlenone
));

return html_writer::tag('span', "$all / $none", array(
Expand Down
5 changes: 3 additions & 2 deletions grade/report/singleview/classes/local/screen/select.php
Expand Up @@ -99,9 +99,10 @@ public function html() {
);

$url = new moodle_url('/grade/report/singleview/index.php', $params);
$html .= $OUTPUT->heading($screen->description());

$html .= $OUTPUT->single_select($url, 'itemid', $options);
$select = new \single_select($url, 'itemid', $options);
$select->set_label($screen->description());
$html .= $OUTPUT->render($select);
}

if (empty($html)) {
Expand Down
42 changes: 38 additions & 4 deletions grade/report/singleview/classes/local/ui/bulk_insert.php
Expand Up @@ -85,22 +85,56 @@ public function get_insert_value($data) {
* @return string HTML
*/
public function html() {
$insertgrade = get_string('bulkinsertgrade', 'gradereport_singleview');
$insertvalue = get_string('bulkinsertvalue', 'gradereport_singleview');
$insertappliesto = get_string('bulkappliesto', 'gradereport_singleview');

$apply = html_writer::checkbox($this->applyname, 1, false, $insertgrade);
$insertoptions = array(
'all' => get_string('all_grades', 'gradereport_singleview'),
'blanks' => get_string('blanks', 'gradereport_singleview')
);

$selectlabel = html_writer::label(
$insertappliesto,
$this->selectname
);
$select = html_writer::select(
$insertoptions, $this->selectname, 'blanks', false
);

$label = html_writer::tag('label', $insertappliesto);
$textlabel = html_writer::label(
$insertvalue,
$this->insertname
);
$text = new text_attribute($this->insertname, "0", 'bulk');
return implode(' ', array($apply, $text->html(), $label, $select));

$inner = implode(' ', array(
$selectlabel,
$select,
$textlabel,
$text->html()
));

$fieldset = html_writer::tag(
'fieldset',
html_writer::tag(
'legend',
get_string('bulklegend', 'gradereport_singleview'),
array(
'class' => 'accesshide'
)
) .
$inner
);

$apply = html_writer::checkbox(
$this->applyname,
1,
false,
get_string('bulkperform', 'gradereport_singleview')
);
$applydiv = html_writer::div($apply, 'enable');

return $applydiv . $fieldset;
}

/**
Expand Down
6 changes: 4 additions & 2 deletions grade/report/singleview/lang/en/gradereport_singleview.php
Expand Up @@ -26,8 +26,10 @@
$string['all_grades'] = 'All grades';
$string['assessmentname'] = 'Assessment Name';
$string['blanks'] = 'Empty grades';
$string['bulkappliesto'] = 'for';
$string['bulkinsertgrade'] = 'Bulk insert';
$string['bulkappliesto'] = 'For';
$string['bulkinsertvalue'] = 'Insert value';
$string['bulklegend'] = 'Bulk insert';
$string['bulkperform'] = 'Perform bulk insert';
$string['bulkfor'] = 'Grades for {$a}';
$string['exclude'] = 'Exclude';
$string['excludeall'] = 'Exclude all grades';
Expand Down
28 changes: 28 additions & 0 deletions grade/report/singleview/styles.css
@@ -1,5 +1,6 @@
.path-grade-report-singleview div.generalbox {
margin: 0 20px 15px 20px;
text-align: center;
}

.path-grade-report-singleview div.generalbox div.singleselect form div {
Expand Down Expand Up @@ -60,3 +61,30 @@
.dir-rtl.path-grade-report-singleview .generaltable th {
text-align: right;
}

.path-grade-report-singleview div.generalbox form div.singleview_bulk {
display: inline-block;
text-align: left;
margin-bottom: 1em;
}
.dir-rtl.path-grade-report-singleview div.generalbox form div.singleview_bulk {
text-align: right;
}

.path-grade-report-singleview .singleview_bulk div > *,
.path-grade-report-singleview .singleview_bulk fieldset > * {
display: inline-block;
vertical-align: middle;
margin: 0;
}

.path-grade-report-singleview .singleview_bulk > fieldset {
display: block;
}

.path-grade-report-singleview div.generalbox form .singleview_bulk > div.enable {
text-align: left;
}
.dir-rtl.path-grade-report-singleview div.generalbox form .singleview_bulk > div.enable {
text-align: right;
}
10 changes: 10 additions & 0 deletions grade/report/singleview/tests/behat/singleview.feature
Expand Up @@ -95,6 +95,16 @@ Feature: We can use Single view
And I follow "Single view for Student 1"
Then I should see "Student 1"

@javascript
Scenario: I can bulk update grades.
Given I follow "Single view for Student 1"
Then I should see "Student 1"
When I click on "All grades" "option"
And I set the field "Insert value" to "1.0"
And I click on "Perform bulk insert" "checkbox"
And I press "Update"
Then I should see "Grades were set for 9 items"

Scenario: Navigation works in the Single view.
Given I follow "Single view for Student 1"
Then I should see "Student 1"
Expand Down

0 comments on commit dd01789

Please sign in to comment.