/**
  * Get actual array data
  * @return array 2-dimensional array - each array contains the elements:
  * 0 ['id']        : user id
  * 1 ['result_id'] : result id
  * 2 ['lastname']  : user lastname
  * 3 ['firstname'] : user firstname
  * 4 ['score']     : student's score
  * 5 ['display']   : custom score display (only if custom scoring enabled)
  */
 public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false, $pdf = false)
 {
     // do some checks on count, redefine if invalid value
     $number_decimals = api_get_setting('gradebook_number_decimals');
     if (!isset($count)) {
         $count = count($this->results) - $start;
     }
     if ($count < 0) {
         $count = 0;
     }
     $scoredisplay = ScoreDisplay::instance();
     // generate actual data array
     $table = array();
     foreach ($this->results as $result) {
         $user = array();
         $info = get_user_info_from_id($result->get_user_id());
         $user['id'] = $result->get_user_id();
         if ($pdf) {
             $user['username'] = $info['username'];
         }
         $user['result_id'] = $result->get_id();
         $user['lastname'] = $info['lastname'];
         $user['firstname'] = $info['firstname'];
         if ($pdf) {
             $user['score'] = $result->get_score();
         } else {
             $user['score'] = $this->get_score_display($result->get_score(), true, $ignore_score_color);
         }
         $user['percentage_score'] = intval($scoredisplay->display_score(array($result->get_score(), $this->evaluation->get_max()), SCORE_PERCENT, SCORE_BOTH, true));
         if ($pdf && $number_decimals == null) {
             $user['scoreletter'] = $result->get_score();
         }
         if ($scoredisplay->is_custom()) {
             $user['display'] = $this->get_score_display($result->get_score(), false, $ignore_score_color);
         }
         $table[] = $user;
     }
     // sort array
     if ($sorting & self::RDG_SORT_LASTNAME) {
         usort($table, array('ResultsDataGenerator', 'sort_by_last_name'));
     } elseif ($sorting & self::RDG_SORT_FIRSTNAME) {
         usort($table, array('ResultsDataGenerator', 'sort_by_first_name'));
     } elseif ($sorting & self::RDG_SORT_SCORE) {
         usort($table, array('ResultsDataGenerator', 'sort_by_score'));
     } elseif ($sorting & self::RDG_SORT_MASK) {
         usort($table, array('ResultsDataGenerator', 'sort_by_mask'));
     }
     if ($sorting & self::RDG_SORT_DESC) {
         $table = array_reverse($table);
     }
     $return = array_slice($table, $start, $count);
     return $return;
 }
예제 #2
0
 /**
  * @param Category $catobj
  * @param $showtree
  * @param $selectcat
  * @param $is_course_admin
  * @param $is_platform_admin
  * @param $simple_search_form
  * @param bool $show_add_qualification
  * @param bool $show_add_link
  */
 public function display_header_gradebook_per_gradebook($catobj, $showtree, $selectcat, $is_course_admin, $is_platform_admin, $simple_search_form, $show_add_qualification = true, $show_add_link = true)
 {
     // Student
     $status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
     $objcat = new Category();
     $course_id = Database::get_course_by_category($selectcat);
     $message_resource = $objcat->show_message_resource_delete($course_id);
     if (!$is_course_admin && $status != 1 && $selectcat != 0) {
         $user_id = api_get_user_id();
         $user = get_user_info_from_id($user_id);
         $catcourse = Category::load($catobj->get_id());
         $scoredisplay = ScoreDisplay::instance();
         $scorecourse = $catcourse[0]->calc_score($user_id);
         // generating the total score for a course
         $allevals = $catcourse[0]->get_evaluations($user_id, true);
         $alllinks = $catcourse[0]->get_links($user_id, true);
         $evals_links = array_merge($allevals, $alllinks);
         $item_value = 0;
         $item_total = 0;
         for ($count = 0; $count < count($evals_links); $count++) {
             $item = $evals_links[$count];
             $score = $item->calc_score($user_id);
             $my_score_denom = $score[1] == 0 ? 1 : $score[1];
             $item_value += $score[0] / $my_score_denom * $item->get_weight();
             $item_total += $item->get_weight();
         }
         $item_value = number_format($item_value, 2, '.', ' ');
         $total_score = array($item_value, $item_total);
         $scorecourse_display = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT);
         $cattotal = Category::load(0);
         $scoretotal = $cattotal[0]->calc_score(api_get_user_id());
         $scoretotal_display = isset($scoretotal) ? $scoredisplay->display_score($scoretotal, SCORE_PERCENT) : get_lang('NoResultsAvailable');
         $scoreinfo = get_lang('StatsStudent') . ' :<b> ' . api_get_person_name($user['firstname'], $user['lastname']) . '</b><br />';
         if (!$catobj->get_id() == '0' && !isset($_GET['studentoverview']) && !isset($_GET['search'])) {
             $scoreinfo .= '<h2>' . get_lang('Total') . ' : ' . $scorecourse_display . '</h2>';
         }
         Display::display_normal_message($scoreinfo, false);
     }
     // show navigation tree and buttons?
     $header = '<div class="actions"><table border=0>';
     if ($showtree == '1' || isset($_GET['studentoverview'])) {
         $header .= '<tr>';
         if (!$selectcat == '0') {
             $header .= '<td style=" "><a href="' . api_get_self() . '?selectcat=' . $catobj->get_parent_id() . '">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('RootCat'), '', ICON_SIZE_MEDIUM) . '</a></td>';
         }
         $header .= '<td style=" ">' . get_lang('CurrentCategory') . '</td>' . '<td style=" "><form name="selector"><select name="selectcat" onchange="document.selector.submit()">';
         $cats = Category::load();
         $tree = $cats[0]->get_tree();
         unset($cats);
         foreach ($tree as $cat) {
             for ($i = 0; $i < $cat[2]; $i++) {
                 $line .= '&mdash;';
             }
             $line = isset($line) ? $line : '';
             if (isset($_GET['selectcat']) && $_GET['selectcat'] == $cat[0]) {
                 $header .= '<option selected value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>';
             } else {
                 $header .= '<option value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>';
             }
             $line = '';
         }
         $header .= '</select></form></td>';
         if (!empty($simple_search_form) && $message_resource === false) {
             $header .= '<td style="vertical-align: top;">' . $simple_search_form->toHtml() . '</td>';
         } else {
             $header .= '<td></td>';
         }
         if ($is_course_admin && $message_resource === false && $_GET['selectcat'] != 0) {
             /* $header .= '<td style="vertical-align: top;"><a href="gradebook_flatview.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() . '"><img src="../img/view_list.gif" alt="' . get_lang('FlatView') . '" /> ' . get_lang('FlatView') . '</a>';
                if ($is_course_admin && $message_resource===false) {
                $header .= '<td style="vertical-align: top;"><a href="gradebook_scoring_system.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() .'"><img src="../img/acces_tool.gif" alt="' . get_lang('ScoreEdit') . '" /> ' . get_lang('ScoreEdit') . '</a>';
                } */
         } elseif (!isset($_GET['studentoverview'])) {
             if ($message_resource === false) {
                 //$header .= '<td style="vertical-align: top;"><a href="'.api_get_self().'?'.api_get_cidreq().'&studentoverview=&selectcat=' . $catobj->get_id() . '"><img src="../img/view_list.gif" alt="' . get_lang('FlatView') . '" /> ' . get_lang('FlatView') . '</a>';
             }
         } else {
             $header .= '<td style="vertical-align: top;"><a href="' . api_get_self() . '?' . api_get_cidreq() . '&studentoverview=&exportpdf=&selectcat=' . $catobj->get_id() . '" target="_blank"><img src="../img/icons/32/pdf.png" alt="' . get_lang('ExportPDF') . '" /> ' . get_lang('ExportPDF') . '</a>';
         }
         $header .= '</td></tr>';
     }
     $header .= '</table></div>';
     // for course admin & platform admin add item buttons are added to the header
     $header .= '<div class="actions">';
     $my_category = $catobj->shows_all_information_an_category($catobj->get_id());
     $user_id = api_get_user_id();
     $course_code = $my_category['course_code'];
     $status_user = api_get_status_of_user_in_course($user_id, $course_code);
     //$header .= '<a href="gradebook_add_cat.php?'.api_get_cidreq().'&selectcat=0"><img src="../img/folder_new.gif" alt="' . get_lang('AddGradebook') . '" /></a></td>';
     if (api_is_allowed_to_edit(null, true)) {
         if ($selectcat == '0') {
             if ($show_add_qualification === true) {
             }
             if ($show_add_link) {
                 //$header .= '<td><a href="gradebook_add_eval.php?'.api_get_cidreq().'"><img src="../img/filenew.gif" alt="' . get_lang('NewEvaluation') . '" /> ' . get_lang('NewEvaluation') . '</a>';
             }
         } else {
             if ($show_add_qualification === true && $message_resource === false) {
                 //$header .= '<a href="gradebook_add_cat.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() . '" ><img src="../img/folder_new.gif" alt="' . get_lang('NewSubCategory') . '" align="absmiddle" /> ' . get_lang('NewSubCategory') . '</a></td>';
             }
             $my_category = $catobj->shows_all_information_an_category($catobj->get_id());
             $my_api_cidreq = api_get_cidreq();
             if ($my_api_cidreq == '') {
                 $my_api_cidreq = 'cidReq=' . $my_category['course_code'];
             }
             if ($show_add_link && !$message_resource) {
                 //$header .= '<td><a href="gradebook_add_eval.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '" >'.Display::return_icon('new_evaluation.png', get_lang('NewEvaluation'),'',ICON_SIZE_MEDIUM).'</a>';
                 $cats = Category::load($selectcat);
                 if ($cats[0]->get_course_code() != null && !$message_resource) {
                     //$header .= '<td><a href="gradebook_add_link.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() . '"><img src="../img/link.gif" alt="' . get_lang('MakeLink') . '" align="absmiddle" /> ' . get_lang('MakeLink') . '</a>';
                     //$header .= '<td><a href="gradebook_add_link.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'),'',ICON_SIZE_MEDIUM).'</a>';
                 } else {
                     //	$header .= '<td><a href="gradebook_add_link_select_course.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'),'',ICON_SIZE_MEDIUM).'</a>';
                 }
             }
             if (!$message_resource) {
                 $myname = $catobj->shows_all_information_an_category($catobj->get_id());
                 $my_course_id = api_get_course_id();
                 $my_file = substr($_SESSION['gradebook_dest'], 0, 5);
                 $header .= '<td style="vertical-align: top;"><a href="gradebook_flatview.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' . Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM) . '</a>';
                 $header .= '<td style="vertical-align: top;"><a href="gradebook_display_certificate.php?' . $my_api_cidreq . '&amp;cat_id=' . (int) $_GET['selectcat'] . '">' . Display::return_icon('certificate_list.png', get_lang('GradebookSeeListOfStudentsCertificates'), '', ICON_SIZE_MEDIUM) . '</a>';
                 $visibility_icon = $catobj->is_visible() == 0 ? 'invisible' : 'visible';
                 $visibility_command = $catobj->is_visible() == 0 ? 'set_visible' : 'set_invisible';
                 //Right icons
                 $modify_icons = '<a href="gradebook_edit_cat.php?editcat=' . $catobj->get_id() . '&cidReq=' . $catobj->get_course_code() . '&id_session=' . $catobj->get_session_id() . '">' . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM) . '</a>';
                 //$modify_icons .= '<a href="../document/document.php?curdirpath=/certificates&'.$my_api_cidreq.'&origin=gradebook&selectcat=' . $catobj->get_id() . '">'.
                 //Display::return_icon('certificate.png', get_lang('AttachCertificate'),'',ICON_SIZE_MEDIUM).'</a>';
                 //hide or delete are not options available
                 //$modify_icons .= '&nbsp;<a  href="' . api_get_self() . '?visiblecat=' . $catobj->get_id() . '&amp;' . $visibility_command . '=&amp;selectcat=0 ">'.Display::return_icon($visibility_icon.'.png', get_lang('Visible'),'',ICON_SIZE_MEDIUM).'</a>';
                 if ($catobj->get_name() != api_get_course_id()) {
                     $modify_icons .= '&nbsp;<a  href="' . api_get_self() . '?deletecat=' . $catobj->get_id() . '&amp;selectcat=0&amp;cidReq=' . $catobj->get_course_code() . '" onclick="return confirmation();">' . Display::return_icon('delete.png', get_lang('DeleteAll'), '', ICON_SIZE_MEDIUM) . '</a>';
                 }
                 $header .= Display::div($modify_icons, array('class' => 'right'));
             }
         }
     } elseif (isset($_GET['search'])) {
         $header .= '<b>' . get_lang('SearchResults') . ' :</b>';
     }
     $header .= '</div>';
     echo $header;
 }
예제 #3
0
$alllinks = $category[0]->get_links($my_user_id, true);
if ($_GET['selectcat'] != null) {
    $addparams = array('userid' => $my_user_id, 'selectcat' => Security::remove_XSS($_GET['selectcat']));
} else {
    $addparams = array('userid' => $my_user_id, 'selecteval' => Security::remove_XSS($_GET['selecteval']));
}
$user_table = new UserTable($my_user_id, $allevals, $alllinks, $addparams);
if (isset($_GET['exportpdf'])) {
    $datagen = new UserDataGenerator($my_user_id, $allevals, $alllinks);
    $data_array = $datagen->get_data(UserDataGenerator::UDG_SORT_NAME, 0, null, true);
    $newarray = array();
    $displayscore = Scoredisplay::instance();
    foreach ($data_array as $data) {
        $newarray[] = array_slice($data, 1);
    }
    $userinfo = get_user_info_from_id($my_user_id);
    $html .= get_lang('Results') . ' : ' . api_get_person_name($userinfo['firstname'], $userinfo['lastname']) . ' (' . api_convert_and_format_date(null, DATE_FORMAT_SHORT) . ' ' . api_convert_and_format_date(null, TIME_NO_SEC_FORMAT) . ')';
    if ($displayscore->is_custom()) {
        $header_names = array(get_lang('Evaluation'), get_lang('Course'), get_lang('Category'), get_lang('EvaluationAverage'), get_lang('Result'), get_lang('Display'));
    } else {
        $header_names = array(get_lang('Evaluation'), get_lang('Course'), get_lang('Category'), get_lang('EvaluationAverage'), get_lang('Result'));
    }
    $table = new HTML_Table(array('class' => 'data_table'));
    $row = 0;
    $column = 0;
    foreach ($header_names as $item) {
        $table->setHeaderContents($row, $column, $item);
        $column++;
    }
    $row = 1;
    if (!empty($newarray)) {
}
if (isset($_GET['overwritemax'])) {
    Display::display_warning_message(get_lang('OverWriteMax'), false);
}
if (isset($_GET['importoverwritescore'])) {
    Display::display_confirmation_message(get_lang('ImportOverWriteScore') . ' ' . $_GET['importoverwritescore']);
}
if (isset($_GET['import_user_error'])) {
    $userinfo = get_user_info_from_id($_GET['import_user_error']);
    Display::display_warning_message(get_lang('UserInfoDoesNotMatch') . ' ' . api_get_person_name($userinfo['firstname'], $userinfo['lastname']));
}
if (isset($_GET['allresdeleted'])) {
    Display::display_confirmation_message(get_lang('AllResultDeleted'));
}
if (isset($_GET['import_score_error'])) {
    $userinfo = get_user_info_from_id($_GET['import_score_error']);
    Display::display_warning_message(get_lang('ScoreDoesNotMatch') . ' ' . api_get_person_name($userinfo['firstname'], $userinfo['lastname']));
}
if ($file_type == null) {
    //show the result header
    if (isset($export_result_form) && !isset($edit_res_form)) {
        echo $export_result_form->display();
        DisplayGradebook::display_header_result($eval[0], $currentcat[0]->get_id(), 1);
    } else {
        if (isset($import_result_form)) {
            echo $import_result_form->display();
        }
        if (isset($edit_res_form)) {
            echo $edit_res_form->toHtml();
        }
        DisplayGradebook::display_header_result($eval[0], $currentcat[0]->get_id(), 1);
예제 #5
0
    /**
     * This function builds a form to edit all results in an evaluation
     */
    protected function build_all_results_edit_form()
    {
        //extra field for check on maxvalue
        $this->addElement('hidden', 'maxvalue', $this->evaluation_object->get_max());
        $this->addElement('hidden', 'minvalue', 0);
        $this->addElement('header', get_lang('EditResult'));
        $renderer =& $this->defaultRenderer();
        // set new form template
        $form_template = '<form{attributes}>
                    <table class="data_table" border="0" cellpadding="5" cellspacing="5">{content}
                    </table>
                </form>';
        $renderer->setFormTemplate($form_template);
        if (api_is_western_name_order()) {
            $renderer->setHeaderTemplate('<tr>
    		       <th>' . get_lang('OfficialCode') . '</th>
    		      <th>' . get_lang('UserName') . '</th>
    		      <th>' . get_lang('FirstName') . '</th>
    		      <th>' . get_lang('LastName') . '</th>
    		      <th>' . get_lang('Qualify') . '</th>
    		   </tr>');
        } else {
            $renderer->setHeaderTemplate('<tr>
                   <th>' . get_lang('OfficialCode') . '</th>
                  <th>' . get_lang('UserName') . '</th>
                  <th>' . get_lang('LastName') . '</th>
                  <th>' . get_lang('FirstName') . '</th>
                  <th>' . get_lang('Qualify') . '</th>
               </tr>');
        }
        $template_submit = '<tr>
			       <td colspan="4" ></td>
			      <td >
			       {element}
			         <!-- BEGIN error --><br /><span style="color: #ff0000;font-size:10px">{error}</span><!-- END error -->
			      </td>
			   </tr>';
        $results_and_users = array();
        foreach ($this->result_object as $result) {
            $user = get_user_info_from_id($result->get_user_id());
            $results_and_users[] = array('result' => $result, 'user' => $user);
        }
        usort($results_and_users, array('EvalForm', 'sort_by_user'));
        $defaults = array();
        foreach ($results_and_users as $result_and_user) {
            $user = $result_and_user['user'];
            $result = $result_and_user['result'];
            $renderer =& $this->defaultRenderer();
            $this->add_textfield('score[' . $result->get_id() . ']', $this->build_stud_label($user['user_id'], $user['username'], $user['lastname'], $user['firstname']), false, array('class' => "span2", 'maxlength' => 5));
            $this->addRule('score[' . $result->get_id() . ']', get_lang('OnlyNumbers'), 'numeric');
            $this->addRule(array('score[' . $result->get_id() . ']', 'maxvalue'), get_lang('OverMax'), 'compare', '<=');
            $this->addRule(array('score[' . $result->get_id() . ']', 'minvalue'), get_lang('UnderMin'), 'compare', '>=');
            $defaults['score[' . $result->get_id() . ']'] = $result->get_score();
            if (api_is_western_name_order()) {
                $user_info = '<td align="left" >' . $user['firstname'] . '</td>';
                $user_info .= '<td align="left" >' . $user['lastname'] . '</td>';
            } else {
                $user_info = '<td align="left" >' . $user['lastname'] . '</td>';
                $user_info .= '<td align="left" >' . $user['firstname'] . '</td>';
            }
            $template = '<tr>
		      <td align="left" >' . $user['official_code'] . '</td>
		      <td align="left" >' . $user['username'] . '</td>
		      ' . $user_info . '
		       <td align="left">{element} / ' . $this->evaluation_object->get_max() . '
		         <!-- BEGIN error --><br /><span style="color: #ff0000;font-size:10px">{error}</span><!-- END error -->
		      </td>
		   </tr>';
            $renderer->setElementTemplate($template, 'score[' . $result->get_id() . ']');
        }
        $this->setDefaults($defaults);
        $this->addElement('style_submit_button', 'submit', get_lang('EditResult'), 'class="save"');
        $renderer->setElementTemplate($template_submit, 'submit');
    }
예제 #6
0
        $pdf->line(50, 790, 550, 790);
        $pdf->line(50, 40, 550, 40);
        $pdf->ezSetY(750);
        $pdf->ezTable($newarray, $header_names, '', array('showHeadings' => 1, 'shaded' => 1, 'showLines' => 1, 'rowGap' => 3, 'width' => 500));
        $pdf->ezStream();
        exit;
    }
} elseif (!empty($_GET['export_certificate'])) {
    //@todo this code seems not to be used
    $user_id = strval(intval($_GET['user']));
    if (!api_is_allowed_to_edit(true, true)) {
        $user_id = api_get_user_id();
    }
    $category = Category::load($_GET['cat_id']);
    if ($category[0]->is_certificate_available($user_id)) {
        $user = get_user_info_from_id($user_id);
        $scoredisplay = ScoreDisplay::instance();
        $scorecourse = $category[0]->calc_score($user_id);
        $scorecourse_display = isset($scorecourse) ? $scoredisplay->display_score($scorecourse, SCORE_AVERAGE) : get_lang('NoResultsAvailable');
        $cattotal = Category::load(0);
        $scoretotal = $cattotal[0]->calc_score($user_id);
        $scoretotal_display = isset($scoretotal) ? $scoredisplay->display_score($scoretotal, SCORE_PERCENT) : get_lang('NoResultsAvailable');
        //prepare all necessary variables:
        $organization_name = api_get_setting('Institution');
        $portal_name = api_get_setting('siteName');
        $stud_fn = $user['firstname'];
        $stud_ln = $user['lastname'];
        $certif_text = sprintf(get_lang('CertificateWCertifiesStudentXFinishedCourseYWithGradeZ'), $organization_name, $stud_fn . ' ' . $stud_ln, $category[0]->get_name(), $scorecourse_display);
        $certif_text = str_replace("\\n", "\n", $certif_text);
        $date = api_convert_and_format_date(null, DATE_FORMAT_SHORT);
        $pdf = new Cezpdf('a4', 'landscape');