Permalink
Browse files

Assignments can be now rebuild from interface (#2105)

* Assignments can be now rebuild from interface

* individual assignments can be now rebuild

* resolved error in e2e test as new button is added on navigation page
  • Loading branch information...
tushargr authored and bmcutler committed Jun 12, 2018
1 parent 0cf7f25 commit 33e60f59905e4f12888663448ad3411f7fc5a4f7
@@ -36,7 +36,10 @@ public function run() {
break;
case 'delete_gradeable':
$this->deleteGradeable();
break;
break;
case 'rebuild_assignement':
$this->rebuildAssignment();
break;
default:
$this->viewPage();
break;
@@ -591,11 +594,9 @@ private function deleteGradeable() {
if (!isset($_POST['csrf_token']) || $_POST['csrf_token'] != $this->core->getCsrfToken()) {
die("Invalid CSRF Token");
$this->returnToNav();
}
if (!$this->core->getUser()->accessAdmin()) {
die("Only admins can delete gradeable");
$this->returnToNav();
}
$this->core->getQueries()->deleteGradeable($g_id);
@@ -620,6 +621,28 @@ private function deleteGradeable() {
$this->returnToNav();
}
private function rebuildAssignment(){
if (!$this->core->getUser()->accessAdmin()) {
die("Only admins can rebuild assignements");
}
$course_path = $this->core->getConfig()->getCoursePath();
$course = $this->core->getConfig()->getCourse();
$semester=$this->core->getConfig()->getSemester();
$g_id = $_REQUEST['gradeable_id'];
$config_build_file = "/var/local/submitty/to_be_built/".$semester."__".$course."__".$g_id.".json";
$config_build_data = array("semester" => $semester,
"course" => $course ,
"gradeable" => $g_id
);
if (file_put_contents($config_build_file, json_encode($config_build_data, JSON_PRETTY_PRINT)) === false) {
die("Failed to write file {$config_build_file}");
}
$this->returnToNav();
}
private function quickLink() {
$g_id = $_REQUEST['id'];
$action = $_REQUEST['quick_link_action'];
@@ -628,6 +628,16 @@ public function showGradeables($sections_to_list) {
else {
$admin_button = "";
}
if (($this->core->getUser()->accessAdmin()) && ($g_data->getType() == GradeableType::ELECTRONIC_FILE)) {
$admin_rebuild_button = <<<HTML
<a class="btn btn-default" style="width:100%;" href="{$this->core->buildUrl(array('component' => 'admin', 'page' => 'admin_gradeable', 'action' => 'rebuild_assignement', 'gradeable_id' => $gradeable))}">
Rebuild
</a>
HTML;
}
else {
$admin_rebuild_button = "";
}
if ($title_save === "ITEMS BEING GRADED" && $this->core->getUser()->accessAdmin()) {
$quick_links = <<<HTML
<a class="btn btn-primary" style="width:100%;" href="{$this->core->buildUrl(array('component' => 'admin', 'page' => 'admin_gradeable', 'action' => 'quick_link', 'id' => $gradeable, 'quick_link_action' => 'release_grades_now'))}">
@@ -676,6 +686,7 @@ public function showGradeables($sections_to_list) {
$return .= <<<HTML
<td style="padding: 20px;">{$gradeable_grade_range}</td>
<td style="padding: 20px;">{$admin_button}</td>
<td style="padding: 20px;">{$admin_rebuild_button}</td>
<td style="padding: 20px;">{$quick_links}</td>
HTML;
}
@@ -34,7 +34,7 @@ def test_instructor(self):
self.assertEqual(9, len(self.driver
.find_element_by_id('graded_tbody')
.find_elements_by_class_name("gradeable_row")))
self.assertEqual(6, len(self.driver.find_element_by_class_name(
self.assertEqual(7, len(self.driver.find_element_by_class_name(
'gradeable_row').find_elements_by_tag_name('td')))

def test_ta(self):
@@ -63,7 +63,7 @@ def test_ta(self):
.find_element_by_id('graded_tbody')
.find_elements_by_class_name("gradeable_row")))

self.assertEqual(6, len(self.driver.find_element_by_class_name(
self.assertEqual(7, len(self.driver.find_element_by_class_name(
'gradeable_row').find_elements_by_tag_name('td')))


0 comments on commit 33e60f5

Please sign in to comment.