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