Updating from mine branch

skala
Julio Montoya 12 years ago
parent 335f1417cc
commit b6046ae717
  1. 6
      main/exercice/exercice.php
  2. 70
      main/exercice/exercise.class.php
  3. 4
      main/exercice/exercise_admin.php
  4. 43
      main/exercice/exercise_reminder.php
  5. 13
      main/exercice/exercise_result.php
  6. 45
      main/exercice/exercise_submit.php
  7. 2
      main/exercice/freeanswer.class.php
  8. 9
      main/exercice/live_stats.php
  9. 2
      main/exercice/media.php
  10. 2
      main/exercice/multiple_answer.class.php
  11. 17
      main/exercice/overview.php
  12. 16
      main/exercice/question.class.php
  13. 4
      main/exercice/question_list_pagination_admin.inc.php
  14. 5
      main/exercice/unique_answer.class.php

@ -645,7 +645,7 @@ if (!empty($exercise_list)) {
$actions .='<a href="exercise_report.php?'.api_get_cidreq().'&exerciseId='.$my_exercise_id.'">'.Display :: return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>';
//Export
$actions .= Display::url(Display::return_icon('cd.gif', get_lang('CopyExercise')), '', array('onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToCopy'), ENT_QUOTES, $charset))." ".addslashes($row['title'])."?"."')) return false;", 'href' => 'exercice.php?'.api_get_cidreq().'&choice=copy_exercise&sec_token='.$token.'&exerciseId='.$my_exercise_id));
$actions .= Display::url(Display::return_icon('cd.gif', get_lang('CopyExercise')), '', array('onclick' => "javascript:if(!confirm('".addslashes(get_lang('AreYouSureToCopy'))." ".addslashes($row['title'])."?"."')) return false;", 'href' => 'exercice.php?'.api_get_cidreq().'&choice=copy_exercise&sec_token='.$token.'&exerciseId='.$my_exercise_id));
if ($autolaunch_setting_on) {
$icon = Display::return_icon('launch.png', get_lang('AutoLaunch'));
@ -680,13 +680,13 @@ if (!empty($exercise_list)) {
// not session
$actions = Display::return_icon('edit_na.png', get_lang('ExerciseEditionNotAvailableInSession'));
$actions .='<a href="exercise_report.php?'.api_get_cidreq().'&exerciseId='.$my_exercise_id.'">'.Display :: return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>';
$actions .= Display::url(Display::return_icon('cd.gif', get_lang('CopyExercise')), '', array('onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToCopy'), ENT_QUOTES, $charset))." ".addslashes($row['title'])."?"."')) return false;", 'href' => 'exercice.php?'.api_get_cidreq().'&choice=copy_exercise&sec_token='.$token.'&exerciseId='.$my_exercise_id));
$actions .= Display::url(Display::return_icon('cd.gif', get_lang('CopyExercise')), '', array('onclick' => "javascript:if(!confirm('".addslashes(get_lang('AreYouSureToCopy'))." ".addslashes($row['title'])."?"."')) return false;", 'href' => 'exercice.php?'.api_get_cidreq().'&choice=copy_exercise&sec_token='.$token.'&exerciseId='.$my_exercise_id));
}
//Delete
if ($session_id == $row['session_id']) {
if ($locked == false) {
$actions .= Display::url(Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL), '', array('onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToDelete'), ENT_QUOTES, $charset))." ".addslashes($row['title'])."?"."')) return false;", 'href' => 'exercice.php?'.api_get_cidreq().'&choice=delete&sec_token='.$token.'&exerciseId='.$my_exercise_id));
$actions .= Display::url(Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL), '', array('onclick' => "javascript:if(!confirm('".addslashes(get_lang('AreYouSureToDelete'))." ".addslashes($row['title'])."?"."')) return false;", 'href' => 'exercice.php?'.api_get_cidreq().'&choice=delete&sec_token='.$token.'&exerciseId='.$my_exercise_id));
} else {
$actions .= Display::return_icon('delete_na.png', get_lang('ResourceLockedByGradebook'), '', ICON_SIZE_SMALL);
}

@ -539,6 +539,7 @@ class Exercise
* @param int $sidx
* @param string $sord
* @param array $where_condition
* @param array $extraFields
*/
public function getQuestionListPagination($start, $limit, $sidx, $sord, $where_condition = array(), $extraFields = array())
{
@ -584,6 +585,7 @@ class Exercise
$extraFieldValue = new ExtraFieldValue('question');
}
while ($question = Database::fetch_array($result, 'ASSOC')) {
/** @var Question $objQuestionTmp */
$objQuestionTmp = Question::read($question['iid']);
$category_labels = Testcategory::return_category_labels($objQuestionTmp->category_list, $category_list);
@ -2743,15 +2745,19 @@ class Exercise
$html .= '<br />';
} else {
// User
$showEndWarning = 0;
if (api_is_allowed_to_session_edit()) {
if ($this->type == ALL_ON_ONE_PAGE || $nbrQuestions == $questionNum) {
if ($this->review_answers) {
$label = get_lang('ReviewQuestions');
$class = 'btn btn-success';
//$label = get_lang('ReviewQuestions');
//$class = 'btn btn-success';
$label = get_lang('EndTest');
$class = 'btn btn-warning';
} else {
$label = get_lang('EndTest');
$class = 'btn btn-warning';
}
$showEndWarning = 1;
} else {
$label = get_lang('NextQuestion');
$class = 'btn btn-primary';
@ -2768,7 +2774,7 @@ class Exercise
$questions_in_media = "['".implode("','", $questions_in_media)."']";
$all_button .= '&nbsp;<a href="javascript://" class="'.$class.'" onclick="save_question_list('.$questions_in_media.'); ">'.$label.'</a>';
} else {
$all_button .= '&nbsp;<a href="javascript://" class="'.$class.'" onclick="save_now('.$question_id.'); ">'.$label.'</a>';
$all_button .= '&nbsp;<a href="javascript://" class="'.$class.'" onclick="save_now('.$question_id.', null, true, '.$showEndWarning.'); ">'.$label.'</a>';
}
$all_button .= '<span id="save_for_now_'.$question_id.'" class="exercise_save_mini_message"></span>&nbsp;';
$html .= $all_button;
@ -2849,7 +2855,7 @@ class Exercise
if ($('#exercise_form').length) {
$('#exercise_form').submit();
} else {
// In reminder
// In reminder.
final_submit();
}
}
@ -4643,7 +4649,6 @@ class Exercise
return false;
}
//if (0) {
if (!empty($this->emailNotificationTemplate)) {
$twig = new \Twig_Environment(new \Twig_Loader_String());
$twig->addFilter('var_dump', new Twig_Filter_Function('var_dump'));
@ -5471,6 +5476,57 @@ class Exercise
return $html;
}
public function returnWarningJs($url)
{
$condition = "
var dialog = $('#dialog-confirm');
saveNow(dialog.data('question_id'), dialog.data('url_extra'), dialog.data('redirect'));
$(this).dialog('close');
";
if (!empty($url)) {
$condition = 'window.location = "'.$url.'&" + lp_data;';
}
return '<script>
$(function() {
$("#dialog-confirm").dialog({
autoOpen: false,
resizable: false,
height:200,
width:550,
modal: true,
buttons: {
"cancel": {
click: function() {
$(this).dialog("close");
},
text : "'.get_lang("NoIWantToTurnBack").'",
class : "btn btn-danger"
},
"ok": {
click : function() {
'.$condition.'
},
text: "'.get_lang("YesImSure").'",
class : "btn btn-success"
}
}
});
});
</script>';
}
function returnWarningHtml()
{
return '<div id="dialog-confirm" title="'.get_lang('Exercise').'" style="display:none">
<p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>
'.get_lang('IfYouContinueYourAnswerWillBeSavedAnyChangeWillBeNotAllowed').'
</p>
</div>';
}
/**
* Get question list (including question ids of the media)
* @return int
@ -6211,7 +6267,7 @@ class Exercise
$exercise_actions .= $this->show_button($questionId, $current_question, null, $remindList);
break;
case ALL_ON_ONE_PAGE:
$button = '<a href="javascript://" class="btn" onclick="save_now(\''.$questionId.'\'); ">'.get_lang('SaveForNow').'</a>';
$button = '<a href="javascript://" class="btn" onclick="save_now(\''.$questionId.'\', null, true, 1); ">'.get_lang('SaveForNow').'</a>';
$button .= '<span id="save_for_now_'.$questionId.'" class="exercise_save_mini_message"></span>&nbsp;';
$exercise_actions .= Display::div($button, array('class'=>'exercise_save_now_button'));
break;
@ -6220,7 +6276,7 @@ class Exercise
if (!empty($questions_in_media)) {
$count_of_questions_inside_media = count($questions_in_media);
if ($count_of_questions_inside_media > 1) {
$button = '<a href="javascript://" class="btn" onclick="save_now(\''.$questionId.'\', false, false); ">'.get_lang('SaveForNow').'</a>';
$button = '<a href="javascript://" class="btn" onclick="save_now(\''.$questionId.'\', false, false, 0); ">'.get_lang('SaveForNow').'</a>';
$button .= '<span id="save_for_now_'.$questionId.'" class="exercise_save_mini_message"></span>&nbsp;';
$exercise_actions = Display::div($button, array('class'=>'exercise_save_now_button'));
}

@ -101,10 +101,10 @@ $htmlHeadXtra[] = '<script>
var my_display = document.getElementById(\'HiddenFCKexerciseDescription\').style.display;
if(my_display== \'none\' || my_display == \'\') {
document.getElementById(\'HiddenFCKexerciseDescription\').style.display = \'block\';
document.getElementById(\'media_icon\').innerHTML=\' '.Display::return_icon('media-question.png').' '.addslashes(api_htmlentities(get_lang('ExerciseDescription'))).'\';
document.getElementById(\'media_icon\').innerHTML=\' '.Display::return_icon('media-question.png').' '.addslashes(get_lang('ExerciseDescription')).'\';
} else {
document.getElementById(\'HiddenFCKexerciseDescription\').style.display = \'none\';
document.getElementById(\'media_icon\').innerHTML=\' '.Display::return_icon('media-question.png').' '.addslashes(api_htmlentities(get_lang('ExerciseDescription'))).'\';
document.getElementById(\'media_icon\').innerHTML=\' '.Display::return_icon('media-question.png').' '.addslashes(get_lang('ExerciseDescription')).'\';
}
}

@ -42,7 +42,7 @@ if ( empty ($objExercise)) { $objExercise = $_SESSION['objExercise'];}
if (!$objExercise) {
//Redirect to the exercise overview
//Check if the exe_id exists
header("Location: overview.php?exerciseId=".$exerciseId);
header("Location: ".$urlMainExercise."overview.php?exerciseId=".$exerciseId."&".api_get_cidreq());
exit;
}
@ -54,7 +54,7 @@ if ($objExercise->expired_time != 0 && !empty($clock_expired_time)) {
}
if ($time_control) {
// Get time left for exipiring time
// Get time left for expiring time
$time_left = api_strtotime($clock_expired_time,'UTC') - time();
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/stylesheet/jquery.epiclock.css');
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/renderers/minute/epiclock.minute.css');
@ -106,35 +106,9 @@ if ($time_control) {
echo Display::div('', array('id' => 'message'));
$urlMainExercise = api_get_path(WEB_CODE_PATH).'exercice/';
echo $objExercise->returnWarningJs($urlMainExercise.'exercise_result.php?origin='.$origin.'&exe_id='.$exe_id);
echo '<script>
$(function() {
$( "#dialog-confirm" ).dialog({
autoOpen: false,
resizable: false,
height:200,
width:550,
modal: true,
buttons: {
"cancel": {
click: function() {
$( this ).dialog( "close" );
},
text : "'.get_lang("NoIWantToTurnBack").'",
class : "btn btn-danger"
},
"ok": {
click : function() {
// Normal inputs
//$( this ).dialog( "close" );
window.location = "'.$urlMainExercise.'exercise_result.php?origin='.$origin.'&exe_id='.$exe_id.'&" + lp_data;
},
text: "'.get_lang("YesImSure").'",
class : "btn btn-success"
}
}
});
});
lp_data = $.param({"learnpath_id": '.$learnpath_id.', "learnpath_item_id" : '.$learnpath_item_id.', "learnpath_item_view_id": '.$learnpath_item_view_id.'});
@ -272,11 +246,6 @@ foreach ($question_list as $questionId) {
$table .= "</div>";
$table .= "</div>";
/*echo Display::label(get_lang('QuestionWithNoAnswer'), 'warning');
echo '<hr>';
echo '<div class="clear"></div><br />';
echo Display::div($table, array('class' => 'span12'));
*/
$exercise_actions = Display::url(get_lang('EndTest'), 'javascript://', array('onclick' => 'final_submit();', 'class' => 'btn btn-warning'));
//$exercise_actions .= '&nbsp;'.Display::url(get_lang('ReviewQuestions'), 'javascript://', array('onclick' => 'review_questions();', 'class' => 'btn btn-success'));
@ -303,11 +272,7 @@ echo $objExercise->getProgressPagination(
echo Display::div('', array('class' => 'clear'));
echo Display::div($exercise_actions, array('class' => 'form-actions'));
echo '<div id="dialog-confirm" title="'.get_lang('Exercise').'" style="display:none">
<p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>
'.get_lang('IfYouContinueYourAnswerWillBeSavedAnyChangeWillBeNotAllowed').'
</p>
</div>';
echo $objExercise->returnWarningHtml();
if ($origin != 'learnpath') {
//we are not in learnpath tool

@ -62,14 +62,21 @@ $exe_id = isset($_REQUEST['exe_id']) ? intval($_REQUEST['exe_id']) : 0;
if (empty($objExercise)) {
// Redirect to the exercise overview
// Check if the exe_id exists
$objExercise = new Exercise();
$exercise_stat_info = $objExercise->getStatTrackExerciseInfoByExeId($exe_id);
if (!empty($exercise_stat_info) && isset($exercise_stat_info['exe_exo_id'])) {
if ($exercise_stat_info['status'] == 'incomplete') {
$objExercise->read($exercise_stat_info['exe_exo_id']);
} else {
header("Location: overview.php?exerciseId=".$exercise_stat_info['exe_exo_id']);
exit;
}
} else {
api_not_allowed(true);
}
}
$gradebook = '';
if (isset($_SESSION['gradebook'])) {
@ -129,7 +136,7 @@ if ($objExercise->selectAttempts() > 0) {
if ($attempt_count >= $objExercise->selectAttempts()) {
Display :: display_warning_message(sprintf(get_lang('ReachedMaxAttempts'), $objExercise->selectTitle(), $objExercise->selectAttempts()), false);
if ($origin != 'learnpath') {
//we are not in learnpath tool
// We are not in learnpath tool
Display::display_footer();
}
exit;
@ -149,7 +156,7 @@ if (isset($session_control_key) && !ExerciseLib::exercise_time_control_is_valid(
Database::query($sql_fraud);
}
//Unset session for clock time
// Unset session for clock time.
ExerciseLib::exercise_time_control_delete($objExercise->id, $learnpath_id, $learnpath_item_id);
ExerciseLib::delete_chat_exercise_session($exe_id);
@ -177,7 +184,7 @@ if ($origin != 'learnpath') {
Session::erase('exe_id');
Session::erase('categoryList');
}
//record the results in the learning path, using the SCORM interface (API)
// Record the results in the learning path, using the SCORM interface (API)
echo "<script>window.parent.API.void_save_asset('$total_score', '$total_weight', 0, 'completed');</script>";
echo '<script type="text/javascript">'.$href.'</script>';
echo '</body></html>';

@ -256,14 +256,22 @@ var connectorType = "Straight";
sourceDestinationArray[count+1] = sourceEndPoint;
count++;
jsPlumb.addEndpoint(windowId, { anchor:[ "RightMiddle","RightMiddle","RightMiddle","RightMiddle" ] }, sourceEndPoint);
jsPlumb.addEndpoint(
windowId,
{ anchor:[ "RightMiddle","RightMiddle","RightMiddle","RightMiddle" ] },
sourceEndPoint
);
var destinationCount = 0;
$(windowQuestion).each(function( index ) {
var windowDestinationId = $(this).attr("id");
destinationEndPoint.scope = scope;
destinationEndPoint.paintStyle.fillStyle = colorArrayDestination[destinationCount].getHex();
destinationCount++;
jsPlumb.addEndpoint(windowDestinationId+"_answer", { anchor:[ "LeftMiddle","LeftMiddle","LeftMiddle","LeftMiddle" ] }, destinationEndPoint);
jsPlumb.addEndpoint(
windowDestinationId+"_answer",
{ anchor:[ "LeftMiddle","LeftMiddle","LeftMiddle","LeftMiddle" ] },
destinationEndPoint
);
});
});
//var divsWithWindowClass = jsPlumb.CurrentLibrary.getSelector("#"+questionId+" .window");
@ -395,6 +403,17 @@ if ($objExercise->review_answers) {
}
}
$exeId = isset($_GET['exe_id']) ? $_GET['exe_id'] : null;
// Blocking access if exe_id was already treated
if (!empty($exeId)) {
$attemptInfo = $objExercise->getStatTrackExerciseInfoByExeId($exeId);
if (!empty($attemptInfo) && $attemptInfo['status'] == '') {
header("Location: ".$urlMainExercise."overview.php?exerciseId=".$exerciseId."&".api_get_cidreq());
exit;
}
}
$current_timestamp = time();
$my_remind_list = array();
@ -832,7 +851,8 @@ if ($question_count != 0) {
}
}
if ($objExercise->review_answers) {
header('Location: '.$urlMainExercise.'exercise_reminder.php?'.$params);
//header('Location: '.$urlMainExercise.'exercise_reminder.php?'.$params);
header("Location: ".$urlMainExercise."exercise_result.php?".api_get_cidreq()."&exe_id=$exe_id&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id");
exit;
} else {
header("Location: ".$urlMainExercise."exercise_result.php?".api_get_cidreq()."&exe_id=$exe_id&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id");
@ -1015,7 +1035,7 @@ if ($reminder == 2) {
}
} else {
if ($objExercise->review_answers) {
if ($debug) { error_log('. redirecting to exercise_reminder.php '); }
if ($debug) { error_log('Redirecting to exercise_reminder.php '); }
header("Location: ".$urlMainExercise."exercise_reminder.php?$params");
exit;
}
@ -1069,6 +1089,7 @@ if (!empty($error)) {
$onsubmit = " onsubmit=\"return validateFlashVar('".$number_of_hotspot_questions."', '" .get_lang('HotspotValidateError1')."', '".get_lang('HotspotValidateError2')."');\"";
}
echo $objExercise->returnWarningJs(null);
echo '<script>
$(function() {
$(".main_question").mouseover(function() {
@ -1111,11 +1132,23 @@ if (!empty($error)) {
window.location = url;
}
function save_now(question_id, url_extra, redirect) {
function save_now(question_id, url_extra, redirect, showWarning) {
if (redirect == undefined) {
redirect = true;
}
if (showWarning == 1) {
$("#dialog-confirm").data("question_id", question_id);
$("#dialog-confirm").data("url_extra", url_extra);
$("#dialog-confirm").data("redirect", redirect);
$("#dialog-confirm").dialog("open");
} else {
saveNow(question_id, url_extra, redirect);
}
}
function saveNow(question_id, url_extra, redirect)
{
//1. Normal choice inputs
var my_choice = $(\'*[name*="choice[\'+question_id+\']"]\').serialize();
@ -1159,6 +1192,7 @@ if (!empty($error)) {
" ".get_lang('SelectAnAnswerToContinue')).'");
} else if (return_value == "one_per_page") {
var url = "";
// Redirect to reminder
if ('.$reminder.' == 1) {
url = "'.$urlMainExercise.'exercise_reminder.php?'.$params.'&num='.$current_question.'";
} else if ('.$reminder.' == 2 ) {
@ -1265,6 +1299,7 @@ if (!empty($error)) {
<input type="hidden" name="learnpath_item_view_id" value="'.$learnpath_item_view_id . '" />';
$objExercise->renderQuestionList($questionList, $current_question, $exerciseResult, $attempt_list, $remind_list);
echo '</form>';
echo $objExercise->returnWarningHtml();
}
if ($origin != 'learnpath') {

@ -49,9 +49,11 @@ class FreeAnswer extends Question
}
}
if ($form->isFrozen() == false) {
// Setting the save button here and not in the question class.php.
$form->addElement('style_submit_button', 'submitQuestion', $this->submitText, 'class="'.$this->submitClass.'"');
}
}
/**
* abstract function which creates the form to create / edit the answers of the question

@ -52,15 +52,6 @@ $column_model = array(
$extra_params['autowidth'] = 'true';
//height auto
$extra_params['height'] = 'auto';
/*
//With this function we can add actions to the jgrid (edit, delete, etc)
$action_links = 'function action_formatter(cellvalue, options, rowObject) {
return \'<a href="?action=edit&id=\'+options.rowId+\'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'.
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="?action=copy&id=\'+options.rowId+\'">'.Display::return_icon('copy.png',get_lang('Copy'),'',ICON_SIZE_SMALL).'</a>'.
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="?action=delete&id=\'+options.rowId+\'">'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'.
'\';
}';
*/
?>
<script>

@ -92,7 +92,7 @@ $extra_params['height'] = 'auto';
//With this function we can add actions to the jgrid (edit, delete, etc)
$action_links = 'function action_formatter(cellvalue, options, rowObject) {
return \'<a href="?action=edit&id=\'+options.rowId+\'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'.
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="?sec_token='.$token.'&action=delete&id=\'+options.rowId+\'">'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'.
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(get_lang("ConfirmYourChoice"))."\'".')) return false;" href="?sec_token='.$token.'&action=delete&id=\'+options.rowId+\'">'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'.
'\';
}';
?>

@ -182,6 +182,7 @@ class MultipleAnswer extends Question
$form->add_multiple_required_rule($boxes_names, get_lang('ChooseAtLeastOneCheckbox'), 'multiple_required');
$navigator_info = api_get_navigator();
if ($form->isFrozen() == false) {
if ($obj_ex->edit_exercise_in_lp == true) {
//ie6 fix
if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') {
@ -203,6 +204,7 @@ class MultipleAnswer extends Question
$renderer->setElementTemplate('{element}&nbsp;', 'lessAnswers');
$renderer->setElementTemplate('{element}&nbsp;', 'submitQuestion');
$renderer->setElementTemplate('{element}&nbsp;', 'moreAnswers');
}
$form->addElement('html', '</div></div>');
$defaults['correct'] = $correct;

@ -52,6 +52,10 @@ if ($objExercise->expired_time != 0 && !empty($clock_expired_time)) {
$time_control = true;
}
$urlMainExercise = api_get_path(WEB_CODE_PATH).'exercice/';
$exercise_stat_info = $objExercise->getStatTrackExerciseInfo($learnpath_id, $learnpath_item_id, 0);
if ($time_control) {
// Get time left for expiring time
$time_left = api_strtotime($clock_expired_time, 'UTC') - time();
@ -62,6 +66,15 @@ if ($time_control) {
$htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.epiclock.min.js');
$htmlHeadXtra[] = api_get_js('epiclock/renderers/minute/epiclock.minute.js');
$htmlHeadXtra[] = $objExercise->show_time_control_js($time_left);
$htmlHeadXtra[] = '<script>
function final_submit() {
var lp_data = $.param({"learnpath_id": '.intval($learnpath_id).', "learnpath_item_id" : '.intval($learnpath_item_id).', "learnpath_item_view_id": '.intval($learnpath_item_view_id).'});
var url = "'.$urlMainExercise.'exercise_result.php?'.api_get_cidreq().'&origin='.$origin.'&exe_id='.$exercise_stat_info['exe_id'].'&";
window.location = url ;
}
</script>';
}
if ($origin != 'learnpath') {
@ -93,7 +106,6 @@ if (isset($_GET['preview'])) {
$extra_params = '&preview=1';
}
$exercise_stat_info = $objExercise->getStatTrackExerciseInfo($learnpath_id, $learnpath_item_id, 0);
$attempt_list = null;
if (isset($exercise_stat_info['exe_id'])) {
$attempt_list = getAllExerciseEventByExeId($exercise_stat_info['exe_id']);
@ -159,7 +171,8 @@ if (!empty($attempts)) {
if ($attempt_result['attempt_revised'] == 0) {
$teacher_revised = Display::label(get_lang('NotValidated'), 'info');
}
$row = array('count' => $i,
$row = array(
'count' => $i,
'date' => api_convert_and_format_date($attempt_result['start_date'], DATE_TIME_FORMAT_LONG)
);
$attempt_link .= "&nbsp;&nbsp;&nbsp;".$teacher_revised;

@ -2264,6 +2264,10 @@ abstract class Question
//var_dump($exerciseId);
// Including actions
foreach ($questions as &$question) {
$type = self::get_question_type($question['type']);
$question['type'] = get_lang($type[1]);
$question['question_question_type'] = get_lang($type[1]);
if (empty($exerciseId)) {
// View.
$actions = Display::url(
@ -2309,7 +2313,10 @@ abstract class Question
// Copy.
$actions .= Display::url(
$copyIcon,
$app['url_generator']->generate(
'javascript:void(0);',
array(
'onclick' => 'ajaxAction(this);',
'data-url' => $app['url_generator']->generate(
'exercise_copy_question',
array(
'cidReq' => api_get_course_id(),
@ -2318,12 +2325,16 @@ abstract class Question
'exerciseId' => $exerciseId
)
)
)
);
// Reuse.
$actions .= Display::url(
$reuseIcon,
$app['url_generator']->generate(
'javascript:void(0);',
array(
'onclick' => 'ajaxAction(this);',
'data-url' => $app['url_generator']->generate(
'exercise_reuse_question',
array(
'cidReq' => api_get_course_id(),
@ -2331,6 +2342,7 @@ abstract class Question
'questionId' => $question['iid'],
'exerciseId' => $exerciseId
)
),
)
);
}

@ -114,12 +114,12 @@ $courseCode = api_get_course_id();
$delete_link = null;
if ($objExercise->edit_exercise_in_lp == true) {
$delete_link = '&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."\'".')) return false;" href="?exerciseId='.$exerciseId.'&cidReq='.$courseCode.'&sec_token='.$token.'&deleteQuestion=\'+options.rowId+\'">'.Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
$delete_link = '&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(get_lang("ConfirmYourChoice"))."\'".')) return false;" href="?exerciseId='.$exerciseId.'&cidReq='.$courseCode.'&sec_token='.$token.'&deleteQuestion=\'+options.rowId+\'">'.Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
}
//With this function we can add actions to the jgrid (edit, delete, etc)
$action_links = 'function action_formatter(cellvalue, options, rowObject) {
return \'<a href="?exerciseId='.$exerciseId.'&myid=1&cidReq='.$courseCode.'&editQuestion=\'+options.rowId+\'">'.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>'.
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."\'".')) return false;" href="?cidReq='.$courseCode.'&sec_token='.$token.'&clone_question=\'+options.rowId+\'">'.Display::return_icon('cd.gif', get_lang('Copy'), '',ICON_SIZE_SMALL).'</a>'.
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(get_lang("ConfirmYourChoice"))."\'".')) return false;" href="?cidReq='.$courseCode.'&sec_token='.$token.'&clone_question=\'+options.rowId+\'">'.Display::return_icon('cd.gif', get_lang('Copy'), '',ICON_SIZE_SMALL).'</a>'.
$delete_link.'\';
}';
?>

@ -294,6 +294,7 @@ class UniqueAnswer extends Question
// ie6 fix.
if ($form->isFrozen() == false) {
if ($obj_ex->edit_exercise_in_lp == true) {
if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') {
$form->addElement('submit', 'lessAnswers', get_lang('LessAnswer'), 'class="btn minus"');
@ -309,6 +310,7 @@ class UniqueAnswer extends Question
$renderer->setElementTemplate('{element}&nbsp;', 'submitQuestion');
$renderer->setElementTemplate('{element}&nbsp;', 'lessAnswers');
$renderer->setElementTemplate('{element}&nbsp;', 'moreAnswers');
}
$form->addElement('html', '</div></div>');
@ -469,8 +471,9 @@ class UniqueAnswer extends Question
$score = filter_var($score, FILTER_SANITIZE_NUMBER_FLOAT);
$correct = filter_var($correct, FILTER_SANITIZE_NUMBER_INT);
if (empty($question_id) or empty($score) or empty($correct))
if (empty($question_id) or empty($score) or empty($correct)) {
return false;
}
// Get the max position
$sql = "SELECT max(position) as max_position FROM $tbl_quiz_answer WHERE question_id = $question_id";

Loading…
Cancel
Save