Beispiel #1
0
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * @package mod
 * @subpackage emarking
 * @copyright 2012 Jorge Villalón {@link http://www.uai.cl}
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
/** General feedback to include in the marking **/
$generalfeedback = required_param('feedback', PARAM_RAW_TRIMMED);
// Firstly create the response pdf
if (emarking_create_response_pdf($draft, $user, $context, $cm->id)) {
    // If the pdf was created successfully then update the final grade and feedback
    list($finalgrade, $previouslvlid, $previouscomment) = emarking_set_finalgrade($submission->student, 0, null, $submission, $draft, $emarking, $context, $generalfeedback, false, $cm->id);
    // It is only publish if there just one draft
    if ($DB->count_records('emarking_draft', array('emarkingid' => $submission->emarking, 'submissionid' => $submission->id, 'qualitycontrol' => 0)) == 1) {
        emarking_publish_grade($draft);
    }
    $nextsubmission = emarking_get_next_submission($emarking, $draft, $context, $user, $issupervisor);
    // Send the output
    $output = array('error' => '', 'message' => 'Feedback created successfully', 'finalgrade' => $finalgrade, 'previouslvlid' => $previouslvlid, 'previouscomment' => $previouscomment, 'nextsubmission' => $nextsubmission);
} else {
    // Response couldn't be created
    $output = array('error' => 'Could not create response from eMarking.');
}
Beispiel #2
0
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * @package mod
 * @subpackage emarking
 * @copyright 2012 Jorge Villalón {@link http://www.uai.cl}
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
/** The rubric level to be deleted in the corresponding submission **/
$rubriclevel = required_param('level', PARAM_INT);
// Basic validation
if ($rubriclevel <= 0) {
    emarking_json_error("Invalid rubric level id");
}
// Get the comment corresponding the the level in this submission
if (!($comment = $DB->get_record_sql("SELECT ec.*\n\t\tFROM {emarking_comment} AS ec\n\t\tWHERE ec.levelid = :level AND ec.draft = :draft", array('level' => $rubriclevel, 'draft' => $draft->id)))) {
    emarking_json_error("Invalid comment", array('levelid' => $rubriclevel, 'draft' => $draft->id));
}
// Delete the comment
$DB->delete_records('emarking_comment', array('id' => $comment->id));
// Update the final grade for the submission
list($finalgrade, $previouslvlid, $previouscomment) = emarking_set_finalgrade($userid, $rubriclevel, '', $submission, $draft, $emarking, $context, null, true);
// Send the output if everything went well
if ($finalgrade === false) {
    $output = array('error' => 'Invalid values from finalgrade', 'grade' => $finalgrade, 'lvlidprev' => $previouslvlid, 'timemodified' => time());
} else {
    $output = array('error' => '', 'grade' => $finalgrade, 'lvlidprev' => $previouslvlid, 'timemodified' => time());
}
Beispiel #3
0
    $commentrawtext = $previouscomment;
}
if ($previouslvlid > 0 && $levelid <= 0) {
    emarking_json_error("Invalid level id for a rubric id which has a previous level", array("id" => $commentid, "levelid" => $previouslvlid));
}
/** transformation pixels screen to percentages **/
$posx = $posx / $winwidth;
$posy = $posy / $winheight;
$comment->posx = $posx;
$comment->posy = $posy;
$comment->id = $commentid;
$comment->rawtext = $commentrawtext;
$comment->bonus = $bonus;
$comment->textformat = $format;
$comment->levelid = $levelid;
$comment->markerid = $USER->id;
$DB->update_record('emarking_comment', $comment);
$diff = abs($previousbonus - $bonus);
if ($comment->levelid > 0) {
    if ($diff > 0.01 || $previouslvlid != $levelid || $previouscomment !== $commentrawtext) {
        emarking_set_finalgrade($levelid, $commentrawtext, $submission, $draft, $emarking, $context, null);
    }
}
if ($regradeid > 0) {
    $regrade->markercomment = $regrademarkercomment;
    $regrade->timemodified = time();
    $regrade->accepted = $regradeaccepted;
    $DB->update_record('emarking_regrade', $regrade);
}
include "getSubmissionGrade.php";
$newgrade = $results->finalgrade;
Beispiel #4
0
/**
 *
 * @param unknown $submission
 * @param unknown $draft
 * @param unknown $emarking
 * @param unknown $context
 * @return unknown
 */
function emarking_update_comment($submission, $draft, $emarking, $context)
{
    global $CFG, $DB;
    require_once "{$CFG->dirroot}/grade/grading/form/rubric/lib.php";
    // Required and optional params for emarking.
    $userid = required_param('markerid', PARAM_INT);
    $commentid = required_param('cid', PARAM_INT);
    $commentrawtext = required_param('comment', PARAM_RAW_TRIMMED);
    $bonus = optional_param('bonus', -111111, PARAM_FLOAT);
    $levelid = optional_param('levelid', 0, PARAM_INT);
    $format = optional_param('format', 2, PARAM_INT);
    $regradeid = optional_param('regradeid', 0, PARAM_INT);
    $regrademarkercomment = optional_param('regrademarkercomment', null, PARAM_RAW_TRIMMED);
    $regradeaccepted = optional_param('regradeaccepted', 0, PARAM_INT);
    $feedback = optional_param('feedback', 0, PARAM_RAW_TRIMMED);
    $posx = required_param('posx', PARAM_INT);
    $posy = required_param('posy', PARAM_INT);
    // Measures the correction window.
    $winwidth = optional_param('windowswidth', '-1', PARAM_NUMBER);
    $winheight = optional_param('windowsheight', '-1', PARAM_NUMBER);
    if (!($comment = $DB->get_record('emarking_comment', array('id' => $commentid)))) {
        emarking_json_error("Invalid comment", array("id" => $commentid));
    }
    if ($regradeid > 0 && !($regrade = $DB->get_record('emarking_regrade', array('id' => $regradeid)))) {
        emarking_json_error("Invalid regrade", array("id" => $regradeid));
    }
    $previousbonus = $comment->bonus;
    $previouslvlid = $comment->levelid;
    $previouscomment = $comment->rawtext;
    if ($bonus < -111110) {
        $bonus = $previousbonus;
    }
    if ($commentrawtext === 'delphi') {
        $commentrawtext = $previouscomment;
    }
    if ($previouslvlid > 0 && $levelid <= 0) {
        emarking_json_error("Invalid level id for a rubric id which has a previous level", array("id" => $commentid, "levelid" => $previouslvlid));
    }
    // Transformation pixels screen to percentages.
    if ($winheight != -1 && $winheight != -1) {
        $posx = $posx / $winwidth;
        $posy = $posy / $winheight;
        $comment->posx = $posx;
        $comment->posy = $posy;
    }
    $comment->id = $commentid;
    $comment->rawtext = $commentrawtext;
    $comment->bonus = $bonus;
    $comment->textformat = $format;
    $comment->levelid = $levelid;
    if ($previouslvlid != $levelid) {
        $comment->markerid = $userid;
    }
    $DB->update_record('emarking_comment', $comment);
    if ($feedback) {
        // Delete previous feedback
        $DB->delete_records('emarking_feedback', array('commentid' => $commentid));
        // Inserte current feedback
        $insertfeedback = array();
        $arrayfeedback = explode("__separador__", $feedback);
        //TODO: validar que el split por @@separador@@ contenga 3 objetos de lo contrario el insert fallara
        for ($count = 0; $count < count($arrayfeedback); $count++) {
            $fields = explode("@@separador@@", $arrayfeedback[$count]);
            $row = new stdClass();
            $row->commentid = $commentid;
            $row->oer = $fields[0];
            $row->name = $fields[1];
            $row->link = $fields[2];
            $row->timecreated = time();
            $insertfeedback[] = $row;
        }
        $DB->insert_records('emarking_feedback', $insertfeedback);
    }
    if ($regradeid == 0) {
        // Update draft correction time
        if ($draft->timecorrectionstarted == null) {
            $draft->timecorrectionstarted = time();
        }
        $draft->timecorrectionended = time();
        $DB->update_record('emarking_draft', $draft);
    }
    $diff = abs($previousbonus - $bonus);
    if ($comment->levelid > 0) {
        if ($diff > 0.01 || $previouslvlid != $levelid || $previouscomment !== $commentrawtext) {
            emarking_set_finalgrade($levelid, $commentrawtext, $submission, $draft, $emarking, $context, null);
        }
    }
    if ($regradeid > 0) {
        $regrade->markercomment = $regrademarkercomment;
        $regrade->timemodified = time();
        $regrade->accepted = $regradeaccepted;
        $DB->update_record('emarking_regrade', $regrade);
        if ($draft->timeregradingstarted == null) {
            $draft->timeregradingstarted = time();
        }
        $draft->timeregradingended = time();
        $DB->update_record("emarking_draft", $draft);
        $remainingregrades = $DB->count_records("emarking_regrade", array("draft" => $draft->id, "accepted" => 0));
        if ($remainingregrades == 0) {
            $draft->status = EMARKING_STATUS_REGRADING_RESPONDED;
            $draft->timemodified = time();
            $DB->update_record("emarking_draft", $draft);
        }
    }
    $results = emarking_get_submission_grade($draft);
    $newgrade = $results->finalgrade;
    return $newgrade;
}
Beispiel #5
0
$emarking_comment->width = '140';
$emarking_comment->pageno = $pageno;
$emarking_comment->timecreated = time();
$emarking_comment->timemodified = time();
$emarking_comment->rawtext = $comment;
$emarking_comment->markerid = $USER->id;
$emarking_comment->colour = 'yellow';
$emarking_comment->levelid = $rubriclevel;
$emarking_comment->criterionid = $rubricinfo->criterionid;
$emarking_comment->bonus = $bonus;
$emarking_comment->textformat = 2;
// Insert the record
$commentid = $DB->insert_record('emarking_comment', $emarking_comment);
$raterid = $USER->id;
// Update the final grade
list($finalgrade, $previouslevel, $previouscomment) = emarking_set_finalgrade($rubriclevel, $comment, $submission, $draft, $emarking, $context, null);
// When we add a mark we also have to include its regrade information (that may not be included)
$regrade = $DB->get_record('emarking_regrade', array('draft' => $draft->id, 'criterion' => $rubricinfo->criterionid));
// If there was no regrade create default information (as empty)
if (!$regrade) {
    $regrade = new stdClass();
    $regrade->id = 0;
    $regrade->accepted = 0;
    $regrade->comment = '';
    $regrade->motive = 0;
    $regrade->markercomment = '';
} else {
    $regrade->accepted = 1;
    $regrade->markercomment = $comment;
    $regrade->timemodified = time();
    $DB->update_record('emarking_regrade', $regrade);
Beispiel #6
0
/**
 *
 * @param unknown $submission
 * @param unknown $draft
 * @param unknown $emarking
 * @param unknown $context
 * @return unknown
 */
function emarking_update_comment($submission, $draft, $emarking, $context)
{
    global $CFG, $DB;
    require_once "{$CFG->dirroot}/grade/grading/form/rubric/lib.php";
    // Required and optional params for emarking.
    $userid = required_param('markerid', PARAM_INT);
    $commentid = required_param('cid', PARAM_INT);
    $commentrawtext = required_param('comment', PARAM_RAW_TRIMMED);
    $bonus = optional_param('bonus', -1, PARAM_FLOAT);
    $levelid = optional_param('levelid', 0, PARAM_INT);
    $format = optional_param('format', 2, PARAM_INT);
    $regradeid = optional_param('regradeid', 0, PARAM_INT);
    $regrademarkercomment = optional_param('regrademarkercomment', null, PARAM_RAW_TRIMMED);
    $regradeaccepted = optional_param('regradeaccepted', 0, PARAM_INT);
    $posx = required_param('posx', PARAM_INT);
    $posy = required_param('posy', PARAM_INT);
    // Measures the correction window.
    $winwidth = optional_param('windowswidth', '-1', PARAM_NUMBER);
    $winheight = optional_param('windowsheight', '-1', PARAM_NUMBER);
    if (!($comment = $DB->get_record('emarking_comment', array('id' => $commentid)))) {
        emarking_json_error("Invalid comment", array("id" => $commentid));
    }
    if ($regradeid > 0 && !($regrade = $DB->get_record('emarking_regrade', array('id' => $regradeid)))) {
        emarking_json_error("Invalid regrade", array("id" => $regradeid));
    }
    $previousbonus = $comment->bonus;
    $previouslvlid = $comment->levelid;
    $previouscomment = $comment->rawtext;
    if ($bonus < 0) {
        $bonus = $previousbonus;
    }
    if ($commentrawtext === 'delphi') {
        $commentrawtext = $previouscomment;
    }
    if ($previouslvlid > 0 && $levelid <= 0) {
        emarking_json_error("Invalid level id for a rubric id which has a previous level", array("id" => $commentid, "levelid" => $previouslvlid));
    }
    // Transformation pixels screen to percentages.
    if ($winheight != -1 && $winheight != -1) {
        $posx = $posx / $winwidth;
        $posy = $posy / $winheight;
        $comment->posx = $posx;
        $comment->posy = $posy;
    }
    $comment->id = $commentid;
    $comment->rawtext = $commentrawtext;
    $comment->bonus = $bonus;
    $comment->textformat = $format;
    $comment->levelid = $levelid;
    if ($previouslvlid != $levelid) {
        $comment->markerid = $userid;
    }
    $DB->update_record('emarking_comment', $comment);
    if ($regradeid == 0) {
        // Update draft correction time
        if ($draft->timecorrectionstarted == null) {
            $draft->timecorrectionstarted = time();
        }
        $draft->timecorrectionended = time();
        $DB->update_record('emarking_draft', $draft);
    }
    $diff = abs($previousbonus - $bonus);
    if ($comment->levelid > 0) {
        if ($diff > 0.01 || $previouslvlid != $levelid || $previouscomment !== $commentrawtext) {
            emarking_set_finalgrade($levelid, $commentrawtext, $submission, $draft, $emarking, $context, null);
        }
    }
    if ($regradeid > 0) {
        $regrade->markercomment = $regrademarkercomment;
        $regrade->timemodified = time();
        $regrade->accepted = $regradeaccepted;
        $DB->update_record('emarking_regrade', $regrade);
        if ($draft->timeregradingstarted == null) {
            $draft->timeregradingstarted = time();
        }
        $draft->timeregradingended = time();
        $DB->update_record("emarking_draft", $draft);
        $remainingregrades = $DB->count_records("emarking_regrade", array("draft" => $draft->id, "accepted" => 0));
        if ($remainingregrades == 0) {
            $draft->status = EMARKING_STATUS_REGRADING_RESPONDED;
            $draft->timemodified = time();
            $DB->update_record("emarking_draft", $draft);
        }
    }
    $results = emarking_get_submission_grade($draft);
    $newgrade = $results->finalgrade;
    return $newgrade;
}