Esempio n. 1
0
              if ($objAnswer->isCorrect($i)) {
                  $correct = $i;
              }
          }
      }
      // minimum 2 answers
      if ($nbrAnswers < 2) {
          $nbrAnswers = 2;
      }
  }
  $tool_content .= "<div class='panel panel-primary'>
                    <div class='panel-heading'>
                      <h3 class='panel-title'>$langQuestion</h3>
                    </div>
                    <div class='panel-body'>
                          <h4><small>$questionTypeWord</small><br>" . nl2br(q_math($questionName)) . "</h4>                         
                    </div>
                  </div>";
 $tool_content .= "<div class='panel panel-info'>
                    <div class='panel-heading'>
                      <h3 class='panel-title'>$langQuestionAnswers</h3>
                    </div>
                    <div class='panel-body'>";
 
  if ($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER) {
      $tool_content .= "
                  <form method='post' action='$_SERVER[SCRIPT_NAME]?course=$course_code".((isset($exerciseId))? "&amp;exerciseId=$exerciseId" : "")."&amp;modifyAnswers=" . urlencode($_GET['modifyAnswers']) . "'>
                  <input type='hidden' name='formSent' value='1' />
                  <input type='hidden' name='nbrAnswers' value='$nbrAnswers' />
                  
                  <fieldset>
Esempio n. 2
0
if ($is_editor && isset($_GET['purgeAttempID'])) {
    $eurid = $_GET['purgeAttempID'];
    $objExercise->purgeAttempt($eurid);
    Session::Messages($langPurgeExerciseResultsSuccess);
    redirect_to_home_page("modules/exercise/results.php?course=$course_code&exerciseId=$exerciseId");  
}
$exerciseTitle = $objExercise->selectTitle();
$exerciseDescription = $objExercise->selectDescription();
$exerciseDescription_temp = nl2br(make_clickable($exerciseDescription));
 
$tool_content .= "
<div class='table-responsive'>
    <table class='table-default'>
    <tr>
    <th>" . q_math($exerciseTitle) . "</th>
    </tr>";
if($exerciseDescription_temp) {
    $tool_content .= "
        <tr>
            <td>" . standard_text_escape($exerciseDescription_temp) . "</td>
        </tr>";
}
$tool_content .= "</table>
</div><br>";
$status = (isset($_GET['status'])) ? intval($_GET['status']) : 0; 
$tool_content .= "<select class='form-control' style='margin:0 0 12px 0;' id='status_filtering'>
        <option value='results.php?course=$course_code&exerciseId=$exerciseId' ".(($status == 0)? 'selected' : '').">--- $langCurrentStatus ---</option>
        <option value='results.php?course=$course_code&exerciseId=$exerciseId&status=".ATTEMPT_COMPLETED."' ".(($status == 1)? 'selected' : '').">$langAttemptCompleted</option>
        <option value='results.php?course=$course_code&exerciseId=$exerciseId&status=".ATTEMPT_PENDING."' ".(($status == 2)? 'selected' : '').">$langAttemptPending</option>
        <option value='results.php?course=$course_code&exerciseId=$exerciseId&status=".ATTEMPT_PAUSED."' ".(($status == 3)? 'selected' : '').">$langAttemptPaused</option>
Esempio n. 3
0
    <h3>$langQuestions</h3>
    <div class='table-responsive'>
        <table class='table-default'>
            <thead>
                <tr>
                    <th>$langTitle</th>
                    <th>Ποσοστό Επιτυχίας</th>
                </tr>
            </thead>
            <tbody>";
foreach($questionList as $id){
    $objQuestionTmp = new Question();
    $objQuestionTmp->read($id);    
    $tool_content .= "
                <tr>
                    <td>".q_math($objQuestionTmp->selectTitle())."</th>
                    <td>
                        <div class='progress'>
                            <div class='progress-bar progress-bar-success progress-bar-striped' role='progressbar' aria-valuenow='".$objQuestionTmp->successRate($exerciseId)."' aria-valuemin='0' aria-valuemax='100' style='width: ".$objQuestionTmp->successRate($exerciseId)."%;'>
                              ".$objQuestionTmp->successRate($exerciseId)."%
                            </div>
                        </div></td>                   
                </tr>";         
}
               
$tool_content .= "
            </tbody>
        </table>
    </div>";    
draw($tool_content, 2, null, $head_content);
Esempio n. 4
0
        unset_exercise_var($exerciseId);      
        redirect_to_home_page('modules/exercise/index.php?course='.$course_code);        
    } 
//    else {
//        redirect_to_home_page("modules/exercise/exercise_submit.php?course=$course_code&exerciseId=$exerciseId");
//    }
} // end of submit


$exerciseDescription_temp = standard_text_escape($exerciseDescription);
$tool_content .= "<div class='panel panel-primary'>
  <div class='panel-heading'>
    <h3 class='panel-title'>" .
      (isset($timeleft) && $timeleft>0 ?
        "<div class='pull-right'>$langRemainingTime: <span id='progresstime'>" . $timeleft . "</span></div>" : '') .
      q_math($exerciseTitle) . "</h3>
  </div>";
if (!empty($exerciseDescription_temp)) {
    $tool_content .= "<div class='panel-body'>
        $exerciseDescription_temp
      </div>";
}
$tool_content .= "</div><br>";

  
$tool_content .= "
  <form class='form-horizontal exercise' role='form' method='post' action='$_SERVER[SCRIPT_NAME]?course=$course_code&amp;exerciseId=$exerciseId".(isset($paused_attempt) ? "&amp;eurId=$eurid" : "")."'>
  <input type='hidden' name='formSent' value='1'>
  <input type='hidden' name='attempt_value' value='$attempt_value'>
  <input type='hidden' name='nbrQuestions' value='$nbrQuestions'>";
        
Esempio n. 5
0
        if ($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER || $answerType == TRUE_FALSE) {
            $colspan = 4;
        } elseif ($answerType == MATCHING) {
            $colspan = 2;
        } else {
            $colspan = 1;
        }
        $iplus = $i + 1;
        $tool_content .= "
            <table class='table-default ".(($question_graded)? 'graded' : 'ungraded')."'>
            <tr class='active'>
              <td colspan='${colspan}'><b><u>$langQuestion</u>: $iplus</b></td>
            </tr>
            <tr>
              <td colspan='${colspan}'>
                <b>" . q_math($questionName) . "</b>
                <br />" .
                standard_text_escape($questionDescription_temp)
                . "<br/><br/>
              </td>
            </tr>";
        if (file_exists($picturePath . '/quiz-' . $row->question_id)) {
            $tool_content .= "
                      <tr class='even'>
                        <td class='text-center' colspan='${colspan}'><img src='../../" . ${'picturePath'} . "/quiz-" . $row->question_id . "'></td>
                      </tr>";
        }
        $questionScore = 0;

        if ($showResults) {
            if ($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER || $answerType == TRUE_FALSE) {
Esempio n. 6
0
        exit();
    }
    // saves the object into the session
    $_SESSION['objExercise'][$exerciseId] = $objExercise;
}

// if there is an active attempt and it's time passed. Complete the record to finish attempt
$tmp = Database::get()->querySingle("SELECT COUNT(*) AS cnt, record_start_date FROM `exercise_user_record` WHERE eid = ?d AND uid= ?d AND record_end_date is NULL", $exerciseId, $uid);
if ($tmp->cnt > 0) {	
    Database::get()->query("UPDATE `exercise_user_record` SET record_end_date = '".date('Y-m-d H:i:s', time())."' WHERE eid = ?d AND uid = ?d AND record_end_date is NULL", $exerciseId, $uid);
}

$exerciseTitle = $objExercise->selectTitle();
$exerciseDescription = $objExercise->selectDescription();
$exerciseDescription_temp = nl2br(make_clickable($exerciseDescription));

$tool_content .= "<table class='Exercise' width='99%'>
<thead><tr>
  <td colspan='2'>
  <b>" . q_math($exerciseTitle) . "</b>
  <br/><br/>
  " . q($exerciseDescription_temp) . "
  </td>
</tr>
</thead></table>";

$tool_content .= $tool_content_extra;
draw($tool_content, 2);


Esempio n. 7
0
function showQuestion(&$objQuestionTmp, $exerciseResult = array()) {
    global $tool_content, $picturePath, $langNoAnswer, $langQuestion,
    $langColumnA, $langColumnB, $langMakeCorrespond, $langInfoGrades, $i,
    $exerciseType, $nbrQuestions, $langInfoGrade;

    $questionId = $objQuestionTmp->id;
    $questionWeight = $objQuestionTmp->selectWeighting();
    $answerType = $objQuestionTmp->selectType();

    $message = $langInfoGrades;
    if (intval($questionWeight) == $questionWeight) {
        $questionWeight = intval($questionWeight);
    }
    if ($questionWeight == 1) {
        $message = $langInfoGrade;
    }


    $questionName = $objQuestionTmp->selectTitle();
    $questionDescription = standard_text_escape($objQuestionTmp->selectDescription());
    $questionTypeWord = $objQuestionTmp->selectTypeWord($answerType);
    $tool_content .= "
            <div class='panel panel-success'>
              <div class='panel-heading'>
                <h3 class='panel-title'>$langQuestion : $i ($questionWeight $message)".(($exerciseType == 2) ? " / " . $nbrQuestions : "")."</h3>
              </div>
              <div class='panel-body'>
                    <h4>
                        <small>$questionTypeWord</small><br>" . q_math($questionName) . " 
                    </h4>
                    $questionDescription
                    <div class='text-center'>
                        ".(file_exists($picturePath . '/quiz-' . $questionId) ? "<img src='../../$picturePath/quiz-$questionId'>" : "")."
                    </div>";

    // construction of the Answer object
    $objAnswerTmp = new Answer($questionId);
    $nbrAnswers = $objAnswerTmp->selectNbrAnswers();

    if ($answerType == FREE_TEXT) {
            $text = (isset($exerciseResult[$questionId])) ? $exerciseResult[$questionId] : '';
            $tool_content .= rich_text_editor('choice['.$questionId.']', 14, 90, $text);
    }
    if ($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER ||$answerType == TRUE_FALSE) {
         $tool_content .= "<input type='hidden' name='choice[${questionId}]' value='0' />";
    }
    // only used for the answer type "Matching"
    if ($answerType == MATCHING && $nbrAnswers>0) {
        $cpt1 = 'A';
        $cpt2 = 1;
        $Select = array();
        $tool_content .= "
                      <table class='table-default'>
                      <tr>
                        <th>$langColumnA</th>
                        <th>$langMakeCorrespond</th>
                        <th>$langColumnB</th>
                      </tr>";
    }

    if ($answerType == FILL_IN_BLANKS || $answerType == FILL_IN_BLANKS_TOLERANT) {
        $tool_content .= "<div class='form-inline' style='line-height:2.2;'>";
    }

    for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
        $answer = $objAnswerTmp->selectAnswer($answerId);
        $answer = mathfilter($answer, 12, '../../courses/mathimg/');
        $answerCorrect = $objAnswerTmp->isCorrect($answerId);
        if ($answerType == FILL_IN_BLANKS || $answerType == FILL_IN_BLANKS_TOLERANT) {
            // splits text and weightings that are joined with the character '::'
            list($answer) = explode('::', $answer);
            // replaces [blank] by an input field
            $replace_callback = function () use ($questionId, $exerciseResult) {
                    static $id = 0;
                    $id++;
                    $value = (isset($exerciseResult[$questionId][$id])) ? 'value = '.$exerciseResult[$questionId][$id] : '';
                    return "<input type='text' style='line-height:normal;' name='choice[$questionId][$id]' $value>";
            };
            $answer = preg_replace_callback('/\[[^]]+\]/', $replace_callback, standard_text_escape(($answer)));
        }
        // unique answer
        if ($answerType == UNIQUE_ANSWER) {
            $checked = (isset($exerciseResult[$questionId]) && $exerciseResult[$questionId] == $answerId) ? 'checked="checked"' : '';
            $tool_content .= "
                        <div class='radio'>
                          <label>
                            <input type='radio' name='choice[${questionId}]' value='${answerId}' $checked>
                            " . standard_text_escape($answer) . "
                          </label>
                        </div>";
        }
        // multiple answers
        elseif ($answerType == MULTIPLE_ANSWER) {
            $checked = (isset($exerciseResult[$questionId][$answerId]) && $exerciseResult[$questionId][$answerId] == 1) ? 'checked="checked"' : '';
            $tool_content .= "
                        <div class='checkbox'>
                          <label>
                            <input type='checkbox' name='choice[${questionId}][${answerId}]' value='1' $checked>
                            " . standard_text_escape($answer) . "
                          </label>
                        </div>";
        }
        // fill in blanks
        elseif ($answerType == FILL_IN_BLANKS || $answerType == FILL_IN_BLANKS_TOLERANT) {
            $tool_content .= $answer;
        }
        // matching
        elseif ($answerType == MATCHING) {
            if (!$answerCorrect) {
                // options (A, B, C, ...) that will be put into the list-box
                $Select[$answerId]['Lettre'] = $cpt1++;
                // answers that will be shown at the right side
                $Select[$answerId]['Reponse'] = standard_text_escape($answer);
            } else {
                $tool_content .= "
				    <tr>
				      <td><b>${cpt2}.</b> " . standard_text_escape($answer) . "</td>
				      <td><div align='left'>
				       <select name='choice[${questionId}][${answerId}]'>
					 <option value='0'>--</option>";

                // fills the list-box
                foreach ($Select as $key => $val) {
                $selected = (isset($exerciseResult[$questionId][$answerId]) && $exerciseResult[$questionId][$answerId] == $key) ? 'selected="selected"' : '';
                    $tool_content .= "
					<option value=\"" . q($key) . "\" $selected>${val['Lettre']}</option>";
                }
                $tool_content .= "</select></div></td><td width='200'>";
                if (isset($Select[$cpt2])) {
                    $tool_content .= '<b>' . q($Select[$cpt2]['Lettre']) . '.</b> ' . $Select[$cpt2]['Reponse'];
                } else {
                    $tool_content .= '&nbsp;';
                }

                $tool_content .= "</td></tr>";
                $cpt2++;
                // if the left side of the "matching" has been completely shown
                if ($answerId == $nbrAnswers) {
                    // if it remains answers to shown at the right side
                    while (isset($Select[$cpt2])) {
                        $tool_content .= "
                                              <tr class='even'>
                                                <td colspan='2'>
                                                  <table width='100%'>
                                                  <tr>
                                                  <td width='200'>&nbsp;</td>
                                                  <td width='100'>&nbsp;</td>
                                                  <td width='200' valign='top'>" .
                                "<b>" . q($Select[$cpt2]['Lettre']) . ".</b> " . q($Select[$cpt2]['Reponse']) . "
                                                  </td>
                                                  </tr>
                                                  </table>
                                                </td>
                                              </tr>";
                        $cpt2++;
                    } // end while()
                }  // end if()
            }
        } elseif ($answerType == TRUE_FALSE) {
            $checked = (isset($exerciseResult[$questionId]) && $exerciseResult[$questionId] == $answerId) ? 'checked="checked"' : '';
            $tool_content .= "
                        <div class='radio'>
                          <label>
                            <input type='radio' name='choice[${questionId}]' value='${answerId}' $checked>
                            " . standard_text_escape($answer) . "
                          </label>
                        </div>";
        }
    } // end for()
    if ($answerType == MATCHING && $nbrAnswers>0) {
        $tool_content .= "</table>";
    }
    if ($answerType == FILL_IN_BLANKS || $answerType == FILL_IN_BLANKS_TOLERANT) {
        $tool_content .= "</div>";
    }
    if (!$nbrAnswers && $answerType != FREE_TEXT) {
        $tool_content .= "<div class='alert alert-danger'>$langNoAnswer</div>";
    }
    $tool_content .= "
                </div>
            </div>";
    // destruction of the Answer object
    unset($objAnswerTmp);
    // destruction of the Question object
    unset($objQuestionTmp);
    return $nbrAnswers;
}