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

Abstract out creation of the 'submit to view' pieform.



This means that it should be much easier to use in other locations without
duplicating code.
Signed-off-by: default avatarAndrew Robert Nicols <andrew.nicols@luns.net.uk>
Signed-off-by: default avatarEvan Goldenberg <evang@catalyst.net.nz>
parent 8444c870
......@@ -2826,6 +2826,48 @@ function createview_cancel_submit(Pieform $form, $values) {
redirect(get_config('wwwroot') . 'view/');
}
function view_group_submission_form($viewid, $tutorgroupdata) {
$options = array();
foreach ($tutorgroupdata as $group) {
$options[$group->id] = $group->name;
}
// This form sucks from a language string point of view. It should
// use pieforms' form template feature
return pieform(array(
'name' => 'view_group_submission_form_' . $viewid,
'method' => 'post',
'renderer' => 'oneline',
'autofocus' => false,
'successcallback' => 'view_group_submission_form_submit',
'elements' => array(
'text1' => array(
'type' => 'html', 'value' => get_string('submitthisviewto', 'view') . ' ',
),
'options' => array(
'type' => 'select',
'collapseifoneoption' => false,
'options' => $options,
),
'text2' => array(
'type' => 'html',
'value' => get_string('forassessment', 'view'),
),
'submit' => array(
'type' => 'submit',
'value' => get_string('submit')
),
'view' => array(
'type' => 'hidden',
'value' => $viewid
)
),
));
}
function view_group_submission_form_submit(Pieform $form, $values) {
redirect('/view/submit.php?id=' . $values['view'] . '&group=' . $values['options']);
}
function add_feedback_form($attachments=false) {
global $USER;
......
......@@ -51,45 +51,10 @@ if (!$tutorgroupdata = group_get_user_course_groups()) {
$tutorgroupdata = array();
}
else {
$options = array();
foreach ($tutorgroupdata as $group) {
$options[$group->id] = $group->name;
}
$i = 0;
$options = array();
foreach ($data->data as &$view) {
if (empty($view['submittedto'])) {
// This form sucks from a language string point of view. It should
// use pieforms' form template feature
$view['submitto'] = pieform(array(
'name' => 'submitto' . $i++,
'method' => 'post',
'renderer' => 'oneline',
'autofocus' => false,
'successcallback' => 'submitto_submit',
'elements' => array(
'text1' => array(
'type' => 'html',
'value' => get_string('submitthisviewto', 'view') . ' ',
),
'options' => array(
'type' => 'select',
'collapseifoneoption' => false,
'options' => $options,
),
'text2' => array(
'type' => 'html',
'value' => get_string('forassessment', 'view'),
),
'submit' => array(
'type' => 'submit',
'value' => get_string('submit')
),
'view' => array(
'type' => 'hidden',
'value' => $view['id']
)
),
));
$view['submitto'] = view_group_submission_form($view['id'], $tutorgroupdata);
}
}
}
......@@ -103,10 +68,6 @@ $pagination = build_pagination(array(
'resultcounttextplural' => get_string('views', 'view')
));
function submitto_submit(Pieform $form, $values) {
redirect('/view/submit.php?id=' . $values['view'] . '&group=' . $values['options']);
}
$createviewform = pieform(create_view_form());
$smarty = smarty();
......
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