CSC/ECE 517 Fall 2019 - E1964. Export review scores for projects

From Expertiza_Wiki
Jump to navigation Jump to search

E1964. Export review scores for projects

This page provides a description of the Expertiza website project undertaken for OSS component in Object Oriented Design and Development.

About Expertiza

Expertiza GitHub source code is an Open Source project based on Ruby on Rails framework. It is a software to create renewable learning projects through peer reviews and continuous assessments. It enables group projects and project submissions via URLs and wiki pages as well. It is supported by the National Science Foundation.

Problem Statement / Motivation

This project aims to easily handle review score exporting for instructor and TAs, when they try to export scores from Expertiza to WebAssign website. Currently, no such option exists to export scores so that it can be later uploaded to WebAssign efficiently.

Tasks Identified

All tasks pertaining to the completion of the project have been listed out here as follows:

  • A new button has been added to export scores.
  • All functionality to be handled will be taken care of using VanillaJS in the view of Review Report.
  • Tests have been written for the UI and CSV creation.
  • Files modified:
 1. app/views/reports/_review_report.html.erb                         - Functionality and UI changes.
 2. spec/features/review_mapping_helper_spec.rb                       - Added new test cases.
 3. app/controllers/reports_controller.rb                             - Added new function for test case.
 4. spec/features/review_report_details/review_report_no_data_csv.txt - Created a blank csv for testing.

Implementation

Diagrammatic representation of the workflow of the project is shown as follows:

   


Screenshot of the Review Report page with the option to export scores (marked in red):

   


Code snippet of the added button:

  <button onclick="exportTableToCSV('review_scores.csv')">Export Review Scores To CSV File</button>
  <br />
  <br />
   .
   . 
   .
   <td>
      <%= link_to user.name(session[:ip]), impersonate_impersonate_path(:user => {:name => user.name(session[:ip])}), :method => :post, :class => "runityID" %>
      (<span class="rname"><%= user.fullname(session[:ip]) %></span>)
   </td>

Screencast

  1. Here is the link to a screen recording on how to access the functionality and export the CSV file.

Code and Snapshots

We have written two methods inside _review_report.html.erb named exportTableToCSV and downloadCSV which are as follows:

function downloadCSV(csv, filename) {
var csvFile;
var downloadLink;

// CSV file
csvFile = new Blob([csv], {type: "text/csv"});

// Download link
downloadLink = document.createElement("a");

// File name
downloadLink.download = filename;

// Create a link to the file
downloadLink.href = window.URL.createObjectURL(csvFile);

// Hide download link
downloadLink.style.display = "none";

// Add the link to DOM
document.body.appendChild(downloadLink);

// Click download link
downloadLink.click();
}
	function exportTableToCSV(filename) {
		var csv = [];
		var rows = document.querySelector("table#myTable").rows;
		var row = [];
		row = setHeaderForCSV();
		csv.push(row.join(","));
		
		for (var i = 1; i < rows.length; i++) {
			var row = [];
			
			reviewer_name = "\"" + rows[i].querySelector("td span.rname").innerHTML + "\"";
			reviewer_unityid = rows[i].querySelector("td a.runityID").innerHTML;
			reviewer_emailid = reviewer_unityid + "@ncsu.edu";
			reviewer_grade = rows[i].querySelector("input#grade_for_reviewer").value;
			reviewer_comment = "\"" + rows[i].querySelector("textarea#comment_for_reviewer").innerHTML.replace(/"/g,"\'") + "\"";
			
			row.push(reviewer_name);
			row.push(reviewer_unityid);
			row.push(reviewer_emailid);
			row.push(reviewer_grade);
			row.push(reviewer_comment);
			
      csv.push(row.join(","));
              
		}

    // Call Download CSV file function here
    downloadCSV(csv.join("\n"), filename);
	}

The output file has "name", "unity_id", "email_id", "grade" and "comment" fields from the Review Scores Report table.

Test

The code has been designed such that all the reviews completed by reviewers for a particular assignment can be seen, graded collected and stored easily by the click of a button. Thus, a good test case would be to check whether the required headers and data are getting stored and to check whether junk data gets stored in the csv if there are no reviews by reviewers.
Newly created test cases include:

  • Test cases to check for the UI elements in Review Report html page.
  • Test case to check whether added button ("Export Review Scores To CSV File") is actually rendered in the html page.
  it "has Export Reviews button" do
    expect(page).to have_button('Export Review Scores To CSV File')
  end
  • Test case to see whether a simple CSV with the correct headers (Name, Unity ID, Email ID, Grade and Comments) is being created.
  # test to check whether a blank CSV with headers is being created or not.
  it "can create an empty csv with just headers" do
    expected_csv = File.read('spec/features/review_report_details/review_report_no_data_csv.txt')
    expect(generated_csv(true, @options)).to eq(expected_csv)
  end

  # function to generate a simple CSV with headers.
  def generated_csv(t_assignment, t_options)
    delimiter = ','
    CSV.generate(col_sep: delimiter) do |csv|
      csv << ReportsController.export_details_fields(t_options)
      ReportsController.export_details(csv, t_assignment, false)
    end
  end

Test Plan

  1. Log into expertiza as the instructor.
2. Load all assignments. (Manage -> Assignments)
3. Click on 'View Reports' button.
4. Choose 'Review Report' from the dropdown and click 'View'.
5. You can now export the grade and comments of the reviewers along with their details, i.e, name, unity ID and email.
6. The file will be downloaded.

Team

Mentor: Harsh Agrawal
Team:

  • Yash Thakkar (yrthakka)
  • Pururaj Dave (pdave2)
  • Maharshi Parekh (mgparekh)

References

  1. Expertiza website
  2. Expertiza GitHub source code
  3. WebAssign website
  4. Wiki Expertiza project documentation
  5. Rspec Documentation