Beispiel #1
0
 function definition()
 {
     global $COURSE, $USER, $OUTPUT;
     $mform =& $this->_form;
     //Is this particular course mapped to a course in WeBWorK
     $wwclient = new wwassignment_client();
     $wwcoursename = _wwassignment_mapped_course($COURSE->id, false);
     $wwsetname = _wwassignment_mapped_set($this->_instance);
     $wwusername = $USER->username;
     //create the instructor if necessary
     $wwusername = _wwassignment_mapcreate_user($wwcoursename, $wwusername, '10');
     //login the instructor
     $wwkey = _wwassignment_login_user($wwcoursename, $wwusername);
     $wwinstructorlink = _wwassignment_link_to_instructor_auto_login($wwcoursename, $wwusername, $wwkey);
     $mform->addElement('link', 'instructor_page_link', get_string('instructor_page_link_desc', 'wwassignment'), $wwinstructorlink, get_string('instructor_page_link_name', 'wwassignment'));
     if ($wwsetname != -1) {
         //we are doing an update, since an id exists in moodle db
         $wwsetlink = _wwassignment_link_to_edit_set_auto_login($wwcoursename, $wwsetname, $wwusername, $wwkey);
         $mform->addElement('link', 'edit_set', get_string('edit_set_link_desc', 'wwassignment'), $wwsetlink, get_string('edit_set_link_name', 'wwassignment'));
         $wwsetdata = $wwclient->get_assignment_data($wwcoursename, $wwsetname, false);
         $opendate = strftime("%c", $wwsetdata['open_date']);
         $duedate = strftime("%c", $wwsetdata['due_date']);
         $mform->addElement('static', 'opendate', 'WeBWorK Set Open Date', $opendate);
         $mform->addElement('static', 'duedate', 'WeBWorK Set Due Date', $duedate);
     }
     //define the mapping
     $mform->addElement('header', 'set_initialization', get_string('set_initialization', 'wwassignment'));
     //name
     $mform->addElement('text', 'name', get_string('wwassignmentname', 'wwassignment'), array('size' => '64'));
     $mform->setType('name', PARAM_TEXT);
     $mform->addRule('name', null, 'required', null, 'client');
     //set select
     $options = $wwclient->options_set($wwcoursename, false);
     $mform->addElement('select', 'webwork_set', get_string('webwork_set', 'wwassignment'), $options);
     //	$OUTPUT->help_icon('enablenotification','assignment');
     $mform->addHelpButton('webwork_set', 'webwork_set', 'wwassignment');
     //description
     $mform->addElement('htmleditor', 'description', get_string('description', 'assignment'));
     $mform->setType('description', PARAM_RAW);
     $mform->addHelpButton('description', 'writing', 'wwassignment');
     $features = new stdClass();
     $features->gradecat = true;
     $features->groups = false;
     $this->standard_coursemodule_elements($features);
     $this->add_action_buttons();
     //$this->standard_hidden_coursemodule_elements();
     return;
 }
Beispiel #2
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;
}
Beispiel #3
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;
}
Beispiel #4
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;
}
Beispiel #5
0
function wwassignment_grades($wwassignmentid)
{
    /// Must return an array of grades for a given instance of this module,
    /// indexed by user.  It also returns a maximum allowed grade.
    ///
    ///    $return->grades = array of grades;
    ///    $return->maxgrade = maximum allowed grade;
    ///
    ///    return $return;
    // here's how we compute the grade:
    // NOTE: each set has P problems in it.
    // NOTE: each problem may be attempted M times.
    // NOTE: each problem has been attempted A times (by a given user).
    // NOTE: each problem was gotten correct C times (by a given user).
    // NOTE: each problem was gotten incorrect I times (by a given user).
    // Thus, a users grade is: sigma(over P) C/A
    // And the max score is P
    // Alternately, code is provided for:
    // sigma(over P) { if( C > 0) 1 else 0 }
    // again with a max of P
    // redefine it here, 'cause for some reason we can't global it...
    //debug_log("start grades ".$wwassignmentid);
    global $COURSE;
    $webworkclient = webwork_client::get_instance();
    $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);
    foreach ($students as $student) {
        $webworkuser = $webworkclient->mapped_user($webworkcourse, $student->username, false);
        $webworkuserset = $webworkclient->mapped_user_set($webworkcourse, $webworkuser, $webworkset, false);
        $studentproblems = $webworkclient->get_user_problems($webworkcourse, $webworkuser, $webworkset);
        $finalgrade = 0.0;
        foreach ($studentproblems as $problem) {
            $finalgrade += $problem->status;
        }
        $studentgrades->grades[$student->id] = $finalgrade;
    }
    $studentgrades->maxgrade = $webworkclient->get_max_grade($webworkcourse, $webworkset);
    //error_log("all grades".print_r($studentgrades, true));
    return $studentgrades;
}