Commit c0f494c2 authored by Nigel McNie's avatar Nigel McNie
Browse files

Major tidy up of view feedback.

The format is now much easier to read and style. Users have icons beside their names. Language strings are translated.
parent 4524e5e5
......@@ -84,6 +84,7 @@ $string['addusertogroup'] = 'Add this user to a group';
// view view
$string['addedtowatchlist'] = 'This view has been added to your watchlist';
$string['attachment'] = 'Attachment';
$string['removedfromwatchlist'] = 'This view has been removed from your watchlist';
$string['addfeedbackfailed'] = 'Add feedback failed';
$string['addtowatchlist'] = 'Add view to watchlist';
......@@ -106,7 +107,8 @@ $string['nopublicfeedback'] = 'No public feedback';
$string['notifysiteadministrator'] = 'Notify site administrator';
$string['placefeedback'] = 'Place feedback';
$string['print'] = 'Print';
$string['private'] = 'Private';
$string['thisfeedbackispublic'] = 'This feedback is public';
$string['thisfeedbackisprivate'] = 'This feedback is private';
$string['makeprivate'] = 'Change to Private';
$string['reportobjectionablematerial'] = 'Report objectionable material';
$string['reportsent'] = 'Your report has been sent';
......
......@@ -19,9 +19,9 @@
</div>
</div>
<div id="publicfeedback">
<table id="feedbacktable">
<table id="feedbacktable" class="fullwidth">
<thead>
<tr><th colspan=5>{str tag=feedback section=view}</th></tr>
<tr><th>{str tag="feedback" section="view"}</th></tr>
</thead>
</table>
</div>
......
......@@ -74,9 +74,10 @@ else {
. ($public ? ' AND (public = 1 OR author = ' . $userid . ')' : ''));
$feedback = get_records_sql_array('
SELECT
f.id, f.author, f.ctime, f.message, f.public, f.attachment, a.title
f.id, f.author, f.ctime, f.message, f.public, f.attachment, a.title, af.size
FROM {view_feedback} f
LEFT OUTER JOIN {artefact} a ON f.attachment = a.id
LEFT OUTER JOIN {artefact_file_files} af ON af.artefact = a.id
WHERE view = ' . $view
. ($public ? ' AND (f.public = 1 OR f.author = ' . $userid . ')' : '') . '
ORDER BY id DESC', '', $offset, $limit);
......@@ -90,13 +91,15 @@ if ($feedback) {
'table' => $table,
'ownedbythisuser' => ( $owner == $userid ? true : false ),
'name' => display_name($record->author),
'date' => format_date(strtotime($record->ctime), 'strftimedate'),
'date' => format_date(strtotime($record->ctime), 'strftimedatetime'),
'message' => format_whitespace($record->message),
'ispublic' => $record->public
'ispublic' => $record->public,
'author' => $record->author,
);
if (!empty($record->attachment)) {
$d['attachid'] = $record->attachment;
$d['attachid'] = $record->attachment;
$d['attachtitle'] = $record->title;
$d['attachsize'] = display_size($record->size);
}
$data[] = $d;
}
......
......@@ -55,7 +55,7 @@ if ($submittedgroup
// The user is a tutor of the group that this view has
// been submitted to, and is entitled to upload an additional
// file when submitting feedback.
$tutorfilefeedbackformrow = "TR(null, TH(null, LABEL(null, '" . get_string('attachfile') . "'))),"
$tutorfilefeedbackformrow = "TR(null, TH(null, LABEL(null, '" . get_string('attachfile', 'view') . "'))),"
. "TR(null, TD(null, INPUT({'type':'file', 'name':'attachment'}))),";
}
$viewbeingwatched = (int)record_exists('usr_watchlist_view', 'usr', $USER->get('id'), 'view', $viewid);
......@@ -64,7 +64,8 @@ $getstring = quotestrings(array(
'mahara' => array('message', 'cancel'),
'view' => array('makepublic', 'placefeedback', 'complaint',
'feedbackonthisartefactwillbeprivate', 'notifysiteadministrator',
'nopublicfeedback', 'reportobjectionablematerial', 'print')
'nopublicfeedback', 'reportobjectionablematerial', 'print',
'thisfeedbackispublic', 'thisfeedbackisprivate', 'attachment')
));
$getstring['addtowatchlist'] = json_encode(get_string('addtowatchlist', 'view'));
......@@ -187,56 +188,53 @@ function view_menu() {
addLoadEvent(view_menu);
// The list of existing feedback.
var feedbacklist = new TableRenderer(
'feedbacktable',
'getfeedback.json.php',
[
function (r) {
var td = TD(null);
td.innerHTML = r.message;
if (r.attachid && r.ownedbythisuser) {
appendChildNodes(td, DIV(null, {$getstring['feedbackattachmessage']}));
return td;
}
return td;
},
'name',
'date',
function (r) {
if (r.ispublic == 1) {
var makePrivate = null;
if (r.ownedbythisuser) {
makePrivate = A({'href': ''}, get_string('makeprivate'));
connect(makePrivate, 'onclick', function (e) {
sendjsonrequest(
'changefeedback.json.php',
r,
'POST',
function (data) {
if (!data.error) {
replaceChildNodes(makePrivate.parentNode, '(' + get_string('private') + ')');
}
}
);
var feedbacklist = new TableRenderer('feedbacktable', 'getfeedback.json.php', []);
e.stop();
});
}
return TD(null, '(' + get_string('public') + ') ', makePrivate);
}
return TD(null, '(' + get_string('private') + ')');
},
function (r) {
if (r.attachid) {
return TD(null, A({'href':config.wwwroot + 'artefact/file/download.php?file=' + r.attachid},
r.attachtitle));
}
return TD(null);
feedbacklist.limit = 10;
feedbacklist.rowfunction = function(r, n, d) {
var td = TD(null);
td.innerHTML = r.message;
if (r.attachid && r.ownedbythisuser) {
appendChildNodes(td, DIV(null, {$getstring['feedbackattachmessage']}));
}
var publicPrivate = null;
if (r.ispublic == 1) {
var makePrivate = null;
if (r.ownedbythisuser) {
makePrivate = A({'href': ''}, get_string('makeprivate'));
connect(makePrivate, 'onclick', function (e) {
sendjsonrequest(
'changefeedback.json.php',
r,
'POST',
function (data) {
if (!data.error) {
replaceChildNodes(makePrivate.parentNode, '(' + {$getstring['private']} + ')');
}
}
);
e.stop();
});
makePrivate = [' - ', makePrivate];
}
]
);
publicPrivate = SPAN(null, {$getstring['thisfeedbackispublic']}, makePrivate);
}
else {
publicPrivate = {$getstring['thisfeedbackisprivate']};
}
feedbacklist.limit = 10;
var attachment = null;
if (r.attachid) {
attachment = [' | ', {$getstring['attachment']}, ': ', A({'href':config.wwwroot + 'artefact/file/download.php?file=' + r.attachid}, r.attachtitle), ' (', r.attachsize, ')'];
}
var icon = A({'href': config.wwwroot + 'user/view.php?id=' + r.author}, IMG({'src': config.wwwroot + 'thumb.php?type=profileicon&id=' + r.author + '&maxsize=20', 'valign': 'middle'}));
appendChildNodes(td, DIV({'class': 'details'}, DIV({'class': 'icon'}, icon), A({'href': config.wwwroot + 'user/view.php?id=' + r.author}, r.name), ' | ', r.date, ' | ', publicPrivate, attachment));
return TR({'class': 'r' + (n % 2)}, td);
};
feedbacklist.view = view;
feedbacklist.statevars.push('view');
feedbacklist.emptycontent = {$getstring['nopublicfeedback']};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment