/** * Get name to display: same as exercise title */ public function get_name() { $documentPath = api_get_path(SYS_COURSE_PATH) . $this->course_code . "/document"; require_once api_get_path(SYS_CODE_PATH) . 'exercice/hotpotatoes.lib.php'; $data = $this->get_exercise_data(); if ($this->is_hp == 1) { if (isset($data['path'])) { $hotpotatoes_exist = true; $item = ''; $title = GetQuizName($data['path'], $documentPath); if ($title == '') { $title = basename($data['path']); } return $title; } } return $data['title']; }
/** * Gets the exam'data results * @todo this function should be moved in a library + no global calls * @param int $from * @param int $number_of_items * @param int $column * @param string $direction * @param int $exercise_id * @param null $extra_where_conditions * @param bool $get_count * @return array */ public static function get_exam_results_data($from, $number_of_items, $column, $direction, $exercise_id, $extra_where_conditions = null, $get_count = false) { //@todo replace all this globals global $documentPath, $filter; $course_id = api_get_course_int_id(); $sessionId = api_get_session_id(); $is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_allowed_to_edit(true) || api_is_drh() || api_is_student_boss(); $TBL_USER = Database::get_main_table(TABLE_MAIN_USER); $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); $TBL_GROUP_REL_USER = Database::get_course_table(TABLE_GROUP_USER); $TBL_GROUP = Database::get_course_table(TABLE_GROUP); $TBL_TRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); $TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); $TBL_TRACK_ATTEMPT_RECORDING = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING); $session_id_and = ' AND te.session_id = ' . $sessionId . ' '; $exercise_id = intval($exercise_id); $exercise_where = ''; if (!empty($exercise_id)) { $exercise_where .= ' AND te.exe_exo_id = ' . $exercise_id . ' '; } $hotpotatoe_where = ''; if (!empty($_GET['path'])) { $hotpotatoe_path = Database::escape_string($_GET['path']); $hotpotatoe_where .= ' AND exe_name = "' . $hotpotatoe_path . '" '; } // sql for chamilo-type tests for teacher / tutor view $sql_inner_join_tbl_track_exercices = "\n (\n SELECT DISTINCT ttte.*, if(tr.exe_id,1, 0) as revised\n FROM {$TBL_TRACK_EXERCICES} ttte LEFT JOIN {$TBL_TRACK_ATTEMPT_RECORDING} tr\n ON (ttte.exe_id = tr.exe_id)\n WHERE\n c_id = {$course_id} AND\n exe_exo_id = {$exercise_id} AND\n ttte.session_id = " . $sessionId . "\n )"; if ($is_allowedToEdit) { //@todo fix to work with COURSE_RELATION_TYPE_RRHH in both queries // Hack in order to filter groups $sql_inner_join_tbl_user = ''; if (strpos($extra_where_conditions, 'group_id')) { $sql_inner_join_tbl_user = "******" . $course_id . ")\n INNER JOIN {$TBL_GROUP} g\n ON (gru.group_id = g.id AND g.c_id=" . $course_id . ")\n )"; } if (strpos($extra_where_conditions, 'group_all')) { $extra_where_conditions = str_replace("AND ( group_id = 'group_all' )", '', $extra_where_conditions); $extra_where_conditions = str_replace("AND group_id = 'group_all'", '', $extra_where_conditions); $extra_where_conditions = str_replace("group_id = 'group_all' AND", '', $extra_where_conditions); $sql_inner_join_tbl_user = "******"; $sql_inner_join_tbl_user = null; } if (strpos($extra_where_conditions, 'group_none')) { $extra_where_conditions = str_replace("AND ( group_id = 'group_none' )", "AND ( group_id is null )", $extra_where_conditions); $extra_where_conditions = str_replace("AND group_id = 'group_none'", "AND ( group_id is null )", $extra_where_conditions); $sql_inner_join_tbl_user = "******" . $course_id . " )\n LEFT OUTER JOIN {$TBL_GROUP} g\n ON (gru.group_id = g.id AND g.c_id = " . $course_id . ")\n )"; } // All $is_empty_sql_inner_join_tbl_user = false; if (empty($sql_inner_join_tbl_user)) { $is_empty_sql_inner_join_tbl_user = true; $sql_inner_join_tbl_user = "******" . api_get_users_status_ignored_in_reports('string') . ")\n )"; } $sqlFromOption = " , {$TBL_GROUP_REL_USER} AS gru "; $sqlWhereOption = " AND gru.c_id = " . $course_id . " AND gru.user_id = user.user_id "; $first_and_last_name = api_is_western_name_order() ? "firstname, lastname" : "lastname, firstname"; if ($get_count) { $sql_select = "SELECT count(te.exe_id) "; } else { $sql_select = "SELECT DISTINCT\n user_id,\n {$first_and_last_name},\n official_code,\n ce.title,\n username,\n te.exe_result,\n te.exe_weighting,\n te.exe_date,\n te.exe_id,\n email as exemail,\n te.start_date,\n steps_counter,\n exe_user_id,\n te.exe_duration,\n propagate_neg,\n revised,\n group_name,\n group_id,\n orig_lp_id,\n te.user_ip"; } $sql = " {$sql_select}\n FROM {$TBL_EXERCICES} AS ce\n INNER JOIN {$sql_inner_join_tbl_track_exercices} AS te\n ON (te.exe_exo_id = ce.id)\n INNER JOIN {$sql_inner_join_tbl_user} AS user\n ON (user.user_id = exe_user_id)\n WHERE\n te.status != 'incomplete' AND\n te.c_id = " . $course_id . " {$session_id_and} AND\n ce.active <>-1 AND ce.c_id = " . $course_id . "\n {$exercise_where}\n {$extra_where_conditions}\n "; // sql for hotpotatoes tests for teacher / tutor view if ($get_count) { $hpsql_select = "SELECT count(username)"; } else { $hpsql_select = "SELECT\n {$first_and_last_name} ,\n username,\n official_code,\n tth.exe_name,\n tth.exe_result ,\n tth.exe_weighting,\n tth.exe_date"; } $hpsql = " {$hpsql_select}\n FROM\n {$TBL_TRACK_HOTPOTATOES} tth,\n {$TBL_USER} user\n {$sqlFromOption}\n WHERE\n user.user_id=tth.exe_user_id\n AND tth.c_id = " . $course_id . "\n {$hotpotatoe_where}\n {$sqlWhereOption}\n AND user.status NOT IN(" . api_get_users_status_ignored_in_reports('string') . ")\n ORDER BY\n tth.c_id ASC,\n tth.exe_date DESC"; } if ($get_count) { $resx = Database::query($sql); $rowx = Database::fetch_row($resx, 'ASSOC'); return $rowx[0]; } $teacher_list = CourseManager::getTeacherListFromCourse(api_get_course_int_id()); $teacher_id_list = array(); if (!empty($teacher_list)) { foreach ($teacher_list as $teacher) { $teacher_id_list[] = $teacher['user_id']; } } $list_info = array(); // Simple exercises if (empty($hotpotatoe_where)) { $column = !empty($column) ? Database::escape_string($column) : null; $from = intval($from); $number_of_items = intval($number_of_items); if (!empty($column)) { $sql .= " ORDER BY {$column} {$direction} "; } $sql .= " LIMIT {$from}, {$number_of_items}"; $results = array(); $resx = Database::query($sql); while ($rowx = Database::fetch_array($resx, 'ASSOC')) { $results[] = $rowx; } $group_list = GroupManager::get_group_list(); $clean_group_list = array(); if (!empty($group_list)) { foreach ($group_list as $group) { $clean_group_list[$group['id']] = $group['name']; } } $lp_list_obj = new LearnpathList(api_get_user_id()); $lp_list = $lp_list_obj->get_flat_list(); if (is_array($results)) { $users_array_id = array(); $from_gradebook = false; if (isset($_GET['gradebook']) && $_GET['gradebook'] == 'view') { $from_gradebook = true; } $sizeof = count($results); $user_list_id = array(); $locked = api_resource_is_locked_by_gradebook($exercise_id, LINK_EXERCISE); // Looping results for ($i = 0; $i < $sizeof; $i++) { $revised = $results[$i]['revised']; if ($from_gradebook && $is_allowedToEdit) { if (in_array($results[$i]['username'] . $results[$i]['firstname'] . $results[$i]['lastname'], $users_array_id)) { continue; } $users_array_id[] = $results[$i]['username'] . $results[$i]['firstname'] . $results[$i]['lastname']; } $lp_obj = isset($results[$i]['orig_lp_id']) && isset($lp_list[$results[$i]['orig_lp_id']]) ? $lp_list[$results[$i]['orig_lp_id']] : null; $lp_name = null; if ($lp_obj) { $url = api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?' . api_get_cidreq() . '&action=view&lp_id=' . $results[$i]['orig_lp_id']; $lp_name = Display::url($lp_obj['lp_name'], $url, array('target' => '_blank')); } //Add all groups by user $group_name_list = null; if ($is_empty_sql_inner_join_tbl_user) { $group_list = GroupManager::get_group_ids(api_get_course_int_id(), $results[$i]['user_id']); foreach ($group_list as $id) { $group_name_list .= $clean_group_list[$id] . '<br/>'; } $results[$i]['group_name'] = $group_name_list; } $results[$i]['exe_duration'] = !empty($results[$i]['exe_duration']) ? round($results[$i]['exe_duration'] / 60) : 0; $user_list_id[] = $results[$i]['exe_user_id']; $id = $results[$i]['exe_id']; $dt = api_convert_and_format_date($results[$i]['exe_weighting']); // we filter the results if we have the permission to if (isset($results[$i]['results_disabled'])) { $result_disabled = intval($results[$i]['results_disabled']); } else { $result_disabled = 0; } if ($result_disabled == 0) { $my_res = $results[$i]['exe_result']; $my_total = $results[$i]['exe_weighting']; $results[$i]['start_date'] = api_get_local_time($results[$i]['start_date']); $results[$i]['exe_date'] = api_get_local_time($results[$i]['exe_date']); if (!$results[$i]['propagate_neg'] && $my_res < 0) { $my_res = 0; } $score = self::show_score($my_res, $my_total); $actions = ''; if ($is_allowedToEdit) { if (isset($teacher_id_list)) { if (in_array($results[$i]['exe_user_id'], $teacher_id_list)) { $actions .= Display::return_icon('teachers.gif', get_lang('Teacher')); } } if ($revised) { $actions .= "<a href='exercise_show.php?" . api_get_cidreq() . "&action=edit&id={$id}'>" . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL); $actions .= ' '; } else { $actions .= "<a href='exercise_show.php?" . api_get_cidreq() . "&action=qualify&id={$id}'>" . Display::return_icon('quiz.gif', get_lang('Qualify')); $actions .= ' '; } $actions .= "</a>"; if ($filter == 2) { $actions .= ' <a href="exercise_history.php?' . api_get_cidreq() . '&exe_id=' . $id . '">' . Display::return_icon('history.gif', get_lang('ViewHistoryChange')) . '</a>'; } //Admin can always delete the attempt if (($locked == false || api_is_platform_admin()) && !api_is_student_boss()) { $ip = TrackingUserLog::get_ip_from_user_event($results[$i]['exe_user_id'], date('Y-m-d h:i:s'), false); $actions .= '<a href="http://www.whatsmyip.org/ip-geo-location/?ip=' . $ip . '" target="_blank">'; $actions .= Display::return_icon('info.png', $ip, ['title' => $ip]); $actions .= '</a>'; $delete_link = '<a href="exercise_report.php?' . api_get_cidreq() . '&filter_by_user='******'filter_by_user']) . '&filter=' . $filter . '&exerciseId=' . $exercise_id . '&delete=delete&did=' . $id . '" onclick="javascript:if(!confirm(\'' . sprintf(get_lang('DeleteAttempt'), $results[$i]['username'], $dt) . '\')) return false;">' . Display::return_icon('delete.png', get_lang('Delete')) . '</a>'; $delete_link = utf8_encode($delete_link); if (api_is_drh() && !api_is_platform_admin()) { $delete_link = null; } $actions .= $delete_link . ' '; } } else { $attempt_url = api_get_path(WEB_CODE_PATH) . 'exercice/result.php?' . api_get_cidreq() . '&id=' . $results[$i]['exe_id'] . '&id_session=' . $sessionId; $attempt_link = Display::url(get_lang('Show'), $attempt_url, ['class' => 'ajax btn btn-default', 'data-title' => get_lang('Show')]); $actions .= $attempt_link; } if ($revised) { $revised = Display::label(get_lang('Validated'), 'success'); } else { $revised = Display::label(get_lang('NotValidated'), 'info'); } if ($is_allowedToEdit) { $results[$i]['status'] = $revised; $results[$i]['score'] = $score; $results[$i]['lp'] = $lp_name; $results[$i]['actions'] = $actions; $list_info[] = $results[$i]; } else { $results[$i]['status'] = $revised; $results[$i]['score'] = $score; $results[$i]['actions'] = $actions; $list_info[] = $results[$i]; } } } } } else { $hpresults = StatsUtils::getManyResultsXCol($hpsql, 6); // Print HotPotatoes test results. if (is_array($hpresults)) { for ($i = 0; $i < sizeof($hpresults); $i++) { $hp_title = GetQuizName($hpresults[$i][3], $documentPath); if ($hp_title == '') { $hp_title = basename($hpresults[$i][3]); } $hp_date = api_get_local_time($hpresults[$i][6], null, date_default_timezone_get()); $hp_result = round($hpresults[$i][4] / ($hpresults[$i][5] != 0 ? $hpresults[$i][5] : 1) * 100, 2) . '% (' . $hpresults[$i][4] . ' / ' . $hpresults[$i][5] . ')'; if ($is_allowedToEdit) { $list_info[] = array($hpresults[$i][0], $hpresults[$i][1], $hpresults[$i][2], '', $hp_title, '-', $hp_date, $hp_result, '-'); } else { $list_info[] = array($hp_title, '-', $hp_date, $hp_result, '-'); } } } } return $list_info; }
/** * Displays the exercise results for a specific user in a specific course. * @param string $view * @param int $user_id User ID * @param string $courseCode Course code * @return array * @todo remove globals */ public function display_exercise_tracking_info($view, $userId, $courseCode) { global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong; $courseId = api_get_course_int_id($courseCode); $userId = intval($userId); if (substr($view, 1, 1) == '1') { $new_view = substr_replace($view, '0', 1, 1); $title[1] = get_lang('ExercicesDetails'); $line = ''; $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)\n FROM {$TABLECOURSE_EXERCICES} AS ce , {$TABLETRACK_EXERCICES} AS te\n WHERE te.c_id = {$courseId}\n AND te.exe_user_id = {$userId}\n AND te.exe_exo_id = ce.id\n ORDER BY ce.title ASC, te.exe_date ASC"; $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)\n FROM {$TABLETRACK_HOTPOTATOES} AS te\n WHERE te.exe_user_id = '{$userId}' AND te.c_id = {$courseId}\n ORDER BY te.c_id ASC, te.exe_date ASC"; $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4); $NoTestRes = 0; $NoHPTestRes = 0; $results = StatsUtils::getManyResultsXCol($sql, 4); $title_line = get_lang('ExercicesTitleExerciceColumn') . ";" . get_lang('Date') . ';' . get_lang('ExercicesTitleScoreColumn') . "\n"; if (is_array($results)) { for ($i = 0; $i < sizeof($results); $i++) { $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get()); $line .= $results[$i][0] . ";" . $display_date . ";" . $results[$i][1] . " / " . $results[$i][2] . "\n"; } } else { // istvan begin $NoTestRes = 1; } // The Result of Tests if (is_array($hpresults)) { for ($i = 0; $i < sizeof($hpresults); $i++) { $title = GetQuizName($hpresults[$i][0], ''); if ($title == '') { $title = basename($hpresults[$i][0]); } $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get()); $line .= $title . ';' . $display_date . ';' . $hpresults[$i][1] . '/' . $hpresults[$i][2] . "\n"; } } else { $NoHPTestRes = 1; } if ($NoTestRes == 1 && $NoHPTestRes == 1) { $line = get_lang('NoResult'); } } else { $new_view = substr_replace($view, '1', 1, 1); } return array($title_line, $line); }
/** * This function is to create and return a link to the added resources (lessons). * It returns the same thing as display_addedresource_link_in_learnpath() but doesn't display * anything. * * Parameters: * @param type - that is the correspondent type in the mirror tool (like this is a Link item) * @param id - that is the correspondent id in the mirror tool (like Agenda item 2) * @param id_in_path - the unique index in the items table */ function get_addedresource_link_in_learnpath($type, $id, $id_in_path) { global $_course, $learnpath_id, $tbl_learnpath_item, $items; global $curDirPath, $_configuration, $enableDocumentParsing, $_user, $_cid; $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM); $course_id = api_get_course_int_id(); $hyperlink_target_parameter = ''; // or e.g. target='_blank' $builder = 'player'; $origin = 'learnpath'; $linktype = $type; if ($type == 'Link _self' || $type == 'Link _blank') { $type = 'Link'; } $link = ''; switch ($type) { case 'Agenda': $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA); $result = Database::query("SELECT * FROM {$TABLEAGENDA} WHERE c_id = {$course_id} AND id={$id}"); $myrow = Database::fetch_array($result); $sql = "select * from {$tbl_lp_item} where c_id = {$course_id} AND id={$id_in_path}"; $result = Database::query($sql); $row = Database::fetch_array($result); if ($row['title'] != '') { $myrow['title'] = $row['title']; } $desc = $row['description']; $agenda_id = $row['item_id']; if ($builder != 'builder') { $link .= api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Agenda&origin={$origin}&agenda_id={$agenda_id}#{$id_in_path}"; } else { $link .= "../calendar/agenda.php?origin={$origin}&agenda_id={$agenda_id}"; } break; case 'Ad_Valvas': $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); $result = Database::query("SELECT * FROM {$tbl_announcement} WHERE c_id = {$course_id} AND id={$id}"); $myrow = Database::fetch_array($result); if ($builder != 'builder') { $link .= api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Ad_Valvas&origin={$origin}&ann_id={$id}#{$id_in_path}"; } else { $link .= "../announcements/announcements.php?origin={$origin}&ann_id={$id}"; } break; case 'Link': $TABLETOOLLINK = Database::get_course_table(TABLE_LINK); $result = Database::query("SELECT * FROM {$TABLETOOLLINK} WHERE c_id = {$course_id} AND id={$id}"); $myrow = Database::fetch_array($result); $sql = "select * from {$tbl_lp_item} where c_id = {$course_id} AND id={$id_in_path}"; $result = Database::query($sql); $row = Database::fetch_array($result); $thelink = $myrow['url']; if ($builder != 'builder') { $link .= api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type={$linktype}&origin={$origin}&thelink={$thelink}#{$id_in_path}"; } else { $link .= $thelink; } break; case 'Exercise': $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); $result = Database::query("SELECT * FROM {$TBL_EXERCICES} WHERE c_id = {$course_id} AND id={$id}"); $myrow = Database::fetch_array($result); if ($builder == 'builder') { $origin = 'builder'; } // This is needed for the exercise_submit.php can delete the session info about tests. $sql = "select * from {$tbl_lp_item} where c_id = {$course_id} AND id={$id_in_path}"; $result = Database::query($sql); $row = Database::fetch_array($result); if ($row['title'] != '') { $myrow['title'] = $row['title']; } if ($builder != 'builder') { $link .= api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Exercise&origin={$origin}&exerciseId=" . $myrow["id"] . "#{$id_in_path}"; } else { $link .= "../exercice/exercise_submit.php?origin={$origin}&exerciseId=" . $myrow["id"]; } break; case 'HotPotatoes': $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); $documentPath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document'; $result = Database::query("SELECT * FROM " . $TBL_DOCUMENT . " WHERE c_id = {$course_id} AND id={$id}"); $myrow = Database::fetch_array($result); $path = $myrow['path']; $name = GetQuizName($path, $documentPath); if ($builder == 'builder') { $origin = 'builder'; } $cid = $_course['official_code']; if ($builder != 'builder') { $link .= api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=HotPotatoes&origin={$origin}&id={$id}#{$id_in_path}"; } else { $link .= "../exercice/showinframes.php?file={$path}&cid={$cid}&uid=" . $_user['user_id']; } break; case 'Forum': //deprecated $TBL_FORUMS = Database::get_course_table(TABLE_FORUM); // TODO: This is the old table name, it should be corrected. $result = Database::query("SELECT * FROM {$TBL_FORUMS} WHERE c_id = {$course_id} AND forum_id={$id}"); $myrow = Database::fetch_array($result); if ($builder == 'builder') { $origin = 'builder'; } $sql = "select * from {$tbl_lp_item} where c_id = {$course_id} AND id={$id_in_path}"; $result = Database::query($sql); $row = Database::fetch_array($result); if ($row['title'] != '') { $myrow['forum_name'] = $row['title']; } if ($myrow['forum_name'] == '') { $type = 'Forum'; } $forumparameters = "forum=" . $myrow["forum_id"] . "&md5=" . $myrow["md5"]; if ($builder != 'builder') { $link .= api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Forum&origin={$origin}&forumparameters={$forumparameters}#{$id_in_path}"; } else { $link .= "../phpbb/viewforum.php?{$forumparameters}"; } break; case 'Thread': //forum post //deprecated $tbl_topics = Database::get_course_table(TABLE_FORUM_THREAD); $tbl_posts = Database::get_course_table(TABLE_FORUM_POST); $TBL_FORUMS = Database::get_course_table(TABLE_FORUM); $sql = "SELECT * FROM {$tbl_topics} where c_id = {$course_id} AND topic_id={$id}"; $result = Database::query($sql); $myrow = Database::fetch_array($result); $sql = "select * from {$tbl_lp_item} where c_id = {$course_id} AND id={$id_in_path}"; $result = Database::query($sql); $row = Database::fetch_array($result); if ($builder != 'builder') { $link .= api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Thread&origin={$origin}&topic=" . $myrow["topic_id"] . "&forum=" . $myrow["forum_id"] . "&md5=" . $myrow["md5"] . "#{$id_in_path}"; } else { $link .= "../forum/viewtopic.php?topic=" . $myrow["topic_id"] . "&forum=" . $myrow["forum_id"] . "&md5=" . $myrow["md5"]; } break; case 'Post': //deprecated $tbl_posts = Database::get_course_table(TABLE_FORUM_POST); $result = Database::query("SELECT * FROM {$tbl_posts} where c_id = {$course_id} AND post_id={$id}"); $myrow = Database::fetch_array($result); // Grabbing the title of the post. $sql = "select * from {$tbl_lp_item} where c_id = {$course_id} AND id={$id_in_path}"; $result = Database::query($sql); $row = Database::fetch_array($result); if ($row['title'] != '') { $myrow['post_title'] = $row['title']; } $desc = $row['description']; //$link .= str_repeat(" >", $level); $posternom = $myrow['nom']; $posterprenom = $myrow['prenom']; $posttime = $myrow['post_time']; $posttext = $myrow['post_text']; $posttitle = $myrow['post_title']; $posttext = str_replace('"', "'", $posttext); if ($builder != 'builder') { $link .= api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Post&origin={$origin}&posternom={$posternom}&posterprenom={$posterprenom}&posttime={$posttime}&posttext={$posttext}&posttitle={$posttitle}#{$id_in_path}"; } else { $link .= "../phpbb/viewtopic.php?topic=" . $myrow["topic_id"] . "&forum=" . $myrow["forum_id"] . "&md5=" . $myrow["md5"]; } break; case 'Document': $dbTable = Database::get_course_table(TABLE_DOCUMENT); $result = Database::query("SELECT * FROM {$dbTable} WHERE id={$id}"); $myrow = Database::fetch_array($result); $pathname = explode('/', $myrow['path']); // Making a correct name for the link. $last = count($pathname) - 1; // Making a correct name for the link. $filename = $pathname[$last]; // Making a correct name for the link. $sql = "select * from {$tbl_lp_item} where c_id = {$course_id} AND id={$id_in_path}"; $result = Database::query($sql); $row = Database::fetch_array($result); if ($builder != 'builder') { $link .= api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Document&origin={$origin}&docurl=" . $myrow["path"] . "#{$id_in_path}"; } else { $enableDocumentParsing = yes; if (!$enableDocumentParsing) { // This is the solution for the non-parsing version in the builder. $file = urlencode($myrow['path']); $link .= "../document/showinframes.php?file={$file}"; } else { $link .= "../document/download.php?doc_url=" . $myrow['path']; } } break; case 'Assignments': if ($builder != 'builder') { $link .= api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Assignments&origin={$origin}#{$id_in_path}"; } else { $link .= "../work/work.php"; } break; case 'Dropbox': if ($builder != 'builder') { $link .= api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Dropbox&origin={$origin}#{$id_in_path}"; } else { $link .= "../dropbox/index.php"; } break; case 'Introduction_text': if ($builder != 'builder') { $link .= api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Introduction_text&origin={$origin}#{$id_in_path}"; } else { $s = api_get_path(WEB_COURSE_PATH) . "{$_cid}/index.php?intro_cmdEdit=1"; $link .= $s; } break; case 'Course_description': if ($builder != 'builder') { $link .= api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Course_description&origin={$origin}#{$id_in_path}"; } else { $s = api_get_path(WEB_CODE_PATH) . 'course_description'; $link .= $s; } break; case 'Groups': if ($builder != 'builder') { $link .= api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Groups&origin={$origin}#{$id_in_path}"; } else { $link .= "../group/group.php?origin={$origin}"; } break; case 'Users': if ($builder != 'builder') { $link .= api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Users&origin={$origin}#{$id_in_path}"; } else { $link .= "../user/user.php?origin={$origin}"; } break; } //end huge switch-statement return $link; }
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); $result = Database::query("SELECT * FROM " . $TBL_EXERCICES . " WHERE active='1' ORDER BY id ASC"); while ($myrow = Database::fetch_array($result)) { echo "<img src='../img/quiz.gif'>" . $myrow["title"] . "<br>"; showorhide_addresourcelink($content, $myrow["id"]); echo "<br><br>"; } if ($from_learnpath == 'yes') { $uploadPath = "/HotPotatoes_files"; $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); $documentPath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document'; $sql = "SELECT * FROM " . $TBL_DOCUMENT . " WHERE (path LIKE '%htm%' OR path LIKE '%html%') AND path LIKE '" . $uploadPath . "/%/%' ORDER BY id ASC"; $result = Database::query($sql); while ($myrow = Database::fetch_array($result)) { $path = $myrow["path"]; echo "<img src='../img/jqz.gif'>" . GetQuizName($path, $documentPath) . "<br>"; showorhide_addresourcelink("HotPotatoes", $myrow["id"]); echo "<br><br>"; } } } /* ----------------------------------------------------------- External Links ----------------------------------------------------------- */ if ($content == "Externallink") { ?> <form name="form1" method="post" action=""> <table width="80%" border="0" cellspacing="0" cellpadding="0"> <tr>
$attribute['path'][] = $row['path']; $attribute['visibility'][] = $row['visibility']; $attribute['comment'][] = $row['comment']; } $nbrActiveTests = 0; if (isset($attribute['path']) && is_array($attribute['path'])) { $hotpotatoes_exist = true; while (list($key, $path) = each($attribute['path'])) { $item = ''; list($a, $vis) = each($attribute['visibility']); if (strcmp($vis, "1") == 0) { $active = 1; } else { $active = 0; } $title = GetQuizName($path, $documentPath); if ($title == '') { $title = basename($path); } $class = 'row_even'; if ($count % 2) { $class = 'row_odd'; } // prof only if ($is_allowedToEdit) { $item = Display::tag('td', '<img src="../img/hotpotatoes_s.png" alt="HotPotatoes" /> <a href="showinframes.php?file=' . $path . '&cid=' . api_get_course_id() . '&uid=' . api_get_user_id() . '"' . (!$active ? 'class="invisible"' : '') . '>' . $title . '</a> '); $item .= Display::tag('td', '-'); $actions = Display::url(Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL), 'adminhp.php?' . api_get_cidreq() . '&hotpotatoesName=' . $path); $actions .= '<a href="hotpotatoes_exercise_report.php?' . api_get_cidreq() . '&path=' . $path . '">' . Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL) . '</a>'; // if active if ($active) {
/** * Gets the results of all students (or just one student if access is limited) * @param string The document path (for HotPotatoes retrieval) * @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null */ public function getExercisesReporting($document_path, $hotpotato_name) { $return = array(); $TBL_USER = Database::get_main_table(TABLE_MAIN_USER); $TBL_TRACK_HOTPOTATOES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); $cid = api_get_course_id(); $course_id = api_get_course_int_id(); //$user_id = intval($user_id); $user_id = null; $session_id_and = ' AND te.session_id = ' . api_get_session_id() . ' '; $hotpotato_name = Database::escape_string($hotpotato_name); if (!empty($exercise_id)) { $session_id_and .= " AND exe_exo_id = {$exercise_id} "; } if (empty($user_id)) { $sql = "SELECT firstname as userpart1, lastname as userpart2 ,\n email,\n tth.exe_name,\n tth.exe_result,\n tth.exe_weighting,\n tth.exe_date\n FROM {$TBL_TRACK_HOTPOTATOES} tth, {$TBL_USER} tu\n WHERE tu.user_id=tth.exe_user_id AND\n tth.exe_cours_id = '" . Database::escape_string($cid) . "' AND\n tth.exe_name = '{$hotpotato_name}'\n ORDER BY tth.exe_cours_id ASC, tth.exe_date ASC"; } else { $user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' '; // get only this user's results $sql = "SELECT '', exe_name, exe_result , exe_weighting, exe_date\n FROM {$TBL_TRACK_HOTPOTATOES}\n WHERE\n exe_user_id = '" . $user_id . "' AND\n exe_cours_id = '" . Database::escape_string($cid) . "' AND\n tth.exe_name = '{$hotpotato_name}'\n ORDER BY exe_cours_id ASC, exe_date ASC"; } $results = array(); $resx = Database::query($sql); while ($rowx = Database::fetch_array($resx, 'ASSOC')) { $results[] = $rowx; } $hpresults = array(); $resx = Database::query($sql); while ($rowx = Database::fetch_array($resx, 'ASSOC')) { $hpresults[] = $rowx; } /*if ($filter) { switch ($filter) { case 1 : $filter_by_not_revised = true; break; case 2 : $filter_by_revised = true; break; default : null; } }*/ // Print the Result of Hotpotatoes Tests if (is_array($hpresults)) { for ($i = 0; $i < sizeof($hpresults); $i++) { $return[$i] = array(); $title = GetQuizName($hpresults[$i]['exe_name'], $document_path); if ($title == '') { $title = basename($hpresults[$i]['exe_name']); } if (empty($user_id)) { $return[$i]['email'] = $hpresults[$i]['email']; $return[$i]['first_name'] = $hpresults[$i]['userpart1']; $return[$i]['last_name'] = $hpresults[$i]['userpart2']; } $return[$i]['title'] = $title; $return[$i]['exe_date'] = $hpresults[$i]['exe_date']; $return[$i]['result'] = $hpresults[$i]['exe_result']; $return[$i]['max'] = $hpresults[$i]['exe_weighting']; } } $this->results = $return; return true; }
$newcontent = str_replace($mit, $js_content, $content); $prehref = "<!-- BeginTopNavButtons -->"; $posthref = "<!-- BeginTopNavButtons -->"; $newcontent = str_replace($prehref, $posthref, $newcontent); if (CheckSubFolder($full_file_path . $user_id . '.t.html') == 0) { $newcontent = ReplaceImgTag($newcontent); } } else { $newcontent = $content; } WriteFileCont($full_file_path . $user_id . '.t.html', $newcontent); $doc_url = GetFolderPath($doc_url) . urlencode(basename($doc_url)); $documentPath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . "/document"; $my_file = Security::remove_XSS($_GET['file']); $my_file = str_replace(array('../', '\\..', '\\0', '..\\'), array('', '', '', ''), urldecode($my_file)); $title = GetQuizName($my_file, $documentPath); if ($title == '') { $title = basename($my_file); } $nameTools = $title; $noPHP_SELF = true; if (isset($_SESSION['gradebook'])) { $gradebook = $_SESSION['gradebook']; } if (!empty($gradebook) && $gradebook == 'view') { $interbreadcrumb[] = array('url' => '../gradebook/' . $_SESSION['gradebook_dest'], 'name' => get_lang('ToolGradebook')); } $htmlHeadXtra[] = ' <script> $(document).ready( function(){ var height = $(this).innerHeight() - 20;
/** * Gets the results of all students (or just one student if access is limited) * @param string The document path (for HotPotatoes retrieval) * @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null */ function _getGradeBookReporting($document_path, $user_id = null) { $return = array(); $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST); $TBL_USER = Database::get_main_table(TABLE_MAIN_USER); $TBL_TRACK_EXERCISES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES); $TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); $cid = api_get_course_id(); $course_id = api_get_course_int_id(); if (empty($user_id)) { //get all results (ourself and the others) as an admin should see them //AND exe_user_id <> $_user['user_id'] clause has been removed $sql = "SELECT " . (api_is_western_name_order() ? "CONCAT(firstname,' ',lastname)" : "CONCAT(lastname,' ',firstname)") . ", ce.title, te.exe_result ,\n\t\t\t\t\t\tte.exe_weighting, te.exe_date,te.exe_id, user.email, user.user_id\n\t\t\t\t FROM {$TBL_EXERCISES} ce , {$TBL_TRACK_EXERCISES} te, {$TBL_USER} user\n\t\t\t\t WHERE ce.c_id = {$course_id} AND\n\t\t\t\t \t\tte.exe_exo_id = ce.id AND\n\t\t\t\t \t\tuser_id=te.exe_user_id AND te.c_id = '{$course_id}'\n\t\t\t\t ORDER BY te.c_id ASC, ce.title ASC, te.exe_date ASC"; $hpsql = "SELECT " . (api_is_western_name_order() ? "CONCAT(tu.firstname,' ',tu.lastname)" : "CONCAT(tu.lastname,' ',tu.firstname)") . ", tth.exe_name,\n\t\t\t\t\t\ttth.exe_result , tth.exe_weighting, tth.exe_date, tu.email, tu.user_id\n\t\t\t\t\tFROM {$TBL_TRACK_HOTPOTATOES} tth, {$TBL_USER} tu\n\t\t\t\t\tWHERE tu.user_id=tth.exe_user_id AND tth.c_id = '" . $course_id . "'\n\t\t\t\t\tORDER BY tth.c_id ASC, tth.exe_date ASC"; } else { // get only this user's results $sql = "SELECT '',ce.title, te.exe_result , te.exe_weighting, te.exe_date,te.exe_id\n\t\t\t\t\t\tFROM {$TBL_EXERCISES} ce , {$TBL_TRACK_EXERCISES} te\n\t\t\t\t \t\tWHERE \tce.c_id \t\t= {$course_id} AND\n\t\t\t\t \t\t\t\tte.exe_exo_id \t= ce.id AND\n\t\t\t\t \t\t\t\tte.exe_user_id \t= '" . $user_id . "' AND\n\t\t\t\t \t\t\t\tte.c_id = '{$course_id}'\n\t\t\t\t \t\tORDER BY te.c_id ASC, ce.title ASC, te.exe_date ASC"; $hpsql = "SELECT '',exe_name, exe_result , exe_weighting, exe_date\n\t\t\t\t\tFROM {$TBL_TRACK_HOTPOTATOES}\n\t\t\t\t\tWHERE exe_user_id = '" . $user_id . "' AND c_id = '" . $course_id . "'\n\t\t\t\t\tORDER BY c_id ASC, exe_date ASC"; } $results = getManyResultsXCol($sql, 8); $hpresults = getManyResultsXCol($hpsql, 7); $NoTestRes = 0; $NoHPTestRes = 0; $j = 0; //Print the results of tests if (is_array($results)) { for ($i = 0; $i < sizeof($results); $i++) { $return[$i] = array(); $id = $results[$i][5]; $mailid = $results[$i][6]; $user = $results[$i][0]; $test = $results[$i][1]; $res = $results[$i][2]; if (empty($user_id)) { $user = $results[$i][0]; $return[$i]['user'] = $user; $return[$i]['user_id'] = $results[$i][7]; } $return[$i]['title'] = $test; $return[$i]['time'] = api_convert_and_format_date($results[$i][4], null, date_default_timezone_get()); $return[$i]['result'] = $res; $return[$i]['max'] = $results[$i][3]; $j = $i; } } $j++; // Print the Result of Hotpotatoes Tests if (is_array($hpresults)) { for ($i = 0; $i < sizeof($hpresults); $i++) { $return[$j + $i] = array(); $title = GetQuizName($hpresults[$i][1], $document_path); if ($title == '') { $title = basename($hpresults[$i][1]); } if (empty($user_id)) { $return[$j + $i]['user'] = $hpresults[$i][0]; $return[$j + $i]['user_id'] = $results[$i][6]; } $return[$j + $i]['title'] = $title; $return[$j + $i]['time'] = api_convert_and_format_date($hpresults[$i][4], null, date_default_timezone_get()); $return[$j + $i]['result'] = $hpresults[$i][2]; $return[$j + $i]['max'] = $hpresults[$i][3]; } } $this->results = $return; return true; }
$finish = 1; } } else { // If we are (still) on the first step of the upload process. if ($finish == 0) { $finish = 2; // Get number and name of images from the files contents. GetImgParams('/' . $filename, $document_sys_path . $uploadPath . '/' . $fld, $imgparams, $imgcount); if ($imgcount == 0) { $finish = 1; } else { $dialogBox .= get_lang('DownloadEnd'); } } } $title = @htmlspecialchars(GetQuizName($filename, $document_sys_path . $uploadPath . '/' . $fld . '/'), ENT_COMPAT, api_get_system_encoding()); $query = "UPDATE {$dbTable} SET comment='" . Database::escape_string($title) . "' WHERE c_id = {$course_id} AND path=\"" . $uploadPath . "/" . $fld . "/" . $filename . "\""; Database::query($query); api_item_property_update($_course, TOOL_QUIZ, $id, 'QuizAdded', api_get_user_id()); } else { if ($finish == 2) { // delete? //$dialogBox .= get_lang('NoImg'); } $finish = 0; // error if (api_failure::get_last_failure() == 'not_enough_space') { $dialogBox .= get_lang('NoSpace'); } elseif (api_failure::get_last_failure() == 'php_file_in_zip_file') { $dialogBox .= get_lang('ZipNoPhp'); }
while ($myrow = Database::fetch_array($result)) { echo Display::return_icon('quiz.gif'); echo $myrow["title"] . "<br>"; showorhide_addresourcelink($content, $myrow["id"]); echo "<br><br>"; } if ($from_learnpath == 'yes') { $uploadPath = "/HotPotatoes_files"; $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); $documentPath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document'; $sql = "SELECT * FROM " . $TBL_DOCUMENT . " WHERE (path LIKE '%htm%' OR path LIKE '%html%') AND path LIKE '" . $uploadPath . "/%/%' ORDER BY id ASC"; $result = Database::query($sql); while ($myrow = Database::fetch_array($result)) { $path = $myrow["path"]; echo Display::return_icon('jqz.gif'); echo GetQuizName($path, $documentPath) . "<br>"; showorhide_addresourcelink("HotPotatoes", $myrow["id"]); echo "<br><br>"; } } } /* ----------------------------------------------------------- External Links ----------------------------------------------------------- */ if ($content == "Externallink") { ?> <form name="form1" method="post" action=""> <table width="80%" border="0" cellspacing="0" cellpadding="0"> <tr>
/** * This function is to create and return a link to the added resources (lessons). * It returns the same thing as display_addedresource_link_in_learnpath() but doesn't display * anything. * * Parameters: * @param type - that is the correspondent type in the mirror tool (like this is a Link item) * @param id - that is the correspondent id in the mirror tool (like Agenda item 2) * @param id_in_path - the unique index in the items table */ function get_addedresource_link_in_learnpath($type, $id, $id_in_path) { global $_course, $learnpath_id, $tbl_learnpath_item, $items; global $curDirPath, $_configuration, $enableDocumentParsing, $_user , $_cid; $hyperlink_target_parameter = ""; //or e.g. target='_blank' $builder = 'player'; $origin='learnpath'; $linktype=$type; if (($type=="Link _self") or ($type=="Link _blank")) { $type="Link"; } $link = ''; switch ($type) { case "Agenda": $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA,$_course['dbName']);; $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE id=$id"); $myrow=Database::fetch_array($result); $sql="select * from $tbl_learnpath_item where id=$id_in_path"; $result=Database::query($sql); $row=Database::fetch_array($result); if ($row['title'] != '') { $myrow["title"]=$row['title']; } $desc=$row['description']; $agenda_id=$row['item_id']; if ($builder != 'builder') { $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path"; } else { $link .= "../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id"; } break; case "Ad_Valvas": $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); $result = Database::query("SELECT * FROM $tbl_announcement WHERE id=$id"); $myrow=Database::fetch_array($result); if ($builder != 'builder') { $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$id#$id_in_path"; } else { $link .= "../announcements/announcements.php?origin=$origin&ann_id=$id"; } break; case "Link" : $TABLETOOLLINK = Database::get_course_table(TABLE_LINK,$_course['dbName']); $result= Database::query("SELECT * FROM $TABLETOOLLINK WHERE id=$id"); $myrow=Database::fetch_array($result); $sql="select * from $tbl_learnpath_item where id=$id_in_path"; $result=Database::query($sql); $row=Database::fetch_array($result); $thelink=$myrow["url"]; if ($builder != 'builder') { $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path"; } else { $link .= $thelink; } break; case "Exercise": $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST,$_course['dbName']); $result= Database::query("SELECT * FROM $TBL_EXERCICES WHERE id=$id"); $myrow=Database::fetch_array($result); if ($builder=='builder') { $origin='builder'; } //this is needed for the exercise_submit.php can delete the session info about tests $sql="select * from $tbl_learnpath_item where id=$id_in_path"; $result=Database::query($sql); $row=Database::fetch_array($result); if ($row['title'] != '') { $myrow["title"]=$row['title']; } if ($builder != 'builder') { $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path"; } else { $link .= "../exercice/exercise_submit.php?origin=$origin&exerciseId=".$myrow["id"]; } break; case "HotPotatoes": $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT,$_course['dbName']); $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; $result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE id=$id"); $myrow= Database::fetch_array($result); $path=$myrow["path"]; $name=GetQuizName($path,$documentPath); if ($builder=='builder') { $origin='builder'; } $cid = $_course['official_code']; if ($builder != 'builder') { $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path"; } else { $link .= "../exercice/showinframes.php?file=$path&cid=$cid&uid=".$_user['user_id'].""; } break; case "Forum": //deprecated $TBL_FORUMS = Database::get_course_table(TABLE_FORUM,$_course['dbName']); $result= Database::query("SELECT * FROM $TBL_FORUMS WHERE forum_id=$id"); $myrow=Database::fetch_array($result); if ($builder=='builder') { $origin='builder'; } $sql="select * from $tbl_learnpath_item where id=$id_in_path"; $result=Database::query($sql); $row=Database::fetch_array($result); if ($row['title'] != '') { $myrow["forum_name"]=$row['title']; } if ($myrow["forum_name"]=='') { $type="Forum"; } $forumparameters="forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]; if ($builder != 'builder') { $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path"; } else { $link .= "../phpbb/viewforum.php?$forumparameters"; } break; case "Thread": //forum post //deprecated $tbl_topics = $_course['dbNameGlu'].'bb_topics'; $tbl_posts = $_course['dbNameGlu'].'bb_posts'; $TBL_FORUMS = $_course['dbNameGlu']."bb_forums"; $sql="SELECT * FROM $tbl_topics where topic_id=$id"; $result= Database::query($sql); $myrow=Database::fetch_array($result); $sql="select * from $tbl_learnpath_item where id=$id_in_path"; $result=Database::query($sql); $row=Database::fetch_array($result); if ($builder != 'builder') { $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path"; } else { $link .= "../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]; } break; case "Post": /* todo REVIEW THIS SECTION - NOT USING VALID TABLES ANYMORE $tbl_posts = $_course['dbNameGlu'].'bb_posts'; $tbl_posts_text = $_course['dbNameGlu'].'bb_posts_text'; $TBL_FORUMS = $_course['dbNameGlu']."bb_forums"; $result= Database::query("SELECT * FROM $tbl_posts where post_id=$id"); $myrow=Database::fetch_array($result); // grabbing the title of the post $sql_titel="SELECT * FROM $tbl_posts_text WHERE post_id=".$myrow["post_id"]; $result_titel=Database::query($sql_titel); $myrow_titel=Database::fetch_array($result_titel); $sql="select * from $tbl_learnpath_item where id=$id_in_path"; $result=Database::query($sql); $row=Database::fetch_array($result); if ($row['title'] != '') { $myrow_titel["post_title"]=$row['title']; } $desc=$row['description']; $link .= str_repeat(" >",$level); $posternom=$myrow['nom']; $posterprenom=$myrow['prenom']; $posttime=$myrow['post_time']; $posttext=$myrow_titel['post_text']; $posttitle=$myrow_titel['post_title']; $posttext = str_replace('"',"'",$posttext); if ($builder != 'builder') { $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path"; } else { $link .= "../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]; } */ break; case "Document": $dbTable = Database::get_course_table(TABLE_DOCUMENT,$_course['dbName']); $result=Database::query("SELECT * FROM $dbTable WHERE id=$id",__FILE__,__LINE); $myrow=Database::fetch_array($result); $pathname=explode("/",$myrow["path"]); // making a correct name for the link $last=count($pathname)-1; // making a correct name for the link $filename=$pathname[$last]; // making a correct name for the link $sql="select * from $tbl_learnpath_item where id=$id_in_path"; $result=Database::query($sql); $row=Database::fetch_array($result); if ($builder != 'builder') { $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path"; } else { $enableDocumentParsing='yes'; if (!$enableDocumentParsing) { //this is the solution for the non-parsing version in the builder $file=urlencode($myrow["path"]); $link .= "../document/showinframes.php?file=$file"; } else { $link .= "../document/download.php?doc_url=".$myrow["path"]; } } break; case "Assignments": if ($builder != 'builder') { $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path"; } else { $link .= "../work/work.php"; } break; case "Dropbox": if ($builder != 'builder') { $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path"; } else { $link .= "../dropbox/index.php"; } break; case "Introduction_text": if ($builder != 'builder') { $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path"; } else { $s = api_get_path(WEB_COURSE_PATH)."$_cid/index.php?intro_cmdEdit=1"; $link .= $s; } break; case "Course_description": if ($builder != 'builder') { $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path"; } else { $s=api_get_path(WEB_CODE_PATH)."course_description"; $link .= $s; } break; case "Groups": if ($builder != 'builder') { $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path"; } else { $link .= "../group/group.php?origin=$origin"; } break; case "Users": if ($builder != 'builder') { $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path"; } else { $link .= "../user/user.php?origin=$origin"; } break; }//end huge switch-statement return $link; }
<h4> <?php echo $nameTools; ?> </h4> <?php if (isset($newName)) { if ($newName != "") { //alter database record for that test SetComment($hotpotatoesName, $newName); echo "<script type='text/javascript'>window.location='" . $urlMainExercise . "exercice.php'; </script>"; } } echo "<form action=\"" . $urlMainExercise . "adminhp.php\" method='post' name='form1'>"; echo "<input type=\"hidden\" name=\"hotpotatoesName\" value=\"{$hotpotatoesName}\">"; echo "<input type=\"text\" name=\"newName\" value=\""; $lstrComment = ""; $lstrComment = GetComment($hotpotatoesName); if ($lstrComment == "") { $lstrComment = GetQuizName($hotpotatoesName, $documentPath); } if ($lstrComment == "") { $lstrComment = basename($hotpotatoesName, $documentPath); } echo $lstrComment; echo "\" size=40> "; echo "<button type=\"submit\" class=\"save\" name=\"submit\" value=\"" . get_lang('Ok') . "\">" . get_lang('Ok') . "</button>"; echo "<button type=\"button\" class=\"cancel\" name=\"cancel\" value=\"" . get_lang('Cancel') . "\" onclick=\"javascript:document.form1.newName.value='';\">" . get_lang('Cancel') . "</button>"; echo "</form>"; Display::display_footer();
/** * Gets the results of all students (or just one student if access is limited) * @param string The document path (for HotPotatoes retrieval) * @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null */ function _getExercisesReporting($document_path, $user_id = null, $filter = 0, $exercise_id = 0, $hotpotato_name = null) { $return = array(); $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST); $TBL_USER = Database::get_main_table(TABLE_MAIN_USER); $TBL_TRACK_EXERCISES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES); $TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); $TBL_TRACK_ATTEMPT_RECORDING = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING); $TBL_TABLE_LP_MAIN = Database::get_course_table(TABLE_LP_MAIN); $cid = api_get_course_id(); $course_id = api_get_course_int_id(); $user_id = intval($user_id); $session_id_and = ' AND te.session_id = ' . api_get_session_id() . ' '; $exercise_id = intval($exercise_id); $hotpotato_name = Database::escape_string($hotpotato_name); if (!empty($exercise_id)) { $session_id_and .= " AND exe_exo_id = {$exercise_id} "; } if (empty($user_id)) { $user_id_and = null; $sql = "SELECT " . (api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2") . ",\n ce.title as extitle,\n te.exe_result as exresult ,\n te.exe_weighting as exweight,\n te.exe_date as exdate,\n te.exe_id as exid,\n email as exemail,\n te.start_date as exstart,\n steps_counter as exstep,\n exe_user_id as excruid,\n te.exe_duration as duration\n FROM {$TBL_EXERCISES} AS ce \n INNER JOIN {$TBL_TRACK_EXERCISES} AS te ON (te.exe_exo_id = ce.iid) \n INNER JOIN {$TBL_USER} AS user ON (user.user_id = exe_user_id)\n LEFT JOIN {$TBL_TABLE_LP_MAIN} AS tlm ON tlm.id = te.orig_lp_id AND tlm.c_id = ce.c_id\n WHERE ce.c_id = {$course_id} AND\n te.status != 'incomplete' AND\n te.c_id = '" . $course_id . "' {$user_id_and} {$session_id_and} AND\n ce.active <>-1 AND\n orig_lp_id = 0 AND\n orig_lp_item_id = 0"; $hpsql = "SELECT " . (api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2") . ",\n email,\n tth.exe_name,\n tth.exe_result,\n tth.exe_weighting,\n tth.exe_date\n FROM {$TBL_TRACK_HOTPOTATOES} tth, {$TBL_USER} tu\n WHERE tu.user_id=tth.exe_user_id AND\n tth.c_id = '" . $course_id . "' AND\n tth.exe_name = '{$hotpotato_name}'\n ORDER BY tth.c_id ASC, tth.exe_date DESC"; } else { $user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' '; // get only this user's results $sql = "SELECT " . (api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2") . ",\n ce.title as extitle,\n te.exe_result as exresult,\n te.exe_weighting as exweight,\n te.exe_date as exdate,\n te.exe_id as exid,\n email as exemail,\n te.start_date as exstart,\n steps_counter as exstep,\n exe_user_id as excruid,\n te.exe_duration as duration,\n ce.results_disabled as exdisabled,\n te.orig_lp_id as orig_lp_id,\n tlm.name as lp_name\n FROM {$TBL_EXERCISES} AS ce \n INNER JOIN {$TBL_TRACK_EXERCISES} AS te ON (te.exe_exo_id = ce.id) \n INNER JOIN {$TBL_USER} AS user ON (user.user_id = exe_user_id)\n LEFT JOIN {$TBL_TABLE_LP_MAIN} AS tlm ON tlm.id = te.orig_lp_id AND tlm.c_id = ce.c_id\n WHERE ce.c_id = {$course_id} AND\n te.status != 'incomplete' AND\n te.c_id ='" . $course_id . "' {$user_id_and} {$session_id_and} AND\n ce.active <>-1 AND\n orig_lp_id = 0 AND\n orig_lp_item_id = 0\n ORDER BY userpart2, te.c_id ASC, ce.title ASC, te.exe_date DESC"; $hpsql = "SELECT '', exe_name, exe_result , exe_weighting, exe_date\n FROM {$TBL_TRACK_HOTPOTATOES}\n WHERE exe_user_id = '" . $user_id . "' AND\n c_id = '" . $course_id . "' AND\n tth.exe_name = '{$hotpotato_name}'\n ORDER BY c_id ASC, exe_date DESC"; } $results = array(); $resx = Database::query($sql); while ($rowx = Database::fetch_array($resx, 'ASSOC')) { $results[] = $rowx; } $hpresults = array(); $resx = Database::query($hpsql); while ($rowx = Database::fetch_array($resx, 'ASSOC')) { $hpresults[] = $rowx; } $filter_by_not_revised = false; $filter_by_revised = false; if ($filter) { switch ($filter) { case 1: $filter_by_not_revised = true; break; case 2: $filter_by_revised = true; break; default: null; } } //Print the results of tests if (is_array($results) && empty($hotpotato_name)) { for ($i = 0; $i < sizeof($results); $i++) { $revised = false; //revised or not $sql_exe = "SELECT exe_id FROM {$TBL_TRACK_ATTEMPT_RECORDING}\n\t\t\t\t\t\t\tWHERE author != '' AND exe_id = " . Database::escape_string($results[$i]['exid']) . " LIMIT 1"; $query = Database::query($sql_exe); if (Database::num_rows($query) > 0) { $revised = true; } if ($filter_by_not_revised && $revised) { continue; } if ($filter_by_revised && !$revised) { continue; } $return[$i] = array(); if (empty($user_id)) { $return[$i]['first_name'] = $results[$i]['userpart1']; $return[$i]['last_name'] = $results[$i]['userpart2']; $return[$i]['user_id'] = $results[$i]['excruid']; $return[$i]['email'] = $results[$i]['exemail']; } $return[$i]['title'] = $results[$i]['extitle']; $return[$i]['start_date'] = api_get_local_time($results[$i]['exstart']); $return[$i]['end_date'] = api_get_local_time($results[$i]['exdate']); $return[$i]['duration'] = $results[$i]['duration']; $return[$i]['result'] = $results[$i]['exresult']; $return[$i]['max'] = $results[$i]['exweight']; $return[$i]['status'] = $revised ? get_lang('Validated') : get_lang('NotValidated'); $return[$i]['lp_id'] = $results[$i]['orig_lp_id']; $return[$i]['lp_name'] = $results[$i]['lp_name']; } } // Print the Result of Hotpotatoes Tests if (is_array($hpresults)) { for ($i = 0; $i < sizeof($hpresults); $i++) { $return[$i] = array(); $title = GetQuizName($hpresults[$i]['exe_name'], $document_path); if ($title == '') { $title = basename($hpresults[$i]['exe_name']); } if (empty($user_id)) { $return[$i]['email'] = $hpresults[$i]['email']; $return[$i]['first_name'] = $hpresults[$i]['userpart1']; $return[$i]['last_name'] = $hpresults[$i]['userpart2']; } $return[$i]['title'] = $title; $return[$i]['start_date'] = api_get_local_time($results[$i]['exstart']); $return[$i]['end_date'] = api_get_local_time($results[$i]['exdate']); $return[$i]['duration'] = $results[$i]['duration']; $return[$i]['result'] = $hpresults[$i]['exe_result']; $return[$i]['max'] = $hpresults[$i]['exe_weighting']; } } $this->results = $return; return true; }