query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Returns the XModule corresponding to this descriptor. Expects that the system already supports all of the attributes needed by xmodules | def _xmodule(self):
if self.xmodule_runtime is None:
raise UndefinedContext()
assert self.xmodule_runtime.error_descriptor_class is not None
if self.xmodule_runtime.xmodule_instance is None:
try:
self.xmodule_runtime.construct_xblock_from_class(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def base_module(self) -> nn.Module:\n return getattr(__import__(\"src.modules\", fromlist=[\"\"]), self.name)",
"def module(self) -> Optional[Module]:\n return self._module",
"def get_module(self):\n return self.module",
"def module(self):\n return self._module",
"def module(sel... | [
"0.58881956",
"0.58523905",
"0.5821836",
"0.5778364",
"0.5778364",
"0.5778364",
"0.5778364",
"0.5778364",
"0.5760708",
"0.5760708",
"0.5758348",
"0.55904615",
"0.5401175",
"0.5291778",
"0.5258689",
"0.5251493",
"0.524128",
"0.52311504",
"0.52281404",
"0.5197124",
"0.517288",
... | 0.58770597 | 1 |
Log in as a staff user, then return the cookies for the session (as a dict) Raises a `StudioApiLoginError` if the login fails. | def session_cookies(self):
return {key: val for key, val in self.session.cookies.items()} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _login_as_staff(self):\n self.client.login(username=self.user.username, password=self.password)",
"def _login_as_staff(self):\n self.client.login(username=self.user.username, password=self.password)",
"def session(self):\r\n # Use auto-auth to retrieve the session for a logged in user\... | [
"0.6884532",
"0.6884532",
"0.6569206",
"0.6368328",
"0.62374204",
"0.623155",
"0.6205007",
"0.6120014",
"0.5833338",
"0.57833576",
"0.57824486",
"0.57805836",
"0.5777915",
"0.57241195",
"0.567013",
"0.56403023",
"0.5623068",
"0.5607853",
"0.5600912",
"0.5550434",
"0.55042005"... | 0.0 | -1 |
String representation of the course fixture, useful for debugging. | def __str__(self):
return "<CourseFixture: org='{org}', number='{number}', run='{run}'>".format(**self._course_dict) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\r\n return dedent(\"\"\"\r\n <XBlockFixtureDescriptor:\r\n category={0},\r\n data={1},\r\n metadata={2},\r\n grader_type={3},\r\n publish={4},\r\n children={5}\r\n >\r\n ... | [
"0.70024043",
"0.6708708",
"0.6225768",
"0.61122996",
"0.60852194",
"0.60829085",
"0.607513",
"0.60093874",
"0.60072273",
"0.59836423",
"0.59822226",
"0.59508353",
"0.59374034",
"0.5918395",
"0.5882353",
"0.5879081",
"0.5866462",
"0.5857417",
"0.58506274",
"0.5844919",
"0.582... | 0.8302604 | 0 |
Create the course and XBlocks within the course. This is NOT an idempotent method; if the course already exists, this will raise a `CourseFixtureError`. You should use unique course identifiers to avoid conflicts between tests. | def install(self):
self._create_course()
self._install_course_updates()
self._install_course_handouts()
self._configure_course()
self._upload_assets()
self._create_xblock_children(self._course_location, self._children) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_temporary_xblocks(self):\r\n test_course = persistent_factories.PersistentCourseFactory.create(\r\n offering='tempcourse', org='testx',\r\n display_name='fun test course', user_id='testbot'\r\n )\r\n\r\n test_chapter = modulestore('split').create_xblock(\r\n ... | [
"0.7042408",
"0.6844693",
"0.68238753",
"0.6737102",
"0.6733219",
"0.6728474",
"0.66444606",
"0.6556639",
"0.6492217",
"0.6395226",
"0.63806987",
"0.6374901",
"0.63698936",
"0.6313253",
"0.6293124",
"0.620479",
"0.6191778",
"0.61905825",
"0.6139826",
"0.6105808",
"0.60519505"... | 0.54749084 | 50 |
Return the locator string for the course. | def _course_key(self):
return "slashes:{org}+{number}+{run}".format(**self._course_dict) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _course_location(self):\r\n return \"location:{org}+{number}+{run}+course+{run}\".format(**self._course_dict)",
"def id(self):\r\n return self.location.course_key",
"def format_course_for_view(course):\r\n return (\r\n course.display_name,\r\n reverse_course_url('... | [
"0.7052879",
"0.63027805",
"0.62709135",
"0.6068942",
"0.6016974",
"0.6007825",
"0.60016185",
"0.5838124",
"0.5754807",
"0.5703287",
"0.5699874",
"0.5663746",
"0.5627803",
"0.5614587",
"0.56138086",
"0.5579316",
"0.55437505",
"0.5536758",
"0.5531428",
"0.55245405",
"0.5518374... | 0.5697923 | 11 |
Return the locator string for the course. | def _course_location(self):
return "location:{org}+{number}+{run}+course+{run}".format(**self._course_dict) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id(self):\r\n return self.location.course_key",
"def format_course_for_view(course):\r\n return (\r\n course.display_name,\r\n reverse_course_url('course_handler', course.id),\r\n get_lms_link_for_item(course.location),\r\n course.display_org_with_def... | [
"0.63027805",
"0.62709135",
"0.6068942",
"0.6016974",
"0.6007825",
"0.60016185",
"0.5838124",
"0.5754807",
"0.5703287",
"0.5699874",
"0.5697923",
"0.5663746",
"0.5627803",
"0.5614587",
"0.56138086",
"0.5579316",
"0.55437505",
"0.5536758",
"0.5531428",
"0.55245405",
"0.5518374... | 0.7052879 | 0 |
Create the course described in the fixture. | def _create_course(self):
# If the course already exists, this will respond
# with a 200 and an error message, which we ignore.
response = self.session.post(
STUDIO_BASE_URL + '/course/',
data=self._encode_post_dict(self._course_dict),
headers=self.heade... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_course(self):\r\n self.assert_created_course()",
"def make_course(self, **kwargs):\r\n self.course = CourseFactory.create(**kwargs)\r\n user = UserFactory.create()\r\n CourseEnrollmentFactory.create(user=user, course_id=self.course.id)\r\n self.client.login(user... | [
"0.76689804",
"0.7653774",
"0.73350924",
"0.72051156",
"0.70910674",
"0.70505136",
"0.70354646",
"0.6988811",
"0.690185",
"0.6868761",
"0.68410766",
"0.6839978",
"0.68391967",
"0.6835739",
"0.6774067",
"0.67215884",
"0.66953605",
"0.66687447",
"0.6659502",
"0.66501087",
"0.66... | 0.8094964 | 0 |
Create an XBlock with `parent_loc` (the location of the parent block) and `xblock_desc` (an `XBlockFixtureDesc` instance). | def _create_xblock(self, parent_loc, xblock_desc):
create_payload = {
'category': xblock_desc.category,
'display_name': xblock_desc.display_name,
}
if parent_loc is not None:
create_payload['parent_locator'] = parent_loc
# Create the new XBl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_xblock(self, runtime, category, fields=None, block_id=None, definition_id=None, parent_xblock=None):\r\n xblock_class = runtime.load_block_type(category)\r\n json_data = {\r\n 'category': category,\r\n 'fields': fields or {},\r\n }\r\n if definition_id i... | [
"0.7252264",
"0.71231586",
"0.68086666",
"0.66647965",
"0.6664029",
"0.6289036",
"0.62196326",
"0.6183538",
"0.60991496",
"0.5986656",
"0.5968019",
"0.58566606",
"0.5820241",
"0.5806665",
"0.5773406",
"0.57233775",
"0.5699754",
"0.5686786",
"0.56843084",
"0.56816936",
"0.5635... | 0.88450336 | 0 |
Encode `post_dict` (a dictionary) as UTF8 encoded JSON. | def _encode_post_dict(self, post_dict):
return json.dumps({
k: v.encode('utf-8') if v is not None else v
for k, v in post_dict.items()
}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dict_json_encoding_utf_8(json_dict=dict):\n # type: (dict)->str\n return json.dumps(json_dict, encoding='utf-8', ensure_ascii=False)",
"def __encode_json_dictionary(json_dict:dict):\n\n json_string = json.dumps(json_dict)\n\n return base64.b64encode(json_string.encode()).decode()",
"def... | [
"0.70999765",
"0.6899196",
"0.6446441",
"0.6353656",
"0.62041366",
"0.6186512",
"0.61551934",
"0.6068298",
"0.6049462",
"0.60401994",
"0.6035994",
"0.58781",
"0.58560926",
"0.5846899",
"0.5838879",
"0.57663196",
"0.57617575",
"0.5753998",
"0.5752947",
"0.5735813",
"0.5723777"... | 0.8967628 | 0 |
Course ID is currently of the form "edx/999/2013_Spring" but this format could change. | def __init__(self, browser, course_id):
super(CoursePage, self).__init__(browser)
self.course_id = course_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_course_id(course_data):\r\n return SlashSeparatedCourseKey(course_data['org'], course_data['number'], course_data['run'])",
"def clean_course_id(self):\r\n cleaned_id = self.cleaned_data[\"course_id\"]\r\n try:\r\n course_key = CourseKey.from_string(cleaned_id)\r\n exc... | [
"0.75549996",
"0.72693044",
"0.7171918",
"0.68737787",
"0.67263",
"0.67069846",
"0.66662633",
"0.66629577",
"0.6604551",
"0.65023017",
"0.6491508",
"0.6415044",
"0.64052343",
"0.6310634",
"0.6305837",
"0.62599605",
"0.62403166",
"0.6194568",
"0.6180436",
"0.6175055",
"0.61278... | 0.51762795 | 100 |
Go to the course with `course_id` (e.g. edx/Open_DemoX/edx_demo_course) | def view_course(self, course_id):
link_css = self._link_css(course_id)
if link_css is not None:
self.q(css=link_css).first.click()
else:
msg = "No links found for course {0}".format(course_id)
self.warning(msg) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def course_about(request, course_id):\r\n\r\n if microsite.get_value(\r\n 'ENABLE_MKTG_SITE',\r\n settings.FEATURES.get('ENABLE_MKTG_SITE', False)\r\n ):\r\n raise Http404\r\n course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)\r\n course = get_course_with_access... | [
"0.6991421",
"0.6721529",
"0.6532393",
"0.64985514",
"0.6412017",
"0.64042187",
"0.63293487",
"0.6311007",
"0.63066167",
"0.6274922",
"0.62662756",
"0.62483406",
"0.62321573",
"0.6116765",
"0.6114513",
"0.6106505",
"0.60752434",
"0.6061803",
"0.605835",
"0.6034409",
"0.603310... | 0.74170387 | 0 |
Returns the text of the first element matching the given selector, or None if no such element exists | def _get_element_text(self, selector):
text_list = self._find_within(selector).text
return text_list[0] if text_list else None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_text(self, selector):\n el = self.locate_element(selector)\n return el.text",
"def get_text(self, selector):\n self._wait_element_localed(self.driver, selector)\n element = self.get_element(selector)\n text = element.text\n\n return text",
"def text_or_none(sel... | [
"0.78152287",
"0.7197709",
"0.7143898",
"0.7079664",
"0.70175076",
"0.6848068",
"0.6839316",
"0.68265414",
"0.68011874",
"0.66378343",
"0.6637486",
"0.6616651",
"0.6582851",
"0.65699816",
"0.6378284",
"0.6367606",
"0.63612837",
"0.63196754",
"0.6313576",
"0.62399375",
"0.6238... | 0.8633373 | 0 |
Returns the response count text, or None if not present | def get_response_total_text(self):
return self._get_element_text(".response-count") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_shown_responses_text(self):\r\n return self._get_element_text(\".response-display-count\")",
"def response_count(self) -> int:\n return pulumi.get(self, \"response_count\")",
"def _get_echo_resp_sent_count(self):\n return self.__echo_resp_sent_count",
"def count(self) -> Optional[int... | [
"0.71569556",
"0.7121792",
"0.66261506",
"0.65575737",
"0.65575737",
"0.653364",
"0.65083045",
"0.650509",
"0.6431651",
"0.6426053",
"0.6181215",
"0.6170782",
"0.61277163",
"0.6119513",
"0.611333",
"0.6069534",
"0.6069534",
"0.6069534",
"0.6069534",
"0.6069534",
"0.6069534",
... | 0.7522919 | 0 |
Returns true if the delete comment button is present, false otherwise | def is_comment_deletable(self, comment_id):
return self._is_element_visible("#comment_{} div.action-delete".format(comment_id)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_delete(self) -> bool:\n return \"delete_item\" not in self.__abstractmethods__",
"def can_delete_comment(comment, user):\r\n if user.is_staff or user.is_superuser:\r\n return True\r\n if hasattr(comment, 'user') and comment.user == user:\r\n return True\r\n return False",
... | [
"0.67760175",
"0.66011405",
"0.6575845",
"0.6491653",
"0.6433732",
"0.6420124",
"0.6409524",
"0.6325653",
"0.6318207",
"0.6228136",
"0.61564624",
"0.6142117",
"0.6120892",
"0.6090206",
"0.6041708",
"0.5984539",
"0.5981233",
"0.59721357",
"0.5954789",
"0.59106374",
"0.59014183... | 0.6959623 | 0 |
Return the type of assessment currently active. Options are "self", "ai", or "peer" | def assessment_type(self):
labels = self.q(css='section#combined-open-ended-status>div.statusitem-current').text
if len(labels) < 1:
self.warning("Could not find assessment type label")
# Provide some tolerance to UI changes
label_compare = labels[0].lower().strip()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assessment_type(self) -> str:\n return pulumi.get(self, \"assessment_type\")",
"def assessment_mode(self) -> str:\n return pulumi.get(self, \"assessment_mode\")",
"def assessment_mode(self) -> str:\n return pulumi.get(self, \"assessment_mode\")",
"def current_option(self) -> str | No... | [
"0.70030946",
"0.6849701",
"0.6849701",
"0.6279049",
"0.5870678",
"0.5794739",
"0.57116985",
"0.5669596",
"0.56638086",
"0.56605434",
"0.5646005",
"0.5634365",
"0.5620534",
"0.5603442",
"0.5581257",
"0.55766946",
"0.55766946",
"0.55766946",
"0.55766946",
"0.55766946",
"0.5576... | 0.73314077 | 0 |
Status message from the grader. If not present, return an empty string. | def grader_status(self):
status_list = self.q(css='div.grader-status').text
if len(status_list) < 1:
self.warning("No grader status found")
return ""
elif len(status_list) > 1:
self.warning("Multiple grader statuses found; returning the first one")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_status(self):\n held_msg=\"\"\n return u'%s%s' % (self.get_status_display(), held_msg)",
"def status_message(self) -> Optional[str]:\n return pulumi.get(self, \"status_message\")",
"def get_status(self):\n return self.msg",
"def status_message(self) -> str:\n retur... | [
"0.7768845",
"0.7698746",
"0.7681176",
"0.7569557",
"0.744005",
"0.7339512",
"0.70998675",
"0.7062698",
"0.6861984",
"0.6861984",
"0.6861984",
"0.6861984",
"0.6861984",
"0.6861984",
"0.6861984",
"0.6861984",
"0.6861984",
"0.6808289",
"0.68042177",
"0.67800725",
"0.6734945",
... | 0.7420159 | 5 |
Course ID is currently of the form "edx/999/2013_Spring" but this format could change. | def __init__(self, browser, course_id):
super(RegisterPage, self).__init__(browser)
self._course_id = course_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_course_id(course_data):\r\n return SlashSeparatedCourseKey(course_data['org'], course_data['number'], course_data['run'])",
"def clean_course_id(self):\r\n cleaned_id = self.cleaned_data[\"course_id\"]\r\n try:\r\n course_key = CourseKey.from_string(cleaned_id)\r\n exc... | [
"0.75549996",
"0.72693044",
"0.7171918",
"0.68737787",
"0.67263",
"0.67069846",
"0.66662633",
"0.66629577",
"0.6604551",
"0.65023017",
"0.6491508",
"0.6415044",
"0.64052343",
"0.6310634",
"0.6305837",
"0.62599605",
"0.62403166",
"0.6194568",
"0.6180436",
"0.6175055",
"0.61278... | 0.0 | -1 |
Initialize pages and install a course fixture. | def setUp(self):
super(RegistrationTest, self).setUp()
self.find_courses_page = FindCoursesPage(self.browser)
self.course_about_page = CourseAboutPage(self.browser, self.course_id)
# Create a course to register for
course_fix = CourseFixture(
self.course_inf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\r\n super(CoursePagesTest, self).setUp()\r\n\r\n CourseFixture(\r\n self.course_info['org'],\r\n self.course_info['number'],\r\n self.course_info['run'],\r\n self.course_info['display_name']\r\n ).install()\r\n\r\n self.auth_p... | [
"0.8282417",
"0.76040125",
"0.7183474",
"0.71796674",
"0.71796674",
"0.70454746",
"0.685738",
"0.68541235",
"0.6807795",
"0.6738954",
"0.66194975",
"0.6543731",
"0.6526002",
"0.6412598",
"0.64015865",
"0.6370282",
"0.63253987",
"0.6294786",
"0.6265056",
"0.62492144",
"0.62339... | 0.76128566 | 1 |
Initialize pages and install a course fixture. | def setUp(self):
super(HighLevelTabTest, self).setUp()
self.course_info_page = CourseInfoPage(self.browser, self.course_id)
self.progress_page = ProgressPage(self.browser, self.course_id)
self.course_nav = CourseNavPage(self.browser)
self.tab_nav = TabNavPage(self.browser)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\r\n super(CoursePagesTest, self).setUp()\r\n\r\n CourseFixture(\r\n self.course_info['org'],\r\n self.course_info['number'],\r\n self.course_info['run'],\r\n self.course_info['display_name']\r\n ).install()\r\n\r\n self.auth_p... | [
"0.8282417",
"0.76128566",
"0.76040125",
"0.7183474",
"0.71796674",
"0.71796674",
"0.685738",
"0.68541235",
"0.6807795",
"0.6738954",
"0.66194975",
"0.6543731",
"0.6526002",
"0.6412598",
"0.64015865",
"0.6370282",
"0.63253987",
"0.6294786",
"0.6265056",
"0.62492144",
"0.62339... | 0.70454746 | 6 |
Initialize pages and install a course fixture. | def setUp(self):
super(VideoTest, self).setUp()
self.course_info_page = CourseInfoPage(self.browser, self.course_id)
self.course_nav = CourseNavPage(self.browser)
self.tab_nav = TabNavPage(self.browser)
self.video = VideoPage(self.browser)
# Install a course fix... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\r\n super(CoursePagesTest, self).setUp()\r\n\r\n CourseFixture(\r\n self.course_info['org'],\r\n self.course_info['number'],\r\n self.course_info['run'],\r\n self.course_info['display_name']\r\n ).install()\r\n\r\n self.auth_p... | [
"0.8282417",
"0.76128566",
"0.76040125",
"0.7183474",
"0.71796674",
"0.71796674",
"0.70454746",
"0.685738",
"0.6807795",
"0.6738954",
"0.66194975",
"0.6543731",
"0.6526002",
"0.6412598",
"0.64015865",
"0.6370282",
"0.63253987",
"0.6294786",
"0.6265056",
"0.62492144",
"0.62339... | 0.68541235 | 8 |
Install a test course with ORA problems. Always start in the subsection with open response problems. | def setUp(self):
super(OpenResponseTest, self).setUp()
# Create page objects
self.auth_page = AutoAuthPage(self.browser, course_id=self.course_id)
self.course_info_page = CourseInfoPage(self.browser, self.course_id)
self.tab_nav = TabNavPage(self.browser)
self.cou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _install_course_fixture(self):\r\n if self.assets:\r\n self.course_fixture.add_asset(self.assets)\r\n\r\n chapter_sequential = XBlockFixtureDesc('sequential', 'Test Section')\r\n chapter_sequential.add_children(*self._add_course_verticals())\r\n chapter = XBlockFixtureDes... | [
"0.6350962",
"0.62114507",
"0.6108433",
"0.60954446",
"0.60634583",
"0.6033648",
"0.5912209",
"0.58729047",
"0.5872897",
"0.5856727",
"0.58407325",
"0.582248",
"0.5822253",
"0.58171386",
"0.58171386",
"0.5785828",
"0.57844645",
"0.57558626",
"0.5735907",
"0.57209015",
"0.5719... | 0.6345245 | 1 |
Test negative response with invalid user | def test_bad_student(self):
staff_page = self._goto_staff_page()
staff_page.answer_problem()
staff_debug_page = staff_page.open_staff_debug_info()
staff_debug_page.delete_state('INVALIDUSER')
msg = staff_debug_page.idash_msg[0]
self.assertEqual(u'Failed to delete ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_request_users_user_invalid(self):\n response = requests.get(self.url + '/users/invalid')\n\n self.assertEqual(response.status_code, 404)",
"def test_access_negative(self, api):\n self.builder.add_user(api.get_user())\n r1 = api.access_user(api.get_user(), False)\n acce... | [
"0.70589536",
"0.70502025",
"0.6903529",
"0.685752",
"0.6811523",
"0.6805677",
"0.6791189",
"0.6747452",
"0.667556",
"0.66501343",
"0.66332376",
"0.66256285",
"0.66227764",
"0.662252",
"0.66006565",
"0.65893406",
"0.65893406",
"0.6575141",
"0.65472984",
"0.6544657",
"0.654247... | 0.0 | -1 |
Make sure that you can get to the dashboard page without a course. | def test_dashboard_no_courses(self):
self.auth_page.visit()
self.dashboard_page.visit() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_instructor_course_access(self):\r\n self.login(self.instructor_user)\r\n\r\n # Now should be able to get to self.course, but not self.test_course\r\n url = reverse('instructor_dashboard', kwargs={'course_id': self.course.id.to_deprecated_string()})\r\n check_for_get_code(self,... | [
"0.72981995",
"0.7141651",
"0.7119509",
"0.706196",
"0.7048631",
"0.7034219",
"0.6978209",
"0.6939554",
"0.6908361",
"0.68701243",
"0.68476814",
"0.6794322",
"0.6788033",
"0.67677885",
"0.67495894",
"0.6749225",
"0.6723602",
"0.67220926",
"0.67111117",
"0.6692311",
"0.6576263... | 0.84066397 | 0 |
Install a course with no content using a fixture. | def setUp(self):
super(CoursePagesTest, self).setUp()
CourseFixture(
self.course_info['org'],
self.course_info['number'],
self.course_info['run'],
self.course_info['display_name']
).install()
self.auth_page = AutoAuthPage(self.b... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _install_course_fixture(self):\r\n if self.assets:\r\n self.course_fixture.add_asset(self.assets)\r\n\r\n chapter_sequential = XBlockFixtureDesc('sequential', 'Test Section')\r\n chapter_sequential.add_children(*self._add_course_verticals())\r\n chapter = XBlockFixtureDes... | [
"0.7808761",
"0.6507606",
"0.64201313",
"0.61155766",
"0.6106973",
"0.6106973",
"0.5933164",
"0.5877465",
"0.58606565",
"0.5818078",
"0.5796704",
"0.5775042",
"0.5774167",
"0.5759785",
"0.5740059",
"0.57255274",
"0.572248",
"0.5653657",
"0.56234246",
"0.56198543",
"0.5594114"... | 0.5378643 | 39 |
Prepare the course and get to the video unit however do not wait for it to render, because the has been an error. | def navigate_to_video_no_render(self):
self._install_course_fixture()
self._navigate_to_courseware_video_no_render() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _navigate_to_courseware_video_and_render(self):\r\n self._navigate_to_courseware_video()\r\n self.video.wait_for_video_player_render()",
"def _navigate_to_courseware_video_no_render(self):\r\n self._navigate_to_courseware_video()\r\n self.video.wait_for_video_class()",
"def navi... | [
"0.7187755",
"0.68451035",
"0.64584947",
"0.63607806",
"0.6238985",
"0.61532456",
"0.6130649",
"0.60218024",
"0.58825064",
"0.5834479",
"0.5820916",
"0.5762437",
"0.5753175",
"0.57005346",
"0.56177044",
"0.56038094",
"0.555447",
"0.5548856",
"0.55473435",
"0.5530015",
"0.5518... | 0.65009975 | 2 |
Register for the course and navigate to the video unit | def _navigate_to_courseware_video(self):
AutoAuthPage(self.browser, course_id=self.course_id).visit()
self.course_info_page.visit()
self.tab_nav.go_to_tab('Courseware') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def navigate_to_video(self):\r\n self._install_course_fixture()\r\n self._navigate_to_courseware_video_and_render()",
"def _navigate_to_courseware_video_and_render(self):\r\n self._navigate_to_courseware_video()\r\n self.video.wait_for_video_player_render()",
"def setUp(self):\r\n ... | [
"0.7667031",
"0.68046284",
"0.6792578",
"0.65996",
"0.64599663",
"0.63729817",
"0.6354724",
"0.62829596",
"0.6277192",
"0.6216918",
"0.61717045",
"0.59452873",
"0.5904643",
"0.58777606",
"0.58071166",
"0.57772887",
"0.5777218",
"0.56935346",
"0.5651072",
"0.56465006",
"0.5600... | 0.7471679 | 1 |
Returns the set of locales to be translated (ignoring the source_locale). | def translated_locales(self):
return sorted(set(self.locales) - set([self.source_locale])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getLocales(self):\n pass",
"def get_locales(self) -> List[str]:\n\n return self.possible_locale_list",
"def allLocales(self):\n return util.parseLocales(urlopen(self.all_url).read())",
"def get_available_translations(localedir=None):\n\n localedir = localedir or gettext._default_local... | [
"0.7093997",
"0.7087095",
"0.6553833",
"0.6167475",
"0.61271393",
"0.6123111",
"0.58603424",
"0.57853276",
"0.5683068",
"0.5681859",
"0.56635964",
"0.5566244",
"0.55128956",
"0.55021054",
"0.5465106",
"0.5437513",
"0.54041505",
"0.54009885",
"0.53997386",
"0.53591377",
"0.528... | 0.7905095 | 0 |
This is a generator. Returns the fully expanded filenames for all extracted files Fails assertion if one of the files doesn't exist. | def get_files(self):
for filename in self.generated_files:
path = os.path.join(CONFIGURATION.source_messages_dir, filename)
exists = os.path.exists(path)
self.assertTrue(exists, msg='Missing file: %s' % filename)
if exists:
yield path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_files(self):\n import re\n for year, url in self.metadata.build.sources.items():\n zf = self.filesystem.download(url)\n for fn in self.filesystem.unzip_dir(zf, re.compile(r'.*all.*', re.IGNORECASE)):\n yield year, fn",
"def eachfilename(... | [
"0.64294136",
"0.6419423",
"0.6418118",
"0.62472844",
"0.6134603",
"0.6076132",
"0.60409635",
"0.5996643",
"0.59629387",
"0.5960463",
"0.5859329",
"0.58495116",
"0.583847",
"0.5812835",
"0.57837504",
"0.5776029",
"0.57361674",
"0.57315165",
"0.5721509",
"0.5715944",
"0.570492... | 0.6375901 | 3 |
Returns random filename as string, like test4BZ81W | def random_name(size=6):
chars = string.ascii_uppercase + string.digits
return 'test-' + ''.join(random.choice(chars) for x in range(size)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_filename():\n\n return ''.join(random.choices(string.ascii_uppercase + string.digits, k=5))",
"def create_random_file_name():\n\n def random_file_name_factory():\n length = random.randint(10, 15)\n chars = string.ascii_letters + string.digits + \"-_\"\n return f\"{''.join(ra... | [
"0.8442081",
"0.8029586",
"0.7822746",
"0.7534251",
"0.7502992",
"0.74438566",
"0.73993975",
"0.73796916",
"0.7359657",
"0.733721",
"0.7326632",
"0.7239",
"0.72336316",
"0.7208772",
"0.71404624",
"0.70574075",
"0.70545816",
"0.7035917",
"0.6976221",
"0.69351745",
"0.69201285"... | 0.6630024 | 37 |
Get the count of enrolled students matching the feature value. | def get_count(feature, value):
return CourseEnrollment.objects.filter(
course_id=course_id,
**get_filter(feature, value)
).count() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count(self,value = 1):\n n = 0\n for s in self.sample:\n if s == value:\n n += 1\n return n",
"def num_enrolled_in(cls, course_id):\r\n enrollment_number = CourseEnrollment.objects.filter(course_id=course_id, is_active=1).count()\r\n\r\n return enr... | [
"0.6215665",
"0.6053471",
"0.59922534",
"0.5985372",
"0.59182024",
"0.58712965",
"0.5866586",
"0.58254325",
"0.57913285",
"0.5743052",
"0.57103103",
"0.56276613",
"0.5570912",
"0.5518846",
"0.5495244",
"0.5492273",
"0.54905635",
"0.54823583",
"0.5439658",
"0.540929",
"0.53951... | 0.80131286 | 0 |
Create plain text message. Convert plain text body (`plaintext`) into plaintext email message using the stored plain template and the provided `context` dict. | def render_plaintext(self, plaintext, context):
return CourseEmailTemplate._render(self.plain_template, plaintext, context) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plaintext_only():\n msg = EmailMessage()\n msg[\"From\"] = sender\n msg[\"To\"] = recipient\n msg[\"Subject\"] = \"Plaintext only\"\n msg.set_content(\"This is the body of a plaintext message.\")\n\n return msg",
"def render_email(subject, template_prefix, to_email, context, from_email=None... | [
"0.70558953",
"0.6457034",
"0.63837767",
"0.6360517",
"0.6156275",
"0.6134871",
"0.60626274",
"0.6055863",
"0.59894615",
"0.5983271",
"0.59811634",
"0.5980337",
"0.59234464",
"0.59234464",
"0.591321",
"0.58424366",
"0.5835025",
"0.5825519",
"0.5825519",
"0.5818378",
"0.578373... | 0.7602155 | 0 |
Returns whether or not email is enabled for the given course id. If email has not been explicitly enabled, returns False. | def instructor_email_enabled(cls, course_id):
# If settings.FEATURES['REQUIRE_COURSE_EMAIL_AUTH'] is
# set to False, then we enable email for every course.
if not settings.FEATURES['REQUIRE_COURSE_EMAIL_AUTH']:
return True
try:
record = cls.objects.get(cou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def emails_disabled(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"emails_disabled\")",
"def emails_disabled(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"emails_disabled\")",
"def emails_disabled(self) -> pulumi.Output[bool]:\n return pulumi.get(se... | [
"0.6410162",
"0.6410162",
"0.63928884",
"0.5980464",
"0.59285027",
"0.57694143",
"0.57535213",
"0.56601906",
"0.5636747",
"0.5628749",
"0.557292",
"0.5547813",
"0.5545748",
"0.55085266",
"0.55085266",
"0.54508585",
"0.5420065",
"0.5412655",
"0.53323394",
"0.5331028",
"0.53254... | 0.8776417 | 0 |
Test response when email is disabled for course. | def test_email_disabled(self):
test_email = {
'action': 'Send email',
'send_to': 'myself',
'subject': 'test subject for myself',
'message': 'test message for myself'
}
response = self.client.post(self.send_mail_url, test_email)
# We... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_send_mail_unauthorized(self):\r\n\r\n response = self.client.post(\r\n self.url, {\r\n 'action': 'Send email',\r\n 'to_option': 'all',\r\n 'subject': \"Welcome to the course!\",\r\n 'message': \"Lets start with an introduction!\... | [
"0.77057666",
"0.74273306",
"0.7325756",
"0.7179017",
"0.68696094",
"0.66738045",
"0.6532277",
"0.6516731",
"0.6485321",
"0.6479449",
"0.6450182",
"0.6287598",
"0.62756747",
"0.6274359",
"0.626104",
"0.61926806",
"0.61782825",
"0.6173168",
"0.6158762",
"0.6158762",
"0.6156764... | 0.81033045 | 0 |
Tests exception when the course in the email doesn't exist | def test_nonexistent_course(self):
course_id = SlashSeparatedCourseKey("I", "DONT", "EXIST")
email = CourseEmail(course_id=course_id)
email.save()
entry = InstructorTask.create(course_id, "task_type", "task_key", "task_input", self.instructor)
task_input = {"email_id": email... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_course_does_not_exist(self):\n self.client.login(username=self.student.username, password=self.password)\n base_url = reverse(\n self.namespaced_url,\n kwargs={\n 'course_id': 'course-v1:MITx+8.MechCX+2014_T1',\n }\n )\n url = f\"... | [
"0.75935173",
"0.7519906",
"0.73814833",
"0.73232",
"0.7223531",
"0.69809246",
"0.69378805",
"0.6924819",
"0.69219893",
"0.67680067",
"0.6766058",
"0.6753396",
"0.67431384",
"0.66928273",
"0.6669861",
"0.66117823",
"0.66034853",
"0.659229",
"0.6586259",
"0.6564418",
"0.652306... | 0.80212456 | 0 |
Tests exception when the to_option in the email doesn't exist | def test_nonexistent_to_option(self):
email = CourseEmail(course_id=self.course.id, to_option="IDONTEXIST")
email.save()
entry = InstructorTask.create(self.course.id, "task_type", "task_key", "task_input", self.instructor)
task_input = {"email_id": email.id} # pylint: disable=E1101
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_compose_email_somebad(self):\n pass",
"def test_invalid_email_when_logging_in(self):\n pass",
"def test_compose_email2_good(self):\n pass",
"def test_empty_email():\n expect_error(register, InputError, \"a\", \"abdkjjd\", \"a\", \"A\", \"\")",
"def _checkEmailOption(args, s... | [
"0.6738066",
"0.65240574",
"0.63824505",
"0.628924",
"0.6202352",
"0.61972064",
"0.61789",
"0.6130065",
"0.612689",
"0.612414",
"0.60808456",
"0.60550326",
"0.6006743",
"0.5944662",
"0.5944315",
"0.59339327",
"0.5931328",
"0.59167784",
"0.59086514",
"0.58681947",
"0.5859767",... | 0.7500362 | 0 |
Tests exception when the course_id in task is not the same as one explicitly passed in. | def test_wrong_course_id_in_task(self):
email = CourseEmail(course_id=self.course.id, to_option=SEND_TO_ALL)
email.save()
entry = InstructorTask.create("bogus/task/id", "task_type", "task_key", "task_input", self.instructor)
task_input = {"email_id": email.id} # pylint: disable=E110... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _test_undefined_course(self, task_class):\r\n task_entry = self._create_input_entry(course_id=\"bogus/course/id\")\r\n with self.assertRaises(ItemNotFoundError):\r\n self._run_task_with_mock_celery(task_class, task_entry.id, task_entry.task_id)",
"def test_wrong_course_id_in_email(se... | [
"0.7624101",
"0.75454146",
"0.6801898",
"0.6400998",
"0.6361911",
"0.624596",
"0.62282073",
"0.61889297",
"0.6184139",
"0.61447936",
"0.6140014",
"0.612624",
"0.6112731",
"0.6106207",
"0.60772973",
"0.60479057",
"0.60370505",
"0.6018855",
"0.6002463",
"0.59904426",
"0.5985179... | 0.8153526 | 0 |
Tests exception when the course_id in CourseEmail is not the same as one explicitly passed in. | def test_wrong_course_id_in_email(self):
email = CourseEmail(course_id=SlashSeparatedCourseKey("bogus", "course", "id"), to_option=SEND_TO_ALL)
email.save()
entry = InstructorTask.create(self.course.id, "task_type", "task_key", "task_input", self.instructor)
task_input = {"email_id":... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_wrong_course_id_in_task(self):\r\n email = CourseEmail(course_id=self.course.id, to_option=SEND_TO_ALL)\r\n email.save()\r\n entry = InstructorTask.create(\"bogus/task/id\", \"task_type\", \"task_key\", \"task_input\", self.instructor)\r\n task_input = {\"email_id\": email.id} ... | [
"0.7753778",
"0.7046368",
"0.6828902",
"0.6812808",
"0.66637546",
"0.6562966",
"0.6487516",
"0.6316158",
"0.6310329",
"0.6295797",
"0.6281416",
"0.62687796",
"0.62286365",
"0.6203208",
"0.61888546",
"0.6179946",
"0.61716974",
"0.61260235",
"0.6121648",
"0.6102917",
"0.6094077... | 0.82161945 | 0 |
Returns true if the `user` is an instructor for the course. | def has_instructor_access_for_class(user, course_id):
course = get_course_with_access(user, 'staff', course_id, depth=None)
return has_access(user, 'staff', course) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_instructor(self):\n # pylint: disable=no-member\n return self.xmodule_runtime.get_user_role() == 'instructor'",
"def has_instructor(self, user, allow_superusers=True):\n return (user.is_superuser and allow_superusers) or len(self.instructors.filter(id=user.id)) > 0",
"def is_instruc... | [
"0.76412964",
"0.7549649",
"0.7056647",
"0.69144547",
"0.67706746",
"0.6756618",
"0.66180205",
"0.6616132",
"0.6518098",
"0.64525497",
"0.6450732",
"0.64035004",
"0.63512963",
"0.6344585",
"0.6341001",
"0.6184008",
"0.6075976",
"0.6063987",
"0.60577804",
"0.604527",
"0.589574... | 0.76374173 | 1 |
Check whether a user has the access to do action on obj. Handles any magic switching based on various settings. | def has_access(user, action, obj, course_key=None):
# Just in case user is passed in as None, make them anonymous
if not user:
user = AnonymousUser()
# delegate the work to type-specific functions.
# (start with more specific types, then get more general)
if isinstance(obj, CourseDes... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_object_permission(self, request, view, obj):\n return request.user == obj",
"def has_object_permission(self, request, view, obj):\n # if the user is trying to retrieve to create a item.. it will return true\n if request.method in permissions.SAFE_METHODS:\n return True\n ... | [
"0.77711433",
"0.7726961",
"0.7718259",
"0.76810753",
"0.766425",
"0.76604754",
"0.7658015",
"0.7653245",
"0.7614711",
"0.7613074",
"0.76073533",
"0.7548031",
"0.7531675",
"0.7528472",
"0.74728173",
"0.7467154",
"0.7466981",
"0.74646765",
"0.746313",
"0.74588895",
"0.7436291"... | 0.7474068 | 14 |
Check if user has access to a course descriptor. | def _has_access_course_desc(user, action, course):
def can_load():
"""
Can this user load this course?
NOTE: this is not checking whether user is actually enrolled in the course.
"""
# delegate to generic descriptor check to check start dates
return _has_acce... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _has_instructor_access_to_descriptor(user, descriptor, course_key): # pylint: disable=invalid-name\r\n return _has_instructor_access_to_location(user, descriptor.location, course_key)",
"def _has_access_descriptor(user, action, descriptor, course_key=None):\r\n def can_load():\r\n \"\"\"\r\n ... | [
"0.8081699",
"0.77481306",
"0.76806027",
"0.7082301",
"0.7028319",
"0.70242417",
"0.69625396",
"0.68995625",
"0.68932486",
"0.6775686",
"0.67720586",
"0.65645754",
"0.6562731",
"0.6549636",
"0.6546511",
"0.6536085",
"0.6471673",
"0.6458647",
"0.6449811",
"0.64438045",
"0.6409... | 0.7641454 | 3 |
Can this user load this course? | def can_load():
# delegate to generic descriptor check to check start dates
return _has_access_descriptor(user, 'load', course, course.id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _has_access_course_desc(user, action, course):\r\n def can_load():\r\n \"\"\"\r\n Can this user load this course?\r\n\r\n NOTE: this is not checking whether user is actually enrolled in the course.\r\n \"\"\"\r\n # delegate to generic descriptor check to check start dates\... | [
"0.7046981",
"0.66222256",
"0.6526042",
"0.64902955",
"0.6240273",
"0.6163539",
"0.61610687",
"0.61349314",
"0.61280817",
"0.6107775",
"0.60852045",
"0.60666627",
"0.6053351",
"0.6047911",
"0.60262656",
"0.597511",
"0.59646",
"0.5941255",
"0.591786",
"0.5915296",
"0.59029037"... | 0.77919745 | 0 |
Check if user has access to this descriptor. | def _has_access_descriptor(user, action, descriptor, course_key=None):
def can_load():
"""
NOTE: This does not check that the student is enrolled in the course
that contains this module. We may or may not want to allow non-enrolled
students to see modules. If not, views should... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_user_has_access(self):\n return self.user_has_access(users.get_current_user())",
"def has_access(self, user):\n if user.is_superuser:\n return True\n return self.user_objects(user).filter(id=self.id).exists()",
"def user_has_access(self, user):\n if self.visibilit... | [
"0.8097304",
"0.7962327",
"0.772044",
"0.7556903",
"0.75112677",
"0.74926335",
"0.7484404",
"0.74448925",
"0.74140525",
"0.7405168",
"0.7405168",
"0.7405168",
"0.7370347",
"0.73693395",
"0.7282778",
"0.7275459",
"0.726787",
"0.7252788",
"0.7236161",
"0.7234116",
"0.72263086",... | 0.69110584 | 73 |
Check if user has access to this xmodule. | def _has_access_xmodule(user, action, xmodule, course_key):
# Delegate to the descriptor
return has_access(user, action, xmodule.descriptor, course_key) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_user_has_access(self):\n return self.user_has_access(users.get_current_user())",
"def has_module_permission(self, request):\n if request.user.groups.filter(name__in=['Sellers', 'Supporters']).exists():\n return True\n return False",
"def has_access(self, user):\n ... | [
"0.8142638",
"0.7611717",
"0.75791585",
"0.74543196",
"0.7448139",
"0.74159044",
"0.7331683",
"0.7331683",
"0.7331683",
"0.7326514",
"0.7307256",
"0.7250407",
"0.7188936",
"0.7182665",
"0.71717167",
"0.7123095",
"0.7075409",
"0.70740813",
"0.7059868",
"0.7037536",
"0.69634473... | 0.78738683 | 1 |
Check if user has access to this location. | def _has_access_location(user, action, location, course_key):
checkers = {
'staff': lambda: _has_staff_access_to_location(user, location, course_key)
}
return _dispatch(checkers, action, user, location) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_user_has_access(self):\n return self.user_has_access(users.get_current_user())",
"def has_access(self):\n self._has_access = False\n\n if self.read_contact_info is not None:\n if self.read_contact_info['USERNAME'] == consts.USERNAME or \\\n consts.USERNAME in... | [
"0.8045186",
"0.77502805",
"0.7657084",
"0.7326014",
"0.7326014",
"0.7326014",
"0.729074",
"0.72806543",
"0.7126278",
"0.7006277",
"0.6974516",
"0.6955445",
"0.6939202",
"0.693477",
"0.693477",
"0.6907451",
"0.6897502",
"0.6884003",
"0.6861564",
"0.6840213",
"0.6839658",
"0... | 0.7114521 | 9 |
Check if user has access to the course with this course_key | def _has_access_course_key(user, action, course_key):
checkers = {
'staff': lambda: _has_staff_access_to_location(user, None, course_key),
'instructor': lambda: _has_instructor_access_to_location(user, None, course_key),
}
return _dispatch(checkers, action, user, course_key) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_course_access(user, course_key, role=CourseStaffRole):\r\n if GlobalStaff().has_user(user):\r\n return True\r\n return auth.has_access(user, role(course_key))",
"def has_course(self, course_key):\r\n if not (self.user.is_authenticated() and self.user.is_active):\r\n return ... | [
"0.8113183",
"0.79094017",
"0.73681295",
"0.7131429",
"0.7106778",
"0.6966545",
"0.6910267",
"0.682639",
"0.670503",
"0.66795063",
"0.6674519",
"0.6664081",
"0.66631764",
"0.65184754",
"0.6497686",
"0.6488006",
"0.6484573",
"0.6472863",
"0.6463141",
"0.64606845",
"0.64519656"... | 0.8001567 | 1 |
Helper method that checks whether the user has staff access to the course of the location. | def _has_instructor_access_to_descriptor(user, descriptor, course_key): # pylint: disable=invalid-name
return _has_instructor_access_to_location(user, descriptor.location, course_key) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_course_staff(self):\n # pylint: disable=no-member\n return getattr(self.xmodule_runtime, 'user_is_staff', False)",
"def is_course_staff(self):\n # pylint: disable=no-member\n return getattr(self.xmodule_runtime, 'user_is_staff', False)",
"def is_staff(self):\n\t\treturn self.... | [
"0.74596995",
"0.74596995",
"0.7403295",
"0.73815364",
"0.7374605",
"0.7257984",
"0.7256288",
"0.72260946",
"0.72260946",
"0.71963775",
"0.71826214",
"0.71826214",
"0.71826214",
"0.7171786",
"0.70772076",
"0.7024924",
"0.69838166",
"0.6931539",
"0.6833902",
"0.67269826",
"0.6... | 0.6263529 | 46 |
Helper method that checks whether the user has staff access to the course of the location. | def _has_staff_access_to_descriptor(user, descriptor, course_key):
return _has_staff_access_to_location(user, descriptor.location, course_key) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_course_staff(self):\n # pylint: disable=no-member\n return getattr(self.xmodule_runtime, 'user_is_staff', False)",
"def is_course_staff(self):\n # pylint: disable=no-member\n return getattr(self.xmodule_runtime, 'user_is_staff', False)",
"def is_staff(self):\n\t\treturn self.... | [
"0.74596995",
"0.74596995",
"0.7403295",
"0.7374605",
"0.7257984",
"0.7256288",
"0.72260946",
"0.72260946",
"0.71963775",
"0.71826214",
"0.71826214",
"0.71826214",
"0.7171786",
"0.70772076",
"0.7024924",
"0.69838166",
"0.6931539",
"0.6833902",
"0.67269826",
"0.66777724",
"0.6... | 0.73815364 | 3 |
Sorts a list of courses by their announcement date. If the date is not available, sort them by their start date. | def sort_by_announcement(courses):
# Sort courses by how far are they from they start day
key = lambda course: course.sorting_score
courses = sorted(courses, key=key)
return courses | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sorted_courses(self, include_unscheduled=False) -> List[Course]:\n return sorted(\n filter(\n lambda c: c.time is not None or include_unscheduled, self.get_courses()\n ),\n key=lambda c: (0, 0) if not c.time else (c.weekday(), c.time.start),\n )... | [
"0.59686023",
"0.5965024",
"0.5756154",
"0.5721303",
"0.56587714",
"0.56257683",
"0.54293036",
"0.5335714",
"0.53313637",
"0.52889013",
"0.52329147",
"0.5228138",
"0.52021295",
"0.51994926",
"0.5180485",
"0.5145523",
"0.51429576",
"0.5127328",
"0.5120068",
"0.51098776",
"0.51... | 0.82256895 | 0 |
r"""that a course has an annotatable component with (?P\d+) annotations$ | def define_component(self, step, count):
count = int(count)
coursenum = 'test_course'
i_am_registered_for_the_course(step, coursenum)
world.scenario_dict['ANNOTATION_VERTICAL'] = world.ItemFactory(
parent_location=world.scenario_dict['SECTION'].location,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sequence_annotate(self):\n self.t(\"1,2 annotate note\")\n code, out, err = self.t(\"_get 1.annotations.1.description 2.annotations.1.description\")\n self.assertEqual(\"note note\\n\", out)",
"def annotate(m, ss_seq): # -> None:\n ...",
"def isOk(annots):\n if annots == []:\n... | [
"0.5875146",
"0.55578995",
"0.5453736",
"0.5412457",
"0.54065573",
"0.5382905",
"0.53683305",
"0.523951",
"0.5203274",
"0.51730347",
"0.5126791",
"0.5109073",
"0.50882936",
"0.5079143",
"0.5076882",
"0.50729257",
"0.5057978",
"0.5057971",
"0.50538343",
"0.49862885",
"0.494495... | 0.49415416 | 21 |
Total duration of the video, in seconds. | def duration():
elapsed_time, duration = video_time()
return duration | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def video_duration(self):\n # type: () -> int\n return self._video_duration",
"def duration_seconds(self):\n duration = 0.0\n if self.is_video() or self.is_audio():\n if self.__dict__['duration']:\n try:\n duration = float(self.__dict__['du... | [
"0.86572087",
"0.81173015",
"0.8051628",
"0.78134835",
"0.77336496",
"0.7732309",
"0.773135",
"0.7729803",
"0.77236676",
"0.7716521",
"0.77161247",
"0.7705715",
"0.7705715",
"0.7705715",
"0.7705715",
"0.7705715",
"0.7705715",
"0.7705715",
"0.7705715",
"0.7678941",
"0.76706064... | 0.8940862 | 0 |
This returns all of the descendants of a descriptor. If the descriptor has dynamic children, the module will be created using module_creator and the children (as descriptors) of that module will be returned. | def yield_dynamic_descriptor_descendents(descriptor, module_creator):
def get_dynamic_descriptor_children(descriptor):
if descriptor.has_dynamic_children():
module = module_creator(descriptor)
if module is None:
return []
return module.get_child_desc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_child_descriptors(descriptor, depth, descriptor_filter):\r\n if descriptor_filter(descriptor):\r\n descriptors = [descriptor]\r\n else:\r\n descriptors = []\r\n\r\n if depth is None or depth > 0:\r\n new_depth = depth - 1 if dept... | [
"0.7862194",
"0.73171365",
"0.68371236",
"0.6713046",
"0.6636622",
"0.6480913",
"0.6183964",
"0.61806214",
"0.6154407",
"0.5991575",
"0.59713686",
"0.59620696",
"0.5931775",
"0.5926146",
"0.5894748",
"0.58227015",
"0.57527167",
"0.57391137",
"0.5727665",
"0.5725252",
"0.57182... | 0.72565323 | 2 |
Yields the values from items in chunks of size chunk_size | def chunks(items, chunk_size):
items = list(items)
return (items[i:i + chunk_size] for i in xrange(0, len(items), chunk_size)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_chunks(vals, size):\n for i in range(0, len(vals), size):\n yield vals[i:i + size]",
"def chunk(items, chunk_size):\n start_index = 0\n for start_index in xrange(0, len(items), chunk_size):\n end_index = min(start_index+chunk_size, len(items))\n yield items[start_index:end_i... | [
"0.80819196",
"0.80435675",
"0.773785",
"0.7727106",
"0.7726286",
"0.76837945",
"0.762391",
"0.759855",
"0.7573987",
"0.75342876",
"0.75166476",
"0.74383414",
"0.7424603",
"0.7413448",
"0.7413448",
"0.7413448",
"0.7410609",
"0.74083394",
"0.73967093",
"0.7382117",
"0.73690414... | 0.76307815 | 6 |
Return a package resource for the specified XBlock. | def xblock_resource(request, block_type, uri): # pylint: disable=unused-argument
try:
xblock_class = XBlock.load_class(block_type, select=settings.XBLOCK_SELECT_FUNCTION)
content = xblock_class.open_local_resource(uri)
except IOError:
log.info('Failed to load xblock resource', exc_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xblock_resource_pkg(block):\n # XModules are a special case because they map to different dirs for\n # sub-modules.\n module_name = block.__module__\n if module_name.startswith('xmodule.'):\n return module_name\n\n return module_name.rsplit('.', 1)[0]",
"def xblock_resource(request, blo... | [
"0.7584072",
"0.5838558",
"0.581237",
"0.5676023",
"0.5659006",
"0.5594816",
"0.53200305",
"0.52900904",
"0.5251955",
"0.52289414",
"0.52049756",
"0.5172312",
"0.5102771",
"0.50852406",
"0.50852406",
"0.50852406",
"0.49761835",
"0.49324977",
"0.49170926",
"0.48867318",
"0.483... | 0.589946 | 1 |
Check that we got the expected code when accessing url via POST. Returns the HTTP response. `self` is a class that subclasses TestCase. `code` is a status code for HTTP responses. `url` is a url pattern for which we want to test the response. | def check_for_post_code(self, code, url, data={}):
resp = self.client.post(url, data)
self.assertEqual(resp.status_code, code,
"got code %d for url '%s'. Expected code %d"
% (resp.status_code, url, code))
return resp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_for_get_code(self, code, url):\r\n resp = self.client.get(url)\r\n self.assertEqual(resp.status_code, code,\r\n \"got code %d for url '%s'. Expected code %d\"\r\n % (resp.status_code, url, code))\r\n return resp",
"def test_view_success_code(self):\n ... | [
"0.73557484",
"0.6367812",
"0.6367812",
"0.6367812",
"0.6367812",
"0.6367812",
"0.6358653",
"0.61974454",
"0.61974454",
"0.61974454",
"0.61974454",
"0.61974454",
"0.61974454",
"0.61974454",
"0.61974454",
"0.61974454",
"0.61974454",
"0.61974454",
"0.61974454",
"0.61974454",
"0... | 0.8447823 | 0 |
Create a request object for user. | def get_request_for_user(user):
request = RequestFactory()
request.user = user
request.META = {}
request.is_secure = lambda: True
request.get_host = lambda: "edx.org"
return request | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_request(self, user=None):\n if user is None:\n user = self.honor_user\n request = Request(self.request_factory.get('/'))\n request.user = user\n return request",
"def create_user_request(self, user_request):\n request_meta = json.dumps(user_request['request_... | [
"0.8133377",
"0.6943831",
"0.6933943",
"0.6914224",
"0.69083554",
"0.69076943",
"0.6820671",
"0.68001205",
"0.6782085",
"0.66864824",
"0.66655576",
"0.6608735",
"0.6533378",
"0.64726835",
"0.6444535",
"0.6439539",
"0.64158183",
"0.64025927",
"0.63942355",
"0.6383346",
"0.6362... | 0.76747924 | 1 |
Test login the setup function does all the work. | def test_activate_login(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_login(self):\n self._configure_testshib_provider()\n self._test_login()",
"def setUp(self): \n self.client = app.test_client()\n self.acceso = login(self.client)\n identity_loaded.connect(_on_principal_init)",
"def setUp(self):\n logging.debug('setting ... | [
"0.79013246",
"0.7741121",
"0.7599444",
"0.7599444",
"0.7523758",
"0.7518283",
"0.75056195",
"0.7504992",
"0.74985886",
"0.7478486",
"0.7454289",
"0.7431473",
"0.7430175",
"0.7428174",
"0.7427076",
"0.7404589",
"0.7397558",
"0.73729897",
"0.73633957",
"0.7359733",
"0.73444283... | 0.76374567 | 2 |
Assert that all pages in the course load correctly. `course_id` is the ID of the course to check. | def check_all_pages_load(self, course_key):
store = modulestore()
# Enroll in the course before trying to access pages
course = store.get_course(course_key)
self.enroll(course, True)
# Search for items in the course
items = store.get_items(course_key)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_course(self, course, course_id='edX/toy/2012_Fall'):\n assert course_id == str(course.id)",
"def test_render_page_big_course(self):\n url = reverse('completion_view', kwargs={'course_id': self.course.id})\n self.response = self.staff_client.get(url)\n self.assertEqual(self.... | [
"0.7042764",
"0.6823567",
"0.6766555",
"0.67437136",
"0.6722491",
"0.670321",
"0.66990966",
"0.66294605",
"0.652298",
"0.6451752",
"0.6448133",
"0.6421182",
"0.6402258",
"0.6383052",
"0.63240004",
"0.6291693",
"0.6253488",
"0.6241355",
"0.6187359",
"0.6173506",
"0.6152006",
... | 0.761711 | 0 |
Ensure has_access handles a user being passed as null | def test__user_passed_as_none(self):
access.has_access(None, 'staff', 'global', None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_access_allowed(self, user_id):\n ### DATABASE CODE GOES HERE\n return False",
"def has_access(self, user):\n if user.is_superuser:\n return True\n return self.user_objects(user).filter(id=self.id).exists()",
"def has_object_permission(self, request, view, user):\n ... | [
"0.6764999",
"0.66393954",
"0.65840006",
"0.65829015",
"0.6536139",
"0.6533454",
"0.6517244",
"0.6499423",
"0.64810914",
"0.64397264",
"0.6436567",
"0.63980025",
"0.6381931",
"0.6377291",
"0.6338842",
"0.6287365",
"0.6286596",
"0.6278351",
"0.6277061",
"0.6269047",
"0.626178"... | 0.8471188 | 0 |
Tests that get_cms_course_link_by_id and get_cms_block_link_by_id return the right thing | def test_get_cms_course_block_link(self):
self.course = CourseFactory.create(
org='org', number='num', display_name='name'
)
cms_url = u"//{}/course/slashes:org+num+name".format(CMS_BASE_TEST)
self.assertEqual(cms_url, get_cms_course_link(self.course))
cms_url... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_cms_imported_course_walkthrough(self):\r\n def test_get_html(handler):\r\n # Helper function for getting HTML for a page in Studio and\r\n # checking that it does not error.\r\n resp = self.client.get_html(\r\n get_url(handler, course_key, 'course_key... | [
"0.67945874",
"0.64487123",
"0.6359713",
"0.6218109",
"0.61804205",
"0.6077192",
"0.6051277",
"0.60482985",
"0.59748966",
"0.5962627",
"0.5950492",
"0.59384924",
"0.5926657",
"0.5905347",
"0.5900261",
"0.58986825",
"0.5870593",
"0.5821793",
"0.5797571",
"0.57975507",
"0.57773... | 0.86367106 | 0 |
Create course, 2 chapters, 2 sections | def setUp(self):
self.course = CourseFactory.create(display_name=self.COURSE_NAME, number=self.COURSE_SLUG)
self.chapter1 = ItemFactory.create(
parent_location=self.course.location,
display_name="chapter1",
category='chapter')
self.section1 = ItemFactory... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_course(self):\r\n super(TestPublish, self)._create_course(split=False)\r\n\r\n self._create_item('chapter', 'Chapter1', {}, {'display_name': 'Chapter 1'}, 'course', 'runid', split=False)\r\n self._create_item('chapter', 'Chapter2', {}, {'display_name': 'Chapter 2'}, 'course', 'runi... | [
"0.7176095",
"0.6954658",
"0.68545",
"0.6833363",
"0.67807233",
"0.6667957",
"0.6658229",
"0.66437274",
"0.6536673",
"0.64460194",
"0.6442501",
"0.6441651",
"0.6437317",
"0.64023334",
"0.6375915",
"0.6344063",
"0.62689334",
"0.61738867",
"0.6158038",
"0.61236113",
"0.6111082"... | 0.62069535 | 17 |
Tests what happens when the lti listing rest endpoint gets a bad course_id | def test_lti_rest_bad_course(self):
bad_ids = [u"sf", u"dne/dne/dne", u"fo/ey/\u5305"]
request = mock.Mock()
request.method = 'GET'
for bad_course_id in bad_ids:
response = get_course_lti_endpoints(request, bad_course_id)
self.assertEqual(404, response.statu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_get_course_by_id_not_integer(client):\n add_course(client=client, times=10)\n response = client.get(\n \"/api/1.0/courses/not_int\"\n )\n error_response = (\n b'<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\\n'\n b'<title>404 Not Found</title>\\n'\n ... | [
"0.77569044",
"0.7672581",
"0.76622707",
"0.7586275",
"0.7433619",
"0.7291196",
"0.7050525",
"0.6997218",
"0.6988733",
"0.6950452",
"0.6936455",
"0.69309384",
"0.68857163",
"0.6870749",
"0.6855487",
"0.6846242",
"0.67932403",
"0.6773205",
"0.6733077",
"0.6720461",
"0.6691822"... | 0.8169756 | 0 |
Make sure we see the right content on the homepage if we are not in a microsite | def test_not_microsite_anonymous_homepage_content(self):
resp = self.client.get('/')
self.assertEqual(resp.status_code, 200)
# assert various branding definitions on this Microsite ARE NOT VISIBLE
self.assertNotContains(resp, 'This is a Test Microsite Overlay') # Overlay test... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_microsite_anonymous_homepage_content(self):\r\n\r\n resp = self.client.get('/', HTTP_HOST=MICROSITE_TEST_HOSTNAME)\r\n self.assertEqual(resp.status_code, 200)\r\n\r\n # assert various branding definitions on this Microsite\r\n # as per the configuration and Microsite overrides\... | [
"0.75232047",
"0.66365117",
"0.66141385",
"0.6415771",
"0.6375876",
"0.63654965",
"0.62982535",
"0.62587553",
"0.62492204",
"0.61790746",
"0.6166509",
"0.6140028",
"0.6115735",
"0.61125946",
"0.60858583",
"0.6075525",
"0.60493815",
"0.6042014",
"0.59976965",
"0.59680885",
"0.... | 0.7638807 | 0 |
This test validates that the /jump_to_id/ shorthand for intracourse linking works assertIn expected. Note there's a HTML element in the 'toy' course with the url_name 'toyjumpto' which defines this linkage | def test_module_render_with_jump_to_id(self):
mock_request = MagicMock()
mock_request.user = self.mock_user
course = get_course_with_access(self.mock_user, 'load', self.course_key)
field_data_cache = FieldDataCache.cache_for_descriptor_descendents(
self.course_key, s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_url_tranform(self):\r\n response = self.client.get('/courses/edx/math101/2014/wiki/math101/')\r\n self.assertIn('/courses/edx/math101/2014/wiki/math101/_edit/', response.content)\r\n self.assertIn('/courses/edx/math101/2014/wiki/math101/_settings/', response.content)",
"def test_pag... | [
"0.5859107",
"0.5809681",
"0.56636614",
"0.5663647",
"0.56213784",
"0.55696213",
"0.55686325",
"0.55675435",
"0.55080914",
"0.550045",
"0.5494387",
"0.5486039",
"0.547496",
"0.5471687",
"0.5465954",
"0.5465374",
"0.5460201",
"0.54488665",
"0.5444181",
"0.5441185",
"0.54382145... | 0.6729143 | 0 |
Regular Studio courses should see 'View in Studio' links. | def test_view_in_studio_link_studio_course(self):
self.setup_mongo_course()
result_fragment = self.module.render('student_view')
self.assertIn('View Unit in Studio', result_fragment.content) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_view_in_studio_link_xml_authored(self):\r\n self.setup_mongo_course(course_edit_method='XML')\r\n result_fragment = self.module.render('student_view')\r\n self.assertNotIn('View Unit in Studio', result_fragment.content)",
"def test_view_in_studio_link_xml_authored(self):\r\n ... | [
"0.72927946",
"0.72927946",
"0.70517457",
"0.6968205",
"0.69486326",
"0.6778731",
"0.67560464",
"0.67560464",
"0.6709523",
"0.6667161",
"0.6647675",
"0.6613458",
"0.66007864",
"0.66003925",
"0.65628946",
"0.65032065",
"0.6449698",
"0.6428085",
"0.64079154",
"0.6328134",
"0.63... | 0.7753072 | 0 |
Regular Studio courses should not see 'View in Studio' for child verticals of verticals. | def test_view_in_studio_link_only_in_top_level_vertical(self):
self.setup_mongo_course()
# Render the parent vertical, then check that there is only a single "View Unit in Studio" link.
result_fragment = self.module.render('student_view')
# The single "View Unit in Studio" link shoul... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_export_failure_subsection_level(self):\r\n vertical = ItemFactory.create(parent_location=self.course.location, category='vertical', display_name='foo')\r\n ItemFactory.create(\r\n parent_location=vertical.location,\r\n category='aawefawef'\r\n )\r\n\r\n se... | [
"0.6286532",
"0.6083359",
"0.60626996",
"0.60626996",
"0.603002",
"0.6007336",
"0.6007336",
"0.59179413",
"0.5800635",
"0.5732942",
"0.57291824",
"0.5692172",
"0.56824106",
"0.56716603",
"0.56427044",
"0.5591746",
"0.55359584",
"0.552019",
"0.5501907",
"0.537001",
"0.5362658"... | 0.7641207 | 0 |
Mixed mongo courses that are mongo backed should see 'View in Studio' links. | def test_view_in_studio_link_mongo_backed(self):
self.setup_mongo_course()
result_fragment = self.module.render('student_view')
self.assertIn('View Unit in Studio', result_fragment.content) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_view_in_studio_link_studio_course(self):\r\n self.setup_mongo_course()\r\n result_fragment = self.module.render('student_view')\r\n self.assertIn('View Unit in Studio', result_fragment.content)",
"def test_view_in_studio_link_xml_authored(self):\r\n self.setup_mongo_course(co... | [
"0.7109084",
"0.6546867",
"0.6546867",
"0.62119055",
"0.6132229",
"0.6041701",
"0.6001178",
"0.5946457",
"0.5907335",
"0.58674365",
"0.58490235",
"0.5846289",
"0.5815",
"0.57841295",
"0.57474667",
"0.5744629",
"0.5735803",
"0.56937724",
"0.5675217",
"0.56718475",
"0.5625481",... | 0.743432 | 0 |
Make sure password are viewed as expired in LMS after the policy time has elapsed | def test_forced_password_change(self):
student_email, student_password = self._setup_user()
staff_email, staff_password = self._setup_user(is_staff=True)
self._login(student_email, student_password)
self._login(staff_email, staff_password)
staff_reset_time = timezone.n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_password_expire(self):\n user_dn = \"cn=skip,ou=nerdherd,dc=bonsai,dc=test\"\n cli = LDAPClient(\"ldap://%s\" % self.ipaddr)\n cli.set_password_policy(True)\n cli.set_credentials(\"SIMPLE\", (user_dn, \"p@ssword\"))\n conn, ctrl = cli.connect()\n entry = conn.sear... | [
"0.724493",
"0.6853387",
"0.6759965",
"0.6680757",
"0.6673391",
"0.6658037",
"0.6648881",
"0.6550285",
"0.6506365",
"0.6450612",
"0.6411205",
"0.640502",
"0.63836986",
"0.6357806",
"0.633176",
"0.6331754",
"0.6254826",
"0.62233603",
"0.6222118",
"0.6218706",
"0.62045246",
"... | 0.6127447 | 26 |
Should require the gender if configured as 'required' but missing | def test_required_gender_missing(self):
self.url_params['gender'] = ''
response = self.client.post(self.url, self.url_params)
self.assertEqual(response.status_code, 400)
obj = json.loads(response.content)
self.assertEqual(
obj['value'],
u'Your gende... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validateGender(gender):\n if gender == \"male\" or gender == \"female\" or gender == None:\n return None\n else:\n return {'error': 'invalid value: %s (%s), valid values male/female/null' % (gender, pythonTypeToJSONType(gender))}",
"def test_set_gender_if_provided():\n\n # GIVEN a gend... | [
"0.7219572",
"0.6634468",
"0.65970063",
"0.6480768",
"0.63858426",
"0.6335253",
"0.6272775",
"0.6230633",
"0.61540526",
"0.6133486",
"0.60803473",
"0.60685843",
"0.6008421",
"0.59293175",
"0.591006",
"0.58833414",
"0.58833414",
"0.58833414",
"0.58833414",
"0.58820593",
"0.586... | 0.75155234 | 0 |
Checks that the right compentents are rendered for user with ``user_tag`` | def _check_split_test(self, user_tag):
# This explicitly sets the user_tag for self.student to ``user_tag``
UserCourseTagFactory(
user=self.student,
course_id=self.course.id,
key='xblock.partition_service.partition_{0}'.format(self.partition.id),
val... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_valid(self):\n if self.user_tag:\n return self.interface.is_tag_available(self.user_tag)\n return True",
"def should_render(\n self,\n *,\n context: Context,\n ) -> bool:\n request = context['request']\n user = request.user\n\n return (... | [
"0.6353422",
"0.6183934",
"0.6183934",
"0.6145261",
"0.60119146",
"0.5971634",
"0.5909282",
"0.5848663",
"0.5848663",
"0.57522833",
"0.57074344",
"0.57074344",
"0.56151223",
"0.557197",
"0.5557202",
"0.5557202",
"0.5529729",
"0.55149955",
"0.55149955",
"0.55149955",
"0.549953... | 0.5493033 | 21 |
Test that the lowest is dropped for a perfect score. | def test_dropping_all_correct(self):
self.dropping_setup()
self.dropping_homework_stage1()
for name in self.hw3_names:
self.submit_question_answer(name, {'2_1': 'Correct'})
self.check_grade_percent(1.0)
self.assertEqual(self.earned_hw_scores(), [1.0, 2.0, 2.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_score(self, score):\n self._evaluated = False\n self._min_score = score\n return self",
"def worst_score(self):\r\n pass",
"def test_score_is_greater() -> None:\n gp = PerimeterGoal(MELON_MAMBO)\n board = one_block_four_children_(1)\n sp = SmartPlayer(1, gp, 4)\n sp._proceed... | [
"0.66105527",
"0.65693235",
"0.640604",
"0.6335648",
"0.62698656",
"0.6246375",
"0.6244422",
"0.624272",
"0.6187786",
"0.6125517",
"0.6094523",
"0.6091136",
"0.60400873",
"0.59797764",
"0.59603393",
"0.5954682",
"0.5952835",
"0.59405303",
"0.5939436",
"0.59244365",
"0.5915284... | 0.0 | -1 |
Visits the about page for `course_id` and tests that both the text "Classes End", as well as the specified `expected_end_text`, is present on the page. If `expected_end_text` is None, verifies that the about page does not contain the text "Classes End". | def verify_end_date(self, course_id, expected_end_text=None):
request = self.request_factory.get("foo")
request.user = self.user
# TODO: Remove the dependency on MakoMiddleware (by making the views explicitly supply a RequestContext)
MakoMiddleware().process_request(request)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_render_page_wrong_course(self):\n url = reverse(\n 'completion_view', kwargs={\n 'course_id': 'course-v1:mss+MSS001+2019_2'})\n self.response = self.staff_client.get(url)\n self.assertEqual(self.response.status_code, 404)",
"def test_course_index_view_with_... | [
"0.59014523",
"0.58241904",
"0.58031934",
"0.5711362",
"0.5696689",
"0.5680008",
"0.5631544",
"0.55645037",
"0.5519088",
"0.5414101",
"0.531949",
"0.5312383",
"0.53070277",
"0.53016603",
"0.5294164",
"0.5294068",
"0.52862114",
"0.52843773",
"0.5258141",
"0.52400553",
"0.51645... | 0.8032192 | 0 |
Get the text of the /about page for the course. | def get_about_text(self, course_key):
text = views.course_about(self.request, course_key.to_deprecated_string()).content
return text | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_about_page_link(self):\r\n course_key = SlashSeparatedCourseKey('mitX', '101', 'test')\r\n return utils.get_lms_link_for_about_page(course_key)",
"def about():\n return render_template(\n 'about.html',\n title='About',\n year=datetime.now().year,\n message='ab... | [
"0.7443564",
"0.73169255",
"0.7137932",
"0.7098183",
"0.70952034",
"0.70932525",
"0.7085873",
"0.7085873",
"0.7085873",
"0.7085873",
"0.7085873",
"0.7085873",
"0.7085873",
"0.7085873",
"0.7085873",
"0.7085873",
"0.7085873",
"0.7085873",
"0.7085873",
"0.7067689",
"0.7053026",
... | 0.8059424 | 0 |
Make sure that before course start staff can access course pages. | def test_dark_launch_global_staff(self):
now = datetime.datetime.now(pytz.UTC)
tomorrow = now + datetime.timedelta(days=1)
self.course.start = tomorrow
self.test_course.start = tomorrow
self.course = self.update_course(self.course)
self.test_course = self.update_cou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_dashboard_no_courses(self):\r\n self.auth_page.visit()\r\n self.dashboard_page.visit()",
"def _check_staff(self, course):\r\n names = ['about_course', 'instructor_dashboard', 'progress']\r\n urls = self._reverse_urls(names, course)\r\n urls.extend([\r\n reve... | [
"0.70196754",
"0.69913894",
"0.6924134",
"0.6915165",
"0.6818831",
"0.6760227",
"0.6723985",
"0.67187625",
"0.6628042",
"0.6593737",
"0.6593737",
"0.6556709",
"0.65113074",
"0.6499573",
"0.64143586",
"0.6398963",
"0.6330481",
"0.63187367",
"0.6281235",
"0.62542385",
"0.622259... | 0.5890453 | 43 |
Return a redirect to the user's current place in the course. If this is the user's first time, redirects to COURSE/CHAPTER/SECTION. If this isn't the users's first time, redirects to COURSE/CHAPTER, and the view will find the current section and display a message about reusing the stored position. If there is no curren... | def redirect_to_course_position(course_module):
urlargs = {'course_id': course_module.id.to_deprecated_string()}
chapter = get_current_child(course_module)
if chapter is None:
# oops. Something bad has happened.
raise Http404("No chapter found when loading current position in course")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _redirect_from_referrer(self, request, wiki_path):\r\n course_id = course_id_from_url(request.META.get('HTTP_REFERER'))\r\n if course_id:\r\n # See if we are able to view the course. If we are, redirect to it\r\n try:\r\n _course = get_course_with_access(reque... | [
"0.56456167",
"0.55735767",
"0.52796894",
"0.50398815",
"0.50398815",
"0.5031314",
"0.50182664",
"0.4986582",
"0.49743968",
"0.49710816",
"0.48247632",
"0.48210764",
"0.47777393",
"0.47777393",
"0.47508505",
"0.47456136",
"0.47152755",
"0.46795118",
"0.46587256",
"0.46477833",
... | 0.69073355 | 0 |
Show the page that contains a specific location. If the location is invalid or not in any class, return a 404. Otherwise, delegates to the index view to figure out whether this user has access, and what they should see. | def jump_to(request, course_id, location):
try:
course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
usage_key = course_key.make_usage_key_from_deprecated_string(location)
except InvalidKeyError:
raise Http404(u"Invalid course_key or usage_key")
try:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index_route(self, request, *args, **kwargs):\n raise Http404()",
"def default(self, *args, **kwargs):\n Page = \"I don't know where you're trying to go, so have a 404 Error.\"\n cherrypy.response.status = 404\n return Page",
"def page_not_found(er):\n return render_template('... | [
"0.5929832",
"0.584182",
"0.5766436",
"0.57411546",
"0.57407564",
"0.57407564",
"0.57407564",
"0.57407564",
"0.57407564",
"0.57407564",
"0.57407564",
"0.5732912",
"0.5732912",
"0.5732912",
"0.5732912",
"0.5732912",
"0.5732912",
"0.5732912",
"0.5732912",
"0.5731505",
"0.570384... | 0.0 | -1 |
Return True if user is registered for course, else False | def registered_for_course(course, user):
if user is None:
return False
if user.is_authenticated():
return CourseEnrollment.is_enrolled(user, course.id)
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_registered(self):\n if self.user == getpass.getuser():\n return True\n else:\n return False",
"def user_auth_inst(request):\n if request.user.is_authenticated:\n user = User.objects.get(email=request.user.email)\n if UserInformation.objects.filter(user=... | [
"0.75303644",
"0.73451257",
"0.68669456",
"0.6841035",
"0.669902",
"0.66339856",
"0.6618475",
"0.65667236",
"0.65413064",
"0.65055734",
"0.6445795",
"0.64241713",
"0.63875294",
"0.63701034",
"0.6359003",
"0.6355362",
"0.6329029",
"0.6324901",
"0.6309324",
"0.62689126",
"0.626... | 0.85251474 | 0 |
Display the course's about page. Assumes the course_id is in a valid format. | def course_about(request, course_id):
if microsite.get_value(
'ENABLE_MKTG_SITE',
settings.FEATURES.get('ENABLE_MKTG_SITE', False)
):
raise Http404
course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
course = get_course_with_access(request.user, 'see_e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mktg_course_about(request, course_id):\r\n\r\n course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)\r\n try:\r\n course = get_course_with_access(request.user, 'see_exists', course_key)\r\n except (ValueError, Http404) as e:\r\n # if a course does not exist yet, display ... | [
"0.78882277",
"0.7216142",
"0.7066893",
"0.70590043",
"0.70485044",
"0.70485044",
"0.70485044",
"0.70485044",
"0.70485044",
"0.70485044",
"0.70485044",
"0.70485044",
"0.70485044",
"0.70485044",
"0.70485044",
"0.70485044",
"0.70485044",
"0.701464",
"0.7007945",
"0.7005768",
"0... | 0.73405665 | 1 |
View that, given a course_id, returns the a JSON object that enumerates all of the LTI endpoints for that course. The LTI 2.0 result service spec at | def get_course_lti_endpoints(request, course_id):
try:
course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
except InvalidKeyError:
return HttpResponse(status=404)
try:
course = get_course(course_key, depth=2)
except ValueError:
return HttpResp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _course_json(request, course_key):\r\n course_module = _get_course_module(course_key, request.user, depth=None)\r\n return _xmodule_json(course_module, course_module.id)",
"def list_all_courses(request):\r\n courses = Course.objects.all()\r\n courses = [dict(course_name = c.course_name, course_co... | [
"0.63766736",
"0.636873",
"0.6343846",
"0.62430626",
"0.62356764",
"0.61549497",
"0.5994301",
"0.59463197",
"0.5943078",
"0.59215456",
"0.5896985",
"0.5863846",
"0.5855248",
"0.58319736",
"0.5816822",
"0.5790645",
"0.57805103",
"0.57155555",
"0.5695932",
"0.5603481",
"0.56022... | 0.7796113 | 0 |
Is user allowed to restore or purge article? | def CAN_MODERATE(article, user): # pylint: disable=invalid-name
return _is_staff_for_article(article, user) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_modify(article):\n return authenticated() and article.adder_id == session['user_id']",
"def CAN_DELETE(article, user): # pylint: disable=invalid-name\r\n return _is_staff_for_article(article, user)",
"def _may_user_access_osmaxx_frontend(user):\n return user.has_perm('excerptexport.add_extrac... | [
"0.6664482",
"0.6647211",
"0.6205739",
"0.61930233",
"0.61582756",
"0.6146344",
"0.6100056",
"0.60931545",
"0.59488714",
"0.59423566",
"0.5898547",
"0.5896011",
"0.5892804",
"0.5892048",
"0.5888606",
"0.5885734",
"0.5874261",
"0.5844977",
"0.5844977",
"0.5840939",
"0.5840939"... | 0.5701767 | 40 |
Is user allowed to change permissions on article? | def CAN_CHANGE_PERMISSIONS(article, user): # pylint: disable=invalid-name
return _is_staff_for_article(article, user) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_modify(article):\n return authenticated() and article.adder_id == session['user_id']",
"def CAN_MODERATE(article, user): # pylint: disable=invalid-name\r\n return _is_staff_for_article(article, user)",
"def test_permissions(self):\n taxonomy = self.get_taxonomy()\n return True if s... | [
"0.8107636",
"0.7784639",
"0.74873614",
"0.7465038",
"0.7263506",
"0.72360396",
"0.72003275",
"0.71993333",
"0.71993333",
"0.7189999",
"0.71300256",
"0.70978373",
"0.70897615",
"0.7083018",
"0.7070742",
"0.70409787",
"0.70155567",
"0.70033544",
"0.6972177",
"0.69704753",
"0.6... | 0.8283427 | 0 |
Test that requesting wiki URLs redirect properly to or out of classes. An enrolled in student going from /courses/edX/toy/2012_Fall/progress to /wiki/some/fake/wiki/page/ will redirect to /courses/edX/toy/2012_Fall/wiki/some/fake/wiki/page/ An unenrolled student going to /courses/edX/toy/2012_Fall/wiki/some/fake/wiki/p... | def test_wiki_redirect(self):
self.login(self.student, self.password)
self.enroll(self.toy)
referer = reverse("progress", kwargs={'course_id': self.toy.id.to_deprecated_string()})
destination = reverse("wiki:get", kwargs={'path': 'some/fake/wiki/page/'})
redirected_to ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_wiki_not_accessible_when_not_enrolled(self):\r\n\r\n self.login(self.instructor, self.password)\r\n self.enroll(self.toy)\r\n self.create_course_page(self.toy)\r\n\r\n self.login(self.student, self.password)\r\n course_wiki_page = reverse('wiki:get', kwargs={'path': self... | [
"0.7237849",
"0.6905572",
"0.68849975",
"0.6689792",
"0.6674032",
"0.6597808",
"0.65193987",
"0.64937717",
"0.64500207",
"0.6398437",
"0.6371821",
"0.6369851",
"0.63490593",
"0.63471794",
"0.6327473",
"0.62549496",
"0.6244119",
"0.6127698",
"0.6125441",
"0.60739255",
"0.59780... | 0.81521636 | 0 |
Ensure that the response has the course navigator. | def has_course_navigator(self, resp):
self.assertContains(resp, "Course Info")
self.assertContains(resp, "courseware") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_course_navigator(self):\r\n\r\n self.login(self.student, self.password)\r\n self.enroll(self.toy)\r\n self.create_course_page(self.toy)\r\n\r\n course_wiki_page = reverse('wiki:get', kwargs={'path': self.toy.wiki_slug + '/'})\r\n referer = reverse(\"courseware\", kwargs=... | [
"0.6945498",
"0.61166066",
"0.60580057",
"0.594798",
"0.59300697",
"0.58643454",
"0.5861905",
"0.58230793",
"0.5819565",
"0.5810731",
"0.57919854",
"0.57705224",
"0.5760387",
"0.5760387",
"0.5751489",
"0.5670441",
"0.5660648",
"0.5651954",
"0.56351554",
"0.5634622",
"0.563207... | 0.81570566 | 0 |
The root of a course wiki is /. This means in case there are two courses which have the same course_number they will end up with the same course wiki root e.g. MITx/Phy101/Spring and HarvardX/Phy101/Fall will share /Phy101. This looks at the course wiki root of the article and returns True if the user belongs to a grou... | def user_is_article_course_staff(user, article):
wiki_slug = article_course_wiki_root_slug(article)
if wiki_slug is None:
return False
# The wiki expects article slugs to contain at least one non-digit so if
# the course number is just a number the course wiki root slug is set to
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_restricted(self, real_path):\n if real_path.find(self._root) != 0:\n return True\n\n # get rid of the root part plus the following /\n real_path = real_path[len(self._root)+1:]\n for folder in self._restricted_folders:\n if real_path.find(folder) == 0:\n ... | [
"0.5548856",
"0.5450464",
"0.5372171",
"0.5296278",
"0.5260629",
"0.5254753",
"0.52451664",
"0.5237185",
"0.5197548",
"0.51874804",
"0.5163656",
"0.51087976",
"0.5107301",
"0.5102986",
"0.5079998",
"0.50668645",
"0.5047601",
"0.50230694",
"0.50102156",
"0.5005141",
"0.4985505... | 0.569964 | 0 |
Returns whether the slug can be interpreted as a number. | def slug_is_numerical(slug):
try:
float(slug)
except ValueError:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isnumber(n):\r\n N = str(n)\r\n if N.isdigit():\r\n return True\r\n else:\r\n return False",
"def is_number(text):\n return text.lower() in AVRO_NUMBERS",
"def isnum(self, x):\n\n return x in '1234567890.-'",
"def is_number(self) -> bool:\n return False",
"def is... | [
"0.7338984",
"0.7320732",
"0.7296679",
"0.7289426",
"0.72743684",
"0.7212811",
"0.7182385",
"0.70439243",
"0.7043254",
"0.6932011",
"0.69314873",
"0.69154245",
"0.68937373",
"0.6859537",
"0.68534786",
"0.6802866",
"0.6800903",
"0.67799634",
"0.67790836",
"0.67591286",
"0.6732... | 0.8595435 | 0 |
This redirects to whatever page on the wiki that the course designates as it's home page. A course's wiki must be an article on the root (for example, "/6.002x") to keep things simple. | def course_wiki_redirect(request, course_id): # pylint: disable=W0613
course = get_course_by_id(SlashSeparatedCourseKey.from_deprecated_string(course_id))
course_slug = course_wiki_slug(course)
valid_slug = True
if not course_slug:
log.exception("This course is improperly configured. The... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_wiki_redirect(self):\r\n self.login(self.student, self.password)\r\n\r\n self.enroll(self.toy)\r\n\r\n referer = reverse(\"progress\", kwargs={'course_id': self.toy.id.to_deprecated_string()})\r\n destination = reverse(\"wiki:get\", kwargs={'path': 'some/fake/wiki/page/'})\r\n\... | [
"0.6843388",
"0.6822684",
"0.66886556",
"0.66886556",
"0.66772145",
"0.6670284",
"0.66561073",
"0.6481921",
"0.6354425",
"0.635022",
"0.6321896",
"0.6317613",
"0.62347823",
"0.6111296",
"0.6035912",
"0.59991616",
"0.5986384",
"0.5879225",
"0.58712155",
"0.5869879",
"0.5867036... | 0.75486106 | 0 |
Test repo that is in detached head state. | def test_detached_repo(self):
repo_dir = self.GIT_REPO_DIR
# Test successful import from command
try:
os.mkdir(repo_dir)
except OSError:
pass
self.addCleanup(shutil.rmtree, repo_dir)
git_import.add_repo(self.TEST_REPO, repo_dir / 'edx4edx_l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_head_detached(repository: Repository) -> None:\n repository._repository.set_head(repository.head.commit.id)\n with pytest.raises(ValueError):\n repository.head",
"def test_detached_head(tmpdir):\n repo = Repo.init(path=tmpdir)\n tmppath = pathlib.Path(tmpdir)\n\n index = repo.index... | [
"0.7689153",
"0.73909396",
"0.6961982",
"0.6564489",
"0.6503445",
"0.64368033",
"0.63902026",
"0.6283895",
"0.62466574",
"0.62373453",
"0.6221233",
"0.62158716",
"0.6179471",
"0.6146083",
"0.6108963",
"0.60782236",
"0.6069705",
"0.6038691",
"0.60216635",
"0.6010847",
"0.60055... | 0.75938356 | 1 |
Returns the datatable used for this view | def make_common_context(self):
self.datatable = {}
self.datatable = dict(header=[_('Statistic'), _('Value')],
title=_('Site statistics'))
self.datatable['data'] = [[_('Total number of users'),
User.objects.all().count()]]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chart_data_table(self):\n return self.container['chart_data_table']",
"def get_table_data(self):\n return self.table_data",
"def get_data_for_table(self):\n self._set_data_for_table()\n return self._data_for_table",
"def get_df(self):\n return self.df",
"def get_df(se... | [
"0.7438795",
"0.7371454",
"0.72080076",
"0.6965129",
"0.6961679",
"0.6947768",
"0.68977004",
"0.68411124",
"0.6768324",
"0.6705651",
"0.6629084",
"0.6608896",
"0.6608896",
"0.66028774",
"0.65548384",
"0.65521985",
"0.65285486",
"0.65094364",
"0.65047735",
"0.64984983",
"0.645... | 0.0 | -1 |
Ensure course team users are allowed to access only their own course. | def test_gitlog_courseteam_access(self):
self._mkdir(getattr(settings, 'GIT_REPO_DIR'))
self._setstaff_login()
self._add_edx4edx()
self.user.is_staff = False
self.user.save()
logged_in = self.client.login(username=self.user.username,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_access(self):\n if not has_course_staff_privileges(self.request.user, self.course.id):\n raise PermissionDenied(\n \"To manage team membership of {}, you must be course staff.\".format(\n self.course.id\n )\n )",
"def access_... | [
"0.7125422",
"0.6545926",
"0.65115815",
"0.64699715",
"0.64619476",
"0.6413487",
"0.6259432",
"0.62483895",
"0.6243291",
"0.623053",
"0.6223485",
"0.62008095",
"0.61251277",
"0.60887367",
"0.60868996",
"0.60806936",
"0.60790604",
"0.6074304",
"0.6074304",
"0.6055418",
"0.6052... | 0.5611804 | 89 |
given a course_id and comment_id, update the comment with payload attributes handles static and ajax submissions | def update_comment(request, course_id, comment_id):
comment = cc.Comment.find(comment_id)
if 'body' not in request.POST or not request.POST['body'].strip():
return JsonError(_("Body can't be empty"))
comment.body = request.POST["body"]
comment.save()
if request.is_ajax():
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_comment():\n # Implement me!\n\n logger.info(\"vars: %r\" % request.vars)\n logger.info(\"vars_comment_text: %r\" % request.vars.comment_text)\n logger.info(\"vars id: %r\" % request.vars.comment_id)\n logger.info(\"comment_text: %r\" % db(db.Comments.id == request.vars.comment_id))\n\n ... | [
"0.67796344",
"0.66515034",
"0.6601699",
"0.65747607",
"0.65382206",
"0.6444549",
"0.6433368",
"0.6418978",
"0.63031423",
"0.62520856",
"0.6188447",
"0.61686057",
"0.61664134",
"0.6134872",
"0.6102889",
"0.60437495",
"0.6030755",
"0.602387",
"0.602387",
"0.5993579",
"0.599191... | 0.7903285 | 0 |
Given the email and passed in value (str), return the expected verification code. | def verify_code(email, val):
# TODO: is this the right string?
verification_string = email.lower() + '|' + val
return hashlib.md5(verification_string).hexdigest() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_email(self, value):\n verifier = EmailVerifier(value)\n if not verifier.is_valid():\n if verifier.errors:\n raise serializers.ValidationError(verifier.errors)\n error_code = verifier.data.get('result', 'unknown_error')\n if verifier.status_... | [
"0.6917",
"0.6775107",
"0.66332495",
"0.6553821",
"0.64792866",
"0.6476687",
"0.641848",
"0.6357939",
"0.6194508",
"0.61753875",
"0.61486405",
"0.6130494",
"0.6128021",
"0.61058056",
"0.6096686",
"0.6093118",
"0.6047934",
"0.60228086",
"0.6017826",
"0.600875",
"0.5994582",
... | 0.7963479 | 0 |
Unenroll a student by email. `student_email` is student's emails e.g. "foo.com" `email_students` determines if student should be notified of action by email. `email_params` parameters used while parsing email templates (a `dict`). returns two EmailEnrollmentState's representing state before and after the action. | def unenroll_email(course_id, student_email, email_students=False, email_params=None):
previous_state = EmailEnrollmentState(course_id, student_email)
if previous_state.enrollment:
CourseEnrollment.unenroll_by_email(student_email, course_id)
if email_students:
email_params['me... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unenroll_by_email(cls, email, course_id):\r\n try:\r\n user = User.objects.get(email=email)\r\n return cls.unenroll(user, course_id)\r\n except User.DoesNotExist:\r\n err_msg = u\"Tried to unenroll email {} from course {}, but user not found\"\r\n log.e... | [
"0.73115504",
"0.7244278",
"0.67865914",
"0.6171541",
"0.6133704",
"0.5882073",
"0.555865",
"0.55282885",
"0.5452572",
"0.5451925",
"0.5373598",
"0.537203",
"0.5352314",
"0.5182686",
"0.51029474",
"0.4986507",
"0.49422893",
"0.48337644",
"0.48273993",
"0.48059508",
"0.4803695... | 0.87865967 | 0 |
Used to return whether course has Shibboleth as the enrollment domain Returns a boolean indicating if Shibboleth authentication is set for this course. | def uses_shib(course):
return course.enrollment_domain and course.enrollment_domain.startswith(SHIBBOLETH_DOMAIN_PREFIX) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_frozensand_auth_available(self):\n cvar = self.getCvar('auth')\n if cvar:\n auth = cvar.getInt()\n return auth != 0\n else:\n return False",
"def is_bothell_student():\n return _is_member('uw_affiliation_bothell-student')",
"def can_log_in_without... | [
"0.6333624",
"0.63209385",
"0.60733056",
"0.60253274",
"0.5950663",
"0.5888397",
"0.58029085",
"0.5799935",
"0.575448",
"0.5749943",
"0.5730417",
"0.57285565",
"0.5707601",
"0.5704415",
"0.5689181",
"0.5684532",
"0.5653466",
"0.56510985",
"0.56244993",
"0.5612999",
"0.5612999... | 0.71210855 | 1 |
Asserts that accessing the given `endpoint` gets a response of `status_code`. | def _access_endpoint(self, endpoint, args, status_code, msg):
url = reverse(endpoint, kwargs={'course_id': self.course.id.to_deprecated_string()})
if endpoint in ['send_email']:
response = self.client.post(url, args)
else:
response = self.client.get(url, args)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert_status_code(response, status):\n assert response.status_code == status",
"def test_status_code(self):\n assert self.detail_response.status_code == 200",
"def test_response_status():\n\n status_code = 400\n retval = apigateway.response(\"Message\", status_code)\n assert retval[\"st... | [
"0.7656304",
"0.70859385",
"0.70849204",
"0.70540833",
"0.70301896",
"0.7014528",
"0.69920486",
"0.69626063",
"0.6957905",
"0.69553757",
"0.6933571",
"0.68789095",
"0.6861854",
"0.6845359",
"0.6835022",
"0.67479205",
"0.6729876",
"0.67288977",
"0.67282873",
"0.671144",
"0.661... | 0.6594142 | 21 |
Test missing all query parameters. | def test_missing_params(self):
url = reverse('students_update_enrollment', kwargs={'course_id': self.course.id.to_deprecated_string()})
response = self.client.get(url)
self.assertEqual(response.status_code, 400) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unspecified_excluded(self):\n handler = self.create_handler(r'unspecified1=foo&unspecified2=5')\n self.assertEqual(handler.get_params(), {})",
"def test_missing_required(self):\n param_types = {\n 'string': str,\n 'unicode': unicode,\n 'integer': int... | [
"0.7126219",
"0.679801",
"0.67690396",
"0.6741716",
"0.6725646",
"0.669974",
"0.6687397",
"0.66828966",
"0.6645133",
"0.6641524",
"0.6563922",
"0.6557512",
"0.65499204",
"0.65497726",
"0.652759",
"0.6515057",
"0.65111923",
"0.6451922",
"0.6426107",
"0.6363816",
"0.635193",
... | 0.6110607 | 40 |
Test missing all query parameters. | def test_missing_params(self):
url = reverse('bulk_beta_modify_access', kwargs={'course_id': self.course.id.to_deprecated_string()})
response = self.client.get(url)
self.assertEqual(response.status_code, 400) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unspecified_excluded(self):\n handler = self.create_handler(r'unspecified1=foo&unspecified2=5')\n self.assertEqual(handler.get_params(), {})",
"def test_missing_required(self):\n param_types = {\n 'string': str,\n 'unicode': unicode,\n 'integer': int... | [
"0.7127251",
"0.67988014",
"0.6770091",
"0.67419416",
"0.67252225",
"0.6698752",
"0.66880447",
"0.66842455",
"0.6644828",
"0.6644126",
"0.65643525",
"0.65499425",
"0.6548345",
"0.6528742",
"0.6514254",
"0.65115935",
"0.6452918",
"0.6424865",
"0.6364997",
"0.63504666",
"0.6329... | 0.6558517 | 11 |
Test missing all query parameters. | def test_modify_access_noparams(self):
url = reverse('modify_access', kwargs={'course_id': self.course.id.to_deprecated_string()})
response = self.client.get(url)
self.assertEqual(response.status_code, 400) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unspecified_excluded(self):\n handler = self.create_handler(r'unspecified1=foo&unspecified2=5')\n self.assertEqual(handler.get_params(), {})",
"def test_missing_required(self):\n param_types = {\n 'string': str,\n 'unicode': unicode,\n 'integer': int... | [
"0.7126219",
"0.679801",
"0.67690396",
"0.6741716",
"0.6725646",
"0.669974",
"0.6687397",
"0.66828966",
"0.6645133",
"0.6641524",
"0.6563922",
"0.6557512",
"0.65499204",
"0.65497726",
"0.652759",
"0.6515057",
"0.65111923",
"0.6451922",
"0.6426107",
"0.6363816",
"0.635193",
... | 0.0 | -1 |
Test with an invalid action parameter. | def test_modify_access_bad_action(self):
url = reverse('modify_access', kwargs={'course_id': self.course.id.to_deprecated_string()})
response = self.client.get(url, {
'unique_student_identifier': self.other_staff.email,
'rolename': 'staff',
'action': 'robot-not-a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bad_action(self):\r\n action = 'robot-not-an-action'\r\n url = reverse('bulk_beta_modify_access', kwargs={'course_id': self.course.id.to_deprecated_string()})\r\n response = self.client.get(url, {'identifiers': self.beta_tester.email, 'action': action})\r\n self.assertEqual(res... | [
"0.76586306",
"0.72435814",
"0.71517026",
"0.71287143",
"0.7116332",
"0.67044556",
"0.6523515",
"0.6460687",
"0.64346725",
"0.637539",
"0.63585573",
"0.6340017",
"0.6340017",
"0.63109213",
"0.6292523",
"0.62799144",
"0.6258393",
"0.62145853",
"0.6203797",
"0.62011826",
"0.615... | 0.6738869 | 5 |
Test with an invalid action parameter. | def test_modify_access_bad_role(self):
url = reverse('modify_access', kwargs={'course_id': self.course.id.to_deprecated_string()})
response = self.client.get(url, {
'unique_student_identifier': self.other_staff.email,
'rolename': 'robot-not-a-roll',
'action': 're... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bad_action(self):\r\n action = 'robot-not-an-action'\r\n url = reverse('bulk_beta_modify_access', kwargs={'course_id': self.course.id.to_deprecated_string()})\r\n response = self.client.get(url, {'identifiers': self.beta_tester.email, 'action': action})\r\n self.assertEqual(res... | [
"0.7658963",
"0.7244518",
"0.7152294",
"0.71292",
"0.71167237",
"0.67394805",
"0.6704666",
"0.65240884",
"0.64618355",
"0.6435548",
"0.63764995",
"0.63582385",
"0.6338813",
"0.6338813",
"0.63106215",
"0.6292061",
"0.62800866",
"0.62589335",
"0.62146664",
"0.62038964",
"0.6201... | 0.0 | -1 |
Test missing all query parameters. | def test_list_course_role_members_noparams(self):
url = reverse('list_course_role_members', kwargs={'course_id': self.course.id.to_deprecated_string()})
response = self.client.get(url)
self.assertEqual(response.status_code, 400) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unspecified_excluded(self):\n handler = self.create_handler(r'unspecified1=foo&unspecified2=5')\n self.assertEqual(handler.get_params(), {})",
"def test_missing_required(self):\n param_types = {\n 'string': str,\n 'unicode': unicode,\n 'integer': int... | [
"0.7127251",
"0.67988014",
"0.6770091",
"0.67419416",
"0.67252225",
"0.6698752",
"0.66880447",
"0.66842455",
"0.6644828",
"0.6644126",
"0.65643525",
"0.6558517",
"0.65499425",
"0.6548345",
"0.6528742",
"0.6514254",
"0.65115935",
"0.6452918",
"0.6424865",
"0.6364997",
"0.63504... | 0.0 | -1 |
Test with an invalid rolename parameter. | def test_list_course_role_members_bad_rolename(self):
url = reverse('list_course_role_members', kwargs={'course_id': self.course.id.to_deprecated_string()})
response = self.client.get(url, {
'rolename': 'robot-not-a-rolename',
})
self.assertEqual(response.status_code, 40... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _assert_valid_name(name, container):\n container.file.name_validation(container.directory, name)",
"def validname(name):\r\n return len(name)>0 and (\r\n Context.__invalid_character.search(name) is None)",
"def test_is_valid_kubernetes_resource_name_invalid_input():\n # test length ... | [
"0.6147081",
"0.601775",
"0.6007219",
"0.5915931",
"0.5860429",
"0.5799295",
"0.5746872",
"0.572036",
"0.5716759",
"0.571531",
"0.5705997",
"0.5690729",
"0.56686085",
"0.5668601",
"0.5638399",
"0.56012434",
"0.559468",
"0.5556731",
"0.5551577",
"0.5541939",
"0.5539702",
"0.... | 0.62736845 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.