Skip to content

Commit

Permalink
ohm-527 migration for data model
Browse files Browse the repository at this point in the history
ohm-527 change creation timestamp to created_at field

ohm-527 match ENUM plural form

ohm-527 update table name output

ohm-528 initial logging class and testing pattern

ohm-528 add findCourseAction and update/cleanup tests

ohm-525 fix in memory sqlite db for tests

ohm-525 use global userid

ohm-525 add source file to all metadata

ohm-525 Assessment setting changes logged

ohm-525 update for mass updates not reqiring itemid

ohm-525 Mass change assessment

ohm-525 Unenroll with grade save

ohm-525 Mass Assessment Date Change

ohm-525 Clear Attempts, Question Settings Change, Assessment Settings Change

ohm-525 Clear Attempts

ohm-525 Clear Scores and Attempts

ohm-525 update Clear Scores

ohm-524 delete items

ohm-525 initial Teacher Audit Log Report

ohm-525 use blob for metadata

ohm-525 update for code bugs

ohm-525 record updated scores

ohm-525 update Clear Scores, Clear Attempts. Change 'Grade Override' to 'Grade Change'

ohm-525 mass change dates

ohm-525 Change Grades Old Assessment

ohm-525 record new assessment updates

ohm-525 update include to TeacherAuditLog

ohm-525 build assess2 for production

ohm-525 loadRecord to get score data. Only record if this is a scoreoverride

ohm-525 do not need to log teacher clearing their own scores

ohm-525 clear attempts

ohm-525 do not need to record for adding a new assessment

ohm-525 clean up logged data

ohm-525 record offline, forum and external grades from imas_grades

ohm-525 must be admin to access Teacher Audit Log Report

ohm-525 update breadcrumbs

ohm-525 only pull imas_grades where appropriate

ohm-525 count forums
  • Loading branch information
Alena Holligan committed May 1, 2020
1 parent e6fb80e commit f1dab79
Show file tree
Hide file tree
Showing 37 changed files with 1,091 additions and 101 deletions.
84 changes: 84 additions & 0 deletions admin/teacherauditlog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?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);
$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
30 changes: 30 additions & 0 deletions 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,6 +181,23 @@ public function saveRecord() {
}
$stm = $this->DBH->prepare($query);
$stm->execute($qarr);
if ($stm->rowCount()>0 && $this->data['scoreoverride']==true) {
$this->loadRecord($this->curUid);
//do we want to keep the score data? if so we need to decode or else unset
$this->assessRecord['scoreddata'] = json_decode(gzdecode($this->assessRecord['scoreddata']), true);
$qarr[':scoreddata'] = json_decode(gzdecode($qarr[':scoreddata']), true);
$result = TeacherAuditLog::addTracking(
$this->assess_info->getCourseId(),
"Change Grades",
$this->curAid,
array(
'Assessment Ver' => 2,
'studentid' => $this->curUid,
'old score' => $this->assessRecord['score'],
'new score' => $qarr[':score']
)
);
}

$this->need_to_record = false;
}
Expand Down Expand Up @@ -2942,6 +2960,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())
);
}
// update LTI grade
$lti_sourcedid = $assess_record->getLTIsourcedId();
if (strlen($lti_sourcedid) > 1) {
Expand Down
47 changes: 34 additions & 13 deletions assess2/vue-src/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f1dab79

Please sign in to comment.