Commit 0ab3f882 authored by Camille Tardy's avatar Camille Tardy
Browse files

Fix Form dispatch code writing + Display


Signed-off-by: Camille Tardy's avatarCamille Tardy <camille.tardy@unige.ch>
parent 327f17c3
......@@ -42,12 +42,12 @@ class quiz_group_dispatchgrade_form extends moodleform {
//todo: disable if no attempt
$mform_dispatch = $this->_form;
$mform_dispatch->addElement('html', "<p>".get_string('dispatchgrade_info', 'quiz_group')."</p>");
$mform_dispatch->addElement('header', 'quizgroupdispatchgrades', get_string('titleapply', 'quiz_group'));
$mform_dispatch->addElement('html', "<p>".get_string('info_dispatchgrades', 'quiz_group')."</p>");
$mform_dispatch->addElement('hidden', 'groupingid');
//submit button
$mform_dispatch->addElement('submit', 'dispatch', get_string('dispatchgrades', 'quiz_group'));
$mform_dispatch->addElement('submit', 'dispatch', get_string('apply', 'quiz_group'));
}
function validation($data, $files) {
......
......@@ -73,7 +73,7 @@ class quiz_group_settings_form extends moodleform {
//submit button
$this->add_action_buttons(true, get_string('savechanges', 'quiz_group'), false);
$mform->addElement('submit', 'savechanges', get_string('savechanges', 'quiz_group'));
//$mform->disabledIf('submitbutton', 'hasattempts', 'eq',true);
//$mform->disabledIf('sel_groupingid', 'hasattempts', 'eq',true);
......
......@@ -26,6 +26,7 @@
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/mod/quiz/report/group/groupsettings_form.php');
require_once($CFG->dirroot . '/mod/quiz/report/group/groupdispatchgrade_form.php');
require_once($CFG->dirroot . '/mod/quiz/report/group/locallib.php');
......@@ -63,8 +64,6 @@ class quiz_group_report extends quiz_default_report{
$pageoptions['id'] = $cm->id;
$pageoptions['quizid'] = $quiz->id;
// $actionurl = new moodle_url('/mod/quiz/view.php', $pageoptions);
// retrieve current grouping value for the given quizid return false if not found
$grouping_record = $DB->get_record('quiz_group', array('quizid'=>$quiz->id), 'id, groupingid', 'IGNORE_MISSING');
......@@ -79,11 +78,15 @@ class quiz_group_report extends quiz_default_report{
$bool_hasattempts = quiz_has_attempts($quiz->id);
// create quiz group setting form
// pramas for both Forms
$form_params = array('quizid' => $quiz->id, 'idnumber' => $cm->id, 'hasattempts'=>$bool_hasattempts);
$toform = array("sel_groupingid"=>$groupingID/*, 'hasattempts'=>$bool_hasattempts*/);
// create quiz group setting form
$mform = new quiz_group_settings_form($form_params, 'get');
$toform = array("sel_groupingid"=>$groupingID/*, 'hasattempts'=>$bool_hasattempts*/);
// if cancel do nothing
if ($mform->is_cancelled()) {
......@@ -126,41 +129,21 @@ class quiz_group_report extends quiz_default_report{
// Dispatch grades to other group members button
$pageoptions['mode'] = "group";
$actionurl = $PAGE->url;
$info_dispatchgrades_string = get_string('info_dispatchgrades', 'quiz_group');
$apply_string = get_string('apply', 'quiz_group');
$titleapply_string = get_string('titleapply', 'quiz_group');
$out ='<br/>';
$out .= html_writer::start_tag('form', array('method' => 'post',
'action' => $actionurl,
'class' => 'mform', 'id' => 'form_groupdispatchgrade'));
$out .= html_writer::tag('h4', $titleapply_string);
$out .= html_writer::tag('p', $info_dispatchgrades_string);
$out .= html_writer::input_hidden_params(new moodle_url('', array(
'groupingid' => $groupingID, 'sesskey' => sesskey())));
// Create Dispatch grades to other group members button
$submit_btn = html_writer::empty_tag('input', array('type'=>'submit', 'value' => $apply_string, 'name'=> 'dispatchgrades'));
$submit_div = html_writer::tag('div',$submit_btn, array('class'=>'felement fgroup'));
$pageoptions['mode'] = "group";
$out .= html_writer::tag('div',$submit_div, array('id'=>'fgroup_id_buttonar', 'class'=>'fitem fitem_actionbuttons fitem_fgroup'));
$formDispatch = new quiz_group_dispatchgrade_form($form_params, 'post');
$out .= html_writer::end_tag('form');
if($fromformDispatch = $formDispatch->get_data()){
dispatch_grade($quiz, $groupingID);
}
echo $out;
//retreive submitted data, false if none
$data = data_submitted();
// is there submitted data?
if ($data !== false){
// Process dispatch grades.
if ($data->dispatchgrades == $apply_string && confirm_sesskey()){
dispatch_grade($quiz, $groupingID);
}
}
$formDispatch->set_data($toform);
$formDispatch->display();
}
......
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