mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-53638 mod_feedback: change items classes
remove duplication by creating methods in the parent class delete unused methods add new method complete_form_element() that hooks into the moodleform
This commit is contained in:
parent
97d71cbc3a
commit
c83c052230
@ -19,14 +19,6 @@ require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_class.php');
|
||||
|
||||
class feedback_item_captcha extends feedback_item_base {
|
||||
protected $type = "captcha";
|
||||
private $commonparams;
|
||||
private $item_form = false;
|
||||
private $item = false;
|
||||
private $feedback = false;
|
||||
|
||||
public function init() {
|
||||
|
||||
}
|
||||
|
||||
public function build_editform($item, $feedback, $cm) {
|
||||
global $DB;
|
||||
@ -47,7 +39,6 @@ class feedback_item_captcha extends feedback_item_base {
|
||||
}
|
||||
|
||||
$this->item = $item;
|
||||
$this->feedback = $feedback;
|
||||
$this->item_form = true; //dummy
|
||||
|
||||
$lastposition = $DB->count_records('feedback_item', array('feedback'=>$feedback->id));
|
||||
@ -93,11 +84,6 @@ class feedback_item_captcha extends feedback_item_base {
|
||||
return $DB->get_record('feedback_item', array('id'=>$this->item->id));
|
||||
}
|
||||
|
||||
//liefert eine Struktur ->name, ->data = array(mit Antworten)
|
||||
public function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public function get_printval($item, $value) {
|
||||
return '';
|
||||
}
|
||||
@ -113,195 +99,56 @@ class feedback_item_captcha extends feedback_item_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the edit-page of feedback
|
||||
* Returns the formatted name of the item for the complete form or response view
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @return void
|
||||
* @param stdClass $item
|
||||
* @param bool $withpostfix
|
||||
* @return string
|
||||
*/
|
||||
public function print_item_preview($item) {
|
||||
global $DB, $OUTPUT;
|
||||
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
|
||||
$cmid = 0;
|
||||
$feedbackid = $item->feedback;
|
||||
if ($feedbackid > 0) {
|
||||
$feedback = $DB->get_record('feedback', array('id'=>$feedbackid));
|
||||
$cm = get_coursemodule_from_instance("feedback", $feedback->id, $feedback->course);
|
||||
if ($cm) {
|
||||
$cmid = $cm->id;
|
||||
}
|
||||
}
|
||||
|
||||
$requiredmark = '<img class="req" title="'.get_string('requiredelement', 'form').'" alt="'.
|
||||
get_string('requiredelement', 'form').'" src="'.$OUTPUT->pix_url('req') .'" />';
|
||||
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
if (strval($item->label) !== '') {
|
||||
echo '('. format_string($item->label).') ';
|
||||
}
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
echo '</div>';
|
||||
|
||||
public function get_display_name($item, $withpostfix = true) {
|
||||
return get_string('captcha', 'feedback');
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
* Adds an input element to the complete form
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @param string $value
|
||||
* @param bool $highlightrequire
|
||||
* @return void
|
||||
* @param stdClass $item
|
||||
* @param mod_feedback_complete_form $form
|
||||
*/
|
||||
public function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
global $SESSION, $CFG, $DB, $USER, $OUTPUT;
|
||||
require_once($CFG->libdir.'/recaptchalib.php');
|
||||
public function complete_form_element($item, $form) {
|
||||
$name = $this->get_display_name($item);
|
||||
$inputname = $item->typ . '_' . $item->id;
|
||||
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
if ($form->get_mode() != mod_feedback_complete_form::MODE_COMPLETE) {
|
||||
$form->add_form_element($item,
|
||||
['static', $inputname, $name],
|
||||
false,
|
||||
false);
|
||||
} else {
|
||||
$form->add_form_element($item,
|
||||
['recaptcha', $inputname, $name],
|
||||
false,
|
||||
false);
|
||||
}
|
||||
|
||||
$cmid = 0;
|
||||
$feedbackid = $item->feedback;
|
||||
if ($feedbackid > 0) {
|
||||
$feedback = $DB->get_record('feedback', array('id'=>$feedbackid));
|
||||
$cm = get_coursemodule_from_instance("feedback", $feedback->id, $feedback->course);
|
||||
if ($cm) {
|
||||
$cmid = $cm->id;
|
||||
// Add recaptcha validation to the form.
|
||||
$form->add_validation_rule(function($values, $files) use ($item, $form) {
|
||||
$elementname = $item->typ . '_' . $item->id;
|
||||
$recaptchaelement = $form->get_form_element($elementname);
|
||||
if (empty($values['recaptcha_response_field'])) {
|
||||
return array($elementname => get_string('required'));
|
||||
} else if (!empty($values['recaptcha_challenge_field'])) {
|
||||
$challengefield = $values['recaptcha_challenge_field'];
|
||||
$responsefield = $values['recaptcha_response_field'];
|
||||
if (true !== ($result = $recaptchaelement->verify($challengefield, $responsefield))) {
|
||||
return array($elementname => $result);
|
||||
}
|
||||
} else {
|
||||
return array($elementname => get_string('missingrecaptchachallengefield'));
|
||||
}
|
||||
}
|
||||
|
||||
//check if an false value even the value is not required
|
||||
if ($highlightrequire AND !$this->check_value($value, $item)) {
|
||||
$falsevalue = true;
|
||||
} else {
|
||||
$falsevalue = false;
|
||||
}
|
||||
|
||||
if ($falsevalue) {
|
||||
$highlight = '<br class="error"><span id="id_error_recaptcha_response_field" class="error"> '.
|
||||
get_string('err_required', 'form').'</span><br id="id_error_break_recaptcha_response_field" class="error" >';
|
||||
} else {
|
||||
$highlight = '';
|
||||
}
|
||||
$requiredmark = '<img class="req" title="'.get_string('requiredelement', 'form').'" alt="'.
|
||||
get_string('requiredelement', 'form').'" src="'.$OUTPUT->pix_url('req') .'" />';
|
||||
|
||||
if (isset($SESSION->feedback->captchacheck) AND
|
||||
$SESSION->feedback->captchacheck == $USER->sesskey AND
|
||||
$value == $USER->sesskey) {
|
||||
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
if (strval($item->label) !== '') {
|
||||
echo '('. format_string($item->label).') ';
|
||||
}
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
$inputname = 'name="'.$item->typ.'_'.$item->id.'"';
|
||||
echo '<input type="hidden" value="'.$USER->sesskey.'" '.$inputname.' />';
|
||||
echo '</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
$strincorrectpleasetryagain = get_string('incorrectpleasetryagain', 'auth');
|
||||
$strenterthewordsabove = get_string('enterthewordsabove', 'auth');
|
||||
$strenterthenumbersyouhear = get_string('enterthenumbersyouhear', 'auth');
|
||||
$strgetanothercaptcha = get_string('getanothercaptcha', 'auth');
|
||||
$strgetanaudiocaptcha = get_string('getanaudiocaptcha', 'auth');
|
||||
$strgetanimagecaptcha = get_string('getanimagecaptcha', 'auth');
|
||||
|
||||
$recaptureoptions = Array('theme'=>'custom', 'custom_theme_widget'=>'recaptcha_widget');
|
||||
$html = html_writer::script(js_writer::set_variable('RecaptchaOptions', $recaptureoptions));
|
||||
$html .= '
|
||||
|
||||
<div id="recaptcha_widget" style="display:none">
|
||||
|
||||
<div id="recaptcha_image"></div>
|
||||
<div class="recaptcha_only_if_incorrect_sol" style="color:red">'.
|
||||
$strincorrectpleasetryagain.
|
||||
'</div>
|
||||
<span class="recaptcha_only_if_image">
|
||||
<label for="recaptcha_response_field">'.$strenterthewordsabove.$requiredmark.'</label>
|
||||
</span>
|
||||
<span class="recaptcha_only_if_audio">
|
||||
<label for="recaptcha_response_field">'.$strenterthenumbersyouhear.'</label>
|
||||
</span>
|
||||
<label for="recaptcha_response_field">'.$highlight.'</label>
|
||||
|
||||
<input type="text" id="recaptcha_response_field" name="'.$item->typ.'_'.$item->id.'" />
|
||||
|
||||
<div><a href="javascript:Recaptcha.reload()">' . $strgetanothercaptcha . '</a></div>
|
||||
<div class="recaptcha_only_if_image">
|
||||
<a href="javascript:Recaptcha.switch_type(\'audio\')">' . $strgetanaudiocaptcha . '</a>
|
||||
</div>
|
||||
<div class="recaptcha_only_if_audio">
|
||||
<a href="javascript:Recaptcha.switch_type(\'image\')">' . $strgetanimagecaptcha . '</a>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
// Check if we are using SSL.
|
||||
if (is_https()) {
|
||||
$ssl = true;
|
||||
} else {
|
||||
$ssl = false;
|
||||
}
|
||||
|
||||
//we have to rename the challengefield
|
||||
if (!empty($CFG->recaptchaprivatekey) AND !empty($CFG->recaptchapublickey)) {
|
||||
$captchahtml = recaptcha_get_html($CFG->recaptchapublickey, null, $ssl);
|
||||
echo $html.$captchahtml;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function print_item_show_value($item, $value = '') {
|
||||
global $OUTPUT;
|
||||
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
|
||||
$requiredmark = '<img class="req" title="'.get_string('requiredelement', 'form').'" alt="'.
|
||||
get_string('requiredelement', 'form').'" src="'.$OUTPUT->pix_url('req') .'" />';
|
||||
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
if (strval($item->label) !== '') {
|
||||
echo '('. format_string($item->label).') ';
|
||||
}
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
||||
public function check_value($value, $item) {
|
||||
global $SESSION, $CFG, $USER;
|
||||
require_once($CFG->libdir.'/recaptchalib.php');
|
||||
|
||||
//is recaptcha configured in moodle?
|
||||
if (empty($CFG->recaptchaprivatekey) OR empty($CFG->recaptchapublickey)) {
|
||||
return true;
|
||||
}
|
||||
$challenge = optional_param('recaptcha_challenge_field', '', PARAM_RAW);
|
||||
});
|
||||
|
||||
if ($value == $USER->sesskey AND $challenge == '') {
|
||||
return true;
|
||||
}
|
||||
$remoteip = getremoteaddr(null);
|
||||
$response = recaptcha_check_answer($CFG->recaptchaprivatekey, $remoteip, $challenge, $value);
|
||||
if ($response->is_valid) {
|
||||
$SESSION->feedback->captchacheck = $USER->sesskey;
|
||||
return true;
|
||||
}
|
||||
unset($SESSION->feedback->captchacheck);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function create_value($data) {
|
||||
@ -309,20 +156,6 @@ class feedback_item_captcha extends feedback_item_base {
|
||||
return $USER->sesskey;
|
||||
}
|
||||
|
||||
//compares the dbvalue with the dependvalue
|
||||
//dbvalue is value stored in the db
|
||||
//dependvalue is the value to check
|
||||
public function compare_value($item, $dbvalue, $dependvalue) {
|
||||
if ($dbvalue == $dependvalue) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get_presentation($data) {
|
||||
return '';
|
||||
}
|
||||
|
||||
public function get_hasvalue() {
|
||||
global $CFG;
|
||||
|
||||
@ -337,11 +170,17 @@ class feedback_item_captcha extends feedback_item_base {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function value_type() {
|
||||
return PARAM_RAW;
|
||||
}
|
||||
|
||||
public function clean_input_value($value) {
|
||||
return clean_param($value, $this->value_type());
|
||||
/**
|
||||
* Returns the list of actions allowed on this item in the edit mode
|
||||
*
|
||||
* @param stdClass $item
|
||||
* @param stdClass $feedback
|
||||
* @param cm_info $cm
|
||||
* @return action_menu_link[]
|
||||
*/
|
||||
public function edit_actions($item, $feedback, $cm) {
|
||||
$actions = parent::edit_actions($item, $feedback, $cm);
|
||||
unset($actions['update']);
|
||||
return $actions;
|
||||
}
|
||||
}
|
||||
|
@ -15,25 +15,45 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
abstract class feedback_item_base {
|
||||
|
||||
/** @var string type of the element, should be overridden by each item type */
|
||||
protected $type;
|
||||
|
||||
/** @var feedback_item_form */
|
||||
protected $item_form;
|
||||
|
||||
/** @var stdClass */
|
||||
protected $item;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->init();
|
||||
}
|
||||
|
||||
//this function only can used after the call of build_editform()
|
||||
/**
|
||||
* Displays the form for editing an item
|
||||
*
|
||||
* this function only can used after the call of build_editform()
|
||||
*/
|
||||
public function show_editform() {
|
||||
$this->item_form->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the editing form was cancelled
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_cancelled() {
|
||||
return $this->item_form->is_cancelled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets submitted data from the edit form and saves it in $this->item
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function get_data() {
|
||||
if ($this->item = $this->item_form->get_data()) {
|
||||
return true;
|
||||
@ -41,27 +61,62 @@ abstract class feedback_item_base {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function value_type() {
|
||||
return PARAM_RAW;
|
||||
}
|
||||
|
||||
public function value_is_array() {
|
||||
return false;
|
||||
}
|
||||
|
||||
abstract public function init();
|
||||
/**
|
||||
* Creates and returns an instance of the form for editing the item
|
||||
*
|
||||
* @param stdClass $item
|
||||
* @param stdClass $feedback
|
||||
* @param cm_info|stdClass $cm
|
||||
*/
|
||||
abstract public function build_editform($item, $feedback, $cm);
|
||||
abstract public function save_item();
|
||||
abstract public function check_value($value, $item);
|
||||
abstract public function create_value($data);
|
||||
abstract public function compare_value($item, $dbvalue, $dependvalue);
|
||||
abstract public function get_presentation($data);
|
||||
abstract public function get_hasvalue();
|
||||
abstract public function can_switch_require();
|
||||
|
||||
/**
|
||||
* Saves the item after it has been edited (or created)
|
||||
*/
|
||||
abstract public function save_item();
|
||||
|
||||
/**
|
||||
* Converts the value from complete_form data to the string value that is stored in the db.
|
||||
* @param mixed $value element from mod_feedback_complete_form::get_data() with the name $item->typ.'_'.$item->id
|
||||
* @return string
|
||||
*/
|
||||
public function create_value($value) {
|
||||
return strval($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the dbvalue with the dependvalue
|
||||
*
|
||||
* @param stdClass $item
|
||||
* @param string $dbvalue is the value input by user in the format as it is stored in the db
|
||||
* @param string $dependvalue is the value that it needs to be compared against
|
||||
*/
|
||||
public function compare_value($item, $dbvalue, $dependvalue) {
|
||||
return strval($dbvalue) === strval($dependvalue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wether this item type has a value that is expected from the user and saved in the stored values.
|
||||
* @return int
|
||||
*/
|
||||
public function get_hasvalue() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wether this item can be set as both required and not
|
||||
* @return bool
|
||||
*/
|
||||
public function can_switch_require() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds summary information about an item to the Excel export file
|
||||
*
|
||||
* @param object $worksheet a reference to the pear_spreadsheet-object
|
||||
* @param integer $row_offset
|
||||
* @param stdClass $xls_formats see analysis_to_excel.php
|
||||
* @param object $item the db-object from feedback_item
|
||||
* @param integer $groupid
|
||||
* @param integer $courseid
|
||||
@ -72,6 +127,8 @@ abstract class feedback_item_base {
|
||||
$groupid, $courseid = false);
|
||||
|
||||
/**
|
||||
* Prints analysis for the current item
|
||||
*
|
||||
* @param $item the db-object from feedback_item
|
||||
* @param string $itemnr
|
||||
* @param integer $groupid
|
||||
@ -81,6 +138,8 @@ abstract class feedback_item_base {
|
||||
abstract public function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false);
|
||||
|
||||
/**
|
||||
* Prepares the value for exporting to Excel
|
||||
*
|
||||
* @param object $item the db-object from feedback_item
|
||||
* @param string $value a item-related value from feedback_values
|
||||
* @return string
|
||||
@ -88,54 +147,105 @@ abstract class feedback_item_base {
|
||||
abstract public function get_printval($item, $value);
|
||||
|
||||
/**
|
||||
* returns an Array with three values(typ, name, XXX)
|
||||
* XXX is also an Array (count of responses on type $this->type)
|
||||
* each element is a structure (answertext, answercount)
|
||||
* @param $item the db-object from feedback_item
|
||||
* @param $groupid if given
|
||||
* @param $courseid if given
|
||||
* @return array
|
||||
* Returns the formatted name of the item for the complete form or response view
|
||||
*
|
||||
* @param stdClass $item
|
||||
* @param bool $withpostfix
|
||||
* @return string
|
||||
*/
|
||||
abstract public function get_analysed($item, $groupid = false, $courseid = false);
|
||||
public function get_display_name($item, $withpostfix = true) {
|
||||
return format_text($item->name, FORMAT_HTML, array('noclean' => true, 'para' => false)) .
|
||||
($withpostfix ? $this->get_display_name_postfix($item) : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the edit-page of feedback
|
||||
* Returns the postfix to be appended to the display name that is based on other settings
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @return void
|
||||
* @param stdClass $item
|
||||
* @return string
|
||||
*/
|
||||
abstract public function print_item_preview($item);
|
||||
public function get_display_name_postfix($item) {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
* Adds an input element to the complete form
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @param string $value
|
||||
* @param bool $highlightrequire
|
||||
* @return void
|
||||
* This method is called:
|
||||
* - to display the form when user completes feedback
|
||||
* - to display existing elements when teacher edits the feedback items
|
||||
* - to display the feedback preview (print.php)
|
||||
* - to display the completed response
|
||||
* - to preview a feedback template
|
||||
*
|
||||
* If it is important which mode the form is in, use $form->get_mode()
|
||||
*
|
||||
* Each item type must add a single form element with the name $item->typ.'_'.$item->id
|
||||
* To add an element use either:
|
||||
* $form->add_form_element() - adds a single element to the form
|
||||
* $form->add_form_group_element() - adds a group element to the form
|
||||
*
|
||||
* Other useful methods:
|
||||
* $form->get_item_value()
|
||||
* $form->set_element_default()
|
||||
* $form->add_validation_rule()
|
||||
* $form->set_element_type()
|
||||
*
|
||||
* The element must support freezing so it can be used for viewing the response as well.
|
||||
* If the desired form element does not support freezing, check $form->is_frozen()
|
||||
* and create a static element instead.
|
||||
*
|
||||
* @param stdClass $item
|
||||
* @param mod_feedback_complete_form $form
|
||||
*/
|
||||
abstract public function print_item_complete($item, $value = '', $highlightrequire = false);
|
||||
abstract public function complete_form_element($item, $form);
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
* Returns the list of actions allowed on this item in the edit mode
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @param string $value
|
||||
* @return void
|
||||
* @param stdClass $item
|
||||
* @param stdClass $feedback
|
||||
* @param cm_info $cm
|
||||
* @return action_menu_link[]
|
||||
*/
|
||||
abstract public function print_item_show_value($item, $value = '');
|
||||
public function edit_actions($item, $feedback, $cm) {
|
||||
$actions = array();
|
||||
|
||||
/**
|
||||
* cleans the userinput while submitting the form
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function clean_input_value($value);
|
||||
$strupdate = get_string('edit_item', 'feedback');
|
||||
$actions['update'] = new action_menu_link_secondary(
|
||||
new moodle_url('/mod/feedback/edit_item.php', array('id' => $item->id)),
|
||||
new pix_icon('t/edit', $strupdate, 'moodle', array('class' => 'iconsmall', 'title' => '')),
|
||||
$strupdate,
|
||||
array('class' => 'editing_update', 'data-action' => 'update')
|
||||
);
|
||||
|
||||
if ($this->can_switch_require()) {
|
||||
if ($item->required == 1) {
|
||||
$buttontitle = get_string('switch_item_to_not_required', 'feedback');
|
||||
$buttonimg = 'required';
|
||||
} else {
|
||||
$buttontitle = get_string('switch_item_to_required', 'feedback');
|
||||
$buttonimg = 'notrequired';
|
||||
}
|
||||
$url = new moodle_url('/mod/feedback/edit.php', array('id' => $cm->id, 'do_show' => 'edit'));
|
||||
$actions['required'] = new action_menu_link_secondary(
|
||||
new moodle_url($url, array('switchitemrequired' => $item->id)),
|
||||
new pix_icon($buttonimg, $buttontitle, 'feedback', array('class' => 'iconsmall', 'title' => '')),
|
||||
$buttontitle,
|
||||
array('class' => 'editing_togglerequired', 'data-action' => 'togglerequired')
|
||||
);
|
||||
}
|
||||
|
||||
$strdelete = get_string('delete_item', 'feedback');
|
||||
$actions['delete'] = new action_menu_link_secondary(
|
||||
new moodle_url('/mod/feedback/delete_item.php', array('deleteitem' => $item->id)),
|
||||
new pix_icon('t/delete', $strdelete, 'moodle', array('class' => 'iconsmall', 'title' => '')),
|
||||
$strdelete,
|
||||
array('class' => 'editing_delete', 'data-action' => 'delete')
|
||||
);
|
||||
|
||||
return $actions;
|
||||
}
|
||||
}
|
||||
|
||||
//a dummy class to realize pagebreaks
|
||||
@ -144,25 +254,23 @@ class feedback_item_pagebreak extends feedback_item_base {
|
||||
|
||||
public function show_editform() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the editing form was cancelled
|
||||
* @return bool
|
||||
*/
|
||||
public function is_cancelled() {
|
||||
}
|
||||
public function get_data() {
|
||||
}
|
||||
public function init() {
|
||||
}
|
||||
public function build_editform($item, $feedback, $cm) {
|
||||
}
|
||||
public function save_item() {
|
||||
}
|
||||
public function check_value($value, $item) {
|
||||
}
|
||||
public function create_value($data) {
|
||||
}
|
||||
public function compare_value($item, $dbvalue, $dependvalue) {
|
||||
}
|
||||
public function get_presentation($data) {
|
||||
}
|
||||
public function get_hasvalue() {
|
||||
return 0;
|
||||
}
|
||||
public function excelprint_item(&$worksheet, $row_offset,
|
||||
$xls_formats, $item,
|
||||
@ -173,19 +281,38 @@ class feedback_item_pagebreak extends feedback_item_base {
|
||||
}
|
||||
public function get_printval($item, $value) {
|
||||
}
|
||||
public function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
}
|
||||
public function print_item_preview($item) {
|
||||
}
|
||||
public function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
}
|
||||
public function print_item_show_value($item, $value = '') {
|
||||
}
|
||||
public function can_switch_require() {
|
||||
}
|
||||
public function value_type() {
|
||||
}
|
||||
public function clean_input_value($value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an input element to the complete form
|
||||
*
|
||||
* @param stdClass $item
|
||||
* @param mod_feedback_complete_form $form
|
||||
*/
|
||||
public function complete_form_element($item, $form) {
|
||||
$form->add_form_element($item,
|
||||
['static', $item->typ.'_'.$item->id, '', '<hr class="feedback_pagebreak">']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of actions allowed on this item in the edit mode
|
||||
*
|
||||
* @param stdClass $item
|
||||
* @param stdClass $feedback
|
||||
* @param cm_info $cm
|
||||
* @return action_menu_link[]
|
||||
*/
|
||||
public function edit_actions($item, $feedback, $cm) {
|
||||
$actions = array();
|
||||
$strdelete = get_string('delete_pagebreak', 'feedback');
|
||||
$actions['delete'] = new action_menu_link_secondary(
|
||||
new moodle_url('/mod/feedback/delete_item.php', array('deleteitem' => $item->id)),
|
||||
new pix_icon('t/delete', $strdelete, 'moodle', array('class' => 'iconsmall', 'title' => '')),
|
||||
$strdelete,
|
||||
array('class' => 'editing_delete', 'data-action' => 'delete')
|
||||
);
|
||||
return $actions;
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ abstract class feedback_item_form extends moodleform {
|
||||
|
||||
$mform =& $this->_form;
|
||||
|
||||
if ($common['items']) {
|
||||
if (array_filter(array_keys($common['items']))) {
|
||||
$mform->addElement('select',
|
||||
'dependitem',
|
||||
get_string('dependitem', 'feedback').' ',
|
||||
@ -49,6 +49,7 @@ abstract class feedback_item_form extends moodleform {
|
||||
'dependvalue',
|
||||
get_string('dependvalue', 'feedback'),
|
||||
array('size'=>FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE, 'maxlength'=>255));
|
||||
$mform->disabledIf('dependvalue', 'dependitem', 'eq', '0');
|
||||
} else {
|
||||
$mform->addElement('hidden', 'dependitem', 0);
|
||||
$mform->addElement('hidden', 'dependvalue', '');
|
||||
@ -107,5 +108,20 @@ abstract class feedback_item_form extends moodleform {
|
||||
$mform->addGroup($buttonarray, 'buttonar', ' ', array(' '), false);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return submitted data if properly submitted or returns NULL if validation fails or
|
||||
* if there is no submitted data.
|
||||
*
|
||||
* @return object submitted data; NULL if not valid or not submitted or cancelled
|
||||
*/
|
||||
public function get_data() {
|
||||
if ($item = parent::get_data()) {
|
||||
if (!isset($item->dependvalue)) {
|
||||
$item->dependvalue = '';
|
||||
}
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,13 +19,13 @@ require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_class.php');
|
||||
|
||||
class feedback_item_info extends feedback_item_base {
|
||||
protected $type = "info";
|
||||
private $commonparams;
|
||||
private $item_form;
|
||||
private $item;
|
||||
|
||||
public function init() {
|
||||
|
||||
}
|
||||
/** Mode recording response time (for non-anonymous feedbacks only) */
|
||||
const MODE_RESPONSETIME = 1;
|
||||
/** Mode recording current course */
|
||||
const MODE_COURSE = 2;
|
||||
/** Mode recording current course category */
|
||||
const MODE_CATEGORY = 3;
|
||||
|
||||
public function build_editform($item, $feedback, $cm) {
|
||||
global $DB, $CFG;
|
||||
@ -64,22 +64,6 @@ class feedback_item_info extends feedback_item_base {
|
||||
'position' => $position));
|
||||
}
|
||||
|
||||
//this function only can used after the call of build_editform()
|
||||
public function show_editform() {
|
||||
$this->item_form->display();
|
||||
}
|
||||
|
||||
public function is_cancelled() {
|
||||
return $this->item_form->is_cancelled();
|
||||
}
|
||||
|
||||
public function get_data() {
|
||||
if ($this->item = $this->item_form->get_data()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function save_item() {
|
||||
global $DB;
|
||||
|
||||
@ -102,8 +86,15 @@ class feedback_item_info extends feedback_item_base {
|
||||
return $DB->get_record('feedback_item', array('id'=>$item->id));
|
||||
}
|
||||
|
||||
//liefert eine Struktur ->name, ->data = array(mit Antworten)
|
||||
public function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
/**
|
||||
* Helper function for collected data, both for analysis page and export to excel
|
||||
*
|
||||
* @param stdClass $item the db-object from feedback_item
|
||||
* @param int|false $groupid
|
||||
* @param int $courseid
|
||||
* @return stdClass
|
||||
*/
|
||||
protected function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
|
||||
$presentation = $item->presentation;
|
||||
$analysed_val = new stdClass();
|
||||
@ -116,15 +107,15 @@ class feedback_item_info extends feedback_item_base {
|
||||
$datavalue = new stdClass();
|
||||
|
||||
switch($presentation) {
|
||||
case 1:
|
||||
case self::MODE_RESPONSETIME:
|
||||
$datavalue->value = $value->value;
|
||||
$datavalue->show = userdate($datavalue->value);
|
||||
break;
|
||||
case 2:
|
||||
case self::MODE_COURSE:
|
||||
$datavalue->value = $value->value;
|
||||
$datavalue->show = $datavalue->value;
|
||||
break;
|
||||
case 3:
|
||||
case self::MODE_CATEGORY:
|
||||
$datavalue->value = $value->value;
|
||||
$datavalue->show = $datavalue->value;
|
||||
break;
|
||||
@ -142,7 +133,8 @@ class feedback_item_info extends feedback_item_base {
|
||||
if (!isset($value->value)) {
|
||||
return '';
|
||||
}
|
||||
return $item->presentation == 1 ? userdate($value->value) : $value->value;
|
||||
return $item->presentation == self::MODE_RESPONSETIME ?
|
||||
userdate($value->value) : $value->value;
|
||||
}
|
||||
|
||||
public function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
|
||||
@ -187,236 +179,84 @@ class feedback_item_info extends feedback_item_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the edit-page of feedback
|
||||
* Calculates the value of the item (time, course, course category)
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @return void
|
||||
* @param stdClass $item
|
||||
* @param stdClass $feedback
|
||||
* @param int $courseid
|
||||
* @return string
|
||||
*/
|
||||
public function print_item_preview($item) {
|
||||
global $USER, $DB, $OUTPUT;
|
||||
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$presentation = $item->presentation;
|
||||
$requiredmark = ($item->required == 1)?'<img class="req" title="'.get_string('requiredelement', 'form').'" alt="'.
|
||||
get_string('requiredelement', 'form').'" src="'.$OUTPUT->pix_url('req') .'" />':'';
|
||||
|
||||
if ($item->feedback) {
|
||||
$courseid = $DB->get_field('feedback', 'course', array('id'=>$item->feedback));
|
||||
} else { // the item must be a template item
|
||||
$cmid = required_param('id', PARAM_INT);
|
||||
$courseid = $DB->get_field('course_modules', 'course', array('id'=>$cmid));
|
||||
}
|
||||
if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
|
||||
print_error('error');
|
||||
}
|
||||
if ($course->id !== SITEID) {
|
||||
$coursecategory = $DB->get_record('course_categories', array('id'=>$course->category));
|
||||
} else {
|
||||
$coursecategory = false;
|
||||
}
|
||||
switch($presentation) {
|
||||
case 1:
|
||||
$itemvalue = time();
|
||||
$itemshowvalue = userdate($itemvalue);
|
||||
protected function get_current_value($item, $feedback, $courseid) {
|
||||
global $DB;
|
||||
switch ($item->presentation) {
|
||||
case self::MODE_RESPONSETIME:
|
||||
if ($feedback->anonymous != FEEDBACK_ANONYMOUS_YES) {
|
||||
// Response time is not allowed in anonymous feedbacks.
|
||||
return time();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$itemvalue = format_string($course->shortname,
|
||||
true,
|
||||
array('context' => $coursecontext));
|
||||
|
||||
$itemshowvalue = $itemvalue;
|
||||
case self::MODE_COURSE:
|
||||
$course = get_course($courseid);
|
||||
return format_string($course->shortname, true,
|
||||
array('context' => context_course::instance($course->id)));
|
||||
break;
|
||||
case 3:
|
||||
if ($coursecategory) {
|
||||
$category_context = context_coursecat::instance($coursecategory->id);
|
||||
$itemvalue = format_string($coursecategory->name,
|
||||
true,
|
||||
array('context' => $category_context));
|
||||
|
||||
$itemshowvalue = $itemvalue;
|
||||
} else {
|
||||
$itemvalue = '';
|
||||
$itemshowvalue = '';
|
||||
case self::MODE_CATEGORY:
|
||||
if ($courseid !== SITEID) {
|
||||
$coursecategory = $DB->get_record_sql('SELECT cc.id, cc.name FROM {course_categories} cc, {course} c '
|
||||
. 'WHERE c.category = cc.id AND c.id = ?', array($courseid));
|
||||
return format_string($coursecategory->name, true,
|
||||
array('context' => context_coursecat::instance($coursecategory->id)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
if (strval($item->label) !== '') {
|
||||
echo '('. format_string($item->label).') ';
|
||||
}
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
if ($item->dependitem) {
|
||||
if ($dependitem = $DB->get_record('feedback_item', array('id'=>$item->dependitem))) {
|
||||
echo ' <span class="feedback_depend">';
|
||||
echo '('.format_string($dependitem->label).'->'.$item->dependvalue.')';
|
||||
echo '</span>';
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
echo '<input type="hidden" name="'.$item->typ.'_'.$item->id.'" value="'.$itemvalue.'" />';
|
||||
echo '<span class="feedback_item_info">'.$itemshowvalue.'</span>';
|
||||
echo '</div>';
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
* Adds an input element to the complete form
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @param string $value
|
||||
* @param bool $highlightrequire
|
||||
* @return void
|
||||
* @param stdClass $item
|
||||
* @param mod_feedback_complete_form $form
|
||||
*/
|
||||
public function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
global $USER, $DB, $OUTPUT;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
|
||||
$presentation = $item->presentation;
|
||||
if ($highlightrequire AND $item->required AND strval($value) == '') {
|
||||
$highlight = 'error';
|
||||
public function complete_form_element($item, $form) {
|
||||
if ($form->get_mode() == mod_feedback_complete_form::MODE_VIEW_RESPONSE) {
|
||||
$value = strval($form->get_item_value($item));
|
||||
} else {
|
||||
$highlight = '';
|
||||
$value = $this->get_current_value($item,
|
||||
$form->get_feedback(), $form->get_current_course_id());
|
||||
}
|
||||
$requiredmark = ($item->required == 1)?'<img class="req" title="'.get_string('requiredelement', 'form').'" alt="'.
|
||||
get_string('requiredelement', 'form').'" src="'.$OUTPUT->pix_url('req') .'" />':'';
|
||||
$printval = $this->get_printval($item, (object)['value' => $value]);
|
||||
|
||||
$feedback = $DB->get_record('feedback', array('id'=>$item->feedback));
|
||||
|
||||
if ($courseid = optional_param('courseid', 0, PARAM_INT)) {
|
||||
$course = $DB->get_record('course', array('id'=>$courseid));
|
||||
} else {
|
||||
$course = $DB->get_record('course', array('id'=>$feedback->course));
|
||||
}
|
||||
|
||||
if ($course->id !== SITEID) {
|
||||
$coursecategory = $DB->get_record('course_categories', array('id'=>$course->category));
|
||||
} else {
|
||||
$coursecategory = false;
|
||||
}
|
||||
|
||||
switch($presentation) {
|
||||
case 1:
|
||||
if ($feedback->anonymous == FEEDBACK_ANONYMOUS_YES) {
|
||||
$itemvalue = 0;
|
||||
$itemshowvalue = '-';
|
||||
} else {
|
||||
$itemvalue = time();
|
||||
$itemshowvalue = userdate($itemvalue);
|
||||
}
|
||||
$class = '';
|
||||
switch ($item->presentation) {
|
||||
case self::MODE_RESPONSETIME:
|
||||
$class = 'info-responsetime';
|
||||
break;
|
||||
case 2:
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$itemvalue = format_string($course->shortname,
|
||||
true,
|
||||
array('context' => $coursecontext));
|
||||
|
||||
$itemshowvalue = $itemvalue;
|
||||
case self::MODE_COURSE:
|
||||
$class = 'info-course';
|
||||
break;
|
||||
case 3:
|
||||
if ($coursecategory) {
|
||||
$category_context = context_coursecat::instance($coursecategory->id);
|
||||
$itemvalue = format_string($coursecategory->name,
|
||||
true,
|
||||
array('context' => $category_context));
|
||||
|
||||
$itemshowvalue = $itemvalue;
|
||||
} else {
|
||||
$itemvalue = '';
|
||||
$itemshowvalue = '';
|
||||
}
|
||||
case self::MODE_CATEGORY:
|
||||
$class = 'info-category';
|
||||
break;
|
||||
}
|
||||
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
echo '<span class="'.$highlight.'">';
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
echo '</span>';
|
||||
echo '</div>';
|
||||
$name = $this->get_display_name($item);
|
||||
$inputname = $item->typ . '_' . $item->id;
|
||||
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
echo '<input type="hidden" name="'.$item->typ.'_'.$item->id.'" value="'.$itemvalue.'" />';
|
||||
echo '<span class="feedback_item_info">'.$itemshowvalue.'</span>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function print_item_show_value($item, $value = '') {
|
||||
global $USER, $DB, $OUTPUT;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
|
||||
$presentation = $item->presentation;
|
||||
$requiredmark = ($item->required == 1)?'<img class="req" title="'.get_string('requiredelement', 'form').'" alt="'.
|
||||
get_string('requiredelement', 'form').'" src="'.$OUTPUT->pix_url('req') .'" />':'';
|
||||
|
||||
if ($presentation == 1) {
|
||||
$value = $value ? userdate($value) : ' ';
|
||||
$element = $form->add_form_element($item,
|
||||
['select', $inputname, $name,
|
||||
array($value => $printval),
|
||||
array('class' => $class)],
|
||||
false,
|
||||
false);
|
||||
$form->set_element_default($inputname, $value);
|
||||
$element->freeze();
|
||||
if ($form->get_mode() == mod_feedback_complete_form::MODE_COMPLETE) {
|
||||
$element->setPersistantFreeze(true);
|
||||
}
|
||||
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
if (strval($item->label) !== '') {
|
||||
echo '('. format_string($item->label).') ';
|
||||
}
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
echo '</div>';
|
||||
|
||||
//print the presentation
|
||||
echo $OUTPUT->box_start('generalbox boxalign'.$align);
|
||||
echo $value;
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
public function check_value($value, $item) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function create_value($data) {
|
||||
$data = clean_text($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
//compares the dbvalue with the dependvalue
|
||||
//the values can be the shortname of a course or the category name
|
||||
//the date is not compareable :(.
|
||||
public function compare_value($item, $dbvalue, $dependvalue) {
|
||||
if ($dbvalue == $dependvalue) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get_presentation($data) {
|
||||
return $data->infotype;
|
||||
}
|
||||
|
||||
public function get_hasvalue() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function can_switch_require() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function value_type() {
|
||||
return PARAM_TEXT;
|
||||
}
|
||||
|
||||
public function clean_input_value($value) {
|
||||
return clean_param($value, $this->value_type());
|
||||
}
|
||||
}
|
||||
|
@ -21,13 +21,12 @@ require_once($CFG->libdir.'/formslib.php');
|
||||
class feedback_item_label extends feedback_item_base {
|
||||
protected $type = "label";
|
||||
private $presentationoptions = null;
|
||||
private $commonparams;
|
||||
private $item_form;
|
||||
private $context;
|
||||
private $item;
|
||||
|
||||
public function init() {
|
||||
global $CFG;
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->presentationoptions = array('maxfiles' => EDITOR_UNLIMITED_FILES,
|
||||
'trusttext'=>true);
|
||||
|
||||
@ -87,22 +86,6 @@ class feedback_item_label extends feedback_item_base {
|
||||
$this->item_form = new feedback_label_form('edit_item.php', $customdata);
|
||||
}
|
||||
|
||||
//this function only can used after the call of build_editform()
|
||||
public function show_editform() {
|
||||
$this->item_form->display();
|
||||
}
|
||||
|
||||
public function is_cancelled() {
|
||||
return $this->item_form->is_cancelled();
|
||||
}
|
||||
|
||||
public function get_data() {
|
||||
if ($this->item = $this->item_form->get_data()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function save_item() {
|
||||
global $DB;
|
||||
|
||||
@ -137,7 +120,12 @@ class feedback_item_label extends feedback_item_base {
|
||||
return $DB->get_record('feedback_item', array('id'=>$item->id));
|
||||
}
|
||||
|
||||
public function print_item($item) {
|
||||
/**
|
||||
* prepares the item for output or export to file
|
||||
* @param stdClass $item
|
||||
* @return string
|
||||
*/
|
||||
private function print_item($item) {
|
||||
global $DB, $CFG;
|
||||
|
||||
require_once($CFG->libdir . '/filelib.php');
|
||||
@ -172,63 +160,51 @@ class feedback_item_label extends feedback_item_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the edit-page of feedback
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @return void
|
||||
* @param stdClass $item
|
||||
* @param bool|true $withpostfix
|
||||
* @return string
|
||||
*/
|
||||
public function print_item_preview($item) {
|
||||
global $OUTPUT, $DB;
|
||||
public function get_display_name($item, $withpostfix = true) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($item->dependitem) {
|
||||
if ($dependitem = $DB->get_record('feedback_item', array('id'=>$item->dependitem))) {
|
||||
echo ' <span class="feedback_depend">';
|
||||
echo '('.format_string($dependitem->label).'->'.$item->dependvalue.')';
|
||||
echo '</span>';
|
||||
/**
|
||||
* Adds an input element to the complete form
|
||||
*
|
||||
* @param stdClass $item
|
||||
* @param mod_feedback_complete_form $form
|
||||
*/
|
||||
public function complete_form_element($item, $form) {
|
||||
global $DB;
|
||||
if (!$item->feedback AND $item->template) {
|
||||
// This is a template.
|
||||
$template = $DB->get_record('feedback_template', array('id' => $item->template));
|
||||
if ($template->ispublic) {
|
||||
$context = context_system::instance();
|
||||
} else {
|
||||
$context = context_course::instance($template->course);
|
||||
}
|
||||
$filearea = 'template';
|
||||
} else {
|
||||
// This is a question in the current feedback.
|
||||
$context = $form->get_cm()->context;
|
||||
$filearea = 'item';
|
||||
}
|
||||
$this->print_item($item);
|
||||
}
|
||||
$output = file_rewrite_pluginfile_urls($item->presentation, 'pluginfile.php',
|
||||
$context->id, 'mod_feedback', $filearea, $item->id);
|
||||
$formatoptions = array('overflowdiv' => true, 'noclean' => true);
|
||||
$output = format_text($output, FORMAT_HTML, $formatoptions);
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @param string $value
|
||||
* @param bool $highlightrequire
|
||||
* @return void
|
||||
*/
|
||||
public function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
$this->print_item($item);
|
||||
}
|
||||
$inputname = $item->typ . '_' . $item->id;
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function print_item_show_value($item, $value = '') {
|
||||
$this->print_item($item);
|
||||
}
|
||||
|
||||
public function create_value($data) {
|
||||
return false;
|
||||
$name = $this->get_display_name($item);
|
||||
$form->add_form_element($item, ['static', $inputname, $name, $output], false, false);
|
||||
}
|
||||
|
||||
public function compare_value($item, $dbvalue, $dependvalue) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//used by create_item and update_item functions,
|
||||
//when provided $data submitted from feedback_show_edit
|
||||
public function get_presentation($data) {
|
||||
}
|
||||
|
||||
public function postupdate($item) {
|
||||
global $DB;
|
||||
|
||||
@ -253,9 +229,6 @@ class feedback_item_label extends feedback_item_base {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function check_value($value, $item) {
|
||||
}
|
||||
|
||||
public function excelprint_item(&$worksheet,
|
||||
$row_offset,
|
||||
$xls_formats,
|
||||
@ -268,12 +241,4 @@ class feedback_item_label extends feedback_item_base {
|
||||
}
|
||||
public function get_printval($item, $value) {
|
||||
}
|
||||
public function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
}
|
||||
public function value_type() {
|
||||
return PARAM_BOOL;
|
||||
}
|
||||
public function clean_input_value($value) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@ -25,13 +25,6 @@ define('FEEDBACK_MULTICHOICE_HIDENOSELECT', 'h');
|
||||
|
||||
class feedback_item_multichoice extends feedback_item_base {
|
||||
protected $type = "multichoice";
|
||||
private $commonparams;
|
||||
private $item_form;
|
||||
private $item;
|
||||
|
||||
public function init() {
|
||||
|
||||
}
|
||||
|
||||
public function build_editform($item, $feedback, $cm) {
|
||||
global $DB, $CFG;
|
||||
@ -75,22 +68,6 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
$this->item_form = new feedback_multichoice_form('edit_item.php', $customdata);
|
||||
}
|
||||
|
||||
//this function only can used after the call of build_editform()
|
||||
public function show_editform() {
|
||||
$this->item_form->display();
|
||||
}
|
||||
|
||||
public function is_cancelled() {
|
||||
return $this->item_form->is_cancelled();
|
||||
}
|
||||
|
||||
public function get_data() {
|
||||
if ($this->item = $this->item_form->get_data()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function save_item() {
|
||||
global $DB;
|
||||
|
||||
@ -119,7 +96,16 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
|
||||
//gets an array with three values(typ, name, XXX)
|
||||
//XXX is an object with answertext, answercount and quotient
|
||||
public function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
|
||||
/**
|
||||
* Helper function for collected data, both for analysis page and export to excel
|
||||
*
|
||||
* @param stdClass $item the db-object from feedback_item
|
||||
* @param int $groupid
|
||||
* @param int $courseid
|
||||
* @return array
|
||||
*/
|
||||
protected function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
$info = $this->get_info($item);
|
||||
|
||||
$analysed_item = array();
|
||||
@ -217,15 +203,6 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
|
||||
public function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
|
||||
global $OUTPUT;
|
||||
$sep_dec = get_string('separator_decimal', 'feedback');
|
||||
if (substr($sep_dec, 0, 2) == '[[') {
|
||||
$sep_dec = FEEDBACK_DECIMAL;
|
||||
}
|
||||
|
||||
$sep_thous = get_string('separator_thousand', 'feedback');
|
||||
if (substr($sep_thous, 0, 2) == '[[') {
|
||||
$sep_thous = FEEDBACK_THOUSAND;
|
||||
}
|
||||
|
||||
$analysed_item = $this->get_analysed($item, $groupid, $courseid);
|
||||
if ($analysed_item) {
|
||||
@ -243,19 +220,22 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
foreach ($analysed_vals as $val) {
|
||||
$intvalue = $pixnr % 10;
|
||||
$pix = $OUTPUT->pix_url('multichoice/' . $intvalue, 'feedback');
|
||||
$pixspacer = $OUTPUT->pix_url('spacer');
|
||||
$pixnr++;
|
||||
$pixwidth = intval($val->quotient * FEEDBACK_MAX_PIX_LENGTH);
|
||||
$quotient = number_format(($val->quotient * 100), 2, $sep_dec, $sep_thous);
|
||||
$pixwidth = max(2, intval($val->quotient * FEEDBACK_MAX_PIX_LENGTH));
|
||||
$pixwidthspacer = FEEDBACK_MAX_PIX_LENGTH + 1 - $pixwidth;
|
||||
$quotient = format_float($val->quotient * 100, 2);
|
||||
$str_quotient = '';
|
||||
if ($val->quotient > 0) {
|
||||
$str_quotient = ' ('. $quotient . ' %)';
|
||||
}
|
||||
echo '<tr>';
|
||||
echo '<td align="left" valign="top">
|
||||
- '.trim($val->answertext).':
|
||||
- '.format_text(trim($val->answertext), FORMAT_HTML, array('noclean' => true, 'para' => false)).':
|
||||
</td>
|
||||
<td align="left" style="width:'.FEEDBACK_MAX_PIX_LENGTH.';">
|
||||
<img class="feedback_bar_image" alt="'.$intvalue.'" src="'.$pix.'" height="5" width="'.$pixwidth.'" />
|
||||
<img class="feedback_bar_image" alt="'.$intvalue.'" src="'.$pix.'" width="'.$pixwidth.'" />'.
|
||||
'<img class="feedback_bar_image" alt="" src="'.$pixspacer.'" width="'.$pixwidthspacer.'" />
|
||||
'.$val->answercount.$str_quotient.'
|
||||
</td>';
|
||||
echo '</tr>';
|
||||
@ -300,310 +280,109 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the edit-page of feedback
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @return void
|
||||
* Options for the multichoice element
|
||||
* @param stdClass $item
|
||||
* @return array
|
||||
*/
|
||||
public function print_item_preview($item) {
|
||||
global $OUTPUT, $DB;
|
||||
protected function get_options($item) {
|
||||
$info = $this->get_info($item);
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
|
||||
$presentation = explode (FEEDBACK_MULTICHOICE_LINE_SEP, $info->presentation);
|
||||
$strrequiredmark = '<img class="req" title="'.get_string('requiredelement', 'form').'" alt="'.
|
||||
get_string('requiredelement', 'form').'" src="'.$OUTPUT->pix_url('req') .'" />';
|
||||
|
||||
//test if required and no value is set so we have to mark this item
|
||||
//we have to differ check and the other subtypes
|
||||
$requiredmark = ($item->required == 1) ? $strrequiredmark : '';
|
||||
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
if ($info->subtype == 'd') {
|
||||
echo '<label for="'. $item->typ . '_' . $item->id .'">';
|
||||
$options = array();
|
||||
foreach ($presentation as $idx => $optiontext) {
|
||||
$options[$idx + 1] = format_text($optiontext, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
}
|
||||
if (strval($item->label) !== '') {
|
||||
echo '('. format_string($item->label).') ';
|
||||
}
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
if ($item->dependitem) {
|
||||
if ($dependitem = $DB->get_record('feedback_item', array('id'=>$item->dependitem))) {
|
||||
echo ' <span class="feedback_depend">';
|
||||
echo '('.format_string($dependitem->label).'->'.$item->dependvalue.')';
|
||||
echo '</span>';
|
||||
}
|
||||
}
|
||||
if ($info->subtype == 'd') {
|
||||
echo '</label>';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
$index = 1;
|
||||
$checked = '';
|
||||
if ($info->subtype == 'r' || $info->subtype == 'c') {
|
||||
// if (r)adio buttons or (c)heckboxes
|
||||
echo '<fieldset>';
|
||||
echo '<ul>';
|
||||
if ($info->subtype === 'r' && !$this->hidenoselect($item)) {
|
||||
$options = array(0 => get_string('not_selected', 'feedback')) + $options;
|
||||
}
|
||||
|
||||
if ($info->horizontal) {
|
||||
$hv = 'h';
|
||||
} else {
|
||||
$hv = 'v';
|
||||
}
|
||||
|
||||
if ($info->subtype == 'r' AND !$this->hidenoselect($item)) {
|
||||
//print the "not_selected" item on radiobuttons
|
||||
?>
|
||||
<li class="feedback_item_radio_<?php echo $hv.'_'.$align;?>">
|
||||
<span class="feedback_item_radio_<?php echo $hv.'_'.$align;?>">
|
||||
<?php
|
||||
echo '<input type="radio" '.
|
||||
'name="'.$item->typ.'_'.$item->id.'[]" '.
|
||||
'id="'.$item->typ.'_'.$item->id.'_xxx" '.
|
||||
'value="" checked="checked" />';
|
||||
?>
|
||||
</span>
|
||||
<span class="feedback_item_radiolabel_<?php echo $hv.'_'.$align;?>">
|
||||
<label for="<?php echo $item->typ . '_' . $item->id.'_xxx';?>">
|
||||
<?php print_string('not_selected', 'feedback');?>
|
||||
</label>
|
||||
</span>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
switch($info->subtype) {
|
||||
case 'r':
|
||||
$this->print_item_radio($presentation, $item, false, $info, $align);
|
||||
break;
|
||||
case 'c':
|
||||
$this->print_item_check($presentation, $item, false, $info, $align);
|
||||
break;
|
||||
case 'd':
|
||||
$this->print_item_dropdown($presentation, $item, false, $info, $align);
|
||||
break;
|
||||
}
|
||||
if ($info->subtype == 'r' || $info->subtype == 'c') {
|
||||
// if (r)adio buttons or (c)heckboxes
|
||||
echo '</ul>';
|
||||
echo '</fieldset>';
|
||||
}
|
||||
echo '</div>';
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
* Adds an input element to the complete form
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @param string $value
|
||||
* @param bool $highlightrequire
|
||||
* @return void
|
||||
* This element has many options - it can be displayed as group or radio elements,
|
||||
* group of checkboxes or a dropdown list.
|
||||
*
|
||||
* @param stdClass $item
|
||||
* @param mod_feedback_complete_form $form
|
||||
*/
|
||||
public function print_item_complete($item, $value = null, $highlightrequire = false) {
|
||||
global $OUTPUT;
|
||||
public function complete_form_element($item, $form) {
|
||||
$info = $this->get_info($item);
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
|
||||
if ($value == null) {
|
||||
$value = array();
|
||||
}
|
||||
$presentation = explode (FEEDBACK_MULTICHOICE_LINE_SEP, $info->presentation);
|
||||
$strrequiredmark = '<img class="req" title="'.get_string('requiredelement', 'form').'" alt="'.
|
||||
get_string('requiredelement', 'form').'" src="'.$OUTPUT->pix_url('req') .'" />';
|
||||
|
||||
//test if required and no value is set so we have to mark this item
|
||||
//we have to differ check and the other subtypes
|
||||
if (is_array($value)) {
|
||||
$values = $value;
|
||||
} else {
|
||||
$values = explode(FEEDBACK_MULTICHOICE_LINE_SEP, $value);
|
||||
}
|
||||
$requiredmark = ($item->required == 1) ? $strrequiredmark : '';
|
||||
|
||||
//print the question and label
|
||||
$name = $this->get_display_name($item);
|
||||
$class = 'multichoice-' . $info->subtype;
|
||||
$inputname = $item->typ . '_' . $item->id;
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
if ($info->subtype == 'd') {
|
||||
echo '<label for="'. $inputname .'">';
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
if ($highlightrequire AND $item->required AND (count($values) == 0 OR $values[0] == '' OR $values[0] == 0)) {
|
||||
echo '<br class="error"><span id="id_error_'.$inputname.'" class="error"> '.get_string('err_required', 'form').
|
||||
'</span><br id="id_error_break_'.$inputname.'" class="error" >';
|
||||
}
|
||||
echo '</label>';
|
||||
} else {
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
if ($highlightrequire AND $item->required AND (count($values) == 0 OR $values[0] == '' OR $values[0] == 0)) {
|
||||
echo '<br class="error"><span id="id_error_'.$inputname.'" class="error"> '.get_string('err_required', 'form').
|
||||
'</span><br id="id_error_break_'.$inputname.'" class="error" >';
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
$options = $this->get_options($item);
|
||||
$separator = !empty($info->horizontal) ? ' ' : '<br>';
|
||||
$tmpvalue = $form->get_item_value($item);
|
||||
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
|
||||
if ($info->subtype == 'r' || $info->subtype == 'c') {
|
||||
// if (r)adio buttons or (c)heckboxes
|
||||
echo '<fieldset>';
|
||||
echo '<ul>';
|
||||
}
|
||||
if ($info->horizontal) {
|
||||
$hv = 'h';
|
||||
if ($info->subtype === 'd' || ($info->subtype === 'r' && $form->is_frozen())) {
|
||||
// Display as a dropdown in the complete form or a single value in the response view.
|
||||
$element = $form->add_form_element($item,
|
||||
['select', $inputname.'[0]', $name, array(0 => '') + $options, array('class' => $class)],
|
||||
false, false);
|
||||
$form->set_element_default($inputname.'[0]', $tmpvalue);
|
||||
} else if ($info->subtype === 'c' && $form->is_frozen()) {
|
||||
// Display list of checkbox values in the response view.
|
||||
$objs = [];
|
||||
foreach (explode(FEEDBACK_MULTICHOICE_LINE_SEP, $form->get_item_value($item)) as $v) {
|
||||
$objs[] = ['static', $inputname."[$v]", '', isset($options[$v]) ? $options[$v] : ''];
|
||||
}
|
||||
$element = $form->add_form_group_element($item, 'group_'.$inputname, $name, $objs, $separator, $class);
|
||||
} else {
|
||||
$hv = 'v';
|
||||
}
|
||||
//print the "not_selected" item on radiobuttons
|
||||
if ($info->subtype == 'r' AND !$this->hidenoselect($item)) {
|
||||
?>
|
||||
<li class="feedback_item_radio_<?php echo $hv.'_'.$align;?>">
|
||||
<span class="feedback_item_radio_<?php echo $hv.'_'.$align;?>">
|
||||
<?php
|
||||
$checked = '';
|
||||
// if (!$value) {
|
||||
// $checked = 'checked="checked"';
|
||||
// }
|
||||
if (count($values) == 0 OR $values[0] == '' OR $values[0] == 0) {
|
||||
$checked = 'checked="checked"';
|
||||
// Display group or radio or checkbox elements.
|
||||
$class .= ' multichoice-' . ($info->horizontal ? 'horizontal' : 'vertical');
|
||||
$objs = [];
|
||||
if ($info->subtype === 'c') {
|
||||
// Checkboxes.
|
||||
$objs[] = ['hidden', $inputname.'[0]', 0];
|
||||
foreach ($options as $idx => $label) {
|
||||
$objs[] = ['advcheckbox', $inputname.'['.$idx.']', '', $label, null, array(0, $idx)];
|
||||
}
|
||||
$element = $form->add_form_group_element($item, 'group_'.$inputname, $name, $objs, $separator, $class);
|
||||
if ($tmpvalue) {
|
||||
foreach (explode(FEEDBACK_MULTICHOICE_LINE_SEP, $tmpvalue) as $v) {
|
||||
$form->set_element_default($inputname.'['.$v.']', $v);
|
||||
}
|
||||
echo '<input type="radio" '.
|
||||
'name="'.$item->typ.'_'.$item->id.'[]" '.
|
||||
'id="'.$item->typ.'_'.$item->id.'_xxx" '.
|
||||
'value="" '.$checked.' />';
|
||||
?>
|
||||
</span>
|
||||
<span class="feedback_item_radiolabel_<?php echo $hv.'_'.$align;?>">
|
||||
<label for="<?php echo $item->typ.'_'.$item->id.'_xxx';?>">
|
||||
<?php print_string('not_selected', 'feedback');?>
|
||||
</label>
|
||||
</span>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
// Radio.
|
||||
foreach ($options as $idx => $label) {
|
||||
$objs[] = ['radio', $inputname.'[0]', '', $label, $idx];
|
||||
}
|
||||
$element = $form->add_form_group_element($item, 'group_'.$inputname, $name, $objs, $separator, $class);
|
||||
$form->set_element_default($inputname.'[0]', $tmpvalue);
|
||||
}
|
||||
}
|
||||
|
||||
switch($info->subtype) {
|
||||
case 'r':
|
||||
$this->print_item_radio($presentation, $item, $value, $info, $align);
|
||||
break;
|
||||
case 'c':
|
||||
$this->print_item_check($presentation, $item, $value, $info, $align);
|
||||
break;
|
||||
case 'd':
|
||||
$this->print_item_dropdown($presentation, $item, $value, $info, $align);
|
||||
break;
|
||||
// Process 'required' rule.
|
||||
if ($item->required) {
|
||||
$elementname = $element->getName();
|
||||
$form->add_validation_rule(function($values, $files) use ($elementname, $item) {
|
||||
$inputname = $item->typ . '_' . $item->id;
|
||||
return empty($values[$inputname]) || !array_filter($values[$inputname]) ?
|
||||
array($elementname => get_string('required')) : true;
|
||||
});
|
||||
}
|
||||
if ($info->subtype == 'r' || $info->subtype == 'c') {
|
||||
// if (r)adio buttons or (c)heckboxes
|
||||
echo '</ul>';
|
||||
echo '</fieldset>';
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @param string $value
|
||||
* @return void
|
||||
* Prepares value that user put in the form for storing in DB
|
||||
* @param array $value
|
||||
* @return string
|
||||
*/
|
||||
public function print_item_show_value($item, $value = null) {
|
||||
global $OUTPUT;
|
||||
$info = $this->get_info($item);
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
|
||||
if ($value == null) {
|
||||
$value = array();
|
||||
}
|
||||
|
||||
$presentation = explode (FEEDBACK_MULTICHOICE_LINE_SEP, $info->presentation);
|
||||
|
||||
//test if required and no value is set so we have to mark this item
|
||||
//we have to differ check and the other subtypes
|
||||
if ($info->subtype == 'c') {
|
||||
if (is_array($value)) {
|
||||
$values = $value;
|
||||
} else {
|
||||
$values = explode(FEEDBACK_MULTICHOICE_LINE_SEP, $value);
|
||||
}
|
||||
}
|
||||
$requiredmark = '';
|
||||
if ($item->required == 1) {
|
||||
$requiredmark = '<img class="req" title="'.get_string('requiredelement', 'form').'" alt="'.
|
||||
get_string('requiredelement', 'form').'" src="'.$OUTPUT->pix_url('req') .'" />';
|
||||
}
|
||||
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
if (strval($item->label) !== '') {
|
||||
echo '('. format_string($item->label).') ';
|
||||
}
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
echo '</div>';
|
||||
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
$index = 1;
|
||||
if ($info->subtype == 'c') {
|
||||
echo $OUTPUT->box_start('generalbox boxalign'.$align);
|
||||
foreach ($presentation as $pres) {
|
||||
foreach ($values as $val) {
|
||||
if ($val == $index) {
|
||||
echo '<div class="feedback_item_multianswer">';
|
||||
echo format_text($pres, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
echo '</div>';
|
||||
break;
|
||||
}
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
} else {
|
||||
foreach ($presentation as $pres) {
|
||||
if ($value == $index) {
|
||||
echo $OUTPUT->box_start('generalbox boxalign'.$align);
|
||||
echo format_text($pres, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
echo $OUTPUT->box_end();
|
||||
break;
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
public function create_value($value) {
|
||||
$value = array_unique(array_filter($value));
|
||||
return join(FEEDBACK_MULTICHOICE_LINE_SEP, $value);
|
||||
}
|
||||
|
||||
public function check_value($value, $item) {
|
||||
$info = $this->get_info($item);
|
||||
|
||||
if ($item->required != 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (empty($value) OR !is_array($value) OR !array_filter($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function create_value($data) {
|
||||
$vallist = $data;
|
||||
if (is_array($vallist)) {
|
||||
$vallist = array_unique(array_filter($vallist));
|
||||
}
|
||||
return trim($this->item_array_to_string($vallist));
|
||||
}
|
||||
|
||||
//compares the dbvalue with the dependvalue
|
||||
//dbvalue is the number of one selection
|
||||
//dependvalue is the presentation of one selection
|
||||
/**
|
||||
* Compares the dbvalue with the dependvalue
|
||||
*
|
||||
* @param stdClass $item
|
||||
* @param string $dbvalue is the value input by user in the format as it is stored in the db
|
||||
* @param string $dependvalue is the value that it needs to be compared against
|
||||
*/
|
||||
public function compare_value($item, $dbvalue, $dependvalue) {
|
||||
|
||||
if (is_array($dbvalue)) {
|
||||
@ -626,23 +405,6 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get_presentation($data) {
|
||||
$present = str_replace("\n", FEEDBACK_MULTICHOICE_LINE_SEP, trim($data->itemvalues));
|
||||
if (!isset($data->subtype)) {
|
||||
$subtype = 'r';
|
||||
} else {
|
||||
$subtype = substr($data->subtype, 0, 1);
|
||||
}
|
||||
if (isset($data->horizontal) AND $data->horizontal == 1 AND $subtype != 'd') {
|
||||
$present .= FEEDBACK_MULTICHOICE_ADJUST_SEP.'1';
|
||||
}
|
||||
return $subtype.FEEDBACK_MULTICHOICE_TYPE_SEP.$present;
|
||||
}
|
||||
|
||||
public function get_hasvalue() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function get_info($item) {
|
||||
$presentation = empty($item->presentation) ? '' : $item->presentation;
|
||||
|
||||
@ -671,163 +433,6 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
return $info;
|
||||
}
|
||||
|
||||
private function item_array_to_string($value) {
|
||||
if (!is_array($value)) {
|
||||
return $value;
|
||||
}
|
||||
if (empty($value)) {
|
||||
return '0';
|
||||
}
|
||||
$retval = '';
|
||||
$arrvals = array_values($value);
|
||||
$arrvals = clean_param_array($arrvals, PARAM_INT); //prevent sql-injection
|
||||
$retval = $arrvals[0];
|
||||
$sizeofarrvals = count($arrvals);
|
||||
for ($i = 1; $i < $sizeofarrvals; $i++) {
|
||||
$retval .= FEEDBACK_MULTICHOICE_LINE_SEP.$arrvals[$i];
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
private function print_item_radio($presentation, $item, $value, $info, $align) {
|
||||
$index = 1;
|
||||
$checked = '';
|
||||
|
||||
if (is_array($value)) {
|
||||
$values = $value;
|
||||
} else {
|
||||
$values = array($value);
|
||||
}
|
||||
|
||||
if ($info->horizontal) {
|
||||
$hv = 'h';
|
||||
} else {
|
||||
$hv = 'v';
|
||||
}
|
||||
|
||||
foreach ($presentation as $radio) {
|
||||
foreach ($values as $val) {
|
||||
if ($val == $index) {
|
||||
$checked = 'checked="checked"';
|
||||
break;
|
||||
} else {
|
||||
$checked = '';
|
||||
}
|
||||
}
|
||||
$inputname = $item->typ . '_' . $item->id;
|
||||
$inputid = $inputname.'_'.$index;
|
||||
?>
|
||||
<li class="feedback_item_radio_<?php echo $hv.'_'.$align;?>">
|
||||
<span class="feedback_item_radio_<?php echo $hv.'_'.$align;?>">
|
||||
<?php
|
||||
echo '<input type="radio" '.
|
||||
'name="'.$inputname.'[]" '.
|
||||
'id="'.$inputid.'" '.
|
||||
'value="'.$index.'" '.$checked.' />';
|
||||
?>
|
||||
</span>
|
||||
<span class="feedback_item_radiolabel_<?php echo $hv.'_'.$align;?>">
|
||||
<label for="<?php echo $inputid;?>">
|
||||
<?php echo format_text($radio, FORMAT_HTML, array('noclean' => true, 'para' => false));?>
|
||||
</label>
|
||||
</span>
|
||||
</li>
|
||||
<?php
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
|
||||
private function print_item_check($presentation, $item, $value, $info, $align) {
|
||||
|
||||
if (is_array($value)) {
|
||||
$values = $value;
|
||||
} else {
|
||||
$values = explode(FEEDBACK_MULTICHOICE_LINE_SEP, $value);
|
||||
}
|
||||
|
||||
if ($info->horizontal) {
|
||||
$hv = 'h';
|
||||
} else {
|
||||
$hv = 'v';
|
||||
}
|
||||
|
||||
$index = 1;
|
||||
$checked = '';
|
||||
$inputname = $item->typ. '_' . $item->id;
|
||||
echo '<input type="hidden" name="'.$inputname.'[]" value="0" />';
|
||||
foreach ($presentation as $check) {
|
||||
foreach ($values as $val) {
|
||||
if ($val == $index) {
|
||||
$checked = 'checked="checked"';
|
||||
break;
|
||||
} else {
|
||||
$checked = '';
|
||||
}
|
||||
}
|
||||
$inputid = $item->typ. '_' . $item->id.'_'.$index;
|
||||
?>
|
||||
<li class="feedback_item_check_<?php echo $hv.'_'.$align;?>">
|
||||
<span class="feedback_item_check_<?php echo $hv.'_'.$align;?>">
|
||||
<?php
|
||||
echo '<input type="checkbox" '.
|
||||
'name="'.$inputname.'[]" '.
|
||||
'id="'.$inputid.'" '.
|
||||
'value="'.$index.'" '.$checked.' />';
|
||||
?>
|
||||
</span>
|
||||
<span class="feedback_item_radiolabel_<?php echo $hv.'_'.$align;?>">
|
||||
<label for="<?php echo $inputid;?>">
|
||||
<?php echo format_text($check, FORMAT_HTML, array('noclean' => true, 'para' => false));?>
|
||||
</label>
|
||||
</span>
|
||||
</li>
|
||||
<?php
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
|
||||
private function print_item_dropdown($presentation, $item, $value, $info, $align) {
|
||||
if (is_array($value)) {
|
||||
$values = $value;
|
||||
} else {
|
||||
$values = array($value);
|
||||
}
|
||||
|
||||
if ($info->horizontal) {
|
||||
$hv = 'h';
|
||||
} else {
|
||||
$hv = 'v';
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="feedback_item_select_<?php echo $hv.'_'.$align;?>">
|
||||
<select id="<?php echo $item->typ .'_' . $item->id;?>" name="<?php echo $item->typ .'_' . $item->id;?>[]" size="1">
|
||||
<option value="0"> </option>
|
||||
<?php
|
||||
$index = 1;
|
||||
$selected = '';
|
||||
foreach ($presentation as $dropdown) {
|
||||
foreach ($values as $val) {
|
||||
if ($val == $index) {
|
||||
$selected = 'selected="selected"';
|
||||
break;
|
||||
} else {
|
||||
$selected = '';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<option value="<?php echo $index;?>" <?php echo $selected;?>>
|
||||
<?php echo format_text($dropdown, FORMAT_HTML, array('noclean' => true, 'para' => false));?>
|
||||
</option>
|
||||
<?php
|
||||
$index++;
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function set_ignoreempty($item, $ignoreempty=true) {
|
||||
$item->options = str_replace(FEEDBACK_MULTICHOICE_IGNOREEMPTY, '', $item->options);
|
||||
if ($ignoreempty) {
|
||||
@ -855,20 +460,4 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function can_switch_require() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function value_type() {
|
||||
return PARAM_INT;
|
||||
}
|
||||
|
||||
public function value_is_array() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function clean_input_value($value) {
|
||||
return clean_param_array($value, $this->value_type());
|
||||
}
|
||||
}
|
||||
|
@ -43,12 +43,6 @@ class feedback_multichoice_form extends feedback_item_form {
|
||||
array('size' => FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE,
|
||||
'maxlength' => 255));
|
||||
|
||||
$mform->addElement('select',
|
||||
'horizontal',
|
||||
get_string('adjustment', 'feedback').' ',
|
||||
array(0 => get_string('vertical', 'feedback'),
|
||||
1 => get_string('horizontal', 'feedback')));
|
||||
|
||||
$mform->addElement('select',
|
||||
'subtype',
|
||||
get_string('multichoicetype', 'feedback').' ',
|
||||
@ -56,15 +50,22 @@ class feedback_multichoice_form extends feedback_item_form {
|
||||
'c'=>get_string('check', 'feedback'),
|
||||
'd'=>get_string('dropdown', 'feedback')));
|
||||
|
||||
$mform->addElement('selectyesno',
|
||||
'ignoreempty',
|
||||
get_string('do_not_analyse_empty_submits', 'feedback'));
|
||||
$mform->addElement('select',
|
||||
'horizontal',
|
||||
get_string('adjustment', 'feedback').' ',
|
||||
array(0 => get_string('vertical', 'feedback'),
|
||||
1 => get_string('horizontal', 'feedback')));
|
||||
$mform->disabledIf('horizontal', 'subtype', 'eq', 'd');
|
||||
|
||||
$mform->addElement('selectyesno',
|
||||
'hidenoselect',
|
||||
get_string('hide_no_select_option', 'feedback'));
|
||||
$mform->disabledIf('hidenoselect', 'subtype', 'ne', 'r');
|
||||
|
||||
$mform->addElement('selectyesno',
|
||||
'ignoreempty',
|
||||
get_string('do_not_analyse_empty_submits', 'feedback'));
|
||||
|
||||
$mform->addElement('textarea', 'values', get_string('multichoice_values', 'feedback'),
|
||||
'wrap="virtual" rows="10" cols="65"');
|
||||
|
||||
@ -106,6 +107,9 @@ class feedback_multichoice_form extends feedback_item_form {
|
||||
if (!isset($item->hidenoselect)) {
|
||||
$item->hidenoselect = 1;
|
||||
}
|
||||
if (!isset($item->ignoreempty)) {
|
||||
$item->ignoreempty = 0;
|
||||
}
|
||||
|
||||
$item->presentation = $subtype.FEEDBACK_MULTICHOICE_TYPE_SEP.$presentation;
|
||||
return $item;
|
||||
|
@ -30,13 +30,6 @@ define('FEEDBACK_MULTICHOICERATED_HIDENOSELECT', 'h');
|
||||
|
||||
class feedback_item_multichoicerated extends feedback_item_base {
|
||||
protected $type = "multichoicerated";
|
||||
private $commonparams;
|
||||
private $item_form;
|
||||
private $item;
|
||||
|
||||
public function init() {
|
||||
|
||||
}
|
||||
|
||||
public function build_editform($item, $feedback, $cm) {
|
||||
global $DB, $CFG;
|
||||
@ -80,22 +73,6 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
$this->item_form = new feedback_multichoicerated_form('edit_item.php', $customdata);
|
||||
}
|
||||
|
||||
//this function only can used after the call of build_editform()
|
||||
public function show_editform() {
|
||||
$this->item_form->display();
|
||||
}
|
||||
|
||||
public function is_cancelled() {
|
||||
return $this->item_form->is_cancelled();
|
||||
}
|
||||
|
||||
public function get_data() {
|
||||
if ($this->item = $this->item_form->get_data()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function save_item() {
|
||||
global $DB;
|
||||
|
||||
@ -122,9 +99,15 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
}
|
||||
|
||||
|
||||
//gets an array with three values(typ, name, XXX)
|
||||
//XXX is an object with answertext, answercount and quotient
|
||||
public function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
/**
|
||||
* Helper function for collected data, both for analysis page and export to excel
|
||||
*
|
||||
* @param stdClass $item the db-object from feedback_item
|
||||
* @param int $groupid
|
||||
* @param int $courseid
|
||||
* @return array
|
||||
*/
|
||||
protected function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
$analysed_item = array();
|
||||
$analysed_item[] = $item->typ;
|
||||
$analysed_item[] = $item->name;
|
||||
@ -193,16 +176,6 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
|
||||
public function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
|
||||
global $OUTPUT;
|
||||
$sep_dec = get_string('separator_decimal', 'feedback');
|
||||
if (substr($sep_dec, 0, 2) == '[[') {
|
||||
$sep_dec = FEEDBACK_DECIMAL;
|
||||
}
|
||||
|
||||
$sep_thous = get_string('separator_thousand', 'feedback');
|
||||
if (substr($sep_thous, 0, 2) == '[[') {
|
||||
$sep_thous = FEEDBACK_THOUSAND;
|
||||
}
|
||||
|
||||
$analysed_item = $this->get_analysed($item, $groupid, $courseid);
|
||||
if ($analysed_item) {
|
||||
echo '<tr><th colspan="2" align="left">';
|
||||
@ -218,16 +191,20 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
foreach ($analysed_vals as $val) {
|
||||
$intvalue = $pixnr % 10;
|
||||
$pix = $OUTPUT->pix_url('multichoice/' . $intvalue, 'feedback');
|
||||
$pixspacer = $OUTPUT->pix_url('spacer');
|
||||
$pixnr++;
|
||||
$pixwidth = intval($val->quotient * FEEDBACK_MAX_PIX_LENGTH);
|
||||
$pixwidthspacer = FEEDBACK_MAX_PIX_LENGTH + 1 - $pixwidth;
|
||||
|
||||
$avg += $val->avg;
|
||||
$quotient = number_format(($val->quotient * 100), 2, $sep_dec, $sep_thous);
|
||||
$quotient = format_float($val->quotient * 100, 2);
|
||||
echo '<tr>';
|
||||
echo '<td align="left" valign="top">';
|
||||
echo '- '.trim($val->answertext).' ('.$val->value.'):</td>';
|
||||
echo '- ('.$val->value.') '.
|
||||
format_text(trim($val->answertext), FORMAT_HTML, array('noclean' => true, 'para' => false)).':</td>';
|
||||
echo '<td align="left" style="width: '.FEEDBACK_MAX_PIX_LENGTH.'">';
|
||||
echo '<img class="feedback_bar_image" alt="'.$intvalue.'" src="'.$pix.'" height="5" width="'.$pixwidth.'" />';
|
||||
echo '<img class="feedback_bar_image" alt="'.$intvalue.'" src="'.$pix.'" width="'.$pixwidth.'" />';
|
||||
echo '<img class="feedback_bar_image" alt="" src="'.$pixspacer.'" width="'.$pixwidthspacer.'" /> ';
|
||||
echo $val->answercount;
|
||||
if ($val->quotient > 0) {
|
||||
echo ' ('.$quotient.' %)';
|
||||
@ -236,7 +213,7 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
}
|
||||
echo '</td></tr>';
|
||||
}
|
||||
$avg = number_format(($avg), 2, $sep_dec, $sep_thous);
|
||||
$avg = format_float($avg, 2);
|
||||
echo '<tr><td align="left" colspan="2"><b>';
|
||||
echo get_string('average', 'feedback').': '.$avg.'</b>';
|
||||
echo '</td></tr>';
|
||||
@ -288,167 +265,70 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the edit-page of feedback
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @return void
|
||||
* Options for the multichoice element
|
||||
* @param stdClass $item
|
||||
* @return array
|
||||
*/
|
||||
public function print_item_preview($item) {
|
||||
global $OUTPUT, $DB;
|
||||
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
protected function get_options($item) {
|
||||
$info = $this->get_info($item);
|
||||
$strrequiredmark = '<img class="req" title="'.get_string('requiredelement', 'form').'" alt="'.
|
||||
get_string('requiredelement', 'form').'" src="'.$OUTPUT->pix_url('req') .'" />';
|
||||
$lines = explode(FEEDBACK_MULTICHOICERATED_LINE_SEP, $info->presentation);
|
||||
$options = array();
|
||||
foreach ($lines as $idx => $line) {
|
||||
list($weight, $optiontext) = explode(FEEDBACK_MULTICHOICERATED_VALUE_SEP, $line);
|
||||
$options[$idx + 1] = format_text("<span class=\"weight\">($weight) </span>".$optiontext,
|
||||
FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
}
|
||||
if ($info->subtype === 'r' && !$this->hidenoselect($item)) {
|
||||
$options = array(0 => get_string('not_selected', 'feedback')) + $options;
|
||||
}
|
||||
|
||||
$lines = explode (FEEDBACK_MULTICHOICERATED_LINE_SEP, $info->presentation);
|
||||
$requiredmark = ($item->required == 1) ? $strrequiredmark : '';
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
if ($info->subtype == 'd') {
|
||||
echo '<label for="'. $item->typ . '_' . $item->id .'">';
|
||||
}
|
||||
if (strval($item->label) !== '') {
|
||||
echo '('. format_string($item->label).') ';
|
||||
}
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
if ($item->dependitem) {
|
||||
if ($dependitem = $DB->get_record('feedback_item', array('id'=>$item->dependitem))) {
|
||||
echo ' <span class="feedback_depend">';
|
||||
echo '('.format_string($dependitem->label).'->'.$item->dependvalue.')';
|
||||
echo '</span>';
|
||||
}
|
||||
}
|
||||
if ($info->subtype == 'd') {
|
||||
echo '</label>';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
switch($info->subtype) {
|
||||
case 'r':
|
||||
$this->print_item_radio($item, false, $info, $align, true, $lines);
|
||||
break;
|
||||
case 'd':
|
||||
$this->print_item_dropdown($item, false, $info, $align, true, $lines);
|
||||
break;
|
||||
}
|
||||
echo '</div>';
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
* Adds an input element to the complete form
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @param string $value
|
||||
* @param bool $highlightrequire
|
||||
* @return void
|
||||
* @param stdClass $item
|
||||
* @param mod_feedback_complete_form $form
|
||||
*/
|
||||
public function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
global $OUTPUT;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
public function complete_form_element($item, $form) {
|
||||
$info = $this->get_info($item);
|
||||
$strrequiredmark = '<img class="req" title="'.get_string('requiredelement', 'form').'" alt="'.
|
||||
get_string('requiredelement', 'form').'" src="'.$OUTPUT->pix_url('req') .'" />';
|
||||
|
||||
$lines = explode (FEEDBACK_MULTICHOICERATED_LINE_SEP, $info->presentation);
|
||||
$requiredmark = ($item->required == 1) ? $strrequiredmark : '';
|
||||
|
||||
//print the question and label
|
||||
$name = $this->get_display_name($item);
|
||||
$class = 'multichoicerated-' . $info->subtype;
|
||||
$inputname = $item->typ . '_' . $item->id;
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
if ($info->subtype == 'd') {
|
||||
echo '<label for="'. $inputname .'">';
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
if ($highlightrequire AND $item->required AND intval($value) <= 0) {
|
||||
echo '<br class="error"><span id="id_error_'.$inputname.'" class="error"> '.get_string('err_required', 'form').
|
||||
'</span><br id="id_error_break_'.$inputname.'" class="error" >';
|
||||
}
|
||||
echo '</label>';
|
||||
$options = $this->get_options($item);
|
||||
if ($info->subtype === 'd' || $form->is_frozen()) {
|
||||
$el = $form->add_form_element($item,
|
||||
['select', $inputname, $name, array('' => '') + $options, array('class' => $class)]);
|
||||
} else {
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
if ($highlightrequire AND $item->required AND intval($value) <= 0) {
|
||||
echo '<br class="error"><span id="id_error_'.$inputname.'" class="error"> '.get_string('err_required', 'form').
|
||||
'</span><br id="id_error_break_'.$inputname.'" class="error" >';
|
||||
$objs = array();
|
||||
foreach ($options as $idx => $label) {
|
||||
$objs[] = ['radio', $inputname, '', $label, $idx];
|
||||
}
|
||||
$separator = $info->horizontal ? ' ' : '<br>';
|
||||
$class .= ' multichoicerated-' . ($info->horizontal ? 'horizontal' : 'vertical');
|
||||
$el = $form->add_form_group_element($item, 'group_'.$inputname, $name, $objs, $separator, $class);
|
||||
|
||||
// Set previously input values.
|
||||
$form->set_element_default($inputname, $form->get_item_value($item));
|
||||
|
||||
// Process "required" rule.
|
||||
if ($item->required) {
|
||||
$form->add_validation_rule(function($values, $files) use ($item) {
|
||||
$inputname = $item->typ . '_' . $item->id;
|
||||
return empty($values[$inputname]) ? array('group_' . $inputname => get_string('required')) : true;
|
||||
});
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
switch($info->subtype) {
|
||||
case 'r':
|
||||
$this->print_item_radio($item, $value, $info, $align, false, $lines);
|
||||
break;
|
||||
case 'd':
|
||||
$this->print_item_dropdown($item, $value, $info, $align, false, $lines);
|
||||
break;
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
* Compares the dbvalue with the dependvalue
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @param string $value
|
||||
* @return void
|
||||
* @param stdClass $item
|
||||
* @param string $dbvalue is the value input by user in the format as it is stored in the db
|
||||
* @param string $dependvalue is the value that it needs to be compared against
|
||||
*/
|
||||
public function print_item_show_value($item, $value = '') {
|
||||
global $OUTPUT;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$info = $this->get_info($item);
|
||||
|
||||
$lines = explode (FEEDBACK_MULTICHOICERATED_LINE_SEP, $info->presentation);
|
||||
$requiredmark = ($item->required == 1)?'<img class="req" title="'.get_string('requiredelement', 'form').'" alt="'.
|
||||
get_string('requiredelement', 'form').'" src="'.$OUTPUT->pix_url('req') .'" />':'';
|
||||
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
if (strval($item->label) !== '') {
|
||||
echo '('. format_string($item->label).') ';
|
||||
}
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
echo '</div>';
|
||||
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
$index = 1;
|
||||
foreach ($lines as $line) {
|
||||
if ($value == $index) {
|
||||
$item_value = explode(FEEDBACK_MULTICHOICERATED_VALUE_SEP, $line);
|
||||
echo $OUTPUT->box_start('generalbox boxalign'.$align);
|
||||
echo format_text($item_value[1], FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
echo $OUTPUT->box_end();
|
||||
break;
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
public function check_value($value, $item) {
|
||||
if ((!isset($value) OR $value == '' OR $value == 0) AND $item->required != 1) {
|
||||
return true;
|
||||
}
|
||||
if (intval($value) > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function create_value($data) {
|
||||
$data = trim($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
//compares the dbvalue with the dependvalue
|
||||
//dbvalue is the number of one selection
|
||||
//dependvalue is the presentation of one selection
|
||||
public function compare_value($item, $dbvalue, $dependvalue) {
|
||||
|
||||
if (is_array($dbvalue)) {
|
||||
@ -473,25 +353,6 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get_presentation($data) {
|
||||
$present = $this->prepare_presentation_values_save(trim($data->itemvalues),
|
||||
FEEDBACK_MULTICHOICERATED_VALUE_SEP2,
|
||||
FEEDBACK_MULTICHOICERATED_VALUE_SEP);
|
||||
if (!isset($data->subtype)) {
|
||||
$subtype = 'r';
|
||||
} else {
|
||||
$subtype = substr($data->subtype, 0, 1);
|
||||
}
|
||||
if (isset($data->horizontal) AND $data->horizontal == 1 AND $subtype != 'd') {
|
||||
$present .= FEEDBACK_MULTICHOICERATED_ADJUST_SEP.'1';
|
||||
}
|
||||
return $subtype.FEEDBACK_MULTICHOICERATED_TYPE_SEP.$present;
|
||||
}
|
||||
|
||||
public function get_hasvalue() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function get_info($item) {
|
||||
$presentation = empty($item->presentation) ? '' : $item->presentation;
|
||||
|
||||
@ -526,112 +387,6 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
return $info;
|
||||
}
|
||||
|
||||
private function print_item_radio($item, $value, $info, $align, $showrating, $lines) {
|
||||
$index = 1;
|
||||
$checked = '';
|
||||
|
||||
if ($info->horizontal) {
|
||||
$hv = 'h';
|
||||
} else {
|
||||
$hv = 'v';
|
||||
}
|
||||
echo '<fieldset>';
|
||||
echo '<ul>';
|
||||
if (!$this->hidenoselect($item)) {
|
||||
?>
|
||||
<li class="feedback_item_radio_<?php echo $hv.'_'.$align;?>">
|
||||
<span class="feedback_item_radio_<?php echo $hv.'_'.$align;?>">
|
||||
<?php
|
||||
echo '<input type="radio" '.
|
||||
'name="'.$item->typ.'_'.$item->id.'" '.
|
||||
'id="'.$item->typ.'_'.$item->id.'_xxx" '.
|
||||
'value="" checked="checked" />';
|
||||
?>
|
||||
</span>
|
||||
<span class="feedback_item_radiolabel_<?php echo $hv.'_'.$align;?>">
|
||||
<label for="<?php echo $item->typ . '_' . $item->id.'_xxx';?>">
|
||||
<?php print_string('not_selected', 'feedback');?>
|
||||
</label>
|
||||
</span>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
foreach ($lines as $line) {
|
||||
if ($value == $index) {
|
||||
$checked = 'checked="checked"';
|
||||
} else {
|
||||
$checked = '';
|
||||
}
|
||||
$radio_value = explode(FEEDBACK_MULTICHOICERATED_VALUE_SEP, $line);
|
||||
$inputname = $item->typ . '_' . $item->id;
|
||||
$inputid = $inputname.'_'.$index;
|
||||
?>
|
||||
<li class="feedback_item_radio_<?php echo $hv.'_'.$align;?>">
|
||||
<span class="feedback_item_radio_<?php echo $hv.'_'.$align;?>">
|
||||
<?php
|
||||
echo '<input type="radio" '.
|
||||
'name="'.$inputname.'" '.
|
||||
'id="'.$inputid.'" '.
|
||||
'value="'.$index.'" '.$checked.' />';
|
||||
?>
|
||||
</span>
|
||||
<span class="feedback_item_radiolabel_<?php echo $hv.'_'.$align;?>">
|
||||
<label for="<?php echo $inputid;?>">
|
||||
<?php
|
||||
if ($showrating) {
|
||||
$str_rating_value = '('.$radio_value[0].') '.$radio_value[1];
|
||||
echo format_text($str_rating_value, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
} else {
|
||||
echo format_text($radio_value[1], FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
}
|
||||
?>
|
||||
</label>
|
||||
</span>
|
||||
</li>
|
||||
<?php
|
||||
$index++;
|
||||
}
|
||||
echo '</ul>';
|
||||
echo '</fieldset>';
|
||||
}
|
||||
|
||||
private function print_item_dropdown($item, $value, $info, $align, $showrating, $lines) {
|
||||
if ($info->horizontal) {
|
||||
$hv = 'h';
|
||||
} else {
|
||||
$hv = 'v';
|
||||
}
|
||||
?>
|
||||
<div class="feedback_item_select_<?php echo $hv.'_'.$align;?>">
|
||||
<select id="<?php echo $item->typ.'_'.$item->id;?>" name="<?php echo $item->typ.'_'.$item->id;?>">
|
||||
<option value="0"> </option>
|
||||
<?php
|
||||
$index = 1;
|
||||
$checked = '';
|
||||
foreach ($lines as $line) {
|
||||
if ($value == $index) {
|
||||
$selected = 'selected="selected"';
|
||||
} else {
|
||||
$selected = '';
|
||||
}
|
||||
$dropdown_value = explode(FEEDBACK_MULTICHOICERATED_VALUE_SEP, $line);
|
||||
if ($showrating) {
|
||||
echo '<option value="'.$index.'" '.$selected.'>';
|
||||
echo format_text('(' . $dropdown_value[0] . ') ' . $dropdown_value[1], FORMAT_HTML, array('para' => false));
|
||||
echo '</option>';
|
||||
} else {
|
||||
echo '<option value="'.$index.'" '.$selected.'>';
|
||||
echo format_text($dropdown_value[1], FORMAT_HTML, array('para' => false));
|
||||
echo '</option>';
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function prepare_presentation_values($linesep1,
|
||||
$linesep2,
|
||||
$valuestring,
|
||||
@ -703,16 +458,4 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function can_switch_require() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function value_type() {
|
||||
return PARAM_INT;
|
||||
}
|
||||
|
||||
public function clean_input_value($value) {
|
||||
return clean_param($value, $this->value_type());
|
||||
}
|
||||
}
|
||||
|
@ -43,25 +43,28 @@ class feedback_multichoicerated_form extends feedback_item_form {
|
||||
array('size'=>FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE,
|
||||
'maxlength'=>255));
|
||||
|
||||
$mform->addElement('select',
|
||||
'horizontal',
|
||||
get_string('adjustment', 'feedback').' ',
|
||||
array(0 => get_string('vertical', 'feedback'),
|
||||
1 => get_string('horizontal', 'feedback')));
|
||||
|
||||
$mform->addElement('select',
|
||||
'subtype',
|
||||
get_string('multichoicetype', 'feedback').' ',
|
||||
array('r'=>get_string('radio', 'feedback'),
|
||||
'd'=>get_string('dropdown', 'feedback')));
|
||||
|
||||
$mform->addElement('selectyesno',
|
||||
'ignoreempty',
|
||||
get_string('do_not_analyse_empty_submits', 'feedback'));
|
||||
$mform->addElement('select',
|
||||
'horizontal',
|
||||
get_string('adjustment', 'feedback').' ',
|
||||
array(0 => get_string('vertical', 'feedback'),
|
||||
1 => get_string('horizontal', 'feedback')));
|
||||
$mform->disabledIf('horizontal', 'subtype', 'eq', 'd');
|
||||
|
||||
$mform->addElement('selectyesno',
|
||||
'hidenoselect',
|
||||
get_string('hide_no_select_option', 'feedback'));
|
||||
$mform->disabledIf('hidenoselect', 'subtype', 'eq', 'd');
|
||||
|
||||
$mform->addElement('selectyesno',
|
||||
'ignoreempty',
|
||||
get_string('do_not_analyse_empty_submits', 'feedback'));
|
||||
$mform->disabledIf('ignoreempty', 'required', 'eq', '1');
|
||||
|
||||
$this->values = $mform->addElement('textarea',
|
||||
'values',
|
||||
@ -109,6 +112,12 @@ class feedback_multichoicerated_form extends feedback_item_form {
|
||||
$presentation .= FEEDBACK_MULTICHOICERATED_ADJUST_SEP.'1';
|
||||
}
|
||||
$item->presentation = $subtype.FEEDBACK_MULTICHOICERATED_TYPE_SEP.$presentation;
|
||||
if (!isset($item->hidenoselect)) {
|
||||
$item->hidenoselect = 1;
|
||||
}
|
||||
if (!isset($item->ignoreempty)) {
|
||||
$item->ignoreempty = 0;
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,6 @@ require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_class.php');
|
||||
|
||||
class feedback_item_numeric extends feedback_item_base {
|
||||
protected $type = "numeric";
|
||||
private $commonparams;
|
||||
private $item_form;
|
||||
private $item;
|
||||
|
||||
public function init() {
|
||||
|
||||
}
|
||||
|
||||
public function build_editform($item, $feedback, $cm) {
|
||||
global $DB, $CFG;
|
||||
@ -80,22 +73,6 @@ class feedback_item_numeric extends feedback_item_base {
|
||||
$this->item_form = new feedback_numeric_form('edit_item.php', $customdata);
|
||||
}
|
||||
|
||||
//this function only can used after the call of build_editform()
|
||||
public function show_editform() {
|
||||
$this->item_form->display();
|
||||
}
|
||||
|
||||
public function is_cancelled() {
|
||||
return $this->item_form->is_cancelled();
|
||||
}
|
||||
|
||||
public function get_data() {
|
||||
if ($this->item = $this->item_form->get_data()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function save_item() {
|
||||
global $DB;
|
||||
|
||||
@ -118,9 +95,15 @@ class feedback_item_numeric extends feedback_item_base {
|
||||
return $DB->get_record('feedback_item', array('id'=>$item->id));
|
||||
}
|
||||
|
||||
|
||||
//liefert eine Struktur ->name, ->data = array(mit Antworten)
|
||||
public function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
/**
|
||||
* Helper function for collected data, both for analysis page and export to excel
|
||||
*
|
||||
* @param stdClass $item the db-object from feedback_item
|
||||
* @param int $groupid
|
||||
* @param int $courseid
|
||||
* @return stdClass
|
||||
*/
|
||||
protected function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
global $DB;
|
||||
|
||||
$analysed = new stdClass();
|
||||
@ -218,89 +201,6 @@ class feedback_item_numeric extends feedback_item_base {
|
||||
return $row_offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the edit-page of feedback
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @return void
|
||||
*/
|
||||
public function print_item_preview($item) {
|
||||
global $OUTPUT, $DB;
|
||||
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$strrequiredmark = '<img class="req" title="'.get_string('requiredelement', 'form').'" alt="'.
|
||||
get_string('requiredelement', 'form').'" src="'.$OUTPUT->pix_url('req') .'" />';
|
||||
|
||||
//get the range
|
||||
$range_from_to = explode('|', $item->presentation);
|
||||
|
||||
//get the min-value
|
||||
if (isset($range_from_to[0]) AND is_numeric($range_from_to[0])) {
|
||||
$range_from = floatval($range_from_to[0]);
|
||||
} else {
|
||||
$range_from = '-';
|
||||
}
|
||||
|
||||
//get the max-value
|
||||
if (isset($range_from_to[1]) AND is_numeric($range_from_to[1])) {
|
||||
$range_to = floatval($range_from_to[1]);
|
||||
} else {
|
||||
$range_to = '-';
|
||||
}
|
||||
|
||||
$requiredmark = ($item->required == 1) ? $strrequiredmark : '';
|
||||
//print the question and label
|
||||
$inputname = $item->typ . '_' . $item->id;
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
echo '<label for="'. $inputname .'">';
|
||||
if (strval($item->label) !== '') {
|
||||
echo '('. format_string($item->label).') ';
|
||||
}
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
if ($item->dependitem) {
|
||||
$params = array('id'=>$item->dependitem);
|
||||
if ($dependitem = $DB->get_record('feedback_item', $params)) {
|
||||
echo ' <span class="feedback_depend">';
|
||||
echo '('.format_string($dependitem->label).'->'.$item->dependvalue.')';
|
||||
echo '</span>';
|
||||
}
|
||||
}
|
||||
echo '<span class="feedback_item_numinfo">';
|
||||
switch(true) {
|
||||
case ($range_from === '-' AND is_numeric($range_to)):
|
||||
echo ' ('.get_string('maximal', 'feedback').
|
||||
': '.$this->format_float($range_to).')';
|
||||
break;
|
||||
case (is_numeric($range_from) AND $range_to === '-'):
|
||||
echo ' ('.get_string('minimal', 'feedback').
|
||||
': '.$this->format_float($range_from).')';
|
||||
break;
|
||||
case ($range_from === '-' AND $range_to === '-'):
|
||||
break;
|
||||
default:
|
||||
echo ' ('.$this->format_float($range_from).
|
||||
' - '.$this->format_float($range_to).')';
|
||||
break;
|
||||
}
|
||||
echo '</span>';
|
||||
echo '</label>';
|
||||
echo '</div>';
|
||||
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
echo '<span class="feedback_item_textfield">';
|
||||
echo '<input type="text" '.
|
||||
'id="'.$inputname.'" '.
|
||||
'name="'.$inputname.'" '.
|
||||
'size="10" '.
|
||||
'maxlength="10" '.
|
||||
'value="" />';
|
||||
|
||||
echo '</span>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the float nicely in the localized format
|
||||
*
|
||||
@ -318,194 +218,79 @@ class feedback_item_numeric extends feedback_item_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @param string $value
|
||||
* @param bool $highlightrequire
|
||||
* @return void
|
||||
* Returns human-readable boundaries (min - max)
|
||||
* @param stdClass $item
|
||||
* @return string
|
||||
*/
|
||||
public function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
global $OUTPUT;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$strrequiredmark = '<img class="req" title="'.get_string('requiredelement', 'form').'" alt="'.
|
||||
get_string('requiredelement', 'form').'" src="'.$OUTPUT->pix_url('req') .'" />';
|
||||
|
||||
//get the range
|
||||
$range_from_to = explode('|', $item->presentation);
|
||||
|
||||
//get the min-value
|
||||
if (isset($range_from_to[0]) AND is_numeric($range_from_to[0])) {
|
||||
$range_from = floatval($range_from_to[0]);
|
||||
} else {
|
||||
$range_from = '-';
|
||||
protected function get_boundaries_for_display($item) {
|
||||
list($rangefrom, $rangeto) = explode('|', $item->presentation);
|
||||
if (!isset($rangefrom) || !is_numeric($rangefrom)) {
|
||||
$rangefrom = null;
|
||||
}
|
||||
if (!isset($rangeto) || !is_numeric($rangeto)) {
|
||||
$rangeto = null;
|
||||
}
|
||||
|
||||
//get the max-value
|
||||
if (isset($range_from_to[1]) AND is_numeric($range_from_to[1])) {
|
||||
$range_to = floatval($range_from_to[1]);
|
||||
} else {
|
||||
$range_to = '-';
|
||||
if (is_null($rangefrom) && is_numeric($rangeto)) {
|
||||
return ' (' . get_string('maximal', 'feedback') .
|
||||
': ' . $this->format_float($rangeto) . ')';
|
||||
}
|
||||
|
||||
$requiredmark = ($item->required == 1) ? $strrequiredmark : '';
|
||||
|
||||
//print the question and label
|
||||
$inputname = $item->typ . '_' . $item->id;
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
echo '<label for="'. $inputname .'">';
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
echo '<span class="feedback_item_numinfo">';
|
||||
switch(true) {
|
||||
case ($range_from === '-' AND is_numeric($range_to)):
|
||||
echo ' ('.get_string('maximal', 'feedback').
|
||||
': '.$this->format_float($range_to).')';
|
||||
break;
|
||||
case (is_numeric($range_from) AND $range_to === '-'):
|
||||
echo ' ('.get_string('minimal', 'feedback').
|
||||
': '.$this->format_float($range_from).')';
|
||||
break;
|
||||
case ($range_from === '-' AND $range_to === '-'):
|
||||
break;
|
||||
default:
|
||||
echo ' ('.$this->format_float($range_from).
|
||||
' - '.$this->format_float($range_to).')';
|
||||
break;
|
||||
if (is_numeric($rangefrom) && is_null($rangeto)) {
|
||||
return ' (' . get_string('minimal', 'feedback') .
|
||||
': ' . $this->format_float($rangefrom) . ')';
|
||||
}
|
||||
echo '</span>';
|
||||
if ($highlightrequire AND (!$this->check_value($value, $item))) {
|
||||
echo '<br class="error"><span id="id_error_'.$inputname.'" class="error"> '.get_string('err_required', 'form').
|
||||
'</span><br id="id_error_break_'.$inputname.'" class="error" >';
|
||||
if (is_null($rangefrom) && is_null($rangeto)) {
|
||||
return '';
|
||||
}
|
||||
echo '</label>';
|
||||
echo '</div>';
|
||||
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
echo '<span class="feedback_item_textfield">';
|
||||
echo '<input type="text" '.
|
||||
'id="'.$inputname.'" '.
|
||||
'name="'.$item->typ.'_'.$item->id.'" '.
|
||||
'size="10" '.
|
||||
'maxlength="10" '.
|
||||
'value="'.$value.'" />';
|
||||
|
||||
echo '</span>';
|
||||
echo '</div>';
|
||||
return ' (' . $this->format_float($rangefrom) .
|
||||
' - ' . $this->format_float($rangeto) . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
* Returns the postfix to be appended to the display name that is based on other settings
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @param string $value
|
||||
* @return void
|
||||
* @param stdClass $item
|
||||
* @return string
|
||||
*/
|
||||
public function print_item_show_value($item, $value = '') {
|
||||
global $OUTPUT;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$strrequiredmark = '<img class="req" title="'.get_string('requiredelement', 'form').'" alt="'.
|
||||
get_string('requiredelement', 'form').'" src="'.$OUTPUT->pix_url('req') .'" />';
|
||||
|
||||
//get the range
|
||||
$range_from_to = explode('|', $item->presentation);
|
||||
//get the min-value
|
||||
if (isset($range_from_to[0]) AND is_numeric($range_from_to[0])) {
|
||||
$range_from = floatval($range_from_to[0]);
|
||||
} else {
|
||||
$range_from = '-';
|
||||
}
|
||||
//get the max-value
|
||||
if (isset($range_from_to[1]) AND is_numeric($range_from_to[1])) {
|
||||
$range_to = floatval($range_from_to[1]);
|
||||
} else {
|
||||
$range_to = '-';
|
||||
}
|
||||
$requiredmark = ($item->required == 1) ? $strrequiredmark : '';
|
||||
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
if (strval($item->label) !== '') {
|
||||
echo '('. format_string($item->label).') ';
|
||||
}
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
switch(true) {
|
||||
case ($range_from === '-' AND is_numeric($range_to)):
|
||||
echo ' ('.get_string('maximal', 'feedback').
|
||||
': '.$this->format_float($range_to).')';
|
||||
break;
|
||||
case (is_numeric($range_from) AND $range_to === '-'):
|
||||
echo ' ('.get_string('minimal', 'feedback').
|
||||
': '.$this->format_float($range_from).')';
|
||||
break;
|
||||
case ($range_from === '-' AND $range_to === '-'):
|
||||
break;
|
||||
default:
|
||||
echo ' ('.$this->format_float($range_from).
|
||||
' - '.$this->format_float($range_to).')';
|
||||
break;
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
echo $OUTPUT->box_start('generalbox boxalign'.$align);
|
||||
if (is_numeric($value)) {
|
||||
$str_num_value = $this->format_float($value);
|
||||
} else {
|
||||
$str_num_value = ' ';
|
||||
}
|
||||
echo $str_num_value;
|
||||
echo $OUTPUT->box_end();
|
||||
echo '</div>';
|
||||
public function get_display_name_postfix($item) {
|
||||
return html_writer::span($this->get_boundaries_for_display($item), 'boundaries');
|
||||
}
|
||||
|
||||
public function check_value($value, $item) {
|
||||
$value = unformat_float($value, true);
|
||||
//if the item is not required, so the check is true if no value is given
|
||||
if ((!isset($value) OR $value == '') AND $item->required != 1) {
|
||||
/**
|
||||
* Adds an input element to the complete form
|
||||
*
|
||||
* @param stdClass $item
|
||||
* @param mod_feedback_complete_form $form
|
||||
*/
|
||||
public function complete_form_element($item, $form) {
|
||||
$name = $this->get_display_name($item);
|
||||
$inputname = $item->typ . '_' . $item->id;
|
||||
$form->add_form_element($item,
|
||||
['text', $inputname, $name],
|
||||
true,
|
||||
false
|
||||
);
|
||||
$form->set_element_type($inputname, PARAM_NOTAGS);
|
||||
$tmpvalue = $this->format_float($form->get_item_value($item));
|
||||
$form->set_element_default($inputname, $tmpvalue);
|
||||
|
||||
// Add form validation rule to check for boundaries.
|
||||
$form->add_validation_rule(function($values, $files) use ($item) {
|
||||
$inputname = $item->typ . '_' . $item->id;
|
||||
list($rangefrom, $rangeto) = explode('|', $item->presentation);
|
||||
if (!isset($values[$inputname]) || trim($values[$inputname]) === '') {
|
||||
return $item->required ? array($inputname => get_string('required')) : true;
|
||||
}
|
||||
$value = unformat_float($values[$inputname], true);
|
||||
if ($value === false) {
|
||||
return array($inputname => get_string('invalidnum', 'error'));
|
||||
}
|
||||
if ((is_numeric($rangefrom) && $value < floatval($rangefrom)) ||
|
||||
(is_numeric($rangeto) && $value > floatval($rangeto))) {
|
||||
return array($inputname => get_string('numberoutofrange', 'feedback'));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (!is_numeric($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$range_from_to = explode('|', $item->presentation);
|
||||
if (isset($range_from_to[0]) AND is_numeric($range_from_to[0])) {
|
||||
$range_from = floatval($range_from_to[0]);
|
||||
} else {
|
||||
$range_from = '-';
|
||||
}
|
||||
if (isset($range_from_to[1]) AND is_numeric($range_from_to[1])) {
|
||||
$range_to = floatval($range_from_to[1]);
|
||||
} else {
|
||||
$range_to = '-';
|
||||
}
|
||||
|
||||
switch(true) {
|
||||
case ($range_from === '-' AND is_numeric($range_to)):
|
||||
if (floatval($value) <= $range_to) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case (is_numeric($range_from) AND $range_to === '-'):
|
||||
if (floatval($value) >= $range_from) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case ($range_from === '-' AND $range_to === '-'):
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
if (floatval($value) >= $range_from AND floatval($value) <= $range_to) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
public function create_value($data) {
|
||||
@ -518,64 +303,4 @@ class feedback_item_numeric extends feedback_item_base {
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
//compares the dbvalue with the dependvalue
|
||||
//dbvalue is the number put in by the user
|
||||
//dependvalue is the value that is compared
|
||||
public function compare_value($item, $dbvalue, $dependvalue) {
|
||||
if ($dbvalue == $dependvalue) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get_presentation($data) {
|
||||
$num1 = unformat_float($data->numericrangefrom, true);
|
||||
if (is_numeric($num1)) {
|
||||
$num1 = floatval($num1);
|
||||
} else {
|
||||
$num1 = '-';
|
||||
}
|
||||
|
||||
$num2 = unformat_float($data->numericrangeto, true);
|
||||
if (is_numeric($num2)) {
|
||||
$num2 = floatval($num2);
|
||||
} else {
|
||||
$num2 = '-';
|
||||
}
|
||||
|
||||
if ($num1 === '-' OR $num2 === '-') {
|
||||
return $num1 . '|'. $num2;
|
||||
}
|
||||
|
||||
if ($num1 > $num2) {
|
||||
return $num2 . '|'. $num1;
|
||||
} else {
|
||||
return $num1 . '|'. $num2;
|
||||
}
|
||||
}
|
||||
|
||||
public function get_hasvalue() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function can_switch_require() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function value_type() {
|
||||
return PARAM_TEXT;
|
||||
}
|
||||
|
||||
public function clean_input_value($value) {
|
||||
$value = unformat_float($value, true);
|
||||
if (!is_numeric($value)) {
|
||||
if ($value == '') {
|
||||
return null; //an empty string should be null
|
||||
} else {
|
||||
return clean_param($value, PARAM_TEXT); //we have to know the value if it is wrong
|
||||
}
|
||||
}
|
||||
return clean_param($value, PARAM_FLOAT);
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,6 @@ require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_class.php');
|
||||
|
||||
class feedback_item_textarea extends feedback_item_base {
|
||||
protected $type = "textarea";
|
||||
private $commonparams;
|
||||
private $item_form;
|
||||
private $item;
|
||||
|
||||
public function init() {
|
||||
|
||||
}
|
||||
|
||||
public function build_editform($item, $feedback, $cm) {
|
||||
global $DB, $CFG;
|
||||
@ -80,22 +73,6 @@ class feedback_item_textarea extends feedback_item_base {
|
||||
$this->item_form = new feedback_textarea_form('edit_item.php', $customdata);
|
||||
}
|
||||
|
||||
//this function only can used after the call of build_editform()
|
||||
public function show_editform() {
|
||||
$this->item_form->display();
|
||||
}
|
||||
|
||||
public function is_cancelled() {
|
||||
return $this->item_form->is_cancelled();
|
||||
}
|
||||
|
||||
public function get_data() {
|
||||
if ($this->item = $this->item_form->get_data()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function save_item() {
|
||||
global $DB;
|
||||
|
||||
@ -118,9 +95,15 @@ class feedback_item_textarea extends feedback_item_base {
|
||||
return $DB->get_record('feedback_item', array('id'=>$item->id));
|
||||
}
|
||||
|
||||
|
||||
//liefert eine Struktur ->name, ->data = array(mit Antworten)
|
||||
public function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
/**
|
||||
* Helper function for collected data for exporting to excel
|
||||
*
|
||||
* @param stdClass $item the db-object from feedback_item
|
||||
* @param int $groupid
|
||||
* @param int $courseid
|
||||
* @return stdClass
|
||||
*/
|
||||
protected function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
global $DB;
|
||||
|
||||
$analysed_val = new stdClass();
|
||||
@ -193,168 +176,21 @@ class feedback_item_textarea extends feedback_item_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the edit-page of feedback
|
||||
* Adds an input element to the complete form
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @return void
|
||||
* @param stdClass $item
|
||||
* @param mod_feedback_complete_form $form
|
||||
*/
|
||||
public function print_item_preview($item) {
|
||||
global $OUTPUT, $DB;
|
||||
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$strrequiredmark = '<img class="req" title="'.get_string('requiredelement', 'form').'" alt="'.
|
||||
get_string('requiredelement', 'form').'" src="'.$OUTPUT->pix_url('req') .'" />';
|
||||
|
||||
$presentation = explode ("|", $item->presentation);
|
||||
$requiredmark = ($item->required == 1) ? $strrequiredmark : '';
|
||||
//print the question and label
|
||||
public function complete_form_element($item, $form) {
|
||||
$name = $this->get_display_name($item);
|
||||
$inputname = $item->typ . '_' . $item->id;
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
echo '<label for="'. $inputname .'">';
|
||||
if (strval($item->label) !== '') {
|
||||
echo '('. format_string($item->label).') ';
|
||||
}
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
if ($item->dependitem) {
|
||||
if ($dependitem = $DB->get_record('feedback_item', array('id'=>$item->dependitem))) {
|
||||
echo ' <span class="feedback_depend">';
|
||||
echo '('.format_string($dependitem->label).'->'.$item->dependvalue.')';
|
||||
echo '</span>';
|
||||
}
|
||||
}
|
||||
echo '</label>';
|
||||
echo '</div>';
|
||||
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
echo '<span class="feedback_item_textarea">';
|
||||
echo '<textarea id="'.$inputname.'" '.
|
||||
'name="'.$inputname.'" '.
|
||||
'cols="'.$presentation[0].'" '.
|
||||
'rows="'.$presentation[1].'">';
|
||||
echo '</textarea>';
|
||||
echo '</span>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @param string $value
|
||||
* @param bool $highlightrequire
|
||||
* @return void
|
||||
*/
|
||||
public function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
global $OUTPUT;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$strrequiredmark = '<img class="req" title="'.get_string('requiredelement', 'form').'" alt="'.
|
||||
get_string('requiredelement', 'form').'" src="'.$OUTPUT->pix_url('req') .'" />';
|
||||
|
||||
$presentation = explode ("|", $item->presentation);
|
||||
$requiredmark = ($item->required == 1) ? $strrequiredmark :'';
|
||||
|
||||
//print the question and label
|
||||
$inputname = $item->typ . '_' . $item->id;
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
echo '<label for="'. $inputname .'">';
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
if ($highlightrequire AND $item->required AND strval($value) == '') {
|
||||
echo '<br class="error"><span id="id_error_'.$inputname.'" class="error"> '.get_string('err_required', 'form').
|
||||
'</span><br id="id_error_break_'.$inputname.'" class="error" >';
|
||||
}
|
||||
echo '</label>';
|
||||
echo '</div>';
|
||||
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
echo '<span class="feedback_item_textarea">';
|
||||
echo '<textarea id="'.$inputname.'" '.
|
||||
'name="'.$inputname.'" '.
|
||||
'cols="'.$presentation[0].'" '.
|
||||
'rows="'.$presentation[1].'">';
|
||||
echo $value;
|
||||
echo '</textarea>';
|
||||
echo '</span>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function print_item_show_value($item, $value = '') {
|
||||
global $OUTPUT;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$strrequiredmark = '<img class="req" title="'.get_string('requiredelement', 'form').'" alt="'.
|
||||
get_string('requiredelement', 'form').'" src="'.$OUTPUT->pix_url('req') .'" />';
|
||||
|
||||
$presentation = explode ("|", $item->presentation);
|
||||
$requiredmark = ($item->required == 1) ? $strrequiredmark : '';
|
||||
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
if (strval($item->label) !== '') {
|
||||
echo '('. format_string($item->label).') ';
|
||||
}
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
echo '</div>';
|
||||
|
||||
//print the presentation
|
||||
echo $OUTPUT->box_start('generalbox boxalign'.$align);
|
||||
echo $value ? str_replace("\n", '<br />', $value) : ' ';
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
public function check_value($value, $item) {
|
||||
//if the item is not required, so the check is true if no value is given
|
||||
if ((!isset($value) OR $value == '') AND $item->required != 1) {
|
||||
return true;
|
||||
}
|
||||
if ($value == "") {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
list($cols, $rows) = explode ("|", $item->presentation);
|
||||
$form->add_form_element($item,
|
||||
['textarea', $inputname, $name, array('rows' => $rows, 'cols' => $cols)]);
|
||||
$form->set_element_type($inputname, PARAM_NOTAGS);
|
||||
}
|
||||
|
||||
public function create_value($data) {
|
||||
$data = s($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
//compares the dbvalue with the dependvalue
|
||||
//dbvalue is the value put in by the user
|
||||
//dependvalue is the value that is compared
|
||||
public function compare_value($item, $dbvalue, $dependvalue) {
|
||||
if ($dbvalue == $dependvalue) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get_presentation($data) {
|
||||
return $data->itemwidth.'|'.$data->itemheight;
|
||||
}
|
||||
|
||||
public function get_hasvalue() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function can_switch_require() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function value_type() {
|
||||
return PARAM_RAW;
|
||||
}
|
||||
|
||||
public function clean_input_value($value) {
|
||||
return s($value);
|
||||
return s($data);
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,6 @@ require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_class.php');
|
||||
|
||||
class feedback_item_textfield extends feedback_item_base {
|
||||
protected $type = "textfield";
|
||||
private $commonparams;
|
||||
private $item_form;
|
||||
private $item;
|
||||
|
||||
public function init() {
|
||||
|
||||
}
|
||||
|
||||
public function build_editform($item, $feedback, $cm) {
|
||||
global $DB, $CFG;
|
||||
@ -77,22 +70,6 @@ class feedback_item_textfield extends feedback_item_base {
|
||||
$this->item_form = new feedback_textfield_form('edit_item.php', $customdata);
|
||||
}
|
||||
|
||||
//this function only can used after the call of build_editform()
|
||||
public function show_editform() {
|
||||
$this->item_form->display();
|
||||
}
|
||||
|
||||
public function is_cancelled() {
|
||||
return $this->item_form->is_cancelled();
|
||||
}
|
||||
|
||||
public function get_data() {
|
||||
if ($this->item = $this->item_form->get_data()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function save_item() {
|
||||
global $DB;
|
||||
|
||||
@ -116,9 +93,15 @@ class feedback_item_textfield extends feedback_item_base {
|
||||
}
|
||||
|
||||
|
||||
//liefert eine Struktur ->name, ->data = array(mit Antworten)
|
||||
public function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
global $DB;
|
||||
/**
|
||||
* Helper function for collected data for exporting to excel
|
||||
*
|
||||
* @param stdClass $item the db-object from feedback_item
|
||||
* @param int $groupid
|
||||
* @param int $courseid
|
||||
* @return stdClass
|
||||
*/
|
||||
protected function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
|
||||
$analysed_val = new stdClass();
|
||||
$analysed_val->data = null;
|
||||
@ -151,7 +134,7 @@ class feedback_item_textfield extends feedback_item_base {
|
||||
if (strval($item->label) !== '') {
|
||||
echo '('. format_string($item->label).') ';
|
||||
}
|
||||
echo format_text($item->name, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
echo $this->get_display_name($item);
|
||||
echo '</th></tr>';
|
||||
foreach ($values as $value) {
|
||||
echo '<tr><td colspan="2" valign="top" align="left">';
|
||||
@ -184,166 +167,28 @@ class feedback_item_textfield extends feedback_item_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the edit-page of feedback
|
||||
* Adds an input element to the complete form
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @return void
|
||||
* @param stdClass $item
|
||||
* @param mod_feedback_complete_form $form
|
||||
*/
|
||||
public function print_item_preview($item) {
|
||||
global $OUTPUT, $DB;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$strrequiredmark = '<img class="req" title="'.get_string('requiredelement', 'form').'" alt="'.
|
||||
get_string('requiredelement', 'form').'" src="'.$OUTPUT->pix_url('req') .'" />';
|
||||
|
||||
$presentation = explode ("|", $item->presentation);
|
||||
$requiredmark = ($item->required == 1) ? $strrequiredmark : '';
|
||||
//print the question and label
|
||||
public function complete_form_element($item, $form) {
|
||||
$name = $this->get_display_name($item);
|
||||
$inputname = $item->typ . '_' . $item->id;
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
echo '<label for="'. $inputname .'">';
|
||||
if (strval($item->label) !== '') {
|
||||
echo '('. format_string($item->label).') ';
|
||||
}
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
if ($item->dependitem) {
|
||||
if ($dependitem = $DB->get_record('feedback_item', array('id'=>$item->dependitem))) {
|
||||
echo ' <span class="feedback_depend">';
|
||||
echo '('.format_string($dependitem->label).'->'.$item->dependvalue.')';
|
||||
echo '</span>';
|
||||
}
|
||||
}
|
||||
echo '</label>';
|
||||
echo '</div>';
|
||||
list($size, $maxlength) = explode ("|", $item->presentation);
|
||||
$form->add_form_element($item,
|
||||
['text', $inputname, $name, ['maxlength' => $maxlength, 'size' => $size]]);
|
||||
$form->set_element_type($inputname, PARAM_NOTAGS);
|
||||
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
echo '<span class="feedback_item_textfield">';
|
||||
echo '<input type="text" '.
|
||||
'id="'.$inputname.'" '.
|
||||
'name="'.$inputname.'" '.
|
||||
'size="'.$presentation[0].'" '.
|
||||
'maxlength="'.$presentation[1].'" '.
|
||||
'value="" />';
|
||||
echo '</span>';
|
||||
echo '</div>';
|
||||
$form->add_element_rule($inputname, get_string('maximumchars', '', $maxlength), 'maxlength', $maxlength, 'client');
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @param string $value
|
||||
* @param bool $highlightrequire
|
||||
* @return void
|
||||
* Converts the value from complete_form data to the string value that is stored in the db.
|
||||
* @param mixed $value element from mod_feedback_complete_form::get_data() with the name $item->typ.'_'.$item->id
|
||||
* @return string
|
||||
*/
|
||||
public function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
global $OUTPUT;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$strrequiredmark = '<img class="req" title="'.get_string('requiredelement', 'form').'" alt="'.
|
||||
get_string('requiredelement', 'form').'" src="'.$OUTPUT->pix_url('req') .'" />';
|
||||
|
||||
$presentation = explode ("|", $item->presentation);
|
||||
$requiredmark = ($item->required == 1) ? $strrequiredmark : '';
|
||||
|
||||
//print the question and label
|
||||
$inputname = $item->typ . '_' . $item->id;
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
echo '<label for="'. $inputname .'">';
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
if ($highlightrequire AND $item->required AND strval($value) == '') {
|
||||
echo '<br class="error"><span id="id_error_'.$inputname.'" class="error"> '.get_string('err_required', 'form').
|
||||
'</span><br id="id_error_break_'.$inputname.'" class="error" >';
|
||||
}
|
||||
echo '</label>';
|
||||
echo '</div>';
|
||||
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
echo '<span class="feedback_item_textfield">';
|
||||
echo '<input type="text" '.
|
||||
'id="'.$inputname.'" '.
|
||||
'name="'.$inputname.'" '.
|
||||
'size="'.$presentation[0].'" '.
|
||||
'maxlength="'.$presentation[1].'" '.
|
||||
'value="'.$value.'" />';
|
||||
echo '</span>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
*
|
||||
* @global object
|
||||
* @param object $item
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function print_item_show_value($item, $value = '') {
|
||||
global $OUTPUT;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$strrequiredmark = '<img class="req" title="'.get_string('requiredelement', 'form').'" alt="'.
|
||||
get_string('requiredelement', 'form').'" src="'.$OUTPUT->pix_url('req') .'" />';
|
||||
|
||||
$presentation = explode ("|", $item->presentation);
|
||||
$requiredmark = ($item->required == 1) ? $strrequiredmark : '';
|
||||
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
if (strval($item->label) !== '') {
|
||||
echo '('. format_string($item->label).') ';
|
||||
}
|
||||
echo format_text($item->name . $requiredmark, FORMAT_HTML, array('noclean' => true, 'para' => false));
|
||||
echo '</div>';
|
||||
echo $OUTPUT->box_start('generalbox boxalign'.$align);
|
||||
echo $value ? $value : ' ';
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
public function check_value($value, $item) {
|
||||
//if the item is not required, so the check is true if no value is given
|
||||
if ((!isset($value) OR $value == '') AND $item->required != 1) {
|
||||
return true;
|
||||
}
|
||||
if ($value == "") {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function create_value($data) {
|
||||
$data = s($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
//compares the dbvalue with the dependvalue
|
||||
//dbvalue is the value put in by the user
|
||||
//dependvalue is the value that is compared
|
||||
public function compare_value($item, $dbvalue, $dependvalue) {
|
||||
if ($dbvalue == $dependvalue) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get_presentation($data) {
|
||||
return $data->itemsize . '|'. $data->itemmaxlength;
|
||||
}
|
||||
|
||||
public function get_hasvalue() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function can_switch_require() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function value_type() {
|
||||
return PARAM_RAW;
|
||||
}
|
||||
|
||||
public function clean_input_value($value) {
|
||||
public function create_value($value) {
|
||||
return s($value);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user