Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions admin/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//(c) 2006 David Lippman
require("../init.php");
require_once("../includes/password.php");
require_once("../includes/TeacherAuditLog.php");

//Look to see if a hook file is defined, and include if it is
if (isset($CFG['hooks']['admin/actions'])) {
Expand Down Expand Up @@ -662,26 +663,47 @@
}

if ($stm->rowCount()>0) {
$metadata = array();
if ($setdatesbylti==1) {
$stm = $DBH->prepare("UPDATE imas_assessments SET date_by_lti=1 WHERE date_by_lti=0 AND courseid=:cid");
$stm->execute(array(':cid'=>$_GET['id']));
if ($stm->rowCount()>0) {
$metadata['date_by_lti'] = 1;
}
} else {
//undo it - doesn't restore dates
$stm = $DBH->prepare("UPDATE imas_assessments SET date_by_lti=0 WHERE date_by_lti>0 AND courseid=:cid");
$stm->execute(array(':cid'=>$_GET['id']));
if ($stm->rowCount()>0) {
$metadata['date_by_lti'] = 0;
}
//remove is_lti from exceptions with latepasses
$query = "UPDATE imas_exceptions JOIN imas_assessments ";
$query .= "ON imas_exceptions.assessmentid=imas_assessments.id ";
$query .= "SET imas_exceptions.is_lti=0 ";
$query .= "WHERE imas_exceptions.is_lti>0 AND imas_exceptions.islatepass>0 AND imas_assessments.courseid=:cid";
$stm = $DBH->prepare($query);
$stm->execute(array(':cid'=>$_GET['id']));
if ($stm->rowCount()>0) {
$metadata['imas_exceptions.is_lti'] = 0;
}
//delete any other is_lti exceptions
$query = "DELETE imas_exceptions FROM imas_exceptions JOIN imas_assessments ";
$query .= "ON imas_exceptions.assessmentid=imas_assessments.id ";
$query .= "WHERE imas_exceptions.is_lti>0 AND imas_exceptions.islatepass=0 AND imas_assessments.courseid=:cid";
$stm = $DBH->prepare($query);
$stm->execute(array(':cid'=>$_GET['id']));
if ($stm->rowCount()>0) {
$metadata['imas_exceptions.is_lti'] = 'deleted';
}
}
if (!empty($metadata)) {
$result = TeacherAuditLog::addTracking(
$cid,
"Mass Assessment Settings Change",
null,
$metadata
);
}
}
} else { //new course
Expand Down Expand Up @@ -881,6 +903,14 @@ function updateoutcomes(&$arr) {
if ($setdatesbylti==1) {
$stm = $DBH->prepare("UPDATE imas_assessments SET date_by_lti=1 WHERE date_by_lti=0 AND courseid=:cid");
$stm->execute(array(':cid'=>$cid));
if ($stm->rowCount()>0) {
$result = TeacherAuditLog::addTracking(
$cid,
"Mass Assessment Settings Change",
null,
['date_by_lti'=>1]
);
}
}
/*
//add to top of course list (skip until we can do it consistently)
Expand Down
88 changes: 88 additions & 0 deletions admin/teacherauditlog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php
//IMathAS: Add/modify blocks of items on course page
//(c) 2019 David Lippman

/*** master php includes *******/
require("../init.php");
require("../includes/htmlutil.php");
require_once("../includes/TeacherAuditLog.php");

/*** pre-html data manipulation, including function code *******/

//set some page specific variables and counters
$overwriteBody = 0;
$body = "";
$pagetitle = "Teacher Audit Log";
$userid = Sanitize::onlyInt($_GET['userid']);
$cid = Sanitize::courseId($_GET['cid']);

$curBreadcrumb = "$breadcrumbbase <a href=\"admin2.php\">Admin</a> &gt; <a href=\"userdetails.php?id=$userid\">User Details</a> ";
$curBreadcrumb .= "&gt; Teacher Audit Log\n";

if (isset($_GET['id'])) {
$stm = $DBH->prepare("SELECT courseid FROM imas_assessments WHERE id=?");
$stm->execute(array(intval($_GET['id'])));
if ($stm->rowCount()==0 || $stm->fetchColumn(0) != $_GET['cid']) {
echo "Invalid ID";
exit;
}
}

if ($myrights <75) {
$overwriteBody=1;
$body = "You need to log in as an admin to access this page";
} elseif (!(isset($_GET['cid']))) {
$overwriteBody=1;
$body = "You need to select the course";
}
function formatdate($date) {
return tzdate("M j, Y, g:i a",strtotime($date));
}


//BEGIN DISPLAY BLOCK

/******* begin html output ********/
//$placeinhead = "<script type=\"text/javascript\" src=\"$imasroot/javascript/DatePicker.js?v=080818\"></script>";

require("../header.php");

if ($overwriteBody==1) {
echo $body;
} else {
$stm = $DBH->prepare("SELECT ic.name,ic.ownerid,iu.groupid FROM imas_courses AS ic JOIN imas_users AS iu ON ic.ownerid=iu.id WHERE ic.id=?");
$stm->execute(array($cid));
list($coursename, $courseownerid, $coursegroupid) = $stm->fetch(PDO::FETCH_NUM);

echo '<div class=breadcrumb>', $curBreadcrumb, '</div>';
echo '<div id="headeruserdetail" class="pagetitle"><h1>' . _('Teacher Audit Log') . ': ';
echo Sanitize::encodeStringForDisplay($coursename);
echo '</h1></div>';

$teacher_actions = TeacherAuditLog::findActionsByCourse($cid);
if (empty($teacher_actions)) {
echo "<p>Nothing to report</p>";
} else {
$stm = $DBH->query("SELECT FirstName, LastName FROM imas_users WHERE id=" . $teacher_actions[0]['userid']);
list($first, $last) = $stm->fetch();
echo '<table><tr>';
echo '<th>Date/Time</th>';
echo '<th>Teacher</th>';
echo '<th>Action</th>';
echo '<th>ItemID</th>';
echo '<th>Details</th>';
echo '</tr>';

foreach ($teacher_actions as $action) {
echo '<tr>';
echo '<td>' . formatdate($action['created_at']) . '</td>';
echo "<td>$first $last (" . Sanitize::onlyInt($action['userid']) . ')</td>';
echo '<td>' . Sanitize::encodeStringForDisplay($action['action']) . '</td>';
echo '<td>' . Sanitize::onlyInt($action['itemid']) . '</td>';
echo '<td><a href="javascript:alert(\'' . Sanitize::encodeStringForDisplay($action['metadata']) . '\')">Details</a></td>';
echo '</tr>';
}
}
}

require("../footer.php");
3 changes: 2 additions & 1 deletion admin/userdetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ function hidecourse(el) {
var cid = $(el).attr("data-cid");
var thishtml = html + \' <li class="unhide"><a href="#" onclick="unhidecourse(this);return false;">'._('Return to home page course list').'</a></li>\';
thishtml += \' <li class="hide"><a href="#" onclick="hidecourse(this);return false;">'._('Hide from home page course list').'</a></li>\';


thishtml += \' <li><a href="teacherauditlog.php?userid='.$uid.'&cid=\'+cid+\'">'._('Teacher Audit Log').'</a></li>\';
thishtml += \' <li><a href="forms.php?from=ud'.$uid.'&action=modify&id=\'+cid+\'">'._('Settings').'</a></li>\';
thishtml += \' <li><a href="addremoveteachers.php?from=ud'.$uid.'&id=\'+cid+\'">'._('Add/remove teachers').'</a></li>\';
thishtml += \' <li><a href="transfercourse.php?from=ud'.$uid.'&id=\'+cid+\'">'._('Transfer ownership').'</a></li>\';
Expand Down
1 change: 1 addition & 0 deletions admin/userreportdetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ function hidecourse(el) {
var thishtml = html + \' <li class="unhide"><a href="#" onclick="unhidecourse(this);return false;">'._('Return to home page course list').'</a></li>\';
thishtml += \' <li class="hide"><a href="#" onclick="hidecourse(this);return false;">'._('Hide from home page course list').'</a></li>\';

thishtml += \' <li><a href="teacherauditlog.php?userid='.$uid.'&cid=\'+cid+\'">'._('Teacher Audit Log').'</a></li>\';
thishtml += \' <li><a href="forms.php?from=ud'.$uid.'&action=modify&id=\'+cid+\'">'._('Settings').'</a></li>\';
thishtml += \' <li><a href="addremoveteachers.php?from=ud'.$uid.'&id=\'+cid+\'">'._('Add/remove teachers').'</a></li>\';
thishtml += \' <li><a href="transfercourse.php?from=ud'.$uid.'&id=\'+cid+\'">'._('Transfer ownership').'</a></li>\';
Expand Down
48 changes: 47 additions & 1 deletion assess2/AssessRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
require_once(__DIR__ . '/questions/models/ShowAnswer.php');
require_once(__DIR__ . '/questions/ScoreEngine.php');
require_once(__DIR__ . '/questions/models/ScoreQuestionParams.php');
require_once(__DIR__ . '/../includes/TeacherAuditLog.php');

use IMathAS\assess2\questions\QuestionGenerator;
use IMathAS\assess2\questions\models\QuestionParams;
Expand Down Expand Up @@ -180,12 +181,45 @@ public function saveRecord() {
}
$stm = $this->DBH->prepare($query);
$stm->execute($qarr);
if ($stm->rowCount()>0 && isset( $qarr[':scoreddata'])) {
$this->assessRecord['scoreddata'] = json_decode(gzdecode($this->assessRecord['scoreddata']), true);
$qarr[':scoreddata'] = json_decode(gzdecode($qarr[':scoreddata']), true);
$override = $this->array_diff_assoc_recursive($this->assessRecord['scoreddata'],$qarr[':scoreddata']);
TeacherAuditLog::addTracking(
$this->assess_info->getCourseId(),
"Change Grades",
$this->curAid,
array(
'Assessment Ver' => 2,
'studentid' => $this->curUid,
'override' => $override
)
);
}

$this->need_to_record = false;
}
}
private function array_diff_assoc_recursive($firstArray, $secondArray) {
$aReturn = array();
foreach ($firstArray as $mKey => $mValue) {
if (array_key_exists($mKey, $secondArray)) {
if (is_array($mValue)) {
$aRecursiveDiff = $this->array_diff_assoc_recursive($mValue, $secondArray[$mKey]);
if (count($aRecursiveDiff)) { $aReturn[$mKey] = $aRecursiveDiff; }
} else {
if ($mValue != $secondArray[$mKey]) {
$aReturn[$mKey] = $mValue;
}
}
} else {
$aReturn[$mKey] = $mValue;
}
}
return $aReturn;
}

/**
/**
* Create a new record in the database. Call after loadRecord.
*
* @param array $users Array of users to create record for.
Expand Down Expand Up @@ -2942,6 +2976,18 @@ public function gbClearAttempts($type, $keepver, $av=0, $qn=0, $qv=0) {
$replacedDeleted = true;
}
$this->updateStatus();
$result = TeacherAuditLog::addTracking(
$this->assess_info->getCourseId(),
"Clear Attempts",

$this->curAid,
array(
'Assessment Ver' => 2,
'studentid' => $this->curUid,
'type'=>$type,
'keepver' => $this->assessRecord,
)
);
return $replacedDeleted;
}

Expand Down
9 changes: 9 additions & 0 deletions assess2/gbclearattempt.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
require_once("./AssessInfo.php");
require_once("./AssessRecord.php");
require_once('./AssessUtils.php');
require_once("../includes/TeacherAuditLog.php");

header('Content-Type: application/json; charset=utf-8');

Expand Down Expand Up @@ -72,6 +73,14 @@
if ($type == 'all' && $keepver == 0) {
$stm = $DBH->prepare('DELETE FROM imas_assessment_records WHERE assessmentid=? AND userid=?');
$stm->execute(array($aid, $uid));
if ($stm->rowCount()>0) {
$result = TeacherAuditLog::addTracking(
$cid,
"Clear Attempts",
$aid,
array('grades'=>$assess_record->getGbScore())
);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there's only logging for the "delete all attempts" clearing, but not for any of the individual attempt or question version clearing later in the file.

// update LTI grade
$lti_sourcedid = $assess_record->getLTIsourcedId();
if (strlen($lti_sourcedid) > 1) {
Expand Down
Loading