Merge branch '1.10.x' of https://github.com/chamilo/chamilo-lms into B9082
Conflicts: .gitignore1.10.x
commit
dfdb3fcce7
@ -1,11 +1,47 @@ |
||||
{ |
||||
"name": "chamilo/chamilo-lms", |
||||
"description": "E-learning and collaboration software", |
||||
"type": "project", |
||||
"homepage": "http://www.chamilo.org", |
||||
"license": "GPL-3.0", |
||||
"support": { |
||||
"forum": "http://www.chamilo.org/forum", |
||||
"irc": "irc://irc.freenode.org/chamilo" |
||||
}, |
||||
"autoload": { |
||||
"classmap": [ |
||||
"main/auth", |
||||
"main/admin", |
||||
"main/cron/lang", |
||||
"main/coursecopy", |
||||
"main/exercice", |
||||
"main/gradebook/lib", |
||||
"main/newscorm", |
||||
"main/inc/lib", |
||||
"plugin", |
||||
"main/install", |
||||
"main/inc/lib/getid3", |
||||
"main/survey", |
||||
"main/inc/lib/hook" |
||||
] |
||||
}, |
||||
"require": { |
||||
"php": ">=5.3.3", |
||||
"php-ffmpeg/php-ffmpeg": "0.3.x-dev@dev", |
||||
"sabre/vobject": "~3.1", |
||||
"toin0u/digitalocean": "~1.4", |
||||
"twig/twig": "1.*", |
||||
"michelf/php-markdown": "1.4.1", |
||||
"emojione/emojione": "1.3.0", |
||||
"zendframework/zend-config": "2.3.3" |
||||
"zendframework/zend-config": "2.3.3", |
||||
"ezyang/htmlpurifier": "4.6.0", |
||||
"szymach/c-pchart": "1.*", |
||||
"aferrandini/phpqrcode": "1.0.1", |
||||
"mpdf/mpdf": "5.7.4" |
||||
}, |
||||
"extra": { |
||||
"branch-alias": { |
||||
"dev-master": "1.10.x-dev" |
||||
} |
||||
} |
||||
} |
||||
|
||||
@ -0,0 +1,6 @@ |
||||
<html> |
||||
<head> |
||||
</head> |
||||
<body> |
||||
</body> |
||||
</html> |
||||
|
@ -0,0 +1,344 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* Generate a teacher time report in platform or sessions/courses |
||||
* |
||||
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com> |
||||
* @package chamilo.admin |
||||
*/ |
||||
/* INIT SECTION */ |
||||
|
||||
// Language files that need to be included. |
||||
if (isset($_GET['category']) && $_GET['category'] == 'Templates') { |
||||
$language_file = array('admin', 'document'); |
||||
} else if (isset($_GET['category']) && $_GET['category'] == 'Gradebook') { |
||||
$language_file = array('admin', 'gradebook'); |
||||
} else { |
||||
$language_file = array('admin', 'document'); |
||||
} |
||||
$language_file[] = 'tracking'; |
||||
|
||||
// Resetting the course id. |
||||
$cidReset = true; |
||||
|
||||
// Including some necessary library files. |
||||
require_once '../inc/global.inc.php'; |
||||
require_once api_get_path(LIBRARY_PATH) . 'TeacherTimeReport.php'; |
||||
|
||||
// Setting the section (for the tabs). |
||||
$this_section = SECTION_PLATFORM_ADMIN; |
||||
|
||||
$interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin')); |
||||
|
||||
$toolName = get_lang('TeacherTimeReport'); |
||||
|
||||
// Access restrictions. |
||||
api_protect_admin_script(); |
||||
|
||||
$startDate = new DateTime(api_get_local_time()); |
||||
$startDate->modify('first day of this month'); |
||||
|
||||
$limitDate = new DateTime(api_get_local_time()); |
||||
|
||||
$selectedCourse = isset($_REQUEST['course']) ? $_REQUEST['course'] : null; |
||||
$selectedSession = isset($_REQUEST['session']) ? $_REQUEST['session'] : 0; |
||||
$selectedTeacher = isset($_REQUEST['teacher']) ? $_REQUEST['teacher'] : 0; |
||||
$selectedFrom = isset($_REQUEST['from']) && !empty($_REQUEST['from']) ? $_REQUEST['from'] : $startDate->format('Y-m-d'); |
||||
$selectedUntil = isset($_REQUEST['from']) && !empty($_REQUEST['until']) ? $_REQUEST['until'] : $limitDate->format('Y-m-d'); |
||||
|
||||
$courseList = CourseManager::get_courses_list(0, 0, 'title'); |
||||
$sessionsList = SessionManager::get_sessions_list(array(), array('name')); |
||||
|
||||
$teacherList = UserManager::getTeachersList(); |
||||
|
||||
$htmlHeadXtra[] = ' |
||||
<script src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/daterange/moment.min.js"></script> |
||||
<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/daterange/daterangepicker-bs2.css"> |
||||
<script src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/daterange/daterangepicker.js"></script>'; |
||||
|
||||
$withFilter = false; |
||||
|
||||
$reportTitle = get_lang('TimeReportIncludingAllCoursesAndSessionsByTeacher'); |
||||
$reportSubTitle = sprintf(get_lang('TimeSpentBetweenXAndY'), $selectedFrom, $selectedUntil); |
||||
|
||||
$timeReport = new TeacherTimeReport(); |
||||
|
||||
if (!empty($selectedCourse)) { |
||||
$withFilter = true; |
||||
|
||||
$course = api_get_course_info($selectedCourse); |
||||
|
||||
$reportTitle = sprintf(get_lang('TimeReportForCourseX'), $course['title']); |
||||
|
||||
$teachers = CourseManager::get_teacher_list_from_course_code($selectedCourse); |
||||
|
||||
foreach ($teachers as $teacher) { |
||||
$totalTime = UserManager::getExpendedTimeInCourses( |
||||
$teacher['user_id'], |
||||
$selectedCourse, |
||||
0, |
||||
$selectedFrom, |
||||
$selectedUntil |
||||
); |
||||
$formatedTime = api_format_time($totalTime); |
||||
|
||||
$timeReport->data[] = array( |
||||
'session' => null, |
||||
'course' => array( |
||||
'id' => $course['real_id'], |
||||
'name' => $course['title'] |
||||
), |
||||
'coach' => array( |
||||
'userId' => $teacher['user_id'], |
||||
'lastname' => $teacher['lastname'], |
||||
'firstname' => $teacher['firstname'], |
||||
'username' => $teacher['username'], |
||||
'completeName' => api_get_person_name($teacher['firstname'], $teacher['lastname']) |
||||
), |
||||
'totalTime' => $formatedTime |
||||
); |
||||
} |
||||
|
||||
$sessionsByCourse = SessionManager::get_session_by_course($selectedCourse); |
||||
|
||||
foreach ($sessionsByCourse as $session) { |
||||
$coaches = CourseManager::get_coachs_from_course($session['id'], $selectedCourse); |
||||
|
||||
if ($coaches) { |
||||
foreach ($coaches as $coach) { |
||||
$totalTime = UserManager::getExpendedTimeInCourses( |
||||
$coach['user_id'], |
||||
$selectedCourse, |
||||
$session['id'], |
||||
$selectedFrom, |
||||
$selectedUntil |
||||
); |
||||
$formatedTime = api_format_time($totalTime); |
||||
|
||||
$timeReport->data[] = array( |
||||
'session' => array( |
||||
'id' => $session['id'], |
||||
'name' => $session['name'] |
||||
), |
||||
'course' => array( |
||||
'id' => $course['real_id'], |
||||
'name' => $course['title'] |
||||
), |
||||
'coach' => array( |
||||
'userId' => $coach['user_id'], |
||||
'lastname' => $coach['lastname'], |
||||
'firstname' => $coach['firstname'], |
||||
'username' => $coach['username'], |
||||
'completeName' => api_get_person_name($coach['firstname'], $coach['lastname']) |
||||
), |
||||
'totalTime' => $formatedTime |
||||
); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (!empty($selectedSession)) { |
||||
$withFilter = true; |
||||
|
||||
$session = api_get_session_info($selectedSession); |
||||
$sessionData = array( |
||||
'id' => $session['id'], |
||||
'name' => $session['name'] |
||||
); |
||||
|
||||
$reportTitle = sprintf(get_lang('TimeReportForSessionX'), $session['name']); |
||||
|
||||
$courses = SessionManager::get_course_list_by_session_id($selectedSession); |
||||
|
||||
foreach ($courses as $course) { |
||||
$courseData = array( |
||||
'id' => $course['id'], |
||||
'name' => $course['title'] |
||||
); |
||||
|
||||
$coaches = CourseManager::get_coachs_from_course($selectedSession, $course['code']); |
||||
|
||||
if ($coaches) { |
||||
foreach ($coaches as $coach) { |
||||
$totalTime = UserManager::getExpendedTimeInCourses( |
||||
$coach['user_id'], |
||||
$course['code'], |
||||
$selectedSession, |
||||
$selectedFrom, |
||||
$selectedUntil |
||||
); |
||||
$formatedTime = api_format_time($totalTime); |
||||
|
||||
$timeReport->data[] = array( |
||||
'session' => $sessionData, |
||||
'course' => $courseData, |
||||
'coach' => array( |
||||
'userId' => $coach['user_id'], |
||||
'lastname' => $coach['lastname'], |
||||
'firstname' => $coach['firstname'], |
||||
'username' => $coach['username'], |
||||
'completeName' => api_get_person_name($coach['firstname'], $coach['lastname']) |
||||
), |
||||
'totalTime' => $formatedTime |
||||
); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (!empty($selectedTeacher)) { |
||||
$withFilter = true; |
||||
|
||||
$teacher = api_get_user_info(); |
||||
|
||||
$teacherData = array( |
||||
'userId' => $teacher['user_id'], |
||||
'lastname' => $teacher['lastname'], |
||||
'firstname' => $teacher['firstname'], |
||||
'username' => $teacher['username'], |
||||
'completeName' => $teacher['complete_name'] |
||||
); |
||||
|
||||
$reportTitle = sprintf(get_lang('TimeReportForTeacherX'), $teacher['complete_name']); |
||||
|
||||
$courses = CourseManager::get_courses_list_by_user_id($selectedTeacher, false); |
||||
|
||||
if (!empty($courses)) { |
||||
foreach ($courses as $course) { |
||||
$courseInfo = api_get_course_info($course['code']); |
||||
|
||||
$totalTime = UserManager::getExpendedTimeInCourses( |
||||
$selectedTeacher, |
||||
$course['code'], |
||||
0, |
||||
$selectedFrom, |
||||
$selectedUntil |
||||
); |
||||
$formatedTime = api_format_time($totalTime); |
||||
|
||||
$timeReport->data[] = array( |
||||
'session' => null, |
||||
'course' => array( |
||||
'id' => $courseInfo['real_id'], |
||||
'name' => $courseInfo['title'] |
||||
), |
||||
'coach' => $teacherData, |
||||
'totalTime' => $formatedTime |
||||
); |
||||
} |
||||
} |
||||
|
||||
$coursesInSession = SessionManager::getCoursesListByCourseCoach($selectedTeacher); |
||||
|
||||
foreach ($coursesInSession as $course) { |
||||
$session = api_get_session_info($course['id_session']); |
||||
$sessionData = array( |
||||
'id' => $session['id'], |
||||
'name' => $session['name'] |
||||
); |
||||
|
||||
$courseInfo = api_get_course_info($course['course_code']); |
||||
|
||||
$totalTime = UserManager::getExpendedTimeInCourses( |
||||
$selectedTeacher, |
||||
$course['course_code'], |
||||
$session['id'], |
||||
$selectedFrom, |
||||
$selectedUntil |
||||
); |
||||
$formatedTime = api_format_time($totalTime); |
||||
|
||||
$timeReport->data[] = array( |
||||
'session' => $sessionData, |
||||
'course' => array( |
||||
'id' => $courseInfo['real_id'], |
||||
'name' => $courseInfo['title'] |
||||
), |
||||
'coach' => $teacherData, |
||||
'totalTime' => $formatedTime |
||||
); |
||||
} |
||||
} |
||||
|
||||
if (empty($selectedCourse) && empty($selectedSession) && empty($selectedTeacher)) { |
||||
foreach ($teacherList as &$teacher) { |
||||
$timeReport->data[] = array( |
||||
'coach' => array( |
||||
'username' => $teacher['username'], |
||||
'completeName' => $teacher['completeName'], |
||||
), |
||||
'totalTime' => SessionManager::getTotalUserTimeInPlatform($teacher['user_id'], $selectedFrom, $selectedUntil) |
||||
); |
||||
} |
||||
} |
||||
|
||||
$timeReport->sortData($withFilter); |
||||
|
||||
if (isset($_GET['export'])) { |
||||
require_once api_get_path(LIBRARY_PATH) . 'export.lib.inc.php'; |
||||
|
||||
$dataToExport = $timeReport->prepareDataToExport($withFilter); |
||||
|
||||
$fileName = get_lang('TeacherTimeReport') . ' ' . api_get_local_time(); |
||||
|
||||
switch ($_GET['export']) { |
||||
case 'pdf': |
||||
$params = array( |
||||
'add_signatures' => false, |
||||
'filename' => $fileName, |
||||
'pdf_title' => "$reportTitle - $reportSubTitle", |
||||
'pdf_description' => get_lang('TeacherTimeReport'), |
||||
'format' => 'A4-L', |
||||
'orientation' => 'L' |
||||
); |
||||
|
||||
$pdfContent = Export::convert_array_to_html($dataToExport); |
||||
|
||||
Export::export_html_to_pdf($pdfContent, $params); |
||||
break; |
||||
case 'xls': |
||||
array_unshift($dataToExport, array( |
||||
$reportTitle |
||||
), array( |
||||
$reportSubTitle |
||||
), array()); |
||||
|
||||
Export::export_table_xls_html($dataToExport, $fileName); |
||||
break; |
||||
} |
||||
|
||||
die; |
||||
} |
||||
|
||||
// view |
||||
//hack for daterangepicker |
||||
$startDate->modify('+1 day'); |
||||
$limitDate->modify('+1 day'); |
||||
|
||||
$tpl = new Template($toolName); |
||||
$tpl->assign('reportTitle', $reportTitle); |
||||
$tpl->assign('reportSubTitle', $reportSubTitle); |
||||
|
||||
$tpl->assign('filterStartDate', $startDate->format('Y-m-d')); |
||||
$tpl->assign('filterEndDate', $limitDate->format('Y-m-d')); |
||||
$tpl->assign('filterMaxDate', $limitDate->format('Y-m-d')); |
||||
|
||||
$tpl->assign('selectedCourse', $selectedCourse); |
||||
$tpl->assign('selectedSession', $selectedSession); |
||||
$tpl->assign('selectedTeacher', $selectedTeacher); |
||||
$tpl->assign('selectedFrom', $selectedFrom); |
||||
$tpl->assign('selectedUntil', $selectedUntil); |
||||
|
||||
$tpl->assign('withFilter', $withFilter); |
||||
|
||||
$tpl->assign('courses', $courseList); |
||||
$tpl->assign('sessions', $sessionsList); |
||||
$tpl->assign('courseCoaches', $teacherList); |
||||
|
||||
$tpl->assign('rows', $timeReport->data); |
||||
|
||||
$contentTemplate = $tpl->get_template('admin/teacher_time_report.tpl'); |
||||
|
||||
$tpl->display($contentTemplate); |
||||
@ -0,0 +1,105 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Automatic fix online time procedure. If a COURSEMANAGER has been idle for $timeLimit |
||||
* or more then the procedure adds $extraTime to his logout_course_date. |
||||
* @package chamilo.cron |
||||
* @author Imanol Losada <imanol.losada@beeznest.com> |
||||
*/ |
||||
require_once __DIR__ . '/../inc/global.inc.php'; |
||||
|
||||
/** |
||||
* Get ids of COURSEMANAGERs that are inside a course right now |
||||
* @return array COURSEMANAGER's ids |
||||
*/ |
||||
function getTeachersInCourseIds() |
||||
{ |
||||
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
||||
$joinStatement = ' JOIN ' . Database::get_main_table(TABLE_MAIN_USER) . ' ON login_user_id = user_id'; |
||||
return Database::select( |
||||
'login_user_id', $table . $joinStatement, |
||||
array( |
||||
'where' => array( |
||||
'course IS NOT NULL AND status = ?' => array( |
||||
COURSEMANAGER |
||||
) |
||||
) |
||||
) |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* If a COURSEMANAGER has been idle for $timeLimit or more then |
||||
* the procedure adds $extraTime to his logout_course_date. |
||||
* @param array COURSEMANAGER's ids |
||||
* @return void |
||||
*/ |
||||
function updateTeachersInCourseIdleForTimeLimit($teachersInCourseIds) |
||||
{ |
||||
$timeLimit = '- 30 minute'; |
||||
$extraTime = '+ 5 minute'; |
||||
$utcResult = Database::fetch_array( |
||||
Database::query('SELECT UTC_TIMESTAMP') |
||||
); |
||||
$dataBaseCurrentHour = array_shift($utcResult); |
||||
$maximumIdleTimeInCourse = date( |
||||
'Y-m-d H:i:s', |
||||
strtotime($dataBaseCurrentHour . ' ' . $timeLimit) |
||||
); |
||||
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); |
||||
$onLineTrackTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
||||
foreach ($teachersInCourseIds as $key => $value) { |
||||
$value = array_shift($value); |
||||
$logResult = Database::select( |
||||
'course_access_id,logout_course_date', |
||||
$table, |
||||
array( |
||||
'where' => array( |
||||
'user_id = ?' => array( |
||||
$value, |
||||
) |
||||
), |
||||
'order' => 'course_access_id DESC', |
||||
'limit' => '1' |
||||
) |
||||
); |
||||
$currentTeacherData = array_shift($logResult); |
||||
Database::update( |
||||
$table, |
||||
array( |
||||
'logout_course_date' => date( |
||||
'Y-m-d H:i:s', |
||||
strtotime($currentTeacherData['logout_course_date'] . ' ' . $extraTime) |
||||
) |
||||
), |
||||
array( |
||||
'user_id = ? AND logout_course_date < ? AND course_access_id = ?' => array( |
||||
$value, |
||||
$maximumIdleTimeInCourse, |
||||
$currentTeacherData['course_access_id'] |
||||
) |
||||
) |
||||
); |
||||
/* |
||||
* (Avoid multiple updates) |
||||
* When the user enters a course, this field is updated with the course code. |
||||
* And when the user goes to another tool, returns to NULL |
||||
*/ |
||||
$userId = intval($value); |
||||
$updateOnLineSql = "UPDATE $onLineTrackTable SET " |
||||
. "COURSE = NULL " |
||||
. "WHERE login_user_id = $userId"; |
||||
Database::query($updateOnLineSql); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Initialization |
||||
*/ |
||||
if (php_sapi_name() != 'cli') { |
||||
exit; //do not run from browser |
||||
} |
||||
$teachersInCourseIds = getTeachersInCourseIds(); |
||||
if (!empty($teachersInCourseIds)) { |
||||
updateTeachersInCourseIdleForTimeLimit($teachersInCourseIds); |
||||
} |
||||
@ -1,578 +0,0 @@ |
||||
<?php // $Id: $
|
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* @copyright (c) 2007 Dokeos |
||||
* @copyright (c) 2001-2006 Universite catholique de Louvain (UCL) |
||||
* |
||||
* @license http://www.gnu.org/copyleft/gpl.html (GPL) GENERAL PUBLIC LICENSE |
||||
* |
||||
* @author Claro Team <cvs@claroline.net> |
||||
* @author Yannick Warnier <yannick.warnier@beeznest.com> |
||||
* @package chamilo.exercise |
||||
*/ |
||||
/** |
||||
* Code |
||||
*/ |
||||
if ( count( get_included_files() ) == 1 ) die( '---' ); |
||||
require_once '../../exercise.class.php'; |
||||
require_once '../../question.class.php'; |
||||
require_once '../../answer.class.php'; |
||||
require_once '../../unique_answer.class.php'; |
||||
require_once '../../multiple_answer.class.php'; |
||||
require_once '../../fill_blanks.class.php'; |
||||
require_once '../../freeanswer.class.php'; |
||||
require_once '../../hotspot.class.php'; |
||||
require_once '../../matching.class.php'; |
||||
require_once '../../hotspot.class.php'; |
||||
|
||||
|
||||
/** |
||||
* |
||||
* @package chamilo.exercise |
||||
*/ |
||||
class ImsQuestion extends Question |
||||
{ |
||||
/** |
||||
* Include the correct answer class and create answer |
||||
*/ |
||||
function setAnswer() |
||||
{ |
||||
switch($this->type) |
||||
{ |
||||
case MCUA : |
||||
$this->answer = new ImsAnswerMultipleChoice($this->id, false); |
||||
break; |
||||
case MCMA : |
||||
$this->answer = new ImsAnswerMultipleChoice($this->id, true); |
||||
break; |
||||
case TF : |
||||
$this->answer = new ImsAnswerTrueFalse($this->id); |
||||
break; |
||||
case FIB : |
||||
$this->answer = new ImsAnswerFillInBlanks($this->id); |
||||
break; |
||||
case MATCHING : |
||||
$this->answer = new ImsAnswerMatching($this->id); |
||||
break; |
||||
default : |
||||
$this->answer = null; |
||||
break; |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* allow to import the question |
||||
* |
||||
* @param questionArray is an array that must contain all the information needed to build the question |
||||
* @author Guillaume Lederer <guillaume@claroline.net> |
||||
*/ |
||||
|
||||
function import($questionArray, $exerciseTempPath) |
||||
{ |
||||
//import answers |
||||
|
||||
$this->answer->import($questionArray); |
||||
|
||||
//import attached file, if any |
||||
|
||||
if (isset($questionArray['attached_file_url'])) |
||||
{ |
||||
$file= array(); |
||||
$file['name'] = $questionArray['attached_file_url']; |
||||
$file['tmp_name'] = $exerciseTempPath.$file['name']; |
||||
|
||||
$this->setAttachment($file); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @package chamilo.exercise |
||||
*/ |
||||
class ImsAnswerMultipleChoice extends answerMultipleChoice |
||||
{ |
||||
/** |
||||
* Return the XML flow for the possible answers. |
||||
* That's one <response_lid>, containing several <flow_label> |
||||
* |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function imsExportResponses($questionIdent) |
||||
{ |
||||
// Opening of the response block. |
||||
if( $this->multipleAnswer ) |
||||
{ |
||||
$out = '<response_lid ident = "MCM_' . $questionIdent . '" rcardinality = "Multiple" rtiming = "No">' . "\n" |
||||
. '<render_choice shuffle = "No" minnumber = "1" maxnumber = "' . count($this->answerList) . '">' . "\n"; |
||||
} |
||||
else |
||||
{ |
||||
$out = '<response_lid ident="MCS_' . $questionIdent . '" rcardinality="Single" rtiming="No"><render_choice shuffle="No">' . "\n"; |
||||
} |
||||
|
||||
// Loop over answers |
||||
foreach( $this->answerList as $answer ) |
||||
{ |
||||
$responseIdent = $questionIdent . "_A_" . $answer['id']; |
||||
|
||||
$out.= ' <flow_label><response_label ident="' . $responseIdent . '">'.(!$this->multipleAnswer ? '<flow_mat class="list">':'').'<material>' . "\n" |
||||
. ' <mattext><![CDATA[' . $answer['answer'] . ']]></mattext>' . "\n" |
||||
. ' </material>'.(!$this->multipleAnswer ? '</flow_mat>':'').'</response_label></flow_label>' . "\n"; |
||||
} |
||||
$out.= "</render_choice></response_lid>\n"; |
||||
|
||||
return $out; |
||||
} |
||||
|
||||
/** |
||||
* Return the XML flow of answer processing : a succession of <respcondition>. |
||||
* |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function imsExportProcessing($questionIdent) |
||||
{ |
||||
$out = ''; |
||||
|
||||
foreach( $this->answerList as $answer ) |
||||
{ |
||||
$responseIdent = $questionIdent . "_A_" . $answer['id']; |
||||
$feedbackIdent = $questionIdent . "_F_" . $answer['id']; |
||||
$conditionIdent = $questionIdent . "_C_" . $answer['id']; |
||||
|
||||
if( $this->multipleAnswer ) |
||||
{ |
||||
$out .= '<respcondition title="' . $conditionIdent . '" continue="Yes"><conditionvar>' . "\n" |
||||
. ' <varequal respident="MCM_' . $questionIdent . '">' . $responseIdent . '</varequal>' . "\n"; |
||||
} |
||||
else |
||||
{ |
||||
$out .= '<respcondition title="' . $conditionIdent . '"><conditionvar>' . "\n" |
||||
. ' <varequal respident="MCS_' . $questionIdent . '">' . $responseIdent . '</varequal>' . "\n"; |
||||
} |
||||
|
||||
$out .= " </conditionvar>\n" . ' <setvar action="Add">' . $answer['grade'] . "</setvar>\n"; |
||||
|
||||
// Only add references for actually existing comments/feedbacks. |
||||
if( !empty($answer['comment']) ) |
||||
{ |
||||
$out .= ' <displayfeedback feedbacktype="Response" linkrefid="' . $feedbackIdent . '" />' . "\n"; |
||||
} |
||||
$out .= "</respcondition>\n"; |
||||
} |
||||
return $out; |
||||
} |
||||
|
||||
/** |
||||
* Export the feedback (comments to selected answers) to IMS/QTI |
||||
* |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function imsExportFeedback($questionIdent) |
||||
{ |
||||
$out = ""; |
||||
foreach( $this->answerList as $answer ) |
||||
{ |
||||
if( !empty($answer['comment']) ) |
||||
{ |
||||
$feedbackIdent = $questionIdent . "_F_" . $answer['id']; |
||||
$out.= '<itemfeedback ident="' . $feedbackIdent . '" view="Candidate"><flow_mat><material>' . "\n" |
||||
. ' <mattext><![CDATA[' . $answer['comment'] . "]]></mattext>\n" |
||||
. "</material></flow_mat></itemfeedback>\n"; |
||||
} |
||||
} |
||||
return $out; |
||||
} |
||||
|
||||
/** |
||||
* allow to import the answers, feedbacks, and grades of a question |
||||
* @param questionArray is an array that must contain all the information needed to build the question |
||||
* @author Guillaume Lederer <guillaume@claroline.net> |
||||
*/ |
||||
|
||||
function import($questionArray) |
||||
{ |
||||
|
||||
$answerArray = $questionArray['answer']; |
||||
|
||||
$this->answerList = array(); //re-initialize answer object content |
||||
|
||||
|
||||
|
||||
foreach ($answerArray as $key => $answer) |
||||
{ |
||||
if (!isset($answer['feedback'])) $answer['feedback'] = ""; |
||||
if (!isset($questionArray['weighting'][$key])) |
||||
{ |
||||
if (isset($questionArray['default_weighting'])) |
||||
{ |
||||
$grade = $questionArray['default_weighting']; |
||||
} |
||||
else |
||||
{ |
||||
$grade = 0; |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
$grade = $questionArray['weighting'][$key]; |
||||
} |
||||
if (in_array($key,$questionArray['correct_answers'])) $is_correct = true; else $is_correct = false; |
||||
$addedAnswer = array( |
||||
'answer' => $answer['value'], |
||||
'correct' => $is_correct, |
||||
'grade' => $grade, |
||||
'comment' => $answer['feedback'], |
||||
); |
||||
|
||||
$this->answerList[] = $addedAnswer; |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @package chamilo.exercise |
||||
*/ |
||||
class ImsAnswerTrueFalse extends answerTrueFalse |
||||
{ |
||||
/** |
||||
* Return the XML flow for the possible answers. |
||||
* That's one <response_lid>, containing several <flow_label> |
||||
* |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function imsExportResponses($questionIdent) |
||||
{ |
||||
// Opening of the response block. |
||||
$out = '<response_lid ident="TF_' . $questionIdent . '" rcardinality="Single" rtiming="No"><render_choice shuffle="No">' . "\n"; |
||||
|
||||
// true |
||||
$response_ident = $questionIdent . '_A_true'; |
||||
$out .= |
||||
' <flow_label><response_label ident="'.$response_ident.'"><flow_mat class="list"><material>' . "\n" |
||||
. ' <mattext><![CDATA[' . get_lang('True') . ']]></mattext>' . "\n" |
||||
. ' </material></flow_mat></response_label></flow_label>' . "\n"; |
||||
|
||||
// false |
||||
$response_ident = $questionIdent . '_A_false'; |
||||
$out .= |
||||
' <flow_label><response_label ident="'.$response_ident.'"><flow_mat class="list"><material>' . "\n" |
||||
. ' <mattext><![CDATA[' . get_lang('False') . ']]></mattext>' . "\n" |
||||
. ' </material></flow_mat></response_label></flow_label>' . "\n"; |
||||
|
||||
$out .= '</render_choice></response_lid>' . "\n"; |
||||
|
||||
return $out; |
||||
} |
||||
|
||||
/** |
||||
* Return the XML flow of answer processing : a succession of <respcondition>. |
||||
* |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function imsExportProcessing($questionIdent) |
||||
{ |
||||
$out = ''; |
||||
|
||||
// true |
||||
$response_ident = $questionIdent. '_A_true'; |
||||
$feedback_ident = $questionIdent . '_F_true'; |
||||
$condition_ident = $questionIdent . '_C_true'; |
||||
|
||||
$out .= |
||||
'<respcondition title="' . $condition_ident . '"><conditionvar>' . "\n" |
||||
. ' <varequal respident="TF_' . $questionIdent . '">' . $response_ident . '</varequal>' . "\n" |
||||
. ' </conditionvar>' . "\n" . ' <setvar action="Add">' . $this->trueGrade . '</setvar>' . "\n"; |
||||
|
||||
// Only add references for actually existing comments/feedbacks. |
||||
if( !empty($this->trueFeedback) ) |
||||
{ |
||||
$out.= ' <displayfeedback feedbacktype="Response" linkrefid="' . $this->trueFeedback . '" />' . "\n"; |
||||
} |
||||
|
||||
$out .= '</respcondition>' . "\n"; |
||||
|
||||
// false |
||||
$response_ident = $questionIdent. '_A_false'; |
||||
$feedback_ident = $questionIdent . '_F_false'; |
||||
$condition_ident = $questionIdent . '_C_false'; |
||||
|
||||
$out .= |
||||
'<respcondition title="' . $condition_ident . '"><conditionvar>' . "\n" |
||||
. ' <varequal respident="TF_' . $questionIdent . '">' . $response_ident . '</varequal>' . "\n" |
||||
. ' </conditionvar>' . "\n" . ' <setvar action="Add">' . $this->falseGrade . '</setvar>' . "\n"; |
||||
|
||||
// Only add references for actually existing comments/feedbacks. |
||||
if( !empty($this->falseFeedback) ) |
||||
{ |
||||
$out.= ' <displayfeedback feedbacktype="Response" linkrefid="' . $feedback_ident . '" />' . "\n"; |
||||
} |
||||
|
||||
$out .= '</respcondition>' . "\n"; |
||||
|
||||
return $out; |
||||
} |
||||
|
||||
/** |
||||
* Export the feedback (comments to selected answers) to IMS/QTI |
||||
* |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function imsExportFeedback($questionIdent) |
||||
{ |
||||
$out = ""; |
||||
|
||||
if( !empty($this->trueFeedback) ) |
||||
{ |
||||
$feedback_ident = $questionIdent . '_F_true'; |
||||
$out.= '<itemfeedback ident="' . $feedback_ident . '" view="Candidate"><flow_mat><material>' . "\n" |
||||
. ' <mattext><![CDATA[' . $this->trueFeedback . "]]></mattext>\n" |
||||
. "</material></flow_mat></itemfeedback>\n"; |
||||
} |
||||
|
||||
if( !empty($this->falseFeedback) ) |
||||
{ |
||||
$feedback_ident = $questionIdent . '_F_false'; |
||||
$out.= '<itemfeedback ident="' . $feedback_ident . '" view="Candidate"><flow_mat><material>' . "\n" |
||||
. ' <mattext><![CDATA[' . $this->falseFeedback . "]]></mattext>\n" |
||||
. "</material></flow_mat></itemfeedback>\n"; |
||||
} |
||||
return $out; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @package chamilo.exercise |
||||
*/ |
||||
class ImsAnswerFillInBlanks extends answerFillInBlanks |
||||
{ |
||||
/** |
||||
* Export the text with missing words. |
||||
* |
||||
* As a side effect, it stores two lists in the class : |
||||
* the missing words and their respective weightings. |
||||
* |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function imsExportResponses($questionIdent) |
||||
{ |
||||
global $charset; |
||||
|
||||
$out = "<flow>\n"; |
||||
|
||||
$responsePart = explode(']', $this->answer); |
||||
$i = 0; // Used for the reference generation. |
||||
foreach($responsePart as $part) |
||||
{ |
||||
$response_ident = $questionIdent . "_A_" . $i; |
||||
|
||||
if( strpos($part,'[') !== false ) |
||||
{ |
||||
list($rawText, $blank) = explode('[', $part); |
||||
} |
||||
else |
||||
{ |
||||
$rawText = $part; |
||||
$blank = ""; |
||||
} |
||||
|
||||
if ($rawText!="") |
||||
{ |
||||
$out.=" <material><mattext><![CDATA[" . $rawText . "]]></mattext></material>\n"; |
||||
} |
||||
|
||||
if ($blank!="") |
||||
{ |
||||
$out.= ' <response_str ident="' . $response_ident . '" rcardinality="Single" rtiming="No">' . "\n" |
||||
. ' <render_fib fibtype="String" prompt="Box" encoding="' . $charset . '">' . "\n" |
||||
. ' <response_label ident="A"/>' . "\n" |
||||
. " </render_fib>\n" |
||||
. " </response_str>\n"; |
||||
} |
||||
$i++; |
||||
} |
||||
$out.="</flow>\n"; |
||||
|
||||
return $out; |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Exports the response processing. |
||||
* |
||||
* It uses the two lists build by export_responses(). This implies that export_responses MUST |
||||
* be called before. |
||||
* |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function imsExportProcessing($questionIdent) |
||||
{ |
||||
$out = ""; |
||||
|
||||
$answerCount = count($this->answerList); |
||||
|
||||
for( $i = 0; $i < $answerCount ; $i++ ) |
||||
{ |
||||
$response_ident = $questionIdent . "_A_" . $i; |
||||
$out.= ' <respcondition continue="Yes"><conditionvar>' . "\n" |
||||
. ' <varequal respident="' . $response_ident . '" case="No"><![CDATA[' . $this->answerList[$i] . ']]></varequal>' . "\n" |
||||
. ' </conditionvar><setvar action="Add">' . $this->gradeList[$i] . "</setvar>\n" |
||||
. " </respcondition>\n"; |
||||
} |
||||
return $out; |
||||
} |
||||
|
||||
/** |
||||
* Export the feedback (comments to selected answers) to IMS/QTI |
||||
* |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function imsExportFeedback($questionIdent) |
||||
{ |
||||
// no feedback in this question type |
||||
return ''; |
||||
} |
||||
|
||||
/** |
||||
* allow to import the answers, feedbacks, and grades of a question |
||||
* |
||||
* @param questionArray is an array that must contain all the information needed to build the question |
||||
* @author Guillaume Lederer <guillaume@claroline.net> |
||||
*/ |
||||
|
||||
function import($questionArray) |
||||
{ |
||||
$answerArray = $questionArray['answer']; |
||||
$this->answerText = str_replace ("\n","",$questionArray['response_text']); |
||||
if ($questionArray['subtype'] == "TEXTFIELD_FILL") $this->type = TEXTFIELD_FILL; |
||||
if ($questionArray['subtype'] == "LISTBOX_FILL") |
||||
{ |
||||
$this->wrongAnswerList = $questionArray['wrong_answers']; |
||||
$this->type = LISTBOX_FILL; |
||||
} |
||||
|
||||
//build correct_answsers array |
||||
|
||||
if (isset($questionArray['weighting'])) |
||||
{ |
||||
$this->gradeList = $questionArray['weighting']; |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @package chamilo.exercise |
||||
*/ |
||||
class ImsAnswerMatching extends answerMatching |
||||
{ |
||||
/** |
||||
* Export the question part as a matrix-choice, with only one possible answer per line. |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function imsExportResponses($questionIdent) |
||||
{ |
||||
$out = ""; |
||||
// Now, loop again, finding questions (rows) |
||||
foreach( $this->leftList as $leftElt ) |
||||
{ |
||||
$responseIdent = $questionIdent . "_A_" . $leftElt['code']; |
||||
$out.= '<response_lid ident="' . $responseIdent . '" rcardinality="Single" rtiming="No">' . "\n" |
||||
. '<material><mattext><![CDATA[' . $leftElt['answer'] . "]]></mattext></material>\n" |
||||
. ' <render_choice shuffle="No"><flow_label>' . "\n"; |
||||
|
||||
foreach( $this->rightList as $rightElt ) |
||||
{ |
||||
$out.= ' <response_label ident="' . $rightElt['code'] . '"><material>' . "\n" |
||||
. " <mattext><![CDATA[" . $rightElt['answer'] . "]]></mattext>\n" |
||||
. " </material></response_label>\n"; |
||||
} |
||||
|
||||
$out.= "</flow_label></render_choice></response_lid>\n"; |
||||
} |
||||
|
||||
return $out; |
||||
} |
||||
|
||||
/** |
||||
* Export the response processing part |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function imsExportProcessing($questionIdent) |
||||
{ |
||||
$out = ""; |
||||
foreach( $this->leftList as $leftElt ) |
||||
{ |
||||
$responseIdent = $questionIdent . "_A_" . $leftElt['code']; |
||||
$out.= ' <respcondition continue="Yes"><conditionvar>' . "\n" |
||||
. ' <varequal respident="' . $responseIdent . '">' . $leftElt['match'] . "</varequal>\n" |
||||
. ' </conditionvar><setvar action="Add">' . $leftElt['grade'] . "</setvar>\n" |
||||
. " </respcondition>\n"; |
||||
} |
||||
return $out; |
||||
} |
||||
|
||||
/** |
||||
* Export the feedback (comments to selected answers) to IMS/QTI |
||||
* |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function imsExportFeedback($questionIdent) |
||||
{ |
||||
// no feedback in this question type |
||||
return ''; |
||||
} |
||||
|
||||
/** |
||||
* allow to import the answers, feedbacks, and grades of a question |
||||
* |
||||
* @param questionArray is an array that must contain all the information needed to build the question |
||||
* @author Guillaume Lederer <guillaume@claroline.net> |
||||
*/ |
||||
|
||||
function import($questionArray) |
||||
{ |
||||
$answerArray = $questionArray['answer']; |
||||
|
||||
//This tick to remove examples in the answers!!!! |
||||
$this->leftList = array(); |
||||
$this->rightList = array(); |
||||
|
||||
//find right and left column |
||||
|
||||
$right_column = array_pop($answerArray); |
||||
$left_column = array_pop($answerArray); |
||||
|
||||
//1- build answers |
||||
|
||||
foreach ($right_column as $right_key => $right_element) |
||||
{ |
||||
$code = $this->addRight($right_element); |
||||
|
||||
foreach ($left_column as $left_key => $left_element) |
||||
{ |
||||
$matched_pattern = $left_key." ".$right_key; |
||||
$matched_pattern_inverted = $right_key." ".$left_key; |
||||
|
||||
|
||||
if (in_array($matched_pattern, $questionArray['correct_answers']) || in_array($matched_pattern_inverted, $questionArray['correct_answers'])) |
||||
{ |
||||
if (isset($questionArray['weighting'][$matched_pattern])) |
||||
{ |
||||
$grade = $questionArray['weighting'][$matched_pattern]; |
||||
} |
||||
else |
||||
{ |
||||
$grade = 0; |
||||
} |
||||
$this->addLeft($left_element, $code, $grade); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
?> |
||||
@ -1,351 +0,0 @@ |
||||
<?php // $Id: $
|
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* @author Claro Team <cvs@claroline.net> |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
* @author Sebastien Piraux <pir@cerdecam.be> |
||||
* @author Yannick Warnier <yannick.warnier@beeznest.com> |
||||
* @package chamilo.exercise.qti |
||||
*/ |
||||
/** |
||||
* Code |
||||
*/ |
||||
if ( count( get_included_files() ) == 1 ) die( '---' ); |
||||
include dirname(__FILE__) . '/qti_classes.php'; |
||||
/*-------------------------------------------------------- |
||||
Classes |
||||
--------------------------------------------------------*/ |
||||
|
||||
/** |
||||
* This class represents an entire exercise to be exported in IMS/QTI. |
||||
* It will be represented by a single <section> containing several <item>. |
||||
* |
||||
* Some properties cannot be exported, as IMS does not support them : |
||||
* - type (one page or multiple pages) |
||||
* - start_date and end_date |
||||
* - max_attempts |
||||
* - show_answer |
||||
* - anonymous_attempts |
||||
* |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
* @package chamilo.exercise.qti |
||||
*/ |
||||
class ImsSection |
||||
{ |
||||
var $exercise; |
||||
|
||||
/** |
||||
* Constructor. |
||||
* @param $exe The Exercise instance to export |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function ImsSection($exe) |
||||
{ |
||||
$this->exercise = $exe; |
||||
} |
||||
|
||||
function start_section() |
||||
{ |
||||
$out = '<section ident="EXO_' . $this->exercise->getId() . '" title="' . $this->exercise->getTitle() . '">' . "\n"; |
||||
return $out; |
||||
} |
||||
|
||||
function end_section() |
||||
{ |
||||
return "</section>\n"; |
||||
} |
||||
|
||||
function export_duration() |
||||
{ |
||||
if ($max_time = $this->exercise->getTimeLimit()) |
||||
{ |
||||
// return exercise duration in ISO8601 format. |
||||
$minutes = floor($max_time / 60); |
||||
$seconds = $max_time % 60; |
||||
return '<duration>PT' . $minutes . 'M' . $seconds . "S</duration>\n"; |
||||
} |
||||
else |
||||
{ |
||||
return ''; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Export the presentation (Exercise's description) |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function export_presentation() |
||||
{ |
||||
$out = "<presentation_material><flow_mat><material>\n" |
||||
. " <mattext><![CDATA[" . $this->exercise->getDescription() . "]]></mattext>\n" |
||||
. "</material></flow_mat></presentation_material>\n"; |
||||
return $out; |
||||
} |
||||
|
||||
/** |
||||
* Export the ordering information. |
||||
* Either sequential, through all questions, or random, with a selected number of questions. |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function export_ordering() |
||||
{ |
||||
$out = ''; |
||||
if ($n = $this->exercise->getShuffle()) { |
||||
$out.= "<selection_ordering>" |
||||
. " <selection>\n" |
||||
. " <selection_number>" . $n . "</selection_number>\n" |
||||
. " </selection>\n" |
||||
. ' <order order_type="Random" />' |
||||
. "\n</selection_ordering>\n"; |
||||
} |
||||
else |
||||
{ |
||||
$out.= '<selection_ordering sequence_type="Normal">' . "\n" |
||||
. " <selection />\n" |
||||
. "</selection_ordering>\n"; |
||||
} |
||||
|
||||
return $out; |
||||
} |
||||
|
||||
/** |
||||
* Export the questions, as a succession of <items> |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function export_questions() |
||||
{ |
||||
$out = ""; |
||||
foreach ($this->exercise->getQuestionList() as $q) |
||||
{ |
||||
$out .= export_question($q['id'], False); |
||||
} |
||||
return $out; |
||||
} |
||||
|
||||
/** |
||||
* Export the exercise in IMS/QTI. |
||||
* |
||||
* @param bool $standalone Wether it should include XML tag and DTD line. |
||||
* @return a string containing the XML flow |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function export($standalone) |
||||
{ |
||||
global $charset; |
||||
|
||||
$head = $foot = ""; |
||||
if ($standalone) { |
||||
$head = '<?xml version = "1.0" encoding = "' . $charset . '" standalone = "no"?>' . "\n"
|
||||
. '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv1p2p1.dtd">' . "\n" |
||||
. "<questestinterop>\n"; |
||||
$foot = "</questestinterop>\n"; |
||||
} |
||||
|
||||
$out = $head |
||||
. $this->start_section() |
||||
. $this->export_duration() |
||||
. $this->export_presentation() |
||||
. $this->export_ordering() |
||||
. $this->export_questions() |
||||
. $this->end_section() |
||||
. $foot; |
||||
|
||||
return $out; |
||||
} |
||||
} |
||||
|
||||
/* |
||||
Some quick notes on identifiers generation. |
||||
The IMS format requires some blocks, like items, responses, feedbacks, to be uniquely |
||||
identified. |
||||
The unicity is mandatory in a single XML, of course, but it's prefered that the identifier stays |
||||
coherent for an entire site. |
||||
|
||||
Here's the method used to generate those identifiers. |
||||
Question identifier :: "QST_" + <Question Id from the DB> + "_" + <Question numeric type> |
||||
Response identifier :: <Question identifier> + "_A_" + <Response Id from the DB> |
||||
Condition identifier :: <Question identifier> + "_C_" + <Response Id from the DB> |
||||
Feedback identifier :: <Question identifier> + "_F_" + <Response Id from the DB> |
||||
*/ |
||||
/** |
||||
* An IMS/QTI item. It corresponds to a single question. |
||||
* This class allows export from Claroline to IMS/QTI XML format. |
||||
* It is not usable as-is, but must be subclassed, to support different kinds of questions. |
||||
* |
||||
* Every start_*() and corresponding end_*(), as well as export_*() methods return a string. |
||||
* |
||||
* Warning: Attached files are NOT exported. |
||||
* @package chamilo.exercise.qti |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
class ImsItem |
||||
{ |
||||
var $question; |
||||
var $question_ident; |
||||
var $answer; |
||||
|
||||
/** |
||||
* Constructor. |
||||
* |
||||
* @param $question The Question object we want to export. |
||||
* @author Anamd Tihon |
||||
*/ |
||||
function ImsItem($question) |
||||
{ |
||||
$this->question = $question; |
||||
$this->answer = $question->answer; |
||||
$this->questionIdent = "QST_" . $question->getId() ; |
||||
} |
||||
|
||||
/** |
||||
* Start the XML flow. |
||||
* |
||||
* This opens the <item> block, with correct attributes. |
||||
* |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function start_item() |
||||
{ |
||||
return '<item title="' . htmlspecialchars($this->question->getTitle()) . '" ident="' . $this->questionIdent . '">' . "\n"; |
||||
} |
||||
|
||||
/** |
||||
* End the XML flow, closing the </item> tag. |
||||
* |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function end_item() |
||||
{ |
||||
return "</item>\n"; |
||||
} |
||||
|
||||
/** |
||||
* Create the opening, with the question itself. |
||||
* |
||||
* This means it opens the <presentation> but doesn't close it, as this is the role of end_presentation(). |
||||
* Inbetween, the export_responses from the subclass should have been called. |
||||
* |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function start_presentation() |
||||
{ |
||||
return '<presentation label="' . $this->questionIdent . '"><flow>' . "\n" |
||||
. '<material><mattext><![CDATA[' . $this->question->getDescription() . "]]></mattext></material>\n"; |
||||
} |
||||
|
||||
/** |
||||
* End the </presentation> part, opened by export_header. |
||||
* |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function end_presentation() |
||||
{ |
||||
return "</flow></presentation>\n"; |
||||
} |
||||
|
||||
/** |
||||
* Start the response processing, and declare the default variable, SCORE, at 0 in the outcomes. |
||||
* |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function start_processing() |
||||
{ |
||||
return '<resprocessing><outcomes><decvar vartype="Integer" defaultval="0" /></outcomes>' . "\n"; |
||||
} |
||||
|
||||
/** |
||||
* End the response processing part. |
||||
* |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function end_processing() |
||||
{ |
||||
return "</resprocessing>\n"; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Export the question as an IMS/QTI Item. |
||||
* |
||||
* This is a default behaviour, some classes may want to override this. |
||||
* |
||||
* @param $standalone: Boolean stating if it should be exported as a stand-alone question |
||||
* @return A string, the XML flow for an Item. |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function export($standalone = False) |
||||
{ |
||||
global $charset; |
||||
$head = $foot = ""; |
||||
|
||||
if( $standalone ) |
||||
{ |
||||
$head = '<?xml version = "1.0" encoding = "'.$charset.'" standalone = "no"?>' . "\n"
|
||||
. '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv1p2p1.dtd">' . "\n" |
||||
. "<questestinterop>\n"; |
||||
$foot = "</questestinterop>\n"; |
||||
} |
||||
|
||||
return $head |
||||
. $this->start_item() |
||||
. $this->start_presentation() |
||||
. $this->answer->imsExportResponses($this->questionIdent) |
||||
. $this->end_presentation() |
||||
. $this->start_processing() |
||||
. $this->answer->imsExportProcessing($this->questionIdent) |
||||
. $this->end_processing() |
||||
. $this->answer->imsExportFeedback($this->questionIdent) |
||||
. $this->end_item() |
||||
. $foot; |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------- |
||||
Functions |
||||
--------------------------------------------------------*/ |
||||
|
||||
/** |
||||
* Send a complete exercise in IMS/QTI format, from its ID |
||||
* |
||||
* @param int $exerciseId The exercise to exporte |
||||
* @param boolean $standalone Wether it should include XML tag and DTD line. |
||||
* @return The XML as a string, or an empty string if there's no exercise with given ID. |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function export_exercise($exerciseId, $standalone=True) |
||||
{ |
||||
$exercise = new Exercise(); |
||||
if (! $exercise->load($exerciseId)) |
||||
{ |
||||
return ''; |
||||
} |
||||
$ims = new ImsSection($exercise); |
||||
$xml = $ims->export($standalone); |
||||
return $xml; |
||||
} |
||||
|
||||
/** |
||||
* Returns the XML flow corresponding to one question |
||||
* |
||||
* @param int The question ID |
||||
* @param bool standalone (ie including XML tag, DTD declaration, etc) |
||||
* @author Amand Tihon <amand@alrj.org> |
||||
*/ |
||||
function export_question($questionId, $standalone=True) |
||||
{ |
||||
$question = new ImsQuestion(); |
||||
if( !$question->load($questionId) ) |
||||
{ |
||||
return ''; |
||||
} |
||||
|
||||
$ims = new ImsItem($question); |
||||
|
||||
return $ims->export($standalone); |
||||
|
||||
} |
||||
|
||||
?> |
||||
@ -0,0 +1,202 @@ |
||||
|
||||
Apache License |
||||
Version 2.0, January 2004 |
||||
http://www.apache.org/licenses/ |
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION |
||||
|
||||
1. Definitions. |
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, |
||||
and distribution as defined by Sections 1 through 9 of this document. |
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by |
||||
the copyright owner that is granting the License. |
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all |
||||
other entities that control, are controlled by, or are under common |
||||
control with that entity. For the purposes of this definition, |
||||
"control" means (i) the power, direct or indirect, to cause the |
||||
direction or management of such entity, whether by contract or |
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the |
||||
outstanding shares, or (iii) beneficial ownership of such entity. |
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity |
||||
exercising permissions granted by this License. |
||||
|
||||
"Source" form shall mean the preferred form for making modifications, |
||||
including but not limited to software source code, documentation |
||||
source, and configuration files. |
||||
|
||||
"Object" form shall mean any form resulting from mechanical |
||||
transformation or translation of a Source form, including but |
||||
not limited to compiled object code, generated documentation, |
||||
and conversions to other media types. |
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or |
||||
Object form, made available under the License, as indicated by a |
||||
copyright notice that is included in or attached to the work |
||||
(an example is provided in the Appendix below). |
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object |
||||
form, that is based on (or derived from) the Work and for which the |
||||
editorial revisions, annotations, elaborations, or other modifications |
||||
represent, as a whole, an original work of authorship. For the purposes |
||||
of this License, Derivative Works shall not include works that remain |
||||
separable from, or merely link (or bind by name) to the interfaces of, |
||||
the Work and Derivative Works thereof. |
||||
|
||||
"Contribution" shall mean any work of authorship, including |
||||
the original version of the Work and any modifications or additions |
||||
to that Work or Derivative Works thereof, that is intentionally |
||||
submitted to Licensor for inclusion in the Work by the copyright owner |
||||
or by an individual or Legal Entity authorized to submit on behalf of |
||||
the copyright owner. For the purposes of this definition, "submitted" |
||||
means any form of electronic, verbal, or written communication sent |
||||
to the Licensor or its representatives, including but not limited to |
||||
communication on electronic mailing lists, source code control systems, |
||||
and issue tracking systems that are managed by, or on behalf of, the |
||||
Licensor for the purpose of discussing and improving the Work, but |
||||
excluding communication that is conspicuously marked or otherwise |
||||
designated in writing by the copyright owner as "Not a Contribution." |
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity |
||||
on behalf of whom a Contribution has been received by Licensor and |
||||
subsequently incorporated within the Work. |
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of |
||||
this License, each Contributor hereby grants to You a perpetual, |
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
||||
copyright license to reproduce, prepare Derivative Works of, |
||||
publicly display, publicly perform, sublicense, and distribute the |
||||
Work and such Derivative Works in Source or Object form. |
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of |
||||
this License, each Contributor hereby grants to You a perpetual, |
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
||||
(except as stated in this section) patent license to make, have made, |
||||
use, offer to sell, sell, import, and otherwise transfer the Work, |
||||
where such license applies only to those patent claims licensable |
||||
by such Contributor that are necessarily infringed by their |
||||
Contribution(s) alone or by combination of their Contribution(s) |
||||
with the Work to which such Contribution(s) was submitted. If You |
||||
institute patent litigation against any entity (including a |
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work |
||||
or a Contribution incorporated within the Work constitutes direct |
||||
or contributory patent infringement, then any patent licenses |
||||
granted to You under this License for that Work shall terminate |
||||
as of the date such litigation is filed. |
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the |
||||
Work or Derivative Works thereof in any medium, with or without |
||||
modifications, and in Source or Object form, provided that You |
||||
meet the following conditions: |
||||
|
||||
(a) You must give any other recipients of the Work or |
||||
Derivative Works a copy of this License; and |
||||
|
||||
(b) You must cause any modified files to carry prominent notices |
||||
stating that You changed the files; and |
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works |
||||
that You distribute, all copyright, patent, trademark, and |
||||
attribution notices from the Source form of the Work, |
||||
excluding those notices that do not pertain to any part of |
||||
the Derivative Works; and |
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its |
||||
distribution, then any Derivative Works that You distribute must |
||||
include a readable copy of the attribution notices contained |
||||
within such NOTICE file, excluding those notices that do not |
||||
pertain to any part of the Derivative Works, in at least one |
||||
of the following places: within a NOTICE text file distributed |
||||
as part of the Derivative Works; within the Source form or |
||||
documentation, if provided along with the Derivative Works; or, |
||||
within a display generated by the Derivative Works, if and |
||||
wherever such third-party notices normally appear. The contents |
||||
of the NOTICE file are for informational purposes only and |
||||
do not modify the License. You may add Your own attribution |
||||
notices within Derivative Works that You distribute, alongside |
||||
or as an addendum to the NOTICE text from the Work, provided |
||||
that such additional attribution notices cannot be construed |
||||
as modifying the License. |
||||
|
||||
You may add Your own copyright statement to Your modifications and |
||||
may provide additional or different license terms and conditions |
||||
for use, reproduction, or distribution of Your modifications, or |
||||
for any such Derivative Works as a whole, provided Your use, |
||||
reproduction, and distribution of the Work otherwise complies with |
||||
the conditions stated in this License. |
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, |
||||
any Contribution intentionally submitted for inclusion in the Work |
||||
by You to the Licensor shall be under the terms and conditions of |
||||
this License, without any additional terms or conditions. |
||||
Notwithstanding the above, nothing herein shall supersede or modify |
||||
the terms of any separate license agreement you may have executed |
||||
with Licensor regarding such Contributions. |
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade |
||||
names, trademarks, service marks, or product names of the Licensor, |
||||
except as required for reasonable and customary use in describing the |
||||
origin of the Work and reproducing the content of the NOTICE file. |
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or |
||||
agreed to in writing, Licensor provides the Work (and each |
||||
Contributor provides its Contributions) on an "AS IS" BASIS, |
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
||||
implied, including, without limitation, any warranties or conditions |
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A |
||||
PARTICULAR PURPOSE. You are solely responsible for determining the |
||||
appropriateness of using or redistributing the Work and assume any |
||||
risks associated with Your exercise of permissions under this License. |
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, |
||||
whether in tort (including negligence), contract, or otherwise, |
||||
unless required by applicable law (such as deliberate and grossly |
||||
negligent acts) or agreed to in writing, shall any Contributor be |
||||
liable to You for damages, including any direct, indirect, special, |
||||
incidental, or consequential damages of any character arising as a |
||||
result of this License or out of the use or inability to use the |
||||
Work (including but not limited to damages for loss of goodwill, |
||||
work stoppage, computer failure or malfunction, or any and all |
||||
other commercial damages or losses), even if such Contributor |
||||
has been advised of the possibility of such damages. |
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing |
||||
the Work or Derivative Works thereof, You may choose to offer, |
||||
and charge a fee for, acceptance of support, warranty, indemnity, |
||||
or other liability obligations and/or rights consistent with this |
||||
License. However, in accepting such obligations, You may act only |
||||
on Your own behalf and on Your sole responsibility, not on behalf |
||||
of any other Contributor, and only if You agree to indemnify, |
||||
defend, and hold each Contributor harmless for any liability |
||||
incurred by, or claims asserted against, such Contributor by reason |
||||
of your accepting any such warranty or additional liability. |
||||
|
||||
END OF TERMS AND CONDITIONS |
||||
|
||||
APPENDIX: How to apply the Apache License to your work. |
||||
|
||||
To apply the Apache License to your work, attach the following |
||||
boilerplate notice, with the fields enclosed by brackets "[]" |
||||
replaced with your own identifying information. (Don't include |
||||
the brackets!) The text should be enclosed in the appropriate |
||||
comment syntax for the file format. We also recommend that a |
||||
file or class name and description of purpose be included on the |
||||
same "printed page" as the copyright notice for easier |
||||
identification within third-party archives. |
||||
|
||||
Copyright [yyyy] [name of copyright owner] |
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); |
||||
you may not use this file except in compliance with the License. |
||||
You may obtain a copy of the License at |
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0 |
||||
|
||||
Unless required by applicable law or agreed to in writing, software |
||||
distributed under the License is distributed on an "AS IS" BASIS, |
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
See the License for the specific language governing permissions and |
||||
limitations under the License. |
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Can't render this file because it has a wrong number of fields in line 3.
|
|
After Width: | Height: | Size: 872 B |
|
After Width: | Height: | Size: 504 B |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
@ -1,18 +1,3 @@ |
||||
<?php |
||||
|
||||
/** |
||||
* Set up the Chamilo autoload stack. Can be called several time if needed also |
||||
* better to avoid it. |
||||
*/ |
||||
|
||||
require_once dirname(__FILE__) . '/lib/autoload.class.php'; |
||||
Autoload::register(); |
||||
|
||||
/** |
||||
use Symfony\Component\ClassLoader\UniversalClassLoader; |
||||
$loader = new UniversalClassLoader(); |
||||
$loader->registerNamespaces(array( |
||||
'Symfony\\Component\\HttpFoundation', __DIR__.'/vendor/symfony/http-foundation', |
||||
)); |
||||
$loader->register(); |
||||
*/ |
||||
require_once __DIR__ . '/../../vendor/autoload.php'; |
||||
|
||||
@ -0,0 +1,101 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* Library for generate a teacher time report |
||||
* |
||||
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com> |
||||
* @package chamilo.admin |
||||
*/ |
||||
class TeacherTimeReport |
||||
{ |
||||
|
||||
/** |
||||
* The report data |
||||
* @var array |
||||
*/ |
||||
public $data = array(); |
||||
|
||||
/** |
||||
* Callback for compare sessions names |
||||
* @param array $dataA The datab A |
||||
* @param array $dataB The data B |
||||
* @return int returns -1 if dataA is less than dataB, 1 if dataA is greater than dataB, and 0 if they are equal |
||||
*/ |
||||
public function compareSessions($dataA, $dataB) |
||||
{ |
||||
return strnatcmp($dataA['session']['name'], $dataB['session']['name']); |
||||
} |
||||
|
||||
/** |
||||
* Callback for compare courses names |
||||
* @param array $dataA The datab A |
||||
* @param array $dataB The data B |
||||
* @return int returns -1 if dataA is less than dataB, 1 if dataA is greater than dataB, and 0 if they are equal |
||||
*/ |
||||
public function compareCourses($dataA, $dataB) |
||||
{ |
||||
return strnatcmp($dataA['course']['name'], $dataB['course']['name']); |
||||
} |
||||
|
||||
/** |
||||
* Callback for compare coaches names |
||||
* @param array $dataA The datab A |
||||
* @param array $dataB The data B |
||||
* @return int returns -1 if dataA is less than dataB, 1 if dataA is greater than dataB, and 0 if they are equal |
||||
*/ |
||||
public function compareCoaches($dataA, $dataB) |
||||
{ |
||||
return strnatcmp($dataA['coach']['completeName'], $dataB['coach']['completeName']); |
||||
} |
||||
|
||||
/** |
||||
* Sort the report data |
||||
* @param boolean $withFilter Whether sort by sessions and courses |
||||
*/ |
||||
public function sortData($withFilter = false) |
||||
{ |
||||
if ($withFilter) { |
||||
uasort($this->data, array($this, 'compareSessions')); |
||||
uasort($this->data, array($this, 'compareCourses')); |
||||
} |
||||
|
||||
uasort($this->data, array($this, 'compareCoaches')); |
||||
} |
||||
|
||||
public function prepareDataToExport($withFilter = false) |
||||
{ |
||||
$dataToExport = array(); |
||||
|
||||
if ($withFilter) { |
||||
$dataToExport[] = array( |
||||
get_lang('Session'), |
||||
get_lang('Course'), |
||||
get_lang('Coach'), |
||||
get_lang('TotalTime') |
||||
); |
||||
} else { |
||||
$dataToExport[] = array( |
||||
get_lang('Coach'), |
||||
get_lang('TotalTime') |
||||
); |
||||
} |
||||
|
||||
foreach ($this->data as $row) { |
||||
$data = array(); |
||||
|
||||
if ($withFilter) { |
||||
$data[] = $row['session']['name']; |
||||
$data[] = $row['course']['name']; |
||||
} |
||||
|
||||
$data[] = $row['coach']['completeName']; |
||||
$data[] = $row['totalTime']; |
||||
|
||||
$dataToExport[] = $data; |
||||
} |
||||
|
||||
return $dataToExport; |
||||
} |
||||
|
||||
} |
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue