Beispiel #1
0
     //checking if it is new or not
     $checkForExe = Database::get()->querySingle("SELECT * FROM exercise WHERE exercise.course_id = ?d " . "AND  exercise.active = 1 " . "AND exercise.id NOT IN (SELECT module_auto_id FROM gradebook_activities WHERE module_auto_type = 2) AND exercise.id = ?d", $course_id, $id);
     if ($checkForExe) {
         $module_auto_id = $checkForExe->id;
         $module_auto_type = 2;
         //one for assignments
         $module_auto = 1;
         $actTitle = $checkForExe->title;
         $actDate = $checkForExe->end_date;
         $actDesc = $checkForExe->description;
         Database::get()->query("INSERT INTO gradebook_activities SET gradebook_id = ?d, title = ?s, `date` = ?t, description = ?s, module_auto_id = ?d, auto = ?d, module_auto_type = ?d", $gradebook_id, $actTitle, $actDate, $actDesc, $module_auto_id, $module_auto, $module_auto_type);
         $sql = Database::get()->queryArray("SELECT uid FROM gradebook_users WHERE gradebook_id = ?d", $gradebook_id);
         foreach ($sql as $u) {
             $grd = Database::get()->querySingle("SELECT MAX(total_score) AS total_score, total_weighting FROM exercise_user_record \n                                            WHERE uid = {$u->uid} AND eid = ?d", $id);
             if ($grd) {
                 update_gradebook_book($u->uid, $id, $grd->total_score, 'exercise');
             }
         }
     }
 }
 //check the type of the module (3 for LP - scorm and exercises)
 if ($type == 3) {
     //checking if it is new or not
     $checkForLp = Database::get()->querySingle("SELECT \n                lp_module.module_id, lp_module.name, lp_module.contentType, lp_learnPath.name as lp_name\n                FROM lp_module, lp_rel_learnPath_module,lp_learnPath \n                WHERE lp_module.course_id = ?d \n                AND lp_module.module_id = lp_rel_learnPath_module.module_id\n                AND lp_rel_learnPath_module.learnPath_id = lp_learnPath.learnPath_id\n                AND lp_learnPath.visible = 1\n                AND lp_module.module_id = ?d\n                AND (lp_module.contentType = 'EXERCISE' OR lp_module.contentType = 'SCORM_ASSET' OR lp_module.contentType = 'SCORM')\n                AND lp_module.module_id NOT IN (SELECT module_auto_id FROM gradebook_activities WHERE module_auto_type = 3)", $course_id, $id);
     if ($checkForLp) {
         $module_auto_id = $checkForLp->module_id;
         $module_auto_type = 3;
         //3 for lp
         $module_auto = 1;
         $actTitle = $checkForLp->lp_name;
         $actDate = date("Y-m-d");
Beispiel #2
0
function submit_grades($grades_id, $grades, $email = false)
{
    global $tool_content, $langGrades, $langWorkWrongInput, $course_id;
    foreach ($grades as $sid => $grade) {
        $sid = intval($sid);
        $val = Database::get()->querySingle("SELECT grade from assignment_submit WHERE id = ?d", $sid)->grade;
        $grade_valid = filter_var($grade, FILTER_VALIDATE_FLOAT);
        isset($grade) && $grade_valid !== false ? $grade = $grade_valid : ($grade = NULL);
        if ($val != $grade) {
            if (Database::get()->query("UPDATE assignment_submit\n                                        SET grade = ?d, grade_submission_date = NOW(), grade_submission_ip = ?s\n                                        WHERE id = ?d", $grade, $_SERVER['REMOTE_ADDR'], $sid)->affectedRows > 0) {
                $assign_id = Database::get()->querySingle("SELECT assignment_id FROM assignment_submit WHERE id = ?d", $sid)->assignment_id;
                $title = Database::get()->querySingle("SELECT title FROM assignment WHERE assignment.id = ?d", $assign_id)->title;
                Log::record($course_id, MODULE_ID_ASSIGN, LOG_MODIFY, array('id' => $sid, 'title' => $title, 'grade' => $grade));
                //update gradebook if needed
                $quserid = Database::get()->querySingle("SELECT uid FROM assignment_submit WHERE id = ?d", $sid)->uid;
                update_gradebook_book($quserid, $assign_id, $grade, 'assignment');
                if ($email) {
                    grade_email_notify($grades_id, $sid, $grade, '');
                }
                Session::Messages($langGrades, 'alert-success');
            }
        }
    }
    show_assignment($grades_id);
}
Beispiel #3
0
function submit_grades($grades_id, $grades, $email = false) {
    global $tool_content, $langGrades, $langWorkWrongInput, $course_id,
           $course_code, $langFormErrors, $langTheField, $m;
    $assignment = Database::get()->querySingle("SELECT * FROM assignment WHERE id = ?d", $grades_id);
    $errors = [];

    foreach ($grades as $key => $grade) {
        $v = new Valitron\Validator($grade);
        $v->addRule('emptyOrNumeric', function($field, $value, array $params) {
            if(is_numeric($value) || empty($value)) return true;
        });
        $v->rule('emptyOrNumeric', array('grade'));
        $v->rule('min', array('grade'), 0);
        $v->rule('max', array('grade'), $assignment->max_grade);
        $v->labels(array(
            'grade' => "$langTheField $m[grade]"
        ));
        if(!$v->validate()) {
            $valitron_errors = $v->errors();
            $errors["grade.$key"] = $valitron_errors['grade'];
        }
    }
    if(empty($errors)) {
        foreach ($grades as $sid => $grade) {
            $sid = intval($sid);
            $val = Database::get()->querySingle("SELECT grade from assignment_submit WHERE id = ?d", $sid)->grade;

            $grade = is_numeric($grade['grade']) ? $grade['grade'] : null;

            if ($val !== $grade) {
                if (Database::get()->query("UPDATE assignment_submit
                                            SET grade = ?f, grade_submission_date = NOW(), grade_submission_ip = ?s
                                            WHERE id = ?d", $grade, $_SERVER['REMOTE_ADDR'], $sid)->affectedRows > 0) {
                    Log::record($course_id, MODULE_ID_ASSIGN, LOG_MODIFY, array('id' => $sid,
                            'title' => $assignment->title,
                            'grade' => $grade));

                    //update gradebook if needed
                    if ($assignment->group_submissions) {
                        $group_id = Database::get()->querySingle("SELECT group_id FROM assignment_submit WHERE id = ?d", $sid)->group_id;
                        $user_ids = Database::get()->queryArray("SELECT user_id FROM group_members WHERE group_id = ?d", $group_id);
                        foreach ($user_ids as $user_id) {
                            update_gradebook_book($user_id, $assignment->id, $grade/$assignment->max_grade, GRADEBOOK_ACTIVITY_ASSIGNMENT);
                        }
                    } else {                    
                        $quserid = Database::get()->querySingle("SELECT uid FROM assignment_submit WHERE id = ?d", $sid)->uid;
                        update_gradebook_book($quserid, $assignment->id, $grade/$assignment->max_grade, GRADEBOOK_ACTIVITY_ASSIGNMENT);
                    }

                    if ($email) {
                        grade_email_notify($grades_id, $sid, $grade, '');
                    }
                    Session::Messages($langGrades, 'alert-success');
                }
            }
        }
        Session::Messages($langGrades, 'alert-success');
    } else {
        Session::flashPost()->Messages($langFormErrors)->Errors($errors);
    }
    redirect_to_home_page("modules/work/index.php?course=$course_code&id=$grades_id");

}
Beispiel #4
0
     //If time expired in sequential exercise we must add to the DB the non-given answers
     // to the questions the student didn't had the time to answer
     if (isset($time_expired) && $time_expired && $exerciseType == 2) {
         $objExercise->save_unanswered();
     }
     $unmarked_free_text_nbr = Database::get()->querySingle("SELECT count(*) AS count FROM exercise_answer_record WHERE weight IS NULL AND eurid = ?d", $eurid)->count;
     $attempt_status = ($unmarked_free_text_nbr > 0) ? ATTEMPT_PENDING : ATTEMPT_COMPLETED;
     // record results of exercise
     Database::get()->query("UPDATE exercise_user_record SET record_end_date = ?t, total_score = ?f, attempt_status = ?d,
                             total_weighting = ?f, secs_remaining = ?d WHERE eurid = ?d", $record_end_date, $totalScore, $attempt_status, $totalWeighting, $secs_remaining, $eurid);
     
     if ($attempt_status == ATTEMPT_COMPLETED) {
         // update attendance book
         update_attendance_book($uid, $exerciseId, GRADEBOOK_ACTIVITY_EXERCISE);
         // update gradebook            
         update_gradebook_book($uid, $exerciseId, $totalScore/$totalWeighting, GRADEBOOK_ACTIVITY_EXERCISE);
     }
     unset($objExercise);
     unset_exercise_var($exerciseId);
     // if time expired set flashdata
     if (isset($time_expired) && $time_expired) {
         Session::Messages($langExerciseExpiredTime);
     } else {
         Session::Messages($langExerciseCompleted, 'alert-success');
     }
     redirect_to_home_page('modules/exercise/exercise_result.php?course='.$course_code.'&eurId='.$eurid);
 }
 // if the user has clicked on the "Save & Exit" button
 // keeps the exercise in a pending/uncompleted state and returns to the exercise list    
 if (isset($_POST['buttonSave']) && $exerciseTempSave) {
     $eurid = $_SESSION['exerciseUserRecordID'][$exerciseId][$attempt_value];
Beispiel #5
0
/**
 * @brief update grades from modules for given activity
 * @param type $gradebook_id
 * @param type $actID
 */
function update_grades($gradebook_id, $actID) {

    $sql = Database::get()->querySingle("SELECT module_auto_type, module_auto_id
                            FROM gradebook_activities WHERE id = ?d", $actID);
    if ($sql) {
        $activity_type = $sql->module_auto_type;
        $id = $sql->module_auto_id;
    }
    //get all the active users
    $q = Database::get()->queryArray("SELECT uid FROM gradebook_users WHERE gradebook_id = ?d", $gradebook_id);
    if ($q) {
        foreach ($q as $activeUsers) {
            update_gradebook_book($activeUsers->uid, $id, 0, $activity_type);
        }
    }
}
     $totalScore = Database::get()->querySingle("SELECT SUM(weight) FROM exercise_answer_record WHERE eurid = ?d", $eurid);
     $totalWeighting = $objExercise->selectTotalWeighting();
     //If time expired in sequential exercise we must add to the DB the non-given answers
     // to the questions the student didn't had the time to answer
     if (isset($time_expired) && $time_expired && $exerciseType == 2) {
         $objExercise->save_unanswered();
     }
     $unmarked_free_text_nbr = Database::get()->querySingle("SELECT count(*) AS count FROM exercise_answer_record WHERE weight IS NULL AND eurid = ?d", $eurid)->count;
     $attempt_status = $unmarked_free_text_nbr > 0 ? ATTEMPT_PENDING : ATTEMPT_COMPLETED;
     // record results of exercise
     Database::get()->query("UPDATE exercise_user_record SET record_end_date = ?t, total_score = ?f, attempt_status = ?d,\n                                total_weighting = ?f, secs_remaining = ?d WHERE eurid = ?d", $record_end_date, $totalScore, $attempt_status, $totalWeighting, $secs_remaining, $eurid);
     if ($attempt_status == ATTEMPT_COMPLETED) {
         // update attendance book
         update_attendance_book($exerciseId, 'exercise');
         // update gradebook
         update_gradebook_book($uid, $exerciseId, $totalScore, 'exercise');
     }
     unset($objExercise);
     unset_exercise_var($exerciseId);
     // if time expired set flashdata
     if (isset($time_expired) && $time_expired) {
         Session::Messages($langExerciseExpiredTime);
     }
     redirect_to_home_page('modules/exercise/exercise_result.php?course=' . $course_code . '&eurId=' . $eurid);
 }
 // if the user has clicked on the "Save & Exit" button
 // keeps the exercise in a pending/uncompleted state and returns to the exercise list
 if (isset($_POST['buttonSave']) && $exerciseTempSave) {
     $eurid = $_SESSION['exerciseUserRecordID'][$exerciseId];
     $secs_remaining = $_POST['secsRemaining'];
     $totalScore = Database::get()->querySingle("SELECT SUM(weight) FROM exercise_answer_record WHERE eurid = ?d", $eurid);
Beispiel #7
0
    </script>
</head>
<body>

    <nav class='navbar navbar-inverse navbar-static-top' role='navigation'>
            <div class='container-fluid'>
                <div class='navbar-header col-xs-2'>
                  <a id='leftTOCtoggler' class='btn pull-left'><i class='fa fa-bars fa-lg'></i></a>
                  <a id='toc_logo' class='navbar-brand hidden-xs' href='#'><img class='img-responsive' style='height:20px;' src='{$themeimg}/eclass-new-logo-small.png' alt='Logo'></a>
                </div>
                <div class='navbar-header col-xs-10 pull-right'>
                    <ul id='navigation-btns' class='nav navbar-nav navbar-right '>
                        $prevNextString
                        <li id='close-btn'><a href='$returl' target='_top'><i class='fa fa-times fa-lg'>&nbsp;<span class='hidden-xs'>$langLogout</span></i></a></li>
                    </ul>
                    <div class='pull-right progressbar-plr'>";

                         if ($uid) {
                            $path_id = (int) $_SESSION['path_id'];
                            $lpProgress = get_learnPath_progress($path_id, $uid);
                            update_gradebook_book($uid, $path_id, $lpProgress/100, GRADEBOOK_ACTIVITY_LP);
                            echo disp_progress_bar($lpProgress, 1);
                        }
echo "</div>
                </div>
            </div>
    </nav>
    </body>
</html>";