/**
 * Distributes students into groups randomly and creates a grouping with those 
 * groups.
 * 
 * You need to call groups_seed_random_number_generator() at some point in your 
 * script before calling this function. 
 * 
 * Note that this function does not distribute teachers into groups - this still 
 * needs to be done manually. 
 * 
 * @param int $courseid The id of the course that the grouping should belong to
 * @param int $nostudentspergroup The number of students to put in each group - 
 * this can be set to false if you prefer to specify the number of groups 
 * instead
 * @param int $nogroups The number of groups - this can be set to false if you 
 * prefer to specify the number of student in each group. If both are specified 
 * then $nostudentspergroup takes precedence. If neither is
 * specified then the function does nothing and returns false. 
 * @param boolean $distribevenly If $noofstudentspergroup is specified, then 
 * if this is set to true, any leftover students are distributed evenly among 
 * the groups, whereas if it is set to false then they are put in a separate 
 * group. 
 * @param object $groupsettings The default settings to give each group. 
 * This should contain prefix and defaultgroupdescription fields. The groups 
 * are named with the prefix followed by 1, 2, etc. and given the
 * default group description set. 
 * @param int $groupid If this is not set to false, then only students in the 
 * specified group are distributed into groups, not all the students enrolled on 
 * the course. 
 * @param boolean $alphabetical If this is set to true, then the students are 
 * not distributed randomly but in alphabetical order of last name. 
 * @return int The id of the grouping
 */
function groups_create_automatic_grouping($courseid, $nostudentspergroup, $nogroups, $distribevenly, $groupingsettings, $groupid = false, $alphabetical = false)
{
    if (!$nostudentspergroup and !$noteacherspergroup and !$nogroups) {
        $groupingid = false;
    } else {
        // Set $userids to the list of students that we want to put into groups
        // in the grouping
        if (!$groupid) {
            $users = get_course_students($courseid);
            $userids = groups_users_to_userids($users);
        } else {
            $userids = groups_get_members($groupid);
        }
        // Distribute the users into sets according to the parameters specified
        $userarrays = groups_distribute_in_random_sets($userids, $nostudentspergroup, $nogroups, $distribevenly, !$alphabetical);
        if (!$userarrays) {
            $groupingid = false;
        } else {
            // Create the grouping that the groups we create will go into
            $groupingid = groups_create_grouping($courseid, $groupingsettings);
            // Get the prefix for the names of each group and default group
            // description to give each group
            if (!$groupingsettings->prefix) {
                $prefix = get_string('defaultgroupprefix', 'groups');
            } else {
                $prefix = $groupingsettings->prefix;
            }
            if (!$groupingsettings->defaultgroupdescription) {
                $defaultgroupdescription = '';
            } else {
                $defaultgroupdescription = $groupingsettings->defaultgroupdescription;
            }
            // Now create a group for each set of students, add the group to the
            // grouping and then add the students
            $i = 1;
            foreach ($userarrays as $userids) {
                $groupsettings->name = $prefix . ' ' . $i;
                $groupsettings->description = $defaultgroupdescription;
                $i++;
                $groupid = groups_create_group($courseid, $groupsettings);
                $groupadded = groups_add_group_to_grouping($groupid, $groupingid);
                if (!$groupid or !$groupadded) {
                    $groupingid = false;
                } else {
                    if ($userids) {
                        foreach ($userids as $userid) {
                            $usersadded = groups_add_member($groupid, $userid);
                            // If unsuccessful just carry on I guess
                        }
                    }
                }
            }
        }
    }
    return $groupingid;
}
// these are ones that have been checked and submitted to the page
if (isset($_REQUEST['read'])) {
    $read = $_REQUEST['read'];
} else {
    $read = array();
}
if (isset($_REQUEST['write'])) {
    $write = $_REQUEST['write'];
} else {
    $write = array();
}
// either grab all the students or grab all the students in a given group
if ($groupid != -1) {
    $students = get_group_users($groupid, 'u.firstname ASC, u.lastname ASC');
} else {
    $students = get_course_students($courseid, "u.firstname ASC, u.lastname ASC", "", 0, 99999, '', '', NULL, '', 'u.id,u.firstname,u.lastname');
}
if (!($groups = get_groups($courseid))) {
    $groups = array();
}
// dont think we need to pass anything here... ?
print_header("", "", "", "", "", true, "");
print_heading(get_string('permissions', 'netpublish'), 'center', 3);
// start the form off
echo "<form method=\"post\" action=\"permissions.php\" name=\"theform\" id=\"theform\">\n    <input type=\"hidden\" name=\"id\" value=\"{$courseid}\" />\n    <input type=\"hidden\" name=\"groupid\" value=\"\" />";
// making tabs
$tabs = array();
$tabrows = array();
// this tab is for viewing all the students
$tabrows[] = new tabobject(-1, "javascript:document.theform.groupid.value=-1; document.theform.submit();", get_string('viewall', 'netpublish'));
// create a tab foreach group
Example #3
0
            $entrybyuser[$entry->userid]->rating = $vals['r'];
            $entrybyuser[$entry->userid]->entrycomment = $vals['c'];
            $entrybyuser[$entry->userid]->teacher = $USER->id;
            $entrybyuser[$entry->userid]->timemarked = $timenow;
        }
    }
    add_to_log($course->id, "journal", "update feedback", "report.php?id={$cm->id}", "{$count} users", $cm->id);
    notify(get_string("feedbackupdated", "journal", "{$count}"), "green");
} else {
    add_to_log($course->id, "journal", "view responses", "report.php?id={$cm->id}", "{$journal->id}", $cm->id);
}
/// Print out the journal entries
if ($currentgroup) {
    $users = get_group_users($currentgroup);
} else {
    $users = get_course_students($course->id);
}
if (!$users) {
    print_heading(get_string("nousersyet"));
} else {
    $grades = make_grades_menu($journal->assessed);
    $teachers = get_course_teachers($course->id);
    $allowedtograde = ($groupmode != VISIBLEGROUPS or isteacheredit($course->id) or ismember($currentgroup));
    if ($allowedtograde) {
        echo '<form action="report.php" method="post">';
    }
    if ($usersdone = journal_get_users_done($journal)) {
        foreach ($usersdone as $user) {
            if ($currentgroup) {
                if (!ismember($currentgroup, $user->id)) {
                    /// Yes, it's inefficient, but this module will die
/**
 * Unlock messages in the NanoGong database.
 **/
function nanogong_unlock_all_messages($nanogong, $groupid)
{
    global $CFG, $USER;
    if (!isteacheredit($nanogong->course)) {
        return false;
    }
    if (empty($groupid)) {
        $students = get_course_students($nanogong->course, "u.lastname, u.firstname");
    } else {
        $students = get_course_students($nanogong->course, "u.lastname, u.firstname", '', '', '', '', '', $groupid);
    }
    if (!$students) {
        $students = array();
    }
    foreach ($students as $student) {
        $nanogong_messages = get_records_select("nanogong_message", "nanogongid={$nanogong->id} AND userid={$student->id}");
        if (!$nanogong_messages) {
            $nanogong_messages = array();
        }
        foreach ($nanogong_messages as $nanogong_message) {
            $nanogong_message->locked = 0;
            update_record("nanogong_message", $nanogong_message);
        }
    }
    return true;
}
Example #5
0
function hotpot_get_report_users($course, $formdata)
{
    $users = array();
    /// Check to see if groups are being used in this module
    $groupmode = groupmode($course, $cm);
    //TODO: there is no $cm defined!
    $currentgroup = setup_and_print_groups($course, $groupmode, "report.php?id={$cm->id}&mode=simple");
    $sort = "u.lastname ASC";
    switch ($formdata['reportusers']) {
        case 'students':
            if ($currentgroup) {
                $users = get_group_students($currentgroup, $sort);
            } else {
                $users = get_course_students($course->id, $sort);
            }
            break;
        case 'all':
            if ($currentgroup) {
                $users = get_group_users($currentgroup, $sort);
            } else {
                $users = get_course_users($course->id, $sort);
            }
            break;
    }
    return $users;
}
     redirect("view.php?id={$cm->id}", get_string('nopersonchosen', 'dialogue'));
 } else {
     if (substr($params->recipientid, 0, 1) == 'g') {
         // it's a group
         $groupid = intval(substr($params->recipientid, 1));
         $sql = "SELECT MAX(grouping)+1 AS grouping from {$CFG->prefix}dialogue_conversations";
         $grouping = get_field_sql($sql);
         if (!$grouping) {
             $grouping = 1;
         }
         if ($groupid) {
             // it's a real group
             $recipients = get_records_sql("SELECT u.*" . " FROM {$CFG->prefix}user u," . " {$CFG->prefix}groups_members g" . " WHERE g.groupid = {$groupid} " . " AND u.id = g.userid");
         } else {
             // it's all participants
             $recipients = get_course_students($course->id);
         }
     } else {
         $recipients[$params->recipientid] = get_record('user', 'id', $params->recipientid);
         $groupid = 0;
         $grouping = 0;
     }
     if ($recipients) {
         $n = 0;
         foreach ($recipients as $recipient) {
             if ($recipient->id == $USER->id) {
                 // teacher could be member of a group
                 continue;
             }
             if (empty($params->firstentry)) {
                 redirect("view.php?id={$cm->id}", get_string('notextentered', 'dialogue'));
Example #7
0
/**
* @desc Contacts webwork to find out the completion status of a problem set for all users in a course.
* @param integer $wwassignmentid The problem set
* @return object The student grades indexed by student ID.
*/
function wwassignment_grades($wwassignmentid)
{
    //	error_log("Begin wwassignment_grades -- legacy function?");
    global $COURSE, $DB;
    $wwclient = new wwassignment_client();
    $wwassignment = $DB->get_record('wwassignment', array('id' => $wwassignmentid));
    $courseid = $wwassignment->course;
    $studentgrades = new stdClass();
    $studentgrades->grades = array();
    $studentgrades->maxgrade = 0;
    $gradeformula = '$finalgrade += ($problem->status > 0) ? 1 : 0;';
    $wwcoursename = _wwassignment_mapped_course($courseid, false);
    $wwsetname = _wwassignment_mapped_set($wwassignmentid, false);
    // enumerate over the students in the course:
    $students = get_course_students($courseid);
    $usernamearray = array();
    foreach ($students as $student) {
        array_push($usernamearray, $student->username);
    }
    $gradearray = $wwclient->grade_users_sets($wwcoursename, $usernamearray, $wwsetname);
    $i = 0;
    foreach ($students as $student) {
        $studentgrades->grades[$student->id] = $gradearray[$i];
        $i++;
    }
    $studentgrades->maxgrade = $wwclient->get_max_grade($wwcoursename, $wwsetname);
    //    error_log("End wwassignment_grades -- legacy function?");
    return $studentgrades;
}
Example #8
0
            if (isadmin()) {
                $mygroupid = false;
                $SESSION->lstgroupid = false;
            } else {
                $mygroupid = mygroupid($course->id);
            }
        } else {
            $mygroupid = $SESSION->lstgroupid;
        }
        if ($mygroupid) {
            $students = get_group_students($mygroupid, 'u.lastname ASC');
        } else {
            $students = get_course_students($course->id, $sort = "u.lastname", $dir = "ASC");
        }
    } else {
        $students = get_course_students($course->id, $sort = "u.lastname", $dir = "ASC");
    }
    $mygroupid = isset($mygroupid) ? $mygroupid : NULL;
    $completedFeedbackCount = get_completeds_group_count($feedback, $mygroupid);
    echo '<div align="center"><a href="analysis.php?id=' . $id . '">';
    echo get_string('analysis', 'feedback') . ' (' . get_string('completed_feedbacks', 'feedback') . ': ' . $completedFeedbackCount . ')</a>';
    echo '</div>';
}
echo '<p>';
print_simple_box_start('center');
if (isteacher($course->id) || isadmin()) {
    echo '<div align="center">';
    echo '<form action="edit.php?id=' . $id . '" method="post">';
    echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />';
    echo '<input type="hidden" name="id" value="' . $id . '" />';
    echo '<button type="submit">' . get_string('edit_items', 'feedback') . '</button>';
         error(get_string('theCOurseNowNoStudent6', 'block_report_module'));
     } else {
         if ($course = $DB->get_record('course', array('id' => $courseID))) {
             $userPass = true;
             $timeDifferent = getTimeDifferent($dateform);
             $courseUserLogData = produceUserCourseLog($userID, $courseID, $timeDifferent);
             $courseUserArray[$courseID] = produceCourseUserArray($userID, $courseID, $courseUserLogData, $userPass);
             $userPassArray[$courseID] = $userPass;
         } else {
             error(get_string('pleaseSelectRightCourseName6', 'block_report_module'));
         }
     }
 } else {
     $courses = reportmycoursesdata($userID);
     foreach ($courses as $theCourseID => $theCourseName) {
         if (get_course_students($theCourseID)) {
             //!the course no student
             if ($DB->get_record('reportmodule', array('courseid' => $theCourseID))) {
                 //!the course don't setup stardard
                 if ($courseActionItem = getCourseActionItem($theCourseID)) {
                     //!the course no action
                     $userPass = true;
                     $timeDifferent = getTimeDifferent($dateform);
                     $courseUserLogData = produceUserCourseLog($userID, $theCourseID, $timeDifferent);
                     $courseUserArray[$theCourseID] = produceCourseUserArray($userID, $theCourseID, $courseUserLogData, $userPass);
                     $userPassArray[$theCourseID] = $userPass;
                 }
             }
         }
     }
     if (!$courseUserArray) {
Example #10
0
/**
 * Must return an array of grades for a given instance of this module, 
 * indexed by user.  It also returns a maximum allowed grade.
 * 
 * Example:
 *    $return->grades = array of grades;
 *    $return->maxgrade = maximum allowed grade;
 *
 *    return $return;
 *
 * @param int $modid ID of an instance of this module
 * @return mixed Null or object with an array of grades and with the maximum grade
 **/
function nanogong_grades($modid)
{
    if (!($nanogong = get_record('nanogong', 'id', $modid))) {
        return null;
    }
    $grades = array();
    $students = get_course_students($nanogong->course);
    $nanogong_messages = get_records("nanogong_message", "nanogongid", $nanogong->id);
    if ($students != null) {
        foreach ($students as $student) {
            $grade = "-";
            if ($nanogong_messages) {
                $count = 0;
                foreach ($nanogong_messages as $nanogong_message) {
                    if ($nanogong_message->userid != $student->id) {
                        continue;
                    }
                    if ($grade == "-") {
                        $grade = $nanogong_message->score;
                    } else {
                        $grade += $nanogong_message->score;
                    }
                    $count++;
                }
                if ($count > 0) {
                    $grade = $grade / $count;
                }
            }
            $grades[$student->id] = $grade;
        }
    }
    $return->grades = $grades;
    $return->maxgrade = $nanogong->maxscore;
    return $return;
}
Example #11
0
function webquest_grades($webquestid)
{
    $return = null;
    if ($webquest = get_record("webquest", "id", $webquestid)) {
        if ($webquest->gradingstrategy > 0) {
            if (!$webquest->teamsmode) {
                if ($students = get_course_students($webquest->course)) {
                    foreach ($students as $student) {
                        $submission = get_record("webquest_submissions", "webquestid", $webquest->id, "userid", $student->id);
                        if (count_records("webquest_grades", "sid", $submission->id)) {
                            $grade = number_format($submission->grade * $webquest->grade / 100);
                        } else {
                            $grade = null;
                        }
                        $return->grades[$student->id] = $grade;
                    }
                }
            } else {
                if ($students = get_course_students($webquest->course)) {
                    if ($submissionsraw = get_records("webquest_submissions", "webquestid", $webquest->id)) {
                        require_once "locallib.php";
                        foreach ($submissionsraw as $submission) {
                            if (count_records("webquest_grades", "sid", $submission->id)) {
                                $grade = number_format($submission->grade * $webquest->grade / 100);
                            } else {
                                $grade = null;
                            }
                            if ($membersid = webquest_get_team_members($submission->userid)) {
                                foreach ($membersid as $memberid) {
                                    $return->grades[$memberid] = $grade;
                                }
                            }
                        }
                    }
                }
            }
            $return->maxgrade = $webquest->grade;
        }
    }
    return $return;
}
 function cron()
 {
     global $DB;
     $status = true;
     require_once 'lib/function.php';
     if ($courses = $DB->get_records_select('reportmodule', array())) {
         $output = '';
         $separate = ',';
         foreach ($courses as $course) {
             $courseUserArray = array();
             $userPassArray = array();
             $userIDDataArray = array();
             $actionIDNameArray = array();
             $courseID = $course->courseid;
             $students = get_course_students($courseID);
             $timeDifferent = getTimeDifferent('all');
             if ($students) {
                 foreach ($students as $theUserID => $theStudentObj) {
                     if (!$DB->get_record('user', array('id' => $theUserID))) {
                         break;
                     }
                     $userPass = true;
                     $courseUserLogData = produceUserCourseLog($theUserID, $courseID, $timeDifferent);
                     $courseUserArray[$theUserID] = produceCourseUserArray($theUserID, $courseID, $courseUserLogData, $userPass);
                     $userPassArray[$theUserID] = $userPass;
                 }
             }
             /*
             $category = $DB->get_record('course_categories', array('id'=>$course->category));
             $categoryName = format_string($category->name);
             */
             $course = $DB->get_record('course', array('id' => $courseID));
             $courseName = format_string($course->fullname);
             foreach ($courseUserArray as $theUserID => $courseUserData) {
                 $user = $DB->get_record('user', array('id' => $theUserID));
                 $userIDDataArray[$theUserID] = array();
                 $userIDDataArray[$theUserID]['name'] = $user->firstname . $user->lastname;
                 $userIDDataArray[$theUserID]['description'] = $user->description;
                 $userIDDataArray[$theUserID]['email'] = $user->email;
                 foreach ($courseUserData as $courseUserActionID => $courseUserActionContent) {
                     $actionIDNameArray[$courseUserActionID] = getCourseActionModName($courseUserActionID) ? getCourseActionModName($courseUserActionID) : get_string('courseTime3', 'reportmodule');
                 }
             }
             foreach ($courseUserArray as $userID => $actionInfo) {
                 $output .= $course->id . $separate;
                 $output .= $course->fullname . $separate;
                 //$output .= $userIDDataArray[$userID]['name'] . $separate;
                 //$output .= $userIDDataArray[$userID]['description'] . $separate;
                 $output .= $userIDDataArray[$userID]['email'] . $separate;
                 $passType = 0;
                 $coursePass = false;
                 $courseTime = 0;
                 $courseDate = '';
                 $actionPass = false;
                 $actionScore = 0;
                 $actionDate = 0;
                 $actionQuiz = 0;
                 foreach ($actionInfo as $actionID => $actionContent) {
                     if ($actionID == 'course') {
                         if ($actionContent['timeEnable']) {
                             $coursePass = $actionContent['timePass'];
                             $courseTime = $actionContent['time'];
                             $courseDate = $actionContent['date'] ? date('Y/m/d', $actionContent['date']) : '';
                             $passType += 1;
                         }
                     }
                     if ($actionContent['timeEnable']) {
                         //$output .= $actionContent['time'] . $separate;
                     }
                     if ($actionContent['scoreEnable']) {
                         //$output .= $actionContent['score'] . $separate;
                         // First Quiz
                         if ($actionContent['itemmodule'] == 'quiz' && !$actionQuiz) {
                             $actionPass = $actionContent['scorePass'];
                             $actionScore = $actionContent['score'];
                             $actionDate = $actionContent['scoreDate'] ? date('Y/m/d', $actionContent['scoreDate']) : '';
                             $actionQuiz++;
                             $passType += 2;
                         }
                     }
                     if ($actionContent['timePass'] and $actionContent['scorePass']) {
                         //$output .= '通過' . $separate;
                     } else {
                         //$output .= '不通過' . $separate;
                     }
                 }
                 //$output .= $userPassArray[$userID]?'通過':'不通過';
                 $output .= $passType . $separate . ($coursePass ? '1' : '0') . $separate . ($actionPass ? '1' : '0') . $separate . $courseTime . $separate . $actionScore . $separate . $courseDate . $separate . $actionDate;
                 $output .= "\r\n";
             }
         }
     }
     $temp = tmpfile();
     fwrite($temp, $output);
     fseek($temp, 0);
     $meta_data = stream_get_meta_data($temp);
     $filename = $meta_data["uri"];
     // FTP access parameters
     $host = 'FTP_HOST';
     $usr = '******';
     $pwd = 'FTP_PASSWORD';
     // file to move:
     $local_file = $filename;
     $ftp_path = '/report_' . date('j') . '.txt';
     // connect to FTP server (port 21)
     $conn_id = ftp_connect($host, 21) or die("Cannot connect to host");
     // send access parameters
     ftp_login($conn_id, $usr, $pwd) or die("Cannot login");
     // turn on passive mode transfers (some servers need this)
     ftp_pasv($conn_id, true);
     // perform file upload
     $upload = ftp_put($conn_id, $ftp_path, $local_file, FTP_ASCII);
     // check upload status:
     print !$upload ? 'Cannot upload' : 'Upload complete';
     print "\n";
     /*
      ** Chmod the file (just as example)
      */
     // If you are using PHP4 then you need to use this code:
     // (because the "ftp_chmod" command is just available in PHP5+)
     if (!function_exists('ftp_chmod')) {
         function ftp_chmod($ftp_stream, $mode, $filename)
         {
             return ftp_site($ftp_stream, sprintf('CHMOD %o %s', $mode, $filename));
         }
     }
     // try to chmod the new file to 666 (writeable)
     if (ftp_chmod($conn_id, 0666, $ftp_path) !== false) {
         print $ftp_path . " chmoded successfully to 666\n";
     } else {
         print "could not chmod {$file}\n";
     }
     // close the FTP stream
     ftp_close($conn_id);
     fclose($temp);
     // this removes the file
     return $status;
 }
Example #13
0
function exercise_list_submissions_for_admin($exercise)
{
    // list the teacher sublmissions first
    global $CFG, $USER;
    if (!($course = get_record("course", "id", $exercise->course))) {
        error("Course is misconfigured");
    }
    if (!($cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id))) {
        error("Course Module ID was incorrect");
    }
    $groupid = get_current_group($course->id);
    exercise_print_assignment_info($exercise);
    print_heading_with_help(get_string("administration"), "administration", "exercise");
    echo "<p align=\"center\"><b><a href=\"assessments.php?action=teachertable&amp;id={$cm->id}\">" . get_string("teacherassessmenttable", "exercise", $course->teacher) . "</a></b></p>\n";
    if (isteacheredit($course->id)) {
        // list any teacher submissions
        $table->head = array(get_string("title", "exercise"), get_string("submitted", "exercise"), get_string("action", "exercise"));
        $table->align = array("left", "left", "left");
        $table->size = array("*", "*", "*");
        $table->cellpadding = 2;
        $table->cellspacing = 0;
        if ($submissions = exercise_get_teacher_submissions($exercise)) {
            foreach ($submissions as $submission) {
                $action = "<a href=\"submissions.php?action=adminamendtitle&amp;id={$cm->id}&amp;sid={$submission->id}\">" . get_string("amendtitle", "exercise") . "</a>";
                if (isteacheredit($course->id)) {
                    $action .= " | <a href=\"submissions.php?action=adminconfirmdelete&amp;id={$cm->id}&amp;sid={$submission->id}\">" . get_string("delete", "exercise") . "</a>";
                }
                $table->data[] = array(exercise_print_submission_title($exercise, $submission), userdate($submission->timecreated), $action);
            }
            print_heading(get_string("studentsubmissions", "exercise", $course->teacher), "center");
            print_table($table);
        }
    }
    // list student assessments
    // Get all the students...
    if ($users = get_course_students($course->id, "u.lastname, u.firstname")) {
        $timenow = time();
        unset($table);
        $table->head = array(get_string("name"), get_string("title", "exercise"), get_string("assessed", "exercise"), get_string("action", "exercise"));
        $table->align = array("left", "left", "left", "left");
        $table->size = array("*", "*", "*", "*");
        $table->cellpadding = 2;
        $table->cellspacing = 0;
        $nassessments = 0;
        foreach ($users as $user) {
            // check group membership, if necessary
            if ($groupid) {
                // check user's group
                if (!groups_is_member($groupid, $user->id)) {
                    continue;
                    // skip this user
                }
            }
            if ($assessments = exercise_get_user_assessments($exercise, $user)) {
                $title = '';
                foreach ($assessments as $assessment) {
                    if (!($submission = get_record("exercise_submissions", "id", $assessment->submissionid))) {
                        error("exercise_list_submissions_for_admin: Submission record not found!");
                    }
                    $title .= $submission->title;
                    // test for allocated assesments which have not been done
                    if ($assessment->timecreated < $timenow) {
                        // show only warm or cold assessments
                        $title .= " {" . number_format($assessment->grade * $exercise->grade / 100.0, 0);
                        if ($assessment->timegraded) {
                            $title .= "/" . number_format($assessment->gradinggrade * $exercise->gradinggrade / 100.0, 0);
                        }
                        $title .= "} ";
                        if ($realassessments = exercise_count_user_assessments_done($exercise, $user)) {
                            $action = "<a href=\"assessments.php?action=adminlistbystudent&amp;id={$cm->id}&amp;userid={$user->id}\">" . get_string("view", "exercise") . "</a>";
                        } else {
                            $action = "";
                        }
                        $nassessments++;
                        $table->data[] = array(fullname($user), $title, userdate($assessment->timecreated), $action);
                    }
                }
            }
        }
        if (isset($table->data)) {
            if ($groupid) {
                if (!groups_group_exists($groupid)) {
                    //TODO:
                    error("List unassessed student submissions: group not found");
                }
                print_heading("{$group->name} " . get_string("studentassessments", "exercise", $course->student) . " [{$nassessments}]");
            } else {
                print_heading(get_string("studentassessments", "exercise", $course->student) . " [{$nassessments}]");
            }
            print_table($table);
            echo "<p align=\"center\">" . get_string("noteonstudentassessments", "exercise");
            echo "<br />{" . get_string("maximumgrade") . ": {$exercise->grade} / " . get_string("maximumgrade") . ": {$exercise->gradinggrade}}</p>\n";
            // grading grade analysis
            unset($table);
            $table->head = array(get_string("count", "exercise"), get_string("mean", "exercise"), get_string("standarddeviation", "exercise"), get_string("maximum", "exercise"), get_string("minimum", "exercise"));
            $table->align = array("center", "center", "center", "center", "center");
            $table->size = array("*", "*", "*", "*", "*");
            $table->cellpadding = 2;
            $table->cellspacing = 0;
            if ($groupid) {
                $stats = get_record_sql("SELECT COUNT(*) as count, AVG(gradinggrade) AS mean, \n                        STDDEV(gradinggrade) AS stddev, MIN(gradinggrade) AS min, MAX(gradinggrade) AS max \n                        FROM {$CFG->prefix}groups_members g, {$CFG->prefix}exercise_assessments a \n                        WHERE g.groupid = {$groupid} AND a.userid = g.userid AND a.timegraded > 0 \n                        AND a.exerciseid = {$exercise->id}");
            } else {
                // no group/all participants
                $stats = get_record_sql("SELECT COUNT(*) as count, AVG(gradinggrade) AS mean, \n                        STDDEV(gradinggrade) AS stddev, MIN(gradinggrade) AS min, MAX(gradinggrade) AS max \n                        FROM {$CFG->prefix}exercise_assessments a \n                        WHERE a.timegraded > 0 AND a.exerciseid = {$exercise->id}");
            }
            $table->data[] = array($stats->count, number_format($stats->mean * $exercise->gradinggrade / 100.0, 1), number_format($stats->stddev * $exercise->gradinggrade / 100.0, 1), number_format($stats->max * $exercise->gradinggrade / 100.0, 1), number_format($stats->min * $exercise->gradinggrade / 100.0, 1));
            print_heading(get_string("gradinggrade", "exercise") . " " . get_string("analysis", "exercise"));
            print_table($table);
            echo "<p align=\"center\"><a href=\"assessments.php?id={$cm->id}&amp;action=regradestudentassessments\">" . get_string("regradestudentassessments", "exercise") . "</a> ";
            helpbutton("regrading", get_string("regradestudentassessments", "exercise"), "exercise");
            echo "</p>\n";
        }
    }
    // now the sudent submissions
    unset($table);
    if ($users) {
        $table->head = array(get_string("submittedby", "exercise"), get_string("title", "exercise"), get_string("submitted", "exercise"), get_string("action", "exercise"));
        $table->align = array("left", "left", "left", "left");
        $table->size = array("*", "*", "*", "*");
        $table->cellpadding = 2;
        $table->cellspacing = 0;
        $nsubmissions = 0;
        foreach ($users as $user) {
            // check group membership, if necessary
            if ($groupid) {
                // check user's group
                if (!groups_is_member($groupid, $user->id)) {
                    continue;
                    // skip this user
                }
            }
            if ($submissions = exercise_get_user_submissions($exercise, $user)) {
                foreach ($submissions as $submission) {
                    $action = "<a href=\"submissions.php?action=adminamendtitle&amp;id={$cm->id}&amp;sid={$submission->id}\">" . get_string("amendtitle", "exercise") . "</a>";
                    // has teacher already assessed this submission
                    if ($assessment = get_record_select("exercise_assessments", "submissionid = {$submission->id} AND userid = {$USER->id}")) {
                        $curtime = time();
                        if ($curtime - $assessment->timecreated > $CFG->maxeditingtime) {
                            $action .= " | <a href=\"assessments.php?action=assesssubmission&amp;id={$cm->id}&amp;sid={$submission->id}\">" . get_string("reassess", "exercise") . "</a>";
                        } else {
                            // there's still time left to edit...
                            $action .= " | <a href=\"assessments.php?action=assesssubmission&amp;id={$cm->id}&amp;sid={$submission->id}\">" . get_string("edit", "exercise") . "</a>";
                        }
                    } else {
                        // user has not assessed this submission
                        $action .= " | <a href=\"assessments.php?action=assesssubmission&amp;id={$cm->id}&amp;sid={$submission->id}\">" . get_string("assess", "exercise") . "</a>";
                    }
                    if ($nassessments = exercise_count_assessments($submission)) {
                        $action .= " | <a href=\"assessments.php?action=adminlist&amp;id={$cm->id}&amp;sid={$submission->id}\">" . get_string("view", "exercise") . " ({$nassessments})</a>";
                    }
                    if ($submission->late) {
                        $action .= " | <a href=\"submissions.php?action=adminlateflag&amp;id={$cm->id}&amp;sid={$submission->id}\">" . get_string("clearlateflag", "exercise") . "</a>";
                    }
                    $action .= " | <a href=\"submissions.php?action=adminconfirmdelete&amp;id={$cm->id}&amp;sid={$submission->id}\">" . get_string("delete", "exercise") . "</a>";
                    $title = $submission->title;
                    if ($submission->resubmit) {
                        $title .= "*";
                    }
                    $datesubmitted = userdate($submission->timecreated);
                    if ($submission->late) {
                        $datesubmitted = "<font color=\"red\">" . $datesubmitted . "</font>";
                    }
                    $table->data[] = array(fullname($user), $title . " " . exercise_print_submission_assessments($exercise, $submission), $datesubmitted, $action);
                    $nsubmissions++;
                }
            }
        }
        if (isset($table->data)) {
            if ($groupid) {
                if (!groups_group_exists($groupid)) {
                    error("List unassessed student submissions: group not found");
                }
                print_heading("{$group->name} " . get_string("studentsubmissions", "exercise", $course->student) . " [{$nsubmissions}]");
            } else {
                print_heading(get_string("studentsubmissions", "exercise", $course->student) . " [{$nsubmissions}]", "center");
            }
            print_table($table);
            echo "<p align=\"center\">[] - " . get_string("gradeforsubmission", "exercise");
            echo "<br />" . get_string("maximumgrade") . ": {$exercise->grade}</p>\n";
            echo "<p align=\"center\">" . get_string("resubmitnote", "exercise", $course->student) . "</p>\n";
            // grade analysis
            unset($table);
            $table->head = array(get_string("count", "exercise"), get_string("mean", "exercise"), get_string("standarddeviation", "exercise"), get_string("maximum", "exercise"), get_string("minimum", "exercise"));
            $table->align = array("center", "center", "center", "center", "center");
            $table->size = array("*", "*", "*", "*", "*");
            $table->cellpadding = 2;
            $table->cellspacing = 0;
            /// NOTE:  user_teachers was ripped from the following SQL without a proper fix - XXX TO DO
            if ($groupid) {
                $stats = get_record_sql("SELECT COUNT(*) as count, AVG(grade) AS mean, \n                        STDDEV(grade) AS stddev, MIN(grade) AS min, MAX(grade) AS max \n                        FROM {$CFG->prefix}groups_members g, {$CFG->prefix}exercise_assessments a, \n                        {$CFG->prefix}exercise_submissions s\n                        WHERE g.groupid = {$groupid} AND s.userid = g.userid AND a.submissionid = s.id \n                        AND a.exerciseid = {$exercise->id}");
            } else {
                // no group/all participants
                $stats = get_record_sql("SELECT COUNT(*) as count, AVG(grade) AS mean, \n                        STDDEV(grade) AS stddev, MIN(grade) AS min, MAX(grade) AS max \n                        FROM {$CFG->prefix}exercise_assessments a\n                        WHERE a.exerciseid = {$exercise->id}");
            }
            $table->data[] = array($stats->count, number_format($stats->mean * $exercise->grade / 100.0, 1), number_format($stats->stddev * $exercise->grade / 100.0, 1), number_format($stats->max * $exercise->grade / 100.0, 1), number_format($stats->min * $exercise->grade / 100.0, 1));
            print_heading(get_string("grade") . " " . get_string("analysis", "exercise"));
            print_table($table);
        }
    }
}
Example #14
0
/**
* @desc Contacts webwork to find out the completion status of a problem set for all users in a course.
* @param integer $wwassignmentid The problem set
* @return object The student grades indexed by student ID.
*/
function wwassignment_grades($wwassignmentid)
{
    global $COURSE;
    $wwclient = new wwassignment_client();
    $studentgrades = new stdClass();
    $studentgrades->grades = array();
    $studentgrades->maxgrade = 0;
    $gradeformula = '$finalgrade += ($problem->status > 0) ? 1 : 0;';
    $wwcoursename = _wwassignment_mapped_course($COURSE->id, false);
    $wwsetname = _wwassignment_mapped_set($wwassignmentid, false);
    // enumerate over the students in the course:
    $students = get_course_students($COURSE->id);
    $usernamearray = array();
    foreach ($students as $student) {
        array_push($usernamearray, $student->username);
    }
    $gradearray = $wwclient->grade_users_sets($wwcoursename, $usernamearray, $wwsetname);
    $i = 0;
    foreach ($students as $student) {
        $studentgrades->grades[$student->id] = $gradearray[$i];
        $i++;
    }
    $studentgrades->maxgrade = $wwclient->get_max_grade($wwcoursename, $wwsetname);
    return $studentgrades;
}
Example #15
0
 function build_facstu_list_table($interview, $cm, $course)
 {
     global $DB, $OUTPUT;
     $strstudent = get_string('student', 'interview');
     $strphoto = get_string('photo', 'interview');
     $stremail = get_string('email', 'interview');
     // collects the students in the course
     $students = get_course_students($course->id, $sort = "u.lastname", $dir = "ASC");
     // If there are no students, will notify
     if (!$students) {
         $OUTPUT->notify(get_string('noexistingstudents'));
         // If there are students, creates a table with the users
         // that have not picked a horary string
     } else {
         // Defines the headings and alignments in the table of students
         $stu_list_table = new html_table();
         $stu_list_table->head = array($strphoto, $strstudent, $stremail);
         $stu_list_table->align = array('CENTER', 'CENTER', 'CENTER');
         $stu_list_table->data = array();
         // Begins the link to send mail to all the
         // students that have not picked a string
         $mailto = '<a href="mailto:';
         // Para cada uno de los estudiantes
         // For each of the students
         foreach ($students as $student) {
             $row = array();
             // If a relationship that complies with the restrictions does not exist
             if (!$DB->record_exists('interview_slots', array('student' => $student->id, 'interviewid' => $interview->id))) {
                 // Shows the user image
                 $picture = $OUTPUT->user_picture($student);
                 $row["picture"] = $picture;
                 // Shows the full name in link format
                 $name = "<a href=\"../../user/view.php?id={$student->id}&amp;course={$interview->course}\">" . fullname($student) . "</a>";
                 $row["name"] = $name;
                 // Creates a link to the mailto list for the user
                 $email = obfuscate_mailto($student->email);
                 $row["email"] = $email;
                 // Inserts the data in the table
                 $stu_list_table->data[] = array($picture, $name, $email);
                 //, $actions);
             }
         }
     }
     return $stu_list_table;
 }
    //error('課程尚未設定!');
}
$context = get_context_instance(CONTEXT_COURSE, $course->id);
if (!has_capability('moodle/grade:viewall', $context)) {
    error(get_string('NoViewCourseReportAuth3', 'block_report_module'));
}
$courseUserArray = array();
$userPassArray = array();
if ($DB->get_record('user', array('id' => $userID))) {
    $userPass = true;
    $timeDifferent = getTimeDifferent($dateform);
    $courseUserLogData = produceUserCourseLog($userID, $courseID, $timeDifferent);
    $courseUserArray[$userID] = produceCourseUserArray($userID, $courseID, $courseUserLogData, $userPass);
    $userPassArray[$userID] = $userPass;
} else {
    $students = get_course_students($courseID);
    $timeDifferent = getTimeDifferent($dateform);
    if ($students) {
        foreach ($students as $theUserID => $theStudentObj) {
            if (!$DB->get_record('user', array('id' => $theUserID))) {
                break;
            }
            $userPass = true;
            $courseUserLogData = produceUserCourseLog($theUserID, $courseID, $timeDifferent);
            $courseUserArray[$theUserID] = produceCourseUserArray($theUserID, $courseID, $courseUserLogData, $userPass);
            $userPassArray[$theUserID] = $userPass;
        }
    } else {
        echo get_string('courseNoStudentInfomation', 'block_report_module');
        exit;
    }
Example #17
0
function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid = 0)
{
    /// Returns a list of other wikis to display, depending on the type, group and user.
    /// Returns the key containing the currently selected entry as well.
    global $CFG, $id;
    $wikis = false;
    $groupmode = groups_get_activity_groupmode($wiki);
    $mygroupid = mygroupid($course->id);
    $isteacher = wiki_is_teacher($wiki, $user->id);
    $isteacheredit = wiki_is_teacheredit($wiki, $user->id);
    $groupingid = null;
    $cm = new stdClass();
    $cm->id = $wiki->cmid;
    $cm->groupmode = $wiki->groupmode;
    $cm->groupingid = $wiki->groupingid;
    $cm->groupmembersonly = $wiki->groupmembersonly;
    if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) {
        $groupingid = $wiki->groupingid;
    }
    switch ($wiki->wtype) {
        case 'student':
            /// Get all the existing entries for this wiki.
            $wiki_entries = wiki_get_entries($wiki, 'student');
            if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid)) {
                $sql = "SELECT gm.userid FROM {$CFG->prefix}groups_members gm " . "INNER JOIN {$CFG->prefix}groupings_groups gg ON gm.groupid = gg.groupid " . "WHERE gg.groupingid = {$wiki->groupingid} ";
                $groupingmembers = get_records_sql($sql);
            }
            if ($isteacher and SITEID != $course->id) {
                /// If the user is an editing teacher, or a non-editing teacher not assigned to a group, show all student
                /// wikis, regardless of creation.
                if (SITEID != $course->id and ($isteacheredit or $groupmode == NOGROUPS)) {
                    if ($students = get_course_students($course->id)) {
                        /// Default pagename is dependent on the wiki settings.
                        $defpagename = empty($wiki->pagename) ? get_string('wikidefaultpagename', 'wiki') : $wiki->pagename;
                        foreach ($students as $student) {
                            if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid) && empty($groupingmembers[$student->id])) {
                                continue;
                            }
                            /// If this student already has an entry, use its pagename.
                            if ($wiki_entries[$student->id]) {
                                $pagename = $wiki_entries[$student->id]->pagename;
                            } else {
                                $pagename = $defpagename;
                            }
                            $key = 'view.php?id=' . $id . '&userid=' . $student->id . '&page=' . $pagename;
                            $wikis[$key] = fullname($student) . ':' . $pagename;
                        }
                    }
                } else {
                    if ($groupmode == SEPARATEGROUPS) {
                        if ($students = wiki_get_students($wiki, $mygroupid)) {
                            $defpagename = empty($wiki->pagename) ? get_string('wikidefaultpagename', 'wiki') : $wiki->pagename;
                            foreach ($students as $student) {
                                if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid) && empty($groupingmembers[$student->id])) {
                                    continue;
                                }
                                /// If this student already has an entry, use its pagename.
                                if ($wiki_entries[$student->id]) {
                                    $pagename = $wiki_entries[$student->id]->pagename;
                                } else {
                                    $pagename = $defpagename;
                                }
                                $key = 'view.php?id=' . $id . '&userid=' . $student->id . '&page=' . $pagename;
                                $wikis[$key] = fullname($student) . ':' . $pagename;
                            }
                        }
                    } else {
                        if ($groupmode == VISIBLEGROUPS) {
                            /// Get all students in your group.
                            if ($students = wiki_get_students($wiki, $mygroupid)) {
                                $defpagename = empty($wiki->pagename) ? get_string('wikidefaultpagename', 'wiki') : $wiki->pagename;
                                foreach ($students as $student) {
                                    if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid) && empty($groupingmembers[$student->id])) {
                                        continue;
                                    }
                                    /// If this student already has an entry, use its pagename.
                                    if ($wiki_entries[$student->id]) {
                                        $pagename = $wiki_entries[$student->id]->pagename;
                                    } else {
                                        $pagename = $defpagename;
                                    }
                                    $key = 'view.php?id=' . $id . '&userid=' . $student->id . '&page=' . $pagename;
                                    $wikis[$key] = fullname($student) . ':' . $pagename;
                                }
                            }
                            /// Get all student wikis created, regardless of group.
                            if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid)) {
                                $sql = 'SELECT w.id, w.userid, w.pagename, u.firstname, u.lastname ' . '    FROM ' . $CFG->prefix . 'wiki_entries w ' . '    INNER JOIN ' . $CFG->prefix . 'user u ON w.userid = u.id ' . '    INNER JOIN ' . $CFG->prefix . 'groups_members gm ON gm.userid = u.id ' . '    INNER JOIN ' . $CFG->prefix . 'groupings_groups gg ON gm.groupid = gg.groupid ' . '    WHERE w.wikiid = ' . $wiki->id . ' AND gg.groupingid =  ' . $wiki->groupingid . '    ORDER BY w.id';
                            } else {
                                $sql = 'SELECT w.id, w.userid, w.pagename, u.firstname, u.lastname ' . '    FROM ' . $CFG->prefix . 'wiki_entries w, ' . $CFG->prefix . 'user u ' . '    WHERE w.wikiid = ' . $wiki->id . ' AND u.id = w.userid ' . '    ORDER BY w.id';
                            }
                            $wiki_entries = get_records_sql($sql);
                            $wiki_entries = is_array($wiki_entries) ? $wiki_entries : array();
                            foreach ($wiki_entries as $wiki_entry) {
                                $key = 'view.php?id=' . $id . '&userid=' . $wiki_entry->userid . '&page=' . $wiki_entry->pagename;
                                $wikis[$key] = fullname($wiki_entry) . ':' . $wiki_entry->pagename;
                                if ($currentid == $wiki_entry->id) {
                                    $wikis['selected'] = $key;
                                }
                            }
                        }
                    }
                }
            } else {
                /// A user can see other student wikis if they are a member of the same
                /// group (for separate groups) or there are visible groups, or if this is
                /// a site-level wiki, and they are an administrator.
                if ($groupmode == VISIBLEGROUPS or wiki_is_teacheredit($wiki)) {
                    $viewall = true;
                } else {
                    if ($groupmode == SEPARATEGROUPS) {
                        $viewall = mygroupid($course->id);
                    } else {
                        $viewall = false;
                    }
                }
                if ($viewall !== false) {
                    if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid)) {
                        $sql = 'SELECT w.id, w.userid, w.pagename, u.firstname, u.lastname ' . '    FROM ' . $CFG->prefix . 'wiki_entries w ' . '    INNER JOIN ' . $CFG->prefix . 'user u ON w.userid = u.id ' . '    INNER JOIN ' . $CFG->prefix . 'groups_members gm ON gm.userid = u.id ' . '    INNER JOIN ' . $CFG->prefix . 'groupings_groups gg ON gm.groupid = gg.groupid ' . '    WHERE w.wikiid = ' . $wiki->id . ' AND gg.groupingid =  ' . $wiki->groupingid . '    ORDER BY w.id';
                    } else {
                        $sql = 'SELECT w.id, w.userid, w.pagename, u.firstname, u.lastname ' . '    FROM ' . $CFG->prefix . 'wiki_entries w, ' . $CFG->prefix . 'user u ' . '    WHERE w.wikiid = ' . $wiki->id . ' AND u.id = w.userid ' . '    ORDER BY w.id';
                    }
                    $wiki_entries = get_records_sql($sql);
                    $wiki_entries = is_array($wiki_entries) ? $wiki_entries : array();
                    foreach ($wiki_entries as $wiki_entry) {
                        if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid) && empty($groupingmembers[$wiki_entry->userid])) {
                            continue;
                        }
                        if ($viewall === true or groups_is_member($viewall, $wiki_entry->userid)) {
                            $key = 'view.php?id=' . $id . '&userid=' . $wiki_entry->userid . '&page=' . $wiki_entry->pagename;
                            $wikis[$key] = fullname($wiki_entry) . ':' . $wiki_entry->pagename;
                            if ($currentid == $wiki_entry->id) {
                                $wikis['selected'] = $key;
                            }
                        }
                    }
                }
            }
            break;
        case 'group':
            /// If the user is an editing teacher, or a non-editing teacher not assigned to a group, show all group
            /// wikis, regardless of creation.
            /// If user is a member of multiple groups, need to show current group etc?
            /// Get all the existing entries for this wiki.
            $wiki_entries = wiki_get_entries($wiki, 'group');
            if ($groupmode and ($isteacheredit or $isteacher and !$mygroupid)) {
                if ($groups = groups_get_all_groups($course->id, null, $groupingid)) {
                    $defpagename = empty($wiki->pagename) ? get_string('wikidefaultpagename', 'wiki') : $wiki->pagename;
                    foreach ($groups as $group) {
                        /// If this group already has an entry, use its pagename.
                        if (isset($wiki_entries[$group->id])) {
                            $pagename = $wiki_entries[$group->id]->pagename;
                        } else {
                            $pagename = $defpagename;
                        }
                        $key = 'view.php?id=' . $id . ($group->id ? "&groupid=" . $group->id : "") . '&page=' . $pagename;
                        $wikis[$key] = $group->name . ':' . $pagename;
                    }
                }
            } else {
                if ($groupmode == SEPARATEGROUPS) {
                    if ($groups = groups_get_all_groups($course->id, $user->id, $groupingid)) {
                        $defpagename = empty($wiki->pagename) ? get_string('wikidefaultpagename', 'wiki') : $wiki->pagename;
                        foreach ($groups as $group) {
                            /// If this group already has an entry, use its pagename.
                            if (isset($wiki_entries[$group->id])) {
                                $pagename = $wiki_entries[$group->id]->pagename;
                            } else {
                                $pagename = $defpagename;
                            }
                            $key = 'view.php?id=' . $id . ($group->id ? "&groupid=" . $group->id : "") . '&page=' . $pagename;
                            $wikis[$key] = $group->name . ':' . $pagename;
                        }
                    }
                } else {
                    if ($groupmode == VISIBLEGROUPS) {
                        if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid)) {
                            $sql = 'SELECT w.id, w.groupid, w.pagename, g.name as gname ' . '    FROM ' . $CFG->prefix . 'wiki_entries w ' . '    INNER JOIN ' . $CFG->prefix . 'groups g ON g.id = w.groupid ' . '    INNER JOIN ' . $CFG->prefix . 'groupings_groups gg ON g.id = gg.groupid ' . '    WHERE w.wikiid = ' . $wiki->id . ' AND gg.groupingid =  ' . $wiki->groupingid . '    ORDER BY w.groupid';
                        } else {
                            $sql = 'SELECT w.id, w.groupid, w.pagename, g.name as gname ' . '    FROM ' . $CFG->prefix . 'wiki_entries w, ' . $CFG->prefix . 'groups g ' . '    WHERE w.wikiid = ' . $wiki->id . ' AND g.id = w.groupid ' . '    ORDER BY w.groupid';
                        }
                        $wiki_entries = get_records_sql($sql);
                        $wiki_entries = is_array($wiki_entries) ? $wiki_entries : array();
                        foreach ($wiki_entries as $wiki_entry) {
                            $key = 'view.php?id=' . $id . ($wiki_entry->groupid ? "&groupid=" . $wiki_entry->groupid : "") . '&page=' . $wiki_entry->pagename;
                            $wikis[$key] = $wiki_entry->gname . ':' . $wiki_entry->pagename;
                            if ($currentid == $wiki_entry->id) {
                                $wikis['selected'] = $key;
                            }
                        }
                    }
                }
            }
            break;
        case 'teacher':
            if ($isteacher) {
                /// If the user is an editing teacher, or a non-editing teacher not assigned to a group, show all
                /// teacher wikis, regardless of creation.
                if ($groupmode and ($isteacheredit or $isteacher and !$mygroupid)) {
                    if ($groups = groups_get_all_groups($course->id, null, $groupingid)) {
                        $defpagename = empty($wiki->pagename) ? get_string('wikidefaultpagename', 'wiki') : $wiki->pagename;
                        foreach ($groups as $group) {
                            /// If this group already has an entry, use its pagename.
                            if ($wiki_entries[$group->id]) {
                                $pagename = $wiki_entries[$group->id]->pagename;
                            } else {
                                $pagename = $defpagename;
                            }
                            $key = 'view.php?id=' . $id . ($group->id ? "&groupid=" . $group->id : "") . '&page=' . $pagename;
                            $wikis[$key] = $group->name . ':' . $pagename;
                        }
                    }
                } else {
                    if ($groupmode) {
                        if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid)) {
                            $sql = 'SELECT w.id, w.groupid, w.pagename, g.name as gname ' . '    FROM ' . $CFG->prefix . 'wiki_entries w ' . '    INNER JOIN ' . $CFG->prefix . 'groups g ON g.id = w.groupid ' . '    INNER JOIN ' . $CFG->prefix . 'groupings_groups gg ON g.id = gg.groupid ' . '    WHERE w.wikiid = ' . $wiki->id . ' AND gg.groupingid =  ' . $wiki->groupingid . '    ORDER BY w.groupid';
                        } else {
                            $sql = 'SELECT w.id, w.groupid, w.pagename, g.name as gname ' . '    FROM ' . $CFG->prefix . 'wiki_entries w, ' . $CFG->prefix . 'groups g ' . '    WHERE w.wikiid = ' . $wiki->id . ' AND g.id = w.groupid ' . '    ORDER BY w.groupid';
                        }
                        $wiki_entries = get_records_sql($sql);
                        $wiki_entries = is_array($wiki_entries) ? $wiki_entries : array();
                        foreach ($wiki_entries as $wiki_entry) {
                            $key = 'view.php?id=' . $id . ($wiki_entry->groupid ? "&groupid=" . $wiki_entry->groupid : "") . '&page=' . $wiki_entry->pagename;
                            $wikis[$key] = $wiki_entry->gname . ':' . $wiki_entry->pagename;
                            if ($currentid == $wiki_entry->id) {
                                $wikis['selected'] = $key;
                            }
                        }
                    }
                }
            } else {
                /// A user can see other teacher wikis if they are a teacher, a member of the same
                /// group (for separate groups) or there are visible groups.
                if ($groupmode == VISIBLEGROUPS) {
                    $viewall = true;
                } else {
                    if ($groupmode == SEPARATEGROUPS) {
                        $viewall = $mygroupid;
                    } else {
                        $viewall = false;
                    }
                }
                if ($viewall !== false) {
                    if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid)) {
                        $sql = 'SELECT w.id, w.groupid, w.pagename, g.name as gname ' . '    FROM ' . $CFG->prefix . 'wiki_entries w ' . '    INNER JOIN ' . $CFG->prefix . 'groups g ON g.id = w.groupid ' . '    INNER JOIN ' . $CFG->prefix . 'groupings_groups gg ON g.id = gg.groupid ' . '    WHERE w.wikiid = ' . $wiki->id . ' AND gg.groupingid =  ' . $wiki->groupingid . '    ORDER BY w.groupid';
                    } else {
                        $sql = 'SELECT w.id, w.groupid, w.pagename, g.name as gname ' . '    FROM ' . $CFG->prefix . 'wiki_entries w, ' . $CFG->prefix . 'groups g ' . '    WHERE w.wikiid = ' . $wiki->id . ' AND g.id = w.groupid ' . '    ORDER BY w.groupid';
                    }
                    $wiki_entries = get_records_sql($sql);
                    $wiki_entries = is_array($wiki_entries) ? $wiki_entries : array();
                    foreach ($wiki_entries as $wiki_entry) {
                        if ($viewall === true or @in_array($wiki_entry->groupid, $viewall)) {
                            $key = 'view.php?id=' . $id . ($wiki_entry->groupid ? "&groupid=" . $wiki_entry->groupid : "") . '&page=' . $wiki_entry->pagename;
                            $wikis[$key] = $wiki_entry->gname . ':' . $wiki_entry->pagename;
                            if ($currentid == $wiki_entry->id) {
                                $wikis['selected'] = $key;
                            }
                        }
                    }
                }
            }
            break;
    }
    return $wikis;
}
Example #18
0
    print_header();
    notice(get_string("activityiscurrentlyhidden"));
}
add_to_log($course->id, "mail", "view", "view.php?id={$cm->id}", $mail->id, $cm->id);
/// Printing the heading
$strmails = get_string("modulenameplural", "mail");
$strmail = get_string("modulename", "mail");
$navigation = "<a href=\"index.php?id={$course->id}\">{$strmails}</a> ->";
print_header_simple(format_string($mail->name), "", "{$navigation} " . format_string($mail->name), "", "", true, update_module_button($cm->id, $course->id, $strmail), navmenu($course, $cm));
/// If no search results then get potential students for this course excluding users already in course
if (count($SESSION->selectedto) > 0) {
    $existinguserlist = implode(',', $SESSION->selectedto);
} else {
    $existinguserlist = "";
}
if (!($students = get_course_students($course->id, "u.firstname ASC, u.lastname ASC, u.username ASC", "", 0, 99999, '', '', NULL, '', 'u.id,u.username,u.firstname,u.lastname', $existinguserlist))) {
    $students = array();
}
if (!($teachers = get_course_teachers($course->id, '', $existinguserlist))) {
    $teachers = array();
}
$numusers = count($students) + count($teachers);
mail_start_print_table_main($mail, $cm, $course);
print_heading_block("<center>" . get_string("groups", "mail") . "</center>");
echo "<br>";
include 'groups.html';
mail_end_print_table_main($mail);
/// Finish the page
print_footer($course);
?>
Example #19
0
 /**
  * Prints questions with comment and grade form underneath each question
  *
  * @return void
  * @todo Finish documenting this function
  **/
 function print_questions_and_form($quiz, $question)
 {
     global $CFG, $db;
     // grade question specific parameters
     $gradeall = optional_param('gradeall', 0, PARAM_INT);
     $userid = optional_param('userid', 0, PARAM_INT);
     $attemptid = optional_param('attemptid', 0, PARAM_INT);
     // TODO get the context, and put in proper roles an permissions checks.
     $context = NULL;
     $questions[$question->id] =& $question;
     $usehtmleditor = can_use_richtext_editor();
     $users = get_course_students($quiz->course);
     $userids = implode(',', array_keys($users));
     // this sql joins the attempts table and the user table
     $select = 'SELECT ' . sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')) . ' AS userattemptid,
                 qa.id AS attemptid, qa.uniqueid, qa.attempt, qa.timefinish, qa.preview,
                 u.id AS userid, u.firstname, u.lastname, u.picture ';
     $from = 'FROM ' . $CFG->prefix . 'user u LEFT JOIN ' . $CFG->prefix . 'quiz_attempts qa ON (u.id = qa.userid AND qa.quiz = ' . $quiz->id . ') ';
     if ($gradeall) {
         // get all user attempts
         $where = 'WHERE u.id IN (' . $userids . ') ';
     } else {
         if ($userid) {
             // get all the attempts for a specific user
             $where = 'WHERE u.id=' . $userid . ' ';
         } else {
             // get a specific attempt
             $where = 'WHERE qa.id=' . $attemptid . ' ';
         }
     }
     // ignore previews
     $where .= ' AND preview = 0 ';
     $where .= 'AND ' . $db->IfNull('qa.attempt', '0') . ' != 0 ';
     $where .= 'AND ' . $db->IfNull('qa.timefinish', '0') . ' != 0 ';
     $sort = 'ORDER BY u.firstname, u.lastname, qa.attempt ASC';
     $attempts = get_records_sql($select . $from . $where . $sort);
     // Display the form with one part for each selected attempt
     echo '<form method="post" action="report.php">' . '<input type="hidden" name="mode" value="grading" />' . '<input type="hidden" name="q" value="' . $quiz->id . '" />' . '<input type="hidden" name="sesskey" value="' . sesskey() . '" />' . '<input type="hidden" name="action" value="viewquestion" />' . '<input type="hidden" name="questionid" value="' . $question->id . '" />';
     foreach ($attempts as $attempt) {
         // Load the state for this attempt (The questions array was created earlier)
         $states = get_question_states($questions, $quiz, $attempt);
         // The $states array is indexed by question id but because we are dealing
         // with only one question there is only one entry in this array
         $state =& $states[$question->id];
         $options = quiz_get_reviewoptions($quiz, $attempt, $context);
         unset($options->questioncommentlink);
         $copy = $state->manualcomment;
         $state->manualcomment = '';
         $options->readonly = 1;
         // print the user name, attempt count, the question, and some more hidden fields
         echo '<div class="boxaligncenter" width="80%" style="padding:15px;">' . fullname($attempt, true) . ': ' . get_string('attempt', 'quiz') . $attempt->attempt;
         print_question($question, $state, '', $quiz, $options);
         $prefix = "manualgrades[{$attempt->uniqueid}]";
         $grade = round($state->last_graded->grade, 3);
         $state->manualcomment = $copy;
         include $CFG->dirroot . '/question/comment.html';
         echo '</div>';
     }
     echo '<div class="boxaligncenter"><input type="submit" value="' . get_string('savechanges') . '" /></div>' . '</form>';
     if ($usehtmleditor) {
         use_html_editor();
     }
 }
    }
    echo get_string("maximumgrade") . ": {$exercise->grade}\n";
    print_continue("view.php?id={$cm->id}");
} elseif ($action == 'listforassessmentstudent') {
    if (!($users = get_course_students($course->id))) {
        print_heading(get_string("nostudentsyet"));
        print_footer($course);
        exit;
    }
    if (!isteacher($course->id)) {
        error("Only teachers can look at this page");
    }
    exercise_list_unassessed_student_submissions($exercise, $USER);
    print_continue("view.php?id={$cm->id}");
} elseif ($action == 'listforassessmentteacher') {
    if (!($users = get_course_students($course->id))) {
        print_heading(get_string("nostudentsyet"));
        print_footer($course);
        exit;
    }
    exercise_list_unassessed_teacher_submissions($exercise, $USER);
    print_continue("view.php?id={$cm->id}");
} elseif ($action == 'saveleaguetable') {
    $form = (object) $_POST;
    if (!isteacher($course->id)) {
        error("Only teachers can look at this page");
    }
    // save the number of league table entries from the form...
    if ($form->nentries == 'All') {
        $nentries = 99;
    } else {
Example #21
0
/**
* @desc Contacts webwork to find out the completion status of a problem set for all users in a course.
* @param integer $wwassignmentid The problem set
*/
function wwassignment_grades($wwassignmentid)
{
    global $COURSE;
    $webworkclient = new webwork_client();
    $studentgrades->grades = array();
    $studentgrades->maxgrade = 0;
    //debug_log("record ".print_r($oMod,true));
    $gradeformula = '$finalgrade += ($problem->status > 0) ? 1 : 0;';
    //debug_log("formula ".print_r($gradeFormula, true));
    $webworkcourse = _wwassignment_mapped_course($COURSE->id, false);
    $webworkset = _wwassignment_mapped_set($wwassignmentid, false);
    // enumerate over the students in the course:
    $students = get_course_students($COURSE->id);
    $usernamearray = array();
    foreach ($students as $student) {
        array_push($usernamearray, $student->username);
    }
    $gradearray = $webworkclient->grade_users_sets($webworkcourse, $usernamearray, $webworkset);
    $i = 0;
    foreach ($students as $student) {
        $studentgrades->grades[$student->id] = $gradearray[$i];
        $i++;
    }
    $studentgrades->maxgrade = $webworkclient->get_max_grade($webworkcourse, $webworkset);
    return $studentgrades;
}
 public function exportUsers($courseID = 1, $shortname = null)
 {
     if ($courseID != 1 and $shortname != null) {
         //Verify if course exists
         if (!record_exists($this->courses_table, "id", $courseID, "shortname", $shortname)) {
             // Return ERROR message
             throw new MoodlePluginException("ERROR, course not found...", 1);
         }
     }
     //Get course students and teachers
     $teachers = get_course_teachers($courseID);
     $students = get_course_students($courseID);
     $courseUsers = $teachers + $students;
     //Create new DOMDocument
     $xml = new DOMDocument("1.0");
     $xml->formatOutput = true;
     $root = $xml->createElement("users");
     foreach ($courseUsers as $courseUser) {
         $ele_user = $xml->createElement("user");
         $ele_user_description = $xml->createElement("user_description");
         $ele_moodle_oriented = $xml->createElement("moodle_oriented");
         //Assign role to user
         if (in_array($courseUser, $teachers)) {
             $role = "teacher";
         } else {
             $role = "student";
         }
         $att_role = new DOMAttr("role", $role);
         $ele_user->setAttributeNode($att_role);
         //Get every information about users
         $user = get_record($this->users_table, "id", $courseUser->id);
         foreach ($user as $key => $value) {
             $child = $xml->createElement($key, $value);
             switch ($key) {
                 case "username":
                 case "password":
                 case "firstname":
                 case "lastname":
                 case "email":
                     $ele_user->appendChild($child);
                     break;
                 case "id":
                 case "auth":
                 case "confirmed":
                 case "deleted":
                 case "idnumber":
                 case "emailstop":
                 case "firstaccess":
                 case "lastaccess":
                 case "lastlogin":
                 case "currentlogin":
                 case "lastIP":
                 case "secret":
                 case "picture":
                 case "mailformat":
                 case "maildigest":
                 case "maildisplay":
                 case "htmleditor":
                 case "autosubscribe":
                 case "timemodified":
                     $ele_moodle_oriented->appendChild($child);
                     break;
                 case "icq":
                 case "phone1":
                 case "phone2":
                 case "institution":
                 case "department":
                 case "address":
                 case "city":
                 case "country":
                 case "lang":
                 case "timezone":
                 case "url":
                 case "description":
                 case "it_CF":
                 case "birthdate":
                     $ele_user_description->appendChild($child);
                     break;
             }
         }
         $ele_user->appendChild($ele_moodle_oriented);
         $ele_user->appendChild($ele_user_description);
         $root->appendChild($ele_user);
     }
     $xml->appendChild($root);
     //Return a string containing the XML Document
     $xml->save($this->users_xml);
     $f = fopen($this->users_xml, r);
     $str = fread($f, filesize($this->users_xml));
     fclose($f);
     return $str;
 }
/**
 * Return grade for given user or all users.
 *
 * @param int $attforblockid id of attforblock
 * @param int $userid optional user id, 0 means all users
 * @return array array of grades, false if none
 */
function attforblock_get_user_grades($attforblock, $userid = 0)
{
    global $CFG;
    require_once 'locallib.php';
    if (!($course = get_record('course', 'id', $attforblock->course))) {
        error("Course is misconfigured");
    }
    $result = false;
    if ($userid) {
        $result = array();
        $result[$userid]->userid = $userid;
        $result[$userid]->rawgrade = $attforblock->grade * get_percent($userid, $course) / 100;
    } else {
        if ($students = get_course_students($course->id)) {
            $result = array();
            foreach ($students as $student) {
                $result[$student->id]->userid = $student->id;
                $result[$student->id]->rawgrade = $attforblock->grade * get_percent($student->id, $course) / 100;
            }
        }
    }
    return $result;
}
Example #24
0
/**
 * Return a HTML combo box populated with the students in a course
 *
 * @db the MySQL database connection
 *
 **/
function gen_student_select_box($db, $courseID)
{
    $course_select_box = '<select name="student" onChange="frmStudent.submit();"><option value="" selected>Select Student</option>';
    foreach (get_course_students($db, $courseID) as $row) {
        $course_select_box .= "<option value='" . $row['userID'] . "'>" . $row['userName'] . "</option>";
    }
    $course_select_box .= '</select>';
    return $course_select_box;
}
Example #25
0
function get_list_members($course, &$nonmembers, &$listgroups)
{
    /// First, get everyone into the nonmembers array
    if ($students = get_course_students($course->id)) {
        foreach ($students as $student) {
            $nonmembers[$student->id] = fullname($student, true);
        }
        unset($students);
    }
    if ($teachers = get_course_teachers($course->id)) {
        foreach ($teachers as $teacher) {
            $prefix = '- ';
            if (isteacheredit($course->id, $teacher->id)) {
                $prefix = '# ';
            }
            $nonmembers[$teacher->id] = $prefix . fullname($teacher, true);
        }
        unset($teachers);
    }
    /// Pull out all the members into little arrays
    $groups = get_groups($course->id);
    if ($groups) {
        foreach ($groups as $group) {
            $countusers = 0;
            $listmembers[$group->id] = array();
            if ($groupusers = get_group_users($group->id)) {
                foreach ($groupusers as $groupuser) {
                    $listmembers[$group->id][$groupuser->id] = $nonmembers[$groupuser->id];
                    //unset($nonmembers[$groupuser->id]);
                    $countusers++;
                }
                natcasesort($listmembers[$group->id]);
            }
            $listgroups[$group->id] = $group->name . " ({$countusers})";
        }
        natcasesort($listgroups);
    }
    natcasesort($nonmembers);
    if (empty($selectedgroup)) {
        // Choose the first group by default
        if (!empty($listgroups) && ($selectedgroup = array_shift(array_keys($listgroups)))) {
            $members = $listmembers[$selectedgroup];
        }
    } else {
        $members = $listmembers[$selectedgroup];
    }
    return $listmembers;
}
Example #26
0
             }
         }
         $userdata = get_record("user", "id", $student);
         $imagepath = textanalysis_getuserimage($student);
         echo '<table border="1" cellspacing="0" valign="top" cellpadding="10">';
         echo '<tr><td rowspan="2" width="35" valign="top"><a  href="' . $CFG->wwwroot . '/courses/user/view.php?id=' . $blog->userid . '&course=' . $course->id . '"><img class="userpicture" align="middle" src="' . $imagepath . '" border="0" width="35" height="35" alt="" /></a></td><td nowrap="nowrap" width="100%">' . fullname($userdata) . '</td></tr><tr><td width="100%"><hr />';
         textanalysis_printanalizeform($text);
         echo '</td></tr>';
         echo '</table>';
     }
 } else {
     if ($type == "chat") {
         echo "<h2>Chat:</h2><br />";
         echo '<a href="get_csv.php?id=' . $id . '&type=chat">Download CSV</a><br /><br />';
         if ($tf == 0) {
             $allstudents = get_course_students($course->id);
             foreach ($allstudents as $allstudent) {
                 if (isteacher($course->id) || $allstudent->id == $USER->id) {
                     echo '<a href="?id=' . $id . '&jid=' . $jid . '&type=chat&tf=1&student=' . $allstudent->id . '">' . fullname($allstudent) . '</a> count of posts:' . count_records("chat_messages", "userid", $allstudent->id) . '<br />';
                 }
             }
         } else {
             $chats = get_records("chat_messages", "userid", $student, "timestamp");
             foreach ($chats as $chat) {
                 if (isteacher($course->id) || $chat->userid == $USER->id) {
                     $text .= $chat->message . " ";
                 }
             }
             $userdata = get_record("user", "id", $student);
             $imagepath = textanalysis_getuserimage($student);
             echo '<table border="1" cellspacing="0" valign="top" cellpadding="10">';
if (block_exabis_eportfolio_get_active_version() >= 3) {
    $all_shared_users = get_records_sql("SELECT u.id, u.picture, u.firstname, u.lastname, COUNT(v.id) AS detail_count FROM {$CFG->prefix}user AS u" . " JOIN {$CFG->prefix}block_exabeporview v ON u.id=v.userid" . " LEFT JOIN {$CFG->prefix}block_exabeporviewshar vshar ON v.id=vshar.viewid AND vshar.userid={$USER->id}" . " WHERE (v.shareall=1 OR vshar.userid IS NOT NULL)" . " GROUP BY u.id");
    $detailLink = 'shared_views.php';
} else {
    $all_shared_users = get_records_sql("SELECT u.id, u.picture, u.firstname, u.lastname, COUNT(i.id) AS detail_count FROM {$CFG->prefix}user AS u" . " JOIN {$CFG->prefix}block_exabeporitem i ON u.id=i.userid" . " LEFT JOIN {$CFG->prefix}block_exabeporitemshar ishar ON i.id=ishar.itemid AND ishar.userid={$USER->id}" . " WHERE ((i.shareall=1 AND ishar.userid IS NULL) OR (i.shareall=0 AND ishar.userid IS NOT NULL))" . " GROUP BY u.id");
    $detailLink = 'shared_portfolio.php';
}
/*
$all_shared_records = get_records_sql(
"SELECT i.id, i.userid, i.name, u.picture, u.firstname, u.lastname FROM {$CFG->prefix}block_exabeporitem i".
" JOIN {$CFG->prefix}user u ON u.id=i.userid".
" JOIN {$CFG->prefix}block_exabeporcate cat ON i.categoryid=cat.id".
" LEFT JOIN {$CFG->prefix}block_exabeporitemshar ishar ON i.id=ishar.itemid AND ishar.userid={$USER->id}".
" WHERE ((i.shareall=1 AND ishar.userid IS NULL) OR (i.shareall=0 AND ishar.userid IS NOT NULL))");
*/
$coursestudents = get_course_students($COURSE->id);
foreach ($coursestudents as $student) {
    $studentlist[] = $student->id;
}
echo "<pre style='width: 400px; text-align: left;'>";
echo "<div>" . get_string('studentsfromthiscourse', 'block_exabis_eportfolio') . "</div><br/>";
if (is_array($all_shared_users)) {
    echo "<table>";
    foreach ($all_shared_users as $user) {
        if (!in_array($user->id, $studentlist)) {
            continue;
        }
        echo "<tr>";
        echo "<td><a href=\"{$CFG->wwwroot}/blocks/exabis_eportfolio/" . $detailLink . "?courseid={$courseid}&access=id/{$user->id}\">";
        print_user_picture($user->id, $courseid, $user->picture, 0, false, false);
        echo "</a>&nbsp;</td>";
         if ($teammembersraw = get_records("user", "id", $member->userid)) {
             foreach ($teammembersraw as $teammember) {
                 $teammembers[] = $teammember;
             }
         }
     }
     $students = $teammembers;
 }
 ///Get search results excluding any users already in this course
 if ($searchtext != '' and $previoussearch) {
     $searchusers = get_course_students($cm->course, 'firstname ASC, lastname ASC', '', 0, 99999, '', '', NULL, $searchtext, '', $existinguserlist);
     $usercount = count($searchusers);
 }
 /// if empty search then return all portential  members
 if (empty($searchusers)) {
     $potential = get_course_students($cm->course, 'firstname ASC, lastname ASC', '', 0, 99999, '', '', NULL, '', '', $existinguserlist);
     $usercount = count($potential);
     $users = array();
     if ($usercount <= MAX_USERS_PER_PAGE) {
         $users = $potential;
     }
     if (empty($users)) {
         $usercount = 0;
     }
 }
 if ($teamraw = get_records("webquest_teams", "id", $teamid)) {
     foreach ($teamraw as $teampak) {
         $team = $teampak;
     }
 }
 /// print team description
Example #29
0
/**
 * Counts the students in a given course (or site), or a subset of them
 *
 * @param object $course The course in question as a course object.
 * @param string $search ?
 * @param string $firstinitial ? 
 * @param string $lastinitial ?
 * @param ? $group ?
 * @param string $exceptions ? 
 * @return int
 * @todo Finish documenting this function
 */
function count_course_students($course, $search = '', $firstinitial = '', $lastinitial = '', $group = NULL, $exceptions = '')
{
    if ($students = get_course_students($course->id, '', '', 0, 999999, $firstinitial, $lastinitial, $group, $search, '', $exceptions)) {
        return count($students);
    }
    return 0;
}
function produceSimpleCourseUserArray($userID, $courseID, $courseUserLogData, &$userPass)
{
    //relating function produceUserCourseLog
    //use produceUserCourseLog's return as input $courseUserLogData
    global $DB;
    if (!($user = $DB->get_record('user', array('id' => $userID)))) {
        return false;
        //error('不正確的學員名稱!');
    }
    if (!($courseusers = get_course_students($courseID))) {
        return false;
        //error('這門課程目前沒有學生參加!');
    }
    if (!($courseActionItem = getCourseActionItem($courseID))) {
        return false;
        //error('課程未有活動!');
    }
    if (!($courseStandardArray = getReportModuleConfig($courseID))) {
        return false;
        //error('課程尚未設定!');
    }
    //compare time or score
    //compare course action course
    if ($courseStandardArray['course']['timeCheck']) {
        //compare time
        $courseTime = calculateInteTime($courseUserLogData);
        $courseTimeStandard = $courseStandardArray['course']['time'] ? $courseStandardArray['course']['time'] : "0";
        $courseTimePass = $courseTime >= $courseTimeStandard ? true : false;
        //compare score
        $courseScorePass = true;
    } else {
        //compare time
        $courseTimePass = true;
        //compare score
        $courseScorePass = true;
    }
    //include course action data
    $courseUserArray = array();
    //$courseUserArray['course' or 'modID']['timeCheck' or 'score' ...]
    $courseUserArray['course'] = array('timePass' => $courseTimePass, 'scorePass' => $courseScorePass);
    //user pass array edit
    if (!($courseUserArray['course']['timePass'] and $courseUserArray['course']['scorePass'])) {
        return false;
    }
    //compare action item
    foreach ($courseActionItem as $courseActionItemOne) {
        //switch action item
        if (!($courseActionItemOne = courseActionItemCheck($courseActionItemOne))) {
            //if not need action item break the count
            break;
        }
        //setup action time
        switch ($courseActionItemOne->itemmodule) {
            case 'lesson':
                //單元課程
                //compare mod time action mod id
                if ($courseStandardArray[$courseActionItemOne->id]['timeCheck']) {
                    //compare time
                    $courseActionTime = 0;
                    //setup action time
                    $lessonID = $courseActionItemOne->iteminstance;
                    if ($lessonTime = caculateLessonTime($userID, $courseID, $lessonID)) {
                        $courseActionTime = $lessonTime;
                    }
                    //read action time standard
                    $courseActionTimeStandard = $courseStandardArray[$courseActionItemOne->id]['time'] ? $courseStandardArray[$courseActionItemOne->id]['time'] : "0";
                    $courseActionTimePass = $courseActionTime >= $courseActionTimeStandard ? true : false;
                } else {
                    //compare time
                    $courseActionTimePass = true;
                }
                //compare mod score action mod id
                if ($courseStandardArray[$courseActionItemOne->id]['scoreCheck']) {
                    //compare score
                    $courseActionScore = 0;
                    $courseActionScore = getCourseActionScore($courseActionItemOne->id, $userID);
                    $courseActionScore = round($courseActionScore->finalgrade, 2);
                    //read action score standard
                    $courseActionScoreStandard = $courseStandardArray[$courseActionItemOne->id]['score'] ? $courseStandardArray[$courseActionItemOne->id]['score'] : "0";
                    $courseActionScorePass = $courseActionScore >= $courseActionScoreStandard ? true : false;
                } else {
                    //compare score
                    $courseActionScorePass = true;
                }
                break;
            case 'assignment':
                //作業
                //compare mod time action mod id
                if ($courseStandardArray[$courseActionItemOne->id]['timeCheck']) {
                    //compare time
                    $courseActionTimePass = true;
                } else {
                    //compare time
                    $courseActionTimePass = true;
                }
                //compare mod score action mod id
                if ($courseStandardArray[$courseActionItemOne->id]['scoreCheck']) {
                    //compare score
                    $courseActionScore = 0;
                    $courseActionScore = getCourseActionScore($courseActionItemOne->id, $userID);
                    $courseActionScore = round($courseActionScore->finalgrade, 2);
                    //read action score standard
                    $courseActionScoreStandard = $courseStandardArray[$courseActionItemOne->id]['score'] ? $courseStandardArray[$courseActionItemOne->id]['score'] : "0";
                    $courseActionScorePass = $courseActionScore >= $courseActionScoreStandard ? true : false;
                } else {
                    //compare score
                    $courseActionScorePass = true;
                }
                break;
            case 'quiz':
                //考試
                //compare mod time action mod id
                if ($courseStandardArray[$courseActionItemOne->id]['timeCheck']) {
                    //compare time
                    $courseActionTime = 0;
                    //setup action time
                    $quizID = $courseActionItemOne->iteminstance;
                    if ($quizTime = caculateQuizTime($userID, $courseID, $quizID)) {
                        $courseActionTime = $quizTime;
                    }
                    //read action time standard
                    $courseActionTimeStandard = $courseStandardArray[$courseActionItemOne->id]['time'] ? $courseStandardArray[$courseActionItemOne->id]['time'] : "0";
                    $courseActionTimePass = $courseActionTime >= $courseActionTimeStandard ? true : false;
                } else {
                    //compare time
                    $courseActionTimePass = true;
                }
                //compare mod score action mod id
                if ($courseStandardArray[$courseActionItemOne->id]['scoreCheck']) {
                    //compare score
                    $courseActionScore = 0;
                    $courseActionScore = getCourseActionScore($courseActionItemOne->id, $userID);
                    $courseActionScore = round($courseActionScore->finalgrade, 2);
                    //read action score standard
                    $courseActionScoreStandard = $courseStandardArray[$courseActionItemOne->id]['score'] ? $courseStandardArray[$courseActionItemOne->id]['score'] : "0";
                    $courseActionScorePass = $courseActionScore >= $courseActionScoreStandard ? true : false;
                } else {
                    //compare score
                    $courseActionScorePass = true;
                }
                break;
            case 'hotpot':
                //hot potato test
                //compare mod time action mod id
                if ($courseStandardArray[$courseActionItemOne->id]['timeCheck']) {
                    //compare time
                    $courseActionTime = 0;
                    //setup action time
                    $hotpotID = $courseActionItemOne->iteminstance;
                    if ($hotpotTime = caculateHotPotTime($userID, $courseID, $hotpotID)) {
                        $courseActionTime = $hotpotTime;
                    }
                    //read action time standard
                    $courseActionTimeStandard = $courseStandardArray[$courseActionItemOne->id]['time'] ? $courseStandardArray[$courseActionItemOne->id]['time'] : "0";
                    $courseActionTimePass = $courseActionTime >= $courseActionTimeStandard ? true : false;
                } else {
                    //compare time
                    $courseActionTimePass = true;
                }
                //compare mod score action mod id
                if ($courseStandardArray[$courseActionItemOne->id]['scoreCheck']) {
                    //compare score
                    $courseActionScore = 0;
                    $courseActionScore = getCourseActionScore($courseActionItemOne->id, $userID);
                    $courseActionScore = round($courseActionScore->finalgrade, 2);
                    //read action score standard
                    $courseActionScoreStandard = $courseStandardArray[$courseActionItemOne->id]['score'] ? $courseStandardArray[$courseActionItemOne->id]['score'] : "0";
                    $courseActionScorePass = $courseActionScore >= $courseActionScoreStandard ? true : false;
                } else {
                    //compare score
                    $courseActionScorePass = true;
                }
                break;
            case 'scorm':
                //compare mod time action mod id
                if ($courseStandardArray[$courseActionItemOne->id]['timeCheck']) {
                    //compare time
                    $courseActionTime = 0;
                    //setup action time
                    $scormID = $courseActionItemOne->iteminstance;
                    if ($scormTime = caculateScormTime($userID, $courseID, $scormID)) {
                        $courseActionTime = $scormTime;
                    }
                    //read action time standard
                    $courseActionTimeStandard = $courseStandardArray[$courseActionItemOne->id]['time'] ? $courseStandardArray[$courseActionItemOne->id]['time'] : "0";
                    $courseActionTimePass = $courseActionTime >= $courseActionTimeStandard ? true : false;
                } else {
                    //compare time
                    $courseActionTimePass = true;
                }
                //compare mod score action mod id
                if ($courseStandardArray[$courseActionItemOne->id]['scoreCheck']) {
                    //compare score
                    $courseActionScorePass = true;
                } else {
                    //compare score
                    $courseActionScorePass = true;
                }
                break;
        }
        $courseUserArray[$courseActionItemOne->id] = array('timePass' => $courseActionTimePass, 'scorePass' => $courseActionScorePass);
        //user pass array edit
        if (!($courseUserArray[$courseActionItemOne->id]['timePass'] and $courseUserArray[$courseActionItemOne->id]['scorePass'])) {
            return false;
        }
    }
    return true;
}