Commit 6574400c authored by Andrew Robert Nicols's avatar Andrew Robert Nicols Committed by Evan Goldenberg
Browse files

On view submission to a group, redirect in a more contextually aware fashion.



Default option is still to redirect to the view index, but if the returnto
parameter is set to group, redirect to the group the view was submitted to;
and if the parameter is set to view, then redirect to the view that was
submitted.
Signed-off-by: default avatarAndrew Robert Nicols <andrew.nicols@luns.net.uk>
Signed-off-by: default avatarEvan Goldenberg <evang@catalyst.net.nz>
parent 63129f38
......@@ -652,13 +652,17 @@ function group_view_submission_form($groupid, $viewdata) {
'group' => array(
'type' => 'hidden',
'value' => $groupid
)
),
'returnto' => array(
'type' => 'hidden',
'value' => get_config('wwwroot') . 'group/view.php?id=' . $groupid,
),
),
));
}
function group_view_submission_form_submit(Pieform $form, $values) {
redirect('/view/submit.php?id=' . $values['options'] . '&group=' . $values['group']);
redirect('/view/submit.php?id=' . $values['options'] . '&group=' . $values['group'] . '&returnto=group');
}
// Miscellaneous group related functions
......
......@@ -2844,7 +2844,7 @@ function createview_cancel_submit(Pieform $form, $values) {
redirect(get_config('wwwroot') . 'view/');
}
function view_group_submission_form($viewid, $tutorgroupdata) {
function view_group_submission_form($viewid, $tutorgroupdata, $returnto=null) {
$options = array();
foreach ($tutorgroupdata as $group) {
$options[$group->id] = $group->name;
......@@ -2877,13 +2877,17 @@ function view_group_submission_form($viewid, $tutorgroupdata) {
'view' => array(
'type' => 'hidden',
'value' => $viewid
),
'returnto' => array(
'type' => 'hidden',
'value' => $returnto,
)
),
));
}
function view_group_submission_form_submit(Pieform $form, $values) {
redirect('/view/submit.php?id=' . $values['view'] . '&group=' . $values['options']);
redirect('/view/submit.php?id=' . $values['view'] . '&group=' . $values['options'] . '&returnto=' . $values['returnto']);
}
......
......@@ -33,6 +33,7 @@ require_once('view.php');
require_once('activity.php');
$viewid = param_integer('id');
$groupid = param_integer('group');
$returnto = param_variable('returnto', 'view');
$view = get_record('view', 'id', $viewid, 'owner', $USER->get('id'));
$group = get_record_sql(
......@@ -61,7 +62,7 @@ $form = pieform(array(
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('yes'), get_string('no')),
'goto' => get_config('wwwroot') . 'view/'
'goto' => get_config('wwwroot') . returnto(),
)
),
));
......@@ -86,6 +87,21 @@ function submitview_submit(Pieform $form, $values) {
));
db_commit();
$SESSION->add_ok_msg(get_string('viewsubmitted', 'view'));
redirect('/view/');
redirect('/' . returnto());
}
function returnto() {
GLOBAL $viewid, $groupid, $returnto;
// Deteremine the best place to return to
if ($returnto === 'group') {
$goto = 'group/view.php?id=' . $groupid;
}
else if ($returnto === 'view') {
$goto = 'view/view.php?id=' . $viewid;
}
else {
$goto = 'view/';
}
return $goto;
}
?>
......@@ -277,7 +277,7 @@ $smarty->assign('viewbeingwatched', $viewbeingwatched);
if ($tutorgroupdata = group_get_user_course_groups()) {
$options = array();
if (!$view->get('submittedgroup') && !$view->get('submittedhost')) {
$smarty->assign('view_group_submission_form', view_group_submission_form($view->get('id'), $tutorgroupdata));
$smarty->assign('view_group_submission_form', view_group_submission_form($view->get('id'), $tutorgroupdata, 'view'));
}
}
......
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