Commit d0f825a7 authored by Ruslan Kabalin's avatar Ruslan Kabalin
Browse files

Add an option to include feedback to html export (bug #784313)



All the feedback comments will be displayed on the single exported page, no
pagination or limits. Star rating is preserved.

Change-Id: I1d8c175ec2cb1b7c328c6b1835b95e95f2786dc5
Signed-off-by: default avatarRuslan Kabalin <ruslan.kabalin@luns.net.uk>
parent dc44324b
......@@ -263,9 +263,10 @@ class ArtefactTypeComment extends ArtefactType {
* Set to null to use $offset for pagination.
* @param object $view The view object
* @param object $artefact Optional artefact object
* @param bool $export Determines if comments are fetched for html export purposes
* @return object $result Comments data object
*/
public static function get_comments($limit=10, $offset=0, $showcomment, &$view, &$artefact=null) {
public static function get_comments($limit=10, $offset=0, $showcomment, &$view, &$artefact=null, $export=false) {
global $USER;
$userid = $USER->get('id');
$viewid = $view->get('id');
......@@ -290,6 +291,7 @@ class ArtefactTypeComment extends ArtefactType {
'canedit' => $canedit,
'owner' => $owner,
'isowner' => $isowner,
'export' => $export,
'data' => array(),
);
......@@ -498,6 +500,7 @@ class ArtefactTypeComment extends ArtefactType {
'value' => valid_rating($item->rating),
'min_rating' => MIN_RATING,
'max_rating' => MAX_RATING,
'export' => $data->export,
);
}
}
......
......@@ -32,7 +32,11 @@
{if $item->ratingdata}
<div class="commentrating">
{for i $item->ratingdata->min_rating $item->ratingdata->max_rating}
{if !$item->ratingdata->export}
<input name="star{$item->id}" type="radio" class="star" {if $i === $item->ratingdata->value} checked="checked" {/if} disabled="disabled" />
{else}
<div class="star-rating star star-rating-applied star-rating-readonly{if $i <= $item->ratingdata->value} star-rating-on{/if}"><a>&nbsp;</a></div>
{/if}
{/for}
</div><br />
{/if}
......
......@@ -99,6 +99,8 @@ default:
export_iframe_die(get_string('unabletoexportportfoliousingoptions', 'export'));
}
$exporter->includefeedback = $exportdata['includefeedback'];
try {
$zipfile = $exporter->export();
} catch (SystemException $e) {
......
......@@ -84,7 +84,7 @@ class PluginExportHtml extends PluginExport {
// Find what stylesheets need to be included
$themedirs = $THEME->get_path('', true, 'export/html');
$stylesheets = array('style.css', 'print.css');
$stylesheets = array('style.css', 'print.css', 'jquery.rating.css');
foreach ($themedirs as $theme => $themedir) {
foreach ($stylesheets as $stylesheet) {
if (is_readable($themedir . 'style/' . $stylesheet)) {
......@@ -339,6 +339,7 @@ class PluginExportHtml extends PluginExport {
* Dumps all views into the HTML export
*/
private function dump_view_export_data() {
safe_require('artefact', 'comment');
$progressstart = 55;
$progressend = 75;
$i = 0;
......@@ -373,6 +374,17 @@ class PluginExportHtml extends PluginExport {
}
$outputfilter = new HtmlExportOutputFilter($rootpath, $this);
// Include comments
if ($this->includefeedback) {
$feedback = null;
$artefact = null;
if ($feedback = ArtefactTypeComment::get_comments(0, 0, null, $view, $artefact, true)) {
$feedback->tablerows = $outputfilter->filter($feedback->tablerows);
}
$smarty->assign('feedback', $feedback);
}
$smarty->assign('view', $outputfilter->filter($view->build_columns()));
$content = $smarty->fetch('export:html:view.tpl');
if (!file_put_contents("$directory/index.html", $content)) {
......
/* jQuery.Rating Plugin CSS - http://www.fyneworks.com/jquery/star-rating/ */
div.rating-cancel,div.star-rating{float:left;width:17px;height:15px;text-indent:-999em;cursor:pointer;display:block;background:transparent;overflow:hidden}
div.rating-cancel,div.rating-cancel a{background:url(../images/rating-delete.gif) no-repeat 0 -16px}
div.star-rating,div.star-rating a{background:url(../images/rating-star.gif) no-repeat 0 0px}
div.rating-cancel a,div.star-rating a{display:block;width:16px;height:100%;background-position:0 0px;border:0}
div.star-rating-on a{background-position:0 -16px!important}
div.star-rating-hover a{background-position:0 -32px}
/* Read Only CSS */
div.star-rating-readonly a{cursor:default !important}
/* Partial Star CSS */
div.star-rating{background:transparent!important;overflow:hidden!important}
/* END jQuery.Rating Plugin CSS */
\ No newline at end of file
......@@ -54,6 +54,10 @@ div.pagination span.selected,
span.pagination {
padding: 5px;
}
.date {
color: #888;
font-style: italic;
}
/* Headings */
h1 {
......@@ -72,6 +76,18 @@ h2, h3, h4, h5, h6 {
margin: .5em 0 .25em;
}
/* Tables */
table {
border-spacing: 0;
border-collapse: collapse;
}
th {
padding: 3px 0;
text-align: left;
vertical-align: top;
line-height: 1.8em;
}
/* Main content */
#content {
margin: 0 1em;
......@@ -159,6 +175,23 @@ h2, h3, h4, h5, h6 {
font-size: smaller;
}
/* views footer */
.viewfooter {
border: 1px solid #eee;
}
#feedbacktable .fr {
margin-top: 3px;
}
#feedbacktable th {
color: #303030;
}
#feedbacktable .details {
color: #d1d1d1;
}
#feedbacktable .details span {
color: #9e9e9e;
}
/* Footer */
#footer {
border-top: 1px solid #bbb;
......
......@@ -16,4 +16,16 @@
{$view|safe}
{if $feedback && $feedback->count}
<div class="viewfooter">
<table id="feedbacktable" class="fullwidth table">
<thead><tr><th>{str tag="feedback" section="artefact.comment"}</th></tr></thead>
<tbody>
{$feedback->tablerows|safe}
</tbody>
</table>
{$feedback->pagination|safe}
</div>
{/if}
{include file="export:html:footer.tpl"}
......@@ -71,6 +71,13 @@ $elements = array(
'separator' => '</div><div>',
'defaultvalue' => 'all',
),
'includefeedback' => array(
'type' => 'checkbox',
'title' => get_string('includefeedback', 'export'),
'description' => get_string('includefeedbackdescription', 'export'),
'separator' => '</div><div>',
'defaultvalue' => 1,
),
);
if ($viewids = get_column('view', 'id', 'owner', $USER->get('id'), 'type', 'portfolio')) {
......@@ -172,9 +179,10 @@ function export_submit(Pieform $form, $values) {
}
$exportdata = array(
'format' => $values['format'],
'what' => $values['what'],
'views' => $views,
'format' => $values['format'],
'what' => $values['what'],
'views' => $views,
'includefeedback' => $values['includefeedback'],
);
$SESSION->set('exportdata', $exportdata);
......
......@@ -99,6 +99,11 @@ abstract class PluginExport extends Plugin {
*/
public $views = array();
/**
* Whether the user requested to export feedback as well
*/
public $includefeedback = false;
/**
* User object for the user being exported.
*/
......
......@@ -75,6 +75,18 @@ addLoadEvent(function() {
}
});
// Make the export format radio buttons show/hide the includefeedback checkbox
forEach(getElementsByTagAndClassName('input', 'radio', 'exportformat-buttons'), function(radio) {
connect(radio, 'onclick', function(e) {
hideElement($('includefeedback'));
if (radio.checked) {
if (radio.value == 'html') {
showElement($('includefeedback'));
}
}
});
});
// Hook up 'click to preview' links
forEach(getElementsByTagAndClassName('a', 'viewlink', containers.views.container), function(i) {
disconnectAll(i);
......
......@@ -48,6 +48,8 @@ $string['generateexport'] = 'Generate export';
$string['noexportpluginsenabled'] = 'No export plugins have been enabled by the administrator, so you are unable to use this feature';
$string['justsomecollections'] = 'Just some of my Collections';
$string['justsomeviews'] = 'Just some of my pages';
$string['includefeedback'] = 'Include user feedback';
$string['includefeedbackdescription'] = 'All user comments will be included in the HTML export.';
$string['nonexistentfile'] = "Tried to add non-existent file: '%s'";
$string['pleasewaitwhileyourexportisbeinggenerated'] = 'Please wait while your export is being generated...';
$string['reverseselection'] = 'Reverse selection';
......
......@@ -17,7 +17,7 @@ EOF;
echo $form_tag;
echo '<h3>' . get_string('chooseanexportformat', 'export') . '</h3>';
echo '<div class="element">';
echo '<div class="element" id="exportformat-buttons">';
echo '<div>' . $elements['format']['html'] . '</div>';
echo '</div>';
echo '<h3>' . get_string('whatdoyouwanttoexport', 'export') . '</h3>';
......@@ -118,6 +118,10 @@ if ($body) {
echo '</fieldset></div>';
}
echo '<div id="includefeedback">';
echo $elements['includefeedback']['html'] . ' ' . $elements['includefeedback']['labelhtml'];
echo '<div class="radio-description">' . $elements['includefeedback']['description'] . '</div>';
echo '</div>';
echo '<div id="export_submit_container">';
echo $elements['submit']['html'];
echo '</div>';
......
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