Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Mixed Evaluation - Duplicate Self-Evaluations #666

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions app/controllers/mixevals_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,36 @@ function edit($id)
}
}

/**
* get the event id and event index
* Load event index for the view to use in the Event Self-Evaluation
*/
$eval = $this->Mixeval->findById($id);
if($this->params['action'] == 'edit') {
function getEventById($array, $key) {
foreach ($array as $value) {
if($value['template_id'] == $key){
return $value['id'];
}
}
}
$event_id = getEventById($eval['Event'], $id);
$event_index = array_search($event_id, array_values($events));
$this->set('event_index', $event_index);
}

// Save changes if there are any
if (!empty($this->data)) {
/**
* check if the form submission includes the event data before saving
*/
if(!empty($this->data['Event'])) {
$this->data['Event'][$event_index]['id'] = $eval['Event'][$event_index]['id'];
$this->data['Event'][$event_index]['created'] = $eval['Event'][$event_index]['created'];
$this->data['Event'][$event_index]['event_template_type_id'] = $eval['Event'][$event_index]['event_template_type_id'];
$this->Event->save($this->data['Event'][$event_index]);
}

$this->_dataSavePrep();
// This is kind of a hack. Inside _transactionSave, it will call saveAll with 'validate' option
// equals to 'only' to perform validation. In turn, the cake library Model's __save function
Expand Down
2 changes: 1 addition & 1 deletion app/views/elements/evaluations/mixeval_eval_form.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<?php endforeach;
}?>

<?php if ($mixeval['Mixeval']['self_eval'] > 0 && $event['Event']['self_eval'] && $enrol > 0) { ?>
<?php if ($mixeval['Mixeval']['self_eval'] > 0 && $enrol > 0) { ?>
<h1 id="self-title" class="title"><?php __("Self-Evaluation Questions")?></h1>

<?php
Expand Down
2 changes: 1 addition & 1 deletion app/views/elements/mixevals/questions_editor.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ echo $html->div('', $reloadedQ, array('id' => 'questions', 'class' => 'questions

// self evaluation questions section
echo '<div id="self-eval-ques">';
echo $html->tag('h3', __('Self-Evaluation Questions', true));
echo $html->tag('h3', __('Include Additional Questions for Reflection', true));
$addQButton = $form->button(__('Add', true),
array('type' => 'button', 'onclick' => "insertQ(true);"));
$selfQTypes = $qTypes;
Expand Down
38 changes: 33 additions & 5 deletions app/views/mixevals/add.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,40 @@ echo $html->div("help-text",
echo $form->input('zero_mark');
echo $html->div("help-text",
__('Start marks from zero for all Likert questions.', true));

/**
* Adds evaluators to Peer Evaluation list for Self-Evaluation.
*/
if(isset($this->data['Mixeval']['id']) && $this->params['action'] == 'edit' && !empty($this->data['Event'])) {
$self_eval_checked = ($this->data['Event'][$event_index]['self_eval'] > 0) ? true : false;
echo $form->input('event_self_eval',
array(
'legend' => 'Self-Evaluation',
'type' => 'radio',
'name' => 'data[Event]['.$event_index.'][self_eval]',
'value' => $this->data['Event'][$event_index]['self_eval'],
'default' => $self_eval_checked,
'options' => array(
'1' => __('Enabled', true),
'0' => __('Disabled', true)
)
)
);
}

/**
* Adds a reflective questions section for evaluators.
*/
$check = ($this->data['Mixeval']['self_eval'] > 0) ? true : false;
echo $form->input('self_eval',
array('type' => 'checkbox', 'id' => 'self_eval', 'label' => __('Self-Evaluation', true),
'checked' => $check));
echo $html->div("help-text",
__('Adds a reflective questions section for evaluators.', true));
echo $form->input('self_eval',
array(
'type' => 'checkbox',
'id' => 'self_eval',
'label' => __('Additional Questions<br /> for Reflection', true),
'checked' => $check
)
);
echo $html->div("help-text", __('Adds a reflective questions section for evaluators.', true));

// If we're editing a previously saved mixeval, will need to have an id for
// the mixeval.
Expand Down