function export($from, $to) { $productId = $this->common->getCurrentProduct()->id; $productName = $this->common->getCurrentProduct()->name; $data = $this->device->getDeviceTypeDetail($productId); $this->load->library('export'); $export = new Export(); //设定文件名 $export->setFileName($productName . '_' . $from . '_' . $to . '.csv'); //输出列名第一种方法 $fields = array(); foreach ($data->list_fields() as $field) { array_push($fields, $field); } $export->setTitle($fields); //输出列名第二种方法 // $excel_title = array (iconv("UTF-8", "GBK", "设备型号"),iconv("UTF-8", "GBK", "总数"),iconv("UTF-8", "GBK", "用户比例") ); // $export->setTitle ($excel_title ); //输出内容 foreach ($data->result() as $row) { $export->addRow($row); } $export->export(); die; }
public function actionIndex() { //registering js file Yii::app()->clientScript->registerScriptFile(Yii::app()->assetManager->publish(Yii::getPathOfAlias('application.modules.export.assets') . '/js/jquery-ui.1.10.4.js')); $models = Yii::app()->controller->module->allowedModels; if ($models == NULL) { foreach (glob('./protected/models/*.php') as $filename) { $modelname = str_replace(array("./protected/models/", ".php"), "", $filename); $models[$modelname]['label'] = $modelname; } } $modelsArray = array(); foreach ($models as $mindex => $smodel) { $modelsArray[$mindex] = isset($smodel['label']) ? $smodel['label'] : $mindex; } if (isset($_POST['export-database'])) { if (isset($_POST['reqColumns']) and count($_POST['reqColumns']) > 0) { $model = $_POST['model']; $format = 'csv'; if (in_array($model, array_keys($modelsArray))) { $export = new Export(); if (!$export->exportdb($format, $model, $_POST['reqColumns'])) { $this->redirect(array('index')); } } else { Yii::app()->user->setFlash('exporterror', 'You are not allowed to access this model !!'); $this->redirect(array('index')); } } else { Yii::app()->user->setFlash('exporterror', 'Choose columns to export !!'); $this->redirect(array('index')); } } $this->render('index', array('modelsArray' => $modelsArray)); }
function export($from, $to) { $this->load->library('export'); $productId = $this->common->getCurrentProduct()->id; $productName = $this->common->getCurrentProduct()->name; $data = $this->os->getTotalUserPercentByOS($productId); $export = new Export(); //设定文件名 $export->setFileName($productName . '.csv'); // //输出列名第一种方法 $fields = array(); foreach ($data->list_fields() as $field) { array_push($fields, $field); } $export->setTitle($fields); //输出列名第二种方法 // $excel_title = array (iconv("UTF-8", "GBK", "操作系统版本"),iconv("UTF-8", "GBK", "用户比例") ); // $export->setTitle ($excel_title ); //输出内容 foreach ($data->result() as $row) { $export->addRow($row); } $export->export(); die; }
function trigger_salsa_db_date($jaguar_model, $date) { global $DB; foreach ($jaguar_model as $jaguar) { $row = $DB->query('select * from export where model = "' . $jaguar . '" ')->fetch_array(MYSQLI_ASSOC); $export = new Export($row); $export->reset_export_date($date); } }
/** * @param $id * @return Export * @throws CHttpException */ public function loadModel($id) { $model = Export::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, Yii::t('YmlModule.default', 'Page not found!')); } return $model; }
public function addProductLine($product, $template, $params = false) { $product = parent::addProductLine($product, $template, $params); $line = array(); foreach ($product as $fieldData) { $field = $fieldData['field']; $data = $fieldData['data']; $value = $data['value']; $before = $data['before']; $after = $data['after']; $value = ($before !== false ? $before : '') . $value . ($after !== false ? $after : ''); array_push($line, self::prepareValueForCsv($value)); } $this->_fileContents[] = implode(self::$_delimiter, $line); }
public function actionView($id) { $model = Export::model()->findByPk($id); if (false === $model) { throw new CHttpException(404); } $criteria = new CDbCriteria(); $criteria->compare('t.status', Product::STATUS_ACTIVE); if (!empty($model->categories)) { $criteria->addInCondition('t.category_id', (array) $model->categories); } if (!empty($model->brands)) { $criteria->addInCondition('t.producer_id', (array) $model->brands); } $dataProvider = new CActiveDataProvider('Product', ['criteria' => $criteria]); $offers = new CDataProviderIterator($dataProvider, 100); ContentType::setHeader(ContentType::TYPE_XML); $this->renderPartial('view', ['model' => $model, 'currencies' => Yii::app()->getModule('store')->getCurrencyList(), 'categories' => StoreCategory::model()->published()->findAll(), 'offers' => $offers]); }
public function actionView($id) { /* @var $model Export */ $model = Export::model()->findByPk($id); if (!$model) { throw new CHttpException(404); } $cacheKey = $this->cacheKey . $model->id; if (!($xml = Yii::app()->getCache()->get($cacheKey))) { $xml = $this->getXmlHead(); $xml .= CHtml::openTag('yml_catalog', ['date' => date('Y-m-d H:i')]); $xml .= CHtml::openTag('shop'); $xml .= $this->getShopInfo($model->shop_name, $model->shop_company, $model->shop_url ?: Yii::app()->getBaseUrl(true), $model->shop_platform, $model->shop_version, $model->shop_agency, $model->shop_email, $model->shop_cpa); $xml .= $this->getCurrenciesElement([['id' => 'RUR', 'rate' => 1]]); $xml .= $this->getCategoriesElement(); $xml .= $this->getOffersElement($model->categories, $model->brands); $xml .= CHtml::closeTag('shop'); $xml .= CHtml::closeTag('yml_catalog'); Yii::app()->getCache()->set($cacheKey, $xml, 60 * 60); } header("Content-type: text/xml"); echo $xml; Yii::app()->end(); }
private function export($res) { header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=persons_list_' . date('Ymd') . '.csv'); $contents = array(); $title = array(); $fp = fopen('php://output', 'w'); fputs($fp, $bom = chr(0xef) . chr(0xbb) . chr(0xbf)); $k = 0; foreach ($res as $row) { $fields = \Export::person_field($row); foreach ($fields as $field => $val) { $title[$k][] = preg_replace('/_[0-9]+$/', '', $field); $contents[$k][] = $val; } if ($k == 0) { fputcsv($fp, $title[$k]); } fputcsv($fp, $contents[$k]); ++$k; } fclose($fp); exit; }
$tool_name = get_lang('ImportGlossary'); break; case 'changeview': $tool_name = get_lang('List'); break; } if (isset($_GET['action']) && $_GET['action'] == 'export') { $data = GlossaryManager::get_glossary_data(0, GlossaryManager::get_number_glossary_terms(api_get_session_id()), 0, 'ASC'); usort($data, "sorter"); $list = array(); $list[] = array('term', 'definition'); foreach ($data as $line) { $list[] = array($line[0], $line[1]); } $filename = 'glossary_course_' . api_get_course_id(); Export::export_table_csv_utf8($list, $filename); } if (isset($_GET['action']) && $_GET['action'] == 'export_to_pdf') { GlossaryManager::export_to_pdf(); } Display::display_header($tool_name); // Tool introduction Display::display_introduction_section(TOOL_GLOSSARY); if (isset($_GET['action']) && $_GET['action'] == 'changeview' and in_array($_GET['view'], array('list', 'table'))) { $_SESSION['glossary_view'] = $_GET['view']; } else { if (!isset($_SESSION['glossary_view'])) { $_SESSION['glossary_view'] = 'table'; //Default option } }
public function destroy($export_id) { $export = Export::findOrFail($export_id); $export->delete(); return Redirect::to(action('ExportsController@index'))->with('message', ['content' => 'Export verwijderd.', 'class' => 'danger']); }
} else { $csv_header[] = array(get_lang('LastName'), get_lang('FirstName'), get_lang('FirstLogin'), get_lang('LastConnexion')); } } $form = new FormValidator('search_user', 'get', api_get_path(WEB_CODE_PATH) . 'mySpace/student.php'); $form = Tracking::setUserSearchForm($form); $form->setDefaults($params); if ($export_csv) { // send the csv file if asked $content = $table->get_table_data(); foreach ($content as &$row) { unset($row[4]); } $csv_content = array_merge($csv_header, $content); ob_end_clean(); Export::arrayToCsv($csv_content, 'reporting_student_list'); exit; } else { Display::display_header($nameTools); echo $actions; $page_title = get_lang('Students'); echo Display::page_subheader($page_title); if (isset($active)) { if ($active) { $activeLabel = get_lang('ActiveUsers'); } else { $activeLabel = get_lang('InactiveUsers'); } echo Display::page_subheader2($activeLabel); } $form->display();
$extra = '<div style="text-align:center"><h2>' . get_lang('GroupList') . '</h2></div>'; $extra .= '<strong>' . get_lang('Course') . ': </strong>' . $courseInfo['title'] . ' (' . $courseInfo['code'] . ')'; $content = $extra . $content; $pdf->content_to_pdf($content, null, null, api_get_course_id()); break; case 'export': $groupId = isset($_GET['id']) ? intval($_GET['id']) : null; $data = GroupManager::exportCategoriesAndGroupsToArray($groupId, true); switch ($_GET['type']) { case 'csv': Export::export_table_csv($data); exit; break; case 'xls': if (!empty($data)) { Export::export_table_xls($data); exit; } break; } break; } } /* Header */ $interbreadcrumb[] = array('url' => 'group.php', 'name' => get_lang('Groups')); if (!isset($_GET['origin']) || $_GET['origin'] != 'learnpath') { // So we are not in learnpath tool if (!$is_allowed_in_course) { api_not_allowed(true); } if (!api_is_allowed_to_edit(false, true)) {
switch ($exportFormat) { case 'xls': //TODO add date if exists $file_name = !empty($action) ? $action : 'company_report'; $browser = new Browser(); if ($browser->getPlatform() == Browser::PLATFORM_WINDOWS) { Export::export_table_xls_html($array, $file_name, 'ISO-8859-15'); } else { Export::export_table_xls_html($array, $file_name); } break; case 'csv': default: //TODO add date if exists $file_name = !empty($action) ? $action : 'company_report'; Export::arrayToCsv($array, $file_name); break; } exit; } $i = 0; if (!empty($result)) { foreach ($result as $row) { // if results tab give not id, set id to $i otherwise id="null" for all <tr> of the jqgrid - ref #4235 if (!isset($row['id']) || isset($row['id']) && $row['id'] == '') { $response->rows[$i]['id'] = $i; } else { $response->rows[$i]['id'] = $row['id']; } $array = array(); foreach ($columns as $col) {
/** * It's used to print attendance sheet * @param string action * @param int attendance id */ public function attendance_sheet_export_to_pdf($action, $attendance_id, $student_id = 0, $course_id = '') { $attendance = new Attendance(); $courseInfo = CourseManager::get_course_information($course_id); $attendance->set_course_id($courseInfo['code']); $data_array = array(); $data_array['attendance_id'] = $attendance_id; $data_array['users_in_course'] = $attendance->get_users_rel_course($attendance_id); $filter_type = 'today'; if (!empty($_REQUEST['filter'])) { $filter_type = $_REQUEST['filter']; } $my_calendar_id = null; if (is_numeric($filter_type)) { $my_calendar_id = $filter_type; $filter_type = 'calendar_id'; } $data_array['attendant_calendar'] = $attendance->get_attendance_calendar($attendance_id, $filter_type, $my_calendar_id); if (api_is_allowed_to_edit(null, true) || api_is_drh()) { $data_array['users_presence'] = $attendance->get_users_attendance_sheet($attendance_id); } else { if (!empty($student_id)) { $user_id = intval($student_id); } else { $user_id = api_get_user_id(); } $data_array['users_presence'] = $attendance->get_users_attendance_sheet($attendance_id, $user_id); $data_array['faults'] = $attendance->get_faults_of_user($user_id, $attendance_id); $data_array['user_id'] = $user_id; } $data_array['next_attendance_calendar_id'] = $attendance->get_next_attendance_calendar_id($attendance_id); //Set headers pdf $courseCategory = CourseManager::get_course_category($courseInfo['category_code']); $teacherInfo = CourseManager::get_teacher_list_from_course_code($courseInfo['real_id']); $teacherName = null; foreach ($teacherInfo as $dados) { if ($teacherName != null) { $teacherName = $teacherName . " / "; } $teacherName .= $dados['firstname'] . " " . $dados['lastname']; } // Get data table - Marco - ordenacao fixa - just fullname $data_table = array(); $head_table = array('#', get_lang('Name')); foreach ($data_array['attendant_calendar'] as $class_day) { //$head_table[] = api_format_date($class_day['date_time'], DATE_FORMAT_SHORT).' <br />'.api_format_date($class_day['date_time'], TIME_NO_SEC_FORMAT); $head_table[] = api_format_date($class_day['date_time'], DATE_FORMAT_NUMBER_NO_YEAR); } $data_table[] = $head_table; $dataClass = array(); $max_dates_per_page = 10; $data_attendant_calendar = $data_array['attendant_calendar']; $data_users_presence = $data_array['users_presence']; $count = 1; if (!empty($data_array['users_in_course'])) { foreach ($data_array['users_in_course'] as $user) { $cols = 1; $result = array(); $result['count'] = $count; $result['full_name'] = api_get_person_name($user['firstname'], $user['lastname']); foreach ($data_array['attendant_calendar'] as $class_day) { if ($class_day['done_attendance'] == 1) { if ($data_users_presence[$user['user_id']][$class_day['id']]['presence'] == 1) { $result[$class_day['id']] = get_lang('UserAttendedSymbol'); } else { $result[$class_day['id']] = get_lang('UserNotAttendedSymbol'); } } else { $result[$class_day['id']] = " "; } $cols++; } $count++; $data_table[] = $result; } } $max_cols_per_page = 12; //10 dates + 2 name and number $max_dates_per_page = $max_dates_per_page_original = $max_cols_per_page - 2; //10 $rows = count($data_table); if ($cols > $max_cols_per_page) { $number_tables = round(($cols - 2) / $max_dates_per_page); $headers = $data_table[0]; $all = array(); $tables = array(); $changed = 1; for ($i = 0; $i <= $rows; $i++) { $row = $data_table[$i]; $key = 1; $max_dates_per_page = 10; $item = $data_table[$i]; $count_j = 0; if (!empty($item)) { foreach ($item as $value) { if ($count_j >= $max_dates_per_page) { $key++; $max_dates_per_page = $max_dates_per_page_original * $key; //magic hack $tables[$key][$i][] = $tables[1][$i][0]; $tables[$key][$i][] = $tables[1][$i][1]; } $tables[$key][$i][] = $value; $count_j++; } } } $content = null; if (!empty($tables)) { foreach ($tables as $sub_table) { $content .= Export::convert_array_to_html($sub_table) . '<br /><br />'; } } } else { $content .= Export::convert_array_to_html($data_table, array('header_attributes' => array('align' => 'center'))); } $params = array('filename' => get_lang('Attendance') . '-' . api_get_local_time(), 'pdf_title' => $courseInfo['title'], 'course_code' => $courseInfo['code'], 'add_signatures' => true, 'orientation' => 'landscape', 'pdf_teachers' => $teacherName, 'pdf_course_category' => $courseCategory['name'], 'format' => 'A4-L', 'orientation' => 'L'); Export::export_html_to_pdf($content, $params); exit; }
/** * @param int $user_id * @param array $courseInfo * @param int $session_id * @param string $origin * @param bool $export_csv * @param int $lp_id * @param int $lp_item_id * @param int $extendId * @param int $extendAttemptId * @param string $extendedAttempt * @param string $extendedAll * @param string $type classic or simple * @param boolean $allowExtend Optional. Allow or not extend te results * @return null|string */ public static function getLpStats($user_id, $courseInfo, $session_id, $origin, $export_csv, $lp_id, $lp_item_id = null, $extendId = null, $extendAttemptId = null, $extendedAttempt = null, $extendedAll = null, $type = 'classic', $allowExtend = true) { if (empty($courseInfo) || empty($lp_id)) { return null; } $lp_id = intval($lp_id); $lp_item_id = intval($lp_item_id); $user_id = intval($user_id); $session_id = intval($session_id); $origin = Security::remove_XSS($origin); $list = learnpath::get_flat_ordered_items_list($lp_id, 0, $courseInfo['real_id']); $is_allowed_to_edit = api_is_allowed_to_edit(null, true); $course_id = $courseInfo['real_id']; $courseCode = $courseInfo['code']; $session_condition = api_get_session_condition($session_id); // Extend all button $output = null; $extend_all = 0; if ($origin == 'tracking') { $url_suffix = '&session_id=' . $session_id . '&course=' . $courseCode . '&student_id=' . $user_id . '&lp_id=' . $lp_id . '&origin=' . $origin; } else { $url_suffix = '&lp_id=' . $lp_id; } if (!empty($extendedAll)) { $extend_all_link = Display::url(Display::return_icon('view_less_stats.gif', get_lang('HideAllAttempts')), api_get_self() . '?action=stats' . $url_suffix); $extend_all = 1; } else { $extend_all_link = Display::url(Display::return_icon('view_more_stats.gif', get_lang('ShowAllAttempts')), api_get_self() . '?action=stats&extend_all=1' . $url_suffix); } if ($origin != 'tracking') { $output .= '<div class="section-status">'; $output .= Display::page_header(get_lang('ScormMystatus')); $output .= '</div>'; } $actionColumn = null; if ($type == 'classic') { $actionColumn = ' <th>' . get_lang('Actions') . '</th>'; } $output .= '<div class="table-responsive">'; $output .= '<table class="table tracking"> <thead> <tr class="table-header"> <th width="16">' . ($allowExtend == true ? $extend_all_link : ' ') . '</th> <th colspan="4"> ' . get_lang('ScormLessonTitle') . ' </th> <th colspan="2"> ' . get_lang('ScormStatus') . ' </th> <th colspan="2"> ' . get_lang('ScormScore') . ' </th> <th colspan="2"> ' . get_lang('ScormTime') . ' </th> ' . $actionColumn . ' </tr> </thead> <tbody> '; // Going through the items using the $items[] array instead of the database order ensures // we get them in the same order as in the imsmanifest file, which is rather random when using // the database table. $TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM); $TBL_LP_ITEM_VIEW = Database::get_course_table(TABLE_LP_ITEM_VIEW); $TBL_LP_VIEW = Database::get_course_table(TABLE_LP_VIEW); $tbl_quiz_questions = Database::get_course_table(TABLE_QUIZ_QUESTION); $TBL_QUIZ = Database::get_course_table(TABLE_QUIZ_TEST); $tbl_stats_exercices = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); $tbl_stats_attempts = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); $sql = "SELECT max(view_count)\n FROM {$TBL_LP_VIEW}\n WHERE\n c_id = {$course_id} AND\n lp_id = {$lp_id} AND\n user_id = {$user_id}\n {$session_condition}"; $res = Database::query($sql); $view = ''; if (Database::num_rows($res) > 0) { $myrow = Database::fetch_array($res); $view = $myrow[0]; } $counter = 0; $total_time = 0; $h = get_lang('h'); if (!empty($export_csv)) { $csv_content[] = array(get_lang('ScormLessonTitle'), get_lang('ScormStatus'), get_lang('ScormScore'), get_lang('ScormTime')); } $result_disabled_ext_all = true; $chapterTypes = learnpath::getChapterTypes(); // Show lp items if (is_array($list) && count($list) > 0) { foreach ($list as $my_item_id) { $extend_this = 0; $order = 'DESC'; if (!empty($extendId) && $extendId == $my_item_id || $extend_all) { $extend_this = 1; $order = 'ASC'; } // Prepare statement to go through each attempt. $viewCondition = null; if (!empty($view)) { $viewCondition = " AND v.view_count = {$view} "; } $sql = "SELECT\n iv.status as mystatus,\n v.view_count as mycount,\n iv.score as myscore,\n iv.total_time as mytime,\n i.id as myid,\n i.lp_id as mylpid,\n iv.lp_view_id as mylpviewid,\n i.title as mytitle,\n i.max_score as mymaxscore,\n iv.max_score as myviewmaxscore,\n i.item_type as item_type,\n iv.view_count as iv_view_count,\n iv.id as iv_id,\n path\n FROM {$TBL_LP_ITEM} as i\n INNER JOIN {$TBL_LP_ITEM_VIEW} as iv\n ON (i.id = iv.lp_item_id AND i.c_id = iv.c_id)\n INNER JOIN {$TBL_LP_VIEW} as v\n ON (iv.lp_view_id = v.id AND v.c_id = iv.c_id)\n WHERE\n v.c_id = {$course_id} AND\n i.id = {$my_item_id} AND\n i.lp_id = {$lp_id} AND\n v.user_id = {$user_id} AND\n v.session_id = {$session_id}\n {$viewCondition}\n ORDER BY iv.view_count {$order} "; $result = Database::query($sql); $num = Database::num_rows($result); $time_for_total = 'NaN'; // Extend all if (($extend_this || $extend_all) && $num > 0) { $row = Database::fetch_array($result); $result_disabled_ext_all = false; if ($row['item_type'] == 'quiz') { // Check results_disabled in quiz table. $my_path = Database::escape_string($row['path']); $sql = "SELECT results_disabled\n FROM {$TBL_QUIZ}\n WHERE\n c_id = {$course_id} AND\n id ='" . $my_path . "'"; $res_result_disabled = Database::query($sql); $row_result_disabled = Database::fetch_row($res_result_disabled); if (Database::num_rows($res_result_disabled) > 0 && (int) $row_result_disabled[0] === 1) { $result_disabled_ext_all = true; } } // If there are several attempts, and the link to extend has been clicked, show each attempt... if ($counter % 2 == 0) { $oddclass = 'row_odd'; } else { $oddclass = 'row_even'; } $extend_link = ''; if (!empty($inter_num)) { $extend_link = Display::url(Display::return_icon('visible.gif', get_lang('HideAttemptView')), api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix); } $title = $row['mytitle']; if (empty($title)) { $title = rl_get_resource_name($courseInfo['code'], $lp_id, $row['myid']); } if (in_array($row['item_type'], $chapterTypes)) { $title = "<h4> {$title} </h4>"; } $lesson_status = $row['mystatus']; $title = Security::remove_XSS($title); $counter++; $action = null; if ($type == 'classic') { $action = '<td></td>'; } if (in_array($row['item_type'], $chapterTypes)) { $output .= '<tr class="' . $oddclass . '"> <td>' . $extend_link . '</td> <td colspan="4"> ' . $title . ' </td> <td colspan="2">' . learnpathItem::humanize_status($lesson_status, true, $type) . '</td> <td colspan="2"></td> <td colspan="2"></td> ' . $action . ' </tr>'; continue; } else { $output .= '<tr class="' . $oddclass . '"> <td>' . $extend_link . '</td> <td colspan="4"> ' . $title . ' </td> <td colspan="2"></td> <td colspan="2"></td> <td colspan="2"></td> ' . $action . ' </tr>'; } $attemptCount = 1; do { // Check if there are interactions below. $extend_attempt_link = ''; $extend_this_attempt = 0; if ((learnpath::get_interactions_count_from_db($row['iv_id'], $course_id) > 0 || learnpath::get_objectives_count_from_db($row['iv_id'], $course_id) > 0) && !$extend_all) { if ($extendAttemptId == $row['iv_id']) { // The extend button for this attempt has been clicked. $extend_this_attempt = 1; $extend_attempt_link = Display::url(Display::return_icon('visible.gif', get_lang('HideAttemptView')), api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix); } else { // Same case if fold_attempt_id is set, so not implemented explicitly. // The extend button for this attempt has not been clicked. $extend_attempt_link = Display::url(Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')), api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix); } } if ($counter % 2 == 0) { $oddclass = 'row_odd'; } else { $oddclass = 'row_even'; } $lesson_status = $row['mystatus']; $score = $row['myscore']; $time_for_total = $row['mytime']; $time = learnpathItem::getScormTimeFromParameter('js', $row['mytime']); if ($score == 0) { $maxscore = $row['mymaxscore']; } else { if ($row['item_type'] == 'sco') { if (!empty($row['myviewmaxscore']) && $row['myviewmaxscore'] > 0) { $maxscore = $row['myviewmaxscore']; } elseif ($row['myviewmaxscore'] === '') { $maxscore = 0; } else { $maxscore = $row['mymaxscore']; } } else { $maxscore = $row['mymaxscore']; } } // Remove "NaN" if any (@todo: locate the source of these NaN) $time = str_replace('NaN', '00' . $h . '00\'00"', $time); if ($row['item_type'] != 'dokeos_chapter') { if (!$is_allowed_to_edit && $result_disabled_ext_all) { $view_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting')); } else { switch ($row['item_type']) { case 'sco': if ($maxscore == 0) { $view_score = $score; } else { $view_score = ExerciseLib::show_score($score, $maxscore, false); } break; case 'document': $view_score = $score == 0 ? '/' : ExerciseLib::show_score($score, $maxscore, false); break; default: $view_score = ExerciseLib::show_score($score, $maxscore, false); break; } } $action = null; if ($type == 'classic') { $action = '<td></td>'; } $output .= '<tr class="' . $oddclass . '"> <td></td> <td>' . $extend_attempt_link . '</td> <td colspan="3">' . get_lang('Attempt') . ' ' . $attemptCount . '</td> <td colspan="2">' . learnpathItem::humanize_status($lesson_status, true, $type) . '</td> <td colspan="2">' . $view_score . '</td> <td colspan="2">' . $time . '</td> ' . $action . ' </tr>'; $attemptCount++; if (!empty($export_csv)) { $temp = array(); $temp[] = $title = Security::remove_XSS($title); $temp[] = Security::remove_XSS(learnpathItem::humanize_status($lesson_status, false, $type)); if ($row['item_type'] == 'quiz') { if (!$is_allowed_to_edit && $result_disabled_ext_all) { $temp[] = '/'; } else { $temp[] = $score == 0 ? '0/' . $maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)); } } else { $temp[] = $score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)); } $temp[] = $time; $csv_content[] = $temp; } } $counter++; $action = null; if ($type == 'classic') { $action = '<td></td>'; } if ($extend_this_attempt || $extend_all) { $list1 = learnpath::get_iv_interactions_array($row['iv_id']); foreach ($list1 as $id => $interaction) { if ($counter % 2 == 0) { $oddclass = 'row_odd'; } else { $oddclass = 'row_even'; } $student_response = urldecode($interaction['student_response']); $content_student_response = explode('__|', $student_response); if (count($content_student_response) > 0) { if (count($content_student_response) >= 3) { // Pop the element off the end of array. array_pop($content_student_response); } $student_response = implode(',', $content_student_response); } $output .= '<tr class="' . $oddclass . '"> <td></td> <td></td> <td></td> <td>' . $interaction['order_id'] . '</td> <td>' . $interaction['id'] . '</td> <td colspan="2">' . $interaction['type'] . '</td> <td>' . $student_response . '</td> <td>' . $interaction['result'] . '</td> <td>' . $interaction['latency'] . '</td> <td>' . $interaction['time'] . '</td> ' . $action . ' </tr>'; $counter++; } $list2 = learnpath::get_iv_objectives_array($row['iv_id']); foreach ($list2 as $id => $interaction) { if ($counter % 2 == 0) { $oddclass = 'row_odd'; } else { $oddclass = 'row_even'; } $output .= '<tr class="' . $oddclass . '"> <td></td> <td></td> <td></td> <td>' . $interaction['order_id'] . '</td> <td colspan="2">' . $interaction['objective_id'] . '</td> <td colspan="2">' . $interaction['status'] . '</td> <td>' . $interaction['score_raw'] . '</td> <td>' . $interaction['score_max'] . '</td> <td>' . $interaction['score_min'] . '</td> ' . $action . ' </tr>'; $counter++; } } } while ($row = Database::fetch_array($result)); } elseif ($num > 0) { // Not extended. $row = Database::fetch_array($result, 'ASSOC'); $my_id = $row['myid']; $my_lp_id = $row['mylpid']; $my_lp_view_id = $row['mylpviewid']; $my_path = $row['path']; $result_disabled_ext_all = false; if ($row['item_type'] == 'quiz') { // Check results_disabled in quiz table. $my_path = Database::escape_string($my_path); $sql = "SELECT results_disabled\n FROM {$TBL_QUIZ}\n WHERE c_id = {$course_id} AND id ='" . $my_path . "'"; $res_result_disabled = Database::query($sql); $row_result_disabled = Database::fetch_row($res_result_disabled); if (Database::num_rows($res_result_disabled) > 0 && (int) $row_result_disabled[0] === 1) { $result_disabled_ext_all = true; } } // Check if there are interactions below $extend_this_attempt = 0; $inter_num = learnpath::get_interactions_count_from_db($row['iv_id'], $course_id); $objec_num = learnpath::get_objectives_count_from_db($row['iv_id'], $course_id); $extend_attempt_link = ''; if ($inter_num > 0 || $objec_num > 0) { if (!empty($extendAttemptId) && $extendAttemptId == $row['iv_id']) { // The extend button for this attempt has been clicked. $extend_this_attempt = 1; $extend_attempt_link = Display::url(Display::return_icon('visible.gif', get_lang('HideAttemptView')), api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix); } else { // Same case if fold_attempt_id is set, so not implemented explicitly. // The extend button for this attempt has not been clicked. $extend_attempt_link = Display::url(Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')), api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix); } } if ($counter % 2 == 0) { $oddclass = 'row_odd'; } else { $oddclass = 'row_even'; } $extend_link = ''; if ($inter_num > 1) { $extend_link = Display::url(Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')), api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix); } $lesson_status = $row['mystatus']; $score = $row['myscore']; $subtotal_time = $row['mytime']; while ($tmp_row = Database::fetch_array($result)) { $subtotal_time += $tmp_row['mytime']; } $title = $row['mytitle']; // Selecting the exe_id from stats attempts tables in order to look the max score value. $sql = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . $user_id . '" AND orig_lp_id = "' . $lp_id . '" AND orig_lp_item_id = "' . $row['myid'] . '" AND c_id = ' . $course_id . ' AND status <> "incomplete" AND session_id = ' . $session_id . ' ORDER BY exe_date DESC LIMIT 1'; $resultLastAttempt = Database::query($sql); $num = Database::num_rows($resultLastAttempt); $id_last_attempt = null; if ($num > 0) { while ($rowLA = Database::fetch_array($resultLastAttempt)) { $id_last_attempt = $rowLA['exe_id']; } } if ($score == 0) { $maxscore = $row['mymaxscore']; } else { if ($row['item_type'] == 'sco') { if (!empty($row['myviewmaxscore']) and $row['myviewmaxscore'] > 0) { $maxscore = $row['myviewmaxscore']; } elseif ($row['myviewmaxscore'] === '') { $maxscore = 0; } else { $maxscore = $row['mymaxscore']; } } else { if ($row['item_type'] == 'quiz') { // Get score and total time from last attempt of a exercise en lp. $sql = "SELECT score\n FROM {$TBL_LP_ITEM_VIEW}\n WHERE\n c_id = {$course_id} AND\n lp_item_id = '" . (int) $my_id . "' AND\n lp_view_id = '" . (int) $my_lp_view_id . "'\n ORDER BY view_count DESC limit 1"; $res_score = Database::query($sql); $row_score = Database::fetch_array($res_score); $sql = "SELECT SUM(total_time) as total_time\n FROM {$TBL_LP_ITEM_VIEW}\n WHERE\n c_id = {$course_id} AND\n lp_item_id = '" . (int) $my_id . "' AND\n lp_view_id = '" . (int) $my_lp_view_id . "'"; $res_time = Database::query($sql); $row_time = Database::fetch_array($res_time); if (Database::num_rows($res_score) > 0 && Database::num_rows($res_time) > 0) { $score = (double) $row_score['score']; $subtotal_time = (int) $row_time['total_time']; } else { $score = 0; $subtotal_time = 0; } // Selecting the max score from an attempt. $sql = "SELECT SUM(t.ponderation) as maxscore\n FROM (\n SELECT DISTINCT\n question_id, marks, ponderation\n FROM {$tbl_stats_attempts} as at\n INNER JOIN {$tbl_quiz_questions} as q\n ON (q.id = at.question_id AND q.c_id = {$course_id})\n WHERE exe_id ='{$id_last_attempt}'\n ) as t"; $result = Database::query($sql); $row_max_score = Database::fetch_array($result); $maxscore = $row_max_score['maxscore']; } else { $maxscore = $row['mymaxscore']; } } } $time_for_total = $subtotal_time; $time = learnpathItem::getScormTimeFromParameter('js', $subtotal_time); if (empty($title)) { $title = rl_get_resource_name($courseInfo['code'], $lp_id, $row['myid']); } $action = null; if ($type == 'classic') { $action = '<td></td>'; } if (in_array($row['item_type'], $chapterTypes)) { $title = Security::remove_XSS($title); $output .= '<tr class="' . $oddclass . '"> <td>' . $extend_link . '</td> <td colspan="4"> <h4>' . $title . '</h4> </td> <td colspan="2">' . learnpathitem::humanize_status($lesson_status) . '</td> <td colspan="2"></td> <td colspan="2"></td> ' . $action . ' </tr>'; } else { $correct_test_link = '-'; if ($row['item_type'] == 'quiz') { $my_url_suffix = '&course=' . $courseCode . '&student_id=' . $user_id . '&lp_id=' . intval($row['mylpid']) . '&origin=' . $origin; $sql = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . $user_id . '" AND orig_lp_id = "' . $lp_id . '" AND orig_lp_item_id = "' . $row['myid'] . '" AND c_id = ' . $course_id . ' AND status <> "incomplete" AND session_id = ' . $session_id . ' ORDER BY exe_date DESC '; $resultLastAttempt = Database::query($sql); $num = Database::num_rows($resultLastAttempt); if ($num > 0) { if ($extendedAttempt == 1 && $lp_id == $my_lp_id && $lp_item_id == $my_id) { $correct_test_link = Display::url(Display::return_icon('view_less_stats.gif', get_lang('HideAllAttempts')), api_get_self() . '?action=stats' . $my_url_suffix . '&session_id=' . $session_id . '&lp_item_id=' . $my_id); } else { $correct_test_link = Display::url(Display::return_icon('view_more_stats.gif', get_lang('ShowAllAttemptsByExercise')), api_get_self() . '?action=stats&extend_attempt=1' . $my_url_suffix . '&session_id=' . $session_id . '&lp_item_id=' . $my_id); } } } $title = Security::remove_XSS($title); $action = null; if ($type == 'classic') { $action = '<td>' . $correct_test_link . '</td>'; } if ($lp_id == $my_lp_id && false) { $output .= '<tr class =' . $oddclass . '> <td>' . $extend_link . '</td> <td colspan="4">' . $title . '</td> <td colspan="2"> </td> <td colspan="2"> </td> <td colspan="2"> </td> ' . $action . ' </tr>'; $output .= '</tr>'; } else { if ($lp_id == $my_lp_id && $lp_item_id == $my_id) { $output .= "<tr class='{$oddclass}'>"; } else { $output .= "<tr class='{$oddclass}'>"; } $scoreItem = null; if ($row['item_type'] == 'quiz') { if (!$is_allowed_to_edit && $result_disabled_ext_all) { $scoreItem .= Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting')); } else { $scoreItem .= ExerciseLib::show_score($score, $maxscore, false); } } else { $scoreItem .= $score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . $maxscore); } $output .= ' <td>' . $extend_link . '</td> <td colspan="4">' . $title . '</td> <td colspan="2">' . learnpathitem::humanize_status($lesson_status) . '</td> <td colspan="2">' . $scoreItem . '</td> <td colspan="2">' . $time . '</td> ' . $action . ' '; $output .= '</tr>'; } if (!empty($export_csv)) { $temp = array(); $temp[] = api_html_entity_decode($title, ENT_QUOTES); $temp[] = api_html_entity_decode($lesson_status, ENT_QUOTES); if ($row['item_type'] == 'quiz') { if (!$is_allowed_to_edit && $result_disabled_ext_all) { $temp[] = '/'; } else { $temp[] = $score == 0 ? '0/' . $maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)); } } else { $temp[] = $score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)); } $temp[] = $time; $csv_content[] = $temp; } } $counter++; $action = null; if ($type == 'classic') { $action = '<td></td>'; } if ($extend_this_attempt || $extend_all) { $list1 = learnpath::get_iv_interactions_array($row['iv_id']); foreach ($list1 as $id => $interaction) { if ($counter % 2 == 0) { $oddclass = 'row_odd'; } else { $oddclass = 'row_even'; } $output .= '<tr class="' . $oddclass . '"> <td></td> <td></td> <td></td> <td>' . $interaction['order_id'] . '</td> <td>' . $interaction['id'] . '</td> <td colspan="2">' . $interaction['type'] . '</td> <td>' . urldecode($interaction['student_response']) . '</td> <td>' . $interaction['result'] . '</td> <td>' . $interaction['latency'] . '</td> <td>' . $interaction['time'] . '</td> ' . $action . ' </tr>'; $counter++; } $list2 = learnpath::get_iv_objectives_array($row['iv_id']); foreach ($list2 as $id => $interaction) { if ($counter % 2 == 0) { $oddclass = 'row_odd'; } else { $oddclass = 'row_even'; } $output .= '<tr class="' . $oddclass . '"> <td></td> <td></td> <td></td> <td>' . $interaction['order_id'] . '</td> <td colspan="2">' . $interaction['objective_id'] . '</td> <td colspan="2">' . $interaction['status'] . '</td> <td>' . $interaction['score_raw'] . '</td> <td>' . $interaction['score_max'] . '</td> <td>' . $interaction['score_min'] . '</td> ' . $action . ' </tr>'; $counter++; } } // Attempts listing by exercise. if ($lp_id == $my_lp_id && $lp_item_id == $my_id && $extendedAttempt) { // Get attempts of a exercise. if (!empty($lp_id) && !empty($lp_item_id) && $row['item_type'] === 'quiz') { $sql = "SELECT path FROM {$TBL_LP_ITEM}\n WHERE\n c_id = {$course_id} AND\n id = '{$lp_item_id}' AND\n lp_id = '{$lp_id}'"; $res_path = Database::query($sql); $row_path = Database::fetch_array($res_path); if (Database::num_rows($res_path) > 0) { $sql = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . (int) $row_path['path'] . '" AND status <> "incomplete" AND exe_user_id="' . $user_id . '" AND orig_lp_id = "' . (int) $lp_id . '" AND orig_lp_item_id = "' . (int) $lp_item_id . '" AND c_id = ' . $course_id . ' AND session_id = ' . $session_id . ' ORDER BY exe_date'; $res_attempts = Database::query($sql); $num_attempts = Database::num_rows($res_attempts); if ($num_attempts > 0) { $n = 1; while ($row_attempts = Database::fetch_array($res_attempts)) { $my_score = $row_attempts['exe_result']; $my_maxscore = $row_attempts['exe_weighting']; $my_exe_id = $row_attempts['exe_id']; $my_orig_lp = $row_attempts['orig_lp_id']; $my_orig_lp_item = $row_attempts['orig_lp_item_id']; $my_exo_exe_id = $row_attempts['exe_exo_id']; $mktime_start_date = api_strtotime($row_attempts['start_date'], 'UTC'); $mktime_exe_date = api_strtotime($row_attempts['exe_date'], 'UTC'); if ($mktime_start_date && $mktime_exe_date) { $mytime = (int) $mktime_exe_date - (int) $mktime_start_date; $time_attemp = learnpathItem::getScormTimeFromParameter('js', $mytime); $time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp); } else { $time_attemp = ' - '; } if (!$is_allowed_to_edit && $result_disabled_ext_all) { $view_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting')); } else { // Show only float when need it if ($my_score == 0) { $view_score = ExerciseLib::show_score(0, $my_maxscore, false); } else { if ($my_maxscore == 0) { $view_score = $my_score; } else { $view_score = ExerciseLib::show_score($my_score, $my_maxscore, false); } } } $my_lesson_status = $row_attempts['status']; if ($my_lesson_status == '') { $my_lesson_status = learnpathitem::humanize_status('completed'); } elseif ($my_lesson_status == 'incomplete') { $my_lesson_status = learnpathitem::humanize_status('incomplete'); } $output .= '<tr class="' . $oddclass . '" > <td></td> <td>' . $extend_attempt_link . '</td> <td colspan="3">' . get_lang('Attempt') . ' ' . $n . '</td> <td colspan="2">' . $my_lesson_status . '</td> <td colspan="2">' . $view_score . '</td> <td colspan="2">' . $time_attemp . '</td>'; if ($action == 'classic') { if ($origin != 'tracking') { if (!$is_allowed_to_edit && $result_disabled_ext_all) { $output .= '<td> <img src="' . api_get_path(WEB_IMG_PATH) . 'quiz_na.gif" alt="' . get_lang('ShowAttempt') . '" title="' . get_lang('ShowAttempt') . '"> </td>'; } else { $output .= '<td> <a href="../exercice/exercise_show.php?origin=' . $origin . '&id=' . $my_exe_id . '&cidReq=' . $courseCode . '" target="_parent"> <img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" alt="' . get_lang('ShowAttempt') . '" title="' . get_lang('ShowAttempt') . '"> </a></td>'; } } else { if (!$is_allowed_to_edit && $result_disabled_ext_all) { $output .= '<td> <img src="' . api_get_path(WEB_IMG_PATH) . 'quiz_na.gif" alt="' . get_lang('ShowAndQualifyAttempt') . '" title="' . get_lang('ShowAndQualifyAttempt') . '"></td>'; } else { $output .= '<td> <a href="../exercice/exercise_show.php?cidReq=' . $courseCode . '&origin=correct_exercise_in_lp&id=' . $my_exe_id . '" target="_parent"> <img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" alt="' . get_lang('ShowAndQualifyAttempt') . '" title="' . get_lang('ShowAndQualifyAttempt') . '"></a></td>'; } } } $output .= '</tr>'; $n++; } } $output .= '<tr><td colspan="12"> </td></tr>'; } } } } $total_time += $time_for_total; // QUIZZ IN LP $a_my_id = array(); if (!empty($my_lp_id)) { $a_my_id[] = $my_lp_id; } } } // NOT Extend all "left green cross" if (!empty($a_my_id)) { if ($extendedAttempt) { // "Right green cross" extended $total_score = self::get_avg_student_score($user_id, $course_id, $a_my_id, $session_id, false, false); } else { // "Left green cross" extended $total_score = self::get_avg_student_score($user_id, $course_id, $a_my_id, $session_id, false, true); } } else { // Extend all "left green cross" $total_score = self::get_avg_student_score($user_id, $course_id, array($lp_id), $session_id, false, false); } $total_time = learnpathItem::getScormTimeFromParameter('js', $total_time); $total_time = str_replace('NaN', '00' . $h . '00\'00"', $total_time); if (!$is_allowed_to_edit && $result_disabled_ext_all) { $final_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting')); } else { if (is_numeric($total_score)) { $final_score = $total_score . '%'; } else { $final_score = $total_score; } } $progress = learnpath::getProgress($lp_id, $user_id, $course_id, $session_id); if ($counter % 2 == 0) { $oddclass = 'row_odd'; } else { $oddclass = 'row_even'; } $action = null; if ($type == 'classic') { $action = '<td></td>'; } $output .= '<tr class="' . $oddclass . '"> <td></td> <td colspan="4"> <i>' . get_lang('AccomplishedStepsTotal') . '</i> </td> <td colspan="2">' . $progress . '%</td> <td colspan="2"> ' . $final_score . ' </td> <td colspan="2">' . $total_time . '</div> ' . $action . ' </tr>'; $output .= ' </tbody> </table> </div> '; if (!empty($export_csv)) { $temp = array('', '', '', ''); $csv_content[] = $temp; $temp = array(get_lang('AccomplishedStepsTotal'), '', $final_score, $total_time); $csv_content[] = $temp; ob_end_clean(); Export::arrayToCsv($csv_content, 'reporting_learning_path_details'); exit; } return $output; }
if (isset($_GET['action'])) { switch ($_GET['action']) { case 'unsubscribe': if (CourseManager::get_user_in_course_status($_GET['user_id'], $_GET['course_code']) == STUDENT) { CourseManager::unsubscribe_user($_GET['user_id'], $_GET['course_code'], $_GET['id_session']); $message = Display::return_message(get_lang('UserUnsubscribed')); } else { $message = Display::return_message(get_lang('CannotUnsubscribeUserFromCourse'), 'error'); } break; case 'unsubscribeSessionCourse': SessionManager::removeUsersFromCourseSession(array($_GET['user_id']), $_GET['id_session'], api_get_course_info($_GET['course_code'])); $message = Display::return_message(get_lang('UserUnsubscribed')); break; case 'export': Export::arrayToCsv($csvContent, 'user_information_' . $user); exit; break; } } Display::display_header($tool_name); echo '<div class="actions"> <a href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/myStudents.php?student=' . intval($_GET['user_id']) . '" title="' . get_lang('Reporting') . '">' . Display::return_icon('statistics.png', get_lang('Reporting'), '', ICON_SIZE_MEDIUM) . ' </a> ' . $login_as_icon . ' ' . $editUser . ' ' . $exportLink . ' </div>'; echo Display::page_header($tool_name); $fullUrlBig = Usermanager::getUserPicture($user['user_id'], USER_IMAGE_SIZE_BIG); $fullUrl = Usermanager::getUserPicture($user['user_id'], USER_IMAGE_SIZE_ORIGINAL);
Export::updateCount($domainName); } setcookie("export_visited", "bloglounge", time() + 86400, "/", ((substr(strtolower($_SERVER['HTTP_HOST']), 0, 4) == 'www.') ? substr($_SERVER['HTTP_HOST'], 3) : $_SERVER['HTTP_HOST'])); } $params = array(); $params['get'] = $_GET; $params['post'] = $_POST; if(!isset($config)) $config = new Settings; $export->exportURL = $service['path'] . '/exports/' . $programName; $content = call_user_func($functionName, $params, Export::getConfig($domainName)); echo $content; } else { // 함수 없음 } } else { // 해당되는 프로그램 없음 header("Location: /"); exit; } } else { // 해당되는 프로그램 없음 header("Location: /"); exit; }
$extra = '<div style="text-align:center"><h2>' . get_lang('GroupList') . '</h2></div>'; $extra .= '<strong>' . get_lang('Course') . ': </strong>' . $courseInfo['title'] . ' (' . $courseInfo['code'] . ')'; $content = $extra . $content; $pdf->content_to_pdf($content, null, null, api_get_course_id()); break; case 'export': $groupId = isset($_GET['id']) ? intval($_GET['id']) : null; $data = GroupManager::exportCategoriesAndGroupsToArray($groupId, true); switch ($_GET['type']) { case 'csv': Export::arrayToCsv($data); exit; break; case 'xls': if (!empty($data)) { Export::arrayToXls($data); exit; } break; } break; } } /* Header */ $interbreadcrumb[] = array('url' => 'group.php?' . api_get_cidReq(), 'name' => get_lang('Groups')); if (!isset($_GET['origin']) || $_GET['origin'] != 'learnpath') { // So we are not in learnpath tool if (!$is_allowed_in_course) { api_not_allowed(true); } if (!api_is_allowed_to_edit(false, true)) {
function exportCSV($label) { $fromTime = $this->common->getFromTime(); $toTime = $this->common->getToTime(); $products = $this->common->getCompareProducts(); if (empty($products)) { $this->common->requireProduct(); return; } $this->load->library('export'); $export = new Export(); if ($label == "country") { $titlename = getExportReportTitle("Compare", lang("v_rpt_re_top10Nations"), $fromTime, $toTime); } else { $titlename = getExportReportTitle("Compare", lang("v_rpt_re_top10Provinces"), $fromTime, $toTime); } $titlename = iconv("UTF-8", "GBK", $titlename); $export->setFileName($titlename); $j = 0; $mk = 0; $title[$j++] = iconv("UTF-8", "GBK", lang('t_activeUsers')); $space[$mk++] = ' '; for ($i = 0; $i < count($products); $i++) { $title[$j++] = iconv("UTF-8", "GBK", $products[$i]->name); $title[$j++] = ''; $space[$mk++] = ' '; $space[$mk++] = ' '; } $export->setTitle($title); $k = 0; $maxlength = 0; $maxlength2 = 0; $j = 0; $nextlabel[$j++] = lang('t_newUsers'); for ($m = 0; $m < count($products); $m++) { if ($label == "country") { $activedata = $this->region->getactivebycountry($fromTime, $toTime, $products[$m]->id); $newdata = $this->region->getnewbycountry($fromTime, $toTime, $products[$m]->id); } else { $country = $this->default_country; $activedata = $this->region->getactivebypro($fromTime, $toTime, $products[$m]->id, $country); $newdata = $this->region->getnewbypro($fromTime, $toTime, $products[$m]->id, $country); } $detailData[$m] = $this->change2StandardPrecent($activedata, $label); $detailNewData[$m] = $this->change2StandardPrecent($newdata, $label); if (count($detailData[$m]) > $maxlength) { $maxlength = count($detailData[$m]); } if (count($detailNewData[$m]) > $maxlength2) { $maxlength2 = count($detailNewData[$m]); } $nextlabel[$j++] = $products[$m]->name; $nextlabel[$j++] = ' '; } $this->getExportRowData($export, $maxlength, $detailData, $products, $label); $export->addRow($space); $export->addRow($nextlabel); $this->getExportRowData($export, $maxlength2, $detailNewData, $products, $label); $export->export(); die; }
$groups_export = $DIA->get('export', $export_id); if ($groups_export['Status'] == "Active") { echo ' waiting for export to reset '; sleep(30); $groups_export = check_for_sleep($export_id); } else { if ($groups_export['Status'] == "Complete") { echo 'ready to sync '; return $groups_export; } else { echo 'something bad happened '; } } } $data['export_KEY'] = $export_id; $export = new Export($data); $export->reset_export(); check_for_sleep($export_id); $groups_export = $DIA->get('export', $export_id); print_r($groups_export); if ($groups_export['Status'] == "Complete") { $file = get_file_from_export($groups_export); echo ' file fetched '; if ($del == 1) { $object = new $model_name(array()); $sql = "truncate " . $object::$table_name; $DB->query($sql); echo 'db deleted '; if ($DB->error) { echo new Exception($DB->error . $sql); }
function export() { $this->load->library('export'); $fromTime = $this->common->getFromTime(); $toTime = $this->common->getToTime(); $productId = $this->common->getCurrentProduct(); $productId = $productId->id; $productName = $this->common->getCurrentProduct()->name; $data = $this->orientationmodel->getTotalUsersPercentByResolution($fromTime, $toTime, $productId); $export = new Export(); $titlename = getExportReportTitle($productName, lang('v_rpt_re_details'), $fromTime, $toTime); $title = iconv("UTF-8", "GBK", $titlename); $export->setFileName($title); $fields = array(); foreach ($data->list_fields() as $field) { array_push($fields, $field); } $export->setTitle($fields); foreach ($data->result() as $row) { $export->addRow($row); } $export->export(); die; }
$inc = 'ticket-edit.inc.php'; } elseif ($_REQUEST['a'] == 'print' && !$ticket->pdfExport($_REQUEST['psize'], $_REQUEST['notes'])) { $errors['err'] = 'Internal error: Unable to export the ticket to PDF for print.'; } } else { $inc = 'tickets.inc.php'; if ($_REQUEST['a'] == 'open' && $thisstaff->canCreateTickets()) { $inc = 'ticket-open.inc.php'; } elseif ($_REQUEST['a'] == 'export') { require_once INCLUDE_DIR . 'class.export.php'; $ts = strftime('%Y%m%d'); if (!($token = $_REQUEST['h'])) { $errors['err'] = 'Query token required'; } elseif (!($query = $_SESSION['search_' . $token])) { $errors['err'] = 'Query token not found'; } elseif (!Export::saveTickets($query, "tickets-{$ts}.csv", 'csv')) { $errors['err'] = 'Internal error: Unable to dump query results'; } } //Clear active submenu on search with no status if ($_REQUEST['a'] == 'search' && !$_REQUEST['status']) { $nav->setActiveSubMenu(-1); } //set refresh rate if the user has it configured if (!$_POST && $_REQUEST['a'] != 'search' && ($min = $thisstaff->getRefreshRate())) { $ost->addExtraHeader('<meta http-equiv="refresh" content="' . $min * 60 . '" />'); } } require_once STAFFINC_DIR . 'header.inc.php'; require_once STAFFINC_DIR . $inc; require_once STAFFINC_DIR . 'footer.inc.php';
public function exportXLSX($data) { Export::toXML($data); }
} else { $csv_headers[] = get_lang('LastName', ''); $csv_headers[] = get_lang('FirstName', ''); } $csv_headers[] = get_lang('Login', ''); // $csv_headers[] = get_lang('TrainingTime', ''); $csv_headers[] = get_lang('CourseProgress', ''); $csv_headers[] = get_lang('ExerciseProgress', ''); $csv_headers[] = get_lang('ExerciseAverage', ''); $csv_headers[] = get_lang('Score', ''); $csv_headers[] = get_lang('Student_publication', ''); $csv_headers[] = get_lang('Messages', ''); if (empty($session_id)) { $csv_headers[] = get_lang('Survey'); } $csv_headers[] = get_lang('FirstLogin', ''); $csv_headers[] = get_lang('LatestLogin', ''); if (isset($_GET['additional_profile_field']) AND is_numeric($_GET['additional_profile_field'])) { $csv_headers[] = $extra_info['field_display_text']; } ob_end_clean(); array_unshift($csv_content, $csv_headers); // Adding headers before the content. Export::export_table_csv($csv_content, 'reporting_student_list'); exit; } Display::display_footer();
background-color:white; z-index:99; padding: 3px; display: inline; } .blackboard_hide { display: none; } .reportes{ border:1px ; } .reportes th { border-bottom: 1px solid #DDDDDD; line-height: normal; text-align: center; vertical-align: middle; background-color: #F2F2F2; } </style>'; $course_code = api_get_course_id(); $resultado = inicializarReporte($course_code); if (isset($_GET['action'])) { Export::export_table_xls($resultado['exportar'], "REPORTE ALUMNOS CURSO" . $course_code); } else { Display::display_header(); api_protect_course_script(); if (!api_is_allowed_to_edit()) { api_not_allowed(); } echo $resultado['mostrar']; Display::display_footer(); }
$errors['err'] = "Coming soon!"; } break; case 'import-users': $status = User::importFromPost($_FILES['import'] ?: $_POST['pasted']); if (is_numeric($status)) { $msg = "Successfully imported {$status} clients"; } else { $errors['err'] = $status; } break; default: $errors['err'] = 'Unknown action/command'; break; } } elseif ($_REQUEST['a'] == 'export') { require_once INCLUDE_DIR . 'class.export.php'; $ts = strftime('%Y%m%d'); if (!($token = $_REQUEST['qh'])) { $errors['err'] = 'Query token required'; } elseif (!($query = $_SESSION['users_qs_' . $token])) { $errors['err'] = 'Query token not found'; } elseif (!Export::saveUsers($query, "users-{$ts}.csv", 'csv')) { $errors['err'] = 'Internal error: Unable to dump query results'; } } $page = $user ? 'user-view.inc.php' : 'users.inc.php'; $nav->setTabActive('users'); require STAFFINC_DIR . 'header.inc.php'; require STAFFINC_DIR . $page; include STAFFINC_DIR . 'footer.inc.php';
$add .= "\t</Session>\n"; fputs($fp, $add); } } switch ($file_type) { case 'xml': fputs($fp, "</Sessions>\n"); fclose($fp); $errorMsg = get_lang('UserListHasBeenExported') . '<br/> <a class="btn btn-default" href="' . $archiveURL . $archiveFile . '">' . get_lang('ClickHereToDownloadTheFile') . '</a>'; break; case 'csv': Export::arrayToCsv($sessionListToExport, $archiveFile); exit; case 'xls': Export::arrayToXls($sessionListToExport, $archiveFile); exit; break; } } } // display the header Display::display_header($tool_name); //select of sessions $sql = "SELECT id, name FROM {$tbl_session} ORDER BY name"; if (api_is_multiple_url_enabled()) { $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $sql = "SELECT s.id, name FROM {$tbl_session} s\n\t\t\tINNER JOIN {$tbl_session_rel_access_url} as session_rel_url\n\t\t\tON (s.id = session_rel_url.session_id)\n\t\t\tWHERE access_url_id = {$access_url_id}\n\t\t\tORDER BY name"; }
} $data[] = $user; $counter++; } } switch ($_GET['type']) { case 'csv': Export::arrayToCsv($a_users); exit; case 'xls': Export::arrayToXls($a_users); exit; case 'pdf': $header_attributes = array(array('style' => 'width:10px'), array('style' => 'width:30px'), array('style' => 'width:50px'), array('style' => 'width:500px')); $params = array('add_signatures' => false, 'filename' => get_lang('UserList'), 'pdf_title' => get_lang('StudentList'), 'header_attributes' => $header_attributes); Export::export_table_pdf($a_users, $params); exit; } } } } // end if allowed to edit if (api_is_allowed_to_edit(null, true)) { // Unregister user from course if (isset($_REQUEST['unregister']) && $_REQUEST['unregister']) { if (isset($_GET['user_id']) && is_numeric($_GET['user_id']) && ($_GET['user_id'] != $_user['user_id'] || api_is_platform_admin())) { $user_id = intval($_GET['user_id']); $tbl_user = Database::get_main_table(TABLE_MAIN_USER); $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); $sql = 'SELECT user.user_id
public static function downloadSample($model, $config = null) { $import = new Import($model, $config); $data = $import->model->find(); $header = []; $sample = []; $modelCols = $import->model->tableSchema->columns; foreach ($import->columns as $key => $col) { $col = is_string($col) ? ['type' => $col] : $col; switch ($col['type']) { case "pk": case "default": $header[] = $key; if (isset($col['sample'])) { $sample[] = $col['sample']; } else { if (isset($modelCols[$key])) { if ($col['type'] == 'pk') { $sample[] = ''; } else { if (isset($data)) { $sample[] = $data->{$key}; } else { $sample[] = Export::getSampleText($modelCols[$key]); } } } else { $sample[] = "text"; } } break; case "lookup": if (@$col['show'] !== false) { $header[] = $key; if (isset($col['sample'])) { $sample[] = $col['sample']; } else { $sample[] = 'text'; } } break; } } $writer = WriterFactory::create(Type::XLSX); $writer->openToBrowser("import-" . Helper::camelToSnake($model) . '.xlsx'); // stream data directly to the browser $writer->addRows([$header, $sample]); // add multiple rows at a time $writer->close(); }