Exemple #1
0
     $pagebreaks = array_values($pagebreaks);
     $firstpagebreak = $pagebreaks[0];
 } else {
     $firstpagebreak = false;
 }
 $maxitemcount = count_records('feedback_item', 'feedback', $feedback->id);
 //get the values of completeds before done. Anonymous user can not get these values.
 if (!isset($SESSION->feedback->is_started) and !isset($savereturn) and $feedback->anonymous == FEEDBACK_ANONYMOUS_NO) {
     if (!($feedbackcompletedtmp = feedback_get_current_completed($feedback->id, true, $courseid))) {
         if ($feedbackcompleted = feedback_get_current_completed($feedback->id, false, $courseid)) {
             //copy the values to feedback_valuetmp create a completedtmp
             $feedbackcompletedtmp = feedback_set_tmp_values($feedbackcompleted);
         }
     }
 } else {
     $feedbackcompletedtmp = feedback_get_current_completed($feedback->id, true, $courseid);
 }
 /// Print the main part of the page
 ///////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////
 print_heading(format_text($feedback->name));
 if (isset($savereturn) && $savereturn == 'saved') {
     if ($feedback->page_after_submit) {
         // print_simple_box_start('center', '75%');
         print_box_start('generalbox boxaligncenter boxwidthwide');
         echo format_text(stripslashes_safe($feedback->page_after_submit));
         // print_simple_box_end();
         print_box_end();
     } else {
         echo '<p align="center"><b><font color="green">' . get_string('entries_saved', 'feedback') . '</font></b></p>';
Exemple #2
0
/**
 * this function checks the correctness of values.
 * the rules for this are implemented in the class of each item.
 * it can be the required attribute or the value self e.g. numeric.
 * the params first/lastitem are given to determine the visible range between pagebreaks.
 *
 * @global object
 * @param int $firstitem the position of firstitem for checking
 * @param int $lastitem the position of lastitem for checking
 * @return boolean
 */
function feedback_check_values($firstitem, $lastitem)
{
    global $DB, $CFG;
    $feedbackid = optional_param('feedbackid', 0, PARAM_INT);
    //get all items between the first- and lastitem
    $select = "feedback = ?\n                    AND position >= ?\n                    AND position <= ?\n                    AND hasvalue = 1";
    $params = array($feedbackid, $firstitem, $lastitem);
    if (!($feedbackitems = $DB->get_records_select('feedback_item', $select, $params))) {
        //if no values are given so no values can be wrong ;-)
        return true;
    }
    foreach ($feedbackitems as $item) {
        //get the instance of the item-class
        $itemobj = feedback_get_item_class($item->typ);
        //the name of the input field of the completeform is given in a special form:
        //<item-typ>_<item-id> eg. numeric_234
        //this is the key to get the value for the correct item
        $formvalname = $item->typ . '_' . $item->id;
        if ($itemobj->value_is_array()) {
            //get the raw value here. It is cleaned after that by the object itself
            $value = optional_param_array($formvalname, null, PARAM_RAW);
        } else {
            //get the raw value here. It is cleaned after that by the object itself
            $value = optional_param($formvalname, null, PARAM_RAW);
        }
        $value = $itemobj->clean_input_value($value);
        // If the item is not visible due to its dependency so it shouldn't be required.
        // Many thanks to Pau Ferrer Ocaña.
        if ($item->dependitem > 0 and $item->required == 1) {
            $comparevalue = false;
            if ($feedbackcompletedtmp = feedback_get_current_completed($item->feedback, true)) {
                $comparevalue = feedback_compare_item_value($feedbackcompletedtmp->id, $item->dependitem, $item->dependvalue, true);
            }
            if (!$comparevalue) {
                $item->required = 0;
                // Override the required property.
            }
        }
        //check if the value is set
        if (is_null($value) and $item->required == 1) {
            return false;
        }
        //now we let check the value by the item-class
        if (!$itemobj->check_value($value, $item)) {
            return false;
        }
    }
    //if no wrong values so we can return true
    return true;
}
 } else {
     $startposition = 0;
     $newpage = 0;
     $ispagebreak = false;
 }
 //get the feedbackitems after the last shown pagebreak
 $feedbackitems = get_records_select('feedback_item', 'feedback = ' . $feedback->id . ' AND position > ' . $startposition, 'position');
 //get the first pagebreak
 if ($pagebreaks = get_records_select('feedback_item', "feedback = " . $feedback->id . " AND typ = 'pagebreak'", 'position')) {
     $pagebreaks = array_values($pagebreaks);
     $firstpagebreak = $pagebreaks[0];
 } else {
     $firstpagebreak = false;
 }
 $maxitemcount = count_records('feedback_item', 'feedback', $feedback->id);
 $feedbackcompletedtmp = feedback_get_current_completed($feedback->id, true, $courseid, $USER->sesskey);
 /// Print the main part of the page
 ///////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////
 print_heading(format_text($feedback->name));
 if (isset($savereturn) && $savereturn == 'saved') {
     if ($feedback->page_after_submit) {
         // print_simple_box_start('center', '75%');
         print_box_start('generalbox boxaligncenter boxwidthwide');
         echo format_text(stripslashes_safe($feedback->page_after_submit));
         // print_simple_box_end();
         print_box_end();
     } else {
         echo '<p align="center"><b><font color="green">' . get_string('entries_saved', 'feedback') . '</font></b></p>';
         if (intval($feedback->publish_stats) == 1) {
public function f2f_feedback_trainer($fid){
 
    global $DB,$CFG,$OUTPUT,$PAGE;
    $evaltype = array(NULL => get_string('evoltype1', 'local_evaluations'),
            '1' => get_string('evoltype2', 'local_evaluations'),
            '2' => get_string('evoltype3', 'local_evaluations'),
            '3' => get_string('evoltype4', 'local_evaluations'));
        $feedbacks = $DB->get_records('local_evaluation',array('classid'=>$fid));
$data = array();
foreach ($feedbacks as $feedback) {
    $line = array();
    $params = array();
    $linkcss = $feedback->publish_stats ? ' ' : 'class="dimmed" ';
    $line[] = '<a ' . $linkcss . ' href="' . $CFG->wwwroot . '/local/evaluations/edit.php?id=' . $feedback->id . '&clid=' . $feedback->classid . '&do_show=edit">' . format_string($feedback->name) . '</a>';
   
    $line[] = $evaltype[$feedback->evaluationtype];


    $params = array('evaluation' => $feedback->id, 'hasvalue' => 1);
    $itemscount = $DB->count_records('evaluation_item', $params);
    $feedback_can_submit = true;
    if ($feedback->multiple_submit == 0) {
        if (evaluation_is_already_submitted($feedback->id, $feedback->classid)) {
            $feedback_can_submit = false;
        }
    }

    if ($feedback_can_submit) {
            $total_count=$DB->get_record_sql("SELECT count(id) as total_count FROM {local_batch_users} lbu where lbu.f2fid=$fid group by lbu.f2fid");
            if($total_count){
                $total_count->total_count=$total_count->total_count;
            }else{
                 $total_count->total_count=0;
            }
         switch($feedback->evaluationtype){
            case 1:
                $submited_count=$DB->get_record_sql("SELECT count(id) as submited_count FROM {local_batch_users} lbu where lbu.f2fid=$fid and lbu.prefeedback!=0  group by lbu.f2fid");
                if($submited_count){
                 $line[] ="$submited_count->submited_count/$total_count->total_count";
                }else{
                 $line[] ="0/$total_count->total_count";
                }
             
              break;	  
             case 2:
                $submited_count=$DB->get_record_sql("SELECT count(id) as submited_count FROM {local_batch_users} lbu where lbu.f2fid=$fid and lbu.postfeedback!=0  group by lbu.f2fid");
                if($submited_count){
                 $line[] ="$submited_count->submited_count/$total_count->total_count";
                }else{
                 $line[] ="0/$total_count->total_count";
                }
             
              break;
            case 3:
                $submited_count=$DB->get_record_sql("SELECT count(id) as submited_count FROM {local_batch_users} lbu where lbu.f2fid=$fid and lbu.trainerfeedback!=0  group by lbu.f2fid");
                if($submited_count){
                 $line[] ="$submited_count->submited_count/$total_count->total_count";
                }else{
                 $line[] ="0/$total_count->total_count";
                }
             
              break;
         }
        //$line[] ="0/1";
        $checktime = time();
        if (($feedback->timeopen > $checktime) OR ( $feedback->timeclose < $checktime AND $feedback->timeclose > 0)) {
            $ected = '<font color="red">';
            $ected .= get_string('feedback_is_not_open', 'local_evaluations');
            $ected .= '</font>';
            $line[] = $ected;
        } else {
            //if the user is not known so we cannot save the values temporarly
            if (!isloggedin() or isguestuser()) {
                $completefile = 'complete_guest.php';
                $guestid = sesskey();
            } else {
                $completefile = 'complete.php';
                $guestid = false;
            }

            $url_params = array('id' => $feedback->id, 'clid' => $feedback->classid, 'gopage' => 0);
            if($feedback->evaluationtype == 3){
            $t_employee = $DB->get_field_sql("SELECT lbu.userid,
                                                    (SELECT concat(us.firstname,' ',us.lastname) FROM {user}  as us where us.id=lbu.userid) as employee_name
                                                    FROM {local_batch_users} lbu where lbu.f2fid=$feedback->classid order by lbu.userid asc limit 1");
            
            $url_params['employee_id'] = $t_employee;
            }
            $completeurl = new moodle_url('/local/evaluations/' . $completefile, $url_params);

            $feedbackcompletedtmp = feedback_get_current_completed($feedback->id, true, $feedback->classid, $guestid);
            if($feedback->evaluationtype!=3){
                $supervisers = $DB->get_fieldset_sql("select supervisorid from {local_batch_users} where f2fid=$feedback->classid and supervisorid!=''");
                $superviser_count = COUNT($supervisers);
               if($DB->record_exists_sql("select * from {evaluation_completed} where evaluation=$feedback->id  HAVING COUNT(userid)=$superviser_count"))
                $line[] = "Completed";
                else
                $line[] = "Pending";
            }else if ($feedbackcompletedtmp) {
                if ($startpage = feedback_get_page_to_continue($feedback->id, $feedback->classid, $guestid)) {
                    $completeurl->param('gopage', $startpage);
                }
                if ($itemscount > 0) {
                     $batchstatus=$DB->get_field('facetoface','active',array('id'=>$feedback->classid));
                     if($batchstatus==0||$batchstatus==3){
                        $line[] = '<a href="' . $completeurl->out() . '">' . get_string('continue_the_form', 'local_evaluations') . '</a>';
                     }elseif($batchstatus==1||$batchstatus==2||$batchstatus==8){
                         $line[] = get_string('continue_the_form', 'local_evaluations');
                     }
                } else {
                    $line[] = "No questions are available";
                }
            } else {
                if ($itemscount > 0) {
                    $batchstatus=$DB->get_field('facetoface','active',array('id'=>$feedback->classid));
                    if($batchstatus==0){
                        $line[] = get_string('complete_the_form', 'local_evaluations');
                    }elseif($batchstatus==1||$batchstatus==2||$batchstatus==8||$batchstatus==3){
                        $line[] = '<a href="' . $completeurl->out() . '">' . get_string('complete_the_form', 'local_evaluations') . '</a>';
                    } 
                } else {
                    $line[] = "No questions are available";
                }
            }
        }
    } else {
        $cted = '<font color="red">';
        $cted .= get_string('this_feedback_is_already_submitted', 'local_evaluations');
        $cted .= '</font>';
        $line[] = $cted;
    }

    $batchstatus=$DB->get_field('facetoface','active',array('id'=>$feedback->classid));
   if($batchstatus==0||$batchstatus==3||$batchstatus==1){
        $buttons = html_writer::link(new moodle_url('/local/evaluations/create_evaluation.php', array('id' => $feedback->id, 'clid' => $feedback->classid, 'delete' => 1, 'sesskey' => sesskey())), html_writer::empty_tag('img',  array('src' => $OUTPUT->pix_url('t/aia/delete'),
                        'onmouseover' => "this.src='".$OUTPUT->pix_url('t/aia/delete1')."'",
                        'onmouseout' => "this.src='".$OUTPUT->pix_url('t/aia/delete')."'", 'title' => get_string('delete'), 'alt' => get_string('delete'),'class' => 'feedback_cion')));
        $buttons .= html_writer::link(new moodle_url('/local/evaluations/create_evaluation.php', array('id' => $feedback->id, 'clid' => $feedback->classid, 'sesskey' => sesskey())), html_writer::empty_tag('img',  array('src' => $OUTPUT->pix_url('t/aia/edit'),
                        'onmouseover' => "this.src='".$OUTPUT->pix_url('t/aia/edit1')."'",
                        'onmouseout' => "this.src='".$OUTPUT->pix_url('t/aia/edit')."'", 'title' => get_string('edit'), 'alt' => get_string('edit'),'class' => 'feedback_cion')));
        /*
         * ###Bugreport#170-Evaluations
         * @author Naveen Kumar<*****@*****.**>
         * (Resolved) Changed the capability to check permission
         */
        //if (has_capability('local/collegestructure:manage', $systemcontext) && !is_siteadmin()) {
            $line[] = $buttons;
    }
    //}

    $data[] = $line;
}


// Moodle 2.2 and onwards
// echo $OUTPUT->heading(get_string('viewfeedbacks', 'local_feedbacks'));
//View Part starts
echo "<div id='filter-box' >";
if (!empty($feedback)) {
    $PAGE->requires->js('/local/evaluations/evalfilter.js');
    echo '<div class="filterarea"></div></div>';
}

$table = new html_table();
$table->id = "cooktable";
//$table->attributes =  array('onclick'=>'fnShowHide(0);');
$table->head = array(get_string('name', 'local_evaluations'),
    get_string('feedback_type', 'local_evaluations'),'submitted',
    get_string('estatus', 'local_evaluations')
);
$batchstatus=$DB->get_field('facetoface','active',array('id'=>$feedback->classid));
if($batchstatus==0||$batchstatus==3||$batchstatus==1){
    $table->head[] = get_string('action');
}elseif($batchstatus==2||$batchstatus==8){
    
}

$table->width = '100%';
$table->align = array('left', 'left', 'center', 'left', 'left');
$table->size = array('30%', '15%', '15%','15%','10%');
$table->data = $data;
if (empty($feedbacks))
    echo '<div class="empty_data">'.get_string('nofeedbackcreated', 'facetoface').'</div>';
else
    echo '<span class="mb-tablewrapper">'.html_writer::table($table).'</span>';
echo '<div id="contents"></div>';
}