Commit 67e87a54 authored by Evan Goldenberg's avatar Evan Goldenberg
Browse files

show date and time of view submission (bug #547981)


Signed-off-by: default avatarEvan Goldenberg <evang@catalyst.net.nz>
parent c19f213d
......@@ -502,6 +502,7 @@ function submit_view_for_assessment($username, $viewid) {
$view = new View($viewid);
$view->set('submittedhost', $authinstance->config['wwwroot']);
$view->set('submittedtime', db_format_timestamp(time()));
// Create secret key
$access = View::new_token($view->get('id'), false);
......@@ -544,6 +545,7 @@ function release_submitted_view($viewid, $assessmentdata, $teacherusername) {
// Release the view for editing
$view->set('submittedhost', null);
$view->set('submittedtime', null);
$view->commit();
db_commit();
}
......
......@@ -128,9 +128,15 @@ if (group_allows_submission($group->grouptype) && ($viewdata = View::get_user_vi
if (!$submitted) {
$group_view_submission_form = group_view_submission_form($group->id, $viewdata);
}
else {
if ($submitted->submittedtime) {
$pieces = explode(' ', $submitted->submittedtime);
$group_view_submission_form = get_string('youhavesubmittedon', 'view', get_config('wwwroot') . 'view/view.php?id=' . $submitted->id, $submitted->title, $pieces[0], $pieces[1]);
}
else {
$group_view_submission_form = get_string('youhavesubmitted', 'view', get_config('wwwroot') . 'view/view.php?id=' . $submitted->id, $submitted->title);
}
}
$smarty->assign('group_view_submission_form', $group_view_submission_form);
}
......
......@@ -68,6 +68,7 @@ $string['views'] = 'views';
$string['View'] = 'View';
$string['Views'] = 'Views';
$string['viewsubmittedtogroup'] = 'This View has been submitted to <a href="%s">%s</a>';
$string['viewsubmittedtogroupon'] = 'This View was submitted to <a href="%s">%s</a> on %s at %s';
$string['nobodycanseethisview2'] = 'Only you can see this View';
$string['noviews'] = 'No Views.';
$string['youhavenoviews'] = 'You have no Views.';
......@@ -79,6 +80,7 @@ $string['viewssharedtogroupbyothers'] = 'Views shared to this group by others';
$string['viewssubmittedtogroup'] = 'Views submitted to this group';
$string['submitaviewtogroup'] = 'Submit a view to this group';
$string['youhavesubmitted'] = 'You have submitted <a href="%s">%s</a> to this group';
$string['youhavesubmittedon'] = 'You submitted <a href="%s">%s</a> to this group on %s at %s';
// access levels
$string['public'] = 'Public';
......@@ -233,6 +235,7 @@ $string['viewtitleby'] = '%s by <a href="%s">%s</a>';
$string['in'] = 'in';
$string['noblocks'] = 'Sorry, no blocks in this category :(';
$string['Preview'] = 'Preview';
$string['timeofsubmission'] = 'Time of submission';
$string['50,50'] = $string['33,33,33'] = $string['25,25,25,25'] = 'Equal widths';
$string['67,33'] = 'Larger left column';
......
......@@ -1376,5 +1376,9 @@ function xmldb_core_upgrade($oldversion=0) {
set_config('surbl', 0);
}
if ($oldversion < 2010040800) {
execute_sql('ALTER TABLE {view} ADD COLUMN submittedtime TIMESTAMP');
}
return $status;
}
......@@ -28,7 +28,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2010040700;
$config->version = 2010040800;
$config->release = '1.3.0dev';
$config->minupgradefrom = 2008040200;
$config->minupgraderelease = '1.0.0 (release tag 1.0.0_RELEASE)';
......
......@@ -43,6 +43,7 @@ class View {
private $stopdate;
private $submittedgroup;
private $submittedhost;
private $submittedtime;
private $title;
private $description;
private $loggedin;
......@@ -743,6 +744,7 @@ class View {
else if ($submitinfo['type'] == 'host') {
$this->set('submittedhost', null);
}
$this->set('submittedtime', null);
$this->commit();
$ownerlang = get_user_language($this->get('owner'));
require_once('activity.php');
......@@ -2007,7 +2009,7 @@ class View {
}
else {
$count = count_records_select('view', 'owner = ? AND type != ?', array($userid, 'profile'));
$viewdata = get_records_sql_array('SELECT v.id,v.title,v.startdate,v.stopdate,v.description, v.template, v.type,
$viewdata = get_records_sql_array('SELECT v.id,v.title,v.startdate,v.stopdate,v.description, v.template, v.type, v.submittedtime,
g.id AS submitgroupid, g.name AS submitgroupname, h.wwwroot AS submithostwwwroot, h.name AS submithostname
FROM {view} v
LEFT OUTER JOIN {group} g ON (v.submittedgroup = g.id AND g.deleted = 0)
......@@ -2055,13 +2057,27 @@ class View {
$data[$i]['removable'] = self::can_remove_viewtype($viewdata[$i]->type);
$data[$i]['description'] = $viewdata[$i]->description;
if (!empty($viewdata[$i]->submitgroupid)) {
if (!empty($viewdata[$i]->submittedtime)) {
$pieces = explode(' ', $viewdata[$i]->submittedtime);
$data[$i]['submittedto'] = get_string('viewsubmittedtogroupon', 'view',
get_config('wwwroot') . 'group/view.php?id=' . $viewdata[$i]->submitgroupid,
$viewdata[$i]->submitgroupname, $pieces[0], $pieces[1]);
}
else {
$data[$i]['submittedto'] = get_string('viewsubmittedtogroup', 'view',
get_config('wwwroot') . 'group/view.php?id=' . $viewdata[$i]->submitgroupid,
$viewdata[$i]->submitgroupname);
}
}
else if (!empty($viewdata[$i]->submithostwwwroot)) {
if (!empty($viewdata[$i]->submittedtime)) {
$pieces = explode(' ', $viewdata[$i]->submittedtime);
$data[$i]['submittedto'] = get_string('viewsubmittedtogroupon', 'view', $viewdata[$i]->submithostwwwroot, $viewdata[$i]->submithostname, $pieces[0], $pieces[1]);
}
else {
$data[$i]['submittedto'] = get_string('viewsubmittedtogroup', 'view', $viewdata[$i]->submithostwwwroot, $viewdata[$i]->submithostname);
}
}
$data[$i]['artefacts'] = array();
$data[$i]['accessgroups'] = array();
if ($viewdata[$i]->startdate && $viewdata[$i]->stopdate) {
......@@ -2448,7 +2464,7 @@ class View {
*/
public static function get_submitted_views($groupid) {
$viewdata = get_records_sql_assoc('
SELECT id, title, description, owner, ownerformat, "group", institution
SELECT id, title, description, owner, ownerformat, "group", institution, submittedtime
FROM {view}
WHERE submittedgroup = ?
ORDER BY title, id',
......
......@@ -85,6 +85,9 @@
{$view.sharedby}
{/if}
{/if}
{if $view.submittedtime}
<span> ({str tag=timeofsubmission section=view}: {$view.submittedtime})</span>
{/if}
<div>{$view.shortdescription}</div>
{if $view.tags}<div class="tags">{str tag=tags}: {list_tags owner=$view.owner tags=$view.tags}</div>{/if}
</td>
......
......@@ -76,7 +76,7 @@ $smarty->display('view/submit.tpl');
function submitview_submit(Pieform $form, $values) {
global $SESSION, $USER, $viewid, $groupid, $group;
db_begin();
update_record('view', array('submittedgroup' => $groupid), array('id' => $viewid));
update_record('view', array('submittedgroup' => $groupid, 'submittedtime' => db_format_timestamp(time())), array('id' => $viewid));
activity_occurred('groupmessage', array(
'subject' => get_string('viewsubmitted', 'view'), // will be overwritten
'message' => get_string('viewsubmitted', 'view'), // will be overwritten
......
......@@ -94,6 +94,13 @@ if ($USER->is_logged_in() && $submittedgroup && group_user_can_assess_submitted_
// been submitted to, and is entitled to release the view, and to
// upload an additional file when submitting feedback.
$submittedgroup = get_record('group', 'id', $submittedgroup);
if ($view->get('submittedtime')) {
$pieces = explode(' ', $view->get('submittedtime'));
$text = get_string('viewsubmittedtogroupon', 'view', get_config('wwwroot') . 'group/view.php?id=' . $submittedgroup->id, $submittedgroup->name, $pieces[0], $pieces[1]);
}
else {
$text = get_string('viewsubmittedtogroup', 'view', get_config('wwwroot') . 'group/view.php?id=' . $submittedgroup->id, $submittedgroup->name);
}
$releaseform = pieform(array(
'name' => 'releaseview',
'method' => 'post',
......@@ -103,7 +110,7 @@ if ($USER->is_logged_in() && $submittedgroup && group_user_can_assess_submitted_
'elements' => array(
'submittedview' => array(
'type' => 'html',
'value' => get_string('viewsubmittedtogroup', 'view', get_config('wwwroot') . 'group/view.php?id=' . $submittedgroup->id, $submittedgroup->name),
'value' => $text,
),
'submit' => array(
'type' => 'submit',
......
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