captcha now uses the recaptcha-plugin and
some code cleanups
This commit is contained in:
@@ -127,11 +127,10 @@ if($check_anonymously) {
|
|||||||
foreach($items as $item) {
|
foreach($items as $item) {
|
||||||
if($item->hasvalue == 0) continue;
|
if($item->hasvalue == 0) continue;
|
||||||
echo '<table width="100%" class="generalbox">';
|
echo '<table width="100%" class="generalbox">';
|
||||||
|
|
||||||
//get the class of item-typ
|
//get the class of item-typ
|
||||||
$itemclass = 'feedback_item_'.$item->typ;
|
$itemobj = feedback_get_item_class($item->typ);
|
||||||
//get the instance of the item-class
|
|
||||||
require_once($CFG->dirroot.'/mod/feedback/item/'.$item->typ.'/lib.php');
|
|
||||||
$itemobj = new $itemclass();
|
|
||||||
$itemnr++;
|
$itemnr++;
|
||||||
if($feedback->autonumbering) {
|
if($feedback->autonumbering) {
|
||||||
$printnr = $itemnr.'.';
|
$printnr = $itemnr.'.';
|
||||||
|
|||||||
@@ -168,10 +168,7 @@ if ($courseitemfilter > 0) {
|
|||||||
if($item->hasvalue == 0) continue;
|
if($item->hasvalue == 0) continue;
|
||||||
echo '<table width="100%" class="generalbox">';
|
echo '<table width="100%" class="generalbox">';
|
||||||
//get the class from item-typ
|
//get the class from item-typ
|
||||||
$itemclass = 'feedback_item_'.$item->typ;
|
$itemobj = feedback_get_item_class($item->typ);
|
||||||
//get the instance of the item-class
|
|
||||||
require_once($CFG->dirroot.'/mod/feedback/item/'.$item->typ.'/lib.php');
|
|
||||||
$itemobj = new $itemclass();
|
|
||||||
$itemnr++;
|
$itemnr++;
|
||||||
if($feedback->autonumbering) {
|
if($feedback->autonumbering) {
|
||||||
$printnr = $itemnr.'.';
|
$printnr = $itemnr.'.';
|
||||||
|
|||||||
@@ -185,9 +185,7 @@ if (empty($items)) {
|
|||||||
}
|
}
|
||||||
foreach($items as $item) {
|
foreach($items as $item) {
|
||||||
//get the class of item-typ
|
//get the class of item-typ
|
||||||
$itemclass = 'feedback_item_'.$item->typ;
|
$itemobj = feedback_get_item_class($item->typ);
|
||||||
//get the instance of the item-class
|
|
||||||
$itemobj = new $itemclass();
|
|
||||||
$rowOffset1 = $itemobj->excelprint_item($worksheet1, $rowOffset1, $xlsFormats, $item, $mygroupid, $coursefilter);
|
$rowOffset1 = $itemobj->excelprint_item($worksheet1, $rowOffset1, $xlsFormats, $item, $mygroupid, $coursefilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,8 +293,7 @@ function feedback_excelprint_detailed_items(&$worksheet, $xlsFormats, $completed
|
|||||||
foreach($items as $item) {
|
foreach($items as $item) {
|
||||||
$value = $DB->get_record('feedback_value', array('item'=>$item->id, 'completed'=>$completed->id));
|
$value = $DB->get_record('feedback_value', array('item'=>$item->id, 'completed'=>$completed->id));
|
||||||
|
|
||||||
$itemclass = 'feedback_item_'.$item->typ;
|
$itemobj = feedback_get_item_class($item->typ);
|
||||||
$itemobj = new $itemclass();
|
|
||||||
$printval = $itemobj->get_printval($item, $value);
|
$printval = $itemobj->get_printval($item, $value);
|
||||||
|
|
||||||
// $worksheet->setFormat('<l><vo>');
|
// $worksheet->setFormat('<l><vo>');
|
||||||
|
|||||||
@@ -84,8 +84,7 @@ if($id and $item = $DB->get_record('feedback_item', array('id'=>$id))) {
|
|||||||
|
|
||||||
require_once($CFG->dirroot.'/mod/feedback/item/'.$typ.'/lib.php');
|
require_once($CFG->dirroot.'/mod/feedback/item/'.$typ.'/lib.php');
|
||||||
|
|
||||||
$itemclass = 'feedback_item_'.$typ;
|
$itemobj = feedback_get_item_class($typ);
|
||||||
$itemobj = new $itemclass();
|
|
||||||
|
|
||||||
$itemobj->build_editform($item, $feedback, $cm);
|
$itemobj->build_editform($item, $feedback, $cm);
|
||||||
|
|
||||||
@@ -124,48 +123,6 @@ if(isset($error)) {
|
|||||||
feedback_print_errors();
|
feedback_print_errors();
|
||||||
$itemobj->show_editform();
|
$itemobj->show_editform();
|
||||||
|
|
||||||
/*
|
|
||||||
echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter');
|
|
||||||
echo '<form action="edit_item.php" method="post">';
|
|
||||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
|
||||||
|
|
||||||
//this div makes the buttons stand side by side
|
|
||||||
echo '<div>';
|
|
||||||
$itemclass = 'feedback_item_'.$typ;
|
|
||||||
$itemobj = new $itemclass();
|
|
||||||
$itemobj->show_edit($item, $usehtmleditor);
|
|
||||||
echo '</div>';
|
|
||||||
echo '<input type="hidden" name="id" value="'.$id.'" />';
|
|
||||||
echo '<input type="hidden" name="itemid" value="'.(isset($item->id)?$item->id:'').'" />';
|
|
||||||
echo '<input type="hidden" name="typ" value="'.$typ.'" />';
|
|
||||||
echo '<input type="hidden" name="feedbackid" value="'.$feedback->id.'" />';
|
|
||||||
|
|
||||||
//choose the position
|
|
||||||
$lastposition = $DB->count_records('feedback_item', array('feedback'=>$feedback->id));
|
|
||||||
echo get_string('position', 'feedback').' ';
|
|
||||||
echo '<select name="position">';
|
|
||||||
//Dropdown-Items for choosing the position
|
|
||||||
if($position == -1){
|
|
||||||
feedback_print_numeric_option_list(1, $lastposition + 1, $lastposition + 1);
|
|
||||||
}else {
|
|
||||||
feedback_print_numeric_option_list(1, $lastposition, $item->position);
|
|
||||||
}
|
|
||||||
echo '</select><hr />';
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
if(!empty($item->id)){
|
|
||||||
echo '<input type="hidden" id="updateitem" name="updateitem" value="1" />';
|
|
||||||
echo '<input type="submit" value ="'.get_string('update_item', 'feedback').'" />';
|
|
||||||
}else{
|
|
||||||
echo '<input type="hidden" id="saveitem" name="saveitem" value="1" />';
|
|
||||||
echo '<input type="submit" value="'.get_string('save_item', 'feedback').'" />';
|
|
||||||
}
|
|
||||||
echo '<input type="submit" name="cancel" value="'.get_string('cancel').'" />';
|
|
||||||
echo '</form>';
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
*/
|
|
||||||
// echo $OUTPUT->box_end();
|
// echo $OUTPUT->box_end();
|
||||||
|
|
||||||
if ($typ!='label') {
|
if ($typ!='label') {
|
||||||
|
|||||||
+114
-129
@@ -5,74 +5,73 @@ require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_class.php');
|
|||||||
class feedback_item_captcha extends feedback_item_base {
|
class feedback_item_captcha extends feedback_item_base {
|
||||||
var $type = "captcha";
|
var $type = "captcha";
|
||||||
var $commonparams;
|
var $commonparams;
|
||||||
var $item_form;
|
var $item_form = false;
|
||||||
var $item;
|
var $item = false;
|
||||||
|
var $feedback = false;
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function build_editform($item, $feedback, $cm) {
|
function build_editform($item, $feedback, $cm) {
|
||||||
global $DB, $CFG;
|
global $DB;
|
||||||
require_once('captcha_form.php');
|
|
||||||
|
|
||||||
//get the lastposition number of the feedback_items
|
|
||||||
$position = $item->position;
|
|
||||||
$lastposition = $DB->count_records('feedback_item', array('feedback'=>$feedback->id));
|
|
||||||
if($position == -1){
|
|
||||||
$i_formselect_last = $lastposition + 1;
|
|
||||||
$i_formselect_value = $lastposition + 1;
|
|
||||||
$item->position = $lastposition + 1;
|
|
||||||
}else {
|
|
||||||
$i_formselect_last = $lastposition;
|
|
||||||
$i_formselect_value = $item->position;
|
|
||||||
}
|
|
||||||
//the elements for position dropdownlist
|
|
||||||
$positionlist = array_slice(range(0,$i_formselect_last),1,$i_formselect_last,true);
|
|
||||||
|
|
||||||
$item->presentation = empty($item->presentation) ? 3 : $item->presentation;
|
$editurl = new moodle_url('/mod/feedback/edit.php', array('id'=>$cm->id));
|
||||||
$item->required = 1;
|
|
||||||
|
|
||||||
//all items for dependitem
|
//ther are no settings for recaptcha
|
||||||
$feedbackitems = feedback_get_depend_candidates_for_item($feedback, $item);
|
if(isset($item->id) AND $item->id > 0) {
|
||||||
$commonparams = array('cmid'=>$cm->id,
|
notice(get_string('there_are_no_settings_for_recaptcha', 'feedback'), $editurl->out());
|
||||||
'id'=>isset($item->id) ? $item->id : NULL,
|
exit;
|
||||||
'typ'=>$item->typ,
|
}
|
||||||
'items'=>$feedbackitems,
|
|
||||||
'feedback'=>$feedback->id);
|
//only one recaptcha can be in a feedback
|
||||||
|
if($DB->record_exists('feedback_item', array('feedback'=>$feedback->id, 'typ'=>$this->type))) {
|
||||||
|
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));
|
||||||
|
|
||||||
//build the form
|
$this->item->feedback = $feedback->id;
|
||||||
$this->item_form = new feedback_captcha_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position));
|
$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 = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
//this function only can used after the call of build_editform()
|
|
||||||
function show_editform() {
|
function show_editform() {
|
||||||
$this->item_form->display();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_cancelled() {
|
function is_cancelled() {
|
||||||
return $this->item_form->is_cancelled();
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_data() {
|
function get_data() {
|
||||||
if($this->item = $this->item_form->get_data()) {
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function save_item() {
|
function save_item() {
|
||||||
global $DB;
|
global $DB;
|
||||||
|
|
||||||
if(!$item = $this->item_form->get_data()) {
|
if(!$this->item) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$item->hasvalue = $this->get_hasvalue();
|
|
||||||
if(!$item->id) {
|
if(!$item->id) {
|
||||||
$item->id = $DB->insert_record('feedback_item', $item);
|
$item->id = $DB->insert_record('feedback_item', $this->item);
|
||||||
}else {
|
}else {
|
||||||
$DB->update_record('feedback_item', $item);
|
$DB->update_record('feedback_item', $this->item);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $DB->get_record('feedback_item', array('id'=>$item->id));
|
return $DB->get_record('feedback_item', array('id'=>$item->id));
|
||||||
@@ -91,7 +90,7 @@ class feedback_item_captcha extends feedback_item_base {
|
|||||||
return $itemnr;
|
return $itemnr;
|
||||||
}
|
}
|
||||||
|
|
||||||
function excelprint_item(&$worksheet, $rowOffset, $item, $groupid, $courseid = false) {
|
function excelprint_item(&$worksheet, $rowOffset, $xlsFormats, $item, $groupid, $courseid = false) {
|
||||||
return $rowOffset;
|
return $rowOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,13 +102,10 @@ class feedback_item_captcha extends feedback_item_base {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function print_item_preview($item) {
|
function print_item_preview($item) {
|
||||||
global $SESSION, $CFG, $DB, $OUTPUT;
|
global $DB;
|
||||||
|
|
||||||
$align = right_to_left() ? 'right' : 'left';
|
$align = right_to_left() ? 'right' : 'left';
|
||||||
|
|
||||||
$presentation = $item->presentation;
|
|
||||||
$SESSION->feedback->item->captcha->charcount = $presentation;
|
|
||||||
|
|
||||||
$cmid = 0;
|
$cmid = 0;
|
||||||
$feedbackid = $item->feedback;
|
$feedbackid = $item->feedback;
|
||||||
if($feedbackid > 0) {
|
if($feedbackid > 0) {
|
||||||
@@ -119,36 +115,14 @@ class feedback_item_captcha extends feedback_item_base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($SESSION->feedback->item->captcha->checked)) {
|
$requiredmark = '<span class="feedback_required_mark">*</span>';
|
||||||
$checked = $SESSION->feedback->item->captcha->checked == true;
|
|
||||||
unset($SESSION->feedback->item->captcha->checked);
|
|
||||||
}else {
|
|
||||||
$checked = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
|
||||||
|
|
||||||
//print the question and label
|
//print the question and label
|
||||||
echo '<div class="feedback_item_label_'.$align.'">';
|
echo '<div class="feedback_item_label_'.$align.'">';
|
||||||
echo '('.$item->label.') ';
|
echo '('.$item->label.') ';
|
||||||
echo format_text($item->name.$requiredmark, true, false, false);
|
echo format_text($item->name.$requiredmark, true, false, false);
|
||||||
if($item->dependitem) {
|
|
||||||
if($dependitem = $DB->get_record('feedback_item', array('id'=>$item->dependitem))) {
|
|
||||||
echo ' <span class="feedback_depend">('.$dependitem->label.'->'.$item->dependvalue.')</span>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|
||||||
//print the presentation
|
|
||||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
|
||||||
$imglink = new moodle_url('/mod/feedback/item/captcha/print_captcha.php', array('id'=>$cmid));
|
|
||||||
echo '<div class="feedback_item_captcha_img_'.$align.'">';
|
|
||||||
echo '<img alt="'.$this->type.'" src="'.$imglink->out().'" />';
|
|
||||||
echo '</div>';
|
|
||||||
echo '<div class="feedback_item_captcha_text_'.$align.'">';
|
|
||||||
echo '<input type="text" name="'.$item->typ.'_'.$item->id.'" size="'.$presentation.'" maxlength="'.$presentation.'" value="" />';
|
|
||||||
echo '</div>';
|
|
||||||
echo '</div>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -161,13 +135,11 @@ class feedback_item_captcha extends feedback_item_base {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function print_item_complete($item, $value = '', $highlightrequire = false) {
|
function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||||
global $SESSION, $CFG, $DB, $OUTPUT;
|
global $SESSION, $CFG, $DB, $USER;
|
||||||
|
require_once($CFG->libdir.'/recaptchalib.php');
|
||||||
|
|
||||||
$align = right_to_left() ? 'right' : 'left';
|
$align = right_to_left() ? 'right' : 'left';
|
||||||
|
|
||||||
$presentation = $item->presentation;
|
|
||||||
$SESSION->feedback->item->captcha->charcount = $presentation;
|
|
||||||
|
|
||||||
$cmid = 0;
|
$cmid = 0;
|
||||||
$feedbackid = $item->feedback;
|
$feedbackid = $item->feedback;
|
||||||
if($feedbackid > 0) {
|
if($feedbackid > 0) {
|
||||||
@@ -177,42 +149,57 @@ class feedback_item_captcha extends feedback_item_base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($SESSION->feedback->item->captcha->checked)) {
|
|
||||||
$checked = $SESSION->feedback->item->captcha->checked == true;
|
|
||||||
unset($SESSION->feedback->item->captcha->checked);
|
|
||||||
}else {
|
|
||||||
$checked = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//check if an false value even the value is not required
|
//check if an false value even the value is not required
|
||||||
if(!$item->required AND $value != '' AND $SESSION->feedback->item->captcha->checkchar != $value) {
|
if($highlightrequire AND !$this->check_value($value, $item)) {
|
||||||
$falsevalue = true;
|
$falsevalue = true;
|
||||||
}else {
|
}else {
|
||||||
$falsevalue = false;
|
$falsevalue = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($highlightrequire AND $item->required AND !$checked) OR $falsevalue) {
|
if($falsevalue) {
|
||||||
$highlight = ' missingrequire';
|
$highlight = 'missingrequire';
|
||||||
}else {
|
}else {
|
||||||
$highlight = '';
|
$highlight = '';
|
||||||
}
|
}
|
||||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
$requiredmark = '<span class="feedback_required_mark">*</span>';
|
||||||
|
|
||||||
//print the question and label
|
if(isset($SESSION->feedback->captchacheck) AND $SESSION->feedback->captchacheck == $USER->sesskey AND $value == $USER->sesskey) {
|
||||||
echo '<div class="feedback_item_label_'.$align.$highlight.'">';
|
//print the question and label
|
||||||
|
echo '<div class="feedback_item_label_'.$align.'">';
|
||||||
|
echo '('.$item->label.') ';
|
||||||
echo format_text($item->name.$requiredmark, true, false, false);
|
echo format_text($item->name.$requiredmark, true, false, false);
|
||||||
echo '</div>';
|
echo '<input type="hidden" value="'.$USER->sesskey.'" name="'.$item->typ.'_'.$item->id.'" />';
|
||||||
|
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 class="'.$highlight.'" 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>
|
||||||
|
|
||||||
//print the presentation
|
<input type="text" id="recaptcha_response_field" name="'.$item->typ.'_'.$item->id.'" />
|
||||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
|
||||||
echo '<div class="feedback_item_captcha_img_'.$align.'">';
|
<div><a href="javascript:Recaptcha.reload()">' . $strgetanothercaptcha . '</a></div>
|
||||||
$imglink = new moodle_url('/mod/feedback/item/captcha/print_captcha.php', array('id'=>$cmid));
|
<div class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type(\'audio\')">' . $strgetanaudiocaptcha . '</a></div>
|
||||||
echo '<img alt="'.$this->type.'" src="'.$imglink->out().'" />';
|
<div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type(\'image\')">' . $strgetanimagecaptcha . '</a></div>
|
||||||
echo '</div>';
|
</div>';
|
||||||
echo '<div class="feedback_item_captcha_text_'.$align.'">';
|
//we have to rename the challengefield
|
||||||
echo '<input type="text" name="'.$item->typ.'_'.$item->id.'" size="'.$presentation.'" maxlength="'.$presentation.'" value="" />';
|
$captchahtml = recaptcha_get_html($CFG->recaptchapublickey, NULL);
|
||||||
echo '</div>';
|
echo $html.$captchahtml;
|
||||||
echo '</div>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -224,57 +211,52 @@ class feedback_item_captcha extends feedback_item_base {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function print_item_show_value($item, $value = '') {
|
function print_item_show_value($item, $value = '') {
|
||||||
global $SESSION, $CFG, $DB, $OUTPUT;
|
global $DB;
|
||||||
|
|
||||||
$align = right_to_left() ? 'right' : 'left';
|
$align = right_to_left() ? 'right' : 'left';
|
||||||
|
|
||||||
$presentation = $item->presentation;
|
|
||||||
$SESSION->feedback->item->captcha->charcount = $presentation;
|
|
||||||
|
|
||||||
$cmid = 0;
|
$cmid = 0;
|
||||||
|
$feedbackid = $item->feedback;
|
||||||
if(isset($SESSION->feedback->item->captcha->checked)) {
|
if($feedbackid > 0) {
|
||||||
$checked = $SESSION->feedback->item->captcha->checked == true;
|
$feedback = $DB->get_record('feedback', array('id'=>$feedbackid));
|
||||||
unset($SESSION->feedback->item->captcha->checked);
|
if($cm = get_coursemodule_from_instance("feedback", $feedback->id, $feedback->course)) {
|
||||||
}else {
|
$cmid = $cm->id;
|
||||||
$checked = false;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
$requiredmark = '<span class="feedback_required_mark">*</span>';
|
||||||
|
|
||||||
//print the question and label
|
//print the question and label
|
||||||
echo '<div class="feedback_item_label_'.$align.'">';
|
echo '<div class="feedback_item_label_'.$align.'">';
|
||||||
echo '('.$item->label.') ';
|
echo '('.$item->label.') ';
|
||||||
echo format_text($item->name . $requiredmark, true, false, false);
|
echo format_text($item->name.$requiredmark, true, false, false);
|
||||||
echo '</div>';
|
|
||||||
|
|
||||||
//print the presentation
|
|
||||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
|
||||||
echo '<div class="feedback_item_captcha_img_'.$align.'">';
|
|
||||||
$imglink = new moodle_url('/mod/feedback/item/captcha/print_captcha.php', array('id'=>$cmid));
|
|
||||||
echo '<img alt="'.$this->type.'" src="'.$imglink->out().'" />';
|
|
||||||
echo '</div>';
|
|
||||||
echo $OUTPUT->box_start('generalbox boxalign'.$align);
|
|
||||||
echo $value ? $value : ' ';
|
|
||||||
echo $OUTPUT->box_end();
|
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function check_value($value, $item) {
|
function check_value($value, $item) {
|
||||||
global $SESSION;
|
global $SESSION, $CFG, $USER;
|
||||||
//if the item is not required, so the check is true if no value is given
|
require_once($CFG->libdir.'/recaptchalib.php');
|
||||||
if((!isset($value) OR $value == '') AND $item->required != 1) return true;
|
|
||||||
if($SESSION->feedback->item->captcha->checkchar == $value) {
|
$challenge = optional_param('recaptcha_challenge_field', '', PARAM_RAW);
|
||||||
$SESSION->feedback->item->captcha->checked = true;
|
|
||||||
|
if($value == $USER->sesskey AND $challenge == '') {
|
||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_value($data) {
|
function create_value($data) {
|
||||||
$data = clean_text($data);
|
global $USER;
|
||||||
return $data;
|
return $USER->sesskey;
|
||||||
}
|
}
|
||||||
|
|
||||||
//compares the dbvalue with the dependvalue
|
//compares the dbvalue with the dependvalue
|
||||||
@@ -288,11 +270,14 @@ class feedback_item_captcha extends feedback_item_base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function get_presentation($data) {
|
function get_presentation($data) {
|
||||||
return $data->count_of_nums;
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_hasvalue() {
|
function get_hasvalue() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function can_switch_require() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|||||||
@@ -1,64 +1,41 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class feedback_item_base {
|
abstract class feedback_item_base {
|
||||||
var $type;
|
var $type;
|
||||||
/**
|
|
||||||
* The class constructor
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function feedback_item_base() {
|
|
||||||
$this->init();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fake constructor to keep PHP5 happy
|
* constructor
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function __construct() {
|
function __construct() {
|
||||||
$this->feedback_item_base();
|
$this->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
//this function only can used after the call of build_editform()
|
||||||
* prints the item-related sequenz on the edit-item form
|
function show_editform() {
|
||||||
*
|
$this->item_form->display();
|
||||||
* @param $item the db-object from feedback_item
|
}
|
||||||
* @param $usehtmleditor defines whether the editor should be shown or not
|
|
||||||
*/
|
function is_cancelled() {
|
||||||
function show_edit($item, $usehtmleditor = false) {
|
return $this->item_form->is_cancelled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
function get_data() {
|
||||||
* returns an Array with three values(typ, name, XXX)
|
if($this->item = $this->item_form->get_data()) {
|
||||||
* XXX is also an Array (count of responses on type $this->type)
|
return true;
|
||||||
* each element is a structure (answertext, answercount)
|
}
|
||||||
* @param $item the db-object from feedback_item
|
return false;
|
||||||
* @param $groupid if given
|
|
||||||
* @param $courseid if given
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
function get_analysed($item, $groupid = false, $courseid = false) {
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param object $item the db-object from feedback_item
|
|
||||||
* @param string $value a item-related value from feedback_values
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function get_printval($item, $value) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $item the db-object from feedback_item
|
|
||||||
* @param string $itemnr
|
|
||||||
* @param integer $groupid
|
|
||||||
* @param integer $courseid
|
|
||||||
* @return integer the new itemnr
|
|
||||||
*/
|
|
||||||
function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract function init();
|
||||||
|
abstract function build_editform($item, $feedback, $cm);
|
||||||
|
abstract function save_item();
|
||||||
|
abstract function check_value($value, $item);
|
||||||
|
abstract function create_value($data);
|
||||||
|
abstract function compare_value($item, $dbvalue, $dependvalue);
|
||||||
|
abstract function get_presentation($data);
|
||||||
|
abstract function get_hasvalue();
|
||||||
|
abstract function can_switch_require();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param object $worksheet a reference to the pear_spreadsheet-object
|
* @param object $worksheet a reference to the pear_spreadsheet-object
|
||||||
@@ -68,36 +45,91 @@ class feedback_item_base {
|
|||||||
* @param integer $courseid
|
* @param integer $courseid
|
||||||
* @return integer the new rowOffset
|
* @return integer the new rowOffset
|
||||||
*/
|
*/
|
||||||
function excelprint_item(&$worksheet, $rowOffset, $item, $groupid, $courseid = false) {
|
abstract function excelprint_item(&$worksheet, $rowOffset, $xlsFormats, $item, $groupid, $courseid = false);
|
||||||
return $rowOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
function print_item($item, $value = false, $readonly = false, $edit = false, $highlightrequire = false){
|
/**
|
||||||
}
|
* @param $item the db-object from feedback_item
|
||||||
|
* @param string $itemnr
|
||||||
|
* @param integer $groupid
|
||||||
|
* @param integer $courseid
|
||||||
|
* @return integer the new itemnr
|
||||||
|
*/
|
||||||
|
abstract function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param object $item the db-object from feedback_item
|
||||||
|
* @param string $value a item-related value from feedback_values
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract 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
|
||||||
|
*/
|
||||||
|
abstract function get_analysed($item, $groupid = false, $courseid = false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* print the item at the edit-page of feedback
|
||||||
|
*
|
||||||
|
* @global object
|
||||||
|
* @param object $item
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
abstract function print_item_preview($item);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* print the item at the complete-page of feedback
|
||||||
|
*
|
||||||
|
* @global object
|
||||||
|
* @param object $item
|
||||||
|
* @param string $value
|
||||||
|
* @param bool $highlightrequire
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
abstract function print_item_complete($item, $value = '', $highlightrequire = false);
|
||||||
|
|
||||||
function check_value($value, $item) {
|
/**
|
||||||
return true;
|
* print the item at the complete-page of feedback
|
||||||
}
|
*
|
||||||
|
* @global object
|
||||||
|
* @param object $item
|
||||||
|
* @param string $value
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
abstract function print_item_show_value($item, $value = '');
|
||||||
|
|
||||||
function create_value($data) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_presentation($data) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_hasvalue() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//a dummy class to realize pagebreaks
|
//a dummy class to realize pagebreaks
|
||||||
class feedback_item_pagebreak extends feedback_item_base {
|
class feedback_item_pagebreak extends feedback_item_base {
|
||||||
var $type = "pagebreak";
|
var $type = "pagebreak";
|
||||||
function init() {
|
|
||||||
|
|
||||||
}
|
function show_editform() {}
|
||||||
|
function is_cancelled() {}
|
||||||
|
function get_data() {}
|
||||||
|
function init() {}
|
||||||
|
function build_editform($item, $feedback, $cm) {}
|
||||||
|
function save_item() {}
|
||||||
|
function check_value($value, $item) {}
|
||||||
|
function create_value($data) {}
|
||||||
|
function compare_value($item, $dbvalue, $dependvalue) {}
|
||||||
|
function get_presentation($data) {}
|
||||||
|
function get_hasvalue() {}
|
||||||
|
function excelprint_item(&$worksheet, $rowOffset, $xlsFormats, $item, $groupid, $courseid = false) {}
|
||||||
|
function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {}
|
||||||
|
function get_printval($item, $value) {}
|
||||||
|
function get_analysed($item, $groupid = false, $courseid = false) {}
|
||||||
|
function print_item_preview($item) {}
|
||||||
|
function print_item_complete($item, $value = '', $highlightrequire = false) {}
|
||||||
|
function print_item_show_value($item, $value = '') {}
|
||||||
|
function can_switch_require(){}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -306,5 +306,8 @@ class feedback_item_info extends feedback_item_base {
|
|||||||
function get_hasvalue() {
|
function get_hasvalue() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function can_switch_require() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|||||||
@@ -208,5 +208,14 @@ class feedback_item_label extends feedback_item_base {
|
|||||||
function get_hasvalue() {
|
function get_hasvalue() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function can_switch_require() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_value($value, $item) {}
|
||||||
|
function excelprint_item(&$worksheet, $rowOffset, $xlsFormats, $item, $groupid, $courseid = false) {}
|
||||||
|
function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {}
|
||||||
|
function get_printval($item, $value) {}
|
||||||
|
function get_analysed($item, $groupid = false, $courseid = false) {}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
@@ -700,6 +700,8 @@ class feedback_item_multichoice extends feedback_item_base {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function can_switch_require() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|||||||
@@ -582,6 +582,8 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function can_switch_require() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|||||||
@@ -411,5 +411,8 @@ class feedback_item_numeric extends feedback_item_base {
|
|||||||
function get_hasvalue() {
|
function get_hasvalue() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function can_switch_require() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ class feedback_item_textarea extends feedback_item_base {
|
|||||||
|
|
||||||
|
|
||||||
//liefert eine Struktur ->name, ->data = array(mit Antworten)
|
//liefert eine Struktur ->name, ->data = array(mit Antworten)
|
||||||
function get_analysed($item, $groupid, $courseid = false) {
|
function get_analysed($item, $groupid = false, $courseid = false) {
|
||||||
global $DB;
|
global $DB;
|
||||||
|
|
||||||
$aVal = null;
|
$aVal = null;
|
||||||
@@ -270,5 +270,8 @@ class feedback_item_textarea extends feedback_item_base {
|
|||||||
function get_hasvalue() {
|
function get_hasvalue() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function can_switch_require() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|||||||
@@ -264,5 +264,8 @@ class feedback_item_textfield extends feedback_item_base {
|
|||||||
function get_hasvalue() {
|
function get_hasvalue() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function can_switch_require() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|||||||
@@ -198,6 +198,7 @@ $string['numeric_range_to'] = 'Range to';
|
|||||||
$string['of'] = 'of';
|
$string['of'] = 'of';
|
||||||
$string['oldvaluespreserved'] = 'All old questions and the assigned values will be preserved';
|
$string['oldvaluespreserved'] = 'All old questions and the assigned values will be preserved';
|
||||||
$string['oldvalueswillbedeleted'] = 'The current questions and all your user\'s responses will be deleted';
|
$string['oldvalueswillbedeleted'] = 'The current questions and all your user\'s responses will be deleted';
|
||||||
|
$string['only_one_captcha_allowed'] = 'Only one captcha is allowed in a feedback';
|
||||||
$string['overview'] = 'Overview';
|
$string['overview'] = 'Overview';
|
||||||
$string['page'] = 'Page';
|
$string['page'] = 'Page';
|
||||||
$string['page_after_submit'] = 'Page after submit';
|
$string['page_after_submit'] = 'Page after submit';
|
||||||
@@ -262,6 +263,7 @@ $string['textarea_width'] = 'Width';
|
|||||||
$string['textfield'] = 'Short text answer';
|
$string['textfield'] = 'Short text answer';
|
||||||
$string['textfield_maxlength'] = 'Maximum characters accepted';
|
$string['textfield_maxlength'] = 'Maximum characters accepted';
|
||||||
$string['textfield_size'] = 'Textfield width';
|
$string['textfield_size'] = 'Textfield width';
|
||||||
|
$string['there_are_no_settings_for_recaptcha'] = 'There are no settings for captcha';
|
||||||
$string['this_feedback_is_already_submitted'] = 'You\'ve already completed this activity.';
|
$string['this_feedback_is_already_submitted'] = 'You\'ve already completed this activity.';
|
||||||
$string['timeclose'] = 'Time to close';
|
$string['timeclose'] = 'Time to close';
|
||||||
$string['timeclose_help'] = 'You can specify times when the feedback is accessible for people to answer the questions. If the checkbox is not ticked there is no limit defined.';
|
$string['timeclose_help'] = 'You can specify times when the feedback is accessible for people to answer the questions. If the checkbox is not ticked there is no limit defined.';
|
||||||
|
|||||||
+35
-51
@@ -1113,6 +1113,25 @@ function feedback_get_template_list($course, $onlyown = false) {
|
|||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load the lib.php from item-plugin-dir and returns the instance of the itemclass
|
||||||
|
*
|
||||||
|
* @global object
|
||||||
|
* @param object $item
|
||||||
|
* @return object the instanz of itemclass
|
||||||
|
*/
|
||||||
|
function feedback_get_item_class($typ) {
|
||||||
|
global $CFG;
|
||||||
|
|
||||||
|
//get the class of item-typ
|
||||||
|
$itemclass = 'feedback_item_'.$typ;
|
||||||
|
//get the instance of item-class
|
||||||
|
if (!class_exists($itemclass)) {
|
||||||
|
require_once($CFG->dirroot.'/mod/feedback/item/'.$typ.'/lib.php');
|
||||||
|
}
|
||||||
|
return new $itemclass();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* load the available item plugins from given subdirectory of $CFG->dirroot
|
* load the available item plugins from given subdirectory of $CFG->dirroot
|
||||||
* the default is "mod/feedback/item"
|
* the default is "mod/feedback/item"
|
||||||
@@ -1213,10 +1232,7 @@ function feedback_create_item($data) {
|
|||||||
$item->label = get_string('no_itemlabel', 'feedback');
|
$item->label = get_string('no_itemlabel', 'feedback');
|
||||||
}
|
}
|
||||||
|
|
||||||
//get the used class from item-typ
|
$itemobj = feedback_get_item_class($data->typ);
|
||||||
$itemclass = 'feedback_item_'.$data->typ;
|
|
||||||
//get the instance of the item class
|
|
||||||
$itemobj = new $itemclass();
|
|
||||||
// $item->presentation = $itemobj->get_presentation($data);
|
// $item->presentation = $itemobj->get_presentation($data);
|
||||||
$item->presentation = ''; //the date comes from postupdate() of the itemobj
|
$item->presentation = ''; //the date comes from postupdate() of the itemobj
|
||||||
|
|
||||||
@@ -1320,9 +1336,14 @@ function feedback_delete_all_items($feedbackid){
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function feedback_switch_item_required($item) {
|
function feedback_switch_item_required($item) {
|
||||||
global $DB;
|
global $DB, $CFG;
|
||||||
|
|
||||||
return $DB->set_field('feedback_item', 'required', (int)!(bool)$item->required, array('id'=>$item->id));
|
$itemobj = feedback_get_item_class($item->typ);
|
||||||
|
|
||||||
|
if($itemobj->can_switch_require()) {
|
||||||
|
$DB->set_field('feedback_item', 'required', (int)!(bool)$item->required, array('id'=>$item->id));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1457,13 +1478,8 @@ function feedback_print_item_preview($item){
|
|||||||
if($item->typ == 'pagebreak') {
|
if($item->typ == 'pagebreak') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//get the class of the given item-typ
|
|
||||||
$itemclass = 'feedback_item_'.$item->typ;
|
|
||||||
if (!class_exists($itemclass)) {
|
|
||||||
require_once($CFG->dirroot.'/mod/feedback/item/'.$item->typ.'/lib.php');
|
|
||||||
}
|
|
||||||
//get the instance of the item-class
|
//get the instance of the item-class
|
||||||
$itemobj = new $itemclass();
|
$itemobj = feedback_get_item_class($item->typ);
|
||||||
$itemobj->print_item_preview($item);
|
$itemobj->print_item_preview($item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1482,13 +1498,8 @@ function feedback_print_item_complete($item, $value = false, $highlightrequire =
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//get the class of the given item-typ
|
|
||||||
$itemclass = 'feedback_item_'.$item->typ;
|
|
||||||
if (!class_exists($itemclass)) {
|
|
||||||
require_once($CFG->dirroot.'/mod/feedback/item/'.$item->typ.'/lib.php');
|
|
||||||
}
|
|
||||||
//get the instance of the item-class
|
//get the instance of the item-class
|
||||||
$itemobj = new $itemclass();
|
$itemobj = feedback_get_item_class($item->typ);
|
||||||
$itemobj->print_item_complete($item, $value, $highlightrequire);
|
$itemobj->print_item_complete($item, $value, $highlightrequire);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1506,13 +1517,8 @@ function feedback_print_item_show_value($item, $value = false){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//get the class of the given item-typ
|
|
||||||
$itemclass = 'feedback_item_'.$item->typ;
|
|
||||||
if (!class_exists($itemclass)) {
|
|
||||||
require_once($CFG->dirroot.'/mod/feedback/item/'.$item->typ.'/lib.php');
|
|
||||||
}
|
|
||||||
//get the instance of the item-class
|
//get the instance of the item-class
|
||||||
$itemobj = new $itemclass();
|
$itemobj = feedback_get_item_class($item->typ);
|
||||||
$itemobj->print_item_show_value($item, $value);
|
$itemobj->print_item_show_value($item, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1833,12 +1839,9 @@ function feedback_compare_item_value($completedid, $itemid, $dependvalue, $tmp =
|
|||||||
|
|
||||||
//get the class of the given item-typ
|
//get the class of the given item-typ
|
||||||
$item = $DB->get_record('feedback_item', array('id'=>$itemid));
|
$item = $DB->get_record('feedback_item', array('id'=>$itemid));
|
||||||
$itemclass = 'feedback_item_'.$item->typ;
|
|
||||||
if (!class_exists($itemclass)) {
|
|
||||||
require_once($CFG->dirroot.'/mod/feedback/item/'.$item->typ.'/lib.php');
|
|
||||||
}
|
|
||||||
//get the instance of the item-class
|
//get the instance of the item-class
|
||||||
$itemobj = new $itemclass();
|
$itemobj = feedback_get_item_class($item->typ);
|
||||||
return $itemobj->compare_value($item, $dbvalue, $dependvalue); //true or false
|
return $itemobj->compare_value($item, $dbvalue, $dependvalue); //true or false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1882,15 +1885,8 @@ function feedback_check_values($firstitem, $lastitem) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//get the class of the item-typ
|
|
||||||
$itemclass = 'feedback_item_'.$item->typ;
|
|
||||||
|
|
||||||
if (!class_exists($itemclass)) {
|
|
||||||
require_once($CFG->dirroot.'/mod/feedback/item/'.$item->typ.'/lib.php');
|
|
||||||
}
|
|
||||||
|
|
||||||
//get the instance of the item-class
|
//get the instance of the item-class
|
||||||
$itemobj = new $itemclass();
|
$itemobj = feedback_get_item_class($item->typ);
|
||||||
|
|
||||||
//now we let check the value by the item-class
|
//now we let check the value by the item-class
|
||||||
if(!$itemobj->check_value($value, $item)) {
|
if(!$itemobj->check_value($value, $item)) {
|
||||||
@@ -1951,13 +1947,7 @@ function feedback_create_values($usrid, $timemodified, $tmp = false, $guestid =
|
|||||||
$value->course_id = $courseid;
|
$value->course_id = $courseid;
|
||||||
|
|
||||||
//get the class of item-typ
|
//get the class of item-typ
|
||||||
$itemclass = 'feedback_item_'.$item->typ;
|
$itemobj = feedback_get_item_class($item->typ);
|
||||||
|
|
||||||
//get the instance of item-class
|
|
||||||
if (!class_exists($itemclass)) {
|
|
||||||
require_once($CFG->dirroot.'/mod/feedback/item/'.$item->typ.'/lib.php');
|
|
||||||
}
|
|
||||||
$itemobj = new $itemclass();
|
|
||||||
|
|
||||||
//the kind of values can be absolutely different so we run create_value directly by the item-class
|
//the kind of values can be absolutely different so we run create_value directly by the item-class
|
||||||
$value->value = $itemobj->create_value($itemvalue);
|
$value->value = $itemobj->create_value($itemvalue);
|
||||||
@@ -2003,13 +1993,7 @@ function feedback_update_values($completed, $tmp = false) {
|
|||||||
$newvalue->course_id = $courseid;
|
$newvalue->course_id = $courseid;
|
||||||
|
|
||||||
//get the class of item-typ
|
//get the class of item-typ
|
||||||
$itemclass = 'feedback_item_'.$item->typ;
|
$itemobj = feedback_get_item_class($item->typ);
|
||||||
|
|
||||||
//get the instance of item-class
|
|
||||||
if (!class_exists($itemclass)) {
|
|
||||||
require_once($CFG->dirroot.'/mod/feedback/item/'.$item->typ.'/lib.php');
|
|
||||||
}
|
|
||||||
$itemobj = new $itemclass();
|
|
||||||
//the kind of values can be absolutely different so we run create_value directly by the item-class
|
//the kind of values can be absolutely different so we run create_value directly by the item-class
|
||||||
$newvalue->value = $itemobj->create_value($itemvalue);
|
$newvalue->value = $itemobj->create_value($itemvalue);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user