Skip to content

Commit

Permalink
MDL-47562 gradereport_singleview: ui fixes and improvements
Browse files Browse the repository at this point in the history
Collection of ui improvements that did not get completed before 2.8 was released.
See the tracker for more details.
  • Loading branch information
Damyon Wiese committed Jan 29, 2015
1 parent 06c2753 commit 2a6cdc5
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 40 deletions.
10 changes: 9 additions & 1 deletion grade/report/singleview/classes/local/screen/grade.php
Expand Up @@ -71,6 +71,14 @@ public static function filter($item) {
!($item->is_course_item() || $item->is_category_item());
}

/**
* Get the label for the select box that chooses items for this page.
* @return string
*/
public function select_label() {
return get_string('selectuser', 'gradereport_singleview');
}

/**
* Get the description of this page
* @return string
Expand Down Expand Up @@ -278,7 +286,7 @@ public function pager() {
* @return string
*/
public function heading() {
return $this->item->get_name();
return get_string('gradeitem', 'gradereport_singleview', $this->item->get_name());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion grade/report/singleview/classes/local/screen/screen.php
Expand Up @@ -200,7 +200,7 @@ public function make_toggle_links($key) {
* @return string
*/
public function heading() {
return get_string('pluginname', 'gradereport_singleview');
return get_string('entrypage', 'gradereport_singleview');
}

/**
Expand Down
5 changes: 3 additions & 2 deletions grade/report/singleview/classes/local/screen/select.php
Expand Up @@ -104,10 +104,11 @@ public function html() {

$url = new moodle_url('/grade/report/singleview/index.php', $params);

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

if (empty($html)) {
$OUTPUT->notification(get_string('noscreens', 'gradereport_singleview'));
Expand Down
Expand Up @@ -40,6 +40,12 @@ interface selectable_items {
*/
public function description();

/**
* Get the label for the select box that chooses items for this page.
* @return string
*/
public function select_label();

/**
* Get the list of options to show.
* @return array
Expand Down
8 changes: 6 additions & 2 deletions grade/report/singleview/classes/local/screen/tablelike.php
Expand Up @@ -183,22 +183,26 @@ public function html() {

$underlying = get_class($this);

$data = new stdClass;
$data = new stdClass();
$data->table = $table;
$data->instance = $this;

$buttonattr = array('class' => 'singleview_buttons submit');
$buttonhtml = implode(' ', $this->buttons());

$buttons = html_writer::tag('div', $buttonhtml, $buttonattr);
$selectview = new select($this->courseid, $this->itemid, $this->groupid);

$sessionvalidation = html_writer::empty_tag('input',
array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));

return html_writer::tag('form',
$html = $selectview->html();
$html .= html_writer::tag('form',
$buttons . html_writer::table($table) . $this->bulk_insert() . $buttons . $sessionvalidation,
array('method' => 'POST')
);
$html .= $selectview->html();
return $html;
}

/**
Expand Down
26 changes: 14 additions & 12 deletions grade/report/singleview/classes/local/screen/user.php
Expand Up @@ -52,6 +52,14 @@ class user extends tablelike implements selectable_items {
/** @var int $requirespaging Do we have more items than the paging limit? */
private $requirespaging = true;

/**
* Get the label for the select box that chooses items for this page.
* @return string
*/
public function select_label() {
return get_string('selectgrade', 'gradereport_singleview');
}

/**
* Get the description for the screen.
*
Expand Down Expand Up @@ -83,15 +91,6 @@ public function item_type() {
return 'grade';
}

/**
* Should we show the group selector on this screen?
*
* @return bool
*/
public function display_group_selector() {
return false;
}

/**
* Init the screen
*
Expand All @@ -103,9 +102,12 @@ public function init($selfitemisempty = false) {
if (!$selfitemisempty) {
$validusers = $this->load_users();
if (!isset($validusers[$this->itemid])) {
print_error('invaliduserid');
// If the passed user id is not valid, show the first user from the list instead.
$this->item = reset($validusers);
$this->itemid = $this->item->id;
} else {
$this->item = $validusers[$this->itemid];
}
$this->item = $validusers[$this->itemid];
}

$params = array('courseid' => $this->courseid);
Expand Down Expand Up @@ -282,7 +284,7 @@ private function category($item) {
* @return string
*/
public function heading() {
return fullname($this->item);
return get_string('gradeuser', 'gradereport_singleview', fullname($this->item));
}

/**
Expand Down
5 changes: 3 additions & 2 deletions grade/report/singleview/index.php
Expand Up @@ -42,6 +42,7 @@

$courseparams = array('id' => $courseid);
$PAGE->set_url(new moodle_url('/grade/report/singleview/index.php', $courseparams));
$PAGE->set_pagelayout('incourse');

if (!$course = $DB->get_record('course', $courseparams)) {
print_error('nocourseid');
Expand Down Expand Up @@ -138,13 +139,13 @@
$navparams['itemid'] = $reloptionssorting[$i - 1];
$link = new moodle_url('/grade/report/singleview/index.php', $navparams);
$navprev = html_writer::link($link, $OUTPUT->larrow() . ' ' . $reloptions[$reloptionssorting[$i - 1]]);
$graderleftnav = html_writer::tag('small', $navprev, array('class' => 'itemnav previtem'));
$graderleftnav = html_writer::tag('div', $navprev, array('class' => 'itemnav previtem'));
}
if ($i < count($reloptionssorting) - 1) {
$navparams['itemid'] = $reloptionssorting[$i + 1];
$link = new moodle_url('/grade/report/singleview/index.php', $navparams);
$navnext = html_writer::link($link, $reloptions[$reloptionssorting[$i + 1]] . ' ' . $OUTPUT->rarrow());
$graderrightnav = html_writer::tag('small', $navnext, array('class' => 'itemnav nextitem'));
$graderrightnav = html_writer::tag('div', $navnext, array('class' => 'itemnav nextitem'));
}
}

Expand Down
6 changes: 6 additions & 0 deletions grade/report/singleview/lang/en/gradereport_singleview.php
Expand Up @@ -31,6 +31,7 @@
$string['bulklegend'] = 'Bulk insert';
$string['bulkperform'] = 'Perform bulk insert';
$string['bulkfor'] = 'Grades for {$a}';
$string['entrypage'] = 'Grade user or grade item';
$string['exclude'] = 'Exclude';
$string['excludeall'] = 'Exclude all grades';
$string['excludefor'] = 'Exclude for {$a}';
Expand All @@ -39,6 +40,8 @@
$string['feedbackfor'] = 'Feedback for {$a}';
$string['filtergrades'] = 'Show grades for {$a}.';
$string['gradefor'] = 'Grade for {$a}';
$string['gradeitem'] = 'Grade item: {$a}';
$string['gradeuser'] = 'Grade user: {$a}';
$string['noscreens'] = 'Could not find a suitable single view screen.';
$string['gradeitemcannotbeoverridden'] = 'This grade item cannot be overridden.';
$string['notvalid'] = 'Not a valid Single view screen: {$a}';
Expand All @@ -49,6 +52,9 @@
$string['pluginname'] = 'Single view';
$string['savegrades'] = 'Saving grades';
$string['savegradessuccess'] = 'Grades were set for {$a} items';
$string['selectgrade'] = 'Select grade item...';
$string['selectuser'] = 'Select user...';
$string['singleview:view'] = 'View report';
$string['summarygrade'] = 'A table of users, with columns for range, grade, feedback, and whether to override or exclude a particular grade.';
$string['summaryuser'] = 'A table of grade items, with columns for grade category, range, grade, feedback, and whether to override or exclude a particular grade.';
$string['userselect'] = 'Select activity';
2 changes: 1 addition & 1 deletion grade/report/singleview/lib.php
Expand Up @@ -107,7 +107,7 @@ public function __construct($courseid, $gpr, $context, $itemtype, $itemid, $unus
*/
public function output() {
global $OUTPUT;
return $OUTPUT->box($this->screen->html());
return $OUTPUT->container($this->screen->html(), 'reporttable');
}
}

76 changes: 57 additions & 19 deletions grade/report/singleview/styles.css
@@ -1,73 +1,102 @@
.path-grade-report-singleview div.generalbox {
margin: 0 20px 15px 20px;
.path-grade-report-singleview div.reporttable {
text-align: center;
}

.path-grade-report-singleview div.generalbox div.singleselect form div {
.path-grade-report-singleview div.groupselector,
.path-grade-report-singleview div.reporttable form div.singleview_buttons,
.path-grade-report-singleview div.selectitems {
display: block;
text-align: right;
clear: both;
}
.dir-rtl.path-grade-report-singleview div.groupselector,
.dir-rtl.path-grade-report-singleview div.reporttable form div.singleview_buttons,
.dir-rtl.path-grade-report-singleview div.selectitems {
text-align: left;
}

.path-grade-report-singleview div.singleselect+div.singleselect select,
.path-grade-report-singleview div.groupselector select {
margin-right: 0px;
}
dir-rtl.path-grade-report-singleview div.singleselect+div.singleselect select,
dir-rtl.path-grade-report-singleview div.groupselector select {
margin-right: 10px;
margin-left: 0px;
}

.path-grade-report-singleview div.reporttable div.singleselect form div {
text-align: center;
}

.path-grade-report-singleview div.generalbox table.generaltable {
.path-grade-report-singleview div.reporttable table.reporttable {
margin: 0 auto 15px auto;
}

.path-grade-report-singleview div.generalbox form div {
.path-grade-report-singleview div.reporttable form div {
text-align: center;
}

.path-grade-report-singleview .singleview_buttons {
padding: 10px 0;
}

.path-grade-report-singleview div.generalbox h2 {
.path-grade-report-singleview div.reporttable h2 {
text-align: center;
}

.path-grade-report-singleview input[name^="finalgrade"] {
width: 50px;
}
.path-grade-report-singleview .generaltable tbody th {
.path-grade-report-singleview .reporttable tbody th,
.path-grade-report-singleview .reporttable tbody td.range {
white-space: nowrap;
}
.path-grade-report-singleview .generaltable tbody th > * {
.path-grade-report-singleview .reporttable tbody th > * {
display: inline-block;
vertical-align: middle;
margin: 0 2px;
}

.path-grade-report-singleview #region-main h2, .paging{
text-align: center;
clear: both;
}

.path-grade-report-singleview .itemnav {
font-size: small;
display: inline;
margin-bottom: 0.5em;
}
.path-grade-report-singleview itemnav.previtem {
float:left;
}
.path-grade-report-singleview.dir-rtl small.previtem {
.path-grade-report-singleview.dir-rtl div.previtem {
float:right;
}
.path-grade-report-singleview small.nextitem {
.path-grade-report-singleview div.nextitem {
float:right;
}
.path-grade-report-singleview.dir-rtl small.nextitem {
.path-grade-report-singleview.dir-rtl div.nextitem {
float:left;
}
.path-grade-report-singleview .generaltable {
.path-grade-report-singleview .reporttable {
width: 100%;
}
.path-grade-report-singleview .generaltable th {
.path-grade-report-singleview .reporttable th {
text-align: left;
}

.dir-rtl.path-grade-report-singleview .generaltable th {
.dir-rtl.path-grade-report-singleview .reporttable th {
text-align: right;
}

.path-grade-report-singleview div.generalbox form div.singleview_bulk {
.path-grade-report-singleview div.reporttable 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 {
.dir-rtl.path-grade-report-singleview div.reporttable form div.singleview_bulk {
text-align: right;
}

Expand All @@ -78,13 +107,22 @@
margin: 0;
}

.path-grade-report-singleview .singleselect select,
.path-grade-report-singleview div.reporttable form .singleview_bulk select,
.path-grade-report-singleview div.reporttable form .singleview_bulk input {
margin-left: 10px;
margin-right: 10px;
}


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

.path-grade-report-singleview div.generalbox form .singleview_bulk > div.enable {
.path-grade-report-singleview div.reporttable form .singleview_bulk > div.enable {
margin-bottom: 0.5em;
text-align: left;
}
.dir-rtl.path-grade-report-singleview div.generalbox form .singleview_bulk > div.enable {
.dir-rtl.path-grade-report-singleview div.reporttable form .singleview_bulk > div.enable {
text-align: right;
}
}

0 comments on commit 2a6cdc5

Please sign in to comment.