.
defined('MOODLE_INTERNAL') OR die('not allowed');
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;
$editurl = new moodle_url('/mod/feedback/edit.php', array('id'=>$cm->id));
//ther are no settings for recaptcha
if (isset($item->id) AND $item->id > 0) {
notice(get_string('there_are_no_settings_for_recaptcha', 'feedback'), $editurl->out());
exit;
}
//only one recaptcha can be in a feedback
$params = array('feedback' => $feedback->id, 'typ' => $this->type);
if ($DB->record_exists('feedback_item', $params)) {
notice(get_string('only_one_captcha_allowed', 'feedback'), $editurl->out());
exit;
}
$this->item = $item;
$this->feedback = $feedback;
$this->item_form = true; //dummy
$lastposition = $DB->count_records('feedback_item', array('feedback'=>$feedback->id));
$this->item->feedback = $feedback->id;
$this->item->template = 0;
$this->item->name = get_string('captcha', 'feedback');
$this->item->label = get_string('captcha', 'feedback');
$this->item->presentation = '';
$this->item->typ = $this->type;
$this->item->hasvalue = $this->get_hasvalue();
$this->item->position = $lastposition + 1;
$this->item->required = 1;
$this->item->dependitem = 0;
$this->item->dependvalue = '';
$this->item->options = '';
}
public function show_editform() {
}
public function is_cancelled() {
return false;
}
public function get_data() {
return true;
}
public function save_item() {
global $DB;
if (!$this->item) {
return false;
}
if (empty($this->item->id)) {
$this->item->id = $DB->insert_record('feedback_item', $this->item);
} else {
$DB->update_record('feedback_item', $this->item);
}
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 '';
}
public function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
return $itemnr;
}
public function excelprint_item(&$worksheet, $row_offset,
$xls_formats, $item,
$groupid, $courseid = false) {
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 $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 = '';
//print the question and label
echo '