skala
Julio Montoya 13 years ago
commit 361d1191a3
  1. 31
      main/css/academica/default.css
  2. 31
      main/css/baby_orange/default.css
  3. 23
      main/css/base_chamilo.css
  4. 8
      main/css/chamilo/default.css
  5. 19
      main/document/document.php
  6. 5
      main/exercice/admin.php
  7. 24
      main/exercice/answer.class.php
  8. 8
      main/exercice/exercise.class.php
  9. 2
      main/exercice/exercise_show.php
  10. 2
      main/exercice/exercise_submit.php
  11. 407
      main/exercice/exercise_submit_modal.php
  12. 2
      main/exercice/hotspot_admin.inc.php
  13. 3
      main/exercice/multiple_answer.class.php
  14. 10
      main/exercice/question_admin.inc.php
  15. 4
      main/exercice/testcategory.class.php
  16. 101
      main/exercice/unique_answer.class.php
  17. 14
      main/gradebook/gradebook_display_certificate.php
  18. 1
      main/inc/lib/autoload.class.php
  19. 27
      main/inc/lib/certificate.lib.php
  20. 12
      main/inc/lib/document.lib.php
  21. 4
      main/inc/lib/pear/HTML/QuickForm.php
  22. 1
      main/template/default/mail_editor/email_link.js.tpl

@ -699,21 +699,7 @@ div.lp_resource_elements {
.exercice_form {
width: 300px;
}
#validationButton {
text-decoration: none;
margin: 5px;
border:1px solid #999999;
background:#F0F0F0;
padding: 3px;
padding-left:10px;
padding-right:10px;
font-weight:bold;
color:#666;
}
.exercise_scenario_label {
}
.exercise_scenario_element {
}
span.checkbox {
width: 19px;
height: 25px;
@ -1282,21 +1268,6 @@ ul#navigation .help a{
.exercice_form {
width: 300px;
}
#validationButton {
text-decoration: none;
margin: 5px;
/*border:1px solid #999999;*/
/*background:#F0F0F0; */
padding: 3px;
padding-left:10px;
padding-right:10px;
font-weight:bold;
color:#666;
}
.exercise_scenario_label {
}
.exercise_scenario_element {
}
span.checkbox {
width: 19px;
height: 25px;

@ -687,21 +687,7 @@ div.lp_resource_elements {
.exercice_form {
width: 300px;
}
#validationButton {
text-decoration: none;
margin: 5px;
border:1px solid #999999;
background:#F0F0F0;
padding: 3px;
padding-left:10px;
padding-right:10px;
font-weight:bold;
color:#666;
}
.exercise_scenario_label {
}
.exercise_scenario_element {
}
span.checkbox {
width: 19px;
height: 25px;
@ -1258,21 +1244,6 @@ ul#navigation .help a{
.exercice_form {
width: 300px;
}
#validationButton {
text-decoration: none;
margin: 5px;
/*border:1px solid #999999;*/
/*background:#F0F0F0; */
padding: 3px;
padding-left:10px;
padding-right:10px;
font-weight:bold;
color:#666;
}
.exercise_scenario_label {
}
.exercise_scenario_element {
}
span.checkbox {
width: 19px;
height: 25px;

@ -1256,22 +1256,7 @@ padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0p
.exercice_form {
width: 300px;
}
#validationButton {
text-decoration: none;
margin: 5px;
/*border:1px solid #999999;*/
/*background:#F0F0F0; */
padding: 3px;
padding-left:10px;
padding-right:10px;
font-weight:bold;
color:#666;
}
.exercise_scenario_label {
}
.exercise_scenario_element {
}
span.checkbox {
width: 19px;
height: 25px;
@ -1289,14 +1274,6 @@ span.radio {
float: left;
}
#exercise_close_link {
padding-left: 20px;
}
#exercise_close_link:hover {
padding-left: 20px;
}
.icon_image_content {
width:70px;
cursor:hand;

@ -118,14 +118,6 @@ footer {
background:transparent url('images/textologo.jpg') no-repeat;
}
#exercise_close_link {
background: url(images/close.gif) no-repeat;
}
#exercise_close_link:hover {
background: url(images/close_highlight.gif) no-repeat;
}
/*including "login" image*/
button.login {
background-image:url(images/bg-button.gif);

@ -324,6 +324,18 @@ if (isset($_GET['curdirpath']) && $_GET['curdirpath'] == '/certificates' && isse
// Generate document HTML
$content_html = DocumentManager::replace_user_info_into_html(api_get_user_id(), api_get_course_id(), true);
$filename = 'certificate_preview/'.api_get_unique_id().'.png';
$qr_code_filename = api_get_path(SYS_ARCHIVE_PATH).$filename;
$temp_folder = api_get_path(SYS_ARCHIVE_PATH).'certificate_preview';
if (!is_dir($temp_folder)) mkdir($temp_folder, api_get_permissions_for_new_directories());
$qr_code_web_filename = api_get_path(WEB_ARCHIVE_PATH).$filename;
$certificate = new Certificate();
$text = $certificate->parse_certificate_variables($content_html['variables']);
$result = $certificate->generate_qr($text, $qr_code_filename);
$new_content_html = $content_html['content'];
$path_image = api_get_path(WEB_COURSE_PATH) . api_get_course_path() . '/document/images/gallery';
$new_content_html = str_replace('../images/gallery', $path_image, $new_content_html);
@ -331,9 +343,14 @@ if (isset($_GET['curdirpath']) && $_GET['curdirpath'] == '/certificates' && isse
$path_image_in_default_course = api_get_path(WEB_CODE_PATH) . 'default_course_document';
$new_content_html = str_replace('/main/default_course_document', $path_image_in_default_course, $new_content_html);
$new_content_html = str_replace('/main/img/', api_get_path(WEB_IMG_PATH), $new_content_html);
Display::display_reduced_header();
echo '<style>body {background:none;}</style><style media="print" type="text/css"> #print_div { visibility:hidden; } </style>';
echo '<a href="javascript:window.print();" style="float:right; padding:4px;" id="print_div"><img src="../img/printmgr.gif" alt="' . get_lang('Print') . '" /> ' . get_lang('Print') . '</a>';
echo '<a href="javascript:window.print();" style="float:right; padding:4px;" id="print_div"><img src="../img/printmgr.gif" alt="'.get_lang('Print').'"/>'.get_lang('Print').'</a>';
if (is_file($qr_code_filename) && is_readable($qr_code_filename)) {
$new_content_html = str_replace('((certificate_barcode))', Display::img($qr_code_web_filename), $new_content_html);
}
print_r($new_content_html);
exit;
}

@ -135,7 +135,7 @@ $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
$picturePath = $documentPath.'/images';
// audio path
$audioPath=$documentPath.'/audio';
$audioPath = $documentPath.'/audio';
// the 5 types of answers
$aType = array(get_lang('UniqueSelect'),get_lang('MultipleSelect'),get_lang('FillBlanks'),get_lang('Matching'),get_lang('FreeAnswer'));
@ -152,7 +152,6 @@ if ($_GET['action'] == 'exportqti2' && !empty($_GET['questionId'])) {
require_once 'export/qti2/qti2_export.php';
$export = export_question($_GET['questionId'],true);
$qid = (int)$_GET['questionId'];
require_once(api_get_path(LIBRARY_PATH).'pclzip/pclzip.lib.php');
$archive_path = api_get_path(SYS_ARCHIVE_PATH);
$temp_dir_short = uniqid();
$temp_zip_dir = $archive_path."/".$temp_dir_short;
@ -217,8 +216,6 @@ if ($editQuestion || $newQuestion || $modifyQuestion || $modifyAnswers) {
}
}
// if cancelling an exercise
if ($cancelExercise) {
// existing exercise

@ -420,7 +420,7 @@ class Answer {
* @param coordinates Coordinates for hotspot exercises (optional)
* @param integer Type for hotspot exercises (optional)
*/
function createAnswer($answer,$correct,$comment,$weighting,$position,$new_hotspot_coordinates = NULL, $new_hotspot_type = NULL,$destination='') {
function createAnswer($answer,$correct,$comment,$weighting,$position,$new_hotspot_coordinates = null, $new_hotspot_type = null, $destination='') {
$this->new_nbrAnswers++;
$id=$this->new_nbrAnswers;
$this->new_answer[$id]=$answer;
@ -430,7 +430,7 @@ class Answer {
$this->new_position[$id]=$position;
$this->new_hotspot_coordinates[$id]=$new_hotspot_coordinates;
$this->new_hotspot_type[$id]=$new_hotspot_type;
$this->new_destination[$id]=$destination;
$this->new_destination[$id] = $destination;
}
/**
@ -446,14 +446,14 @@ class Answer {
$TBL_REPONSES = Database :: get_course_table(TABLE_QUIZ_ANSWER);
$questionId=$this->questionId;
$sql = "UPDATE $TBL_REPONSES SET " .
"answer = '".Database::escape_string($answer)."', " .
"comment = '".Database::escape_string($comment)."', " .
"ponderation = '".Database::escape_string($weighting)."', " .
"position = '".Database::escape_string($position)."', " .
"destination = '".Database::escape_string($destination)."' " .
"WHERE c_id = {$this->course_id} AND id = '".Database::escape_string($position)."' " .
"AND question_id = '".Database::escape_string($questionId)."'";
$sql = "UPDATE $TBL_REPONSES SET
answer = '".Database::escape_string($answer)."',
comment = '".Database::escape_string($comment)."',
ponderation = '".Database::escape_string($weighting)."',
position = '".Database::escape_string($position)."',
destination = '".Database::escape_string($destination)."'
WHERE c_id = {$this->course_id} AND id = '".Database::escape_string($position)."'
AND question_id = '".Database::escape_string($questionId)."'";
Database::query($sql);
}
@ -469,9 +469,10 @@ class Answer {
// removes old answers before inserting of new ones
$sql = "DELETE FROM $TBL_REPONSES WHERE c_id = {$this->course_id} AND question_id = '".($questionId)."'";
Database::query($sql);
$c_id = $this->course['real_id'];
// inserts new answers into data base
$sql = "INSERT INTO $TBL_REPONSES (c_id, id, question_id, answer,correct,comment, ponderation,position,hotspot_coordinates,hotspot_type,destination) VALUES ";
$sql = "INSERT INTO $TBL_REPONSES (c_id, id, question_id, answer, correct, comment, ponderation, position, hotspot_coordinates,hotspot_type, destination) VALUES ";
for ($i=1;$i <= $this->new_nbrAnswers; $i++) {
$answer = Database::escape_string($this->new_answer[$i]);
$correct = Database::escape_string($this->new_correct[$i]);
@ -485,7 +486,6 @@ class Answer {
$sql.="($c_id, '$i','$questionId','$answer','$correct','$comment','$weighting','$position','$hotspot_coordinates','$hotspot_type','$destination'),";
}
$sql = api_substr($sql,0,-1);
Database::query($sql);
// moves $new_* arrays

@ -1588,8 +1588,12 @@ class Exercise {
$all_button = '';
if ($this->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT && $this->type == ONE_PER_PAGE) {
$html .='<a href="exercise_submit_modal.php?learnpath_id='.$safe_lp_id.'&learnpath_item_id='.$safe_lp_item_id.'&learnpath_item_view_id='.$safe_lp_item_view_id.'&origin='.$origin.'&hotspot='.$hotspot_get.'&nbrQuestions='.$nbrQuestions.'&questionnum='.$questionNum.'&exerciseType='.$this->type.'&exerciseId='.$this->id.'&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=480&width=640&modal=true" title="" class="thickbox button" id="validationButton">';
$html .= get_lang('EndTest').'</a>';
$html .='<a href="exercise_submit_modal.php?learnpath_id='.$safe_lp_id.'&learnpath_item_id='.$safe_lp_item_id.'&learnpath_item_view_id='.$safe_lp_item_view_id.'&origin='.$origin.'&hotspot='.$hotspot_get.'&nbrQuestions='.$nbrQuestions.'&num='.$questionNum.'&exerciseType='.$this->type.'&exerciseId='.$this->id.'&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=480&width=640&modal=true" title="" class="thickbox btn">';
if ($questionNum == count($this->questionList)) {
$html .= get_lang('EndTest').'</a>';
} else {
$html .= get_lang('ContinueTest').'</a>';
}
$html .='<br />';
} else {
//User

@ -52,7 +52,7 @@ if ( empty ( $formSent ) ) { $formSent = $_REQUEST['formSent'];
if ( empty ( $exerciseResult ) ) { $exerciseResult = $_SESSION['exerciseResult'];}
if ( empty ( $questionId ) ) { $questionId = $_REQUEST['questionId'];}
if ( empty ( $choice ) ) { $choice = $_REQUEST['choice'];}
if ( empty ( $questionNum ) ) { $questionNum = $_REQUEST['questionNum'];}
if ( empty ( $questionNum ) ) { $questionNum = $_REQUEST['num'];}
if ( empty ( $nbrQuestions ) ) { $nbrQuestions = $_REQUEST['nbrQuestions'];}
if ( empty ( $questionList ) ) { $questionList = $_SESSION['questionList'];}
if ( empty ( $objExercise ) ) { $objExercise = $_SESSION['objExercise'];}

@ -87,7 +87,7 @@ if (empty ($exerciseResultCoordinates)) {
$choice = isset($_REQUEST['choice']) ? $_REQUEST['choice'] : null;
$choice = empty($choice) ? $_REQUEST['choice2'] : null;
$questionNum = isset($_REQUEST['questionNum']) ? intval($_REQUEST['questionNum']) : null;
//From submit modal
$current_question = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : null;
//Error message

@ -10,14 +10,16 @@
use \ChamiloSession as Session;
$language_file=array('exercice');
$language_file = array('exercice');
require_once '../inc/global.inc.php';
api_protect_course_script(false);
require_once api_get_path(LIBRARY_PATH).'geometry.lib.php';
Display::display_reduced_header();
$dbg_local = 0;
require_once 'exercise.class.php';
require_once 'question.class.php';
require_once 'answer.class.php';
@ -47,9 +49,9 @@ $questionList = $_SESSION['questionList'];
$exerciseId = intval($_GET['exerciseId']);
$exerciseType = intval($_GET['exerciseType']);
$questionNum = intval($_GET['questionnum']);
$nbrQuestions = intval($_GET['nbrQuestions']);
$questionNum = intval($_GET['num']);
$nbrQuestions = intval($_GET['nbrQuestions']);
//clean extra session variables
Session::erase('objExerciseExtra'.$exerciseId);
@ -71,9 +73,11 @@ $user_array = substr($user_array,0,-1);
if (isset($_GET['choice'])){
$choice_value = intval($_GET['choice']);
}
// getting the options by js
// Getting the options by js
if (empty($choice_value)) {
echo '<script type="text/javascript">'."
echo "<script>
// this works for only radio buttons
var f= self.parent.window.document.frm_exercise;
var choice_js='';
@ -81,58 +85,49 @@ if (empty($choice_value)) {
var hotspot = new Array();
var hotspotcoord = new Array();
var counter=0;
for( var i = 0; i < f.elements.length; i++ )
{
if (f.elements[i].type=='radio' && f.elements[i].checked)
{
for( var i = 0; i < f.elements.length; i++ ) {
if (f.elements[i].type=='radio' && f.elements[i].checked) {
//alert( f.elements[i].name);
choice_js = f.elements[i].value;
counter ++;
}
if (f.elements[i].type=='hidden' )
{
if (f.elements[i].type=='hidden' ) {
name = f.elements[i].name;
if (name.substr(0,7)=='hotspot')
hotspot.push(f.elements[i].value);
if (name.substr(0,20)=='hotspot_coordinates')
hotspotcoord.push(f.elements[i].value);
//hotspot = f.elements[i].value;
}
}
if (counter==0)
{
if (counter==0) {
choice_js=-1; // this is an error
}
//alert(choice_js);
";
// IMPORTANT
//this is the real redirect function
echo 'window.location.href = "exercise_submit_modal.php?learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&hotspotcoord="+ hotspotcoord + "&hotspot="+ hotspot + "&choice="+ choice_js + "&exerciseId='.$exerciseId.'&questionnum='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'&gradebook='.$gradebook.'";</script>';
echo 'window.location.href = "exercise_submit_modal.php?learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&hotspotcoord="+ hotspotcoord + "&hotspot="+ hotspot + "&choice="+ choice_js + "&exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'&gradebook='.$gradebook.'";</script>';
}
$choice=array();
$choice = array();
$questionid= $questionList[$questionNum];
// $choice_value => value of the user selection
$choice[$questionid]=$choice_value;
$choice[$questionid] = $choice_value;
// initializing
if(!is_array($exerciseResult)) {
$exerciseResult=array();
$exerciseResult = array();
}
// if the user has answered at least one question
if(is_array($choice)) {
if($exerciseType == 1) {
if (is_array($choice)) {
if ($exerciseType == EXERCISE_FEEDBACK_TYPE_DIRECT) {
// $exerciseResult receives the content of the form.
// Each choice of the student is stored into the array $choice
$exerciseResult=$choice;
$exerciseResult = $choice;
} else {
// gets the question ID from $choice. It is the key of the array
list($key)=array_keys($choice);
@ -146,8 +141,8 @@ if(is_array($choice)) {
// the script "exercise_result.php" will take the variable $exerciseResult from the session
Session::write('exerciseResult',$exerciseResult);
Session::write('exerciseResultCoordinates',$exerciseResultCoordinates);
Session::write('exerciseResult', $exerciseResult);
Session::write('exerciseResultCoordinates', $exerciseResultCoordinates);
/*
// if it is the last question (only for a sequential exercise)
@ -162,6 +157,7 @@ if($questionNum >= $nbrQuestions)
// gets the student choice for this question
//print_r($choice); echo "<br>";
// creates a temporary Question object
if (in_array($questionid, $questionList)) {
$objQuestionTmp = Question :: read($questionid);
@ -176,18 +172,21 @@ $objAnswerTmp=new Answer($questionid);
$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
//echo 'answe_type '.$answerType;echo '<br />';
$choice=$exerciseResult[$questionid];
$choice = $exerciseResult[$questionid];
$destination=array();
$comment='';
$next=1;
$_SESSION['hotspot_coord']=array();
$_SESSION['hotspot_dest']=array();
$overlap_color=$missing_color=$excess_color=false;
$organs_at_risk_hit=0;
$_SESSION['hotspot_coord'] = array();
$_SESSION['hotspot_dest'] = array();
$overlap_color = $missing_color = $excess_color=false;
$organs_at_risk_hit = 0;
$wrong_results = false;
$hot_spot_load = false;
if (!empty($choice_value)) {
for($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
$answer = $objAnswerTmp->selectAnswer($answerId);
$answerComment = $objAnswerTmp->selectComment($answerId);
$answerDestination = $objAnswerTmp->selectDestination($answerId);
@ -204,8 +203,8 @@ if (!empty($choice_value)) {
switch($answerType) {
// for unique answer
case UNIQUE_ANSWER :
$studentChoice=($choice_value == $numAnswer)?1:0;
if($studentChoice) {
$studentChoice = ($choice_value == $numAnswer)?1:0;
if ($studentChoice) {
$questionScore +=$answerWeighting;
$totalScore +=$answerWeighting;
$newquestionList[]=$questionid;
@ -213,7 +212,7 @@ if (!empty($choice_value)) {
break;
case HOT_SPOT_DELINEATION :
$studentChoice=$choice[$answerId];
if($studentChoice) {
if ($studentChoice) {
$newquestionList[]=$questionid;
}
if ($answerId===1) {
@ -226,158 +225,158 @@ if (!empty($choice_value)) {
}
if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER) {
//display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect);
//echo $questionScore;
if ($studentChoice) {
$destination=$answerDestination;
$comment=$answerComment;
}
} elseif($answerType == HOT_SPOT_DELINEATION) {
if ($next) {
if ($dbg_local>0) { error_log(__LINE__.' - next',0);}
$hot_spot_load = true; //apparently the script is called twice
$user_answer = $user_array;
$_SESSION['exerciseResultCoordinates'][$questionid]=$user_answer; //needed for exercise_result.php
// we compare only the delineation not the other points
$answer_question = $_SESSION['hotspot_coord'][1];
$answerDestination = $_SESSION['hotspot_dest'][1];
$poly_user = convert_coordinates($user_answer,'/');
$poly_answer = convert_coordinates($answer_question,'|');
$max_coord = poly_get_max($poly_user,$poly_answer);
if (empty($_GET['hotspot'])) { //no user response
$overlap = -2;
} else {
$poly_user_compiled = poly_compile($poly_user,$max_coord);
$poly_answer_compiled = poly_compile($poly_answer,$max_coord);
$poly_results = poly_result($poly_answer_compiled,$poly_user_compiled,$max_coord);
$overlap = $poly_results['both'];
$poly_answer_area = $poly_results['s1'];
$poly_user_area = $poly_results['s2'];
$missing = $poly_results['s1Only'];
$excess = $poly_results['s2Only'];
}
//$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels
if ($dbg_local>0) { error_log(__LINE__.' - Polygons results are '.print_r($poly_results,1),0);}
if ($overlap < 1) {
//shortcut to avoid complicated calculations
$final_overlap = 0;
$final_missing = 100;
$final_excess = 100;
if ($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER) {
//display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect);
//echo $questionScore;
if ($studentChoice) {
$destination = $answerDestination;
$comment = $answerComment;
}
} elseif($answerType == HOT_SPOT_DELINEATION) {
if ($next) {
if ($dbg_local>0) { error_log(__LINE__.' - next',0);}
$hot_spot_load = true; //apparently the script is called twice
$user_answer = $user_array;
$_SESSION['exerciseResultCoordinates'][$questionid]=$user_answer; //needed for exercise_result.php
// we compare only the delineation not the other points
$answer_question = $_SESSION['hotspot_coord'][1];
$answerDestination = $_SESSION['hotspot_dest'][1];
$poly_user = convert_coordinates($user_answer,'/');
$poly_answer = convert_coordinates($answer_question,'|');
$max_coord = poly_get_max($poly_user,$poly_answer);
if (empty($_GET['hotspot'])) { //no user response
$overlap = -2;
} else {
$poly_user_compiled = poly_compile($poly_user,$max_coord);
$poly_answer_compiled = poly_compile($poly_answer,$max_coord);
$poly_results = poly_result($poly_answer_compiled,$poly_user_compiled,$max_coord);
$overlap = $poly_results['both'];
$poly_answer_area = $poly_results['s1'];
$poly_user_area = $poly_results['s2'];
$missing = $poly_results['s1Only'];
$excess = $poly_results['s2Only'];
}
//$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels
if ($dbg_local>0) { error_log(__LINE__.' - Polygons results are '.print_r($poly_results,1),0);}
if ($overlap < 1) {
//shortcut to avoid complicated calculations
$final_overlap = 0;
$final_missing = 100;
$final_excess = 100;
} else {
// the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon
$final_overlap = round(((float)$overlap / (float)$poly_answer_area)*100);
if ($dbg_local>1) { error_log(__LINE__.' - Final overlap is '.$final_overlap,0);}
// the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon
$final_missing = 100 - $final_overlap;
if ($dbg_local>1) { error_log(__LINE__.' - Final missing is '.$final_missing,0);}
// the final excess area is the percentage of the initial polygon's size that is covered by the user's polygon outside of the initial polygon
$final_excess = round((((float)$poly_user_area-(float)$overlap)/(float)$poly_answer_area)*100);
if ($dbg_local>1) { error_log(__LINE__.' - Final excess is '.$final_excess,0);}
}
$destination_items= explode('@@', $answerDestination);
$threadhold_total = $destination_items[0];
$threadhold_items=explode(';',$threadhold_total);
$threadhold1 = $threadhold_items[0]; // overlap
$threadhold2 = $threadhold_items[1]; // excess
$threadhold3 = $threadhold_items[2]; //missing
// echo $final_overlap.' '.$threadhold1 .' - '. $final_missing.' '. $threadhold2 .' - '. $final_excess.' '. $threadhold3;
// if is delineation
if ($answerId===1) {
//setting colors
if ($final_overlap>=$threadhold1) {
$overlap_color=true; //echo 'a';
}
//echo $excess.'-'.$threadhold2;
if ($final_excess<=$threadhold2) {
$excess_color=true; //echo 'b';
}
//echo '--------'.$missing.'-'.$threadhold3;
if ($final_missing<=$threadhold3) {
$missing_color=true; //echo 'c';
}
// if pass
//if ($final_overlap>=$threadhold1 && $final_missing<=$threadhold2 && $final_excess<=$threadhold3) {
if ($final_overlap>=$threadhold1 && $final_missing<=$threadhold3 && $final_excess<=$threadhold2) {
$next=1; //go to the oars
$result_comment=get_lang('Acceptable');
} else {
$next=1; //Go to the oars. If $next = 0 we will show this message: "One (or more) area at risk has been hit" instead of the table resume with the results
$wrong_results = true;
$result_comment=get_lang('Unacceptable');
$special_comment = $comment=$answerDestination=$objAnswerTmp->selectComment(1);
$answerDestination=$objAnswerTmp->selectDestination(1);
$destination_items= explode('@@', $answerDestination);
$try_hotspot=$destination_items[1];
$lp_hotspot=$destination_items[2];
$select_question_hotspot=$destination_items[3];
$url_hotspot=$destination_items[4];
//echo 'show the feedback';
}
} elseif($answerId>1) {
if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
if ($dbg_local>0) { error_log(__LINE__.' - answerId is of type noerror',0);}
//type no error shouldn't be treated
$next = 1;
continue;
}
if ($dbg_local>0) { error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR',0);}
//check the intersection between the oar and the user
//echo 'user'; print_r($x_user_list); print_r($y_user_list);
//echo 'official';print_r($x_list);print_r($y_list);
//$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list);
//$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId); //getting the oars coordinates
$poly_answer = convert_coordinates($delineation_cord,'|');
$max_coord = poly_get_max($poly_user,$poly_answer); //getting max coordinates
$test = false;
// if ($answerId == 2 ){$test = true;} for test oars
if (empty($_GET['hotspot'])) { //no user response
$overlap = false;
} else {
// the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon
$final_overlap = round(((float)$overlap / (float)$poly_answer_area)*100);
if ($dbg_local>1) { error_log(__LINE__.' - Final overlap is '.$final_overlap,0);}
// the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon
$final_missing = 100 - $final_overlap;
if ($dbg_local>1) { error_log(__LINE__.' - Final missing is '.$final_missing,0);}
// the final excess area is the percentage of the initial polygon's size that is covered by the user's polygon outside of the initial polygon
$final_excess = round((((float)$poly_user_area-(float)$overlap)/(float)$poly_answer_area)*100);
if ($dbg_local>1) { error_log(__LINE__.' - Final excess is '.$final_excess,0);}
// poly_compile really works tested with gnuplot
$poly_user_compiled = poly_compile($poly_user,$max_coord,$test);//$poly_user is already set when answerid = 1
$poly_answer_compiled = poly_compile($poly_answer,$max_coord,$test);
$overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord);
}
$destination_items= explode('@@', $answerDestination);
$threadhold_total = $destination_items[0];
$threadhold_items=explode(';',$threadhold_total);
$threadhold1 = $threadhold_items[0]; // overlap
$threadhold2 = $threadhold_items[1]; // excess
$threadhold3 = $threadhold_items[2]; //missing
// echo $final_overlap.' '.$threadhold1 .' - '. $final_missing.' '. $threadhold2 .' - '. $final_excess.' '. $threadhold3;
// if is delineation
if ($answerId===1) {
//setting colors
if ($final_overlap>=$threadhold1) {
$overlap_color=true; //echo 'a';
}
//echo $excess.'-'.$threadhold2;
if ($final_excess<=$threadhold2) {
$excess_color=true; //echo 'b';
}
//echo '--------'.$missing.'-'.$threadhold3;
if ($final_missing<=$threadhold3) {
$missing_color=true; //echo 'c';
}
// if pass
//if ($final_overlap>=$threadhold1 && $final_missing<=$threadhold2 && $final_excess<=$threadhold3) {
if ($final_overlap>=$threadhold1 && $final_missing<=$threadhold3 && $final_excess<=$threadhold2) {
$next=1; //go to the oars
$result_comment=get_lang('Acceptable');
} else {
$next=1; //Go to the oars. If $next = 0 we will show this message: "One (or more) area at risk has been hit" instead of the table resume with the results
$wrong_results = true;
$result_comment=get_lang('Unacceptable');
$sepecial_comment = $comment=$answerDestination=$objAnswerTmp->selectComment(1);
$answerDestination=$objAnswerTmp->selectDestination(1);
$destination_items= explode('@@', $answerDestination);
$try_hotspot=$destination_items[1];
$lp_hotspot=$destination_items[2];
$select_question_hotspot=$destination_items[3];
$url_hotspot=$destination_items[4];
//echo 'show the feedback';
}
} elseif($answerId>1) {
if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
if ($dbg_local>0) { error_log(__LINE__.' - answerId is of type noerror',0);}
//type no error shouldn't be treated
$next = 1;
continue;
}
if ($dbg_local>0) { error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR',0);}
//check the intersection between the oar and the user
//echo 'user'; print_r($x_user_list); print_r($y_user_list);
//echo 'official';print_r($x_list);print_r($y_list);
//$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list);
//$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId); //getting the oars coordinates
$poly_answer = convert_coordinates($delineation_cord,'|');
$max_coord = poly_get_max($poly_user,$poly_answer); //getting max coordinates
$test = false;
// if ($answerId == 2 ){$test = true;} for test oars
if (empty($_GET['hotspot'])) { //no user response
$overlap = false;
} else {
// poly_compile really works tested with gnuplot
$poly_user_compiled = poly_compile($poly_user,$max_coord,$test);//$poly_user is already set when answerid = 1
$poly_answer_compiled = poly_compile($poly_answer,$max_coord,$test);
$overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord);
}
if ($overlap == false) {
//all good, no overlap
$next = 1;
continue;
} else {
if ($dbg_local>0) { error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0);}
$organs_at_risk_hit++;
//show the feedback
$next=1;
$comment=$answerDestination=$objAnswerTmp->selectComment($answerId);
$answerDestination=$objAnswerTmp->selectDestination($answerId);
$destination_items= explode('@@', $answerDestination);
$try_hotspot=$destination_items[1];
$lp_hotspot=$destination_items[2];
$select_question_hotspot=$destination_items[3];
$url_hotspot=$destination_items[4];
}
}
} else {
// the first delineation feedback
if ($dbg_local>0) { error_log(__LINE__.' first',0);}
//we send the error
}
}
if ($overlap == false) {
//all good, no overlap
$next = 1;
continue;
} else {
if ($dbg_local>0) { error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0);}
$organs_at_risk_hit++;
//show the feedback
$next=1;
$comment=$answerDestination=$objAnswerTmp->selectComment($answerId);
$answerDestination=$objAnswerTmp->selectDestination($answerId);
$destination_items= explode('@@', $answerDestination);
$try_hotspot=$destination_items[1];
$lp_hotspot=$destination_items[2];
$select_question_hotspot=$destination_items[3];
$url_hotspot=$destination_items[4];
}
}
} else {
// the first delineation feedback
if ($dbg_local>0) { error_log(__LINE__.' first',0);}
//we send the error
}
}
}
if ($overlap_color) {
@ -412,7 +411,7 @@ if (!empty($choice_value)) {
}
$table_resume='<table class="data_table" >
$table_resume = '<table class="data_table" >
<tr class="row_odd" >
<td></td>
<td ><b>'.get_lang('Requirements').'</b></td>
@ -439,13 +438,19 @@ if (!empty($choice_value)) {
</table>';
//var_dump($final_overlap, $threadhold1 , $final_missing, $threadhold2 , $final_excess, $threadhold3);
}
$_SESSION['newquestionList']=$newquestionList;
if ($choice_value==-1) {
$links. '<a href="#" onclick="self.parent.tb_remove();">'.get_lang('ChooseAnAnswer').'</a>';
$_SESSION['newquestionList'] = $newquestionList;
$links='';
if ($choice_value == -1) {
if ($answerType != HOT_SPOT_DELINEATION) {
$links .= '<a href="#" onclick="self.parent.tb_remove();">'.get_lang('ChooseAnAnswer').'</a><br />';
}
}
if ($answerType!= HOT_SPOT_DELINEATION) {
if ($answerType != HOT_SPOT_DELINEATION) {
if (!empty($destination)) {
$item_list=explode('@@',$destination);
$item_list = explode('@@',$destination);
//print_R($item_list);
$try = $item_list[0];
$lp = $item_list[1];
@ -477,7 +482,7 @@ if ($answerType!= HOT_SPOT_DELINEATION) {
}
}
$links='';
// the link to retry the question
if ($try==1) {
$num_value_array= (array_keys($questionList, $questionid));
@ -511,24 +516,28 @@ if ($destinationid==-1) {
$links.= Display :: return_icon('quiz.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('GoToQuestion').' '.$num_value_array[0].'</a><br /><br />';
}
}
echo '<script>
function SendEx(num) {
if (num==-1) {
self.parent.window.location.href = "exercise_result.php?take_session=1&exerciseId='.$exerciseId.'&questionNum="+num+"&exerciseType='.$exerciseType.'&origin='.$origin.'&learnpath_item_id='.$learnpath_item_id.'&learnpath_id='.$learnpath_id.'";
if (num == -1) {
self.parent.window.location.href = "exercise_result.php?take_session=1&exerciseId='.$exerciseId.'&num="+num+"&exerciseType='.$exerciseType.'&origin='.$origin.'&learnpath_item_id='.$learnpath_item_id.'&learnpath_id='.$learnpath_id.'";
self.parent.tb_remove();
} else {
self.parent.window.location.href = "exercise_submit.php?tryagain=1&exerciseId='.$exerciseId.'&questionNum="+num+"&exerciseType='.$exerciseType.'&origin='.$origin.'&learnpath_item_id='.$learnpath_item_id.'&learnpath_id='.$learnpath_id.'";
num -= 1;
self.parent.window.location.href = "exercise_submit.php?tryagain=1&exerciseId='.$exerciseId.'&num="+num+"&exerciseType='.$exerciseType.'&origin='.$origin.'&learnpath_item_id='.$learnpath_item_id.'&learnpath_id='.$learnpath_id.'";
self.parent.tb_remove();
}
}
</script>';
if ($links!='') {
echo '<div id="ModalContent" style="padding-bottom:30px;padding-top:10px;padding-left:20px;padding-right:20px;">
<a onclick="self.parent.tb_remove();" href="#" style="float:right; margin-top:-10px;" id="exercise_close_link">'.api_ucfirst(get_lang('Close')).'</a>
<a onclick="self.parent.tb_remove();" href="#" style="float:right; margin-top:-10px;">'.api_ucfirst(get_lang('Close')).'</a>
<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>';
if ($answerType == HOT_SPOT_DELINEATION) {
if ($organs_at_risk_hit>0) {
if ($organs_at_risk_hit > 0) {
//$message='<p>'.get_lang('YourDelineation').'</p>';
//$message.=$table_resume;
$message.='<br />'.get_lang('ResultIs').' <b>'.get_lang('Unacceptable').'</b><br />';
@ -546,8 +555,8 @@ if ($links!='') {
echo '<p>'.$comment.'</p>';
}
echo '<h3>'.$links.'</h3>';
//echo '<a onclick="self.parent.tb_remove();" href="#" style="float:right;">'.get_lang('Close').'</a>';
echo '</div>';
$_SESSION['hot_spot_result']=$message;
$_SESSION['hotspot_delineation_result'][$exerciseId][$questionid] = array($message, $exerciseResult[$questionid]);
//reseting the exerciseResult variable
@ -560,7 +569,7 @@ if ($links!='') {
} else {
$questionNum++;
echo '<script>
self.parent.window.location.href = "exercise_submit.php?exerciseId='.$exerciseId.'&questionNum='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'";
self.parent.window.location.href = "exercise_submit.php?exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'";
//self.parent.tb_remove();
</script>';
}

@ -583,8 +583,8 @@ $hotspot_admin_url = api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?' . api_g
} else {
$option_lp = '<option value="0" selected="selected" >'.get_lang('SelectTargetLP').'</option>'.$option_lp;
}
//Feedback SELECT
//Feedback SELECT
$question_list=$objExercise->selectQuestionList();
$option_feed='';
$option_feed.='<option value="0">'.get_lang('SelectTargetQuestion').'</option>';

@ -28,7 +28,7 @@ class MultipleAnswer extends Question {
/**
* Constructor
*/
function MultipleAnswer(){
function MultipleAnswer() {
parent::question();
$this -> type = MULTIPLE_ANSWER;
$this -> isContent = $this-> getIsContent();
@ -106,7 +106,6 @@ class MultipleAnswer extends Question {
}
$renderer = & $form->defaultRenderer();
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'correct['.$i.']');
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'counter['.$i.']');
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'answer['.$i.']');

@ -60,10 +60,10 @@ if (is_object($objQuestion)) {
$form->addElement('header', $text.': '.$form_title_extra);
// question form elements
$objQuestion->createForm ($form);
$objQuestion->createForm($form);
// answer form elements
$objQuestion->createAnswersForm ($form);
$objQuestion->createAnswersForm($form);
// this variable $show_quiz_edition comes from admin.php blocks the exercise/quiz modifications
if (!$show_quiz_edition) {
@ -80,10 +80,10 @@ if (is_object($objQuestion)) {
if (isset($_POST['submitQuestion']) && $form->validate()) {
// question
$objQuestion->processCreation($form,$objExercise);
// answers
$objQuestion->processCreation($form, $objExercise);
$objQuestion->processAnswersCreation($form,$nb_answers);
// answers
$objQuestion->processAnswersCreation($form, $nb_answers);
// TODO: maybe here is the better place to index this tool, including answers text

@ -1,8 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
// $Id: testcategory.class.php 2010-12-06 hubert.borderiou
/** @author hubert.borderiou **/
if(!class_exists('Testcategory')):
if (!class_exists('Testcategory')):
class Testcategory {
public $id;

@ -31,7 +31,7 @@ class UniqueAnswer extends Question {
/**
* Constructor
*/
function UniqueAnswer(){
function UniqueAnswer() {
//this is highly important
parent::question();
$this -> type = UNIQUE_ANSWER;
@ -63,9 +63,10 @@ class UniqueAnswer extends Question {
$feedback_title='';
$comment_title='';
if ($obj_ex->selectFeedbackType()==0) {
if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_END) {
$comment_title = '<th>'.get_lang('Comment').'</th>';
} elseif ($obj_ex->selectFeedbackType()==1) {
} elseif ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
//Scenario
$editor_config['Width'] = '250';
$editor_config['Height'] = '110';
$comment_title = '<th width="500px" >'.get_lang('Comment').'</th>';
@ -104,9 +105,9 @@ class UniqueAnswer extends Question {
$form -> addElement('hidden', 'nb_answers');
//Feedback SELECT
$question_list=$obj_ex->selectQuestionList();
$question_list = $obj_ex->selectQuestionList();
$select_question=array();
$select_question[0]=get_lang('SelectTargetQuestion');
$select_question[0] = get_lang('SelectTargetQuestion');
require_once '../newscorm/learnpathList.class.php';
if (is_array($question_list)) {
@ -119,7 +120,7 @@ class UniqueAnswer extends Question {
$select_question[$questionid]='Q'.$key.' :'.cut($question->selectTitle(),20);
}
}
$select_question[-1]=get_lang('ExitTest');
$select_question[-1] = get_lang('ExitTest');
$list = new LearnpathList(api_get_user_id());
$flat_list = $list->get_flat_list();
@ -137,16 +138,15 @@ class UniqueAnswer extends Question {
Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
}
for ($i = 1 ; $i <= $nb_answers ; ++$i) {
$form -> addElement ('html', '<tr>');
if (isset($answer) && is_object($answer)) {
if ($answer -> correct[$i]) {
$correct = $i;
}
$defaults['answer['.$i.']'] = $answer -> answer[$i];
$defaults['comment['.$i.']'] = $answer -> comment[$i];
$defaults['weighting['.$i.']'] = float_format($answer -> weighting[$i], 1);
$defaults['answer['.$i.']'] = $answer->answer[$i];
$defaults['comment['.$i.']'] = $answer->comment[$i];
$defaults['weighting['.$i.']'] = float_format($answer->weighting[$i], 1);
$item_list=explode('@@',$answer -> destination[$i]);
@ -155,15 +155,16 @@ class UniqueAnswer extends Question {
$list_dest = $item_list[2];
$url = $item_list[3];
if ($try==0)
$try_result=0;
else
$try_result=1;
if ($url==0)
if ($try==0) {
$try_result = 0;
} else {
$try_result = 1;
}
if ($url==0) {
$url_result='';
else
$url_result=$url;
} else {
$url_result = $url;
}
$temp_scenario['url'.$i] = $url_result;
$temp_scenario['try'.$i] = $try_result;
@ -180,7 +181,7 @@ class UniqueAnswer extends Question {
}
$defaults['scenario'] = $temp_scenario;
$renderer =& $form->defaultRenderer();
$renderer = $form->defaultRenderer();
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'correct');
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'counter['.$i.']');
@ -200,21 +201,19 @@ class UniqueAnswer extends Question {
// feedback
$form->addElement('html_editor', 'comment['.$i.']', null, 'style="vertical-align:middle"', $editor_config);
} elseif ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
// direct feedback
$form->addElement('html_editor', 'comment['.$i.']', null, 'style="vertical-align:middle"', $editor_config);
// Direct feedback
//Adding extra feedback fields
$group = array();
$group['try'.$i] =&$form->createElement('checkbox', 'try'.$i,get_lang('TryAgain').': ' );
$group['lp'.$i] =&$form->createElement('select', 'lp'.$i,get_lang('SeeTheory').': ',$select_lp_id);
$group['destination'.$i]=&$form->createElement('select', 'destination'.$i, get_lang('GoToQuestion').': ' ,$select_question);
$group['url'.$i] =&$form->createElement('text', 'url'.$i,get_lang('Other').': ',array('size'=>'25px'));
$group['try'.$i] = $form->createElement('checkbox', 'try'.$i, null , get_lang('TryAgain'));
$group['lp'.$i] = $form->createElement('select', 'lp'.$i, get_lang('SeeTheory').': ', $select_lp_id);
$group['destination'.$i]= $form->createElement('select', 'destination'.$i, get_lang('GoToQuestion').': ' , $select_question);
$group['url'.$i] = $form->createElement('text', 'url'.$i, get_lang('Other').': ', array('class'=>'span2', 'placeholder' => get_lang('Other')));
$form->addGroup($group, 'scenario');
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'url'.$i);
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'lp'.$i);
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'try'.$i);
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}', 'scenario');
$form -> addGroup($group, 'scenario', 'scenario');
$renderer->setGroupElementTemplate('<div class="exercise_scenario_label">{label}</div><div class="exercise_scenario_element">{element}</div>','scenario');
}
$form->addElement('text', 'weighting['.$i.']', null, array('class' => "span1", 'value' => '0'));
$form->addElement ('html', '</tr>');
@ -226,6 +225,7 @@ class UniqueAnswer extends Question {
$navigator_info = api_get_navigator();
global $text, $class, $show_quiz_edition;
//ie6 fix
if ($show_quiz_edition) {
if ($navigator_info['name']=='Internet Explorer' && $navigator_info['version']=='6') {
@ -243,7 +243,7 @@ class UniqueAnswer extends Question {
$renderer->setElementTemplate('{element}&nbsp;','lessAnswers');
$renderer->setElementTemplate('{element}&nbsp;','moreAnswers');
$form -> addElement ('html', '</div></div>');
$form->addElement('html', '</div></div>');
//We check the first radio button to be sure a radio button will be check
if ($correct==0) {
@ -272,21 +272,20 @@ class UniqueAnswer extends Question {
$questionWeighting = $nbrGoodAnswers = 0;
$correct = $form -> getSubmitValue('correct');
$objAnswer = new Answer($this->id);
$nb_answers = $form -> getSubmitValue('nb_answers');
$nb_answers = $form->getSubmitValue('nb_answers');
for ($i=1 ; $i <= $nb_answers ; $i++) {
$answer = trim($form -> getSubmitValue('answer['.$i.']'));
$comment = trim($form -> getSubmitValue('comment['.$i.']'));
$weighting = trim($form -> getSubmitValue('weighting['.$i.']'));
$scenario= $form -> getSubmitValue('scenario');
$scenario = $form -> getSubmitValue('scenario');
echo '<pre>';
//$list_destination = $form -> getSubmitValue('destination'.$i);
//$destination_str = $form -> getSubmitValue('destination'.$i);
$try = $scenario['try'.$i];
$lp= $scenario['lp'.$i];
$lp = $scenario['lp'.$i];
$destination = $scenario['destination'.$i];
$url = trim($scenario['url'.$i]);
@ -294,7 +293,7 @@ class UniqueAnswer extends Question {
How we are going to parse the destination value
here we parse the destination value which is a string
1@@3@@2;4;4;@@http://www.dokeos.com
1@@3@@2;4;4;@@http://www.chamilo.org
where: try_again@@lp_id@@selected_questions@@url
@ -302,31 +301,29 @@ class UniqueAnswer extends Question {
lp_id = id of a learning path (0 if dont select)
selected_questions= ids of questions
url= an url
*/
/*
$destination_str='';
foreach ($list_destination as $destination_id)
{
$destination_str.=$destination_id.';';
}*/
$goodAnswer= ($correct == $i) ? true : false;
$goodAnswer = ($correct == $i) ? true : false;
if($goodAnswer) {
if ($goodAnswer) {
$nbrGoodAnswers++;
$weighting = abs($weighting);
if($weighting > 0)
{
if($weighting > 0) {
$questionWeighting += $weighting;
}
}
if (empty($try))
$try=0;
if (empty($try)) {
$try = 0;
}
if (empty($lp))
{
$lp=0;
if (empty($lp)) {
$lp = 0;
}
if (empty($destination)) {
@ -337,17 +334,17 @@ class UniqueAnswer extends Question {
$url=0;
}
//1@@1;2;@@2;4;4;@@http://www.dokeos.com
$dest= $try.'@@'.$lp.'@@'.$destination.'@@'.$url;
$objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i,NULL,NULL,$dest);
//1@@1;2;@@2;4;4;@@http://www.chamilo.org
$dest = $try.'@@'.$lp.'@@'.$destination.'@@'.$url;
$objAnswer->createAnswer($answer, $goodAnswer, $comment, $weighting, $i, null, null, $dest);
}
// saves the answers into the data base
$objAnswer -> save();
$objAnswer->save();
// sets the total weighting of the question
$this -> updateWeighting($questionWeighting);
$this -> save();
$this->updateWeighting($questionWeighting);
$this->save();
}
function return_header($feedback_type = null, $counter = null, $score = null) {

@ -19,12 +19,10 @@ require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_data_generator.class.php';
require_once api_get_path(LIBRARY_PATH).'certificate.lib.php';
//extra javascript functions for in html head:
$htmlHeadXtra[] =
"<script language='javascript' type='text/javascript'>
"<script>
function confirmation() {
if (confirm(\" ".trim(get_lang('AreYouSureToDelete'))." ?\"))
{return true;}
@ -52,10 +50,10 @@ if ($_GET['action'] == 'delete') {
}
}
echo Display::tag('h3', get_lang('GradebookListOfStudentsCertificates'));
echo Display::page_header(get_lang('GradebookListOfStudentsCertificates'));
?>
<table class="data_table" border="0" width="100%" >
<table class="data_table">
<?php
$cat_id = isset($_GET['cat_id']) ? (int)$_GET['cat_id'] : null;
@ -114,7 +112,7 @@ echo Display::tag('h3', get_lang('GradebookListOfStudentsCertificates'));
</tr>
<tr>
<td>
<table class="data_table" width="100%" >
<table class="data_table">
<?php
$list_certificate = get_list_gradebook_certificates_by_user_id ($value['user_id'], $cat_id);
foreach ($list_certificate as $value_certificate) {
@ -125,8 +123,8 @@ echo Display::tag('h3', get_lang('GradebookListOfStudentsCertificates'));
<td width="20%">
<?php
//$url = "index.php?export_certificate=yes&cat_id=".$cat_id."&user=".$value['user_id'];
$url = api_get_path(WEB_PATH).'certificates/?id='.$value_certificate['id'];
$certificates = Display::url(Display::return_icon('certificate.png', get_lang('Certificates'), array(), ICON_SIZE_SMALL), $url, array('target'=>'_blank'));
$url = api_get_path(WEB_PATH).'certificates/index.php?id='.$value_certificate['id'];
$certificates = Display::url(get_lang('Certificate'), $url, array('target'=>'_blank', 'class' => 'btn'));
echo $certificates;
?>
<a onclick="return confirmation();" href="gradebook_display_certificate.php?action=delete&cat_id=<?php echo $cat_id; ?>&certificate_id=<?php echo $value_certificate['id'] ?>">

@ -584,6 +584,7 @@ class Autoload
$result['EventsMail'] = '/main/inc/lib/events_email.class.php';
$result['Exercise'] = '/main/exercice/exercise.class.php';
$result['ExerciseLink'] = '/main/gradebook/lib/be/exerciselink.class.php';
$result['Testcategory'] = '/main/exercice/testcategory.class.php';
$result['ExerciseResult'] = '/main/exercice/exercise_result.class.php';
$result['ExerciseShowFunctions'] = '/main/inc/lib/exercise_show_functions.lib.php';
$result['FileManager'] = '/main/inc/lib/fileManage.lib.php';

@ -23,8 +23,9 @@ class Certificate extends Model {
var $user_id;
//If true every time we enter to the certificate URL we would generate a new certificate
// (good thing because we can edit the certificate and all users will have the latest certificate bad because we load everytime)
// (good thing because we can edit the certificate and all users will have the latest certificate bad because we load the certificate everytime)
var $force_certificate_generation = true; //default true
/**
* Constructor
* @param int ID of the certificate. If no ID given, take user_id and try to generate one
@ -35,7 +36,7 @@ class Certificate extends Model {
if (isset($certificate_id)) {
$this->certificate_data = $this->get($certificate_id);
$this->user_id = $this->certificate_data['user_id'];
$this->user_id = $this->certificate_data['user_id'];
} else {
//Try with the current user
$this->user_id = api_get_user_id();
@ -98,7 +99,7 @@ class Certificate extends Model {
* the teacher from the gradebook tool to re-generate the certificate because
* the original version wa flawed.
*/
public function delete() {
public function delete($id = null) {
if (!empty($this->certificate_data)) {
@ -148,9 +149,6 @@ class Certificate extends Model {
$scorecourse = $my_category[0]->calc_score($this->user_id);
$scorecourse_display = (isset($scorecourse) ? $scoredisplay->display_score($scorecourse,SCORE_AVERAGE) : get_lang('NoResultsAvailable'));
//$cattotal = Category :: load($this->certificate_data['cat_id']);
//$scoretotal= $cattotal[0]->calc_score($this->user_id);
//$scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal,SCORE_PERCENT) : get_lang('NoResultsAvailable'));
//Prepare all necessary variables:
$organization_name = api_get_setting('Institution');
@ -162,8 +160,6 @@ class Certificate extends Model {
$certif_text = sprintf(get_lang('CertificateWCertifiesStudentXFinishedCourseYWithGradeZ'), $organization_name, $stud_fn.' '.$stud_ln, $my_category[0]->get_name(), $scorecourse_display);
$certif_text = str_replace("\\n","\n", $certif_text);
//$date = date('d/m/Y', time());
//If the gradebook is related to skills we added the skills to the user
$skill = new Skill();
@ -189,10 +185,7 @@ class Certificate extends Model {
$file_info = pathinfo($path_certificate);
$qr_code_filename = $this->certification_user_path.$file_info['filename'].'_qr.png';
$new_content_html['content'] = str_replace('((certificate_barcode))', Display::img($this->certification_web_user_path.$file_info['filename'].'_qr.png', 'QR'), $new_content_html['content']);
$my_new_content_html = $new_content_html['content'];
$my_new_content_html = str_replace('((certificate_barcode))', Display::img($this->certification_web_user_path.$file_info['filename'].'_qr.png', 'QR'), $new_content_html['content']);
$my_new_content_html = mb_convert_encoding($my_new_content_html,'UTF-8', api_get_system_encoding());
$result = @file_put_contents($my_path_certificate, $my_new_content_html);
@ -229,7 +222,7 @@ class Certificate extends Model {
if (!UserManager::is_user_certified($cat_id,$user_id)) {
$sql='UPDATE '.$table_certificate.' SET path_certificate="'.Database::escape_string($path_certificate).'"
WHERE cat_id="'.intval($cat_id).'" AND user_id="'.intval($user_id).'" ';
$rs = Database::query($sql);
Database::query($sql);
}
}
@ -260,8 +253,9 @@ class Certificate extends Model {
if (!empty($text) && !empty($path)) {
require_once api_get_path(LIBRARY_PATH).'phpqrcode/qrlib.php';
//L low, M - Medium, L large error correction
$return = QRcode::png($text, $path, 'M', 2, 2);
return QRcode::png($text, $path, 'M', 2, 2);
}
return false;
}
/**
@ -270,7 +264,7 @@ class Certificate extends Model {
* @param array Contains two array entris: first are the headers, second is an array of contents
* @return string The translated string
*/
private function parse_certificate_variables($array) {
public function parse_certificate_variables($array) {
$text = '';
$headers = $array[0];
$content = $array[1];
@ -278,8 +272,7 @@ class Certificate extends Model {
if (!empty($content)) {
foreach($content as $key => $value) {
$my_header = $headers[$key];
$my_header = str_replace(array('((', '))') , '', $my_header);
$my_header = str_replace(array('((', '))') , '', $headers[$key]);
$final_content[$my_header] = $value;
}
}

@ -1328,7 +1328,7 @@ class DocumentManager {
if ($num == 0) {
return null;
}
$row = Database::fetch_array($rs);
$row = Database::fetch_array($rs);
return $row['document_id'];
}
@ -1337,7 +1337,7 @@ class DocumentManager {
* @param string The course code
* @return string The html content of the certificate
*/
function replace_user_info_into_html($user_id, $course_code, $is_preview = false) {
static function replace_user_info_into_html($user_id, $course_code, $is_preview = false) {
$user_id = intval($user_id);
$course_info = api_get_course_info($course_code);
$tbl_document = Database::get_course_table(TABLE_DOCUMENT);
@ -1350,7 +1350,7 @@ class DocumentManager {
$new_content = '';
$all_user_info = array();
if (Database::num_rows($rs)) {
$row=Database::fetch_array($rs);
$row = Database::fetch_array($rs);
$filepath = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document'.$row['path'];
if (is_file($filepath)) {
$my_content_html = file_get_contents($filepath);
@ -1406,7 +1406,9 @@ class DocumentManager {
$date_long_certificate = api_convert_and_format_date(api_get_utc_datetime());
}
$url = api_get_path(WEB_PATH).'certificates/?id='.$info_grade_certificate['id'];
$url = api_get_path(WEB_PATH).'certificates/index.php?id='.$info_grade_certificate['id'];
//replace content
$info_to_replace_in_content_html = array($first_name,
$last_name,
@ -1423,6 +1425,7 @@ class DocumentManager {
'<a href="'.$url.'" target="_blank">'.get_lang('CertificateOnlineLink').'</a>',
'((certificate_barcode))',
);
$info_to_be_replaced_in_content_html = array('((user_firstname))',
'((user_lastname))',
'((gradebook_institution))',
@ -1445,6 +1448,7 @@ class DocumentManager {
$info_to_replace_in_content_html[]=$value_extra;
}
}
$info_list[]=$info_to_be_replaced_in_content_html;
$info_list[]=$info_to_replace_in_content_html;
return $info_list;

@ -628,8 +628,6 @@ class HTML_QuickForm extends HTML_Common
$args[$i] = null;
}
}
$err = $elementObject->onQuickFormEvent($event, $args, $this);
if ($err !== true) {
return $err;
@ -784,7 +782,7 @@ class HTML_QuickForm extends HTML_Common
$name = 'qf_group_' . $anonGroups++;
$appendName = false;
}
$group =& $this->addElement('group', $name, $groupLabel, $elements, $separator, $appendName);
$group = & $this->addElement('group', $name, $groupLabel, $elements, $separator, $appendName);
return $group;
} // end func addGroup

@ -33,7 +33,6 @@ function addEvent(elm, evType, fn, useCapture) {
*/
function addListeners(e) {
var my_links = $('.clickable_email_link');
console.log(my_links);
for(var i=0;i < my_links.length;i++) {
addEvent(my_links[i],'click',loadEmailEditor,false);
}

Loading…
Cancel
Save