コード例 #1
0
    exit;
}

//$options = $DB->get_records_sql_menu("SELECT u.id,CONCAT(u.firstname,' ',u.lastname)
//                                       FROM {user} as u JOIN {local_batch_users} as bu ON u.id=bu.userid
//                                      WHERE bu.f2fid=$classid and bu.supervisorid=$userid");
    $url = new moodle_url('/local/evaluations/complete.php', array('id'=>$id,'clid'=>$classid,'gopage'=>$gopage,'trainee'=>$trainee_id));

//if($evaluation->evaluationtype<3)
//    echo $OUTPUT->single_select($url, 'trainee', $options,$trainee_id);

//additional check for multiple-submit (prevent browsers back-button).
//the main-check is in view.php
$evaluation_can_submit = true;
if ($evaluation->multiple_submit == 0) {
    if (evaluation_is_already_submitted($evaluation->id, $classid)) {
        $evaluation_can_submit = false;
    }
}
if ($evaluation_can_submit) {
    //preserving the items
    if ($preservevalues == 1) {
        if (!isset($SESSION->evaluation->is_started) OR ! $SESSION->evaluation->is_started == true) {
            print_error('error', '', $CFG->wwwroot . '/class/view.php?id=' . $classid);
        }
        //checken, ob alle required items einen wert haben
        if (evaluation_check_values($startitempos, $lastitempos)) {
            if ($completedid = evaluation_save_values($userid, true,$trainee_id)) {
                if ($userid > 0) {
                    add_to_log($classid, 'evaluation', 'startcomplete', 'view.php?id=' . $cm->id, $evaluation->id, $classid, $userid);
                }
コード例 #2
0
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>';
}