Commit 59e36476 by Vik Paruchuri

Add in support for getting and displaying ETA

parent dbe93502
def convert_seconds_to_human_readable(seconds):
if seconds < 60:
human_string = "{0} seconds".format(seconds)
elif seconds < 60 * 60:
human_string = "{0} minutes".format(round(seconds/60,1))
elif seconds < (24*60*60):
human_string = "{0} hours".format(round(seconds/(60*60),1))
else:
human_string = "{0} days".format(round(seconds/(60*60*24),1))
eta_string = "In {0}.".format(human_string)
return eta_string
\ No newline at end of file
...@@ -22,6 +22,7 @@ from xmodule.modulestore.django import modulestore ...@@ -22,6 +22,7 @@ from xmodule.modulestore.django import modulestore
from xmodule.modulestore import search from xmodule.modulestore import search
from django.http import HttpResponse, Http404, HttpResponseRedirect from django.http import HttpResponse, Http404, HttpResponseRedirect
import open_ended_grading_util
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -150,6 +151,18 @@ def student_problem_list(request, course_id): ...@@ -150,6 +151,18 @@ def student_problem_list(request, course_id):
problem_url_parts = search.path_to_location(modulestore(), course.id, problem_list[i]['location']) problem_url_parts = search.path_to_location(modulestore(), course.id, problem_list[i]['location'])
problem_url = generate_problem_url(problem_url_parts, base_course_url) problem_url = generate_problem_url(problem_url_parts, base_course_url)
problem_list[i].update({'actual_url': problem_url}) problem_list[i].update({'actual_url': problem_url})
eta_available = problem_list[i]['eta_available']
if isinstance(eta_available, basestring):
eta_available = (eta_available.lower() == "true")
eta_string = "N/A"
if eta_available:
try:
eta_string = open_ended_grading_util.convert_seconds_to_human_readable(int(problem_list[i]['eta']))
except:
#This is a student_facing_error
eta_string = "Error getting ETA."
problem_list[i].update({'eta_string' : eta_string})
except GradingServiceError: except GradingServiceError:
#This is a student_facing_error #This is a student_facing_error
......
...@@ -27,7 +27,8 @@ ...@@ -27,7 +27,8 @@
<tr> <tr>
<th>Problem Name</th> <th>Problem Name</th>
<th>Status</th> <th>Status</th>
<th>Type of Grading</th> <th>Grader Type</th>
<th>ETA</th>
</tr> </tr>
%for problem in problem_list: %for problem in problem_list:
<tr> <tr>
...@@ -40,6 +41,9 @@ ...@@ -40,6 +41,9 @@
<td> <td>
${problem['grader_type']} ${problem['grader_type']}
</td> </td>
<td>
${problem['eta_string']}
</td>
</tr> </tr>
%endfor %endfor
</table> </table>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment