Merge branch '1.10.x' into 1.10.x.new_structure

1.10.x
Julio Montoya 10 years ago
commit a235d18213
  1. 275
      main/admin/index.php
  2. 117
      main/cron/create_course_sessions.php
  3. 27
      main/css/base.css
  4. 224
      main/exercice/Draggable.php
  5. 81
      main/exercice/exercise.class.php
  6. 2
      main/exercice/exercise_show.php
  7. 2
      main/exercice/exercise_submit.php
  8. 3
      main/exercice/question.class.php
  9. 1
      main/inc/lib/api.lib.php
  10. 2
      main/inc/lib/course.lib.php
  11. 872
      main/inc/lib/course_description.lib.php
  12. 4
      main/inc/lib/display.lib.php
  13. 129
      main/inc/lib/exercise.lib.php
  14. 4
      main/inc/lib/usermanager.lib.php
  15. 2
      main/lang/english/trad4all.inc.php
  16. 2
      main/lang/spanish/trad4all.inc.php
  17. 95
      main/template/default/exercise/submit.js.tpl

@ -77,7 +77,7 @@ if (!empty($hook)) {
/* Users */
$blocks['users']['icon'] = Display::return_icon('members.gif', get_lang('Users'), array(), ICON_SIZE_SMALL, false);
$blocks['users']['icon'] = Display::return_icon('members.gif', get_lang('Users'), array(), ICON_SIZE_SMALL, false);
$blocks['users']['label'] = api_ucfirst(get_lang('Users'));
$blocks['users']['class'] = 'block-admin-users';
@ -91,43 +91,51 @@ if (api_is_platform_admin()) {
$blocks['users']['editable'] = true;
$search_form = '
<form method="get" class="form-inline" action="user_list.php">
<div class="form-group">
<form method="get" class="form-inline" action="user_list.php">
<div class="form-group">
<input class="form-control" type="text" name="keyword" value="">
<button class="btn btn-default" type="submit"><i class="fa fa-search"></i> '.get_lang('Search').'</button>
</div>
</form>';
<button class="btn btn-default" type="submit">
<i class="fa fa-search"></i> ' . get_lang('Search') . '
</button>
</div>
</form>';
$blocks['users']['search_form'] = $search_form;
$items = array(
array('url'=>'user_list.php', 'label' => get_lang('UserList')),
array('url'=>'user_add.php', 'label' => get_lang('AddUsers')),
array('url'=>'user_export.php', 'label' => get_lang('ExportUserListXMLCSV')),
array('url'=>'user_import.php', 'label' => get_lang('ImportUserListXMLCSV')),
array('url'=>'user_update_import.php', 'label' => get_lang('EditUserListCSV')),
array('url' => 'user_list.php', 'label' => get_lang('UserList')),
array('url' => 'user_add.php', 'label' => get_lang('AddUsers')),
array('url' => 'user_export.php', 'label' => get_lang('ExportUserListXMLCSV')),
array('url' => 'user_import.php', 'label' => get_lang('ImportUserListXMLCSV')),
array('url' => 'user_update_import.php', 'label' => get_lang('EditUserListCSV')),
);
$items[] = array('url'=>'group_add.php', 'label' => get_lang('AddGroups'));
$items[] = array('url'=>'group_list.php', 'label' => get_lang('GroupList'));
$items[] = array('url' => 'group_add.php', 'label' => get_lang('AddGroups'));
$items[] = array('url' => 'group_list.php', 'label' => get_lang('GroupList'));
if (isset($extAuthSource) && isset($extAuthSource['extldap']) && count($extAuthSource['extldap']) > 0) {
$items[] = array('url'=>'ldap_users_list.php', 'label' => get_lang('ImportLDAPUsersIntoPlatform'));
$items[] = array('url' => 'ldap_users_list.php', 'label' => get_lang('ImportLDAPUsersIntoPlatform'));
}
$items[] = array('url'=>'extra_fields.php?type=user', 'label' => get_lang('ManageUserFields'));
$items[] = array('url' => 'extra_fields.php?type=user', 'label' => get_lang('ManageUserFields'));
} else {
$items = array(
array('url'=>'user_list.php', 'label' => get_lang('UserList')),
array('url'=>'user_add.php', 'label' => get_lang('AddUsers')),
array('url'=>'user_import.php', 'label' => get_lang('ImportUserListXMLCSV')),
array('url' => 'user_list.php', 'label' => get_lang('UserList')),
array('url' => 'user_add.php', 'label' => get_lang('AddUsers')),
array('url' => 'user_import.php', 'label' => get_lang('ImportUserListXMLCSV')),
);
}
$items[] = array('url'=>'usergroups.php', 'label' => get_lang('Classes'));
$items[] = array('url' => 'usergroups.php', 'label' => get_lang('Classes'));
$blocks['users']['items'] = $items;
$blocks['users']['extra'] = null;
if (api_is_platform_admin()) {
/* Courses */
$blocks['courses']['icon'] = Display::return_icon('course.gif', get_lang('Courses'), array(), ICON_SIZE_MEDIUM, false);
$blocks['courses']['icon'] = Display::return_icon(
'course.gif',
get_lang('Courses'),
array(),
ICON_SIZE_MEDIUM,
false
);
$blocks['courses']['label'] = api_ucfirst(get_lang('Courses'));
$blocks['courses']['class'] = 'block-admin-courses';
$blocks['courses']['editable'] = true;
@ -139,46 +147,54 @@ if (api_is_platform_admin()) {
}
$search_form = ' <form method="get" class="form-inline" action="course_list.php">
<div class="form-group">
<input class="form-control" type="text" name="keyword" value="">
<button class="btn btn-default" type="submit"><i class="fa fa-search"></i> '.get_lang('Search').'</button>
</div>
</form>';
<div class="form-group">
<input class="form-control" type="text" name="keyword" value="">
<button class="btn btn-default" type="submit">
<i class="fa fa-search"></i> ' . get_lang('Search') . '
</button>
</div>
</form>';
$blocks['courses']['search_form'] = $search_form;
$items = array();
$items[] = array('url'=>'course_list.php', 'label' => get_lang('CourseList'));
$items[] = array('url'=>'course_add.php', 'label' => get_lang('AddCourse'));
$items[] = array('url' => 'course_list.php', 'label' => get_lang('CourseList'));
$items[] = array('url' => 'course_add.php', 'label' => get_lang('AddCourse'));
if (api_get_setting('course_validation') == 'true') {
$items[] = array('url'=>'course_request_review.php', 'label' => get_lang('ReviewCourseRequests'));
$items[] = array('url'=>'course_request_accepted.php', 'label' => get_lang('AcceptedCourseRequests'));
$items[] = array('url'=>'course_request_rejected.php', 'label' => get_lang('RejectedCourseRequests'));
$items[] = array('url' => 'course_request_review.php', 'label' => get_lang('ReviewCourseRequests'));
$items[] = array('url' => 'course_request_accepted.php', 'label' => get_lang('AcceptedCourseRequests'));
$items[] = array('url' => 'course_request_rejected.php', 'label' => get_lang('RejectedCourseRequests'));
}
$items[] = array('url'=>'course_export.php', 'label' => get_lang('ExportCourses'));
$items[] = array('url'=>'course_import.php', 'label' => get_lang('ImportCourses'));
$items[] = array('url'=>'course_category.php', 'label' => get_lang('AdminCategories'));
$items[] = array('url'=>'subscribe_user2course.php', 'label' => get_lang('AddUsersToACourse'));
$items[] = array('url'=>'course_user_import.php', 'label' => get_lang('ImportUsersToACourse'));
$items[] = array('url' => 'course_export.php', 'label' => get_lang('ExportCourses'));
$items[] = array('url' => 'course_import.php', 'label' => get_lang('ImportCourses'));
$items[] = array('url' => 'course_category.php', 'label' => get_lang('AdminCategories'));
$items[] = array('url' => 'subscribe_user2course.php', 'label' => get_lang('AddUsersToACourse'));
$items[] = array('url' => 'course_user_import.php', 'label' => get_lang('ImportUsersToACourse'));
//$items[] = array('url'=>'course_intro_pdf_import.php', 'label' => get_lang('ImportPDFIntroToCourses'));
if (api_get_setting('gradebook_enable_grade_model') == 'true') {
$items[] = array('url'=>'grade_models.php', 'label' => get_lang('GradeModel'));
$items[] = array('url' => 'grade_models.php', 'label' => get_lang('GradeModel'));
}
if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) {
$items[] = array('url'=>'ldap_import_students.php', 'label' => get_lang('ImportLDAPUsersIntoCourse'));
$items[] = array('url' => 'ldap_import_students.php', 'label' => get_lang('ImportLDAPUsersIntoCourse'));
}
$items[] = array('url'=>'extra_fields.php?type=course', 'label' => get_lang('ManageCourseFields'));
$items[] = array('url' => 'extra_fields.php?type=course', 'label' => get_lang('ManageCourseFields'));
$blocks['courses']['items'] = $items;
$blocks['courses']['extra'] = null;
/* Platform */
$blocks['platform']['icon'] = Display::return_icon('platform.png', get_lang('Platform'), array(), ICON_SIZE_MEDIUM, false);
$blocks['platform']['icon'] = Display::return_icon(
'platform.png',
get_lang('Platform'),
array(),
ICON_SIZE_MEDIUM,
false
);
$blocks['platform']['label'] = api_ucfirst(get_lang('Platform'));
$blocks['platform']['class'] = 'block-admin-platform';
$blocks['platform']['editable'] = true;
@ -190,53 +206,67 @@ if (api_is_platform_admin()) {
}
$search_form = ' <form method="get" action="settings.php" class="form-inline">
<div class="form-group">
<input class="form-control" type="text" name="search_field" value="" >
<input type="hidden" value="search_setting" name="category">
<button class="btn btn-default" type="submit"><i class="fa fa-search"></i> '.get_lang('Search').'</button>
</div>
</form>';
$blocks['platform']['search_form'] = $search_form;
<div class="form-group">
<input class="form-control" type="text" name="search_field" value="" >
<input type="hidden" value="search_setting" name="category">
<button class="btn btn-default" type="submit">
<i class="fa fa-search"></i> ' . get_lang('Search') . '
</button>
</div>
</form>';
$blocks['platform']['search_form'] = $search_form;
$items = array();
$items[] = array('url'=>'settings.php', 'label' => get_lang('PlatformConfigSettings'));
$items[] = array('url'=>'settings.php?category=Plugins','label' => get_lang('Plugins'));
$items[] = array('url'=>'settings.php?category=Regions','label' => get_lang('Regions'));
$items[] = array('url'=>'system_announcements.php', 'label' => get_lang('SystemAnnouncements'));
$items[] = array('url'=> api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=admin', 'label' => get_lang('GlobalAgenda'));
$items[] = array('url'=>'configure_homepage.php', 'label' => get_lang('ConfigureHomePage'));
$items[] = array('url'=>'configure_inscription.php', 'label' => get_lang('ConfigureInscription'));
$items[] = array('url'=>'statistics/index.php', 'label' => get_lang('Statistics'));
$items[] = array('url'=> api_get_path(WEB_CODE_PATH).'mySpace/company_reports.php', 'label' => get_lang('Reports'));
$items[] = array('url' => 'settings.php', 'label' => get_lang('PlatformConfigSettings'));
$items[] = array('url' => 'settings.php?category=Plugins', 'label' => get_lang('Plugins'));
$items[] = array('url' => 'settings.php?category=Regions', 'label' => get_lang('Regions'));
$items[] = array('url' => 'system_announcements.php', 'label' => get_lang('SystemAnnouncements'));
$items[] = array(
'url' => api_get_path(WEB_CODE_PATH) . 'calendar/agenda_js.php?type=admin',
'label' => get_lang('GlobalAgenda')
);
$items[] = array('url' => 'configure_homepage.php', 'label' => get_lang('ConfigureHomePage'));
$items[] = array('url' => 'configure_inscription.php', 'label' => get_lang('ConfigureInscription'));
$items[] = array('url' => 'statistics/index.php', 'label' => get_lang('Statistics'));
$items[] = array(
'url' => api_get_path(WEB_CODE_PATH) . 'mySpace/company_reports.php',
'label' => get_lang('Reports')
);
$items[] = array(
'url'=> api_get_path(WEB_CODE_PATH) . 'admin/teacher_time_report.php',
'url' => api_get_path(WEB_CODE_PATH) . 'admin/teacher_time_report.php',
'label' => get_lang('TeacherTimeReport')
);
/* Event settings */
if (api_get_setting('activate_email_template') == 'true') {
$items[] = array('url'=>'event_controller.php?action=listing', 'label' => get_lang('EventMessageManagement'));
$items[] = array('url' => 'event_controller.php?action=listing', 'label' => get_lang('EventMessageManagement'));
}
if (!empty($_configuration['multiple_access_urls'])) {
if (api_is_global_platform_admin()) {
$items[] = array('url'=>'access_urls.php', 'label' => get_lang('ConfigureMultipleAccessURLs'));
$items[] = array('url' => 'access_urls.php', 'label' => get_lang('ConfigureMultipleAccessURLs'));
}
}
if (api_get_setting('allow_reservation') == 'true') {
$items[] = array('url'=>'../reservation/m_category.php', 'label' => get_lang('BookingSystem'));
$items[] = array('url' => '../reservation/m_category.php', 'label' => get_lang('BookingSystem'));
}
if (api_get_setting('allow_terms_conditions') == 'true') {
$items[] = array('url'=>'legal_add.php', 'label' => get_lang('TermsAndConditions'));
$items[] = array('url' => 'legal_add.php', 'label' => get_lang('TermsAndConditions'));
}
$blocks['platform']['items'] = $items;
$blocks['platform']['extra'] = null;
}
/* Sessions */
$blocks['sessions']['icon'] = Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL, false);
$blocks['sessions']['icon'] = Display::return_icon(
'session.png',
get_lang('Sessions'),
array(),
ICON_SIZE_SMALL,
false
);
$blocks['sessions']['label'] = api_ucfirst(get_lang('Sessions'));
$blocks['sessions']['class'] = 'block-admin-sessions';
@ -252,53 +282,70 @@ if (api_is_platform_admin()) {
$search_form = ' <form method="GET" class="form-inline" action="session_list.php">
<div class="form-group">
<input class="form-control" type="text" name="keyword" value="">
<button class="btn btn-default" type="submit"><i class="fa fa-search"></i> '.get_lang('Search').'</button>
<input class="form-control" type="text" name="keyword" value="">
<button class="btn btn-default" type="submit">
<i class="fa fa-search"></i> ' . get_lang('Search') . '
</button>
</div>
</form>';
$blocks['sessions']['search_form'] = $search_form;
$items = array();
$items[] = array('url'=>'session_list.php', 'label' => get_lang('ListSession'));
$items[] = array('url'=>'session_add.php', 'label' => get_lang('AddSession'));
$items[] = array('url'=>'session_category_list.php', 'label' => get_lang('ListSessionCategory'));
$items[] = array('url'=>'session_import.php', 'label' => get_lang('ImportSessionListXMLCSV'));
$items[] = array('url'=>'session_import_drh.php', 'label' => get_lang('ImportSessionDrhList'));
$items[] = array('url' => 'session_list.php', 'label' => get_lang('ListSession'));
$items[] = array('url' => 'session_add.php', 'label' => get_lang('AddSession'));
$items[] = array('url' => 'session_category_list.php', 'label' => get_lang('ListSessionCategory'));
$items[] = array('url' => 'session_import.php', 'label' => get_lang('ImportSessionListXMLCSV'));
$items[] = array('url' => 'session_import_drh.php', 'label' => get_lang('ImportSessionDrhList'));
if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) {
$items[] = array('url'=>'ldap_import_students_to_session.php', 'label' => get_lang('ImportLDAPUsersIntoSession'));
$items[] = array(
'url' => 'ldap_import_students_to_session.php',
'label' => get_lang('ImportLDAPUsersIntoSession')
);
}
$items[] = array('url'=>'session_export.php', 'label' => get_lang('ExportSessionListXMLCSV'));
$items[] = array('url'=>'../coursecopy/copy_course_session.php', 'label' => get_lang('CopyFromCourseInSessionToAnotherSession'));
$items[] = array('url' => 'session_export.php', 'label' => get_lang('ExportSessionListXMLCSV'));
$items[] = array(
'url' => '../coursecopy/copy_course_session.php',
'label' => get_lang('CopyFromCourseInSessionToAnotherSession')
);
if (api_is_platform_admin()) {
if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) { // option only visible in development mode. Enable through code if required
$items[] = array('url'=>'user_move_stats.php', 'label' => get_lang('MoveUserStats'));
// option only visible in development mode. Enable through code if required
if (is_dir(api_get_path(SYS_TEST_PATH) . 'datafiller/')) {
$items[] = array('url' => 'user_move_stats.php', 'label' => get_lang('MoveUserStats'));
}
$items[] = array('url'=>'career_dashboard.php', 'label' => get_lang('CareersAndPromotions'));
$items[] = array('url' => 'career_dashboard.php', 'label' => get_lang('CareersAndPromotions'));
$items[] = array('url' => 'extra_fields.php?type=session', 'label' => get_lang('ManageSessionFields'));
}
$items[] = array('url'=>'extra_fields.php?type=session', 'label' => get_lang('ManageSessionFields'));
$blocks['sessions']['items'] = $items;
$blocks['sessions']['extra'] = null;
/* Settings */
if (api_is_platform_admin()) {
$blocks['settings']['icon'] = Display::return_icon('settings.png', get_lang('System'), array(), ICON_SIZE_SMALL, false);
$blocks['settings']['icon'] = Display::return_icon(
'settings.png',
get_lang('System'),
array(),
ICON_SIZE_SMALL,
false
);
$blocks['settings']['label'] = api_ucfirst(get_lang('System'));
$blocks['settings']['class'] = 'block-admin-settings';
$items = array();
$items[] = array('url'=>'special_exports.php', 'label' => get_lang('SpecialExports'));
$items[] = array('url' => 'special_exports.php', 'label' => get_lang('SpecialExports'));
if (!empty($_configuration['db_admin_path'])) {
$items[] = array('url'=>$_configuration['db_admin_path'], 'label' => get_lang('AdminDatabases').' ('.get_lang('DBManagementOnlyForServerAdmin').') ');
$items[] = array(
'url' => $_configuration['db_admin_path'],
'label' => get_lang('AdminDatabases') . ' (' . get_lang('DBManagementOnlyForServerAdmin') . ') '
);
}
$items[] = array('url'=>'system_status.php', 'label' => get_lang('SystemStatus'));
if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) {
$items[] = array('url'=>'filler.php', 'label' => get_lang('DataFiller'));
$items[] = array('url' => 'system_status.php', 'label' => get_lang('SystemStatus'));
if (is_dir(api_get_path(SYS_TEST_PATH) . 'datafiller/')) {
$items[] = array('url' => 'filler.php', 'label' => get_lang('DataFiller'));
}
$items[] = array('url'=>'archive_cleanup.php', 'label' => get_lang('ArchiveDirCleanup'));
$items[] = array('url' => 'archive_cleanup.php', 'label' => get_lang('ArchiveDirCleanup'));
if (isset($_configuration['db_manager_enabled']) &&
$_configuration['db_manager_enabled'] == true &&
@ -308,7 +355,10 @@ if (api_is_platform_admin()) {
$username = $_configuration['db_user'];
$databaseName = $_configuration['main_database'];
$items[] = array('url'=>"db.php?username=$username&db=$databaseName&server=$host", 'label' => get_lang('Database Manager'));
$items[] = array(
'url' => "db.php?username=$username&db=$databaseName&server=$host",
'label' => get_lang('Database Manager')
);
}
$blocks['settings']['items'] = $items;
@ -318,20 +368,31 @@ if (api_is_platform_admin()) {
// Skills
if (api_get_setting('allow_skills_tool') == 'true') {
$blocks['skills']['icon'] = Display::return_icon('logo.png', get_lang('Skills'), array(), ICON_SIZE_SMALL, false);
$blocks['skills']['icon'] = Display::return_icon(
'logo.png',
get_lang('Skills'),
array(),
ICON_SIZE_SMALL,
false
);
$blocks['skills']['label'] = get_lang('Skills');
$blocks['skills']['class'] = 'block-admin-skills';
$items = array();
//$items[] = array('url'=>'skills.php', 'label' => get_lang('SkillsTree'));
$items[] = array('url'=>'skills_wheel.php', 'label' => get_lang('SkillsWheel'));
$items[] = array('url'=>'skills_import.php', 'label' => get_lang('SkillsImport'));
$items[] = array('url'=>'skill_list.php', 'label' => get_lang('ManageSkills'));
$items[] = array('url' => 'skills_wheel.php', 'label' => get_lang('SkillsWheel'));
$items[] = array('url' => 'skills_import.php', 'label' => get_lang('SkillsImport'));
$items[] = array('url' => 'skill_list.php', 'label' => get_lang('ManageSkills'));
//$items[] = array('url'=>'skills_profile.php', 'label' => get_lang('SkillsProfile'));
$items[] = array('url'=>api_get_path(WEB_CODE_PATH).'social/skills_ranking.php', 'label' => get_lang('SkillsRanking'));
$items[] = array('url'=>'skills_gradebook.php', 'label' => get_lang('SkillsAndGradebooks'));
$items[] = array('url'=> api_get_path(WEB_CODE_PATH) . 'admin/skill_badge.php', 'label' => get_lang('Badges'));
$items[] = array(
'url' => api_get_path(WEB_CODE_PATH) . 'social/skills_ranking.php',
'label' => get_lang('SkillsRanking')
);
$items[] = array('url' => 'skills_gradebook.php', 'label' => get_lang('SkillsAndGradebooks'));
$items[] = array(
'url' => api_get_path(WEB_CODE_PATH) . 'admin/skill_badge.php',
'label' => get_lang('Badges')
);
$blocks['skills']['items'] = $items;
$blocks['skills']['extra'] = null;
$blocks['skills']['search_form'] = null;
@ -339,28 +400,31 @@ if (api_is_platform_admin()) {
/* Chamilo.org */
$blocks['chamilo']['icon'] = Display::return_icon('logo.png', 'Chamilo.org', array(), ICON_SIZE_SMALL, false);
$blocks['chamilo']['icon'] = Display::return_icon('logo.png', 'Chamilo.org', array(), ICON_SIZE_SMALL, false);
$blocks['chamilo']['label'] = 'Chamilo.org';
$blocks['chamilo']['class'] = 'block-admin-chamilo';
$items = array();
$items[] = array('url'=>'http://www.chamilo.org/', 'label' => get_lang('ChamiloHomepage'));
$items[] = array('url'=>'http://www.chamilo.org/forum', 'label' => get_lang('ChamiloForum'));
$items[] = array('url'=>'../../documentation/installation_guide.html', 'label' => get_lang('InstallationGuide'));
$items[] = array('url'=>'../../documentation/changelog.html', 'label' => get_lang('ChangesInLastVersion'));
$items[] = array('url'=>'../../documentation/credits.html', 'label' => get_lang('ContributorsList'));
$items[] = array('url'=>'../../documentation/security.html', 'label' => get_lang('SecurityGuide'));
$items[] = array('url'=>'../../documentation/optimization.html', 'label' => get_lang('OptimizationGuide'));
$items[] = array('url'=>'http://www.chamilo.org/extensions', 'label' => get_lang('ChamiloExtensions'));
$items[] = array('url'=>'http://www.chamilo.org/en/providers', 'label' => get_lang('ChamiloOfficialServicesProviders'));
$items[] = array('url' => 'http://www.chamilo.org/', 'label' => get_lang('ChamiloHomepage'));
$items[] = array('url' => 'http://www.chamilo.org/forum', 'label' => get_lang('ChamiloForum'));
$items[] = array('url' => '../../documentation/installation_guide.html', 'label' => get_lang('InstallationGuide'));
$items[] = array('url' => '../../documentation/changelog.html', 'label' => get_lang('ChangesInLastVersion'));
$items[] = array('url' => '../../documentation/credits.html', 'label' => get_lang('ContributorsList'));
$items[] = array('url' => '../../documentation/security.html', 'label' => get_lang('SecurityGuide'));
$items[] = array('url' => '../../documentation/optimization.html', 'label' => get_lang('OptimizationGuide'));
$items[] = array('url' => 'http://www.chamilo.org/extensions', 'label' => get_lang('ChamiloExtensions'));
$items[] = array(
'url' => 'http://www.chamilo.org/en/providers',
'label' => get_lang('ChamiloOfficialServicesProviders')
);
$blocks['chamilo']['items'] = $items;
$blocks['chamilo']['extra'] = null;
$blocks['chamilo']['search_form'] = null;
//Version check
$blocks['version_check']['icon'] = Display::return_icon('logo.png', 'Chamilo.org', array(), ICON_SIZE_SMALL, false);
$blocks['version_check']['icon'] = Display::return_icon('logo.png', 'Chamilo.org', array(), ICON_SIZE_SMALL, false);
$blocks['version_check']['label'] = get_lang('VersionCheck');
$blocks['version_check']['extra'] = '<div class="admin-block-version"></div>';
$blocks['version_check']['search_form'] = null;
@ -378,9 +442,8 @@ if (api_is_platform_admin()) {
$blocks = $data['blocks'];
}
}
}
$admin_ajax_url = api_get_path(WEB_AJAX_PATH).'admin.ajax.php';
$admin_ajax_url = api_get_path(WEB_AJAX_PATH) . 'admin.ajax.php';
$tpl = new Template();

@ -2,7 +2,7 @@
/* For licensing terms, see /license.txt */
/**
* Create course sessions procedure. It creates sessions for courses that haven't it yet.
* If today is greater than OFFSET, it will create them also for the next month.
* If today is greater than OFFSET, it will create them also for the next quarter
* @package chamilo.cron
* @author Imanol Losada <imanol.losada@beeznest.com>
*/
@ -32,6 +32,106 @@ function getMonthFirstAndLastDates($initialDate = null)
return array('startDate' => $startDate, 'endDate' => $endDate);
}
/**
* Same as month, but for quarters
* @param array $initialDate First day of the quarter
* @return array First and last days of the quarter
*/
function getQuarterFirstAndLastDates($initialDate = null)
{
$startDate = $initialDate ? $initialDate : date("Y-m-01");
$month = getQuarterFirstMonth(getQuarter(date('m', $startDate)));
$startDate = substr($startDate, 0, 5) . $month . '-01';
$nextQuarterStartDate = date('Y-m-d', api_strtotime($startDate.' + 3 month'));
$endDate = date('Y-m-d', api_strtotime($nextQuarterStartDate.' - 1 minute'));
return array('startDate' => $startDate, 'endDate' => $endDate);
}
/**
* Returns a quarter from a month
* @param string The month (digit), with or without leading 0
* @return int The yearly quarter (1, 2, 3 or 4) in which this month lies
*/
function getQuarter($month)
{
$quarter = 1;
// Remove the leading 0 if any
if (substr($month, 0, 1) == '0') {
$month = substr($month, 1);
}
// reduce to 4 quarters: 1..3=1; 4..6=2
switch ($month) {
case 1:
//no break
case 2:
//no break
case 3:
$quarter = 1;
break;
case 4:
//no break
case 5:
//no break
case 6:
$quarter = 2;
break;
case 7:
//no break
case 8:
//no break
case 9:
$quarter = 3;
break;
case 10:
//no break
case 11:
//no break
case 12:
$quarter = 4;
break;
}
return $quarter;
}
/**
* Returns the first month of the quarter
* @param int Quarter
* @return string Number of the month, with leading 0
*/
function getQuarterFirstMonth($quarter)
{
switch ($quarter) {
case 1:
return '01';
case 2:
return '04';
case 3:
return '07';
case 4:
return '10';
}
return false;
}
/**
* Get the quarter in Roman letters
* @param int Quarter
* @return string Roman letters
*/
function getQuarterRoman($quarter)
{
switch ($quarter) {
case 1:
return 'I';
case 2:
return 'II';
case 3:
return 'III';
case 4:
return 'IV';
}
}
/**
* Creates one session per course with $administratorId as the creator and
* adds it to the session starting on $startDate and finishing on $endDate
@ -50,7 +150,13 @@ function createCourseSessions($courses, $administratorId, $startDate, $endDate)
echo "\n=====================================================================================\n\n";
// Loop through courses creating one session per each and adding them
foreach ($courses as $course) {
$sessionName = $course['title']." (".date("m/Y", api_strtotime($startDate)).")";
//$period = date("m/Y", api_strtotime($startDate));
$month = date("m", api_strtotime($startDate));
$year = date("Y", api_strtotime($startDate));
$quarter = getQuarter($month);
$quarter = getQuarterRoman($quarter);
$period = $year . '-' . $quarter;
$sessionName = '[' . $period . '] ' . $course['title'];
$sessionId = SessionManager::create_session(
$sessionName,
$startDate,
@ -82,14 +188,15 @@ if (!$lastingAdministrators) {
$administratorId = intval($administrators[$lastingAdministrators - 1]['user_id']);
// Creates course sessions for the current month
$dates = getMonthFirstAndLastDates(date('Y-m-').'01');
$dates = getQuarterFirstAndLastDates(date('Y-m-').'01');
// Get courses that don't have any session
$courses = CourseManager::getCoursesWithoutSession($dates['startDate'], $dates['endDate']);
createCourseSessions($courses, $administratorId, $dates['startDate'], $dates['endDate']);
// Creates course sessions for the following month
if (date("Y-m-d") >= date("Y-m-".OFFSET)) {
$dates = getMonthFirstAndLastDates(date("Y-m-d", api_strtotime(date("Y-m-01")." + 1 month")));
$offsetDay = intval(substr($dates['endDate'], 8, 2)) - OFFSET;
if (date("Y-m-d") >= date(substr($dates['endDate'], 0, 8) . $offsetDay)) {
$dates = getQuarterFirstAndLastDates(date("Y-m-d", api_strtotime(date("Y-m-01")." + 3 month")));
// Get courses that don't have any session the next month
$courses = CourseManager::getCoursesWithoutSession($dates['startDate'], $dates['endDate']);
createCourseSessions($courses, $administratorId, $dates['startDate'], $dates['endDate']);

@ -5903,3 +5903,30 @@ ul.holder li.bit-box{
height: auto !important;
max-width: 100%;
}
/*** Draggable answer ***/
.question_options ul.exercise-draggable-answer{
float: left;
margin-bottom: 20px;
min-height: 2em;
min-width: 100%;
}
ul.exercise-draggable-answer li {
cursor: move;
float: left;
margin: 0 20px 20px 0;
padding: 5px;
text-align: center;
width: 200px;
}
.question_options .droppable {
float: left;
margin: 0 20px 20px 0;
padding: 20px;
text-align: center;
width: 240px
}
.question_options .droppable .gallery .exercise-draggable-answer-option {
margin-bottom: 15px;
}

@ -0,0 +1,224 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Draggable
*
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
*/
class Draggable extends Question
{
static $typePicture = 'matching.png';
static $explanationLangVar = 'Draggable';
/**
* Class constructor
*/
public function __construct()
{
parent::__construct();
$this->type = DRAGGABLE;
$this->isContent = $this->getIsContent();
}
/**
* Function which redefines Question::createAnswersForm
* @param FormValidator $form
*/
public function createAnswersForm($form)
{
$defaults = array();
$nb_matches = $nb_options = 2;
$matches = array();
$answer = null;
if ($form->isSubmitted()) {
$nb_matches = $form->getSubmitValue('nb_matches');
$nb_options = $form->getSubmitValue('nb_options');
if (isset($_POST['lessMatches'])) {
$nb_matches--;
}
if (isset($_POST['moreMatches'])) {
$nb_matches++;
}
if (isset($_POST['lessOptions'])) {
$nb_options--;
}
if (isset($_POST['moreOptions'])) {
$nb_options++;
}
} else if (!empty($this->id)) {
$answer = new Answer($this->id);
$answer->read();
if (count($answer->nbrAnswers) > 0) {
$nb_matches = $nb_options = 0;
for ($i = 1; $i <= $answer->nbrAnswers; $i++) {
if ($answer->isCorrect($i)) {
$nb_matches++;
$defaults['answer[' . $nb_matches . ']'] = $answer->selectAnswer($i);
$defaults['weighting[' . $nb_matches . ']'] = float_format($answer->selectWeighting($i), 1);
$defaults['matches[' . $nb_matches . ']'] = $answer->correct[$i];
} else {
$nb_options++;
$defaults['option[' . $nb_options . ']'] = $answer->selectAnswer($i);
}
}
}
} else {
$defaults['answer[1]'] = get_lang('DefaultMakeCorrespond1');
$defaults['answer[2]'] = get_lang('DefaultMakeCorrespond2');
$defaults['matches[2]'] = '2';
$defaults['option[1]'] = get_lang('DefaultMatchingOptA');
$defaults['option[2]'] = get_lang('DefaultMatchingOptB');
}
for ($i = 1; $i <= $nb_matches; ++$i) {
$matches[$i] = $i;
}
$form->addElement('hidden', 'nb_matches', $nb_matches);
$form->addElement('hidden', 'nb_options', $nb_options);
// DISPLAY MATCHES
$html = '<table class="table table-striped table-hover">
<thead>
<tr>
<th width="85%">' . get_lang('Answer') . '</th>
<th width="15%">' . get_lang('MatchesTo') . '</th>
<th width="10">' . get_lang('Weighting') . '</th>
</tr>
</thead>
<tbody>';
$form->addHeader(get_lang('MakeCorrespond'));
$form->addHtml($html);
if ($nb_matches < 1) {
$nb_matches = 1;
Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
}
for ($i = 1; $i <= $nb_matches; ++$i) {
$renderer = &$form->defaultRenderer();
$renderer->setElementTemplate(
'<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>',
"answer[$i]"
);
$renderer->setElementTemplate(
'<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>',
"matches[$i]"
);
$renderer->setElementTemplate(
'<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>',
"weighting[$i]"
);
$form->addHtml('<tr>');
$form->addText("answer[$i]", null);
$form->addSelect("matches[$i]", null, $matches);
$form->addText("weighting[$i]", null, true, ['value' => 10]);
$form->addHtml('</tr>');
}
$form->addHtml('</tbody></table>');
$group = array();
$renderer->setElementTemplate(
'<div class="form-group"><div class="col-sm-offset-2">{element}',
'lessMatches'
);
$renderer->setElementTemplate('{element}</div></div>', 'moreMatches');
global $text;
$group = [
$form->addButtonDelete(get_lang('DelElem'), 'lessMatches', true),
$form->addButtonCreate(get_lang('AddElem'), 'moreMatches', true),
$form->addButtonSave($text, 'submitQuestion', true)
];
$form->addGroup($group);
if (!empty($this->id)) {
$form->setDefaults($defaults);
} else {
if ($this->isContent == 1) {
$form->setDefaults($defaults);
}
}
$form->setConstants(
[
'nb_matches' => $nb_matches,
'nb_options' => $nb_options
]
);
}
/**
* Abstract function which creates the form to create / edit the answers of the question
* @param FormValidator $form
*/
public function processAnswersCreation($form)
{
$nb_matches = $form->getSubmitValue('nb_matches');
$this->weighting = 0;
$position = 0;
$objAnswer = new Answer($this->id);
// Insert the options
for ($i = 1; $i <= $nb_matches; ++$i) {
$position++;
$objAnswer->createAnswer($position, 0, '', 0, $position);
}
// Insert the answers
for ($i = 1; $i <= $nb_matches; ++$i) {
$position++;
$answer = $form->getSubmitValue('answer[' . $i . ']');
$matches = $form->getSubmitValue('matches[' . $i . ']');
$weighting = $form->getSubmitValue('weighting[' . $i . ']');
$this->weighting += $weighting;
$objAnswer->createAnswer($answer, $matches, '', $weighting, $position);
}
$objAnswer->save();
$this->save();
}
/**
* Shows question title an description
* @param string $feedback_type
* @param int $counter
* @param float $score
* @return string
*/
public function return_header($feedback_type = null, $counter = null, $score = null)
{
$header = parent::return_header($feedback_type, $counter, $score);
$header .= '<table class="' . $this->question_table_class . '">
<tr>
<th>' . get_lang('ElementList') . '</th>
<th>' . get_lang('Status') . '</th>
</tr>';
return $header;
}
}

@ -1890,7 +1890,7 @@ class Exercise
}
$class .= ' question-validate-btn'; // used to select it with jquery
$all_button = '&nbsp;<a href="javascript://" class="'.$class.'" onclick="validate_all(); ">'.$all_label.'</a>';
$all_button .= '&nbsp;<span id="save_all_reponse"></span>';
$all_button .= '&nbsp;' . Display::span(null, ['id' => 'save_all_reponse']);
$html .= $all_button;
}
}
@ -2772,6 +2772,8 @@ class Exercise
}
}
break;
case DRAGGABLE:
//no break
case MATCHING:
if ($from_database) {
$sql = 'SELECT id, answer, id_auto
@ -2824,20 +2826,38 @@ class Exercise
if ($s_user_answer == $i_answer_correct_answer) {
$questionScore += $i_answerWeighting;
$totalScore += $i_answerWeighting;
if (isset($real_list[$i_answer_id])) {
$user_answer = '<span>'.$real_list[$i_answer_id].'</span>';
if ($answerType == DRAGGABLE) {
$user_answer = Display::label(get_lang('Correct'), 'success');
} else {
if (isset($real_list[$i_answer_id])) {
$user_answer = Display::span($real_list[$i_answer_id]);
}
}
} else {
$user_answer = '<span style="color: #FF0000; text-decoration: line-through;">'.$real_list[$s_user_answer].'</span>';
if ($answerType == DRAGGABLE) {
$user_answer = Display::label(get_lang('Incorrect'), 'danger');
} else {
$user_answer = Display::span(
$real_list[$s_user_answer],
['style' => 'color: #FF0000; text-decoration: line-through;']
);
}
}
} elseif ($answerType == DRAGGABLE) {
$user_answer = Display::label(get_lang('Incorrect'), 'danger');
}
if ($show_result) {
echo '<tr>';
echo '<td>'.$s_answer_label.'</td>';
echo '<td>'.$user_answer;
if (isset($real_list[$i_answer_correct_answer])) {
echo ' <b><span style="color: #008000;">'.$real_list[$i_answer_correct_answer].'</span></b> ';
echo '<td>' . $s_answer_label . '</td>';
echo '<td>' . $user_answer;
if ($answerType == MATCHING) {
if (isset($real_list[$i_answer_correct_answer])) {
echo Display::span(
$real_list[$i_answer_correct_answer],
['style' => 'color: #008000; font-weight: bold;']
);
}
}
echo '</td>';
echo '</tr>';
@ -2850,10 +2870,13 @@ class Exercise
$questionScore += $answerWeighting;
$totalScore += $answerWeighting;
$user_answer = '<span>'.$answerMatching[$choice[$answerAutoId]].'</span>';
$user_answer = Display::span($answerMatching[$choice[$answerAutoId]]);
} else {
if (isset($answerMatching[$choice[$answerAutoId]])) {
$user_answer = '<span style="color: #FF0000; text-decoration: line-through;">'.$answerMatching[$choice[$answerAutoId]].'</span>';
$user_answer = Display::span(
$answerMatching[$choice[$answerAutoId]],
['style' => 'color: #FF0000; text-decoration: line-through;']
);
}
}
$matching[$answerAutoId] = $choice[$answerAutoId];
@ -2951,7 +2974,13 @@ class Exercise
if ($from == 'exercise_result') {
if ($debug) error_log('Showing questions $from '.$from);
//display answers (if not matching type, or if the answer is correct)
if ($answerType != MATCHING || $answerCorrect) {
if (
!in_array(
$answerType,
[MATCHING, DRAGGABLE]
) ||
$answerCorrect
) {
if (
in_array(
$answerType,
@ -3218,10 +3247,15 @@ class Exercise
}
} elseif($answerType == MATCHING) {
echo '<tr>';
echo '<td>' . $answerMatching[$answerId] . '</td>';
echo '<td>' . $user_answer . ' / <b>'
. '<span style="color: #008000;">' . $answerMatching[$answerCorrect] . '</span>'
. '</b></td>';
echo Display::tag('td', $answerMatching[$answerId]);
echo Display::tag(
'td',
"$user_answer / " . Display::tag(
'strong',
$answerMatching[$answerCorrect],
['style' => 'color: #008000; font-weight: bold;']
)
);
echo '</tr>';
}
}
@ -3535,12 +3569,19 @@ class Exercise
$answerComment
);
break;
case DRAGGABLE:
//no break
case MATCHING:
echo '<tr>';
echo '<td>' . $answerMatching[$answerId] . '</td>';
echo '<td>' . $user_answer . ' / <b>'
. '<span style="color: #008000;">' . $answerMatching[$answerCorrect] . '</span></b>'
. '</td>';
echo Display::tag('td', $answerMatching[$answerId]);
echo Display::tag(
'td',
"$user_answer / " . Display::tag(
'strong',
$answerMatching[$answerCorrect],
['style' => 'color: #008000; font-weight: bold;']
)
);
echo '</tr>';
break;
@ -3842,7 +3883,7 @@ class Exercise
} else {
Event::saveQuestionAttempt($questionScore, 0, $quesId, $exeId, 0, $this->id);
}
} elseif ($answerType == MATCHING) {
} elseif (in_array($answerType, [MATCHING, DRAGGABLE])) {
if (isset($matching)) {
foreach ($matching as $j => $val) {
Event::saveQuestionAttempt($questionScore, $val, $quesId, $exeId, $j, $this->id);

@ -343,7 +343,7 @@ foreach ($questionList as $questionId) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == MATCHING) {
} elseif (in_array($answerType, [MATCHING, DRAGGABLE])) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];

@ -57,6 +57,8 @@ $htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.dateformat.min.js');
$htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.epiclock.min.js');
$htmlHeadXtra[] = api_get_js('epiclock/renderers/minute/epiclock.minute.js');
$htmlHeadXtra[] = (new Template())->fetch('default/exercise/submit.js.tpl');
// General parameters passed via POST/GET
$learnpath_id = isset($_REQUEST['learnpath_id']) ? intval($_REQUEST['learnpath_id']) : 0;

@ -49,7 +49,8 @@ abstract class Question
),
GLOBAL_MULTIPLE_ANSWER => array('global_multiple_answer.class.php' , 'GlobalMultipleAnswer'),
CALCULATED_ANSWER => array('calculated_answer.class.php' , 'CalculatedAnswer'),
UNIQUE_ANSWER_IMAGE => ['UniqueAnswerImage.php', 'UniqueAnswerImage']
UNIQUE_ANSWER_IMAGE => ['UniqueAnswerImage.php', 'UniqueAnswerImage'],
DRAGGABLE => ['Draggable.php', 'Draggable']
//MEDIA_QUESTION => array('media_question.class.php' , 'MediaQuestion')
);

@ -475,6 +475,7 @@ define('GLOBAL_MULTIPLE_ANSWER', 14);
define('MEDIA_QUESTION', 15);
define('CALCULATED_ANSWER', 16);
define('UNIQUE_ANSWER_IMAGE', 17);
define('DRAGGABLE', 18);
//Some alias used in the QTI exports
define('MCUA', 1);

@ -3122,7 +3122,7 @@ class CourseManager
relation_type=" . COURSE_RELATION_TYPE_RRHH . " AND
access_url_id = " . api_get_current_access_url_id() . "";
} else {
$sql = "SELECT course_code FROM $tbl_course_rel_user
$sql = "SELECT c_id FROM $tbl_course_rel_user
WHERE user_id = $hr_manager_id AND relation_type=" . COURSE_RELATION_TYPE_RRHH . " ";
}
$result = Database::query($sql);

File diff suppressed because it is too large Load Diff

@ -1754,8 +1754,8 @@ class Display
if (!empty($list)) {
$html = '<dl class="dl-horizontal">';
foreach ($list as $item) {
$html .= '<dt>'.$item['title'].'</dd>';
$html .= '<dd>'.$item['content'].'</dt>';
$html .= '<dt>' . $item['title'] . '</dt>';
$html .= '<dd>' . $item['content'] . '</dd>';
}
$html .= '</dl>';
}

@ -104,8 +104,14 @@ class ExerciseLib
// on the right side are called answers
$num_suggestions = 0;
if ($answerType == MATCHING) {
$s .= '<table class="table table-hover table-striped">';
if (in_array($answerType, [MATCHING, DRAGGABLE])) {
if ($answerType == DRAGGABLE) {
$s .= '<div class="ui-widget ui-helper-clearfix">
<div class="clearfix">
<ul class="exercise-draggable-answer ui-helper-reset ui-helper-clearfix">';
} else {
$s .= '<table class="table table-hover table-striped">';
}
// Iterate through answers
$x = 1;
//mark letters for each answer
@ -908,6 +914,94 @@ class ExerciseLib
} // end if()
$matching_correct_answer++;
}
} elseif ($answerType == DRAGGABLE) {
if ($answerCorrect != 0) {
$parsed_answer = $answer;
$windowId = $questionId . '_' . $lines_count;
$s .= '<li class="thumbnail" id="' . $windowId . '">';
$s .= Display::div(
$parsed_answer,
[
'id' => "window_$windowId",
'class' => "window{$questionId}_question_draggable exercise-draggable-answer-option"
]
);
$selectedValue = 0;
$draggableSelectOptions = [];
foreach ($select_items as $key => $val) {
if ($debug_mark_answer) {
if ($val['id'] == $answerCorrect) {
$selectedValue = $val['id'];
}
}
if (
isset($user_choice[$matching_correct_answer]) &&
$val['id'] == $user_choice[$matching_correct_answer]['answer']
) {
$selectedValue = $val['id'];
}
$draggableSelectOptions[$val['id']] = $val['letter'];
}
$s .= Display::select(
"choice[$questionId][$numAnswer]",
$draggableSelectOptions,
$selectedValue,
[
'id' => "window_{$windowId}_select",
'class' => 'select_option',
'style' => 'display: none;'
],
false
);
if (!empty($answerCorrect) && !empty($selectedValue)) {
$s .= <<<JAVASCRIPT
<script>
$(function() {
DraggableAnswer.deleteItem(
$('#{$questionId}_{$selectedValue}'),
$('#drop_$windowId')
);
});
</script>
JAVASCRIPT;
}
if (isset($select_items[$lines_count])) {
$s .= Display::div(
Display::tag(
'b',
$select_items[$lines_count]['letter']
) . $select_items[$lines_count]['answer'],
[
'id' => "window_{$windowId}_answer",
'style' => 'display: none;'
]
);
} else {
$s .= '&nbsp;';
}
$lines_count++;
if (($lines_count - 1) == $num_suggestions) {
while (isset($select_items[$lines_count])) {
$s .= Display::tag('b', $select_items[$lines_count]['letter']);
$s .= $select_items[$lines_count]['answer'];
$lines_count++;
}
}
$matching_correct_answer++;
$s .= '</li>';
}
}
} // end for()
@ -921,6 +1015,37 @@ class ExerciseLib
}
}
if ($answerType == DRAGGABLE) {
$s .= "</ul></div>";
$counterAnswer = 1;
$s .= '<div class="col-xs-12"><div class="row">';
for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
$answerCorrect = $objAnswerTmp->isCorrect($answerId);
$windowId = $questionId . '_' . $counterAnswer;
if ($answerCorrect) {
$s .= Display::div(
$counterAnswer,
[
'id' => "drop_$windowId",
'class' => 'droppable col-sm-4 well'
]
);
$counterAnswer++;
}
}
$s .= '</div></div>';
}
if ($answerType == MATCHING) {
$s .= '</div>';
}
$s .= '</div>';
// destruction of the Answer object

@ -4489,9 +4489,9 @@ class UserManager
$sql = "INSERT IGNORE INTO $userRelUserTable(user_id, friend_user_id, relation_type) "
. "VALUES ($subscribedUserId, $userId, $relationType)";
Database::query($sql);
$result = Database::query($sql);
$affectedRows = Database::affected_rows();
$affectedRows = Database::affected_rows($result);
}
}

@ -7231,4 +7231,6 @@ $RequestSubmitted = "Your request has been submitted.";
$RequestFailed = "We are not able to fulfill your request at this time. Please contact your administrator.";
$InternalLogin = "Internal login";
$AlreadyLoggedIn = "You are already logged in";
$Draggable = "Draggable";
$Incorrect = "Incorrect";
?>

@ -7235,4 +7235,6 @@ $SaveBadge = "Guardar insignia";
$BadgeMeasuresXPixelsInPNG = "Medidas de la insignia 200x200 píxeles en formato PNG";
$SetTutor = "Hacer tutor";
$UniqueAnswerImage = "Respuesta de imagen única";
$Draggable = "Arrastrable";
$Incorrect = "Incorrecto";
?>

@ -0,0 +1,95 @@
<script>
var DraggableAnswer = {
gallery: null,
trash: null,
deleteItem: function (item, insertHere) {
if (insertHere.find(".exercise-draggable-answer-option").length > 0) {
return false;
}
item.fadeOut(function () {
var $list = $('<div class="gallery ui-helper-reset"/>').appendTo(insertHere);
item.find('a.btn').remove();
var droppedId = item.attr('id'),
dropedOnId = insertHere.attr('id'),
originSelectId = 'window_' + droppedId + '_select',
value = dropedOnId.split('_')[2];
$('#' + originSelectId + ' option')
.filter(function (index) {
return index === parseInt(value);
})
.attr("selected", true);
var recycleButton = $('<a>')
.attr('href', '#')
.addClass('btn btn-default btn-xs')
.append(
"{{ "Undo" | get_lang }} ",
$('<i>').addClass('fa fa-undo')
)
.on('click', function (e) {
e.preventDefault();
var liParent = $(this).parent();
DraggableAnswer.recycleItem(liParent);
});
item.append(recycleButton).appendTo($list).fadeIn();
});
},
recycleItem: function (item) {
item.fadeOut(function () {
item
.find('a.btn')
.remove()
.end()
.find("img")
.end()
.appendTo(DraggableAnswer.gallery)
.fadeIn();
});
var droppedId = item.attr('id'),
originSelectId = 'window_' + droppedId + '_select';
$('#' + originSelectId + ' option:first').attr('selected', 'selected');
},
init: function (gallery, trash) {
this.gallery = gallery;
this.trash = trash;
$("li", DraggableAnswer.gallery).draggable({
cancel: "a.ui-icon",
revert: "invalid",
containment: "document",
helper: "clone",
cursor: "move"
});
DraggableAnswer.trash.droppable({
accept: ".exercise-draggable-answer > li",
hoverClass: "ui-state-active",
drop: function (e, ui) {
DraggableAnswer.deleteItem(ui.draggable, $(this));
}
});
DraggableAnswer.gallery.droppable({
drop: function (e, ui) {
DraggableAnswer.recycleItem(ui.draggable, $(this));
}
});
}
};
$(document).on('ready', function () {
DraggableAnswer.init(
$(".exercise-draggable-answer"),
$(".droppable")
);
});
</script>
Loading…
Cancel
Save